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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,a[300005],ans=1;
string s;
map<string,int> f;
void solve(){
    cin>>n>>s;
    rep(i,1,n+1) ans=ans*i%hell;
    n*=3;
    rep(i,0,n){
        if(s[i]=='R') a[i]=0;
        if(s[i]=='G') a[i]=1;
        if(s[i]=='B') a[i]=2;
    }
    rep(i,0,n){
        if(a[i]==0){
            if(f["12"]) ans=ans*f["12"]%hell,f["12"]--;
            else if(f["1"]) ans=ans*f["1"]%hell,f["01"]++,f["1"]--;
            else if(f["2"]) ans=ans*f["2"]%hell,f["02"]++,f["2"]--;
            else f["0"]++;
        }
        else if(a[i]==1){
            if(f["02"]) ans=ans*f["02"]%hell,f["02"]--;
            else if(f["0"]) ans=ans*f["0"]%hell,f["01"]++,f["0"]--;
            else if(f["2"]) ans=ans*f["2"]%hell,f["12"]++,f["2"]--;
            else f["1"]++;            
        }
        else{
            if(f["01"]) ans=ans*f["01"]%hell,f["01"]--;
            else if(f["0"]) ans=ans*f["0"]%hell,f["02"]++,f["0"]--;
            else if(f["1"]) ans=ans*f["1"]%hell,f["12"]++,f["1"]--;
            else f["2"]++;
        }
    }
    cout<<ans<<endl;
}

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

Measured memory_bytes: 2964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string n; cin>>n;
    string ans = "";
    rep(i, 3){
        if(n[i]=='1'){
            ans += '9';
        } else if(n[i]=='9'){
            ans += '1';
        } else {
            ans += n[i];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

def main():
    S = [int(s) for s in input()]
    N = len(S)
    K = 2019

    V = [0] * (N+1)
    for i in reversed(range(N)):
        rev_i = (N-1)-i
        V[rev_i+1] = V[rev_i] + S[i] * (pow(10,rev_i+1,K))
        # print(V)

    dic = {} # value:count
    U = set()
    for v in V:
        u = v % K
        if u in U:
            dic[u] += 1
        else:
            dic[u] = 1
            U.add(u)

    ans = 0
    for u in U:
        u_count = dic[u]
        ans += u_count * (u_count-1) // 2

    # print(S)
    # print(V)
    # print(dic)
    print(ans)

if __name__ == "__main__":
  main()

Measured memory_bytes: 77976
#include <stdio.h>
#include <string.h>

int main() {
  char A[110], B[110];
  int Alength, Blength;
  int i;
  
  scanf("%s %s", A, B);
  Alength = strlen(A);
  Blength = strlen(B);
  if(Alength < Blength) {
    printf("LESS\n");
    return 0;
  } else if(Alength > Blength) {
    printf("GREATER\n");
    return 0;
  } else {
    for(i = 0; i < Alength; i++) {
      if(A[i] < B[i]) {
        printf("LESS\n");
        return 0;
      } else if(A[i] > B[i]) {
        printf("GREATER\n");
        return 0;
      }
    }
  }
  printf("EQUAL\n");
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int N, K;
    while(cin >> N >> K) {
        if(N == 0) break;
        vector<ll> a(N);
        for(int i = 0; i < N; ++i) cin >> a[i];

        vector<int> s(N+1, 0);
        for(int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

        ll res = -INF;
        for(int i = 0; i <= N-K; ++i) {
            ll val = s[K+i] - s[i];
            if(res < val) res = val;
        }
        cout << res << endl;
    }

}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
using namespace std;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
typedef vector<ll> vc;
typedef vector<string> vcs;
typedef vector<pair<ll, ll>> vcp;
typedef vector<tuple<ll, ll, ll>> vct;
//vector<vector<ll>> vv(n, vector<ll>(n));

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator >(const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int n, m,ans=0;
Graph g;

void dfs(bitset<8> b, int vert, int dep)
{
	if (dep == n-1) {
		ans++;
	}
	else {
		for (auto e : g[vert]) {
			if (!b[e.to]) {
				bitset<8> tmp=b;
				tmp[e.to] = 1;
				dfs(tmp, e.to, dep + 1);
			}
		}
	}
}

int main()
{
	cin >> n >> m;
	g.resize(n);
	REP(i, m)
	{
		ll a, b;
		cin >> a >> b;
		a--; b--;
		add_edge(g, a, b, 1);
		add_edge(g, b, a, 1);
	}
	bitset<8> init;
	init[0] = 1;
	dfs(init, 0, 0);
	cout << ans << endl;
}

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

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

using namespace std;

const int INF = 10000;

int main()
{
	
	rep(i, 1000) {
		int H, W;
		cin >> H >> W;

		if (H == 0 || W == 0)continue;

		rep(i, H) {
			rep(j, W) {
				if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1)) {
					cout << "#";
				}
				else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}



Measured memory_bytes: 3116
#include<iostream>
using namespace std;
int main (void){
 
    int a, b, c, aa, bb ,cc;
 
    cin >> a >> b;
 
    aa = a + b;
 
    bb = a - b;
 
    cc = a * b;
 
    if(aa < bb)
        c = bb;
    else 
        c = aa;
 
    if(c < cc)
        c = cc;
       
        
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=105;
int ans[maxn][maxn];
int a[maxn*maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h,w,n;
    cin>>h>>w>>n;
    for(int i=1;i<=n;++i)
        cin>>a[i];
    int tot=0;
    int f=1;
    for(int i=1;i<=n&&a[i];++i){
        while(a[i]){
            ans[tot/w][tot%w]=i;
//            cout<<"*"<<ans[tot/w][tot%w]<<endl;
            a[i]--;
//            cout<<tot/w<<" "<<tot%w<<endl;
//            cout<<a[i]<<" "<<tot<<" "<<i<<endl;
            if((((tot+1)%w==0&&(((tot+1)/w)&1))||(tot%w==0&&((tot/w)&1)))&&tot){
                tot+=w;
                f*=-1;
            }
            else tot+=f;
        }
    }
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }

}


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

using namespace std;

int main()
{
    string str;
    int cnt1=0,cnt2=0;
    cin>>str;

    for(int i=0;i<str.length();i++){
        if(i%2==0){
            if(str[i]!='0') cnt1++;
        }else {
            if(str[i]!='1') cnt1++;
        }
        if(i%2==0){
            if(str[i]!='1') cnt2++;
        }else {
            if(str[i]!='0') cnt2++;
        }
    }
    cout <<min(cnt1,cnt2)<<endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;


long long fact[202020], frev[202020];

long long modpow(long long a, long long p = MOD - 2) {
    if (p == 0) return 1;
    long long tmp = modpow(a, p / 2);
    tmp = tmp * tmp % MOD;
    if (p % 2 == 1) tmp = tmp * a % MOD;
    return tmp;
}

long long C(int p, int q){
    if (q < 0 || p < q) return 0;
    return fact[p] * frev[q] % MOD * frev[p - q] % MOD;
}

int main(){
    fact[0] = frev[0] = 1;
    for(int i=1;i<=200000;i++){
        fact[i] = (fact[i - 1] * i) % MOD;
        frev[i] = modpow(fact[i]);
    }

    int n;
    cin >> n;

    vector<int> a(n+1);
    vector<int> pos(n, -1);
    int l = -1, r = -1;
    for(int i=0;i<n+1;i++){
        cin >> a[i];
        if(pos[a[i]-1] == -1){
            pos[a[i]-1] = i;
        }else{
            l = pos[a[i]-1];
            r = i;
        }
    }

    for(int k=1;k<=n+1;k++){
        cout << (C(n+1, k) - C(l + (n-r), k - 1) + MOD) % MOD << endl;
    }

    return 0;
}

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

typedef unsigned long long ull;

int main() {
  ull a, b, x;
  cin >> a >> b >> x;

  ull ans;
  if (a == 0) {
    ans = b / x + 1;
  } else {
    ans = b / x - (a - 1) / x;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
        int n,i,j,m,k;
        cin>>n>>k;
        int arr[n+1],dp[n+1]={0};
        for(i=1;i<n+1;i++){
        cin>>arr[i];
        dp[i]=0;
        }
        for(i=2;i<n+1;i++)
        {
        	m=INT_MAX;
        	for(j=1;j<k+1;j++)
        	{
        		if(i-j>0)
        		{
        			m=min(m,dp[i-j]+max(arr[i],arr[i-j])-min(arr[i],arr[i-j]));
        		}
        	}
        	dp[i]+=m;
        }
        cout<<dp[n];
    	return 0;
    }

Measured memory_bytes: 1024
#include<stdio.h>
 
int main()
{
int n, x[100002]={0}, s, i, max;

scanf("%d", &n);
for(i=0; i<n; i++){
  scanf("%d", &s);
  x[s]++;
}
 
max = 0;
for( i = 0; i <= 100000; i++){
  s = x[i] + x[i+1] + x[i+2];
  if( s > max ){
    max = s;
  }
}

printf("%d\n", max);

return 0;
}



Measured memory_bytes: 512
import sys
sys.setrecursionlimit(1000000)
#def input():
#    return sys.stdin.readline()[:-1]

'''
n=int(input())
for i in range(n):
    a[i]=int(input())
    a[i],b[i]=map(int,input().split())
a=[int(x) for x in input().split()]
n,m=map(int,input.split())
from operator import itemgetter
a = [(1, "c", 1), (1, "b", 3), (2, "a", 0), (1, "a", 2)]
print(sorted(a))  # 0 番目の要素でソート、先頭の要素が同じなら 1 番目以降の要素も見る
print(sorted(a, key=itemgetter(0)))  # 0 番目の要素だけでソート
print(sorted(a, key=itemgetter(0, 2)))  # 0 番目と 2 番目の要素でソート
print(sorted(a, key=lambda x: x[0] * x[2]))  # 0 番目の要素 * 2 番目の要素でソート
print(sorted(a, reverse=True))  # 降順にソート
a.sort()  # 破壊的にソート、sorted() よりも高速
try: # エラーキャッチ list index out of range
    for i in range():
        k=b[i]
except IndexError as e:
    print(i)
'''

test_data1 = '''\
3
1 2 1
'''

test_data2 = '''\
2 3 0
4 5 6
7 8 9
-1 2 -5
'''

test_data3 = '''\
9
1 1 1 2 2 1 2 3 2
'''
td_num=3

def GetTestData(index):
    if index==1:
        return test_data1
    if index==2:
        return test_data2
    if index==3:
        return test_data3

if False:
    with open("../test.txt", mode='w') as f:
        f.write(GetTestData(td_num))
    with open("../test.txt") as f:
        # Start Input code ---------------------------------------
        n=int(f.readline())
        b=list(map(int,f.readline().split()))
        # End Input code ---------------------------------------
else:
    for i in range(1):
        # Start Input code ---------------------------------------
        n=int(input())
        b=list(map(int,input().split()))
        # End Input code ---------------------------------------
#print('n,m,x,y=',n,m,x,y)
ans=[]
#print(b)
cnt=0
while cnt<100 and len(b)>0:
    m=len(b)
    cnt+=1
    flg=False
    for i in range(m):
        #print('i,i+1,m-1-i,b[m-1-i]',i,i+1,m-1-i,b[m-1-i],b)
        if b[m-1-i]==m-i:
            ans.append(b.pop(m-1-i))
            
            flg=True
            break
    if flg==False:
        break
if len(ans)==n:
    for i in range(n):
        print(ans[-i-1])
else:
    print(-1)

Measured memory_bytes: 3064
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	cin>>n;
	vint v(n);
	rep(i,n) cin>>v[i];
	int p = n-1;
	vint ans;
	while(p>=0){
		ans.PB(v[p]);
		p-=2;
	}
	if(p==-2) p=1;
	else p=0;
	while(p<n){
		ans.PB(v[p]);
		p+=2;
	}
	rep(i,n){
		if(i) cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 3956
# Author: cr4zjh0bp
# Created: Sun Mar  1 12:10:03 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

n, m = na()
sc = nan(m)

def digit(n):
    c = 1
    while n // 10 != 0:
        n //= 10
        c += 1
    return c

ans = -1
for i in range(1000):
    k = digit(i)
    if k != n:
        continue
    else:
        cs = str(i)
        flag = True
        for j in range(m):
            s, c = sc[j]
            if int(cs[s - 1]) != c:
                flag = False
        if flag:
            ans = i
            break

print(ans)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int cnt = 0;
		if(!(A % 2 == B % 2 && B % 2 == C % 2)) {
			if(A % 2 != B % 2 && A % 2 != C % 2) {
				B++;
				C++;
				cnt++;
			} else if(A % 2 != B % 2 && B % 2 != C % 2) {
				A++;
				C++;
				cnt++;
			} else {
				A++;
				B++;
				cnt++;
			}
		}
		
		if(A >= B && A >= C) {
			cnt += ((A - B) / 2) + ((A - C) / 2);
		} else if(B >= A && B >= C) {
			cnt += ((B - A) / 2) + ((B - C) / 2);
		} else {
			cnt += ((C - A) / 2) + ((C - B) / 2);
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 21972
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 29 21:14:35 2020
"""

import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

N = int(input())
#X, Y = map(int,input().split())
a = np.array(list(map(int,input().split())))
b = np.array(list(map(int,input().split())))

c = b - a

ok = np.sum(c[c > 0]//2)
ng = np.sum(-c[c < 0])

if ok >= ng:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Measured memory_bytes: 20512
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int x, y, z;
        cin >> x >> y >> z;
        if(x == 0)
            return 0;

        vector<int> roulette(x);
        for(int i=0; i<x; ++i)
            cin >> roulette[i];

        int maxMoney = 0;
        vector<pair<int, int> > masu(y+1, make_pair(-1, -1));
        for(int i=0; i<z; ++i){
            int n, e, a;
            cin >> n >> e >> a;
            masu[n] = make_pair(e, a);
            if(e == 2)
                maxMoney += a;
        }

        vector<vector<double> > prob(y+1, vector<double>(maxMoney+1, 0.0));
        prob[0][0] = 1.0;
        for(int i=0; i<y; ++i){
            for(int j=0; j<x; ++j){
                int to = min(y, i + roulette[j]);
                int get = 0;
                if(masu[to].first == 1)
                    to = min(y, to + masu[to].second);
                else if(masu[to].first == 2)
                    get = masu[to].second;
                else if(masu[to].first == 3)
                    get = -masu[to].second;
                for(int k=0; k<=maxMoney; ++k){
                    int money = min(maxMoney, max(0, k+get));
                    prob[to][money] += prob[i][k] / x;
                }
            }
        }

        double ret = 0.0;
        for(int i=0; i<=maxMoney; ++i)
            ret += i * prob[y][i];
        cout << (int)ret << endl;
    }
}

Measured memory_bytes: 0
//????????????
#include <bits/stdc++.h>
using namespace std;
int main(){
	stack<int> s;
	string tmp;
	while( cin>>tmp ){
		if(tmp=="+"){
			int b = s.top();
			s.pop();
			int a = s.top();
			s.pop();
			s.push(a+b);
		} else if(tmp=="-"){
			int b = s.top();
			s.pop();
			int a = s.top();
			s.pop();
			s.push(a-b);
		} else if(tmp=="*"){
			int b = s.top();
			s.pop();
			int a = s.top();
			s.pop();
			s.push(a*b);
		} else {
			int a = stoi(tmp);
			s.push(a);
		}
	}
	int result = s.top();
	cout<<result<<endl;
	return 0;
}

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

int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n; string s;
	cin >> n >> s;
	int ans = 0;
	for(int i = 0;i < n-2;i++){
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
	}
	cout << ans;
}


Measured memory_bytes: 256
class Dice():
    def __init__(self, ls = [0 for i in range(6)]):
        self.ls = ls
        
    def now(self):
        return ls
    
    def S(self):
        ls = self.ls
        n_ls = [0 for i in range(6)]
        n_ls[0] = ls[4]
        n_ls[1] = ls[0]
        n_ls[2] = ls[2]
        n_ls[3] = ls[3]
        n_ls[4] = ls[5]
        n_ls[5] = ls[1]
        
        return Dice(n_ls)
    
    def N(self):
        ls = self.S().S().S().ls
        return Dice(ls)
        
    def E(self):
        ls = self.ls
        n_ls = [0 for i in range(6)]
        n_ls[0] = ls[3]
        n_ls[1] = ls[1]
        n_ls[2] = ls[0]
        n_ls[3] = ls[5]
        n_ls[4] = ls[4]
        n_ls[5] = ls[2]
        return Dice(n_ls)
    
    
    def W(self):
        ls = self.E().E().E().ls
        return Dice(ls)
        
        
        
    def R_rot(self):
        return self.E().S().W()
        
    def rot(self, num):
        for _ in range(num):
            self = self.R_rot()
        return self
    
ls = list(map(int, input().split()))
q = int(input())

a = Dice(ls)
#print(a.ls)
me = [a, a.N(), a.W(), a.E(), a.S(), a.S().S()]
#print([i.ls for i in me])

for _ in range(q):
    n, m = map(int, input().split())



    B= Dice()
    for i in me:
        if i.ls[0] == n:
            B = i
#print(B.ls)
    Rot = [B.rot(i) for i in range(4)]
    for i in Rot:
        if i.ls[1] == m:
            print(i.ls[2])


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

int main() {
    //エラストテネスの篩
    int mx = 55555;
    vector<bool> prime(mx+1,true);
    prime[1] = false;
    for (int i = 2; i <= mx; i++) {
        if (prime[i]) {
            for (int j = 2*i; j <= mx; j += i) prime[j] = false;
        }
    }
    int n; cin >> n;
    vint x;
    for (int i = 2; i <= mx; i++) {
        if (i % 5 != 1) continue;
        if (prime[i]) {
            x.push_back(i);
        }
    }
    rep(i,n) {
        if (i == n-1) cout << x[i] << endl;
        else cout << x[i] << " ";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define reps(i, s, n) for(int i = (s); i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, s, n) for(int i = (n) - 1; i >= (s); i--)
#define INF ~(1 << 31)
#define INFL ~(1LL << 63)

int main()
{
    int n;
    cin >> n;
    vector<vector<int>> h(n, vector<int>(3));
    rep(i, n){
        cin >> h[i][0] >> h[i][1] >> h[i][2];
    }
    vector<vector<int>> ans(n, vector<int>(3));
    ans[0][0] = h[0][0];
    ans[0][1] = h[0][1];
    ans[0][2] = h[0][2];
    reps(i, 1, n){
        ans[i][0] = max(ans.at(i-1).at(1), ans.at(i-1).at(2)) + h[i][0];
        ans[i][1] = max(ans.at(i-1).at(2), ans.at(i-1).at(0)) + h[i][1];
        ans[i][2] = max(ans.at(i-1).at(0), ans.at(i-1).at(1)) + h[i][2];
    }
    int ansmax = max(ans.at(n-1).at(0), ans.at(n-1).at(1));
    ansmax = max(ansmax, ans.at(n-1).at(2));
    cout << ansmax << endl;
}

Measured memory_bytes: 14064
using System;
using System.Linq;

class AtCoderCS {
    static void Main(string[] args) {
        int[] NK = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        int N = NK[0], K = NK[1];

        bool[] ans = new bool[N];
        for (int i = 0; i < K; i++) {
            int d = int.Parse(Console.ReadLine());
            foreach (int j in Console.ReadLine().Split(' ').Select(k => int.Parse(k)))
                ans[j - 1] = true;
        }

        Console.WriteLine(ans.Count(i => !i));
    }
}

Measured memory_bytes: 28480
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    if(t>=400 && t<=599)
    {
    	cout<<"8";
    }
    else if(t>=600 && t<=799)
    {
    	cout<<"7";
    }
    else if(t>=800 && t<=999)
    {
    	cout<<"6";
    }
    else if(t>=1000 && t<=1199)
    {
    	cout<<"5";
    }
    else if(t>=1200 && t<=1399)
    {
    	cout<<"4";
    }
    else if(t>=1400 && t<=1599)
    {
    	cout<<"3";
    }
    else if(t>=1600 && t<=1799)
    {
    	cout<<"2";
    }
    else
    {
    	cout<<"1";
    }
}
 

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

using namespace std;

using ll = long long;
#define rep(i,n) for(int i = 0; i < n ;++i)
#define all(v) v.begin(),v.end()


int main(){
  ll n;
  while(cin >> n,n){
    vector<ll> v(n);
    rep(i,n){
      cin >> v[i];
    }
    sort(all(v));
    ll ans = 10000000000;
    rep(i,n-1){
      ans = min(ans,v[i+1]-v[i]);
    }
    std::cout << ans << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3136
import java.util.*;
public class Main{
	public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int n = sc.nextInt();
	  int k = sc.nextInt();
	  int q = sc.nextInt();
	  int[] a = new int[q];
	  int[] p = new int[n];
	  for(int i=0;i<n;i++)p[i]=0;
	  for(int i=0;i<q;i++)a[i]=sc.nextInt();
	  for(int i=0;i<q;i++){
	  	p[a[i]-1]++;
	  }
	  for(int i=0;i<n;i++){
	  	if(k-q+p[i]>0)System.out.println("Yes");
	  	else System.out.println("No");
	  }
	}
}

Measured memory_bytes: 66692
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b) //最大公約数
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

ll lcm(ll a, ll b) //最小公倍数
{
	return a * b / gcd(a, b);
}

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

// ===============================================================

int main() {
	string a, b;
	cin >> a >> b;
	cout << b << a << endl;
}

Measured memory_bytes: 3600
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <utility>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iterator>
#include <sstream>

using namespace std;

int main()
{
	string s; getline(cin,s);
	int i = 0;
	while(i < (int)s.size()){
		int ap = s.find("apple",i);
		int pe = s.find("peach",i);
		if(ap == string::npos && pe == string::npos) break;
		bool a = true;
		if(ap == string::npos || (pe != string::npos && ap > pe)) a= false;
		if(a){
			s.replace(ap,5,"peach");
			i = ap + 5;
		} else {
			s.replace(pe,5,"apple");
			i = pe + 5;
		}
	}
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 0
st = input() 
n = st.count('N') 
s = st.count('S') 
e = st.count('E') 
w = st.count('W') 

if (n>0 and s==0) or (n==0 and s>0) or (w==0 and e>0) or (e==0 and w>0): 
  print("No") 
else:
  print("Yes") 

Measured memory_bytes: 9000
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

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

#define fs first
#define sc second


int main(void){
	int N, C;
	cin >> N >> C;
	vector<int> in;
	vector<PII> ban[31], ban2;
	REP(i, N){
		int s, t, c;
		cin >> s >> t >> c; c--;
		ban[c].push_back({s, t});
	}
	REP(i, C){
		sort(all(ban[i]));
		int l = -1, r = -1;
		REP(j, ban[i].size()){
			if(ban[i][j].fs != r){
				if(r != -1){
					ban2.push_back({l, r});
					l = -1; r = -1;
				}
				l = ban[i][j].fs; r = ban[i][j].sc;
			}else{
				r = ban[i][j].sc;
			}
		}
		if(r != -1)
			ban2.push_back({l, r});
	}

	priority_queue<int, vector<int>, greater<int> > pq;
	pq.push(-1);
	sort(all(ban2));
	REP(i, ban2.size()){
		if(pq.top() < ban2[i].fs){
			pq.pop();
			pq.push(ban2[i].sc);
		}else{
			pq.push(ban2[i].sc);
		}
	}
	cout << pq.size() << endl;
}


Measured memory_bytes: 2552
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N, M, X;
	cin >> N >> M >> X;
	vector<int>C(N);
	vector<vector<int>> A(N, vector<int>(M));
	for (int i = 0; i < N; i++) {
		cin >> C[i];
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}
	long long int min = 10000000;
	int yen = 0;
	int count = 0;
	vector<int> rec(M, 0);
	for (int bits = 1; bits < (1 << N); bits++) { //2^Nまでの全場合を探索する
		for (int i = 0; i < N; i++) {
			int mask = 1 << i;
			if (bits & mask) {  // i番目のbitが立っていれば加算する
				yen += C[i];
				for (int j = 0; j < M; j++) {
					rec[j] += A[i][j];
				}
			}
		}
		for (int j = 0; j < M; j++) {
			if (rec[j] >= X) {
				count++;
			}
		}
		if (count == M) {
			if (min > yen) {
				min = yen;
			}
		}
		count = 0;
		yen = 0;
		for (int j = 0; j < M; j++) {
			rec[j] = 0;
		}
	}
	if (min == 10000000) {
		cout << -1 << endl;
	}
	else {
		cout << min << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
int N;
vector<int> G[MAXN];
vector<int> values[MAXN];
int ans[MAXN];
int a[MAXN];
int st[MAXN],top;

void DFS(int u,int fa){
    int pos=lower_bound(st,st+top,a[u])-st;
    values[pos].push_back(st[pos]);
    st[pos]=a[u];
    bool yes=false;
    if(pos==top){
        top++;
        yes=true;
    }
    ans[u]=top;
    int siz=G[u].size();
    for(int i=0;i<siz;i++){
        int v=G[u][i];
        if(v==fa) continue;
        DFS(v,u);
    }
    if(yes){
        top--;
    }
    else{
        int sizsiz=values[pos].size();
        st[pos]=values[pos][sizsiz-1];
        values[pos].pop_back();
    }
}

void work(){
    scanf("%d",&N);
    for(int i=1;i<=N;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<N;i++){
        int u,v; scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
//    printf("---\n");
//    for(int i=1;i<=N;i++) values[i].push_back(INF);
    memset(st,INF,sizeof(st));
    top=0;
//    printf("---\n");
    DFS(1,-1);
    for(int i=1;i<=N;i++) printf("%d\n",ans[i]);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}









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

void chmax(int&a, int b) {
  if (a < b) a = b;
}

vector<vector<int>> G;
int dp[100000];


// メモ化再帰
int rec(int v) {
  if (dp[v] != -1) return dp[v];
  
  int res = 0;
  for (auto nv : G[v]) {
    chmax(res, rec(nv) + 1);
  }
  return dp[v] = res; //dp[v] を res にしてリターン
}

int main() {
  int N, M;
  cin >> N >> M;
 
  
  G.assign(N,vector<int>()); // GのN個分の要素として，空っぽのvector<int>を作る
  for (int i = 0; i < M; i++) {
    int x, y; cin >> x >> y;
    x--, y--; // 0-indexed
    G[x].push_back(y);
  }
  
  // dp の初期化
  for (int v = 0; v < N; v++) dp[v] = -1; 
  
  int ans = 0;
  for (int v = 0; v < N; v++) chmax(ans, rec(v));
  cout << ans << endl;

}

Measured memory_bytes: 8192
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    
    int b = sc.nextInt();
    
    int c = 2*a+2*b;
    int d = a*b;
    
    System.out.println(d + " " + c);
    }
}


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

void dfs(string &s, int maxn, int sz){
	
	if(sz==s.size()) {
		cout << s << endl;
		return;
	}
	for(int i=0; i<=maxn; i++){
		s += 'a' + i;
		bool flg=0;
		if(i==maxn){
			maxn++;
			flg = 1;
		}
		dfs(s,maxn,sz);
		s.pop_back();
		if(flg) break;
	}
	return;
}

int main() {
	
	string s;
	int n;
	cin >> n;
	dfs(s,0,n);
	
}


Measured memory_bytes: 1536
N, W = map(int, input().split())

weight = [0] * N
value = [0] * N
for i in range(N):
    w, v = map(int, input().split())
    weight[i], value[i] = w, v

dp = [[0]*(W+1) for _ in range(N)]
# dp[i][ws] : i番目までの品物から総重量がwsを超えないように選んだ時の総価値の最大値

for i in range(weight[0], W+1):
    dp[0][i] = value[0]

for i in range(1, N):
    for ws in range(W+1):
        if ws - weight[i] >= 0:
            dp[i][ws] = dp[i-1][ws - weight[i]] + value[i]
        dp[i][ws] = max(dp[i][ws], dp[i-1][ws])

print(dp[N-1][W])


Measured memory_bytes: 119916
#include<stdio.h>

void swap (int *x, int *y) {
  int temp;    

  temp = *x;
  *x = *y;
  *y = temp;
}


int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}

int main (void) {
  int array[200000];
  int i,n, tmp=0;
  scanf("%d", &n);
  for(i=0; i<n; i++){
  	scanf("%d", &array[i]);
  }

  quick_sort(array, 0, n-1);

	for(i=1; i<n; i++){
	if(array[i-1] == array[i]){
		tmp = -1;
		break;
		}
	}
	if(tmp==0) printf("YES\n");
	else printf("NO\n");
  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  string S;
  cin >> S;
  int cnt=0;
  int s=S.size();
  string memo="";
  for(int i=0;i<s;i++){
    int j=1;
    while(i+j-1<s && memo==S.substr(i,j)){
      j++; 
    }
    if(memo==S.substr(i,j))cnt--;
    memo=S.substr(i,j);
    i+=j-1; cnt++; 
  }
  cout << cnt << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int main()
{
	int x[4], y[4],dx,dy;

	scanf("%d%d%d%d", &x[0], &y[0], &x[1], &y[1]);

	dy= y[0] - y[1];
	dx = x[0] - x[1];

	x[2] = x[1] + dy;
	y[2] = y[1] - dx;
	x[3] = x[0] + dy;
	y[3] = y[0] - dx;

	printf("%d %d %d %d\n", x[2], y[2], x[3],y[3]);

	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#define BIT(nr) (1ULL << (nr))
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }


using namespace std;

// 汎用的な二分探索のテンプレ(めぐる式)
int binary_search(function<bool(int)> isOk, int ng, int ok) {

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOk(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

signed main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N+1, 0), cu(N+1, 0);
    rep(i, N) {
        cin >> A[i];
    }
    sort(ALLOF(A));

    int su = 0;
    REPS(i, N) {
        su += A[i];
        cu[i] = su;
    }

    auto isOK = [&](int x) -> bool {
        int cnt = 0;
        REPS(i, N) {
            //A[i]の相方がいくつあるかを数える
            //相方: x - A[i]以上の数
            auto it = lower_bound(ALLOF(A), x - A[i]);
            //累積和用の0を入れない
            if (it == A.begin()) {
                it++;
            }

            int buddyNum = A.end() - it;
            cnt += buddyNum;
        }
        if (cnt >= M) {
            return true;
        }
        else {
            return false;
        }
    };

    int maxX = binary_search(isOK, LL_HALFMAX, 1);

    int ans = 0;
    int cnt = 0;
    //累積和を用いてA[i] + 相方 >= maxX なる組み合わせを全部足す、個数も覚えておく
    REPS(i, N){
        auto it = lower_bound(ALLOF(A), maxX - A[i]);
        int ind = it - A.begin();
        chmax(ind, 1);  //累積和の関係で1-indexed
        int addCnt = N - ind + 1;
        cnt += addCnt;

        ind--;
        int add1 = A[i] * addCnt;
        int add2 = cu[N] - cu[ind];

        ans += add1;
        ans += add2;
    }

    if (cnt > M) {
        int dif = cnt - M;
        ans -= maxX * dif;
    }

    cout << ans << "\n";

    return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<string>s(n);
  for(int i=0;i<n;i++)
    cin>>s[i];
  int m;
  cin>>m;
  vector<string>t(m);
  for(int i=0;i<m;i++)
    cin>>t[i];
  int a,b=0;
  for(int i=0;i<n;i++){
    a=0;
    string u=s[i];
    for(int j=i;j<n;j++){
      if(s[j]==u) a++;
    }
    for(int j=0;j<m;j++){
      if(t[j]==u) a--;
    }
    b=max(a,b);
  }
  cout<<b<<endl;
}

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

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		//freopen("out.txt", "w", stdout);
	}
}

int main()
{
	long long w, h, x, y;
	cin >> w >> h >> x >> y;
	double ans = 1.0*w/2 * h;
	int flag = 0;
	if (x*2 ==  w && y*2 == h )
		flag = 1;
	printf("%.5lf %d", ans, flag);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int i,n,a,num[52]={};
  char b;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf(" %c",&b);
      scanf("%d",&a);

  switch(b)
    {
    case 'S':
  num[a-1]=a;
  break;
    case 'H':
      num[a+12]=a;
      break;
    case 'C':
      num[a+25]=a;
      break;
    case 'D':
      num[a+38]=a;
      break;
    }
    }
  for(i=0;i<52;i++)
    {
      if(num[i]==0)
	{
	  if(i<=12){b='S';
	    printf("%c %d\n",b,i+1);}
	
	  else if(i<=25){b='H';
	    printf("%c %d\n",b,i-12);}
	  else if(i<=38){b='C';
	  printf("%c %d\n",b,i-25);}
	  else{b='D';
	  printf("%c %d\n",b,i-38);}
	}
    }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=998244353,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll dp[5000][5000];//dp[i][j]:=前からi個数並べて青がj個の時の場合の数
ll bluenum;
ll red_cou,blue_cou;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>s;
    rep(i,Size(s)){
        if(s[i]=='1')bluenum++;
        else if(s[i]=='2')bluenum+=2;
    }
    dp[0][0]=1;
    rep(i,2*Size(s)){
        if(i<Size(s)){
            if(s[i]=='0')red_cou+=2;
            else if(s[i]=='1')red_cou++,blue_cou++;
            else blue_cou+=2;
        }
        rep(j,2*Size(s)){//青がj個
            if((i-j)+1<=red_cou)(dp[i+1][j]+=dp[i][j])%=MOD;//赤をadd
            if(j+1<=blue_cou)(dp[i+1][j+1]+=dp[i][j])%=MOD;
        }
    }
    Cout(dp[2*Size(s)][bluenum]%MOD);
    return 0;
}


Measured memory_bytes: 157696
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


a=int(input())
print(a+a*a+a*a*a)



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

using namespace std;

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

    long ans1, ans2, ansfinal;

    ans1=max(a*c, a*d);
    ans2=max(b*c, b*d);

    ansfinal=max(ans1, ans2);

    cout<<ansfinal<<endl;

}

Measured memory_bytes: 3608
// #include <bits/stdc++.h>
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>
#include<functional>
#include <bitset>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
typedef long long int lli;
// static const int MOD = 998244353;
// static const int MAX = 100005;
// static const int ls = 101;
// static const int NMAX = 5005;
// static const lli INFTY = 1000000000000;

// typedef priority_queue<int, greater<int>> RevQ;
// int n;
int x, y;
string s;
// lli l, r;
// lli gcd(lli a, lli b) {
//   return b ? gcd(b, a%b) : a;
// }

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


int main(){
  cin >> x >> y;
  int a, b;
  // int flag = 0;
  if ((2*x - y) % 3 != 0) {
    cout << 0 << endl;
  } else {
    b = (2*x - y) / 3;
    a = (x - 2*b);
    // cout << "a: " << a << "\n";
    // cout << "b: " << b << "\n";
    if (a < 0 || b < 0) {
      cout << 0 << endl;
    } else {
      mint ans;
      mint nume, denom;
      int minv = min(a, b);
      if (minv == 0) {
        cout << 1 << endl;
      } else {
        rep(i, a){
          if (i == 0)  {
            nume.x = a+b;
            denom.x = a;
            // cout << "nume: " << nume.x << "\n";
            // cout << "denom: " << denom.x << "\n";
            continue;
          } else {
            mint s,t;
            s.x = (a + b - i);
            t.x = (a-i);
            nume *= s;
            denom *= t;
          }
        }
        ans = nume/denom;
        cout << ans.x << endl;
      }
    }
  }
}


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

int main() {
	int n;
	cin >> n;
	int i;
	int ac = 0;
	int wa = 0;
	int tle = 0;
	int re = 0;
	string s;
	for (i = 0; i < n; i++) {
		cin >> s;
		if (s == "AC")ac += 1;
		if (s == "WA")wa += 1;
		if (s == "TLE")tle += 1;
		if (s == "RE")re += 1;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
}

Measured memory_bytes: 3632
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

n = int(arr_data[0][0])

arr=[2,1]

for i in range(2,n+1):

#    print(i)
    
    arr.append(arr[i-2]+arr[i-2+1])
    
print(arr[n])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;
 
int main(){
  int X;
  cin>>X;
  bool flag[1001] = {0};
  flag[1] = 1;
  for(int i(2);i<40;i++){
    int tmp(i);
    while(tmp*i<=1000){
      flag[tmp*i] = 1;
      tmp*=i;
    }
  }
  int ans(0);
  for(int i(1);i<=X;i++){
    if(flag[i]) ans =  i;
  }
  cout << ans << endl;
  return 0;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

int main() {
  ll H,W;
  cin >> H >> W;

  if(H==1 || W==1){
    ANS(1);
    return 0;
  }
  if(H%2==1 && W%2==1){
    ANS(H * W / 2 + 1);
  }
  else{
    ANS(H * W / 2);
  }
  return 0;
}


Measured memory_bytes: 256