akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

string change (string s) {
  string t = s, p;
  int c;
  cin >> c;
  for (int i = 0; i < c; i++) {
    int a;
    cin >> a;
    p = t.substr(0, a);
    t.erase(0, a);
    t += p;
  }
    
  return t;
}

int main() {
  string str;
  
  while(1) {
    cin >> str;
    if (str == "-") break;
    str = change(str);
    cout << str << endl;
  }
}



Measured memory_bytes: 3148
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
long long beki(long long a,long long b){
	if(b==0){
		return 1;
	}
	if(b%2==0){
		return beki(a,b/2)*beki(a,b/2);
	}else{
		return beki(a,b/2)*beki(a,b/2)*a;
	}
}

int main(){
	long long i,x,n,u[50],d[50],ans;
	string s;
	cin >> n;
	u[0] = 0; d[0] = 0;
	for(i=0;i<40;i++){
		if(beki(-2,i)>0){
			u[i+1] = u[i]+beki(-2,i);
			d[i+1] = d[i];
		}else{
			d[i+1] = d[i]+beki(-2,i);
			u[i+1] = u[i];
		}
	}
	
	for(i=0;i<40;i++){
		if(d[i]<=n && n<=u[i]){
			//cout << d[i] << " " << u[i] << endl;
			x = i;
			break;
		}
	}
	long long y = n;
	if(n==0){
		cout << 0 << endl;
		return 0;
	}
	ans = beki(-2,x-1);
	//cout << ans << endl;
	cout << 1 ;
	for(i=x-2;i>=1;i--){
		long long k;
		k = n-ans;
		//cout << ans << " " << beki(-2,i) << " " << d[i] << " " <<u[i] << " "<< i  <<endl;
		if(ans==n){
			cout << 0 ;
		}else if(d[i] <= k-beki(-2,i) && k-beki(-2,i)<=u[i]){
			cout << 1 ;
			ans += beki(-2,i);
		}else{
			cout << 0 ;
		}
	}
	if(abs(y)%2==1){
		cout << 1 << endl;
	}else{
		cout << 0 << endl;
	}
}

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

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>

#define INF 100000000
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

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

    int prime[n+1];

    int i, j;
    for(i = 0; i <= n; i++){
        prime[i] = 0;
    }
    prime[0] = 0;
    prime[1] = 1;

    

    for(i = 2; i <= n; i++){
        if(prime[i] == 0){
            for(j = i; j <= n; j += i){
                prime[j] = i;
            }
        }
    }

    int memo[n+1];
    for(i = 0; i <= n; i++) memo[i] = 0;

    for(i = 2; i <=n; i++){
        int tmp = i;
        while(1){
            memo[prime[tmp]]++;
            tmp /= prime[tmp];
            if(tmp == 1) break;
        }
    }

    long long int ans = 1;
    for(i = 0; i <= n; i++){
        ans = ans * (memo[i]+1) % 1000000007;
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
int main(){
    int n;
    cin >> n;
    vector<ll> a,b;
    vector<ll> arr;
    rep(i,n) {
        ll t;
        cin >> t;
        if(i%2==0) a.push_back(t);
        else b.push_back(t);
        arr.push_back(t);
    }
    sort(All(arr));
    sort(All(a));
    sort(All(b));
    map<ll,int> mp;
    rep(i,n) mp[arr[i]]=i;
    ll nowarr[n];
    rep(i,n){
        if(i%2==0) nowarr[i]=a[i/2];
        else nowarr[i] = b[i/2];
    }
    ll ans =0;
    rep(i,n) if(mp[nowarr[i]]%2!=i%2) ans++;
    assert(ans%2==0);
    cout << ans/2 << endl;
}

Measured memory_bytes: 8812
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  vector<P> red(n);
  vector<P> blue(n);
  rep(i,n){
    cin>>red[i].first>>red[i].second;
  }
  rep(i,n){
    cin>>blue[i].first>>blue[i].second;
  }
  sort(ALL(red));reverse(ALL(red));
  sort(ALL(blue));
  blue.push_back(make_pair(0,inf));
  rep(i,n){
    int ind=n;int min=inf;
    rep(j,n){
      if(blue[j].first>red[i].first&&blue[j].second>red[i].second){
        if(min>blue[j].second){
          min=blue[j].second;
          ind=j;
        }
      }
    }
    blue[ind].first=0;blue[ind].second=inf;
  }
  int res=0;
  rep(i,n){
    if(blue[i].second==inf){
      res++;
    }
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;


int main(){
  int n, m, k;
  bool flag, all_flag;
  vector< vector<int> > v;
  vector<int> leakage;
  vector<int> answer;
  vector<int> ms;
  while(true){
    cin >> n;
    if (n == 0)
    {
      break;
    }
    v.reserve(n);
    for (int i = 0; i < n; ++i)
    {
      cin >> m;
      ms.push_back(m);
      v[i].reserve(m);
      for (int j = 0; j < m; ++j)
      {
        cin >> v[i][j];
      }
    }
    cin >> k;
    leakage.reserve(k);
    for (int i = 0; i < k; ++i)
    {
      cin >> leakage[i];
    }

    // cout << n << endl;
    for (int i = 0; i < n; ++i)
    {
      all_flag = true;
      for (int t = 0; t < k; ++t)
      {
        flag = false;
        for (int j = 0; j < ms[i]; ++j)
        {
          if (v[i][j] == leakage[t])
          {
            flag = true;
            break;
          }
        }
        if (flag == false){
          all_flag = false;
          break;
        }
      }
      if (all_flag == true)
      {
        answer.push_back(i+1);
      }
    }
    if (answer.size() == 1){
      cout << answer[0] << endl;
    }else{
      cout << -1 << endl;
    }
    v.clear();
    leakage.clear();
    answer.clear();
    ms.clear();
  }
}

Measured memory_bytes: 1308
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N;
    R(N);
    int v[60]={};
    REP(i,N){
        LL x;
        R(x);
        REP(j,60){
            v[j]+=(x>>j)&1;
        }
    }
    LL an=0;
    REP(j,60){
        ADD(an,(1LL<<j)%MOD*v[j]%MOD*(N-v[j]));
    }
    W(an);
    return 0;
}


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

bool func(const string& s, int i, int j)
{
    for(; i<=j; ++i, --j) if (s[i]!=s[j]) return false;
    return true;
}

int main()
{
    string s; cin>>s;
    int n=s.size();
    cout<<(func(s, 0, n-1) and func(s, 0, (n-1)/2-1) and func(s, (n+3)/2-1, n-1) ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 256
Kyu = int(input())

if 400 <= Kyu < 600:
  print("8")
elif 600 <= Kyu < 800:
  print("7")
elif 800 <= Kyu < 1000:
  print("6")
elif 1000 <= Kyu < 1200:
  print("5")
elif 1200 <= Kyu < 1400:
  print("4")
elif 1400 <= Kyu < 1600:
  print("3")
elif 1600 <= Kyu < 1800:
  print("2")
elif 1800 <= Kyu < 2000:
  print("1")

Measured memory_bytes: 9188
#B
n = int(input())
a = list(map(int, input().split()))
a_1 =  sorted(a, reverse=True)
alice = 0
bob = 0

for i in range(0, len(a)):
    if i % 2 != 0:
        bob += a_1[i]
    if i % 2 == 0:
        alice += a_1[i]
        
print (alice - bob)

Measured memory_bytes: 3064
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.readline
#read = sys.stdin.buffer.read

def main():
    N = int(input())
    A = list(map(int, input().split()))
    base = 0
    for a in A:
        base ^= a
    ans = []
    for i in range(N):
        ans.append(base^A[i])

    print(*ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 31308
#include "iostream"
using namespace std;

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

    int ans=0;


    if (N % 2 == 0) {
        ans = N/2 - 1;
    } else {
        ans = int(N/2);
    }

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

Measured memory_bytes: 256
// This code wrote by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
#define int long long
using namespace std;
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
int a[2050];
signed main(void)
{
	int x;
	cin>>x;
	for(int i=-1000;i<=1000;++i)
		a[i+1000]=i*i*i*i*i;
	for(int i=-1000;i<=1000;++i)
		for(int j=-1000;j<=1000;++j)
			if(a[i+1000]-a[j+1000]==x)
			{
				printf("%lld %lld\n",i,j);
				return 0;
			}
	return 0;
}



Measured memory_bytes: 3756
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	ll N;
	cin>>N;
	vector<pll> a;
	for(int i=0;i<N;i++){
		ll c;
		cin>>c;
		a.pb(mp(c,i));
	}
	sort(a.begin(),a.end());
	set<ll> tes;
	tes.insert(-1);
	tes.insert(N);
	ll ans=0;
	for(pll P:a){
		auto it=tes.lower_bound(P.second);
		ll L,R;
		R=*it;
		it--;
		L=*it;
		//cout<<L<<" "<<R<<endl;
		ans+=P.first*(P.second-L)*(R-P.second);
		tes.insert(P.second);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 13548
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
int main()
{
  int k;
  int a,b;
  cin>>k>>a>>b;
  int flag=0;
  for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            flag=1;
            break;
        }
    }
    if(flag)
        cout<<"OK"<<endl;
    else
        cout<<"NG"<<endl;
}


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


int main(){
  vector<int> vec(3);
  for (int i = 0; i < 3; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int n = 10 * vec.at(2) + vec.at(1) + vec.at(0);
  cout << n << endl;
}


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

#define PB push_back
#define MP make_pair
#define fi first
#define se second

typedef long long LL;

const double EPS=1e-9;
const double PI=acos(-1.0);
const int MAXN=100005;
const LL MOD=1000000007;
const int dx[8]={-1, 0, 1, -1, 1, -1, 0, 1}, dy[8]={-1, -1, -1, 0, 0, 1, 1, 1};

void base(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

int cnt[26];

int main(){
	base();
	int n, k;
	cin>>n>>k;
	string soal;

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

	int ans=0, temp=0;
	while(1){
		temp=0;
		sort(cnt, cnt+26);
		for(int i=0; i<26; i++){
			if(temp==k) break;
			if(cnt[i]<0){
				cnt[i]++;
				temp++;
			}
		}
		if(temp==k){
			ans++;
		}
		else break;
	}

	cout<<ans<<endl;

	return 0;
}


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

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		if(n % 500 > a) System.out.println("No");
		else System.out.println("Yes");
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

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

Measured memory_bytes: 24148
#include<stdio.h>

int main(int argc, char const* argv[])
{
    int W, H, x, y, r;
    scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
    if (x < 0 || y < 0 || x + r > W || y + r > H) {
        printf("No\n");
    }else {
        printf("Yes\n");
    }
    
    return 0;
}


Measured memory_bytes: 2136
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#ifndef ONLINE_JUDGE
#define OJ \
    freopen("input.txt", "r", stdin); \
    //freopen("output.txt", "w", stdout);
#else
#define OJ ;
#endif
#define fo(int, i, l, r) for ( int i = l ; i < r ; ++ i)
#define srtV(a) sort(a.begin(),a.end())
void solve()
{
    int n;
    cin>>n;
    vector <ll> maxs(n,0),a(n);
    for(int i=0;i<n;++i)
    {
        cin>>a[i];

    }
    maxs[0]=a[0];
    ll ans=0;
    for(int i=1;i<n;++i)
    {
        maxs[i]=max(maxs[i-1],a[i]);
    }
    for(int i=0;i<n;++i)
    {
        ans=ans+max(0ll,maxs[i]-a[i]);
    }
    cout<< ans<< "\n";
}
signed main()
{
    OJ
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //int _t;cin>>_t;while(_t--)
    solve();
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,m;

int main(){
    while(cin >> n >> m && n){
        vector<ll> sum(n+1,0);
        map<ll,ll> hc,wc;
        rep(i,n)cin >> sum[i+1];
        rep(i,n)sum[i+1] += sum[i];
        rep(i,n+1){
            FOR(j,i+1,n+1){
                hc[sum[j] - sum[i]]++;
            }
        }
        sum.clear();
        sum.resize(m+1,0);
        rep(i,m)cin >> sum[i+1];
        rep(i,m)sum[i+1] += sum[i];
        rep(i,m+1){
            FOR(j,i+1,m+1){
                wc[sum[j] - sum[i]]++;
            }
        }
        ll ans = 0;
        for(auto it = hc.begin();it != hc.end();it++){
            ll num = it->first;
            ans += it->second * wc[num];
        }
        cout << ans << endl;
    }

}


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

int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++) {
        cin >> v.at(i);
    }

    sort(v.begin(), v.end());
    double ans = (v.at(0) + v.at(1)) / 2.0d;

    for (int i = 2; i < N; i++) {
        ans = (ans + v.at(i)) / 2.0d;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;
int dp[100005][3][3][3];

class FThreeVariablesGame {
public:
    vector<char> res;

    void solve(std::istream& cin, std::ostream& cout) {
        int N, A, B, C;
        cin >> N >> A >> B >> C;

        vector<string> S(N);
        REP(i, N) cin >> S[i];
        map<char, int> cnt;
        cnt['A'] = A;
        cnt['B'] = B;
        cnt['C'] = C;

        vector<char> res;
        REP(i, N) {
            char ca = S[i][0];
            char cb = S[i][1];
            int a = cnt[ca];
            int b = cnt[cb];
            if (a == 0 && b == 0) {
                cout << "No" << endl;
                return;
            }
            if (a > b) {
                swap(a, b);
                swap(ca, cb);
            }
            if (a == b) {
                if (i+1 < N && (S[i+1][0] == cb || S[i+1][1] == cb)) {
                    swap(a, b);
                    swap(ca, cb);
                }
            }
            cnt[ca]++;
            cnt[cb]--;
            res.push_back(ca);
        }
        cout << "Yes" << endl;
        REP(i, N) cout << res[i] << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    FThreeVariablesGame solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 6692
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
  int i=0,x;

  Scanner scan =new Scanner(System.in);
  while(true){
    x=scan.nextInt();
    i++;
    if(x==0)

    break;

  System.out.println("Case"+" "+i+":"+" "+x);
}
}
}


Measured memory_bytes: 42428
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 28;
const double EPS = 1E-10;

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

vector<int> vi;
int nums[1000];

int main(){
	int n, m;
	while(cin >> n >> m && (n || m)){
		int res = 0;
		vi.clear();
		rep(i, n)cin >> nums[i];
		nums[n] = 0;
		rep(i, n + 1)rep(j, n + 1) if(nums[i] + nums[j] <= m)vi.push_back(nums[i] + nums[j]);
		sort(vi.begin(), vi.end());
		int sz = vi.size();
		rep(i, sz){
			int lb = 0;
			int ub = sz;
			while(ub - lb > 1){
				int mb = (lb + ub) / 2;
				if(vi[i] + vi[mb] <= m) lb = mb;
				else ub = mb;
			}
			res = max(res, vi[i] + vi[lb]);
		}
		cout << res << endl;
	}
	return 0;
}

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

#define ll long long

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n,q;
    cin>>n>>q;
    unordered_map<ll,ll> mp;
    vector<ll> ans(n,0);
    std::vector<pair<ll,ll>> a ;
    for(ll i=0;i<n-1;i++)
    {
        ll v1,v2;
        cin>>v1>>v2;
        a.push_back({v1,v2});
    }
    while(q--)
    {
        ll v1,val;
        cin>>v1>>val;
        mp[v1]+=val;
    }
    sort(a.begin(),a.end());
    for(ll i=0;i<n-1;i++)
    {
        ll f= a[i].first,s=a[i].second;
        mp[s]+=mp[f];
    }
    for(ll i=1;i<=n;i++)
    {
        cout<<mp[i]<<" ";
    }
    
    
    
    
	return 0;
}

Measured memory_bytes: 15468
//#include<bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <string>
#include <stdio.h>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string.h>
#include <vector>
#include <stdlib.h>
using namespace std;
typedef long long ll ;
#define int ll
#define mod 100
#define gcd(m,n) __gcd(m, n)
#define rep(i , j , n) for(int i = j ; i <= n ; i++)
#define red(i , n , j)  for(int i = n ; i >= j ; i--)
#define ME(x , y) memset(x , y , sizeof(x))
//int lcm(int a , int b){return a*b/gcd(a,b);}
//ll quickpow(ll a , ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;b>>=1,a=a*a%mod;}return ans;}
//int euler1(int x){int ans=x;for(int i=2;i*i<=x;i++)if(x%i==0){ans-=ans/i;while(x%i==0)x/=i;}if(x>1)ans-=ans/x;return ans;}
//const int N = 1e7+9; int vis[n],prime[n],phi[N];int euler2(int n){ME(vis,true);int len=1;rep(i,2,n){if(vis[i]){prime[len++]=i,phi[i]=i-1;}for(int j=1;j<len&&prime[j]*i<=n;j++){vis[i*prime[j]]=0;if(i%prime[j]==0){phi[i*prime[j]]=phi[i]*prime[j];break;}else{phi[i*prime[j]]=phi[i]*phi[prime[j]];}}}return len}
#define INF  0x3f3f3f3f
#define PI acos(-1)
#define pii pair<int,int>
#define fi first
#define se second
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define size(v) (int)(v.size())
#define cin(x) scanf("%lld" , &x);
const int N = 1e6+9;
const int maxn = 1e6+9;
const double esp = 1e-6;
char s[maxn];
int cnt ;
struct node{
    int l , r;
}a[maxn];

bool cmp(node a , node b){
    if(a.l >= a.r && b.l < b.r){//左括号多的放前面
        return true;
    }
    if(a.l < a.r && b.l >= b.r){//右括号多的放后面
        return false;
    }
    if(a.l >= a.r && b.l >= b.r){//同样是左括号多，右括号更少的放前面
        return a.r < b.r;
    }
    if(a.r >= a.l && b.r >= b.l)//同样是右括号多，左括号更多的放前面
        return a.l > b.l;
}

void solve(){
    int n , ans = 0,q=0;
    scanf("%lld" , &n);
    rep(i , 1 , n){
        scanf("%s" , s+1);
        int len = strlen(s+1);
        q+=len;
        stack<char>st;
        a[i].l = a[i].r = 0;
        rep(j , 1 , len){
            if(s[j] == '('){
                a[i].l++;
            }else{
                if(a[i].l > 0){
                    a[i].l--;
                    ans += 2;
                }else{
                    a[i].r++;
                }
            }
        }
    }
    sort(a+1 , a+1+n , cmp);
    int l = 0;
    rep(i , 1 , n){
        int t = min(l , a[i].r);
        l -= t;
        ans += 2*t;
        l += a[i].l ;
    }
    if(ans==q)
    cout << "Yes" << endl;
    else cout<<"No"<<endl;
}

signed main()
{
    //ios::sync_with_stdio(false);
   
        solve();

}


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

#define int long long 

signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    if(n == 1){
        cout << a[0];
        return 0;
    }
    sort(a.begin(),a.end());
    double x;
    x = (1.0*(a[0] + a[1]))/2;

    for(int i = 2; i < n; ++i){
        x = (1.0*(a[i]+x))/2;
    }
    cout << x;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int j,minv,maxv,n;
	int R[200000];
	     
	scanf("%d",&n);
	for(j = 0;j < n;j++){
		scanf("%d",&R[j]);
	}
	minv = R[0];
	maxv = R[1] -R[0];
	for(j = 1;j < n;j++){
		if(maxv > R[j] - minv)maxv = maxv;
		else maxv = R[j] - minv;
		if(minv > R[j])minv = R[j];
		else minv = minv;
	}
        printf("%d\n",maxv);
	return 0;
}

Measured memory_bytes: 1376
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int c=0;
		int m=0;
		for( char ch : s.toCharArray()) {
			if( 'R' == ch ) {
				c++;
			}else {
				c=0;
			}
			m = Math.max(m, c);
		}
		System.out.println(m);
	}
}


Measured memory_bytes: 35716
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
string x[100],y[100];
int n,m;
bool test(int a,int b)
{
    for(int i=0; i<m; i++)
    {
        for(int j=0; j<m; j++)
        {
            if(y[i][j]!=x[i+a][j+b])
                return 0;
        }
    }
    return 1;
}
void check(int pos)
{
    for(int i=0; i<=n-m; i++)
    {
        if(test(pos,i)){
            cout<<"Yes"<<endl;
            exit(0);
        }
    }
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    cin>>n>>m;
    for(int i=0; i<n; i++)
        cin>>x[i];
    for(int i=0; i<m; i++)
        cin>>y[i];
    for(int i=0;i<=n-m;i++)
        check(i);


    cout<<"No"<<endl;
    return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n;
    cin>>n;
    vector<int> x(n),y(n);
    
    for(int i = 0; i < n; i++)
    {
        cin>>x[i];
        y[i]=x[i];
    }
    sort(all(y));
    int mid = y[n/2-1];
    
    for(int i = 0; i < n; i++)
    {
        if(x[i]<=mid) cout<<y[n/2]<<endl;
        else cout<<mid<<endl;
    }

    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    int x, y;
    cin >> x >> y;
    int min_ashi = x * 2;
    int max_ashi = x * 4;
    if (min_ashi <= y && y <= max_ashi && y % 2 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3612
import bisect

s = input()
t = input()

d = dict()

for i, ch in enumerate(s):
    if ch in d:
        d[ch].append(i)
    else:
        d[ch] = [i]

ret = 0
cindex = -1

for ch in t:
    if ch not in d:
        print(-1)
        exit()
    else:
        ls = d[ch]
        index = bisect.bisect_right(ls, cindex)
        index = 0 if (index == len(ls)) else index
        if cindex < ls[index]:
            ret += (ls[index] - cindex)
            cindex = ls[index]
        else:
            ret += len(s) + ls[index] - cindex
            cindex = ls[index]

print(ret)


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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define MAX 101

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

ll visited[MAX], d[MAX], f[MAX], tt = 0;
vector<int> G[MAX];

void dfs(int u) {
  d[u] = ++tt;
  visited[u] = 1;
  rep(i, G[u].size()) {
    if(visited[G[u][i]] == 0) dfs(G[u][i]);
  }
  f[u] = ++tt;
}

signed main() {
	ll n;
  cin >> n;
  for(int i = 1; i <= n; i++) visited[i] = 0;
  rep(i, n) {
    ll u, k;
    cin >> u >> k;
    rep(j, k) {
      ll v;
      cin >> v;
      G[u].pb(v);
    }
  }

  for(int i = 1; i <= n; i++) {
    if(visited[i] == 0) dfs(i);
  }
  for(int i = 1; i <= n; i++) {
    cout << i << " " << d[i] << " " << f[i] << endl;
  }

	return 0;
}


Measured memory_bytes: 3236
#include "bits/stdc++.h"
#include <random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
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; }
const lint mod = 1e9 + 7, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };

template< int mod >
struct ModInt {
	int x;

	ModInt() : x(0) {}

	ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

	ModInt& operator+=(const ModInt& p) {
		if ((x += p.x) >= mod) x -= mod;
		return *this;
	}

	ModInt& operator-=(const ModInt& p) {
		if ((x += mod - p.x) >= mod) x -= mod;
		return *this;
	}

	ModInt& operator*=(const ModInt& p) {
		x = (int)(1LL * x * p.x % mod);
		return *this;
	}

	ModInt& operator/=(const ModInt& p) {
		*this *= p.inverse();
		return *this;
	}

	ModInt operator-() const { return ModInt(-x); }

	ModInt operator+(const ModInt& p) const { return ModInt(*this) += p; }

	ModInt operator-(const ModInt& p) const { return ModInt(*this) -= p; }

	ModInt operator*(const ModInt& p) const { return ModInt(*this) *= p; }

	ModInt operator/(const ModInt& p) const { return ModInt(*this) /= p; }

	bool operator==(const ModInt& p) const { return x == p.x; }

	bool operator!=(const ModInt& p) const { return x != p.x; }

	ModInt inverse() const {
		int a = x, b = mod, u = 1, v = 0, t;
		while (b > 0) {
			t = a / b;
			swap(a -= t * b, b);
			swap(u -= t * v, v);
		}
		return ModInt(u);
	}

	ModInt pow(int64_t n) const {
		ModInt ret(1), mul(x);
		while (n > 0) {
			if (n & 1) ret *= mul;
			mul *= mul;
			n >>= 1;
		}
		return ret;
	}

	friend ostream& operator<<(ostream& os, const ModInt& p) {
		return os << p.x;
	}

	friend istream& operator>>(istream& is, ModInt& a) {
		int64_t t;
		is >> t;
		a = ModInt< mod >(t);
		return (is);
	}

	static int get_mod() { return mod; }
};

using modint = ModInt< mod >;

modint func[200000];
void funcinit(int N)
{
	func[0] = 1;
	for (int i = 1; i <= N; i++)
	{
		func[i] = func[i - 1] * i;
	}
}
modint comb(modint n, modint r)
{
	if (n.x <= 0 || n.x < r.x)
	{
		return 0;
	}
	return func[n.x] / (func[r.x] * func[(n - r).x]);
}

lint N, A, _pos, __pos;
lint pos[100000];
int main() {
	cin >> N;
	REP(i, N) pos[i] = -1;
	REP(i, N + 1) {
		cin >> A; A--;
		if (pos[A] != -1) {
			_pos = pos[A];
			__pos = i;
		}
		else {
			pos[A] = i;
		}
	}

	funcinit(N + 2);
	lint rest = N - (__pos - _pos);
	REP(i, N + 1) {
		if (i == 0) cout << N << endk;
		else {
			cout << comb(N + 1, i + 1) - comb(rest, i) << endk;
		}
	}
}	

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

#define pb(s) push_back(s)
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))

typedef long long ll;

string s;

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

    cin>>s;
    int ans=0;
    for(int i=0;i<s.size()-1;++i){
        if(s[i]!=s[i+1])ans++;
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 512
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cstring>
#include <climits>
#include <set>

//#define int long long
//typedef long long ll;
using ll = long long;
using R = double;

//#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

#define MOD 1000000007

using namespace std;

typedef vector<int> V;
typedef vector<V> VV;



signed main()
{
    int N;
    int a[110];

    cin >> N;
    REP(i,N) cin >> a[i];
    sort(a, a + N);
    cout << a[N-1] - a[0] << endl;

    return 0;
}


Measured memory_bytes: 256
s = input()
if s[0] != 'A':
    print('WA') 
else:
    ii = s.count('C',2,-1)
    if ii != 1:
        print('WA')
    else:
        s_1 = s.lstrip('A')
        s_2 = s_1[1:-2].replace('C','')
        s_1 = s_1[0] + s_1[-1]
        s = s_1 + s_2
        if s.islower() == True:
            print('AC')
        else:
            print('WA')



Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
using namespace std;
long long num[100005],cnt[100005]={0};
int main(){
	long long i,n,q,ans=0,b,c;
	scanf("%lld",&n);
	for(i=0;i<n;i++){
		scanf("%lld",&num[i]);
		ans+=num[i];
		cnt[num[i]]++;
	}
	scanf("%lld",&q);
	while(q--){
		scanf("%lld%lld",&b,&c);
		cnt[c]+=cnt[b];
		ans+=cnt[b]*(c-b);
		cnt[b]=0;
		printf("%lld\n",ans);
	}	
}


Measured memory_bytes: 3240
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 1e5+5;
const LL INF = 1e18;

int n,k;
int a[N];

int main(){
	n=get();k=get();
	fo(i,1,n)a[i]=get();
	sort(a+1,a+1+n);
	LL ans=INF;
	fo(i,k,n){
		LL dis=a[i]-a[i-k+1]+min(abs(a[i]),abs(a[i-k+1]));
		ans=min(ans,dis);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
fn main() {
    let a: Vec<usize> = read_vec();
    if a.iter().sum::<usize>() >= 22 {
        println!("bust");
    } else {
        println!("win");
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  string s;in(s);
  out(s[2]==s[3]&&s[4]==s[5]?"Yes":"No");
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
// Problem : B - Judge Status Summary
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

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

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;
map<string, int> m;

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	REP(_, n) {
		string s;
		cin >> s;
		m[s]++;
	}
	for (auto s: {"AC", "WA", "TLE","RE"}) {
		cout << s << " x " << m[s] << endl;
	}
	return 0;
}
 


Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;

int main() {
	static long long N, H[100000];
	cin >> N;
	for (int i = 0; i < N; i++) cin >> H[i];
	H[0]--;
	for (int i = 0; i < N - 1; i++) {
		if (H[i] > H[i + 1]) {
			cout << "No" << endl;
			return 0;
		}
		if (H[i]+ 1 <= H[i + 1]) H[i + 1]--;
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
	int L,M,N,tyo=0,ans=0,i,j=0;
	while(1){
		scanf("%d",&L);
		if(L == 0) break;
		for(i=1;i<13;i++){
			scanf("%d %d",&M ,&N);
			tyo += (M - N);
			if(L <= tyo && j == 0){
				ans = i;
				j++;
			}
			
		}
		if(ans > 0) printf("%d\n",ans);
		else printf("NA\n");
		
		ans = 0;
		j = 0;
		tyo = 0;
	}
	return 0;
}

Measured memory_bytes: 612
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
string s,t;
int has[26];
int dp[26][100000+10];
LL res=0;
int main(){
	cin>>s>>t;
	int len1=s.length(),len2=t.length();
	s='$'+s;
	t='$'+t;
	int jiezhi=0;
	rb(i,1,len1) has[s[i]-'a']=1;
	rb(i,1,len2){
		if(!has[t[i]-'a']){
			puts("-1");
			return 0;
		}
	}
	rl(i,len1,1){
		rb(j,0,25){
			if(s[i]-'a'==j)  dp[j][i]=i;
			else dp[j][i]=dp[j][i+1];
		}
	}
//	int jiezhi=0;
	KEEP{
		int TO=0;
		rb(i,jiezhi+1,len2){
			if(dp[t[i]-'a'][TO+1]!=0){
				TO=dp[t[i]-'a'][TO+1];
				if(i==len2){
					res+=TO;
					cout<<res<<endl;
					return 0;	
				}
			}
			else{
				jiezhi=i-1;	
				break;
			}
		}
		res+=len1;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 10724
fun main(args: Array<String>) {
    val (o, e) = (1..2).map { readLine()!! }
    val result = (0 until o.length + e.length).map {
        if (it % 2 == 0) {
            o[it/2]
        } else {
            e[it/2]
        }
    }.joinToString("")
    println(result)
}

Measured memory_bytes: 33916
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(true){
    c-=b;
    if(c<=0)break;
    a-=d;
    if(a<=0)break;
  }
  if(a<=0){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 3580
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#define MN 40002
#define MM 5000001
#define ll long long
#define ld long double
#define inf 0x7fffffff
#define clz 1000000007
#define ers(arr,val) memset(arr,val,sizeof(arr));
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define repd(i,b,a) for(int i=(b);i>=(a);i--)
#define repe(i,u) for(int i=h[u];i;i=e[i].nx)
using namespace std;
int x,y;
int main(){
	scanf("%d%d",&x,&y);
	printf("%d",x+y/2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string x;
  cin >> x;
 
  if (x == "A") {
    cout << "T" << endl;
  }
 
  else if (x == "T") {
    cout << "A" << endl;
  }
 
  else if (x == "C") {
    cout << "G" << endl;
  }
 
  else {
    cout << "C" << endl;
  }
}

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

int f(int a,int b){
    int c = max(a, b);
    int i = 0;
    while(1){
        c /= 10;
        i++;
        if (c==0){
            return i;
        }
    }
}
//o
int main(){
    ll n;
    cin >> n;
    int a = 0;
    int x = sqrt(n);
    rep(i,x){
        if(n%(i+1)==0){
            a = i + 1;
        }
    }
    a = n / a;
    cout << f(a,1) << endl;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define gsort(x) sort((x).begin(), (x).end(), greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define int int64_t
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

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

   int n, cnt = 0, ans = 0;
   cin >> n;
   bool a = true;
   vector<int> x(n), y;

   rep(i, n)
   {
      cin >> x[i];
   }

   for (int i = 1; i < n; ++i)
   {
      if (x[i - 1] >= x[i])
         a = true;
      else
         a = false;

      if (a)
         ++cnt;
      else
         y.push_back(cnt), cnt = 0;
   }

   y.push_back(cnt);

   gsort(y);

   cout << y[0] << '\n';
}

Measured memory_bytes: 2168
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	a := ReadInts(N)
	c := make([]int, 1e5)
	for _, ai := range a {
		for d := -1; d <= 1; d++ {
			b := ai + d
			if 0 <= b && b < 1e5-1 {
				c[b]++
			}
		}
	}

	max := -1
	for _, ci := range c {
		if ci > max {
			max = ci
		}
	}
	fmt.Println(max)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 4044
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int table[] = new int[3];

		Scanner sc = new Scanner(System.in);

		table[0] = sc.nextInt();
		table[1] = sc.nextInt();
		table[2] = sc.nextInt();

		int work;

		for(int base_loc = 0; base_loc <= 1; base_loc++){
			for(int comp_loc = table.length-1;comp_loc >= base_loc+1; comp_loc--){
				if(table[comp_loc] < table[comp_loc-1]){
					work = table[comp_loc-1];
					table[comp_loc-1] = table[comp_loc];
					table[comp_loc] = work;
				}
			}
		}

		for(int i = 0; i < table.length; i++){
			if(i != 0)System.out.printf(" ");
			System.out.printf("%d", table[i]);
		}
		System.out.printf("\n");
	}
}





Measured memory_bytes: 26276
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll H,W;
    cin >> H >> W;
    vector<string>S(H);
    rep(i,H){
        cin >> S[i];
    }
    ll cnt = 0;
    rep(i,H){
        rep(j,W){
            if(S[i][j] == '.')cnt++;
        }
    }
    vector<vector<ll>> dist(H,vector<ll>(W,1e18));
    queue<pair<Pll,ll>> que;
    que.push(make_pair(Pll(0,0),1));
    while(!que.empty()){
        ll h = que.front().first.first;
        ll w = que.front().first.second;
        ll c = que.front().second;
        que.pop();
        if(!(0<=h && h<H)) continue;
        if(!(0<=w && w<W)) continue;
        if(S[h][w] == '#') continue;
        if(dist[h][w] != 1e18) continue;
        dist[h][w] = c;
        que.push(make_pair(Pll(h-1,w),c+1));
        que.push(make_pair(Pll(h+1,w),c+1));
        que.push(make_pair(Pll(h,w-1),c+1));
        que.push(make_pair(Pll(h,w+1),c+1));
    }
    if(dist[H-1][W-1] == 1e18){
        cout << -1 << endl;
    }else{
        cout << cnt - dist[H-1][W-1] << endl;
    }

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#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 a,b;
    cin >> a >> b;
    if(b%a==0)
        cout << a+b << endl;
    else
        cout << b-a << endl;
    return 0;
}

Measured memory_bytes: 256