akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;


typedef long long int lli;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<float, float> ff;
typedef vector<ii> vii; 
typedef vector<ff> vff;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vi ab(n);
    for (int i=0;i<n;i++) {cin >> ab[i];}
    int i = 0;
    int count = 0;
    int ans = 0;
    while(i<n-1){
        if(ab[i]>=ab[i+1]){
            count++;
            ans = max(count, ans);
        }else{
            count = 0;
        }i++;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main(){

    int N;
    cin>> N;
    vector<int> L;
    for(int i=0; i<2*N; i++){
        int l;
        cin>> l;
        L.push_back(l);
    }

    sort(L.begin(), L.end());
    int ans=0;
    for(int i=0; i<2*N; i+=2){
        ans+=L[i];
    }

    cout<< ans<< endl;

    return 0;
}


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

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	
	if (a<=b && b<=c)
		printf("%d %d %d\n", a, b, c);
	else if (a<=c && c<=b)
		printf("%d %d %d\n", a, c, b);
	else if (b<=a && a<=c)
		printf("%d %d %d\n", b, a, c);
	else if (b<=c && c<=a)
		printf("%d %d %d\n", b, c, a);
	else if (c<=a && a<=b)
		printf("%d %d %d\n", c, a, b);
	else if (c<=b && b<=a)
		printf("%d %d %d\n", c, b, a);
	
	return 0;
}

Measured memory_bytes: 1144
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;




int main()
{
  // string s, m; //かっている数//最大100
  long n;
  cin >> n ;
  vector<long> a(n);
  vector<long> b(n);

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

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

  vector<long> minv;
  vector<long> maxv;



  for (int i = 0; i < n / 2 + n % 2; ++i) {
    minv.push_back(a[i]);
  }

  for (int i = 0; i < n / 2; ++i) {
    maxv.push_back(a[n - 1 - i]);
  }

  vector<long> minv2;
  vector<long> maxv2;

  for (int i = 0; i < minv.size(); ++i) {
    if (i % 2 == 0) {
      minv2.insert(minv2.begin(), minv[i]); //先頭に追加
    } else {
      minv2.push_back(minv[i]);
    }
  }

  for (int i = 0; i < maxv.size(); ++i) {
    if (i % 2 == 0) {
      maxv2.push_back(maxv[i]);
    } else {
      maxv2.insert(maxv2.begin(), maxv[i]); //先頭に追加
    }
  }

  // for (int i = 0; i < minv2.size(); ++i) {
  //   cerr << minv2[i] << ",";
  // } cerr << endl;

  // for (int i = 0; i < maxv2.size(); ++i) {
  //   cerr << maxv2[i] << ",";
  // } cerr << endl;


  vector<long> ansv;
  for (int i = 0; i < n; ++i) {
    if (i % 2 == 0) {
      ansv.push_back(minv2[i/2]);
    } else {
      ansv.push_back(maxv2[i/2]);
    }
  }



  long ans =0;

  for (int i = 0; i < n; ++i) {
    // cerr << ansv[i] << ",";
    if (i>0){
      ans += abs(ansv[i-1] - ansv[i] );
    }
  }

  long ans2 =0;

  vector<long> minw;
  vector<long> maxw;

  for (int i = 0; i < n / 2 ; ++i) {
    minw.push_back(a[i]);
  }

  for (int i = 0; i < n / 2+ n % 2; ++i) {
    maxw.push_back(a[n - 1 - i]);
  }



  vector<long> minw2;
  vector<long> maxw2;

  for (int i = 0; i < minw.size(); ++i) {
    if (i % 2 == 0) {
      minw2.insert(minw2.begin(), minw[i]); //先頭に追加
    } else {
      minw2.push_back(minw[i]);
    }
  }


  for (int i = 0; i < maxw.size(); ++i) {
    if (i % 2 == 0) {
      maxw2.push_back(maxw[i]);
    } else {
      maxw2.insert(maxw2.begin(), maxw[i]); //先頭に追加
    }
  }



  for (int i = 0; i < minw2.size(); ++i) {
    cerr << minw2[i] << ",";
  } cerr << endl;

  for (int i = 0; i < maxw2.size(); ++i) {
    cerr << maxw2[i] << ",";
  } cerr << endl;



  vector<long> answ;
  for (int i = 0; i < n; ++i) {
    if (i % 2 == 0) {
      answ.push_back(maxw2[i/2]);
    } else {
      answ.push_back(minw2[i/2]);
    }
  }



  for (int i = 0; i < n; ++i) {
    cerr << answ[i] << ",";
    if (i>0){
      ans2 += abs(answ[i-1] - answ[i] );
    }
  }



  cout  << max(ans,ans2);

  return 0;
}



























Measured memory_bytes: 7540
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
int H,W,len,p;
int f[4010][4010];
int tmp[4010][4010];
int L[4010][4010],R[4010][4010];
const int SIZE = 4200;
struct BIT{
	int bit[SIZE+10];
	void clear(){
		for(int i=0;i<=SIZE;i++)bit[i]=0;
	}
	void add(int i,int x){
		while(i<=SIZE){
			bit[i]+=x;
			i+=i&-i;
		}
	}
	int sum(int i){
		int res = 0;
		while(i>0){
			res+=bit[i];
			i-=i&-i; 
		}
		return res;
	}
	int sum(int l,int r){
		if(l>r)return 0;
		return sum(r)-sum(l-1);
	}
};
BIT bitL,bitR;
ll ans = 0ll;
void culc(int sx,int sy){
	bitL.clear();
	bitR.clear();
	vector<P> vec;
	for(int i=sx,j=sy;i<=H&&j<=W;i++,j++){
		vec.pb(P(L[i][j],j));
		vec.pb(P(R[i][j],j+W));
	}
	sort(all(vec),greater<P>());
	for(int i=0;i<vec.size();i++){
		int y = vec[i].sec;
		int v = vec[i].fi;
		if(y<=W){
			ans += bitR.sum(y+len-1,y+v-1);
			bitL.add(y,1);
		}else{
			y-=W;
			ans += bitL.sum(y-v+1,y-len+1);
			bitR.add(y,1);
		}
	}
	return;
}
int main(){
	scanf("%d %d %d %d",&H,&W,&len,&p);
	for(int i=0;i<p;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		f[a][b]=1;
	}
	for(int i=W;i>=1;i--){
		for(int j=1;j<=H;j++){
			L[j][i]=L[j][i+1]+1;
			if(f[j][i])L[j][i]=0;
		}
	}
	for(int i=H;i>=1;i--){
		for(int j=1;j<=W;j++){
			tmp[i][j]=tmp[i+1][j]+1;
			if(f[i][j])tmp[i][j]=0;
			L[i][j]=min(L[i][j],tmp[i][j]);
		}
	}
	for(int i=1;i<=W;i++){
		for(int j=1;j<=H;j++){
			R[j][i]=R[j][i-1]+1;
			if(f[j][i])R[j][i]=0;
		}
	}
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			tmp[i][j]=tmp[i-1][j]+1;
			if(f[i][j])tmp[i][j]=0;
			R[i][j]=min(R[i][j],tmp[i][j]);
		}
	}
	/*for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			printf("%d ",L[i][j]);
		}
		printf("\n");
	}
	printf("\n");
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			printf("%d ",R[i][j]);
		}
		printf("\n");
	}*/
	for(int s=2;s<=H;s++)culc(s,1);
	for(int s=1;s<=W;s++)culc(1,s);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 251744
#include <iostream>
#include <array>
#include <cassert>
#include <cstring>
#include <vector>
#include <algorithm>

#define forn(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

#define fi first
#define se second
#define eb emplace_back

template <typename T>
bool uax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template <typename T>
bool uin(T& a, T b) { if (b < a) { a = b; return true; } return false; }

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef vector<int> vi;
typedef long long i64;

constexpr int power(int x, int n) {
  return n > 0 ? power(x, n - 1) * x : 1;
}

const int N = 50;
i64 d[N + 1][N + 1];
const i64 inf = (1ll << (N + 1));

void solve_c() {
  int n;
  cin >> n;
  vi a(n), b(n);
  forn(i, n) cin >> a[i];
  forn(i, n) cin >> b[i];

  i64 ans = 0;

  while (true) {
    forn(i, N + 1) forn(j, N + 1) d[i][j] = inf;
    forn(i, N + 1) forn(j, N + 1) d[i][i] = 0;
    forn(k, N + 1) if (k > 0) {
      forn(i, N + 1) forn(j, N + 1) {
        uin(d[i][j], d[i % k][j] | (i64)((ans >> k) & 1 ? 0 : 1) << k);
      }
    }
    i64 cans = 0;
    forn(i, n) {
      if (d[a[i]][b[i]] == inf) {
        cout << -1 << endl;
        return ;
      } else {
        cans |= d[a[i]][b[i]];
      }
    }
    ford(k, N + 1) if ((cans >> k) & 1) {
      ans |= 1ll << k;
      break;
    }
    if (cans == 0) break;
  }
  cout << ans << endl;
}

void solve_b() {
  int n;
  cin >> n;
  int x = 30000;
  if (n == 3) {
    cout << "2 5 63\n";
    return ;
  } else if (n == 4) {
    cout << "2 5 20 63\n";
    return ;
  }
  int gs = 0;
  int s = 0;
  forn(i, n - 3) {
    while (__gcd(x, 6) == 1) --x;
    cout << x << ' ';
    gs = __gcd(gs, x);
    s += x; s %= 6;
    --x;
  }
  bool ok = false;
  forn(k, x + 1) if (k > 0 && __gcd(k, 6) != 1) {
      forn(j, k) if (j > 0 && __gcd(j, 6) != 1) {
          forn(i, j) if (i > 0 && __gcd(i, 6) != 1) {
              if ((i + j + k + s) % 6 == 0 && __gcd(gs, __gcd(i, __gcd(j, k))) == 1) {
                cout << k << ' ' << j << ' ' << i;
                ok = true;
                break;
              }
            }
          if (ok) break;
        }
      if (ok) break;
    }
  assert(ok);
  cout << endl;
}

void solve_a() {
  string s;
  cin >> s;
  if (s.length() < 26) {
    for (char c = 'a'; c <= 'z'; ++c) {
      if (find(s.begin(), s.end(), c) == s.end()) {
        s += c;
        break;
      }
    }
  } else {
    string t = s;
    if (!next_permutation(s.begin(), s.end())) {
      s = "-1";
    } else {
      int i = 0;
      while (s[i] == t[i]) ++i;
      s = s.substr(0, i + 1);
    }
  }
  cout << s << endl;
}

int main() {
#ifdef HOME
  // freopen("input.txt", "rt", stdin);
#endif
  solve_c();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;

int main() {
  ll n,h;
  cin >> n >> h;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i,n){
    cin >> a[i] >> b[i];
  }
  sort(b.begin(),b.end(),greater<ll>());
  sort(a.begin(),a.end(),greater<ll>());
  ll s;
  rep(i,n){
    if(a[0]>b[i]){
      s = i;
      break;
    }
  }
  int cnt=0;
  int i=0;
  while(i<s&&i<n){
      h-=b[i];
      i++;
      cnt++;
      if(h<=0)
        break;
  }
  if(h>0){
    cnt+=h/a[0];
    if(h%a[0]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 4804
a = int(input())
b = list(map(int, input().split()))
b = sorted(b, reverse=True)
c = [0, 0]
d = [1, 0]
e = [0, 1]
for i in range(a):
    c[0] += b[i] * d[i % 2]
    c[1] += b[i] * e[i % 2]
print(abs(c[0] - c[1]))



Measured memory_bytes: 3060
N, M = map(int, input().split(' '))
data = []
for n in range(N):
  A_n, B_n = map(int, input().split(' '))
  data.append([A_n,B_n])
data = sorted(data)
  
# calc answer
drink = 0
ans = 0
for d in data:
  a, b = d
  drink += b
  ans += a*b
  if drink > M:
    ans -= a*(drink-M)
    break
  
print(ans)


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

using namespace std;

int main(){
    string s;
    int a=0,w=0,t=0,r=0;
    int n;cin>>n;
    for(int i=0;i<n;++i){
        cin>>s;
        if(s[0]=='A')a++;
        else if(s[0]=='W')w++;
        else if(s[0]=='T')t++;
        else r++;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<w<<endl;
    cout<<"TLE x "<<t<<endl;
    cout<<"RE x "<<r<<endl;
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, w[110];
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n;i++){
        cin >> w[i];
        sum += w[i];
    }
    int ans = mod, tmp = 0;
    for (int i = 0; i < n;i++){
        tmp += w[i];
        ans = min(ans, abs((sum - tmp) - tmp));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*{{{*/
#include <bits/stdc++.h>
#define st first
#define nd second
#ifdef LOCAL
int c_;
#define cout (c_?cerr:cout)
#define debug(...) {cerr<<(!c_?"\033[96;1m":"");\
++c_;__VA_ARGS__;--c_;cerr<<(!c_?"\033[0m":"");}
#else
#define debug(...) {}
#endif
#define st first
#define nd second
#define dump_range(...) debug(cerr<<#__VA_ARGS__<<": ";print_range(__VA_ARGS__))
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
#define dump(...) debug(print(#__VA_ARGS__,'=',__VA_ARGS__))
using namespace std; using ll = long long;
template< typename... t > using V = vector< t... >;
void print(){cout << '\n';}
template< typename t, typename... v >
void print(const t& a, const v&... b)
{cout << a << (sizeof...(b)?" ":"");print(b...);}
int argc_; char** argv_;
template< typename t > 
void print_range(t a, const t& b)
{while (a != b) cout << (*a++) << ' '; cout << '\n';}
/*thread_local mt19937 gen;
inline ll arg(int v, ll def = 0)
{return v < argc_? atoll(argv_[v]) : def;}
template< typename t >
t rng(t min, t max) 
{return uniform_int_distribution< t >{min, max}(gen);}*/
/*}}}*/

int n;
V< ll > tab;
V< ll > dp, pd;

void comp(const V< ll >& tab, V< ll >& dp)
{
    dp.resize(tab.size());
    stack< pair< int, int > > S;
    S.push({0, 1e9});
    ll pp = 1e18;
    for (int i = 0; i < tab.size(); ++i)
    {
        dump(i, tab[i], S.size());
        dp[i] = (i > 0? dp[i - 1] : 0);
        ll v = tab[i];
        while (v > pp)
        {
            dp[i] += 2 * (i - S.top().st);
            --S.top().nd;
            if (not S.top().nd) 
                S.pop();
            pp *= 4;
        }
        if (i != 0)
        {
            ll tmp = v;
            int cnt = 0;
            while (tmp * 4 <= pp)
                ++cnt, tmp *= 4;
            if (cnt)
                S.push({i, cnt});
        }
        pp = v;
    }
}

int main(int argc, char** argv)
{
    argc_ = argc; argv_ = argv;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //gen = mt19937(arg(1));
    
    cin >> n;
    tab.resize(n);
    for (auto& i : tab)
        cin >> i;

    reverse(all(tab));
    comp(tab, dp);
    reverse(all(tab));
    for (auto& i : tab) 
        i <<= 1;
    comp(tab, pd);

    ll res = 1e18;
    for (int i = 0; i <= n; ++i)
    {
        ll r = 0;
        if (i > 0) r += pd[i - 1] + i;
        if (i < n)
            r += dp[n - i - 1];
        res = min(res, r);
    }
    dump_range(all(dp));
    dump_range(all(pd));
    print(res);
}

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

int main() {
  long long n, m; cin >> n >> m;
  for(int i = 0; i < (m+1)/2; i++){
    cout << i+1 << " " << 1+m-i << endl;
    if((1+m-i)-(i+1)==1) break;
    cout << i+2+m << " " << 1+2*m-i << endl;
  }
}


Measured memory_bytes: 3592
s=input()
f1=True
f2=True
if int(s[:2])==0 or int(s[:2])>12:
    f1=False
if int(s[2:])==0 or int(s[2:])>12:
    f2=False
if f1 and f2:
    print("AMBIGUOUS")
elif f1:
    print("MMYY")
elif f2:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 38256
#include<bits/stdc++.h>
const int N=2020,M=N*10;
using namespace std;
int n,to[M],hd[M],lk[N],ln[M],cst[M],
u,v,tc,cnt=1,S,T,tp,q[N],h,t,pre[N];
long long dis[N],ans;
bool inq[N];
inline void add(int u,int v,int w,int c){
	to[++cnt]=v,hd[cnt]=lk[u],
	ln[cnt]=w,cst[cnt]=c,lk[u]=cnt;
}
inline void Add(int u,int v,int w,int c){
	add(u,v,w,c),add(v,u,0,-c);
}
int main(){
	scanf("%d",&n);
	S=n*2,T=S+1;
	for(int i=0;i<S;i++){
		scanf("%d%d%d",&u,&v,&tc);
		if(i<n)Add(S,i,tc,0);
		else Add(i,T+4,tc,0);
		for(int s=0;s<4;s++){
			tp=(s&1?u:-u)+(s>>1&1?v:-v);
			if(i<n)Add(i,T+s,tc,tp);
			else Add(T+s,i,tc,-tp);
		}
	}T+=4;
	for(;;){
		for(int i=0;i<=T;i++)
		dis[i]=-1e17;
		dis[q[h=0]=S]=0,t=1;
		for(;h^t;){
			inq[u=q[h++]]=0,h==N?h=0:0;
			for(int i=lk[u];i;i=hd[i])
			if(ln[i]&&dis[v=to[i]]<dis[u]+cst[i])
			dis[v]=dis[u]+cst[i],pre[v]=i,
			inq[v]?0:(inq[q[t++]=v]=1,t==N?t=0:0);
		}
		if(dis[T]==-1e17)break;
		tp=1e9;
		for(u=T;u^S;u=to[pre[u]^1])
		tp=min(tp,ln[pre[u]]);
		ans+=dis[T]*tp;
		for(u=pre[T];u;u=pre[to[u^1]])
		ln[u]-=tp,ln[u^1]+=tp;
	}printf("%lld",ans);
}

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

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
struct Activity
{
	int A;
	int B;
	int C;
};
int solve(vector<Activity> arr,int n)
{
	int dp[n+1][3];
	dp[1][0] = arr[1].A;
	dp[1][1] = arr[1].B;
	dp[1][2] = arr[1].C;
	for(int i=2;i<=n;i++)
	{
		dp[i][0] = arr[i].A  + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = arr[i].B  + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = arr[i].C  + max(dp[i-1][0],dp[i-1][1]);
	}
	return max(dp[n][0],max(dp[n][1],dp[n][2]));
}
int main()
{
	c_p_c();
	int n;
	cin>>n; 
	vector<Activity> arr(n+1);
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i].A>>arr[i].B>>arr[i].C;
	}
	cout<<solve(arr,n);
	return 0;
}

Measured memory_bytes: 6628
#include <cassert>
#include "limits.h"
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<ll, ll>;



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

  ll n,a,b,c,d;
  std::cin>>n>>a>>b>>c>>d;

  rep(i,0,n+1){
    if(c*(n-1-i)-d*i<=b-a&&b-a<=-c*i+(n-1-i)*d){
      std::cout<<"YES\n";
      return 0;
    }
  }

  std::cout<<"NO\n";

  return 0;
}

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

int main(){
  int c,d;
string a,e,s,sum;
cin>>c>>d;

  for(int i=0;i<c+2;i++){
    if(i!=0&&i!=c+1){
      cin>>a;
    }
    for(int j=0;j<d+2;j++){
      if(i==0||i==c+1||j==0||j==d+1){
        cout<<'#';
      }
      else{
        cout<<a[j-1];
      }
    }
    cout<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

int main(){
  ll N,M,K;
  ll ans = 0;
  cin >> N >> M >> K;
  ll a[N];
  ll b[M];
  vector<ll> Acum(N+1,0);
  vector<ll> Bcum(M+1,0);
  Acum[0] = 0;
  Bcum[0] = 0;

  ll posb = 0;
  rep(i,N) {
	cin >> a[i];
	Acum[i+1] += Acum[i] + a[i];
  }
  rep(i,M) {
	cin >> b[i];
	Bcum[i+1] += Bcum[i] + b[i];
  }
  posb = M;
  for(ll posa=0; posa < N + 1; posa++) {
	if(K < Acum[posa]) break;
	while(Acum[posa] + Bcum[posb] > K) {
	  posb--;
	  if(posb == 0) break;
	}
	//	cout << posa << " " << posb << endl;
	ans = max(ans,posa + posb);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 9160
#include <iostream>

using namespace std;

int main()
{
	string n;
	cin >> n;
  	
  	int i, count;
  	i = 0;
  	count = 0;
  	while (n[i] != '\0')
    {
      	count += n[i] - '0';
      	i++;
    }
  	if (count % 9 == 0)
      	cout << "Yes";
  	else
      	cout << "No";
  	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int dc[3] = {5,9,13};
int dx[3][13] = {
	{0,0,0,-1,1},
	{-1,-1,-1,0,0,0,1,1,1},
	{-2,-1,-1,-1,0,0,0,0,0,1,1,1,2}
};
int dy[3][13] = {
	{0,1,-1,0,0},
	{-1,0,1,-1,0,1,-1,0,1},
	{0,-1,0,1,-2,-1,0,1,2,-1,0,1,0}
};

int main(){
	int a,b,c;
	int d[10][10] = {0};
	while(~scanf("%d,%d,%d",&a,&b,&c)){
		c--;
		rep(i,dc[c]){
			int tx = a + dx[c][i] , ty = b + dy[c][i];
			if(tx < 0 || ty < 0 || ty > 9 || tx > 9) continue;
			d[ty][tx]++;
		}
	}
	int white = 0;
	int ans = 0;
	rep(i,10)rep(j,10){
		if(d[i][j]==0)white++;
		else ans = max(d[i][j],ans);
	}
	cout << white << endl << ans << endl;
}

Measured memory_bytes: 0
import java.util.*;
import java.util.Map.Entry;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int F[][] = new int[N][10];
        int P[][] = new int[N][11];
        
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < 10; j++ ){
                F[i][j] = sc.nextInt();
            }
        }
        
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < 11; j++ ){
                P[i][j] = sc.nextInt();
            }
        }
        
        int max = Integer.MIN_VALUE;
        for( int i = 1; i < (1 << 10); i++ ) {
            int count[] = new int[N];
            for( int j = 0; j < N; j++ ) {
                for(int k = 0; k < 10; k++ ) {
                    int bit = (i>>k) & 1;
                    if( bit == 1 && F[j][k] == 1 ) {
                        count[j]++;
                    }
                }
            }
            
            int sum = 0;
            for( int j = 0; j < N; j++ ) {
                sum += P[j][count[j]];
            }
            max = Math.max( max, sum );
        }
        
        System.out.println(max);
    }
}


Measured memory_bytes: 40308
import java.util.*;

public class Main{
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int [] a = new int[3];
			int [] m = new int[3];
			int end = 0;
			for(int i = 0; i < 3; i++){
				a[i] = sc.nextInt();
				m[i] = sc.nextInt();
				end = end | a[i] | m[i];
			}
			if(end == 0) break;
			long [] res = new long[3];
			for(int i = 0; i < 3; i++){
				res[i] = solve(a[i], m[i]);
			}
			long ans = lcm(res[0], lcm(res[1], res[2]));
			System.out.println(ans);
		}
	}

	private long solve(int a, int m) {
		long now = 1;
		for(int times = 1; times <= m + 1; times++){
			now = (now * a) % m;
			if(now == 1){
				return times;
			}
		}
		return -1;
	}
	
	private long gcd(long a, long b){
		if(b == 0)  return a;
		else        return gcd(b, a%b);
	}
	
	private long lcm(long a, long b){
		return a / gcd(a, b) * b;
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define ll long long
#define MAXN 102
// #define M 1000000007
#define f(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define pii pair< int,int >
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define vii vector<pii>
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout)

using namespace std;

int main()
{
    int n;
    cin>>n;
    if(n>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
using namespace std;
using namespace std;
int main(void){
    int n,k;
    string s;
    cin >> n >> k;
    cin >> s;
    s[k-1] = s[k-1] + 32;
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long n = sc.nextLong();
		long result = 1;
		boolean flg = false;
		for(int i = 0; i < n; i++){
		    long a = sc.nextLong();
		    try{
		        result = multiplyExact(result, a);
		    }catch(Exception e){
		        flg = true;
		        result = 1;
		    }
		}
		if(result > 1000000000000000000L) result = -1;
		if(flg && result != 0) result = -1;
		
		// 計算
		//int result = 0;
		
		// 出力
		System.out.println(result);
	}

	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 48012
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = sum(B)

for i in range(n-1):
  if A[i+1]-A[i] == 1:
    ans += C[A[i]-1]

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int n,K;
    cin >>n >>K;
    vector<ll> a(n);
    rep(i,n) cin >>a[i];

    vector<ll> b;
    rep(i,n){
        ll t = 0;
        for(int j=i; j<n; ++j){
            t += a[j];
            b.pb(t);
        }
    }

    sort(all(b));
    reverse(all(b));
    int B = b.size();
    // dbg(b);

    ll ans = 0;
    for(int i=39; i>=0; --i){
        int ct = 0;
        rep(j,B)if(b[j]>>i&1) ++ct;

        if(ct<K) continue;

        ans |= 1LL<<i;
        vector<ll> r;
        rep(j,B)if(b[j]>>i&1) r.pb(b[j]);

        for(int j=i-1; j>=0; --j){
            int R = r.size();

            ct = 0;
            rep(k,R)if(r[k]>>j&1) ++ct;

            if(ct>=K){
                vector<ll> nr;
                rep(k,R)if(r[k]>>j&1) nr.pb(r[k]);

                ans |= 1LL<<j;
                r = nr;
            }
        }

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


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

int main() {
  
  std::string a;
  cin >> a;

  int x;
  x = atoi(a.substr(0, 1).c_str()) + 
    atoi(a.substr(1, 1).c_str()) + 
    atoi(a.substr(2, 1).c_str());
  cout << x << endl;
  
}

Measured memory_bytes: 256
N, M = [int(x) for x in input().split()]
list_ = []
for _ in range(N):
  list_.append([int(x) for x in input().split()])
list_.sort()

NUM = 0
PRICE = 0
for idx in range(N):
  if list_[idx][1] < (M - NUM):
    PRICE += list_[idx][0] * list_[idx][1]
    NUM += list_[idx][1]
  else:
    PRICE += list_[idx][0] * (M - NUM)
    print(PRICE)
    exit()

Measured memory_bytes: 21612
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int n,t[100];

int main()
{
	while(scanf("%d",&n),n)
	{
		rep(i,n)
		{
			int s; t[i]=0;
			rep(j,5)scanf("%d",&s),t[i]+=s;
		}
		sort(t,t+n);
		printf("%d %d\n",t[n-1],t[0]);
	}
	return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		StringTokenizer toks = new StringTokenizer(in.readLine());
		long a = Integer.parseInt(toks.nextToken());
		long b = Integer.parseInt(toks.nextToken());
		if (a <= 0 && b >= 0)
			out.println("Zero");
		else if (a > 0 && b > 0)
			out.println("Positive");
		else if (a < 0 && b < 0)
			if ((Math.abs(b) - Math.abs(a)) % 2 == 0)
				out.println("Negative");
			else
				out.println("Positive");
		out.close();
	}
}

Measured memory_bytes: 21204
import fractions


n, m = map(int, input().split())
s = input()
t = input()

# 先頭文字が一致しない場合はよい文字列は存在しないので終了
if s[0] != t[0]:
    print(-1)
    exit()

# よい文字列が存在する場合、答えは最小公倍数となる
l = (n * m) // fractions.gcd(n, m)

# 連結するとSになるXの位置リストを生成
ss = set(l // n * i for i in range(1, n))
# 連結するとTになるXの位置リストを生成
tt = set(l // m * i for i in range(1, m))

# 共通部分を取得
same = list(ss & tt)

# メモリ開放
del ss
del tt

a = [s[item // (l // n)] for item in same]
b = [t[item // (l // m)] for item in same]

print(l) if a == b else print(-1)


Measured memory_bytes: 19256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include <string.h>
#include <math.h>

using namespace std;


int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	cout << ((n*a > b) ? b : n*a) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int md=998244353;
int n,K,i,j,k,x,y,ans,jc[1000005],rjc[1000005],inv[1000005];
int C(int n,int m)
{
	if(n<0||m<0||m>n)
		return 0;
	return 1ll*jc[n]*rjc[m]%md*rjc[n-m]%md;
}
int work(int n,int m)
{
	return C(n+m,n);
}
int main()
{
	scanf("%d%d",&n,&K);
	inv[1]=1;
	for(i=2;i<=1000000;++i)
		inv[i]=1ll*inv[md%i]*(md-md/i)%md;
	jc[0]=rjc[0]=1;
	for(i=1;i<=1000000;++i)
		jc[i]=1ll*jc[i-1]*i%md,rjc[i]=1ll*rjc[i-1]*inv[i]%md;
	for(i=K;2*i>K;--i)
	{
		j=i-(n-1);
		if(j>=0)
			ans=(1ll*ans+work(i,K-i)-work(i+j,K-i-j)+md)%md;
	}
	if(K%2==0)
	{
		i=K/2,j=i-(n-1);
		if(j>=0)
			ans=(1ll*ans+work(i,K-1-i)-work(i+j,K-1-i-j)+md)%md;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 11904
N = int(input())
S = input()
T = input()
kouho = []
for i in range(len(S)):
    ok = 1
    for j in range(0, len(S)-i):
        if S[i+j] == T[j]:
            continue
        ok = 0
        break
    if ok == 0:
        continue
    break
if ok == 1:
    ans = i+len(T)
else:
    ans = len(S)+len(T)
print(ans)


Measured memory_bytes: 9152
#091b
import collections

N = int(input())
blue_cards = []
for i in range(N):
    s = str(input())
    blue_cards.append(s)
    
M = int(input())
red_cards = []
for i in range(M):
    t = str(input())
    red_cards.append(t)

blue_cards_counted = collections.Counter(blue_cards)
red_cards_counted = collections.Counter(red_cards)

for word in red_cards_counted:
    blue_cards_counted[word] -= red_cards_counted[word]       
    
#print(blue_cards_counted)
print(max(0,max(blue_cards_counted.values())))

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

int main() {
  string s;
  cin >> s;
  int A, Z;
  for(int i = 0; i < s.size(); i++) {
    if (s[i] == 'A') {
      A = i;
      break;
    }
  }
  for(int i = s.size() - 1; i < s.size(); i--) {
    if (s[i] == 'Z') {
      Z = i;
      break;
    }
  }
  cout << Z - A + 1 << endl;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int, int>

typedef long long ll;

ll const mod = 1e9+7;

int n,i,j,k,t,l,f;
int x,y,a,b,c;

int main(){
	scanf("%d", &n);
	a=b=f=0;
	c=1;
	for(i=0;i<n;i++){
		scanf("%d %d %d", &t, &x, &y);
		l = abs(x-a)+abs(b-y);
		if(l!=t-c){
			if(l>t-f)
				c=0;
			else if(abs(l+f-t) %2)
				c=0;
		}
		a = x;
		b = y;
		f = t;
	}
	if(c)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;


int main(){
    int ans = 0;
    string S1,S2;

    cin >> S1 >> S2;

    for(int i = 0;i < 3;i++){
        if(S1[i] == S2[i])ans++;
    }

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll a, b;
    cin >> a >> b;
    set<ll> s;
    rep(i, 3) s.insert(i + 1);
    s.erase(a); s.erase(b);
    for (auto x : s) cout << x << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long   ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ii, ll>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
#define tam 320

#define offset 
const ll MOD= 1e9+7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int dp[tam][tam][tam];
int n,W;
int w[tam],v[tam];
int go(int pos,int cuantos,int sum)
{
    if (pos==n)
    {
        if ((ll)cuantos*w[0]<=(ll)(W-sum))
            return 0;
        else
            return -1e9;
    }
    if (dp[pos][cuantos][sum]!=-1)
        return dp[pos][cuantos][sum];

    int minn;
    minn=go(pos+1,cuantos+1,sum+(w[pos]-w[0]))+v[pos];
    minn=max(minn,go(pos+1,cuantos,sum));
    return dp[pos][cuantos][sum]=minn;
}
int  main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    memset(dp,-1,sizeof dp);
    cin>>n>>W;
    forr(i,0,n)
    {
        cin>>w[i]>>v[i];
    }
    cout<<go(0,0,0)<<endl;

}
// PLUS ULTRA!


Measured memory_bytes: 128384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;

void solve(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)cout<<"bust\n";
    else cout<<"win\n";
}
 
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    string tmp;
    map<string, int> cases;
    for(int i = 0; i < n; ++i){
        cin >> tmp;
        cases[tmp]++;
    }
    vector<string> outputs {"AC", "WA", "TLE", "RE"};
    for(auto&& key : outputs){
        cout << key << " x " << cases[key] << "\n";
    }
    return 0;
}

Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int a, b;
	cin >> a >> b;
	if (b%a == 0) {
		cout << a + b << endl;
	}
	else {
		cout << b - a << endl;
	}
}

Measured memory_bytes: 256
def main():
    import sys
    input = lambda: sys.stdin.buffer.readline().rstrip()
    n, w_max = map(int, input().split())
    import numpy as np

    v,w = [],[]
    for i in range(n):
        w_, v_ = map(int, input().split())
        v.append(v_)
        w.append(w_)
    dp = np.array([10**10]*(10**5+1),dtype=int)
    dp[0] = 0
    for i in range(n):
        dp[v[i]:] = np.minimum(dp[v[i]:], w[i]+dp[:-v[i]])
    ans = 0
    for i,w in enumerate(dp):
        if w<= w_max:
            ans = i
    print(ans)


if __name__ == '__main__':
    main()

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rept(i,k,n) for(ll i = (k); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;
typedef tuple<int,int,int> Tii;

template <typename T>
ostream& operator<<(ostream& s, const vector<T> &vec){
    for(int i=0;i<vec.size();i++){
        if(i) s << ',';
        else s << '{';
        s <<setw(2)<< vec[i];
    }
    s << '}' << endl;
    return s;
}
ll mod = 998244353;

int main(){
    int x;
    cin>>x;
    cout<<360/gcd(x,360)<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  string s; cin >> s;
  vector<int> sum(n+1);
  rep(i, n) {
    sum[i+1] = sum[i] + (s[i]=='W');
  }
  int mn = inf;
  rep(i, n+1) {
    mn = min(max(sum[i], n-i-(sum[n]-sum[i])), mn);
  }
  cout << mn << "\n";
  return 0;
}


Measured memory_bytes: 4396
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) for(auto x:obj)cout<<x<<' ';cout<<endl;
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N;cin>>N;
	int ans = 0LL;
	REP(i,N){
		REP(k,N){
			REP(j,N){
				ans += gcd(i,gcd(k,j));
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#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 SORT(v) sort(v.begin(), v.end())
#define REVERSE(v)  reverse(v.begin(), v.end())
using namespace std;

int main() {
  int N; cin>>N;
  if(N == 1) {
    cout<<"Hello World"<<endl;
    return 0;
  }
  else {
    int A,B; cin>>A>>B;
    cout<<A+B<<endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


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




Measured memory_bytes: 1024
n,m = map(int,input().split())
k_and_s = list(list(map(int,input().split()))for i in range(m))
p = list(map(int,input().split()))

k = []
s = []
switch = list([[0 for i in range(m)]for i in range(n)])
switch_1 = [0 for i in range(n)]
cnt = 0

for i in range(1,len(p)+1):
    if p[i-1] == 1:
        cnt += 2**(m-i)
    if i == m:
        p_1 = cnt

for i in range(m):
    k.append(k_and_s[i][0:1][0])
    s.append(k_and_s[i][1:])

for i in range(len(s)):
    for j in range(len(s[i])):
        switch[s[i][j]-1][i] = 1

for i in range(len(switch)):
    cnt = 0
    for j in range(1,len(switch[i])+1):
        if switch[i][j-1] == 1:
            cnt += 2**(m-j)
        if j == m:
            switch_1[i] = cnt

ans = 0
for i in range(1<<n):
    t = 0
    for j in range(n):
        if i >> j & 1 != 0:
            t ^= switch_1[j]
    if t==p_1:
        ans +=1
print(ans)

Measured memory_bytes: 3064
# include <iostream>
# include <cstdlib>
# include <stack>

using namespace std;

int main() {
	string t;
	stack<int> s;
	while (cin >> t) {
		if (t == "+") {
			int op1 = s.top(); s.pop();
			int op2 = s.top(); s.pop();
			int ans = op2 + op1;
			s.push(ans);
		}
		else if (t == "-") {
			int op1 = s.top(); s.pop();
			int op2 = s.top(); s.pop();
			int ans = op2 - op1;
			s.push(ans);
		}
		else if (t == "*") {
			int op1 = s.top(); s.pop();
			int op2 = s.top(); s.pop();
			int ans = op2 * op1;
			s.push(ans);
		}
		else {
			s.push(atoi(t.c_str()));
		}
	}
	cout << s.top() << endl;
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)

int const md = 1e9 + 7, N = 20000000;
int fc[N + 1], inv[N + 1], fcin[N + 1];

inline void ad(int &x, int y) { if ((x += y) >= md)x -= md; }
inline int P(int n, int k) { return (ll)fc[n] * fcin[n - k] % md; }

int main(){
	fc[0] = 1;
	f(i, 1, N + 1)fc[i] = (ll)fc[i - 1] * i % md;
	inv[1] = 1;
	f(i, 2, N + 1)inv[i] = md - md / i * (ll)inv[md % i] % md;
	fcin[0] = 1;
	f(i, 1, N + 1)fcin[i] = (ll)fcin[i - 1] * inv[i] % md;
	int h, w, k;
	scanf("%d%d%d", &h, &w, &k);
	int an = (ll)P(h + w, k) * k % md;
	f(i, 0, k)ad(an, (ll)P(h - 1 + w, k - 1) * (k - i) % md * h % md);
	f(i, 0, k)ad(an, (ll)P(h + w - 1, k - 1) * (k - i) % md * w % md);
	if (k > 1)f(i, 1, k)ad(an, (ll)P(h + w - 2, k - 2) * (k - i) % md * i % md * h % md * w % md * 2 % md);
	printf("%d\n", an);
}

Measured memory_bytes: 234624
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

void solve()
{
	string s;
	int ans = 0;
	while(cin >> s)
	{
		string sBuf = s;
		reverse(s.begin(), s.end());
		if(s == sBuf)
		{
			++ans;
		}
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 1196
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define VFOR(i, s, n) for(int i = s; i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define PB push_back
#define MP make_pair
using ll = long long;
using Pii = pair<int, int>;
const int MOD = 1000000007;
const int INF = 1000000000;

vector<bool> visited;
//es[i][j].first = to, second = cost
vector<vector<pair<int, int>>> es;
vector<ll> d;

void dfs(int cur){ //0からの距離
    visited[cur] = true;
    REP(i, es[cur].size()){
        if(visited[es[cur][i].first]) continue;
        d[es[cur][i].first] = d[cur] + es[cur][i].second;
        dfs(es[cur][i].first);
    }
}

int main(){
    int n; cin >> n;
    visited.resize(n, false);
    es.resize(n);
    d.resize(n, 0LL);
    REP(i, n-1){
        int u, v, w; cin >> u >> v >> w;
        --u; --v;
        es[u].PB(MP(v, w)); es[v].PB(MP(u, w));
    }
    dfs(0);
    REP(i, n) cout << d[i] % 2 << "\n";
    return 0;
}


Measured memory_bytes: 8576