akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

class Counting {
	unsigned long long p, n;
	vector<long long> invMemo, facMemo, facInvMemo;
public:
	Counting(unsigned long long nn, unsigned long long np) {
		p = np;
		n = nn;
		invMemo.resize(n + 1);
		facMemo.resize(n + 1);
		facInvMemo.resize(n + 1);
		facMemo[0] = 1;
		facMemo[1] = 1;
		facInvMemo[0] = 1;
		facInvMemo[1] = 1;
		invMemo[0] = 0;
		invMemo[1] = 1;
		for (unsigned long long i = 2; i <= n; i++) {
			invMemo[i] = p - (p / i)*invMemo[p%i] % p;
			facMemo[i] = (facMemo[i - 1] * i) % p;
			facInvMemo[i] = (facInvMemo[i - 1] * invMemo[i]) % p;
		}
	}
	unsigned long long fac(unsigned long long k) {
		return facMemo[k];
	}
	unsigned long long facInv(unsigned long long k) {
		return facInvMemo[k];
	}
	unsigned long long choose(unsigned long long n, unsigned long long k) {
		if (!(0 <= k && k <= n))
			return 0;
		return (((facMemo[n] * facInvMemo[k]) % p)*facMemo[n - k]) % p;
	}
	unsigned long long divide(unsigned long long a, unsigned long long b) {
		return (a * invMemo[b]) % p;
	}
	unsigned long long mod(unsigned long long a) {
		a %= p;
		if (a < 0) a += p;
		return a;
	}
	unsigned long long power(unsigned long long a, unsigned long long e) {
		unsigned long long ans = 1;
		for (; e > 0; e /= 2) {
			if (e % 2 != 0)
				ans = ans * a % p;
			a = a*a%p;
		}
		return ans;
	}
};

int main() {
	int x[9] = { -1, -1, -1, 0, 0, 0, 1, 1, 1 };
	int y[9] = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };
	unsigned long long ans[10] = {};
	map<unsigned long long, int> mp;
	long long h, w, n;
	vector<long long> a, b;
	cin >> h >> w >> n;
	a.resize(n);
	b.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 9; j++) {
			if (b[i] + x[j] > 1 && b[i] + x[j] < w && a[i] + y[j] > 1 && a[i] + y[j] < h) {
				mp[(a[i] + y[j]) * 1000000001 + b[i] + x[j]]++;
			}
		}
	}
	ans[0] = (h-2) * (w-2);
	for (auto it = mp.begin(); it != mp.end(); it++) {
		ans[it->second]++;
	}
	for (int i = 1; i < 10; i++) {
		ans[0] -= ans[i];
	}
	for (int i = 0; i < 10; i++)
		cout << ans[i] << endl;
	//cin >> w;
	return 0;
}

Measured memory_bytes: 58112
a, b, c = map(int, raw_input().split())
t = 0
while a != b or b != c or c != a:
    a, b, c = sorted([a, b, c])
    t += (c-a)/2
    a += (c-a)/2 * 2
    t += (c-b)/2
    b += (c-b)/2 * 2
    a, b, c = sorted([a, b, c])
    if a == b and a == c - 1:
        a += 1
        b += 1
        t += 1
    elif b == c and a == b - 1:
        a += 2
        t += 1
print t

Measured memory_bytes: 28012
from heapq import heapify, heappop, heappush
from sys import stdin

N, M = map(int, input().split())
A = list(map(int, stdin.readline().split()))
heapify(A)
BC = [None] * M
for i in range(M):
    BC[i] = tuple(map(int, stdin.readline().split()))
BC = sorted(BC, key=lambda x: x[1], reverse=True)

enough = False
for bc in BC:
    if enough:
        break
    for i in range(bc[0]):
        if bc[1] <= A[0]:
            enough = True
            break
        heappop(A)
        heappush(A, bc[1])

print(sum(A))


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

const int maxn=2e5+5;
int n;
string b[maxn];
string ans[maxn];
int id=0;
int tot=0;
int maxi=0;

int main(){
	cin >> n;
	for (int i=1;i<=n;i++){
		cin >> b[i];	
	}
	sort(b+1,b+n+1);
	for (int i=1;i<=n;i++){
		if (b[i]!=b[i-1])tot=1;	
		else tot++;
		if (tot > maxi){
			maxi = tot;
			ans[id=1]=b[i];
		}
		else if (tot==maxi) ans[++id]=b[i];
	}
	for (int i=1;i<=id;i++){
		cout << ans[i] << endl;	
	}
	return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
//#define MOD 998244353

typedef long long int ll;
typedef unsigned long long int ull;

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 main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	ll N;
	cin >> N;
	vl W(N);

	rep(i, N) {
		cin >> W[i];
	}

	ll ret;
	ll l, r;
	l = r = 0;

	rep(i, N) {
		r += W[i];
	}
	ret = r;

	rep(i, N) {
		l += W[i];
		r -= W[i];
		chmin(ret, abs(l - r));
	}


	cout << ret << endl;


	return 0;
}



Measured memory_bytes: 888
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int H, W, K;
    cin >> H >> W >> K;

    vector<vector<char>> c(H, vector<char>(W));

    REP(i, H) REP(j, W) {
        cin >> c[i][j];
    }

    ll ans = 0;
    REP(i, 1 << H) REP(j, 1 << W) {
        int cnt = 0;
        REP(h, H){
            if (!(i >> h & 1)) continue;
            REP(w, W) {
                if (!(j >> w & 1)) continue;

                if (c[h][w] == '#') cnt++;
            }
        }

        if (cnt == K) ans++;
    }

    print(ans);

    
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  int key;
  Node *parent, *left, *right;
};

Node *NIL;
Node *root;

Node * find(Node *u, int k){
  while (u != NIL && k != u->key){
    if (k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k){
  Node *x = root;
  Node *y = NIL;
  Node *z;

  z = (Node*)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL){
    y = x;
    if (z->key < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;
  if (y == NIL){
    root = z;
  } else  {
    if (z->key < y->key) y->left = z;
    else y->right = z;
  }
}

void inorder(Node *u){
  if (u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if (u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  string com;

  scanf("%d", &n);
  for (i=0; i<n; i++){
    cin >> com;
    if (com[0] == 'f'){
      scanf("%d", &x);
      Node *t = find(root, x);
      if (t != NIL) printf("yes\n");
      else printf("no\n");
    } else if (com == "insert"){
      scanf("%d", &x);
      insert(x);
    } else if (com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 21932
N, X, T = map(int, input().split())
P = 1
if X > 1:
    while True:
        value = int(N / X)
        re = N % X
        if re == 0:
            P = value
            Time = T * P
            break
        else:
            P += value
            Time = T * P
            break
else:
    Time = T * N
print(Time)

Measured memory_bytes: 9096
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] input = br.readLine().split(" ");
        int a = Integer.parseInt(input[0]);
        int b = Integer.parseInt(input[1]);
        
        out.println(Integer.max(Integer.max(a + b, a - b), a * b));
        out.close();
        
    }
}

Measured memory_bytes: 32752
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/



////////////////////////////////////////
ll min(ll a,ll b){return a<b?a:b;}

int main(){
    int n,a,b;cin>>n>>a>>b;
    int x[n-1];
    int s,t;cin>>s;
    for(int i=0;i<=n-2;i++){
        t=s;cin>>s;x[i]=s-t;
    }
    sort(x,x+n-1);
    ll ans=0;
    for(int i=0;i<=n-2;i++){
        ans+=min((ll)x[i]*a,b);
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#define INF 1000000009
#define LINF 1000000000000000009
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmax(T &a, const T&b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T&b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n - 1);
	for (int i = 0; i < n; i++) {
		cin >> a[i]; a[i]--;
	}
	for (int i = 0; i < n; i++) cin >> b[i];
	for (int i = 0; i < n - 1; i++) cin >> c[i];
	int ans = 0;
	for (int i = 0; i < n; i++) ans += b[i];
	for (int i = 0; i < n - 1; i++) {
		if (a[i] + 1 == a[i + 1]) {
			ans += c[a[i]];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, M;
  cin >> N >> M;
  vector<int> v(N, -1);

  if(N == 1 && M == 0){
    cout << 0 << endl;
    return 0;
  }
  
  bool ok = true;
  rep(i,M){
    int s, c;
    cin >> s >> c;
    s--;
    if(s < 0 || s >= N){
      ok = false;
      break;
    }

    if(v[s] != -1 && v[s] != c){
      ok = false;
      break;
    }

    if(N > 1 && s == 0 && c == 0){
      ok = false;
      break;
    }

    v[s] = c;
  }

  if(!ok){
    cout << -1 << endl;
    return 0;
  }

  rep(i,v.size()){
    if(i==0 && v[i] == -1) v[i] = 1;
    if(i>0 && v[i] == -1) v[i] = 0;
  }

  rep(i,v.size()){
    cout << v[i];
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int R = scan.nextInt();
      	int G = scan.nextInt();
      	int B = scan.nextInt();
      	int N = scan.nextInt();
      	int counter = 0;
      	int k = N;
      	for(int i=0; i <= N/R; i++){//i<=4 i++
        	k = N - R*i;//k=4,3,2,1,0
          	for(int j= 0; j <= k/G;j++){
            	int c = k -G*j;//c=4,2,
             	if(c%B == 0){
                	counter++;
                }
            }
        }
      	System.out.print(counter);
    }

}

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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N;
    map<char, int> list;
    for (auto x = 'a'; x <= 'z'; x++)
        list[x] = MOD;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        string tmp;
        cin >> tmp;
        map<char, int> temp;
        for (auto x = 'a'; x <= 'z'; x++)
            temp[x] = 0;
        for (int j = 0; j < tmp.size(); j++)
            temp[tmp[j]]++;
        for (auto x : temp)
            list[x.first] = min(x.second, list[x.first]);
    }
    string ans = "";
    for (auto x : list)
        for (int i = 0; i < x.second; i++)
            ans.push_back(x.first);
    cout << ans;
}

Measured memory_bytes: 256
"use strict"
const assert = require('assert');

function main(input) {
    let ret = check(input);
    console.log(ret);
}

function check(input) {
    let ans = 0;
    let [a, b, c, k] = input.split(" ").map((i) => parseInt(i));
    if (a >= k && k != 0) {
        ans += k;
        k = 0;
    } else if (a < k) {
        ans += a;
        k -= a;
    }
    if (b >= k && k != 0) {
        k = 0;
    } else if (b < k) {
        k -= b;
    }
    if (c >= k && k != 0) {
        ans -= k;
        k = 0;
    } else if (c < k) {
        ans -= c;
        k -= c;
    }
    return ans;
}

var input;
input = require('fs').readFileSync('/dev/stdin', 'utf8');
main(input);

// check
// var answer;

// input = `2 1 1 3`;
// answer = `2`;
// assert.equal(check(input), answer);

// input = `1 2 3 4`;
// answer = `0`;
// assert.equal(check(input), answer);

// input = `2000000000 0 0 2000000000`;
// answer = `2000000000`;
// assert.equal(check(input), answer);

Measured memory_bytes: 29936
#include <iostream>

int solve(std::string s, char ch) {
    int ans = 0;
    if (s[0] != ch) {
        ++ans;
    }
    ch = (ch == '0') ? '1' : '0';
    for (int i=1; i<s.size(); ++i) {
        if (s[i] != ch) ++ans;
        ch = (ch == '0') ? '1' : '0';
    }

    return ans;
}

int main() {
    std::string s;
    std::cin >> s;
    std::cout << std::min(solve(s, '0'), solve(s, '1')) << '\n';
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;

#define rep(i, n) \
for(int i = 0; i <n; i++)
#define REP(i, a, b) \
for(int i = int(a); i <= int(b); i++)
#define TRvi(c, it) \
for(vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for(vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for(msi::iterator it = (c).begin(); it != (c).end(); it++)

#define INF 2000000000

#define MEMSET_INF 127
#define MEMSET_HALF_INF 63
bool check(ll x, vector<ll> logs, ll k){
    ll summ = 0;
    if(x!=0){
        rep(i,logs.size()){
            if(logs[i]%x==0){summ+=(logs[i]/x-1);}
            else{summ+=logs[i]/x;}
        }
    }
//    }else{
//        rep(i,logs.size()){
//            summ+=logs[i];
//        }
//    }
    return summ<=k;
}
void solve(){
    ll n,k;
    cin>>n>>k;
    vector<ll> logs(n);
    ll maxx = 0;
    rep(i,n) {cin>>logs[i]; if(logs[i]>maxx){maxx=logs[i];}}
    ll low = 1;
    ll high = maxx;
    while (low<high) {
        ll mid = (low+high)/2;
        if(check(mid, logs, k)){
            high=mid;
        }else{
            low=mid+1;
        }
    }
    cout<<low<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 6240
#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d%d",&a,&b);
    c=a+b;
    d=b-a;
    if(b%a==0){
        printf("%d\n",c);
    }
    else{
        printf("%d\n",d);
    }
}


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

using namespace std;

string s;
int n,m;
vector<int> l;

int main(void)
{
	while(true)
	{
	l.clear();
	s.clear();
	cin >> n;
	if(n == 0)
		exit(0);
	cin >> m;
	cin >> s;
	int cur = 0;
	for(int i = 0;i < m - 2;i++)
	{
		if(s[i] == 'I' && s[i+1] == 'O' && s[i+2] == 'I')
		{
			cur++;
			i++;
		}
		else
		{
			if(cur != 0)
			{
				l.push_back(cur);
				cur = 0;
			}
		}
	}
	if(cur != 0)
	{
		l.push_back(cur);
		cur = 0;
	}
	int result = 0;
	for(auto itr = l.begin();itr != l.end();itr++)
	{
		if(*itr >= n)
		{
			result = result + ((*itr + 1) - n);
		}
	}
	cout << result << endl;
	}
}

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

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

// DON'T USE THESE MACROS DURING ICPC PRACTICE
#define For(i,n) for (int i=0; i<n; i++)
#define FOR(i,a,b) for (int i=a; i<=b; i++)
#define Down(i,n) for (int i=n-1; i>=0; i--)
#define DOWN(i,a,b) for (int i=b; i>=a; i--)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<int> vi;

const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-10;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

struct Point {
	int a, b;
	bool operator < (const Point& o) const {
		return (a!=o.a ? (a<o.a) : (b<o.b));
	}
	Point operator - (const Point& o) const {
		return { a-o.a, b-o.b };
	}
};

ll power(ll b, ll e) {
	ll r = 1;
	for(;e;e/=2) {
		if(e&1) r = r*b % MOD;
		b = b*b % MOD;
	}
	return r;
}

const int N = 2e5+1;
const int K = 3e3+2;
ll fact[N], invf[N];
ll dp[K];

ll ncr(int n, int r) {
	if(r<0||r>n) return 0;
	return fact[n] * invf[r] % MOD * invf[n-r] % MOD;
}

ll paths(const Point& p) {
	assert(p.a>=0 && p.b>=0);
	return ncr(p.a+p.b, p.a);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(10);

	fact[0] = invf[0] = 1;
	for(int i=1;i<N;i++) {
		fact[i] = fact[i-1] * i % MOD;
		invf[i] = power(fact[i], MOD-2);
	}

	int n, m, k;
	cin >> n >> m >> k;
	vector<Point> p;
	for(int i=0;i<k;i++) {
		int a, b;
		cin >> a >> b;
		p.push_back({a,b});
	}
	p.push_back({1,1});
	p.push_back({n,m});
	sort(p.begin(),p.end());

	dp[0] = 1;
	for(int i=1;i<=k+1;i++) {
		ll bad = 0;
		for(int j=1;j<i;j++) {
			Point d = p[i]-p[j];
			if (d.a>=0 && d.b>=0) {
				bad += dp[j] * paths(d) % MOD;
			}
		}
		dp[i] = (paths(p[i]-p[0]) - bad%MOD + MOD) % MOD;
	}
	cout << dp[k+1] << nl;

	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
bool ab[100000],bc[100000],ac[100000];

bool match(char p, char q)
{
	return (p == '?' || q == '?' || p == q);
}

int main()
{
	string a,b,c;
	cin >> a >> b >> c;

	int A = a.size(), B = b.size(), C = c.size();
	rep(i,A)
	{
		rep(j,B)
		{
			if (!match(a[i],b[j])) ab[i-j+50000] = true;
		}
	}
	rep(i,B)
	{
		rep(j,C)
		{
			if (!match(b[i],c[j])) bc[i-j+50000] = true;
		}
	}
	rep(i,A)
	{
		rep(j,C)
		{
			if (!match(a[i],c[j])) ac[i-j+50000] = true;
		}
	}
	int ans = 6000;
	for (int i = -4000; i <= 4000; ++i)
	{
		for (int j = -4000; j <= 4000; ++j)
		{
			if (!ab[i+50000] && !ac[j+50000] && !bc[j-i+50000])
			{
				int L = min(0,min(i,j));
				int R = max(A,max(B+i,C+j));
				ans = min(ans,R-L);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*
Code by b21
Time: 19:39 Sun 01/03/2020
*/

#include <bits/stdc++.h>

using namespace std;

const int mn = 5 * (int)(1e5) + 10;
const int mod = 1 * (int)(1e9) + 7;
const int mm = 1 * (int)(1e3) + 10;
const int base = 1 * (int)(1e9);
const bool aNs = 0;

int tt, ntest = 1;
void docfile()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    if (ifstream("test.inp"))
    {
       freopen("test.inp", "r", stdin);
       if (!aNs) freopen("test.out", "w", stdout);
       else freopen ("test.ans", "w", stdout);
    }
   else if (ifstream("abc157_e.inp"))
    {
        freopen("abc157_e.inp", "r", stdin);
        freopen("abc157_e.out", "w", stdout);
    }
}

template <typename T>
void read(T& x)
{
    x = 0; T f = 1;
    char ch = getchar();
    while (!isdigit(ch)) f = ch == '-' ? - f : f, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
    x *= f;
}

template <typename T>
void write (T a)
{
    if (a < 0)
    {
        putchar ('-');
        write (-a);
        return;
    }
    if (a < 10)
    {
        putchar ('0' + a);
        return;
    }
    write (a / 10);
    putchar ((char)('0' + (a % 10)));
}

int C[mn][28];

void ub (int x, char c, int ok)
{
    int k = c - 'a';
    for (int i = x; i < mn; i += i & - i) {
        C[i][k] += ok;
    }
}

int v[30];

void db (int x, int ok) {
    if (!x) return;
    int s = 0;
    for (int i = x; i >= 1; i -= i & - i) {
        for (int c = 0; c <= 'z' - 'a'; ++ c)
        v[c] += ok * C[i][c];
    }
}

void enter()
{
    int n;
    cin >> n;
    cin.ignore();
    string s;
    getline (cin, s);
    for (int i = 0; i < n; ++ i)
    ub (i + 1, s[i], 1);
    int q;
    cin >> q;
    for (int i = 0; i < q; ++ i) {
        int id;
        cin >> id;
        if (id == 1) {
            int x;
            char c;
            cin >> x >> c;
            if (s[x - 1] == c) continue;
            ub (x, s[x - 1], - 1);
            s[x - 1] = c;
            ub (x, s[x - 1], 1);
        } else {
            int l, r;
            cin >> l >> r;
            memset (v, 0, sizeof (v));
            db(r, 1);
            db(l - 1, - 1);
            int sol = 0;
            for (int i = 0; i <= 'z' - 'a'; ++ i)
            if (v[i] > 0) ++ sol;
            cout << sol << "\n";
        }
    }
}

void solve()
{

}

void print_result()
{

}

main()
{
    docfile();
    //cin>>ntest;
    for (tt = 1; tt <= ntest; ++ tt)
    {
        enter();
        solve();
        print_result();
    }
}

Measured memory_bytes: 55708
/*input
6 5
1 2
2 3
3 4
4 5
5 6
*/
#include <bits/stdc++.h>
using namespace std;
long long n,tin[55],fup[55],timer=0,res=0;
vector<int> v[55];
bool vis[55]={false};
void dfs(int u, int dad=0){
	vis[u]=true;
	tin[u]=fup[u]=timer++;

	for(int i:v[u]){
		if(i==dad) continue;
		else if(vis[i]) {
			fup[u]=min(tin[i],fup[u]);
			continue;
		}
		dfs(i,u);
		fup[u]=min(fup[u],fup[i]);
		if(fup[i]>tin[u]) ++res;
	}
}
int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	int n,m,x,y;
	for(cin>>n>>m;m--;){
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(1);
	cout<<res;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
int main()
{
  int a,b;
  cin >> a >> b;
  if(b==100){
    if(a==0)printf("%d",101);
    if(a==1)printf("%d",10100);
    if(a==2)printf("%d",1010000);
  }else{
  if(a==0)printf("%d",b);
  if(a==1)printf("%d",100*b);
  if(a==2)printf("%d",10000*b);
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define MAX_N 100000
#define pb push_back
using namespace std;

int par[MAX_N];

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

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

bool same(int x,int y){
	return root(x)==root(y);
}

void unite(int x,int y){
	x=root(x);
	y=root(y);
	if(x==y)return;
	par[x]=y;
}

int main(){
	int n,q;
	int a,b,c;
	cin>>n>>q;

	init(n);
	while(q--){
		cin>>a>>b>>c;
		if(a==0){
			unite(b,c);
		}
		else{
			cout<<same(b,c)<<endl;
		}
	}
}

Measured memory_bytes: 3152
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int n;
void CountingSort(unsigned short *A,unsigned short *B){
  int i,j,C[VMAX+1];

  for(i=0;i<=VMAX;i++){
    C[i]=0;
  }
  for(j=1;j<=n;j++){
    C[A[j]]++;
  }
  for(i=1;i<=VMAX;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=n;j>0;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
}

int main(){
  int i;
  unsigned short *A,*B;

  scanf("%d",&n);

  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);

  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
  }

  CountingSort(A,B);

  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 9552
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define inf 2333333333333333333LL
 
struct edge { int t,v,next; }a[400010];
 
struct node
{
    ll a,b;
    node() {}
    node(ll a,ll b):a(a),b(b) {}
}p[200010],q[200010];
 
vector<node> v[200010];
 
int head[200010],f[200010],in[200010],n,t1,t2,tot;
ll h[200010],mx,ans;
 
inline int rd()
{
    int x=0;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar());
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x;
}
 
inline void add(int x,int y,int z) { a[++tot].t=y;a[tot].v=z;a[tot].next=head[x];head[x]=tot; }
 
inline void dfs(int x,int y)
{
    if (in[x]==1) { v[x].push_back(node(0,0));return; }
    int h1=0,h2=0,s1,s2,i1,i2;
    for (int i=head[x];i;i=a[i].next)
    {
        int t=a[i].t;
        if (t==y) continue;
        f[t]=a[i].v;dfs(t,x);
        if (!h1) h1=t;
        else h2=t;
    }
    s1=v[h1].size();s2=v[h2].size();
    if (!s1||!s2) return;
    if (s1>s2) swap(s1,s2),swap(h1,h2);
    ll hh=mx-f[h1]-f[h2],minn=inf;
    t1=t2=i2=0;
    for (i1=0;i1<s1;i1++)
    {
        while (v[h1][i1].b+minn>hh&&i2<s2) minn=min(minn,v[h2][i2++].a);
        if (v[h1][i1].b+minn>hh) break;
        p[++t1]=(node){v[h1][i1].a+f[h1],v[h2][i2-1].b+f[h2]};
    }
    for (int i=0;i<s1;i++) h[i]=inf;
    minn=inf;i1=0;
    for (i2=0;i2<s2;i2++)
    {
        while (v[h2][i2].b+minn>hh&&i1<s1) minn=min(minn,v[h1][i1++].a);
        if (v[h2][i2].b+minn>hh) break;
        h[i1-1]=min(h[i1-1],v[h2][i2].a+f[h2]);
    }
    for (int i=0;i<s1;i++) if (h[i]!=inf) q[++t2]=(node){h[i],v[h1][i].b+f[h1]};
    i1=1;i2=1;
    while (i1<=t1||i2<=t2)
    {
        node hh;
        if (i2>t2) hh=p[i1++];
        else if (i1>t1||p[i1].b>q[i2].b) hh=q[i2++];
        else hh=p[i1++];
        v[x].push_back(hh);
    }
}
 
inline bool check()
{
    for (int i=1;i<=n;i++) v[i].clear();
    dfs(1,0);
    if (v[1].size()) return true;
    return false;
}
 
int main()
{
    n=rd();
    for (int i=2;i<=n;i++)
    {
       int x=rd(),y=rd();
       add(i,x,y);add(x,i,y);
       in[i]++;in[x]++;
    }
    ll l=0,r=233333333333LL;
    while (l<r)
    {
       mx=(l+r)>>1;
       if (check()) r=mx;
       else l=mx+1;
    }
    printf("%lld\n",l);
    return 0;
}

Measured memory_bytes: 37340
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int n; cin >> n;
	vector<int>a(n);
	rep(i, 0, n)cin >> a[i];
	deque<int>ans;
	rep(i, 0, n) {
		if (i % 2 == 0) {
			ans.push_back(a[i]);
		}
		else {
			ans.push_front(a[i]);
		}
	}
	if (n % 2 == 0) {
		rep(i, 0, n) {
			cout << ans[i];
			if (i != n - 1)cout << " ";
			else cout << "\n";
		}
	}
	else {
		rREP(i, 0, n) {
			cout << ans[i];
			if (i != 0)cout << " ";
			else cout << "\n";
		}
	}
	

	return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string.h>
#include <deque>
#define REP(i,j,n) for(int i=j;i<n;i++)
#define SORT(x) sort(x.begin(),x.end())

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> vv(n);
	for (int i = 0; i < n; i++) {
		cin >> vv[i];
		if(i!=n-1)cout << vv[i] << " ";
		else cout << vv[i] << endl;
	}
	for (int i = 1; i < n; i++) {
		int v, j;
		v = vv[i];
		j = i - 1;
		while (j >= 0 && vv[j] > v) {
			vv[j + 1] = vv[j];
			j--;
			vv[j + 1] = v;
		}
		//vv[j + 1] = v;
		
		
		for (int k = 0; k < n; k++) {
			if(k!=n-1)cout << vv[k] << " ";
			else cout << vv[k] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int R;
    Scd(R);

    printf ("%.5lf\n", R*PI*2 );


    return 0;
}



Measured memory_bytes: 3828
import itertools
def main():
    N,M,Q = map(int,input().split())
    q = []
    for i in range(Q):
        a,b,c,d = map(int,input().split())
        q.append([a-1,b-1,c,d])
    A = [i for i in range(1,M+1)]
    # if N==10:
    #
    #     ans = 0
    #     for i, qq in enumerate(q):
    #         if A[qq[1]] - A[qq[0]] == qq[2]:
    #             ans += qq[3]
    #     print(ans)
    #
    # else:
    aa = list(itertools.combinations_with_replacement(A,N))
    ans = 0

    for i, cc in enumerate(aa):
        ans1 = 0
        for j, qq in enumerate(q):
            if cc[qq[1]] - cc[qq[0]] == qq[2]:
                ans1 += qq[3]
            # print(ans1,cc)
        ans = max(ans,ans1)
    print(ans)

if __name__=='__main__':
    main()


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

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

    int res = 0;
    vector<bool> exists(1e9 + 1, false);
    for (int i = 0; i < N; i++)
    {
        int Ai;
        cin >> Ai;
        if (exists.at(Ai))
        {
            res--;
            exists.at(Ai) = false;
        }
        else
        {
            res++;
            exists.at(Ai) = true;
        }
    }
    cout << res << endl;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

constexpr int mod = 998244353;

long long inv(long long n) {
    long long res = 1;
    while (n > 1) {
        res *= (mod - mod/n);
        res %= mod;
        n = mod % n;
    }
    return res;
}

void solve() {
    int n, m, k;
    cin >> n >> m >> k;

    vector<ll> powM(n);
    powM.at(0) = 1;
    for (int i=1; i<n; ++i) {
        powM.at(i) = powM.at(i-1) * (ll)(m-1);
        powM.at(i) %= mod;
    }

    vector<ll> comb(n);
    ll nume = 1, deno = 1;
    for (int i=0; i<n; ++i) {
        comb.at(i) = nume * inv(deno);
        comb.at(i) %= mod;
        nume *= (ll)(n-i-1);
        nume %= mod;
        deno *= (ll)(i+1);
        deno %= mod;
    }

    ll res = 0;
    for (ll i=0; i<=k; ++i) {
        ll tmp = m;
        tmp *= comb.at(i);;
        tmp %= mod;
        tmp *= powM.at(n-i-1);
        tmp %= mod;
        res += tmp;
        res %= mod;
    }

    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 6368
//Author rahuliitkgp
/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define ff              first
#define ss              second
#define SZ(x)           ((int)(x).size())
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main() {
	cpp();
	ll n;
	cin >> n;
	vector < vector<ll> > v(n, vector <ll>(3, 0) );
	for (ll i = 0; i < n; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		v[i][0] = a;
		v[i][1] = b;
		v[i][2] = c;
	}
	vector<vector<ll> > dp(n, vector<ll>(3, 0));
	dp[0][0] = v[0][0];
	dp[0][1] = v[0][1];
	dp[0][2] = v[0][2];
	for (ll i = 1; i < n; i++) {
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + v[i][0];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + v[i][1];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + v[i][2];
	}
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
	return 0;
}







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

int main() {
    int64_t n;
    cin >> n;
    int64_t p = 1;
    int64_t s = pow(10, 9) + 7;
    for (int64_t i = 1; i <= n; i++) {
        p *= i % s;
        p = p % s;
    }
    cout << p % s << endl;
}


Measured memory_bytes: 256
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
ans = 0

for i in range(1,K+1):
    for j in range(i,K+1):
        for k in range(j,K+1):
            if i == j and j == k:
                ans += gcd(i,j,k)
            elif i != j and j != k and k!= i:
                ans += gcd(i,j,k)*6
            else:
                ans += gcd(i,j,k)*3
print(ans)

Measured memory_bytes: 9632
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n+1);
  rep(i,n+1) cin >> a[i];
  vector<ll> m(n+1);
  m[n] = a[n];
  rep(i,n) m[n-i-1] = m[n-i] + a[n-i-1];

  ll d = 1;
  ll ans = 0;
  rep(i,n+1){
    ans += d;
    if(d<a[i]){
      cout << -1 << endl;
      return 0;
    }
    d -= a[i];
    d *= 2;
    if(i<n) d = min(d,m[i+1]);
  }
  if(d>0) ans = -1;
  cout << ans << endl;
}


Measured memory_bytes: 4548
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int N;
vector<int> a;
ll dp[450][450];
vector<ll> sum;

ll solve(int l, int r){
    if(r-l == 1) return dp[l][r] = 0;
    if(dp[l][r] != LINF) return dp[l][r];
    ll res = LINF;
    repr(i,l+1,r){
        ll tmp = solve(l,i)+solve(i,r)+sum[r]-sum[l];
        res = min(res,tmp);
    }
    return dp[l][r] = res;

}


int main(){
    cin >> N;
    a.resize(N);
    sum.resize(N+1);
    rep(i,N) cin >> a[i];
    rep(i,N) sum[i+1] = sum[i] + a[i];

    rep(i,450)rep(j,450) dp[i][j] = LINF;

    cout << solve(0,N) << endl;
    
}



Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define int long long
using namespace std;
 
int32_t main() {
 
	int a,b,k;	cin >> a >> b >> k;
	
	vector<int> ans;
	
	int g = __gcd(a,b);
	
	for(int x=1;x*x<=g;x++){
		if(g % x == 0){
			ans.push_back(x);
			if(g/x != x)
				ans.push_back(g/x);
		}
	}
	
	sort(ans.rbegin() , ans.rend());
	
	cout << ans[k-1];
 
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int n;
  n = s.size();
  bool can = false;
  bool can1 = false;
  bool can2 = false;
  bool can3 = false;
  if (s.at(0) == 'A') {
    can1 = true;
  }
  int cnt = 0;
  int ci;
  for (int i = 2; i < n - 1; i++) {
    if (s.at(i) == 'C') {
      cnt++;
      ci = i;
    }
  }
  if (cnt == 1) {
    can2 = true;
  }
  bool nonc = true;
  int al;
  for (int i = 1; i < n; i++) {
    if (i == ci) {
      continue;
    }
    al = s.at(i) - 'a';
    if (!(al >= 0 && al <= 25)) {
      nonc = false;
    }
  }
  if (nonc) {
    can3 = true;
  }
  if (can1 && (can2 && can3)) {
    cout << "AC" << endl;
  }
  else {
    cout << "WA" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

void solve(int now){
  if(now == 0) return;
  int num = now%10;
  if(num < 0) num *= (-1);
  if(now < 0) {
    num = (10-num)%10;
  }
  solve((now-num)/(-10));
  cout << num;
}

int main(){
  int num;
  while(cin >> num){
    if(num == 0) break;
    solve(num);
    cout << endl;
  }
}

Measured memory_bytes: 3044
/**
*    author:  yuya1234
*    created: 15.08.2020 21:23:30
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SORT(x) sort(x.begin(),x.end())
#define SORTD(x) sort(x.rbegin(),x.rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SZ(x) ll(x.size())

#define MEMSET(v, h) memset((v), h, sizeof(v))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

  ll x,k,d;
  cin>>x>>k>>d;

  ll a=x/d;
  ll ans=x;

  if(x<0)k*=-1;

  if((k>0 && k-a>=0) || (k<0 && (-1)*k-(-1)*a>=0))
  {
    if(k<0)d*=-1;
    if(abs(k-a)%2==1)
    {
      ans=min(abs(x-abs(a)*d-d),abs(x+abs(a)*d+d));
    }
    else
    {
      ans=min(abs(x-abs(a)*d),abs(x+abs(a)*d));
    }
  }
  else
  {
    ans=min(abs(x-k*d),abs(x+k*d));
  }

  cout<<abs(ans)<<endl;

  return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
    int a[5],k,max,i;
    while(scanf("%d%d%d%d",&a[0],&a[1],&a[2],&k)==4)
    {
        sort(a,a+3);
        max=a[2];
        for(i=1;i<=k;i++)
        {
            max=max*2;
        }
        max=max+a[0]+a[1];
        printf("%d\n",max);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
	int h, w; cin >> h >> w;
	map<char, int> a;
	REP(i, h * w) {
		char c; cin >> c;
		a[c - 'a']++;
	}
	int cnt1, cnt2, cnt3;
	cnt1 = cnt2 = cnt3 = 0;
	for (auto x : a) {
		if (x.second % 4 == 1) cnt1++;
		if (x.second % 4 == 2) cnt2++;
		if (x.second % 4 == 3) cnt1++;
	}
	bool ok = false;
	if (h % 2 && w % 2) {
		if (cnt1 == 1)
			if (cnt2 <= (h / 2) + (w / 2))
				ok = true;
	}
	else if (h % 2 == 0 && w % 2 == 0) {
		if (cnt1 == 0 && cnt2 == 0 && cnt3 == 0)
			ok = true;
	}
	else if (h % 2 == 0 && w % 2) {
		if (cnt1 == 0 && cnt3 == 0)
			if (cnt2 <= h / 2)
				ok = true;
	}
	else if (h % 2 && w % 2 == 0) {
		if (cnt1 == 0 && cnt3 == 0)
			if (cnt2 <= w / 2)
				ok = true;
	}
	cout << (ok ? "Yes" : "No") << '\n';
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);

  int l = 1, r = 0;
  rep(i, 0, n) {
    cin >> a[i];
    r = max(r, a[i]);
  }

  // upper bound
  while (l != r) {
    int mid = (r + l) >> 1;
    bool ok = [&] {
      int res = 0;
      rep(i, 0, n) { res += (a[i] - 1) / mid; }
      return res <= k;
    }();
    if (ok)
      r = mid;
    else
      l = mid + 1;
  }
  cout << l;
  return 0;
}


Measured memory_bytes: 3972
using System;
using System.Collections.Generic;
//using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        const long MOD = 1000000007;
        var sc = new Scanner();

        int r = int.Parse(Console.ReadLine());

        Console.WriteLine(3 * r * r);
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll MOD2=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

void solve(int ca){
    int N,K;

    cin>>N>>K;
    bool have[110]={0};
    int a;
    for (int i = 0; i < K; ++i) {
        int d; cin>>d;
        for (int j = 0; j < d; ++j) {
            cin>>a; --a;
            have[a]=true;
        }
    }

    int cnt=0;
    for (int i = 0; i < N; ++i) {
        if(!have[i]) cnt++;
    }
    cout<<cnt<<endl;

}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 3636
N = int(input())
S = input()
ans = [0] * len(S)
alpha_list = [chr(i) for i in range(65, 65+26)]
alpha_dict = {}
for i in range(len(alpha_list)):
    alpha_dict[alpha_list[i]] = i

for i in range(len(S)):
    s = S[i]
    pos = alpha_dict[s]
    if pos + N < 26:
        ans[i] = alpha_list[pos + N]
    else:
        pos = pos - 26
        ans[i] = alpha_list[pos + N]

print(*ans, sep = "")

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

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;

#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

const int maxN = 1e6+10, mod=1e9+7;

void solve() {
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(NULL);
	
	int t;
	cin >> t;
	cin.ignore();
	string s;
	
	cin >> s;
	int n = len(s);
	
	if(n <= t) {
		cout << s << '\n';
	} else {
		cout << s.substr(0, t) << "..." << '\n';
	}
	
	return 0;
	
	while(t--) {
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;

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

        int anum = Integer.parseInt(s.next());
        int bnum = Integer.parseInt(s.next());

        int coins = 0;
        for (int i = 0; i < 2; i++) {
            if (anum < bnum) {
                coins += bnum;
                bnum--;
            } else{
                coins += anum;
                anum--;
            }
        }
        System.out.println(coins);
    }
}

Measured memory_bytes: 21588
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int N, M, Lx, Rx;
    cin >> N >> M;
    vector<int> L(M), R(M);
    for(int i = 0; i < M; i++){
        cin >> L[i] >> R[i];
    }
    vector<int>::iterator iterL = max_element(L.begin(), L.end());
    size_t indexL = distance(L.begin(), iterL);
    Lx = L[indexL];
    vector<int>::iterator iterR = min_element(R.begin(), R.end());
    size_t indexR = distance(R.begin(), iterR);
    Rx = R[indexR];
    if(Rx - Lx < -1){
        cout << 0;
    }else{
        cout << Rx - Lx + 1;
    }
    return 0;
};


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var a = sc.nextInt();
		var b = sc.nextInt();
		var c = sc.nextInt();
		var k = sc.nextInt();
		sc.close();

		int max = Math.min(a, k) - Math.max(0, Math.min(c, k - a - b));
		System.out.println(max);
	}
}

Measured memory_bytes: 35716
N,K = map(int,input().split())
a = [int(i) for i in input().split()]
ans = float("INF")
for i in range(1<<N):
    cnt = 0
    tmp = a[:]
    m = tmp[0]
    for j in range(1,N):
        if i >> j & 1 and m >= tmp[j]:
            cnt += m - tmp[j] + 1
            tmp[j] = m + 1
        m = max(m,tmp[j])
    color = 1
    m = tmp[0]
    for j in range(1,N):
        if tmp[j] > m:
            color += 1
            m = tmp[j]
    if color >= K: ans = min(ans,cnt)
print(ans)

Measured memory_bytes: 3064