akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

void dfs(vector<set<int>>&g, vector<int>&f, int p) {
	if (f[p])return;
	f[p] = 1;
	for (auto &o : g[p]) {
		dfs(g, f, o);
	}

}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M; cin >> N >> M;
	vector<int> a(M), b(M); rep(i, 0, M) { cin >> a[i] >> b[i]; a[i]--, b[i]--; }
	vector<set<int>>G(N);
	rep(i, 0, M) {
		G[a[i]].insert(b[i]);
		G[b[i]].insert(a[i]);
	}
	int ans(0);
	rep(i, 0, M) {
		G[a[i]].erase(b[i]);
		G[b[i]].erase(a[i]);
		vector<int>f(N, 0);
		dfs(G, f, 0);
		dump(f);
		ans += (accumulate(all(f), 0) != N);
		G[a[i]].insert(b[i]);
		G[b[i]].insert(a[i]);

	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
    ll X,Y;cin>>X>>Y;
    int ans=1;
    while(true){
        if(X*2<=Y){
            X*=2;
            ans++;
        }
        else break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

#define ALL(x) x.begin(), x.end()

typedef long long int lld;
typedef pair<int, int> pii;

const int maxn = 2e5+5;

vector<int> mat[maxn];
int add[maxn] = { 0 };

void func(int now, int v) {
	for (int i = 0; i < mat[now].size(); i++) {
		func(mat[now][i], add[mat[now][i]] + v);
	}
	add[now] = v;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(15);
	cout << fixed;

	int n, q;
	cin >> n >> q;
	

	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		mat[a].push_back(b);
	}

	while (q--) {
		int a, b;
		cin >> a >> b;
		add[a] += b;
	}

	func(1, add[1]);

	for (int i = 1; i <= n; i++) {
		if(i == 1)
			cout << add[i];
		else
			cout << ' ' << add[i];
	}
	cout << endl;

	

	return 0;
}

Measured memory_bytes: 23552
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int a[3];
	for(int i=0;i<3;i++)
	cin>>a[i];
	sort(a,a+3);
	if(a[0]==a[1]&&a[1]!=a[2])
	cout<<"Yes"<<endl;
	else if(a[0]!=a[1]&&a[1]==a[2])
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl; 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <vector>

using namespace std;
typedef long long LL;
#define pb push_back
const int maxn = 300005;

vector<int> adj[maxn],tre[maxn];
int w[maxn],n,ord[maxn],in[maxn],out[maxn],cnt;

bool comp(int a,int b) {return w[a]<w[b];}

#define ls rt<<1
#define rs rt<<1|1
void build(int rt,int L,int R)
{
	if (L==R) {
		in[rt]=ord[L]^1;
		out[rt]=ord[L];
		return ;
	}
	in[rt]=++cnt;out[rt]=++cnt;
	int mid=L+R>>1;
	build(ls,L,mid);
	build(rs,mid+1,R);
	tre[in[rt]].pb(in[ls]);
	tre[in[rt]].pb(in[rs]);
	tre[out[ls]].pb(out[rt]);
	tre[out[rs]].pb(out[rt]);
}
void modify(int rt,int L,int R,int l,int r,int i,int j)
{
	if (L>=l&&R<=r) {
		adj[i].pb(in[rt]);
		adj[out[rt]].pb(j);
		return ;
	}
	int mid=L+R>>1;
	if (l<=mid) modify(ls,L,mid,l,r,i,j);
	if (r>mid) modify(rs,mid+1,R,l,r,i,j);
}

int low[maxn],dfn[maxn],idx,iscc,scc[maxn];
bool ins[maxn];int stk[maxn],top;
void tarjan(int u)
{
	low[u]=dfn[u]=++idx;stk[++top]=u;ins[u]=true;
	for (unsigned i=0;i<adj[u].size();i++)
	{
		int v=adj[u][i];
		if (!dfn[v]) tarjan(v),low[u]=min(low[u],low[v]);
		else if (ins[v]) low[u]=min(low[u],dfn[v]);
	}
	for (unsigned i=0;i<tre[u].size();i++)
	{
		int v=tre[u][i];
		if (!dfn[v]) tarjan(v),low[u]=min(low[u],low[v]);
		else if (ins[v]) low[u]=min(low[u],dfn[v]);
	}
	if (low[u]==dfn[u]) {
		scc[u]=++iscc;
		while (stk[top]!=u) {
			int v=stk[top--];
			ins[v]=false;scc[v]=iscc;
		}
		ins[u]=false;top--;
	}
}
bool check(int dis)
{
	idx=iscc=top=0;
	for (int i=2;i<=cnt;i++)
		adj[i].clear(),dfn[i]=0;
	for (int l=1,i=1;i<=n<<1;i++)
	{
		while (w[ord[i]]-w[ord[l]]>=dis) ++l;
		if (l<i) modify(1,1,n<<1,l,i-1,ord[i],ord[i]^1);
	}
	for (int i=2;i<=(n<<1|1);i++)
		if (!dfn[i]) tarjan(i);
	
	for (int i=1;i<=n;i++)
		if (scc[i<<1]==scc[i<<1|1]) return false;
	return true;
}
int main()
{
	#ifdef Amberframe
		freopen("arc069f.in","r",stdin);
		freopen("arc069f.out","w",stdout);
	#endif
	scanf("%d",&n);
	for (int i=2;i<=n<<1;i+=2)	
		scanf("%d %d",&w[i],&w[i^1]),ord[i-1]=i,ord[i]=i^1;
	sort(ord+1,ord+(n<<1)+1,comp);
	cnt=n<<1|1;build(1,1,n<<1);
	
	int lb=1<<30,rb=w[ord[n<<1]]-w[1]+1;
	for (int i=2;i<=(n<<1);i++)
		lb=min(lb,w[ord[i]]-w[ord[i-1]]);
	while (rb-lb>1) {
		int mid=lb+rb>>1;
		check(mid)?lb=mid:rb=mid;
	}
	printf("%d",lb);
	return 0;
}

Measured memory_bytes: 33792
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) x.begin(), x.end()

#define mp make_pair
#define in insert
#define er erase
#define con continue
#define pb push_back
#define sc scanf
#define pr printf
#define ub upper_bound
#define lb lower_bound
#define s second
#define f first
#define int long long

const long long infl = 1e18; 
const int N = 3e5 + 300, N2 = 2e3, inf = 1e18 + 200;

int a[N], L[N], bestL[N], bestR[N], R[N], n;

main(){
	cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        L[i] = a[i];
        if (i >= 2) L[i] += L[i - 2];
    }
    for (int i = 1; i < n; i += 2)
        bestL[i] = max(L[i - 1], a[i] + (i - 2 >= 0? bestL[i - 2]: 0));
    if (n % 2 == 0) {
       	cout << bestL[n - 1];
        return 0;
    }
    for (int i = n - 1; i >= 0; i--) {
        R[i] = a[i];
        if (i + 2 < n) R[i] += R[i + 2];
    }
    for (int i = n - 2; i >= 0; i -= 2)
        bestR[i] = max(R[i + 1], a[i] + (i + 2 < n? bestR[i + 2]: 0));
    int res = L[n - 2];
    for (int i = 0; i + 1 < n; i++){
        if (i % 2 == 0) {
            int cand = 0;
            if (i - 1 >= 0) cand += bestL[i - 1];
            if (i + 2 < n) cand += R[i + 2];
            res = max(res, cand);
        } else {
            int cand = 0;
            if (i - 1 >= 0) cand += L[i - 1];
            if (i + 2 < n) cand += bestR[i + 2];
            res = max(res, cand);
        }
    }
    cout << res << endl;
    return 0;
}












Measured memory_bytes: 11452
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int card[210];
int n,m;

void r(){
	int c[210];
	int i;
	for(i=0;i<n;i++){
		c[2*i]=card[i];
		c[2*i+1]=card[n+i];
	}
	for(i=0;i<2*n;i++)card[i]=c[i];
}

void c(int k){
	int c[210];
	int i;
	for(i=0;i<2*n;i++){
		if(i<2*n-k)c[i]=card[k+i];
		else c[i]=card[i-2*n+k];
	}
	for(i=0;i<2*n;i++)card[i]=c[i];
}

int main() {
	n=in();
	m=in();
	int i;
	for(i=0;i<2*n;i++)card[i]=i;
	while(m--){
		int s;
		cin>>s;
		if(s)c(s);
		else r();
//for(i=0;i<2*n;i++)cout<<card[i]<<endl;
	}
	for(i=0;i<2*n;i++)cout<<card[i]+1<<endl;
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

#define rep(i, n)for((i) = 0;(i) < (n);++(i))

int main(void){
	int h, w, i;
	scanf("%d%d", &h, &w);
	string s;
	rep(i, h){
		cin >> s;
		cout << s << "\n";
		cout << s << "\n";
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int num = scanner.nextInt();
        for (int i = 0; i < num; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int c = scanner.nextInt();

            if (isRightTriAngle(a, b, c)) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }

    static boolean isRightTriAngle(int side_a, int side_b, int side_c) {
        int[] sides = { side_a, side_b, side_c };
        Arrays.sort(sides);

        int a_2 = (int)Math.pow(sides[0], 2);
        int b_2 = (int)Math.pow(sides[1], 2);
        int c_2 = (int)Math.pow(sides[2], 2);

        return a_2 + b_2 == c_2;
    }

}

Measured memory_bytes: 33592
#include <bits/stdc++.h>
#include <vector>
#define rep(i,n) for (int i = 0;i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;


void solve(long long A, long long B, long long C){
    if(A*C <= B){
        cout << C << endl;
    } else {
        cout << B / A << endl;
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,p,ans;
  cin >> n >> p;
  if(n==1){
    cout << p << endl;
    return 0;
  }
  if(n>40){
    cout << 1 << endl;
    return 0;
  }
  for(ll i=1;i<=p;i++){
    ll gcd=pow(i,n);
    if(p%gcd==0){
      ans=i;
    }else if(gcd>p){
      break;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
n = int(input())
w = [str(input()) for _ in range(n)]

if len(set(w)) != n:
	print('No')
	exit()
memo = w[0][0]
for i in range(n):
	a = w[i]
	if a[0] != memo:
		print('No')
		exit()
	memo = a[-1]
print('Yes')


Measured memory_bytes: 3068
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d %d",&a,&b);
	
	if(a%(b*2+1)==0)printf("%d\n",a/(b*2+1));
	else printf("%d\n",a/(b*2+1)+1);
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[212345];
int main(){
	scanf("%s", s);
	int a = 0, n = strlen(s);
	REP(i, n) a += s[i] - '0';
	if(a % 9 == 0) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 3864
n = int(input())
ans = 0
for i in range(n):
    ans += (i + 1) * (n - i)
for i in range(n - 1):
    u, v = map(int, input().split())
    u, v = min(u, v), max(u, v)
    ans -= u * (n - v + 1)
print(ans)

Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    char x;
    scan(x);
    x+=1;
    print(x);


    return 0;
}

Measured memory_bytes: 256
X, N = map(int, input().split())
V_RANGE = 102

# 0,1~100,101
data_list = [i for i in range(V_RANGE)]
# 取得リスト
get_list = list(map(int, input().split()))

# (data_list-in_value)のリストを作る
sub_list = set(data_list) - set(get_list)

# 絶対値が最小のものを取得
g_abs = 10**4
abs_value = 0
for i in sub_list:
	t_abs = abs(X - i)

	if(g_abs > t_abs):
		g_abs = t_abs
		abs_value = i

print(abs_value)

Measured memory_bytes: 9044
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main(){
  char c;
  cin>>c;
  cout<<(char)(c+1)<<endl;
  return 0;
}


Measured memory_bytes: 888
N,M=map(int,input().split())
H=list(map(int,input().split()))

good=[True]*N

for _ in range(M):
    A,B=map(int,input().split())
    A,B=A-1,B-1
    if H[A]<=H[B]:
        good[A]=False
    if H[B]<=H[A]:
        good[B]=False

ans=0
for g in good:
    if g:
        ans+=1
print(ans)


Measured memory_bytes: 20000
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n, k;
vector<int> a(110, 0);
vector<bool> dp(100100, false);

int main() {
    cin >> n >> k;
    for(int i = 0; i < n; ++i) cin >> a.at(i);

    for(int i = 0; i <= k; ++i) {
        for(int j = 0; j < n; ++j) {
            // 自分の今の一手がa.at(j), dp[i-a.at(j)]がfalseならもう相手は詰みだということがわかる
            // そこでdp[i]は勝ち状態になる
            if(i-a.at(j) >= 0 && dp[i-a.at(j)] == false) dp[i] = true;
        }
    }

    if(dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n,m;
  cin >> n >> m;
  int a[n];
  double sum=0;
  rep(i,n) {
    cin >> a[i];
    sum+=a[i];
  }
  int ans=0;
  sum=sum/(4*m);
  rep(i,n){
    if(a[i]>=sum){
	ans++;
      }
  }
  if(ans>=m){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e7

using namespace std;
typedef long long int ll;

vector<int>par,len;

int find(int x)
{
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
}

void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(len[x] < len[y]) par[x] = par[y];
    else par[y] = par[x];
    if(len[x] == len[y]) len[x]++;
}

int main()
{
   int N,M; cin >> N >> M;
   vector<pair<int,int>>dp;
   for(int i = 0; i < M; i++)
   {
       int a,b; cin >> a >> b;
       a--,b--;
       dp.push_back(pair(a,b));
   }
   int ans = 0;
   for(auto x:dp)
   {
       len.assign(N,0);
       par.resize(N);
       for(int i = 0; i < N; i++) par[i] = i;
       for(auto y:dp)
       {
           if(x == y) continue;
           unite(y.first,y.second);
       }
       bool f = true;
       for(int i = 0; i < N; i++) par[i] = find(i);
       for(int i = 0; i < N; i++)
       {
           for(int j = 0; j < N; j++)
           {
               if(par[i] != par[j]) f = false;
           }
       }
       if(f) ans++;
   }
   cout << M - ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

#define ll long long
#define p pair<ll, ll>
using namespace std;

int main() {
    int n, m, from, to;
    cin >> n >> m >> from >> to;
    from--;
    to--;

    vector<vector<vector<ll>>> graph(n);
    for (int i = 0; i < m; i++) {
        int u, v, y, s;
        cin >> u >> v >> y >> s;
        u--;
        v--;
        graph[u].push_back({v, y, s});
        graph[v].push_back({u, y, s});
    }


    priority_queue<p, vector<p >, greater<>> que;
    vector<ll> ycost(n, 1145141919810364364);
    ycost[from] = 0;
    que.push(p(from, 0));

    while (!que.empty()) {
        p now = que.top();
        que.pop();
        int nowv = now.first;
        if (ycost[nowv] < now.second)continue;
        for (auto next:graph[nowv]) {
            if (ycost[next[0]] > ycost[nowv] + next[1]) {
                ycost[next[0]] = ycost[nowv] + next[1];
                que.push(p(next[0], ycost[next[0]]));
            }
        }
    }


    que = priority_queue<p, vector<p >, greater<>>();
    vector<ll> scost(n, 1145141919810364364);
    scost[to] = 0;
    que.push(p(to, 0));

    while (!que.empty()) {
        p now = que.top();
        que.pop();
        int nowv = now.first;
        if (scost[nowv] < now.second)continue;
        for (auto next:graph[nowv]) {
            if (scost[next[0]] > scost[nowv] + next[2]) {
                scost[next[0]] = scost[nowv] + next[2];
                que.push(p(next[0], scost[next[0]]));
            }
        }
    }

    vector<ll> dis(n);
    dis[n - 1] = ycost[n - 1] + scost[n - 1];
    for (int i = n - 2; i >= 0; i--)
        dis[i] = min(dis[i + 1], ycost[i] + scost[i]);

    for (int i = 0; i < n; i++) {
        ll ret = 1e15;
        cout << ret - dis[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 24044
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Policy;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            MyDebugger.Test(process, "../TextFile1.txt");
            //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
            //MyDebugger.Test(process, "../TextFile2.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
#endif
        }
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var aa = ToIntArray(input.ReadLine(), n);

        long sum = 0;
        foreach (var a in aa) {
            sum ^= a;
        }

        var sb = new StringBuilder();

        foreach(var a in aa) {
            var y = sum ^ a;
            sb.Append(y + " ");
        }

        return sb;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        if(n == 0) return ret;
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 67688
def main():
    N = int(input())
    ac, wa, tle, re = 0, 0, 0, 0

    for i in range(N):
        s = input()
        if s == 'AC':
            ac += 1
        elif s == 'WA':
            wa += 1
        elif s == 'TLE':
            tle += 1
        elif s == 'RE':
            re += 1
    print('AC x {}'.format(ac))
    print('WA x {}'.format(wa))
    print('TLE x {}'.format(tle))
    print('RE x {}'.format(re))



if __name__ == "__main__":
    main()


Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
using namespace std;
#define ll long long int
int main(){
  int n,k;
  cin >> n >> k;
  vector < ll > h(n);
  for ( int i = 0; i < n; ++i ) {
    cin >> h[i];  
  }
  sort( h.begin(), h.end() );
  ll ans = 1e9;
  for ( int i = 0; i < n - k + 1 ; ++i ) {
    ans = min ( ans, h[i + k - 1] - h[i] );  
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    long[] h = new long[N];
    for (int i =0; i<N; i++) {
      h[i] = sc.nextLong();
    }
    Arrays.sort(h);
    long min =1000000000;
    for (int i =0; i<N-K+1; i++) {
      min = (long)Math.min(h[i+K-1] - h[i],min);
    }
    System.out.println((long)min);
  }
}

Measured memory_bytes: 60864
N = int(input())

count = 0

for i in range(N):
    k, t = map(int, input().split())
      
    if not k == t:
        count *= 0
    if k == t:
       count += 1 
    if count == 3:
      print ( "Yes" )
     
      break
        
if count == 3:
        print ("")
else:
  print ("No")



Measured memory_bytes: 9156
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main(){
    int n, r;
    cin >> n >> r;
    if(n >= 10){
        cout << r << endl;
    }else{
        // r = ans - 100 * (10 - k)
        cout << r + 100 * (10 - n) << endl;
    }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll dp[101][100010];
int main(){
    ll n,weight;
    cin>>n>>weight;
    pair<ll,ll>A[n+2];
    ll size1=0;
    for(int i=1;i<=n;i++)
    {
        cin>>A[i].second>>A[i].first;
       size1+=A[i].first;
    }
    for(int i=0;i<=size1;i++)
    dp[0][i]=INT_MAX;
    for(int i=0;i<=n;i++)
    dp[i][0]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=size1;j++){
            if(A[i].first<=j){
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-A[i].first]+A[i].second);
            }else
            {
                dp[i][j]=dp[i-1][j];
            }
            
        }
    }
 /*   for(int i=0;i<=n;i++){
        for(int j=0;j<=size1;j++)
        cout<<dp[i][j]<<" ";
        cout<<endl;
    }
    */
    for(int i=size1;i>=0;i--){
        if(dp[n][i]<=weight){
            cout<<i<<endl;
            break;
        }
    }
    
}

Measured memory_bytes: 79104
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#define MOD(x) (x + 1000000007) % (1000000007)

using namespace std;

template <class t>
using vec = vector<t>;
using ll = long long;

const int MAX = numeric_limits<int>::max();

template <class t>
ostream &operator<<(ostream &out, vec<t> &v)
{
    for (int i = 0; i < v.size(); i++)
        cout << i << " " << v[i] << "\n";
    out << "\n";
    return out;
}

template <class t>
istream &operator>>(istream &in, vec<t> &v)
{
    for (auto &e : v)
        in >> e;
    return in;
}

ll n, mod;
vec<ll> res_bottom, res_top;
vec<vec<ll>> graf;

ll MD(ll x) { return (x + mod) % mod; }

void dfs_1(ll parent, ll node)
{
    for (auto nd : graf[node])
    {
        if (nd != parent)
        {
            dfs_1(node, nd);
            res_bottom[node] = MD(res_bottom[node] * (res_bottom[nd] + 1));
        }
    }
}

void dfs_2(ll parent, ll node)
{
    ll prod_left = 1, prod_right = 1;
    for (auto nd : graf[node])
    {
        if (nd != parent)
        {
            res_top[nd] = MD(res_top[nd] * prod_left);
            prod_left = MD(prod_left * (res_bottom[nd] + 1));
        }
    }
    for (auto nd = graf[node].rbegin(); nd != graf[node].rend(); nd++)
    {
        if (*nd != parent)
        {
            res_top[*nd] = MD(res_top[*nd] *  prod_right);
            if (node != 1)
                res_top[*nd] = MD(res_top[*nd] * res_top[node] + 1);
            else res_top[*nd] = MD(res_top[*nd] + 1);
            dfs_2(node, *nd);
            prod_right = MD(prod_right * (res_bottom[*nd] + 1));
        }
    }
}

int main()
{
    cin >> n >> mod;
    graf = vec<vec<ll>>(n + 1, vec<ll>());
    res_bottom = vec<ll>(n + 1, 1);
    res_top = vec<ll>(n + 1, 1);
    for (int i = 0, u, v; i < n - 1; i++)
    {
        cin >> u >> v;
        graf[u].push_back(v);
        graf[v].push_back(u);
    }
    dfs_1(-1, 1);
    dfs_2(-1, 1);
    for (int i = 1; i <= n; i++)
        cout << MD(res_bottom[i] * res_top[i]) << "\n";
    return 0;
}

Measured memory_bytes: 15776
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
long long mod=1000000007;
long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int y[2100];
long long ks[2100];

int main(){
	int a,b;scanf("%d%d",&a,&b);
	long long ret=0;
	int sz=0;
	for(int i=1;i*i<=a;i++){
		if(a%i==0){
			y[sz++]=i;
			if(i*i!=a)y[sz++]=a/i;
		}
	}
	std::sort(y,y+sz);
	for(int i=0;i<sz;i++){
		long long cnt=pw(b,(y[i]+1)/2);
		for(int j=0;j<i;j++)if(y[i]%y[j]==0)cnt=(cnt+mod-ks[j])%mod;
		ks[i]=cnt;
		//printf("%d: %lld\n",y[i],cnt);
		if(y[i]%2)ret=(ret+cnt*y[i])%mod;
		else ret=(ret+cnt*y[i]/2)%mod;
	}
	printf("%lld\n",ret);
}



Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int N; cin >> N;
    int Q; cin >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 21716
#include<iostream>

using namespace std;

int main(){
   int n, count=0;

   while(cin >>n){
      count=0;
      for(int i=0;i<10;i++)
	 for(int j=0;j<10;j++)
	    for(int k=0;k<10;k++)
	       for(int l=0;l<10;l++)
		  if((i+j+k+l)==n)count++;
      cout <<count<<endl;
   }


   return 0;

}

Measured memory_bytes: 1160
import sys

X = [[int(x) for x in input().split()] for _ in range(3)]

for i in range(min(X[0])+1):
    t1 = [x-i for x in X[0]]
    for j in range(min(X[1])+1):
        t2 = [x-j for x in X[1]]
        for k in range(min(X[2])+1):
            t3 = [x-k for x in X[2]]
            if t1==t2==t3:
                print('Yes')
                sys.exit()

print('No')



Measured memory_bytes: 3316
int x, y, a;
int main(){
  scanf("%d%d", &x, &y);
  a=0;
  if(x<=3){
    a+=(4-x)*100000;
  }
  if(y<=3){
    a+=(4-y)*100000;
  }
  if(x*y==1){
    a+=400000;
  }
  printf("%d\n", a);
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define SREP(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;
int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}

int main() {
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	PRINTD(Min(a, b) + Min(c, d));
}

Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main() {
  string str1, str2;
  cin >> str1 >> str2;

  int count_diff = 0;
  for(int i = 0; i < str1.size(); i++) {
    if(str1[i] != str2[i]) {
      count_diff++;
    }
  }

  cout << count_diff << endl;;
}

Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))

typedef long long LL;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)

const ll mod=1000000007;
const ll INF=mod*mod;

int main(){
  ll s;cin>>s;
  vector<P> v;
  for(ll i=1;i<=s;i++){
    if(s%i==0){
      v.push_back({i,s/i});
    }
  }
  int len=v.size();int out=0;
  for(ll i=1;i<=1000;i++){
    for(ll j=1;j<=1000;j++){
      rep(k,len){
        ll le=v[k].first;ll ri=v[k].second;
        le-=i*(i-1)/2;ri-=j*(j-1)/2;
        if(le<=0||ri<=0||le%i||ri%j)continue;
        out++;
      }
    }
  }
  cout<<out<<endl;
  return 0;
}



Measured memory_bytes: 3104
N, D = map(int, input().split())
list1 = [0] * N
list2 = [0] * N
count = 0
for i in range(N):
    list1[i], list2[i] = map(int, input().split())

for i in range(N):
    if list1[i]**2 + list2[i]**2 <= D**2:
        count += 1
    else:
        continue
print(count)

Measured memory_bytes: 24560
using System;
using System.Linq;
using System.Collections.Generic;


public class CoinChanging
{
    public static void Main()
    {
        var inputs = Console.ReadLine().Split(' ').Select(int.Parse);
        var n = inputs.First();
        
        var coins = Console.ReadLine().Split(' ').Select(int.Parse);
        
        var totals = coins.ToList();
        var count = 1;
        
        var max = coins.Max();
        
        while (totals.All(x => x != n))
        {
            count++;
            
            totals = totals.SelectMany(x => 
            {
                return n - x > max * 10
                    ? new int[] { x + max }
                    : coins.Select(y => x + y);
//                return coins.Select(y => x + y);
            }).ToList();
            totals.RemoveAll(x => x > n);
            totals = totals.Distinct().ToList();
        }
    
        Console.WriteLine(count);
    
    }
}

// Define other methods and classes here

Measured memory_bytes: 37080
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
   int k, n, i, maxd;
   cin >> k >> n;

   int A[n];
   for(i=0; i<n; i++){
       cin >> A[i];
   }

   maxd = k - A[n-1] + A[0];
   for(i=1; i<n; i++){
       maxd = max(maxd, A[i] - A[i-1]);
   }
   cout << k - maxd;
}

Measured memory_bytes: 1024
/**
 * Kagisys
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

import static java.lang.Integer.parseInt;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		int n = parseInt(br.readLine());
		Set<String> ids = new HashSet<String>();
		boolean lock = true;

		for (int i = 0; i < n; i++) {
			ids.add(br.readLine());
		}

		int m = parseInt(br.readLine());
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < m; i++) {
			String id = br.readLine();
			if (ids.contains(id)) {
				if (lock) {
					sb.append("Opened by " + id + "\n");
					lock = false;
				} else {
					sb.append("Closed by " + id + "\n");
					lock = true;
				}
			} else {
				sb.append("Unknown " + id + "\n");
			}
		}
		System.out.print(sb.toString());
	} //end main
}

Measured memory_bytes: 17116
import math
n=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
p1=0
p2=0
p3=0
pinf=0

for i in range(n):
    p1+=abs(x[i]-y[i])
    p2+=abs(x[i]-y[i])**2
    p3+=abs(x[i]-y[i])**3
    pinf=max(pinf,abs(x[i]-y[i]))
p2=math.sqrt(p2)
p3=p3**(1/3)

print(p1)
print(p2)
print(p3)
print(pinf)



Measured memory_bytes: 5688
#include <bits/stdc++.h>

using namespace std;

const int N = 1e4 + 10;
long long dp[N];
int a[N], b[N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);

  int h, n;
  cin >> h >> n;
  for (int i = 0; i < h; ++i) {
    dp[i] = 1e18;
  }
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = h; j >= 0; --j) {
      int v = max(0, j - a[i]);
      dp[v] = min(dp[v], dp[j] + b[i]);
    }
  }
  cout << dp[0];

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long int ll;

ll cnt[26];
vector<ll> v[26];
int main(){
	string s,t; cin >> s >> t;
	int n=s.size();
	int m=t.size();
	for(int i=0;i<n;i++){
		v[s[i]-'a'].push_back(i);
	}
	ll loop=0; ll now=0;
	for(int i=0;i<m;i++){
		int cp=t[i]-'a';
		if(v[cp].size()==0){
			cout << -1 << endl;
			return 0;
		}
		int left=-1; int right=v[cp].size();
		while(right-left>1){
			int mid=(left+right)/2;
			if(v[cp][mid]>=now){
				right=mid;
			}
			else{
				left=mid;
			}
		}
		if(right==v[cp].size()){
			loop++;
			now=(v[cp][0]+1)%n;
		}
		else{
			now=(v[cp][right]+1);
			if(now==n){
				loop++;
				now=0;
			}
		}
	}
	cout << (ll)(loop*n+now) << endl;
}

Measured memory_bytes: 1724
#include <iostream>
using namespace std;
int main() {
    long long  H, W;

    cin >> H;
    cin >> W;

    if(H==1 || W==1) {
        cout << 1 << endl;
    } else{
        long long ret = (long long) H * W / 2 + (H * W) % 2;
        cout << ret << endl;

    }
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
# define lli long long int
# define MOD 1000000007
# define INF 10000000000009
# define MAX 1000000

lli arr[22][22];
lli dp[22][(1<<22)];

lli findNum(lli x, lli n, lli w){
    if(x == n)
        return 1;

    if(dp[x][w] != -1)
        return dp[x][w];

    lli res = 0;
    for(lli i = 0; i < n; i++){
        bool avail = ((w&(1<<i)) == 0) ? false : true;
        if(arr[x][i] == 1 and avail){
            res += findNum(x + 1, n, w&(~(1<<i)));
            res %= MOD;
        }
    }

    return dp[x][w] = res;

}


void solve(){
    lli n;
    cin >> n;

    for(lli i = 0; i < n; i++){
        for(lli j = 0; j < n; j++){
            cin >> arr[i][j];
        }
    }

    memset(dp, -1, sizeof(dp));

    cout << findNum(0, n, ((1<<n) - 1));

}


int main(){
    int t;
    t = 1;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 724492
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(){
    int N,M;
    int sumAi;

    cin >> N >>M;

    sumAi = 0; 
    for(int i=0;i<M;i++){
        uint32_t temp1;
        cin>>temp1;
        sumAi += temp1;
    }

    if(sumAi <= N){
        cout << N - sumAi <<std::endl; 
    }
    else{
        cout << "-1" <<std::endl; 
    }

}



Measured memory_bytes: 3624
#include <stdio.h>
#define MAX(A, B) (((A) < (B)) ? (B) : (A))
#define MIN(A, B) (((A) < (B)) ? (A) : (B))
#define ABS(A) (((A) < 0 ) ? (0 - A) : (A))

int main() {
  int N;
  scanf("%d", &N);
  int a=0;
  int b=0;
  int m=0;
  for (int i=0; i<N; i++) {
    scanf("%d", &a);
    b += a;
    m = MAX(m, a);
  }
  b -= m/2;
  printf("%d", b);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;

long long dp[4][100005];
long long a[100005];
long long b[100005];
long long c[100005];

int main()
{
    long long n;

    cin >> n;


    for(long long i = 1 ; i<=n ; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }

    dp[1][1] = a[1];
    dp[2][1] = b[1];
    dp[3][1] = c[1];

    for(long long i = 2 ; i<=n ; i++)
    {
        dp[1][i] = max(dp[2][i-1]+a[i] , dp[3][i-1]+a[i]);
        dp[2][i] = max(dp[3][i-1]+b[i] , dp[1][i-1]+b[i]);
        dp[3][i] = max(dp[1][i-1]+c[i] , dp[2][i-1]+c[i]);
    }

    cout <<  max(dp[1][n] , max(dp[2][n] , dp[3][n]));

    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n,q;
    string s;
    cin >> n >> s >> q;
    vector<set<int>> alp(26);
    rep(i,n) {
        alp[s[i]-'a'].insert(i+1);
    }
    rep(i,26) alp[i].insert(n+1);
    rep(i,q) {
        int f;
        cin >> f;
        if (f==1) {
            int j;
            char c;
            cin >> j >> c;
            alp[s[j-1]-'a'].erase(j);
            alp[c-'a'].insert(j);
            s[j-1]=c;
        } else {
            int l,r;
            cin >> l >> r;
            int ans=0;
            rep(i,26) {
                int nr=*alp[i].lower_bound(l);
                if (nr<=r) ++ans;
            }
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 27300
#include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    long long k;
    cin >> s >> k;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'a') continue;
        int dif = 'z' - s[i];
        if(dif+1 <= k){
            s[i] = 'a';
            k -= dif+1;
        }
    }
    if(k > 0){
        k %= 26;
        if(k != 0){
            if('z'-s[s.length()-1] >= k) s[s.length()-1] += k;
            else s[s.length()-1] = 'a' + (k-1 - ('z'-s[s.length()-1]));
        }
    }
    cout << s << endl; 
    return 0;
}

Measured memory_bytes: 592
import io.Source.stdin

object Main {

  def main(args: Array[String]) {
    for ((list) <- stdin.getLines().takeWhile(_ != "0 0").map(_.split(" ").map(_.toInt))) {
      val (w: Int, h: Int) = (list(0), list(1))
      printRect(w, h)
    }
  }

  def printRect(w: Int, h: Int) {
    for (i <- 1 to w) {
      for (j <- 1 to h) {
        print("#")
      }
      println()
    }
    println()
  }
}



Measured memory_bytes: 54472
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1 == 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

bool isPrime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0)
            return false;
    }
    if (x == 1)
        return false;
    return true;
}

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}
int a[13][13];
int cost[13];
int n, m, k;
int ans = INT_MAX;
void comb(int x, int curr, int c, vector<int> v)  {
    vector<int> copy = v;
    int cc = c;
    curr += cost[x];
    for (int i = 0; i < m; i++) {
        if (v[i] < k && v[i] + a[x][i] >= k) {
            c++;
        }
        v[i] += a[x][i];
    }
    //cout << curr << endl;
    if (c == m) {
        ans = min(ans, curr);
    }
    if (x + 1 < n) {
        if (c != m)
            comb(x + 1, curr, c, v);
        comb(x + 1, curr - cost[x], cc, copy);
    }
    //else
    //cout << endl; //remove
}
int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("out.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        cin >> n >> m >> k;
        for (int i = 0; i < n; i++) {
            cin >> cost[i];
            for (int j = 0; j < m; j++) {
                cin >> a[i][j];
            }
        }
        vector<int> v(m, 0);
        comb(0, 0, 0, v);
        if (ans == INT_MAX)
            cout << -1 << endl;
        else
            cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h> 

using namespace std; 

int main(){ 
  int64_t a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k<a) cout<<k;
  else if(k<a+b) cout<<a;
  else {
    int64_t x=2*a+b-k;
    cout<<x;
  }
}
  

Measured memory_bytes: 3624
#include <bits/stdc++.h>

using namespace std;

int main(void) {
  string S; cin >> S;
  int C_num = 0;
  int lcnum = 0;
  int L = S.length()-1;

  if ('a' <= S[1] && S[1] <= 'z') lcnum++;
  if ('a' <= S[L] && S[L] <= 'z') lcnum++;
  for (int i = 2; i < L; i++) {
    if (S[i] == 'C') C_num++;
    if ('a' <= S[i] && S[i] <= 'z') lcnum++;
  }

  cout << ((S[0] == 'A' && C_num == 1 && lcnum + 1 == L) ? "AC" : "WA") << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll a, b;
  cin >> a >> b;

  ll res = 0;
  ll curr = 1;
  while (curr < b) {
    curr += a - 1;
    res++;
  }
  cout << res << en;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX (1<<(2*12-3))

void init();
void insert(char *str);
int find(char *str);
int get_hash(char *str);

const int key[] = {
    0  /* A */
    ,0 /* B */
    ,1 /* C */
    ,0 /* D */
    ,0 /* E */
    ,0 /* F */
    ,2 /* G */
    ,0 /* H */
    ,0 /* I */
    ,0 /* J */
    ,0 /* K */
    ,0 /* L */
    ,0 /* M */
    ,0 /* N */
    ,0 /* O */
    ,0 /* P */
    ,0 /* Q */
    ,0 /* R */
    ,0 /* S */
    ,3 /* T */
};

char dic[MAX];

int main(){
    char cmd[7];
    char str[13];
    int n;
    int i;

    init();

    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%s %s",cmd,str);
        if(cmd[0]=='i'){
            /* cmd is "insert" */
            insert(str);
        }else{
            /* cmd is "find" */
            printf(find(str)?"yes\n":"no\n");
        }
    }

    return 0;
}

void init(){
    int i;
    for(i=0;i<MAX;i++)dic[i]=0;
}

void insert(char *str){
    int hash;
    hash = get_hash(str);
    dic[hash>>3]|=0x01<<(hash&0x07);
}

int find(char *str){
    int hash;
    hash = get_hash(str);
    return dic[hash>>3]&(0x01<<(hash&0x07));
}

int get_hash(char *str){
    int hash;
    int idx;

    hash=1;
    for(idx=0;str[idx];idx++){
        hash<<=2;
        hash+=key[str[idx]-'A'];
    }

    return hash;
}

Measured memory_bytes: 3904
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<vector<int> > x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = 0; j < a[i]; j++) {
      int temp;
      cin >> temp;
      temp--;
      x[i].push_back(temp);
      cin >> temp;
      y[i].push_back(temp);
    }
  }
  int ans = 0;
  for (int z = 1; z < 1 << n; z++) {
    bool check = true;
    int num = 0;
    for (int i = 0; i < n; i++) {
      if (z >> i & 1) {
        num++;
        for (int j = 0; j < a[i]; j++) {
          if (((z >> x[i][j]) & 1) != y[i][j]) check = false;
        }
      }
    }
    if (check && ans < num) {
      ans = num;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256