akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)

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

    int n;
    cin >> n;
    if (n == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    vector<pair<ll, ll>> z(n), d;
    rep(i, n) cin >> z[i].first >> z[i].second;

    sort(z.begin(), z.end());

    rep(i, n - 1) forx(j, i + 1, n)
        d.push_back(make_pair(z[j].first - z[i].first, z[j].second - z[i].second));

    sort(d.begin(), d.end());

    int k = 1;
    int mx = 1;
    pair<int, int> a = d[0];

    rep(i, d.size() - 1)
    {
        if (d[i] == d[i + 1])
        {
            k++;
            if (mx < k)
            {
                a = d[i];
                mx = k;
            }
        }
        else
        {
            k = 1;
        }
    }
    cout << n - mx << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define rev(a,b,c) for(int a=b;a>=c;a--)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define end end()
#define vec vector<ll>
#define se set<ll>
#define mults multiset<ll>
#define F first
#define S second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b
#define get(a) cin>>a
#define nextl cout<<endl
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll ncr(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j] + C[j-1])%mod;
    }
    return C[k];
}
void solve()
{
    int a;
    string s;
    cin>>a>>s;
    if(a<3200) pr("red");
    else pr(s);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nextl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){

	string W,T;
	char buf;
	int ans = 0;
	int pos = 0;

	getline(cin, W);
	transform(W.begin(), W.end(), W.begin(), ::toupper);

	while (cin >> T){
		transform(T.begin(), T.end(), T.begin(), ::toupper);
		if (T == W) ans++;
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <algorithm>
#include <vector>

int main() {
	std::vector<int> s;
	int a = 0, b = 0, n;
	std::cin >> n;

	for (int i = 0; i < n; i++) {
		int x;
		std::cin >> x;
		s.push_back(x);
	}
	std::sort(s.begin(), s.end());
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			a += s[i];
		}
		else {
			b += s[i];
		}
	}
	std::cout << std::abs(a - b) << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define MAX 100


int n,c,d=0;
int pre[1000],in[1000],post[1000];

int find(int x);
void rec(int l,int r);

int main(void){
	int i;
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&pre[i]);
	}
	
	for(i=0;i<n;i++){
		scanf("%d",&in[i]);
	}
	
	rec(0,n);
	
	for(i=0;i<n;i++){
		if(i!=n-1){
			printf("%d ",post[i]);
		}
		else {
			printf("%d\n",post[i]);
		}
	}
	return 0;
}


int find(int x){
	int i;
	for(i=0;i<n;i++){
		if(x==in[i]){
			return i;
		}
	}
	return 0;
}

void rec(int l,int r){
	int x,y;
	if(l>=r){
		return;
	}
	
	x=pre[d++];
	y=find(x);
	rec(l,y);
	rec(y+1,r);
	post[c++]=x;
}



Measured memory_bytes: 2108
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int x,a,b,z=0;
    
    cin>>x>>a>>b;

    if(x+1+a>b){
        
        if(a-b>0){cout<<"delicious"<<endl;}
        
        else if(a-b==0){cout<<"delicious"<<endl;}
        
            else{cout<<"safe"<<endl;}
        }
    else{cout<<"dangerous"<<endl;}
    
    }


Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]
ans = {}
ans['AC'] = 0
ans['WA'] = 0
ans['TLE'] = 0
ans['RE'] = 0
for s in S:
    ans[s] += 1
for key in ans:
    print(key + ' x ' + str(ans[key]))

Measured memory_bytes: 16288
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#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 ll long long
#define ull unsigned long long
#define int ll
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
                                                                    
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 4e3 + 5;
int n , X;
int a[N];
ll f(int x){
	deque < pii > dq;
	rep(i , 1, n){
		while(sz(dq) != 0 and dq.back().fi >= a[i])
			dq.pop_back();
		dq.push_back({a[i] , i});
	}
	ll res = 0;
	//1 2 3 4 5 6

	rep(i, n + 1 , n + n){
		while(sz(dq) != 0 and dq.back().fi >= a[i])
			dq.pop_back();
		dq.push_back({a[i] , i});
		while(sz(dq) != 0 and dq.front().se < i - x)
			dq.pop_front();
		res += dq.front().fi;
	}
	return res + x * X;
}
main(){
//	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> X;
	rep(i , 1 , n){
		cin >> a[i];
		a[n + i] = a[i];
	}
	ll ans = mod * mod;
	rep(i ,0 , n){
		ans = min(ans , f(i));		
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define print(x) cout << x << endl;
#define input(x) cin >> x;

int main()
{
    char s[3];
    cin >> s;
    int c = 0;
    for (int i = 0; i < 3; ++i)
    {
        if (s[i] == '1')
            c++;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)

const ll N = 3234566667;

//A = 格納場所, num = 現在の数
void lun(vector<ll> &A, ll num) {
    if (num > N) return;
    A.push_back(num);
    ll res = num%10;
    for (ll i=res-1; i<=res+1;i++){
        if (0<=i && i <= 9){
            lun(A, num*10+i);
        }
    }
}

int main() {
    ll K;
    cin >> K;
    vector<ll> A;
    rep2(i,1,10) lun(A, i);
    sort(A.begin(), A.end());
    cout << A[K-1] << endl;
}



Measured memory_bytes: 1400
// #include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define testP	 cout << "------------------ test ------------------" << endl;	// 動作確認テスト
#define testX(x) cout << "testout : " << x << endl;	// テストアウト
typedef long long ll;
using namespace std;
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)

// ------------------ ベクター表示 ------------------ //
void printVec(vector<int>& vec) {
	cout << "";
	for (auto it = vec.begin(); it != vec.end(); it++) cout << *it << " ";
	cout << endl;
}

// ------------------ ベクター合計 ------------------ //
int sumVec(vector<int> v) {
	int sum = 0;
	for (size_t i = 0; i < v.size(); i++) sum += v[i];
	return sum;
}

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //


vector<int> intEach(int x, int digit) {

	vector<int> xVec;
	int X = x;

	while (x > 0) {
		int tmp = x % 10;
		xVec.insert(xVec.begin(), tmp);
		x /= 10;
	}

	if (floor(log10(X)) != digit) {
		int N = abs(digit - floor(log10(X)));
		rep(i, N-1) xVec.insert(xVec.begin(), 0);
	}
	return xVec;

}


int main(void) {

	int num;
	vector<int> A;
	cin >> num;

	A = intEach(num,4);
	char jg[3] = {'-', '-', '-'};
	
	rep(bit, 1 << 3) {
		int ans = A[0];
		for (int i = 2; i >= 0; i--) {
			if (bit & (1 << i)) {
				ans += A[3 - i];
				jg[i] = '+';
			}
			else {
				ans -= A[3 - i];
				jg[i] = '-';
			}
		}
		if (ans == 7) break;
	
	}

	cout << A[0] << jg[2] << A[1] << jg[1] << A[2] << jg[0] << A[3] << "=7" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

const i64 MOD = 1e9 + 7;

long long modinv(long long a, long long m)
{
  long long b = m, u = 1, v = 0;
  while (b)
  {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

int main()
{
  vector<i64> f(4010, 1);
  for (i64 i = 2; i < 4010; i++)
    f[i] = f[i - 1] * i % MOD;
  i64 n, k;
  cin >> n >> k;
  for (i64 i = 1; i <= k; i++)
  {
    i64 b = k - i, r = n - k - (i - 1);
    if (0 <= r)
      cout << (((f[b + i - 1] * modinv((f[b] * f[i - 1]) % MOD, MOD)) % MOD) * ((f[r + i] * modinv((f[r] * f[i]) % MOD, MOD)) % MOD)) % MOD << endl;
    else
      cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String name;
		int num;
		int compare;
		String waku="";
		String wk2="#";

		int[] a=new int[2];
		int i=0;
		while(true){

			try{
				name=br.readLine();
				StringTokenizer st=new StringTokenizer(name," ");
				while (st.hasMoreTokens()) {
					a[i]=Integer.parseInt(st.nextToken());
					i++;
				}i=0;

				if(a[0]==0 && a[1]==0){
					System.exit(0);
				}

				else if(a[0] != 1){
					for(int k=0; k<a[1]; k++){
						waku=waku+"#";
					}

					for(int k=0; k<a[1]-2; k++){
						wk2=wk2+".";
					}wk2=wk2+"#";

					System.out.println(waku);
					for(int j=0; j<a[0]-2; j++){
						System.out.println(wk2);
					}
					System.out.println(waku);
					System.out.println("");
					waku="";
					wk2="#";
				}

				else if(a[0]==1){
					for(int k=0; k<a[1]; k++){
						waku=waku+"#";
					}

					System.out.println(waku);
					System.out.println("");
					waku="";
					wk2="#";
				}
			}

			catch(Exception e){
				System.exit(0);
			}
		}
	}
}

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

int main() {
  int K, N;
  cin >> K >> N;
  vector<int> home(N+1);
  for(int i = 0; i < N; ++i){
    cin >> home.at(i);
  }
  home.at(N) = K + home.at(0);

  int maxAbs = 0;
  for(int i = 0; i < N; ++i){
    maxAbs = max(home.at(i+1) - home.at(i), maxAbs);
  }

  cout << K - maxAbs << endl;
}


Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <climits>

using namespace std;
using ll=long long;

void solve(){
  int num,a;
  cin >> num >> a;
  cout << num*num-a << endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<int64_t> A(N);
    rep(n,0,N) cin>>A.at(n);

    sort(ToEnd(A));
    int64_t ans=A.at(N-1);
    int n=N-2,cnt=0;

    _rep(i,N-3,0){
        if(cnt>1){
            n--;
            cnt=0;
        }

        ans+=A.at(n);
        cnt++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 4792
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, k;
main() {
  file("threesum");
  ios;
  cin >> n >> k;
  ll ans = 0;
  function<ll(ll,ll)> get = [&](int l, int r) {
    return (r + 1) * r / 2 - (l - 1) * l / 2;
  };
  fo(i, k, n, 1) {
    ans += get(n - i + 1, n) - get(0, i-1) + 1;
    ans %= mod;
  }
  ++ans;
  ans %= mod;
  cout << ans;
  return 0;
}
/**

*/


Measured memory_bytes: 3652
S=input()
K=int(input())
N=len(S)
count=1
countlist=[]
anssub=0
for i in range(N-1):
  if S[i]==S[i+1]:
    count+=1
  else: 
    countlist+=[count]
    count=1
if S[N-2]!=S[N-1]:
  count=1
countlist+=[count]  
for i in range(len(countlist)):
  if i!=0 and i!=len(countlist)-1:
    if countlist[i]!=1:
      anssub+=countlist[i]//2
a=countlist[0]+countlist[-1]
anssub2=0
if S[0]==S[-1]:
  anssub2+=a//2
if S[0]!=S[-1]:
  if countlist[0]!=1:
    anssub2+=countlist[0]//2
  if countlist[-1]!=1:
    anssub2+=countlist[-1]//2
  
b=countlist[0]
c=countlist[-1]
anssub3=0
if b!=1:
  anssub3+=b//2
if c!=1:
  anssub3+=c//2
  
ans=anssub*K+anssub2*(K-1)+anssub3
if len(countlist)==1:
  ans=countlist[0]*K//2
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <deque>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const int INF = 2e9;
int H, W;
int ch, cw, gh, gw;
char S[1002][1002];
int seen[1002][1002];
typedef pair<int, int> P;
queue<P> que;
int dh[4] = {1,0,-1,0}, dw[4] = {0, 1, 0, -1};

int bfs() {
  rep(i, H) rep(j, W) seen[i][j] = INF;
  que.push(P(ch,cw));
  queue<P> cur_oper;
  int cnt=0;
  while(!que.empty()) {
    while(!que.empty()) {
      P p = que.front(); que.pop();
      cur_oper.push(p);
      int h = p.first;
      int w = p.second;
      if (seen[h][w]<=cnt) continue;
      seen[h][w] = cnt;
      if (h==gh && w==gw) return cnt;
      rep(i, 4) {
        int nh = h+dh[i];
        int nw = w+dw[i];
        if ((nh<0) || (nh>=H) || (nw<0) || (nw>=W)) continue;
        if (S[nh][nw]=='#') continue;
        if (seen[nh][nw]<=cnt) continue;
        que.push(P(nh,nw));
      }
    }
    cnt++;
    while(!cur_oper.empty()) {
      P p = cur_oper.front(); cur_oper.pop();
      int h = p.first;
      int w = p.second;
      for (int ih=-2; ih<=2; ih++) {
        for (int iw=-2; iw<=2; iw++) {
          int nh = h+ih;
          int nw = w+iw;
          if ((nh<0) || (nh>=H) || (nw<0) || (nw>=W)) continue;
          if (S[nh][nw]=='#') continue;
          if (seen[nh][nw]<=cnt) continue;
          if (nh==gh && nw==gw) return cnt;
          que.push(P(nh,nw));
        }
      }
    }
  }
  return -1;
}

int main() {
  INCANT;
  cin >> H >> W;
  cin >> ch >> cw >> gh >> gw;
  ch--; cw--; gh--; gw--;
  rep(i, H) rep(j, W) cin >> S[i][j];
  cout << bfs() << endl;
  return 0;
}


Measured memory_bytes: 9832
def solve(n,m,a,b)
  size = n - m
  (0..size).each do |xdiff|
    (0..size).each do |ydiff|
      if check(xdiff,ydiff,a,b,m)
        puts "Yes"
        return
      end
    end
  end
  puts "No"
end

def check(x,y,a,b,m)
  (0...m).each do |xx|
    (0...m).each do |yy|
      next if b[yy][xx] == a[y+yy][x+xx]
      return false
    end
  end
  return true
end


def main
  n, m = gets.split.map(&:to_i)
  a = []
  n.times do
    a << gets.chomp.split(//)
  end
  b = []
  m.times do
    b << gets.chomp.split(//)
  end
  solve(n,m,a,b)
end

main


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

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++) {
        string t;
        cin >> t;
        sort(t.begin(),t.end());
        s[i]=t;
    }
    sort(s.begin(),s.end());
    
    string x=s[0];
    vector<int> b(n);
    int y=0;
    b[y]=1;
    for(int i = 1; i < n; i++) {
        if(x==s[i]) b[y]++;
        else{
            x=s[i];
            y++;
            b[y]=1;
        }
    }

    ll ans=0;
    for(int i = 0; i < n; i++) {
        ll p = b[i];
        p *= b[i]-1;
        p /= 2;

        ans += p;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6704
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt() - 1;
		System.out.println(getLunlun(k));
	}

	static long getLunlun(int k) {
		ArrayList<Long> lunluns = new ArrayList<Long>();
		for (long i = 1; i <= 9; ++i) {
			lunluns.add(i);
		}

		int lunlunIndex = 0;
		while (k >= lunluns.size()) {
			long lunlun = lunluns.get(lunlunIndex);
			long lowestDigit = lunlun % 10;
			for (long toAppended = lowestDigit - 1; toAppended <= lowestDigit + 1; ++toAppended) {
				if (0 <= toAppended && toAppended <= 9) {
					long newLunlun = lunlun * 10 + toAppended;
					lunluns.add(newLunlun);
				}
			}
			++lunlunIndex;
		}
		return lunluns.get(k);
	}

}


Measured memory_bytes: 39964
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int h = input.nextInt();
        int w = input.nextInt();
        String[][] map = new String[h][w];
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                map[i][j] = input.next();
            }
        }
        int height = 1;
        char width = 'A';
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                if (map[i][j].equals("snuke")){
                    width = (char)(((int)'A')+j);
                    height += i;
                }
            }
        }
        System.out.printf("%s%d\n",width,height);
    }
}

Measured memory_bytes: 22228
using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using Debug = System.Diagnostics.Trace;
using SB = System.Text.StringBuilder;
using System.Numerics;
using static System.Math;
using Number = System.Int32;
namespace Program {
	public class Solver {
		Random rnd = new Random();
		public void Solve() {
			var a = ri;
			var b = ri;
			var ans = new int[] { a + b, a - b, a * b };
			Console.WriteLine(ans.Max());
		}

		const long INF = 1L << 60;
		static int[] dx = { -1, 0, 1, 0 };
		static int[] dy = { 0, 1, 0, -1 };
		int ri { get { return sc.Integer(); } }
		long rl { get { return sc.Long(); } }
		double rd { get { return sc.Double(); } }
		string rs { get { return sc.Scan(); } }
		public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());

		static T[] Enumerate<T>(int n, Func<int, T> f) {
			var a = new T[n];
			for (int i = 0; i < a.Length; ++i) a[i] = f(i);
			return a;
		}
		static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
	}
}

#region main
static class Ex {
	static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
	static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") {
		return string.Join(st, ie);
	}
	static public void Main() {
		Console.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = false });
		var solver = new Program.Solver();
		//var t = new System.Threading.Thread(solver.Solve, 50000000);
		//t.Start();
		//t.Join();
		solver.Solve();
		Console.Out.Flush();
	}
}
#endregion
#region Ex
namespace Program.IO {
	using System.IO;
	using System.Text;
	using System.Globalization;

	public class Printer : StreamWriter {
		public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
		public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
	}

	public class StreamScanner {
		public StreamScanner(Stream stream) { str = stream; }

		public readonly Stream str;
		private readonly byte[] buf = new byte[1024];
		private int len, ptr;
		public bool isEof = false;
		public bool IsEndOfStream { get { return isEof; } }

		private byte read() {
			if (isEof) return 0;
			if (ptr >= len) {
				ptr = 0;
				if ((len = str.Read(buf, 0, 1024)) <= 0) {
					isEof = true;
					return 0;
				}
			}
			return buf[ptr++];
		}

		public char Char() {
			byte b = 0;
			do b = read(); while ((b < 33 || 126 < b) && !isEof);
			return (char)b;
		}
		public string Scan() {
			var sb = new StringBuilder();
			for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b);
			return sb.ToString();
		}
		public string ScanLine() {
			var sb = new StringBuilder();
			for (var b = Char(); b != '\n' && b != 0; b = (char)read()) if (b != '\r') sb.Append(b);
			return sb.ToString();
		}
		public long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }
		public int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }
		public double Double() { return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture); }
	}
}

#endregion


Measured memory_bytes: 13264
# 入力
N = int(input())
s = input()
xs = [
    1 if c == 'o' else
    -1
    for c in s
]

# 動物1と動物2の種別を決め打ちで割り当てて、矛盾がないかを検証する
dp = {
    l: {
        r: [0 for _ in range(N + 2)]
        for r in (1, -1)
    }
    for l in (1, -1)
}
for l in (1, -1):
    for r in (1, -1):
        dp[l][r][0] = l
        dp[l][r][1] = r
        for i in range(2, N + 2):
            dp[l][r][i] = dp[l][r][i - 2] * dp[l][r][i - 1] * xs[(i - 1) % N]
ans = next(
    (
        ''.join(
            'S' if dp[l][r][i] == 1 else
            'W'
            for i in range(N)
        )
        for l in (1, -1)
        for r in (1, -1)
        if dp[l][r][N] == l and dp[l][r][N + 1] == r
    ),
    '-1'
)

# 出力
print(ans)


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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

const int Maxn = 105;
const int Maxd = 10;
const int Inf = 2e9;

int n;
int F[Maxn][Maxd];
int P[Maxn][Maxd+1];
int res = -Inf;

int main() {
   cin >> n;
   for (int i = 0; i < n; i++) {
      for (int j = 0; j < Maxd; j++) {
         cin >> F[i][j];
      }
   }
   for (int i = 0; i < n; i++) {
      for (int j = 0; j <= Maxd; j++) {
         cin >> P[i][j];
      }
   }

   for (int i = 1; i < (1 << Maxd); i++) {
      int cand = 0;
      for (int j = 0; j < n; j++) {
         int sum = 0;
         for (int k = 0; k < Maxd; k++) {
            sum += bool(i & 1 << k) && F[j][k];
         }
         cand += P[j][sum];
      }
      res = max(res, cand);
   }
   cout << res << endl;

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	// your code goes here
	ll n,testCase;
	string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
      s[i]='x';
    }
  cout<<s<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
template<typename T> 
map<T,int> factorize(T x){
    map<T,int> mp;
    for (T i = 2; i*i <= x; i++){
        while (x%i == 0) {
            x /= i;
            mp[i]++;
        }
        if (x == 1) break;
    }
    if (x != 1) mp[x]++;
    return mp;
}

ll dp[100][100];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    map<int, int> fac;
    rep1(y,N+1){
        int x = y;
        for(int i = 2; i * i <= x; i++){
            while (x%i == 0) {
                x /= i;
                fac[i]++;
            }
            if (x == 1) break;
        }
        if (x != 1) fac[x]++;
    }
    vector<int> fav;
    for(auto p:fac)fav.push_back(p.second);
    int M = fav.size();
    dp[0][1] = 1;
    rep(i,M){
        rep(j,100){
            rep(cnt, fav[i]+1){
                dp[i+1][min(100, j * (cnt + 1))] += dp[i][j];
            }
        }
    }
    /*
    rep(i,M+1){
        rep(j,76){
            cerr << dp[i][j] << " ";
        }
        cerr << endl;
    }*/
    cout << dp[M][75] << endl;
}

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

#define N 200005

int m,n,a[N];
long long ok1[5*N],ok2[5*N];
long long ans=0;

inline int read(){
	int s=0,t=1;
	char c=getchar();
	while((c<'0'||c>'9')&&c!='-')c=getchar();
	if(c=='-')c=getchar(),t=-1;
	while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+(c^48),c=getchar();
	return s*t;
}

int main(void){
	m=read();
	for(int i=1;i<=m;i++){;
		a[i]=read();
		if(a[i]>=m)continue;
		ok1[m+a[i]+i]++;
		ok2[m+i-a[i]]++;
	}
	for(int i=m;i<=4*m;i++){
		ans+=ok1[i]*ok2[i]*1ll; 
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 8580
#include<stdio.h>
int main()
{
	int N, gr;
	scanf("%d", &N);
	int V[N];
	int C[N];
	
	for(gr=0; gr<N; gr++) scanf("%d", &V[gr]);
	
	for(gr=0; gr<N; gr++) scanf("%d", &C[gr]);
	
	int r = 0;

	for(gr=0; gr<N; gr++){
		if(V[gr]-C[gr] > 0){
			r = r + V[gr] - C[gr];
		}
	}
	
	printf("%d", r);
	
	return 0;
}

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

using namespace std;

#define ll long long

// #define TEST

template <typename T>
struct HLD {
	vector<vector<pair<int, T>>> g;
	int n;
	vector<int> subsz, depth, parent;
	vector<vector<T>> chain_edge;
	vector<vector<int>> chain_node;
	map<int, int> chain_top, chain_id, id_in_chain;

	/* constructor */
	HLD(vector<vector<pair<int, T>>>& g) {
		this->g = g; n = g.size();
		parent.resize(g.size());
		subsz.resize(g.size());
		depth.resize(g.size());
	}

	/* init parent, depth, and subsz */
	int dfs_sz(int s = 0, int p = -1, int dep = 0) {
		parent[s] = p;
		depth[s] = dep;
		int sz = 1;
		if (g[s].size() > 2 && g[s][0].first == p)
			swap(g[s][0], g[s][1]); // g[s][0] must be heavy
		for (int i = 0; i < g[s].size(); ++i) {
			if (g[s][i].first != p) {
				sz += dfs_sz(g[s][i].first, s, dep + 1);
				if (subsz[g[s][0].first] < subsz[g[s][i].first])
					swap(g[s][0], g[s][i]); // g[s][0] must be heavy
			}
		}
		subsz[s] = sz;
		return sz;
	}

	/* HL Decomposition */
	void dfs_hld(int s, int& cid) {
		chain_id[s] = cid;
		for (int i = 0; i < g[s].size(); ++i) {
			if (g[s][i].first != parent[s]) {
				if (i == 0) {
					chain_edge.resize(cid + 1);
					chain_node.resize(cid + 1);
					chain_edge[cid].push_back(g[s][i].second);
					chain_node[cid].push_back(g[s][i].first);
					id_in_chain[g[s][i].first] = chain_edge[cid].size();
					dfs_hld(g[s][i].first, cid);
				}
				else {
					++cid;
					chain_edge.resize(cid + 1);
					chain_node.resize(cid + 1);
					chain_edge[cid].push_back(g[s][i].second);
					chain_node[cid].push_back(g[s][i].first);
					id_in_chain[g[s][i].first] = chain_edge[cid].size();
					dfs_hld(g[s][i].first, cid);
				}
			}
		}
	}

	/* the number of chain */
	int chain_number() {
		return chain_node.size();
	}

	/* find chain_top */
	void find_chain_top() {
		for (int i = 0; i < chain_number(); ++i)
			chain_top[i] = parent[chain_node[i][0]];
	}

	/* for test */
	void show() {
#ifdef TEST
		for (int i = 0; i < chain_number(); ++i) {
			cout << "chain id : " << i << endl;
			cout << "    " << chain_top[i];
			for (int j = 0; j < chain_edge[i].size(); ++j)
				cout << "-(" << chain_edge[i][j] << ")-" << chain_node[i][j];
			cout << endl;
		}
		for (int i = 0; i < n; ++i) {
			cout << "node : " << i << endl;
			cout << "    chain : " << chain_id[i] << ",  id_in_chain : " << id_in_chain[i] << endl;
		}
#endif
	}

	/* build */
	void build() {
		dfs_sz();
		int cid = 0;
		dfs_hld(0, cid);
		find_chain_top();
	}

	/* find lca */
	int LCA(int s, int t) {
		if (chain_id[s] < chain_id[t]) swap(s, t);
		while (chain_id[s] != chain_id[t]) {
			s = chain_top[chain_id[s]];
			if (chain_id[s] < chain_id[t]) swap(s, t);
		}
		if (depth[s] < depth[t]) return s;
		return t;
	}
};

int main() {
	int n; cin >> n;
	vector<vector<pair<int, int>>> g(n);
	for (int i = 0; i < n; ++i) {
		int k; cin >> k;
		while (k--) {
			int c; cin >> c;
			g[i].emplace_back(c, 1);
			g[c].emplace_back(i, 1);
		}
	}
	HLD<int> tree(g);
	tree.build();
	tree.show();
	int q; cin >> q;
	while (q--) {
		int u, v; cin >> u >> v;
		cout << tree.LCA(u, v) << endl;
	}
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

#define INF 1e10

using namespace std;

ll dp[3010][5100];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, m; cin>>n>>m;
    vi a(m), c(m, 0);
    rep(i, m){
        cin>>a[i];
        int b; cin>>b;
        rep(j, b){
            int temp; cin>>temp;
            c[i] += 1<<(temp-1);
        }
    }

    rep(i, m+1)rep(j, 1<<n){
        dp[i][j] = INF;
    }
    dp[0][0] = 0;
    for(int i=0; i<m; i++){
        for(int j=0; j<(1<<n); j++){
            if (dp[i][j] != INF){
                dp[i+1][j|c[i]] = min(dp[i+1][j|c[i]], dp[i][j]+a[i]);
                dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            }
        }
    }
    cout << ((dp[m][(1<<n)-1]!=INF)?dp[m][(1<<n)-1]:-1) << "\n";
	return 0;
}


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

int n, w[1010], a[1010], b[10010] = {}, mi=100000;
bool used[1010];

int partition(int *A, int p, int r){
  int x = A[r];
  int i = p - 1;
    for(int j = p;j < r;j++){
      if(A[j] <= x){
        i++;
        swap(A[i], A[j]);
      }
    }
    swap(A[i + 1], A[r]);
  return i + 1;
}

void quicksort(int *A, int p, int r){
  if(p < r){
    int q = partition(A, p, r);
    quicksort(A, p, q - 1);
    quicksort(A, q + 1, r);
  }
}

int solve(){
  
  int ans = 0;
  
  quicksort(a, 0, n - 1);
  for(int i = 0;i < n;i++) b[a[i]] = i;
  
  for(int i = 0;i < n;i++){
    int cnt = 0, sum = 0, now = i, mimi = 100000;
    
    if(used[i]) continue;
    
    while(true){
      if(used[now]) break;
      cnt++;
      used[now] = true;
      mimi = min(mimi, w[now]);
      sum += w[now];
      now = b[w[now]];
    }
    
    ans += min(sum + (cnt - 2) * mimi, sum + mimi + (cnt + 1) * mi);
  }
  
  return ans;
}

int main(){
  
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> w[i];
    a[i] = w[i];
    mi = min(mi, w[i]);
  }
  
  cout << solve() << endl;

  return 0;
}



Measured memory_bytes: 3124
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << 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; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

LL n, m, k;
LL MOD = 1000000007;
LL memo[200010];


//--------------------------------
//繰り返し２乗法を用いたpow。MOD版。
long long modPow(long long x, long long y){
    long long r=1, a=x%MOD;
    while(y > 0){
        if((y&1) == 1) r = (r*a) % MOD;
        a = (a*a) % MOD;
        y /= 2;
    }
    return r;
}

//--------------------------------
//ここからはMODが素数の場合のみ可

//--------------------------------
//MODでの逆元。
long long modInverse(long long x){
    return modPow(x, MOD-2);
}

//--------------------------------
//MODでの割り算。
long long modDivision(long long p, long long q){
    return (p*modInverse(q)) % MOD; //((p%MOD)*modInverse(q)) % MOD の方が安全？
}

LL C(LL n, LL k) {
  if(memo[k]) return memo[k];
  if(k > n) return 0;
  if(k == 0 || n == 0) return 1;
  long long p=1, q=1;
  for(int i=1; i<=k; i++){
      q = (q*i) % MOD;
      p = (p*((n-i+1+MOD)%MOD))%MOD;
  }
  memo[k] = modDivision(p, q);
  return memo[k];
}

void solve() {
  cin >> n >> m >> k;
  LL res = 0;

  LL ysum = 0;
  REP(i, n) {
    ysum = (ysum + i*(i+1LL)/2%MOD) % MOD;
  }

  REP(i, m) {
    LL _ysum = ysum;
    if(i > 0) _ysum = _ysum*2%MOD;
    LL l = ((_ysum + i*n%MOD*n%MOD) % MOD) * (m-i) % MOD;
    res = (res + l * C(n*m-2, k-2) % MOD ) % MOD;
  }
  cout << res << endl;
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
def solve(s):
    k = 10 ** 9
    if s <= k:
        return 0, 0, 1, 0, 0, s
    X = k
    while True:
        Y = (s - 1) // X + 1
        while Y <= k:
            xy = X * Y - s
            if xy == 0:
                return 0, 0, X, 0, 0, Y
            lim = min(Y, int(xy ** 0.5))
            for y in range(1, lim + 1):
                x, m = divmod(xy, y)
                if x <= X and m == 0:
                    return 0, 0, X, y, x, Y
            Y += 1
        X -= 1


s = int(input())
print(*solve(s))


Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include <string.h>
#define file(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);
using namespace std;
const int maxn=200005;
long long ans1,ans2=1e18,n,da,xiao,maxx,maxy,minx=1e9+10,miny=1e9+10,weizhiy,weizhix;
struct pai
{
	long long x,y;
	bool operator < (const pai &a)const
	{
		long long gx1,gx2;
		if(xiao<=x&&x<=da)
			gx1=0;
		else if(xiao<=y&&y<=da)
			gx1=0;
		else if(y<xiao)
			gx1=xiao-y;
		else if(x>da)
			gx1=x-da;
		else 
			gx1=min(xiao-x,y-da);
		if(xiao<=a.x&&a.x<=da)
			gx2=0;
		else if(xiao<=a.y&&a.y<=da)
			gx2=0;
		else if(a.y<xiao)
			gx2=xiao-a.y;
		else if(a.x>da)
			gx2=a.x-da;
		else 
			gx2=min(xiao-a.x,a.y-da);
		return gx1>gx2;
	}
} p[maxn];
int main()
{
//	file("1"); 
	scanf("%lld",&n);
	if(n==1)
	{
		printf("0");
		return 0;
	}
	for(int i=1; i<=n; i++)
	{
		scanf("%lld%lld",&p[i].x,&p[i].y);
		if(p[i].x>p[i].y)
			swap(p[i].x,p[i].y);
		maxx=max(maxx,p[i].x);
		if(p[i].y>maxy)
		{
			weizhiy=i;
			maxy=p[i].y;
		}
		if(p[i].x<minx)
		{
			weizhix=i;
			minx=p[i].x;
		}
		miny=min(miny,p[i].y);
	}
	ans1=(maxy-miny)*(maxx-minx);
//	cout<<ans1<<endl;
	da=p[weizhix].y,xiao=p[weizhiy].x;
	sort(p+1,p+n+1);
	if(da<xiao)
		swap(da,xiao);
	if(weizhix!=weizhiy)
	{
		for(int i=1; i<=n; i++)
		{
			int t=i;
			if((xiao<=p[i].x&&p[i].x<=da)||(xiao<=p[i].y&&p[i].y<=da))
				continue;
			else if(p[i].x>da)
				da=p[i].x;
			else if(p[i].y<xiao)
				xiao=p[i].y;
			else if(xiao-p[i].x<p[i].y-da)
				xiao=p[i].x;
			else
				da=p[i].y;
		}
		ans2=(maxy-minx)*(da-xiao);
	}
//	cout<<ans2<<endl;
	printf("%lld",min(ans1,ans2));
	return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();
		int G = sc.nextInt();
		int B = sc.nextInt();
		int N = sc.nextInt();
		int cnt = 0;

		for (int r = N / R; r > -1; r--) {
			for (int g = (N - R * r) / G; g > -1; g--) {
				if ((N - R * r - G * g) % B == 0)
					cnt++;
			}
		}

		sc.close();
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21844
from collections import deque
def change(x,y):
    if [x,y] == ["r","g"] or [y,x] == ["r","g"]:
        return "b"
    elif [x,y] == ["g","b"] or [y,x] == ["g","b"]:
        return "r"
    elif [x,y] == ["r","b"] or [y,x] == ["r","b"]:
        return "g"



rgb = ['r','g','b']
while True:
    time = 0
    W_dic = {}
    W_que = deque([])
    worm = tuple(str(input()))
    if worm == ('0',):
        break
    else:
        W_que.append([time,worm])
        W_dic[worm] = time
    while True:
        now_list = W_que.popleft()
        now_time = now_list[0]
        now_worm = now_list[1]
        if now_worm.count('r') == len(now_worm) or now_worm.count('g') == len(now_worm) or now_worm.count('b') == len(now_worm):
            print(now_time)
            break
        a_0 = now_worm[0]
        for i in range(1,len(now_worm)):
            a_1 = now_worm[i]
            rgb_c = rgb
            worm_c = list(now_worm)
            if a_0 != a_1:
                coll = change(a_0,a_1)
                worm_c[i - 1] = coll
                worm_c[i] = coll
                if not tuple(worm_c) in W_dic:
                    W_dic[tuple(worm_c)] = now_time + 1
                    W_que.append([now_time + 1,worm_c])
            a_0 = a_1
        
        if len(W_que) == 0:
            print("NA")
            break

Measured memory_bytes: 12084
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;

int main() {
    int A, B;
    cin >> A >> B;
    if (A + B < 10){
        cout << A + B << endl;
    }
    else {
        cout << "error" << endl;
    }
}


Measured memory_bytes: 256
import numpy as np

n, k = list(map(int, input().split()))
s = str(input())

arr0 = np.array(list(map(len, s.split('1'))))
arr0 = arr0[arr0!=0]

arr1 = np.array(list(map(len, s.split('0'))))
arr1 = arr1[arr1!=0]


ans = 0

if s[0] == '0':
    for i in range(len(arr0)):
        
        if i == 0:
            length = arr0[i:i+k].sum() + arr1[i:i+k].sum()
        else:
            length = arr0[i:i+k].sum() + arr1[i-1:i+k].sum()
        ans = max(ans, length)
        
        if i+k > len(arr0):
            break
        
        
else:        
    for i in range(len(arr0)):
        
        
        length = arr0[i:i+k].sum() + arr1[i:i+k+1].sum()
        ans = max(ans, length)
        
        if i+k > len(arr0):
            break
        
        

if len(s) == s.count('1'):
    print(len(s))
else:
    print(ans)

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

#define rep(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define repn(i, m, n) for (int (i) = (m) ; (i) < (int)(n) ; ++(i))
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define repn_rev(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= (m) ; --(i))

#define INF 2e9
#define ll long long
#define MOD 1e9+7
#define MAX_V 20005

/* 辺を表す構造体 */
struct edge {int to, cap ,rev; };

/* グラフの隣接リスト表現 */
vector<edge> G[MAX_V];
/* DFSですべに調べたかのグラフ */
bool used[MAX_V];

/* fromからtoへ向かう容量capの辺をグラフに追加する */
/* 相互参照できるようにしている */
void add_edge(int from, int to, int cap){
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size() - 1});    
}

/* 増加パスをdfsで探す */
int dfs(int v, int t, int f){
    if(v==t) return f;
    used[v] = true;
    for(int i=0; i<G[v].size(); i++){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap>0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d>0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    for(;;){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if(f==0) return flow;
        flow += f;
    }
}

int main() {
    int N;
    cin >> N;
    vector<int> a(N), b(N), c(N), d(N);
    rep(i, N) cin >> a[i] >> b[i];
    rep(i, N) cin >> c[i] >> d[i];

    /* 0: 始点, 1~N: 赤, N+1~2N: 青, 2N+1: 終点 */
    rep(i, N) {
        add_edge(0, i+1, 1);
        add_edge(i+N+1, 2*N+1, 1);
    }

    rep(i, N) rep(j, N) if(a[i] < c[j] && b[i] < d[j]) add_edge(i+1, j+N+1, 1);
    
    cout << max_flow(0, 2*N+1) << endl;

    return 0;
}


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

int main(){
  int N,buf;
  cin >> N;

  int left = INT_MAX;
  int right= -1;
  for(int i=0; i<N; i++){
    cin >> buf;

    left = min(left , buf);
    right= max(right, buf);
  }

  int ans= right- left;

  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.IO;

class Solve
{
    static void Main(string[] args) {
        var S = Console.ReadLine();
        var len = S.Length;
        long answer = 0;
        for (int bit = 0; bit < 1 << len - 1; bit++) {
            var start = 0;
            var range = 0;
            for (int i = 0; i < len; i++) {
                range++;
                if ((bit & (1 << i)) > 0) continue;
                answer += long.Parse(S.AsSpan(start, range));
                start = i + 1;
                range = 0;
            }
            if (range != 0) answer += long.Parse(S.AsSpan(start, range));
        }
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}

Measured memory_bytes: 27432
#include <iostream>
using namespace std;
struct comd { int sn,d,s,e; };
int main() {
  int x,y,i,j,k,g,n,t,a,b,e,h,dx[4]={1,0,-1,0},dy[4]={0,-1,0,1},d[2][20][20][256],m[20][20],f[20][20];
  char c;
  comd co[10];
  while(cin >> x >> y && x>0) {
	  for (h=0;h<2;h++) for (j=0;j<20;j++) for (k=0;k<20;k++) for (g=0;g<256;g++) d[h][j][k][g]=-1;
	  for (i=0;i<y;i++) {
		  for (j=0;j<x;j++) {
			  cin >> c;  
			  f[i][j]=0;
			  if (c>='0' && c<='9') m[i][j]=c-'0'; else m[i][j]=-1;
			  if (c=='P') { f[i][j]=1; d[0][i][j][0]=0;}
		  }
	  }
	  cin >> n;
	  for (i=0; i<n; i++) {  cin >> g;  cin >> co[g].d >> co[g].s >> co[g].e; co[g].sn=(1 << i);}
	  for (t=0,h=0;t<=100;t++) {
		  for (i=0;i<y;i++) for (j=0;j<x;j++) {
			  if (f[i][j]==0) continue;
		      for (k=0;k<256;k++) {
				if (d[h][i][j][k]==-1) continue;
				a=k; b=d[h][i][j][k];
				for (g=0;g<4;g++) {
					if (j+dx[g]<0 || j+dx[g]>=x || i+dy[g]<0 || i+dy[g]>=y) continue;
					e=m[i+dy[g]][j+dx[g]];
					if (e>=0) if ((co[e].sn & a)==0 && co[e].s<=t && co[e].e>t) {b+=co[e].d; a=a | co[e].sn;}
				}
				d[h][i][j][a]=b;
				for (g=0;g<4;g++) if (j+dx[g]>=0 && j+dx[g]<x && i+dy[g]>=0 && i+dy[g]<y) if (m[i+dy[g]][j+dx[g]]<0) { d[1-h][i+dy[g]][j+dx[g]][a]=b;  f[i+dy[g]][j+dx[g]]=1;} 
				}
			}
			h=1-h;
		}
		a=-1;
		for (i=0;i<y;i++) for (j=0;j<x;j++) for (k=0;k<256;k++) if (a<d[0][i][j][k]) a=d[0][i][j][k];
		cout << a << endl;
	  }
 return 0;
}

Measured memory_bytes: 1964
import * as fs from 'fs'

export const main = (N: number, A: number[]): number => {
  const [Alice, Bob] = A.sort((a, b) => b - a).reduce(
    (acc, val, idx) => {
      if (idx % 2 === 0) acc[0] += val
      else acc[1] += val
      return acc
    },
    [0, 0],
  )
  return Alice - Bob
}

if (require.main === module) {
  const input = (fs.readFileSync('/dev/stdin', 'utf8') as string).split('\n')

  const N = Number(input[0])
  const A: number[] = input[1].split(' ').map(val => Number(val))

  const ret = main(N, A)
  console.log(ret)
}


Measured memory_bytes: 7500
/*
Author: CNYALI_LK
LANG: C++
PROG: C.cpp
Mail: cnyalilk@vip.qq.com
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define all(x) x.begin(),x.end()
using namespace std;
const double eps=1e-8;
const double pi=acos(-1.0);
typedef long long ll;
typedef pair<int,int> pii;
template<class T>int chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>int chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
#define min mmin
#define max mmax
#define abs aabs
int read(){
	int s=0,base=1;
	char c;
	while(!isdigit(c=getchar()))if(c=='-')base=-base;
	while(isdigit(c)){s=s*10+(c^48);c=getchar();}
	return s*base;
}
char WriteIntBuffer[1024];
template<class T>void write(T a,char end){
	int cnt=0,fu=1;
	if(a<0){putchar('-');fu=-1;}
	do{WriteIntBuffer[++cnt]=fu*(a%10)+'0';a/=10;}while(a);
	while(cnt){putchar(WriteIntBuffer[cnt]);--cnt;}
	putchar(end);
}
int c[120202];
int main(){
#ifdef cnyali_lk
	freopen("C.in","r",stdin);
	freopen("C.out","w",stdout);
#endif
	int n=read(),x;
	int cnt=0;
	for(int i=1;i<=n;++i){
		x=read();
		if(x>n){
			++cnt;
		}
		else ++c[x];
	}
	for(int i=1;i<=n;++i)if(c[i]>=i)cnt+=c[i]-i;
	else cnt+=c[i];
	write(cnt,'\n');
	return 0;
}



Measured memory_bytes: 256