akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
    public static int mypow(int a, int n){
        if(n == 0){
            return 1;
        }else if(n == 1){
            return a;
        }
        return a * mypow(a, n - 1);
    }

    public static int bekiSum(int[] x, int n, int i){
        int[] bec = new int[100];
        for(int j = 0; j < n; j++){
            if(((i >> j) & 1) == 1){
                bec[j] = x[j];
            }else{
                bec[j] = 0;
            }
        }
        int Sum = 0;
        for(int k = 0; k < n; k++){
            Sum += bec[k];
        }
        return Sum;
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] A = new int[n];
        for(int i = 0; i < n; i++){
            A[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        int[] M = new int[q];
        for(int i = 0; i < q; i++){
            M[i] = sc.nextInt();
        }
        int[] Sum = new int[mypow(2, n)];
        for(int i = 0; i < mypow(2, n); i++){
            Sum[i] = bekiSum(A, n, i);
        }
        int p = 0;
        for(int i = 0; i < q; i++){
            for(int j = 0; j < mypow(2, n); j++){
                if(M[i] == Sum[j]){
                    System.out.println("yes");
                    p = 1;
                    break;
                }
            }
            if(p != 1){
                System.out.println("no");
            }
            p = 0;
        }
        sc.close();
    }
}


Measured memory_bytes: 163580
#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(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(ALL(a));
    int ans1 = a[n - 1];
    int ans2 = a[n - 1];
    int f = INT_MAX;
    rep(i, n - 1)
    {
        if (f >= abs(a[n - 1] / 2 - a[i]))
        {
            ans2 = a[i];
            f = abs(a[n - 1] / 2 - a[i]);
        }
    }
    cout << ans1 << " " << ans2 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#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 SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
int n;
vector<int> vec;
bool f(int x){
	int s = vec[0];
	for(int i=0;i<3;i++){
		if(x&1)s+=vec[i+1];
		else s-=vec[i+1];
		x >>= 1;
	}
	//cout << s << endl;
	return (s==7);
}
void print(int x){
	cout << vec[0];
	for(int i=0;i<3;i++){
		if(x&1)cout << "+";
		else cout << "-";
		cout << vec[i+1];
		x >>= 1;
	}
	cout << "=7" << endl;
}
int main(){
	cin >> n;
	for(int i=0;i<4;i++){
		vec.pb(n%10);
		n/=10;
	}
	reverse(all(vec));
	for(int i=0;i<(1<<3);i++){
		if(f(i)){
			print(i);
			return 0;
		}
	}	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int s; cin >> s;
   int a=s/1000;
   int b=(s%1000)/100;
   int c=(s%100)/10;
   int d=s%10;
  if(a==b && b==c) {
    cout << "Yes" << endl;
  }
  else if (b==c && c==d){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

ll h,w;

int main()
{
	cin >> w >> h;
	vector<pair<ll,int> > v;
	
	REP(i,w){ll tmp;cin >> tmp;v.PB(MP(tmp,0));}
	REP(i,h){ll tmp;cin >> tmp;v.PB(MP(tmp,1));}
	
	sort(ALL(v));
	
	ll ans = 0;
	int a=0,b=0;
	
	REP(i,w+h)
	{
		if(v[i].SE == 0)
		{
			ans += v[i].FI * (h+1-b);
			a++;
		}
		else
		{
			ans += v[i].FI * (w+1-a);
			b++;
		}
	}
	
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 6512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;
int main(){
    int n;
    cin >> n;
    int w[n];

    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> w[i];
        sum += w[i];
    }
    int sum2 = 0;
    int mini = 1000;
    
    for(int i = 0; i < n; i++){
        sum2 += w[i];
        mini = min(mini, abs(sum2 - (sum - sum2)));
    }

    cout << mini;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void yn(bool j){cout << (j ? "Yes" : "No") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> long long bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> void sortTwoVecter(vector<T1> &f, vector<T2> &s, bool isReverse = false){
    vector<pair<T1, T2>> p;
    rep(i, f.size()) p.emplace_back(make_pair(f[i], s[i]));
    if (!isReverse) sort(p.begin(), p.end());
    else sort(p.rbegin(), p.rend());
    rep(i, f.size()) tie(f[i], s[i]) = p[i];
    return;
}


int main(){
    ll N, MA, MB; cin >> N >> MA >> MB;
    ll lim = 402 * 402 + 402;
    vector<vector<ll>> dp(N + 1, vector<ll>(402 * 402 + 402, INF));
    vector<ll> w(N), c(N);
    rep(i, N){
        ll a, b; cin >> a >> b >> c[i];
        w[i] = 401 * a + b;
    }
    dp[0][0] = 0;
    rep(i, N) rep(j, lim){
        chmin(dp[i + 1][j], dp[i][j]);
        if (j - w[i] >= 0) chmin(dp[i + 1][j], dp[i][j - w[i]] + c[i]);
    }
    ll t = 1;
    ll ans = INF;
    while(t * (401 * MA + MB) < lim){
        chmin(ans, dp[N][t * ( 401 * MA + MB)]);
        t++;
    }
    pt(ans == INF ? -1 : ans);

}

Measured memory_bytes: 53504
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main(void){
  string X;
  cin>>X;
  for(int i = 0; i<3; i++){
    if(X[i]=='1') X[i]='9';
    else if(X[i]=='9') X[i]='1';
  }
  cout<<X<<endl;
  return 0;
}


Measured memory_bytes: 256
from operator import itemgetter, attrgetter

N, M = list(map(int,input().strip().split()))
ar = []
ans = []
num = 0

for i in range(M):
    p, y = list(map(int,input().strip().split()))
    ar.append([p,y,i])

ar.sort(key=itemgetter(0,1))

for i in ar:
    a,b,c = i
    if num != a:
        num = a
        num2 = 0
    num2 += 1
    ans.append([str(num).zfill(6)+str(num2).zfill(6),c])

ans.sort(key=itemgetter(1))

for i in range(M):
    py,c = ans[i]
    print(py)

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

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

    vector<ll>a(n);


    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        if(a[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }

    ll seki=1;

    rep(i,n){
        if(1000000000000000000/seki<a[i]){
            cout<<-1<<endl;
            return 0;
        }
        seki*=a[i];
    }

    cout<<seki<<endl;

}



Measured memory_bytes: 4068
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
  	const int cx = x;
  	const int cy = y;
    int maxp = 0;
    if (a + b > 2 * c)
    {
        maxp += c *2* min(x, y);
        if(x==min(x,y)){
      	y -= x;
        x =0;
        }else{
        x -= y;
        y = 0;
    	}
      	if (x > 0)
        {
            maxp += a * x;
        }
        if (y > 0)
        {
            maxp += b * y;
        }
      	if(maxp>2*c*max(cx,cy)){
        	maxp = 2*c*max(cx,cy);
        }
    }
    else
    {
        maxp += a * x + b * y;
    }
    cout << maxp << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
slis = []
for i in range(n):
    slis.append(input())
m = int(input())
tlis = []
for i in range(m):
    tlis.append(input())
x = 0
for i in set(slis):
    ok = slis.count(i)
    ng = tlis.count(i)
    x = max(x, ok-ng)
print(x)

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

using namespace std;

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    char c;
    cin >> c;
    if('a' <= c && c <= 'z') {
        cout << "a\n";
    }
    else {
        cout << "A\n";
    }
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

string s,t;

bool fun(int x){
    int ns=s.size(),nt=t.size();
 for(int i=0;i<=ns-nt;i++)
   {
       int c=0;
       for(int j=0;j<nt;j++)
        if(s[i+j]==t[j])
            c++;
            if(c+x>=nt)
                return 1;
   }

  return 0;
}
int main()
{
    fast

  cin>>s>>t;
int ns=s.size(),nt=t.size();
  int l=0,r=nt;
  int res=r;
  while(l<=r){
    int med=(l+r)/2;
    if(fun(med))
    {
        res=med;
        r=med-1;
    }
    else
        l=med+1;
       // cout<<med<<endl;

  }
  cout<<res;



    return 0;
}


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

#define ll long int 

void dfs(long int v,vector<long int>graph[],vector<long int>&counter,vector<bool>&visited){
    
    if(visited[v]) return;
    visited[v]=true;
       
    for(auto child:graph[v]){
        if(child == v) continue;
       
        if(!visited[child]){
              counter[child]+=counter[v];
              dfs(child,graph,counter,visited);
        }
        
    }
    
    
    
}

int main(){
    
    long int n,i,q;
    cin>>n>>q;
    vector<long int> counter(n+1,0);
    
    vector<long int>graph[n+1];
    long int a,b,p,c;
    
    for(i=0;i<n-1;i++){
        cin>>a>>b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
  
    for(i=0;i<q;i++){
        cin>>p>>c;
        counter[p]+=c;
    }
    
    vector<bool>visited(n+1,false);
    long int v=1;
    dfs(v,graph,counter,visited);
    for(i=1;i<=n;i++) cout<<counter[i]<<" ";
    
    return 0;
}




Measured memory_bytes: 30592
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    int p[n];
    for(int i=0; i<n; i++) cin >> p[i];
    int ans=0;
    for(int i=2; i<n; i++){
        if(min({p[i-2], p[i-1], p[i]})<p[i-1] && p[i-1]<max({p[i-2], p[i-1], p[i]})) ans++;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
    
    int N, M;

    while (1) {
        cin >> N;
        if (N == 0) break;
        int x, y;
        int grid[21][21];
        for (int i = 0; i < 21; ++i) {
            for(int j = 0; j < 21; ++j) {
                grid[i][j] = 0;
            }
        }

        for (int i = 0; i < N; ++i) {
            cin >> x >> y;
            grid[y][x] = 1;
        }

        cin >> M;

        int sx = 10, sy = 10;

        for (int i = 0; i < M; ++i) {
            char dj;
            int d;
            cin >> dj >> d;

            int dx, dy;
            if (dj == 'N') {
                dx = 0;
                dy = 1;
            } else if (dj == 'E') {
                dx = 1;
                dy = 0;
            } else if (dj == 'S') {
                dx = 0;
                dy = -1;
            } else if (dj == 'W') {
                dx = -1;
                dy = 0;
            }

            for (int j = 0; j < d; j++) {
                sx += dx;
                sy += dy;
                grid[sy][sx] = 0;
            } 
        }

        bool flag = true;
        for (int i = 0; i < 21; ++i) {
            for(int j = 0; j < 21; ++j) {
                if (grid[i][j] == 1) {
                    flag = false;
                }
            }
        }
        if (flag) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3004
# -*- coding: utf-8 -*-
N = int(input())
tree = {n:{} for n in range(N)}
children = set()

for n in range(N):
    inp = [int(m) for m in input().split()]
    tree[inp[0]]["leaf"] = inp[2:]
    children.update(inp[2:])

parent = set([n for n in range(N)]).difference(children).pop()
tree[parent]["depth"] = 0
tree[parent]["parent"] = -1

siblings = tree[parent]["leaf"]
for c in siblings:
    tree[c]["depth"] = 1
    tree[c]["parent"] = parent

depth = 2
while len(children):
    children = children.difference(siblings)
    next_gen = []
    for s in siblings:
        next_gen.extend(tree[s]["leaf"])
        for c in tree[s]["leaf"]:
            tree[c]["depth"] = depth
            tree[c]["parent"] = s
    siblings = next_gen
    depth += 1

    
for n in range(N):
    if tree[n]["depth"] == 0:
        tree[n]["type"] = "root"
    elif tree[n]["leaf"] == []:
        tree[n]["type"] = "leaf"
    else:
        tree[n]["type"] = "internal node"
        
    print("node {}: parent = {}, depth = {}, {}, {}" \
              .format(n, tree[n]["parent"], tree[n]["depth"], tree[n]["type"], tree[n]["leaf"]))

Measured memory_bytes: 73156
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#define ll long long
using namespace std;

static const int MAX = 100000;
int p[MAX], q[MAX], r[MAX];

int main(){
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;

    for(int i = 0; i < A; i++){
        cin >> p[i];
    }
    for(int i = 0; i < B; i++){
        cin >> q[i];
    }
    for(int i = 0; i < C; i++){
        cin >> r[i];
    }

    sort(p, p+A);
    sort(q, q+B);
    sort(r, r+C);

    ll ans = 0;
    priority_queue<int, vector<int>, greater<int> > PQ;
    for(int i = 0; i < X; i++){
        PQ.push(p[A-1-i]);
        ans += p[A-1-i];
    }
    for(int i = 0; i < Y; i++){
        PQ.push(q[B-1-i]);
        ans += q[B-1-i];
    }
    int z = PQ.top();
    for(int i = C-1; z < r[i]; i--){
        PQ.pop();
        ans += r[i] - z;
        if(PQ.size() != 0) z = PQ.top();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2552
#include<cstdio>
using namespace std;
#define N 25050
#define K 405
#define mod 1000000007
int n,m,k,s[N],dp[N][K],su[N][K],as,l,r,s1[N][K],fr[K],ifr[K],vl[N][K];
int pw(int a,int p){int as=1;while(p){if(p&1)as=1ll*as*a%mod;a=1ll*a*a%mod;p>>=1;}return as;}
bool check(int l,int r){for(int i=l;i<=r;i++)for(int j=i+1;j<=r;j++)if(s[i]==s[j])return 0;return 1;}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=k;i++)scanf("%d",&s[i]);
	fr[0]=ifr[0]=1;for(int i=1;i<=m;i++)fr[i]=1ll*fr[i-1]*i%mod,ifr[i]=pw(fr[i],mod-2);
	for(int i=1;i<=k;i++){if(check(1,i))l=i;if(check(k-i+1,k))r=i;}
	for(int i=1;i+m-1<=k;i++)if(check(i,i+m-1)){printf("%d\n",1ll*pw(m,n-k)*(n-k+1)%mod);return 0;}
	if(l==k)
	{
		su[1][1]=dp[1][1]=m;if(l==1)vl[1][1]=s1[1][1]=m;
		for(int i=2;i<=n;i++)
		for(int j=m-1;j>0;j--)dp[i][j]=(su[i-1][j]+1ll*dp[i-1][j-1]*(m-j+1))%mod,su[i][j]=(su[i][j+1]+dp[i][j])%mod,vl[i][j]=(s1[i-1][j]+1ll*vl[i-1][j-1]*(m-j+1)+(j>=l?dp[i][j]:0))%mod,s1[i][j]=(s1[i][j+1]+vl[i][j])%mod;
		printf("%d\n",(1ll*pw(m,n-k)*(n-k+1)%mod-1ll*s1[n][1]*ifr[m]%mod*fr[m-k]%mod%mod+mod)%mod);return 0;
	}
	dp[0][l]=1;for(int j=1;j<=l;j++)su[0][j]=1;
	for(int i=1;i<=n;i++)
	for(int j=m-1;j>0;j--)dp[i][j]=(su[i-1][j]+1ll*dp[i-1][j-1]*(m-j+1))%mod,su[i][j]=(su[i][j+1]+dp[i][j])%mod;
	vl[0][r]=1;for(int j=1;j<=r;j++)s1[0][j]=1;
	for(int i=1;i<=n;i++)
	for(int j=m-1;j>0;j--)vl[i][j]=(s1[i-1][j]+1ll*vl[i-1][j-1]*(m-j+1))%mod,s1[i][j]=(s1[i][j+1]+vl[i][j])%mod;
	for(int i=1;i+k-1<=n;i++)as=(as+1ll*su[i-1][1]*s1[n-(i+k-1)][1])%mod;
	printf("%d\n",(1ll*pw(m,n-k)*(n-k+1)%mod-as+mod)%mod);
}//

Measured memory_bytes: 158720
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb emplace_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define ll long long
#define INF 2000000000
int a[105];
int main(){
        int n;
        while(~getI(n)){
                F(i,0,n) getI(a[i]);
                bool yes=1;
                F(i,0,n) if(a[i]%2==0){
                        bool now=0;
                        if(a[i]%3==0||a[i]%5==0) now=1;
                        if(now==0){
                                puts("DENIED");
                                yes=0;
                                break;
                        }
                }
                if(yes) puts("APPROVED");
        }
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int main() {
	int r, g, b;
	cin >> r >> g >> b;
	int ans = r * 100 + g * 10 + b;
	if (ans % 4 == 0) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
import numpy as np
from collections import Counter

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = []
C = []
for _ in range(M):
    b1, c1 = map(int, input().split())
    B.append(b1)
    C.append(c1)

A = list(Counter(A).items())

for i in range(len(A)):
    C.append(A[i][0])
    B.append(A[i][1])
 
d = np.argsort(C)[::-1]
B = [B[i] for i in d]
C = [C[i] for i in d]

i = 0
c = 0
ans = 0
while True:
    if c + B[i] < N:
        ans += C[i] * B[i]
        c += B[i]
        i += 1
    else:
        ans += C[i] * (N - c)
        break
print(ans)


Measured memory_bytes: 38124
n = int(input())
arr = list(map(int, input().split()))

arr.sort()
count = 0
for i in range(n-1, 0, -1):
	l, r = 0, i - 1
	while l < r:
		if arr[l] + arr[r] > arr[i]:
			count += r - l
			r -= 1
		else:
			l += 1
print(count)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int D, contests[370], ans[370];
lint c[30], s[370][30];
set<int> held_days[30];
lint best_score;

lint get_score(int dd){
    For(i, 1, 27){
        held_days[i].clear();
        held_days[i].insert(0);
        held_days[i].insert(D+1);
    }
    lint ret = 0;
    For(day, 1, dd+1){
        For(i, 1, 27){
            if(contests[day] == i){
                ret += s[day][i];
                held_days[i].insert(day);
            }
            else ret -= c[i] * (day - *next(held_days[i].rbegin()));
        }
    }
    return ret;
}

lint fsum(int n){
    return n*(n+1)/2;
}

lint score_diff(int day, int idx){
    lint ret = 0;
    int prev_id = contests[day];
    contests[day] = idx;

    ret += s[day][idx];
    auto r = held_days[idx].lower_bound(day), l = prev(r);
    ret += c[idx] * fsum(*r-1-*l);
    ret -= c[idx] * (fsum(day-1-*l) + fsum(*r-1-day));
    held_days[idx].insert(day);

    ret -= s[day][prev_id];
    auto m = held_days[prev_id].find(day);
    r = next(m); l = prev(m);
    ret += c[prev_id] * (fsum(day-1-*l) + fsum(*r-1-day));
    ret -= c[prev_id] * fsum(*r-1-*l);
    held_days[prev_id].erase(day);

    return ret;
}

void input(){
    scanf("%d", &D);
    For(i, 1, 27) scanf("%lld", &c[i]);
    For(i, 1, D+1)For(j, 1, 27) scanf("%lld", &s[i][j]);
}

void output(){
    For(i, 1, D+1) printf("%d\n", ans[i]);
}

int main(){
    input();

    For(i, 1, D+1) ans[i] = contests[i] = i%26 + 1;

    double temperature = 10000, colding_rate = 0.99999;
    lint score = get_score(D);
    best_score = score;
    random_device rd;
    mt19937 mt(rd());
    uniform_real_distribution<> dist(0.0, 1.0);
    clock_t start = clock();
    while((clock() - start) / CLOCKS_PER_SEC < 1.0){
        int day = mt()%D + 1;
        int idx = mt()%26 + 1;
        int prev_id = contests[day];
        lint diff = score_diff(day, idx);

        if(diff > 0) score += diff;
        else{
            double prob = dist(mt);
            if(prob <= exp(diff / temperature)) score += diff;
            else score_diff(day, prev_id);
        }

        if(chmax(best_score, score)){
            For(i, 1, D+1) ans[i] = contests[i];
        }

        temperature *= colding_rate;
    }

    output();
}

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

int s = 1, z;
string a;
int main()
{
	int i;
	cin >> a;
	for (i = 1; i < a.size(); i++) {
		if (a[i] != a[i - 1] || z == 1) {s++; z = 0;}
		else {
			if (i + 1 < a.size()) s++;
			i++; z = 1;
		}
	}
	cout << s;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

#define ll long long

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define alll(it,A) for(it=A.begin();it!=A.end();it++)

#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define pii pair<int,int>
#define V vector<ll>
#define VP vector<pll>
#define SP set<pll>
#define VB vector<bool>
#define S set<ll>
#define MS multiset<ll>
#define VV vector<V>
#define VS vector<S>
#define PQi priority_queue< int >
#define PDQi priority_queue< int ,vector< int > ,greater< int > >
#define PQl priority_queue< ll >
#define PDQl priority_queue< ll ,V,greater< ll > >
//#define inf 1e5
#define mod 1000000007
bool isprime(ll n){
    ll i;
    if(n==2||n==3)return 1;
    ll flag=0;
    for(i=2;i<=sqrt(n)+1;i++){
        if(n%i==0){
            flag=1;
            break;
        }
    }
    if(flag)return 0;
    else return 1;
}
//ll cost[200001];
V adj[200001];
//ll d[200001]={0};
//ll dam[200001]={0};
//V rdj[200001];
//ll visited[200001]={0};
//ll par[200001]={0},rnk[200001]={0};
//ll find(ll a){
//	if(par[a]==a)return par[a];
//	return find(par[a]);
//}
//void unionf(ll a,ll b){
//	a=find(a);
//	b=find(b);
//	//if(a==b)continue;
//	if(rnk[a]>rnk[b]){
//		par[b]=a;
//		rnk[a]+=rnk[b];
//	}
//	else{
//		par[a]=b;
//		rnk[b]+=rnk[a];
//	}
//}
ll kadane(ll a[],ll n){
    ll sumtill=0,maxtill=0,start=0,ending=0,start1=0;
    rep(i,0,n){
        sumtill+=a[i];
       // err1(sumtill);
        if(sumtill>maxtill){
            maxtill=sumtill;
            start=start1;
            ending=i;
        }
        if(sumtill<0){
            start1=i+1;
            sumtill=0;
        }
    }
    return maxtill;
}
ll pow1(ll a,ll b,ll mod1){
    int res=1;
    if(b<0) b+=mod1-1;
    while(b>0){
        if(b&1){
        	res=(res*a)%mod1;
		}
        a=(a*a)%mod1;
        b>>=1;
    }
    return res%mod1;
}
ll dp[100001]={0};
ll dpw[100001]={0},dpb[100001]={0};
void dfs(ll node,ll prev){
    dpw[node]=1;
    dpb[node]=1;
    for(ll child : adj[node]){
        if(child==prev)continue;
        dfs(child,node);
        dpb[node]=dpw[child]*dpb[node]%mod;
        dpw[node]=dpw[node]*dp[child]%mod;
    }
    dp[node]=dpw[node]+dpb[node];
    dp[node]%=mod;
}
int main(){
	fast
    ll t;
    //cin>>t;
    t=1;
    while(t--){
            ll n;
            cin>>n;
            //ll par[n+1];
            rep(i,1,n){
                ll x,y;
                cin>>x>>y;
                adj[x].pb(y);
                adj[y].pb(x);
            }
            dfs(1,-1);
            cout<<dp[1];
    }
    return 0;
}



Measured memory_bytes: 20676
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    set<int>s;
    multiset<int>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
        s.insert(a[i]);
    }
    for(int i=0;i<n;i++){
        auto it=m.lower_bound(a[i]);
        if(it==m.begin()){
            m.insert(a[i]);
        }else{
            it--;
            m.erase(it);
            m.insert(a[i]);
        }
    }
    int count=m.size();
    cout<<count<<endl;
    
    return 0;
    
}



Measured memory_bytes: 10240
def main():
  from sys import stdin
  input = stdin.readline
  h,w = map(int,input().split())
  s = []
  sa = s.append
  sa(list("."*(w+2)))
  for _ in range(h):
    sa(["."]+list(input().strip())+["."])
  sa(list("."*(w+2)))
  for i in range(1,h+1):
    for j in range(1,w+1):
      if s[i][j] == ".":
        n = 0
        n += s[i-1][j-1:j+2].count("#")
        n += s[i][j-1:j+2].count("#")
        n += s[i+1][j-1:j+2].count("#")
        s[i][j] = str(n)
  for i in range(1,h+1):
    print("".join(s[i][1:w+1]))
main()

Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;
const int maxN = 1e3;

void solve() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 && i % 5) ans += i;
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //int t;
    //cin >> t;
    int t = 1;
    //srand(time(0));
    while (t--) solve();
}

Measured memory_bytes: 3608
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as MP
import Control.Monad

step :: MP.Map B.ByteString Int -> B.ByteString -> MP.Map B.ByteString Int
step mp x = MP.insertWith (+) x 1 mp

step' :: Int -> Int -> Int
step' acc v
    | v == 1 = acc
    | otherwise = acc + sum [1..v-1]

main = do
    n <- readLn :: IO Int
    xs <- replicateM n (B.sort <$> B.getLine) :: IO [B.ByteString]
    let mp = foldl step MP.empty xs
    print $ MP.foldl step' 0 mp

Measured memory_bytes: 432892
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int N;
ll Z,W;
vector<ll> A;
vector<vector<ll>> dp;

ll dfs(int n, int a) {
    if (dp[n][a] != -1) return dp[n][a];
    ll R = (n == N ? W : A[N-1-n]);
    ll score;
    if (a == 0) {
        score = 0;
        for (int i = 1; i < n; i++) {
            chmax(score,dfs(n-i,1-a));
        }
        chmax(score,abs(R - A[N-1]));
    } else {
        score = 1e18;
        for (int i = 1; i < n; i++) {
            chmin(score,dfs(n-i,1-a));
        }
        chmin(score,abs(R - A[N-1]));
    }
    return dp[n][a] = score;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> N >> Z >> W;
    A.resize(N);
    rep(i,N) cin >> A[i];
    
    dp.resize(N+1, vector<ll>(2,-1));

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

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll unsigned long long
#define f(a,b) for(int i=a;i<b;i++)
#define nitro cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define mod 1000000001
using namespace std;
int dp[30005][3005];
void lcs(string s,string p,int n,int m)
{
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else
            {
                if(s[i-1]==p[j-1])
                    dp[i][j]=1+dp[i-1][j-1];
                else
                    dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
            }
        }
    }
}
string solve(string s,string p)
{
    int n=s.size();
    int m=p.size();
    lcs(s,p,n,m);
    string res="";
    int i=n,j=m;
    while(i>0&&j>0)
    {
        if(s[i-1]==p[j-1])
        {
            res.push_back(s[i-1]);
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
            i--;
        else
            j--;
    }
    reverse(res.begin(),res.end());
    return res;
}
int main()
{
   	nitro;
    string s,p;
    cin>>s>>p;
    memset(dp,-1,sizeof(dp));
    cout<<solve(s,p);
}


Measured memory_bytes: 355772
#include <bits/stdc++.h>
// e.g. sort(all(a), [](int a1, int a2) { return a1 < a2; });
#define all(a) (a).begin(),(a).end()
#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() {
  string s;
  cin >> s;
  // 長さ
  int len = s.size();
  // 長さの半分分をループする
  int ans = 0;
  rep(i,(len+2-1)/2) {
    if (s[i] != s[len-1-i]) {
      ans += 1;
    }
  }

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


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
   int W,H,x,y,r;
   
   cin >> W >> H >> x >> y >> r;
   
   bool isOK = true;
   
   if ((x-r) <0 || (x+r) > W) isOK = false;
   if ((y-r) < 0|| (y+r) > H) isOK = false;
   
   if(isOK)
   {
       cout << "Yes";
   }
   else
   {
       cout << "No";
   }
   
   cout << endl;
    
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    int N,M;
    cin >> N >> M;
    vector<vector<int>>s(M);
    vector<int>p(M);
    for(int i = 0; i < M; i++) {
        int k;
        cin >> k;
        for(int j = 0; j < k; j++){
            int X;
            cin >> X;
            X--;
            s[i].push_back(X);
        }
    }
    for(int i = 0; i < M; i++) {
        cin >> p[i];
    }
    int ans = 0;
    for(int bit = 0; bit<(1<<N); bit++) {
        bool ok = true;
        for(int i = 0; i < M; i++) {
            int cnt = 0;
            for(auto x : s[i]){
                if(bit & (1<<x) ) cnt++;
            }
            if(cnt%2 != p[i]) ok = false;
        }
        if(ok) {
            ans++;
        }
    }
    cout<< ans <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  int res = n + 1, ans = 0;
  rep(i, n) {
    if (p[i] < res) {
      ans++;
      res = p[i];
    }
  }
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

        String a = input.readLine();

        System.out.println("aeiou".contains(a) ? "vowel" : "consonant");
    }
}


Measured memory_bytes: 23124
#      
import collections, atexit, math, sys, bisect 

sys.setrecursionlimit(1000000)
def getIntList():
    return list(map(int, input().split()))    

try :
    #raise ModuleNotFoundError
    import numpy
    def dprint(*args, **kwargs):
        #print(*args, **kwargs, file=sys.stderr)
        # in python 3.4 **kwargs is invalid???
        print(*args,  file=sys.stderr)
    dprint('debug mode')
except Exception:
    def dprint(*args, **kwargs):
        pass



inId = 0
outId = 0
if inId>0:
    dprint('use input', inId)
    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #标准输出重定向至文件
if outId>0:
    dprint('use output', outId)
    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #标准输出重定向至文件
    atexit.register(lambda :sys.stdout.close())     #idle 中不会执行 atexit
zp = []
for i in range(1, 31):
    zp.append(2**i)

dprint(zp)
    
N, = getIntList()
#print(N)

za = getIntList()

tc = collections.Counter(za)
za.sort(reverse = True)

r = 0
for x in za:
    if tc[x]==0: continue
    tc[x] -= 1
    for y in zp:
        if y<= x: continue
        g = y - x
        if g> x:
            break
        if tc[g] >0:
            r +=1
            tc[g] -=1
print(r)            
        







Measured memory_bytes: 112976
#include<iostream>

using namespace std;
int main(){
  int ax,ay,bx,by,cx,cy,dx,dy;
  cin >> ax >> ay >> bx >> by;
  dy=ay-(ax-bx);
  dx=ax+(ay-by);
  cx=bx+(ay-by);
  cy=by-(ax-bx);
  cout << cx << " " << cy << " " << dx << " " << dy << endl;
}


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

int main(){
    set<int>se;
    int q,n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>q;
        se.insert(q);
    }
    cout<<se.size()<<endl;
    return(0);
}

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

using namespace std;
const int N = 123456 * 2;
int prime[N + 1];


int main() {
	for(int i = 0;i <= N;++i) {
		prime[i] = 1;
	}
	prime[0] = prime[1] = 0;
	for(int i = 2;i <= sqrt(N);++i) {
		if(prime[i]) {
			for(int j = 2 * i; j <= N; j += i){
				prime[j] = 0;
			}
		}
	}
	int n, c;
	while(cin >> n, n) {
		c = 0;
		for(int i = n + 1;i <= 2 * n;++i) {
			c += prime[i];
		}
		cout << c << endl;
	}
	return 0;
}



Measured memory_bytes: 4056
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n,a[100009];
	int cost[100009];
	int sum=0;
	//
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> a[i];
	}
	a[0]=0;a[n+1]=0;
	//
	
	for(int i=0;i<=n;i++){
		cost[i]=abs(a[i]-a[i+1]);
		sum+=cost[i];
	}
	
	for(int i=1;i<=n;i++){
		cout << sum-(cost[i-1]+cost[i])+abs(a[i-1]-a[i+1]) << endl;
	}
	return 0;
}

Measured memory_bytes: 2048
#include <iostream> 
#include <cstdio>

using namespace std;

#define For(i , a , b) for (int i = a , _b = b ; i <= _b ; ++i)
#define Ford(i , a  ,b) for (int i = a , _b = b : i >= _b ; --i)
#define Rep(i , n) for (int i = 0 , _n = n ; i < _n ; ++i)
#define sz(A) ((int)A.size())
#define LL(x) (x << 1)
#define RR(x) ((x << 1) | 1)

typedef pair<int , int> pt;

const int maxn = 100000 + 123;
int n, a[maxn], x;

void ReadData() {
	cin >> n >> x;
	For(i,1,n) cin >> a[i];
}

void Process() {
	long long res = 0;
	For(i,2,n) {
		long long z = a[i] + a[i - 1];
		z -= x; 
		if (z <= 0) continue;
		res += z;
		if (z >= a[i]) {
			a[i] = 0;
			a[i - 1] -= (z - a[i]);
		}  else {
			a[i] -= z;
		}
	}

	cout << res << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
//	freopen("input.inp" , "r" , stdin);
	ReadData();
	Process();

	return 0;

}			

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.nextLine());
		String S = scan.nextLine();
		String src;
		String dest;
		boolean exist = false;

		int index = 0;
		int ans = 0;

		while (index + ans + 1 <= N) {
			src = S.substring(index, index + ans + 1);
			for (int i = index + ans + 1 ; i + ans + 1 <= N; i++) {
				dest = S.substring(i, i + ans + 1);
				if (src.equals(dest)) {
					ans = src.length();
					exist = true;
					break;
				}
			}
			// 一致するものがない場合は次の文字に
			if (!exist) {
				index++;
			}
			exist = false;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 346528
import math


n = int(input())
a = math.sqrt(n)

if n % a == 0.0:
    b = int(math.log10(a)) + 1
    print(b)
else:
    a = int(a)
    for i in range(a, 0, -1):
    	if n % i == 0:
    		a = n / i
    		break
    b = int(math.log10(a)) + 1
    print(b)

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

int main(){
	int n, k;
	cin >> n >> k;
	int r, s, p;
	cin >> r >> s >> p;
	string t;
	cin >> t;
	int ans = 0;
	for(int i = 0; i < k; i++){
		int dp[3] = {}, nxt[3] = {};
		for(int j = i; j < n; j += k){
			for(int l = 0; l < 3; l++) nxt[l] = 0;
			// win
			if(t[j] == 's') nxt[0] = max(nxt[0], max(dp[1], dp[2]) + r);
			if(t[j] == 'p') nxt[1] = max(nxt[1], max(dp[0], dp[2]) + s);
			if(t[j] == 'r') nxt[2] = max(nxt[2], max(dp[0], dp[1]) + p);
			// lose
			if(t[j] == 'p') nxt[0] = max(nxt[0], max(dp[1], dp[2]));
			if(t[j] == 'r') nxt[1] = max(nxt[1], max(dp[0], dp[2]));
			if(t[j] == 's') nxt[2] = max(nxt[2], max(dp[0], dp[1]));
			// draw
			if(t[j] == 'r') nxt[0] = max(nxt[0], max(dp[1], dp[2]));
			if(t[j] == 's') nxt[1] = max(nxt[1], max(dp[0], dp[2]));
			if(t[j] == 'p') nxt[2] = max(nxt[2], max(dp[0], dp[1]));
			swap(dp, nxt);	
		}
		ans += max({dp[0], dp[1], dp[2]});
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
/*input
3 1 4
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#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())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main(){
	IOS;
	ll a,b,c;
	cin>>a>>b>>c;
	c=min(c,a+b+1);
	cout<<b+c<<'\n';
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := makeWordScanner()
	n := eGetInt(scanner)
	m := make(map[string]bool)
	for i := 0; i < n; i++ {
		s := eGetLine(scanner)
		m[s] = true
	}
	fmt.Println(len(m))
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
const (
	TooLarge = math.MaxInt64
	TooSmall = math.MinInt64
)

func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func pow(a, n int) int {
	if n == 0 {
		return 1
	}
	if n == 1 {
		return a
	}
	if n%2 == 1 {
		return pow((a*a), n/2) * a
	}
	return pow((a * a), n/2)
}
func powMod(a, n, mod int) int {
	if n == 0 {
		return 1 % mod
	}
	if n == 1 {
		return a % mod
	}
	if n%2 == 1 {
		return powMod((a*a)%mod, n/2, mod) * a % mod
	}
	return powMod((a*a)%mod, n/2, mod)
}

func factoricalMod(n, count, mod int) int {
	if count == 1 {
		return n % mod
	}
	return (n % mod) * (factoricalMod(n-1, count-1, mod)) % mod
}

func combinationMod(n, a, mod int) int {
	x := factoricalMod(n, a, mod)
	y := factoricalMod(a, a, mod)
	y = powMod(y, mod-2, mod)
	return ((x % mod) * (y % mod)) % mod
}
func countBitOfOn(i, numbits int) int {
	count := 0
	var bit uint64
	for bit = 0; bit < uint64(numbits); bit++ {
		t := 1 << bit
		if i&t > 0 {
			count++
		}
	}
	return count
}

type ints []int

func ToString(slice []int) string {
	format := fmt.Sprint(slice)
	return fmt.Sprint(format[1 : len(format)-1])
}


Measured memory_bytes: 14360
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    int N;
    cin >> N;
    int v[100];
    int s[101];
    int c = 0;
    double t = 0;
    rep(i, 101) {
        s[i] = 0;
    }
    rep(i, N){
        int res;
        cin >> res;
        t += res;
        if (s[res] == 0) {
            v[c] = res;
            s[res] = i+1;
            c++;
        }
    }

    t /= (double)N;

    sort(v, v+c);
    int res;
    rep(i, N){
        if (t <= v[i]) {
            res = i;
            break;
        }
    }

    if (res >= 1) {
        if (abs((double)v[res-1] - t) < abs((double)v[res] - t)) {
            cout << s[v[res-1]] - 1 << endl;
        } else if (abs((double)v[res-1] - t) > abs((double)v[res] - t)){
            cout << s[v[res]] - 1 << endl;
        } else {
            cout << min(s[v[res-1]], s[v[res]]) - 1 << endl;
        }
    } else {
        cout << s[v[res]] - 1 << endl;
    }

}

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

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
   	ll n;
   	string a;
   	cin>>n;
   	ll cAC=0, cWA=0, cTLE=0, cRE=0;
   	while(n--){
   		cin>>a;
   		if(a=="AC"){
   			cAC++;
   		}
   		if(a=="WA"){
   			cWA++;
   		}
   		if(a=="TLE"){
   			cTLE++;
   		}
   		if(a=="RE"){
   			cRE++;
   		}
   	}
   	cout<<"AC"<<" "<<'x'<<" "<<cAC<<"\n";
   	cout<<"WA"<<" "<<'x'<<" "<<cWA<<"\n";
   	cout<<"TLE"<<" "<<'x'<<" "<<cTLE<<"\n";
   	cout<<"RE"<<" "<<'x'<<" "<<cRE<<"\n";
   	
	return 0;
}

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

using namespace std;

const int maxn=1e5+20;
int a[maxn];
int main()
{
	int n;
	cin >> n;
	int c=0;
	for(int i=0; i<2*n; i++)
	{
		cin >> a[i];
	}
	sort(a, a+2*n);
	for(int i=0; i<2*n; i+=2)
	{
		c+=a[i];
	}
	cout << c;
}


Measured memory_bytes: 256