akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;

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;
}

const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  
  ll n,m;
  ci(n>>m);
  vll A(m);
  FOR(i,0,m){
    ci(A[i])
  }
  vll dp(1001000);
  ll now=0;
  ll ans=1;
  dp[0]=1;
  
  if(now<m&&A[now]==1){
    dp[1]=0;
    now++;
  }
  else{
  dp[1]=1;
  }
  
  FOR(i,2,n+1){
    if(now<m&&A[now]==i){
      now++;
      dp[i]=0;
    }
    else{
      dp[i]+=dp[i-1]+dp[i-2];
    }
    
    dp[i]%=1000000007;
  }
  co(dp[n])
}


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

using namespace std;

void mySwap(int &a, int &b, int &count) {
    int t = a; a = b; b = t;
    count++;
    return;
}

int main() {
    int a[101];
    int minj, n;
    int count = 0;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];

    for(int i = 0; i < n; i++) {
        minj = i;
        for(int j = i; j < n; j++) {
            if(a[j] < a[minj]) minj = j;
        }
        if(i!=minj) mySwap(a[i], a[minj], count);
    }
    for(int i = 0; i < n; i++) {
        printf("%d", a[i]);
        if(i != n -1) printf(" ");
        else printf("\n");
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3240
S = list(input())

res = 'NA'
bf = (int(S[0])) * 10 + int(S[1])
af = (int(S[2])) * 10 + int(S[3])

if  0 <= bf and  0 < af < 13:
      res = 'YYMM'
      
if  0 < bf < 13 and  0 <= af:
    if res == 'YYMM':
      res = 'AMBIGUOUS'
      
    else:
      res = 'MMYY'
      
print(res)
      




Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <utility>
using namespace std;

int main() {
	string s;
	cin >> s;
	int n;
	cin >> n;
	int ir = 0;
	int ans = 0;
	string r = "";
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (t == 1) {
			ir = (ir + 1) % 2;
			ans++;
			continue;
		}
		int tr;
		cin >> tr;
		string e;
		cin >> e;
		if (tr == 1) {
			if (ir == 0)r += e;
			else s += e;
		}
		if (tr == 2) {
			if (ir == 1)r += e;
			else s += e;
		}
	}
	reverse(r.begin(), r.end());
	if (ans % 2 == 0)cout << r + s;
	else {
		s = r + s;
		reverse(s.begin(), s.end());
		cout << s;
	}
}

Measured memory_bytes: 1312
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      String S  = sc.next();

      if(S.equals("Sunny")){
        System.out.println("Cloudy");
      }
      if(S.equals("Cloudy")){
        System.out.println("Rainy");
      }
      if(S.equals("Rainy")){
        System.out.println("Sunny");
      }
                   }
                 }


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N,L;
  cin>>N>>L;
  
  
  if(L+N-1<=0){
    int sum_1=(L-1)*(N-1);
    for(int i=1;i<N;i++){
      sum_1+=i;
    }
    cout<<sum_1<<endl;
  }
  
  else if(L<=0&&L+N-1>=0){
    int sum_2=(L-1)*N;
    for(int i=1;i<=N;i++){
      sum_2+=i;
    }
    cout<<sum_2<<endl;
  }
  else{
    int sum_3=(L-1)*(N-1);
    for(int i=2;i<=N;i++){
      sum_3+=i;
    }
    cout<<sum_3<<endl;
  }
}

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

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXFIX=2500;
const int MAXWANT=2500;
const int MAXGAP=10000;
const int MOD=1000000007;

int n,nfix,want;
int fix[MAXFIX];

int ways[MAXWANT+1][MAXGAP+1]; // ways[i][j] = ways to put stops in a segment of length j so that everyone can reach the first or last in i steps
int ways1[MAXWANT+1][MAXGAP+1]; // ways1[i][j] = ways to put stops in a segment of length j so that everyone can reach the first in i steps or the last in i-1 steps

int tsum1[MAXGAP+2];
int tsum2[MAXGAP+2];

void run() {
	scanf("%d%d%d",&n,&nfix,&want); REP(i,nfix) scanf("%d",&fix[i]);
	int mxgap=0; REP(i,nfix-1) mxgap=max(mxgap,fix[i+1]-fix[i]);
	REPE(i,MAXWANT) {
		if(i>0) { tsum1[0]=0; REPE(k,MAXGAP) tsum1[k+1]=(tsum1[k]+ways[i-1][k])%MOD; }
		FORE(j,1,MAXGAP) {
			int l=1,r=min(j-1,2*i);
			if(j-(i+1)<=i-1) ++ways1[i][j];
			if(i>0&&l<=r) ways1[i][j]=(ways1[i][j]+tsum1[j-l+1]+MOD-tsum1[j-r])%MOD;
		}
		{ tsum2[0]=0; REPE(k,MAXGAP) tsum2[k+1]=(tsum2[k]+ways1[i][k])%MOD; }
		FORE(j,1,MAXGAP) {
			int l=1,r=min(j-1,2*i);
			if(j-(i+1)<=i) ++ways[i][j];
			if(l<=r) ways[i][j]=(ways[i][j]+tsum2[j-l+1]+MOD-tsum2[j-r])%MOD;
		}
	}
	//REPE(i,want) { printf("%d:",i); FORE(j,1,mxgap) printf(" %d",ways1[i][j]); puts(""); }
	//REPE(i,want) { printf("%d:",i); FORE(j,1,mxgap) printf(" %d",ways[i][j]); puts(""); }
	int ret=1;
	REP(i,nfix-1) ret=(ll)ret*ways1[want-i][fix[i+1]-fix[i]]%MOD;
	printf("%d\n",ret);
}

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


Measured memory_bytes: 195712
N,K = map(int,input().split())
*A, = map(int,input().split())

l = len(bin(K))-2
bK = bin(K)[2:]
Xide = sum(int(sum((a>>i)&1 for a in A)*2<N)<<i for i in range(l))
bXide = bin(Xide)[2:].zfill(l)

def f(x):
    return sum(x^a for a in A)

ans = f(K)
for i in range(l):
    x = int(bK[:i]+"0"+bXide[1+i:],2)
    if x>K:continue
    ans = max(ans,f(x))
print(ans)

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

int main() {
    ll N;
    cin >> N;
    ll dp[N][3] = {};
    for(int i = 0; i<N; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        if(i == 0) {
            dp[i][0] = a;
            dp[i][1] = b;
            dp[i][2] = c;
        }
        else {
            dp[i][0] = a + max(dp[i-  1][1], dp[i - 1][2]);
            dp[i][1] = b + max(dp[i - 1][0], dp[i - 1][2]);
            dp[i][2] = c + max(dp[i - 1][0], dp[i - 1][1]);
        }
    }
    cout << max(dp[N - 1][0], max(dp[N - 1][1], dp[N - 1][2]));
}

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

int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 0; i < s.length()-1; i++) if(s[i] != s[i+1]) cnt++;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
A = input() + "e"
B = input() + "e"
C = input() + "e"
s = "a"
while True:
    if s == "a":
        s = A[0]
        A = A[1:]
    elif s == "b":
        s = B[0]
        B = B[1:]
    elif s == "c":
        s = C[0]
        C = C[1:]
    if A == "":
        print("A")
        break
    if B == "":
        print("B")
        break
    if C == "":
        print("C")
        break

Measured memory_bytes: 3064
from itertools import product

h,w,k = map(int, input().split())
c = [list(input()) for i in range(h)]

ans = 0

for row_bit in product(range(2), repeat=h):
  for col_bit in product(range(2), repeat=w):
    cnt = 0
    for row in range(h):
      for col in range(w):
        if c[row][col] == '#' and (row_bit[row] and col_bit[col]):
          cnt += 1
    if cnt == k:
      ans += 1
    
print(ans)

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

constexpr int INF = (1LL << 31) - 1;

//template <typename T>
class SegmentTree {
private:
  int n;
  int init;
  vector<int> seg;

  int size (int N) {
    int ret;
    for (ret = 1; ret < N; ret <<= 1);
    return ret;
  }

  int query(int a, int b, int k, int l, int r) {
    if (r <= a or b <= l) return init; // maxver
    if (a <= l and r <= b) return seg[k];

    int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return min(vl, vr);
  }

public:
  SegmentTree (int N, int i = 0) : n(size(N)), seg(size(N) * 2, i), init(i) {}

  void update (int k, int val) {
    k += n - 1;
    seg[k] = val;
    while (k > 0) {
      k = (k - 1) / 2;
      // ???????????´
      seg[k] = min(seg[k * 2 + 1], seg[k * 2 + 2]);
    }
  }

  // [l, r) ???????????§???????????¨?????¨???!!! ... [l, r]??????find(l, r + 1)
  int find(int l, int r) {
    return query(l, r, 0, 0, n);
  }
};


int main() {
    int n, q, command, x, y;

    cin >> n >> q;

    SegmentTree st(n, INF);

    for (int i = 0; i < q; ++i) {
        cin >> command >> x >> y;
        if (command == 0) {
            st.update(x, y);
        }
        else {
            cout << st.find(x, y + 1) << endl;
        }
    }
}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
    int main(void){
        int a, b, c;
            cin >> a >> b;
                if(1 <= b && b <= 9){
                    c = 10*a + b;
                }else if(10 <= b && b <= 99){
                    c = 100*a + b;
                }else{
                    c = 1000*a + b;
                }
                    for(int i = 4; i < 317; i++){
                        if(i*i == c){
                            cout << "Yes" << endl;
                                return 0;
                        }
                    }
                        cout << "No" << endl;
    return 0;}


Measured memory_bytes: 256
import sys

def main():
    A = [int(input()) for i in range(3)]
    X = int(input())
    print(counter(A, X))

def counter(A, X):
    count = 0
    for a in range(A[0] + 1):
        for b in range(A[1] + 1):
            for c in range(A[2] + 1):
                total = 500*a + 100*b + 50*c
                if total == X: count += 1
    return count

if __name__ == '__main__':
    main()


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

int main() {
    bool tramp[4][13];
    for(int a = 0; a < 4; ++a) {
        for(int b = 0; b < 13; ++b) {
            tramp[a][b] = false;
        }
    }
    
    int N;

    cin >> N;

    for(int c = 0; c < N; ++c) {
        char kind;
        int number;
        cin >> kind >> number;
        switch(kind) {
            case 'S': tramp[0][number-1] = true;
             break;
            case 'H': tramp[1][number-1] = true;
             break;
            case 'C': tramp[2][number-1] = true;
             break;
            case 'D': tramp[3][number-1] = true;
             break;
        }
    }

    for(int f = 0; f < 4; ++f) {
        for(int g = 0; g < 13; ++ g) {
            if(tramp[f][g] == false) {
                char kind2;
                if(f == 0) {
                    kind2 = 'S';
                }else if(f == 1) {
                    kind2 = 'H';
                }else if(f == 2) {
                    kind2 = 'C';
                }else if(f == 3) {
                    kind2 = 'D';
                }
                cout << kind2 << " " << g+1 << endl;
            }
        }
    }
}

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

int x, y;

int main() {
	cin>>x>>y;
	if (x==1||x==3||x==5||x==7||x==8||x==10||x==12) {
		if (y==1||y==3||y==5||y==7||y==8||y==10||y==12) {
			cout<<"Yes"<<endl;
		}
		else {
			cout<<"No"<<endl;
		}
	}
	if (x==4||x==6||x==9||x==11) {
		if (y==4||y==6||y==9||y==11) {
			cout<<"Yes"<<endl;
		}
		else {
			cout<<"No"<<endl;
		}
	}
	if (x==2) {
		if (y==2) {
			cout<<"Yes"<<endl;
		}
		else {
			cout<<"No"<<endl;
		}
	}
}


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

int main(){
    string s, t;
    cin >> s;
    cin >> t;
    int ans = 0;
    rep(i,3){
        if(s[i] == t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

//const int mod = 1000000007;
//#define long long uint32_t

int  main()
{  
	ios_base::sync_with_stdio(false);

    string str;
    cin>>str;
    if(str.back()=='s') str+="es";
    else str+="s";
    cout<<str;

   
    return 0;
}


Measured memory_bytes: 3608
import sys
sys.setrecursionlimit(10**4)
n, _, y = map(int, input().split())
a = list(map(int, input().split()))
a = [y] + a

memo = [[-1 for i in range(n + 1)] for j in range(2)]
def sol(i, turn):
    # ovaj drugi ima a[i]
    if memo[turn][i] != -1:
        return memo[turn][i]
    best = abs(a[i] - a[n])
    for j in range(i + 1, n):
        pot = sol(j, 1 - turn)
        if turn == 0:
            best = max(best, pot)
        else:
            best = min(best, pot)
    memo[turn][i] = best
    return best

print(sol(0, 0))

Measured memory_bytes: 4852
card = []
a,b,c = map(int,input().split())
card.append(a)
card.append(b)
card.append(c)
a,b,c = map(int,input().split())
card.append(a)
card.append(b)
card.append(c)
a,b,c = map(int,input().split())
card.append(a)
card.append(b)
card.append(c)
N = int(input())
for i in range(N):
    b = int(input())
    try:
        card[card.index(b)] = -1
    except:
        continue
if card[0] == card[1] == card[2] or card[3] == card[4] == card[5] or card[6] == card[7] == card[8] or card[0] == card[3] == card[6] or card[1] == card[4] == card[7] or card[2] == card[5] == card[8] or card[0] == card[4] == card[8] or card[2] == card[4] == card[6]:
    print("Yes")
else:
    print('No')


Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static long value(int x,int j) {
		if (j==0||j==4) return x;
		if (j==2) return (x+1)%2;
		if (x==0) return 2;
		return x%2;
	}
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int L=in.nextInt();
		int[] A=new int[L+1];
		for (int i=1;i<=L;++i)
			A[i]=in.nextInt();
		long[][] dp=new long[L+1][5];
		for (int i=1;i<=L;++i)
			for (int j=0;j<5;++j)
				dp[i][j]=Long.MAX_VALUE;
		for (int i=0;i<L;++i)
			for (int j=0;j<5;++j) if (dp[i][j]!=Long.MAX_VALUE) {
				if (j+1<5) dp[i][j+1]=Math.min(dp[i][j+1],dp[i][j]);
				dp[i+1][j]=Math.min(dp[i+1][j],dp[i][j]+value(A[i+1],j));
			}
		long res=Long.MAX_VALUE;
		for (int i=0;i<5;++i) res=Math.min(res,dp[L][i]);
		System.out.println(res);
	}
}

Measured memory_bytes: 99900
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim/0523?year=2008

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    
    while (cin >> n, n) {
        set<int> taro;
        for (int i = 0; i < n; ++i) {
            int a;
            cin >> a;
            taro.insert(a);
        }

        set<int> hana;
        for (int i = 1; i <= 2 * n; ++i) {
            if (!taro.count(i)) hana.insert(i);
        }

        int tmp = 0;//場に出ているカード
        while (!taro.empty() && !hana.empty()) {
            //太郎のターン
            auto idxT = taro.upper_bound(tmp);
            if (idxT == taro.end()) {
                tmp = 0;
            } else {
                tmp = *idxT;
                taro.erase(idxT);
                if (taro.empty()) break;
            }

            //花子のターン
            auto idxH = hana.upper_bound(tmp);
            if (idxH == hana.end()) {
                tmp = 0;
            } else {
                tmp = *idxH;
                hana.erase(idxH);
                if (hana.empty()) break;
            }
        }

        cout << hana.size() << endl;
        cout << taro.size() << endl;
    }
    return 0;
}

/*
 * サンプル1の場合
 * 太郎：{1,6,7,9,10}
 * 花子：{2,3,4,5,8}
 * 太郎1->花子2->太郎6->花子8->太郎9->太郎7->太郎10
 * で終了。
 * 太郎の得点は3（花子は3,4,5が余る）
 * 花子の得点は0
 * 最大のカードを持っているからといって勝てるとは限らない。
 * 太郎：{1,3,5,7,9}
 * 花子：{2,4,6,8,10}
 * のとき5ターン目で太郎が勝つ。
 *
 */


Measured memory_bytes: 3088
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = n - 1; i >= 0; i--)
    {
        cout << a[i];
        if (i != 0)
            cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 3072
//Author- VMAX


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double 
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define re return 0;
// *#######################################################################################*

/*
bool isp(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return false;
        }
        
    }
}
  */
  ll powerm(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;    
  
    x = x % p; 
   
    if (x == 0) return 0;
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
   
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}
  long long lcm(long long a, long long b){//最小公倍数を求める
   return a * b / gcd(a, b);
}
/*
ll po(ll z,ll z1)
{
    ll rer=0;
    rer=     ((z*(z-1))/2+(z1*(z1-1))/2);
    return rer;

}
*/

//ll ss[2][(1<<22)+10];
       int main()
       {
       
        fast
        
         ll n;
         cin>>n;
         map<string,ll>m;
         ll i;
         string s,s1,s2,s3,s4;
         s="AC";
         s1="WA";
         s2="TLE";
         s3="RE";
         f(i,n)
         {
             cin>>s4;
             m[s4]++;
         }
        o1("AC")o1("x")o1(m[s])
       en
        o1("WA")o1("x")o1(m[s1])
       en
      o1("TLE")o1("x")o1(m[s2])
       en
         o1("RE")o1("x")o1(m[s3])
       en







          re
}


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

int main(){
  int n;
  cin >> n;
  int a=0,b=0,c=0,d=0;
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    if(s.at(0)=='A'){
      a++;
    }
    else if(s.at(0)=='W'){
      b++;
    }
    else if(s.at(0)=='T'){
      c++;
    }
    else if(s.at(0)=='R'){
      d++;
    }
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;
  return 0;
}


Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.CodeFes2017QA
{
    class fLIP
    {
        public static void Main()
        {
            var nmk = ReadLine().Trim().Split(' ').Select(_ => int.Parse(_)).ToArray();
            var n = nmk[0]; var m = nmk[1]; var k = nmk[2];
            string res = "No";
            for (var i = 0; i <= n; ++i)
                for (var j = 0; j <= m; ++j) {
                    if (i * j + (n - i) * (m - j) == k) res = "Yes";
                }
            WriteLine(res);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

int memo[100010];

const int MAX_PRIME = 1000010;
bool isPrime[MAX_PRIME];

void calcPrimes() {
	for (int i = 2; i < MAX_PRIME; i++) isPrime[i] = true;
	for (int i = 2; i < MAX_PRIME; i++) {
		if (!isPrime[i]) continue;
		for (int j = i * i; j < MAX_PRIME; j += i) isPrime[j] = false;
	}
}

signed main() {
	calcPrimes();

	int Q;
	cin >> Q;

	REP(i, 2, 100005) {
		memo[i] = isPrime[i] && isPrime[(i + 1) / 2];
	}

	rep(i, 100000) memo[i + 1] += memo[i];

	rep(_, Q) {
		int l, r;
		cin >> l >> r;

		cout << memo[r] - memo[l - 1] << endl;
	}
}


Measured memory_bytes: 2432
def resolve():
    (H, W) = list(map(int, input().split(" ")))
    S = [list(input()) for i in range(H)]
    L = [[0 for _ in range(W)] for _ in range(H)]
    R = [[0 for _ in range(W)] for _ in range(H)]
    U = [[0 for _ in range(W)] for _ in range(H)]
    D = [[0 for _ in range(W)] for _ in range(H)]
    for i in range(H):
        for j in range(W):
            if S[i][j] == "#":
                continue
            L[i][j] = L[i][j-1]+1 if j > 0 else 1
    for i in range(H-1, -1, -1):
        for j in range(W-1, -1 ,-1):
            if S[i][j] == "#":
                continue
            R[i][j] = R[i][j+1]+1 if j < W-1 else 1
    for i in range(H-1, -1, -1):
        for j in range(W):
            if S[i][j] == "#":
                continue
            D[i][j] = D[i+1][j]+1 if i < H-1 else 1
    for i in range(H):
        for j in range(W-1, -1 ,-1):
            if S[i][j] == "#":
                continue
            U[i][j] = U[i-1][j]+1 if i > 0 else 1
    ans = 0
    for i in range(H):
        for j in range(W):
            ans = max(ans, L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)

    print(ans)

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 312328
/*
_____________________$$o____________________o$$$$$o__
___________________o$o_$$o____oo$$$$$$$oo______o$$$$o
______________$o________o$$$$$o___oo$$$$$$$o______$$$
______________$$$ooo________o$$$$o______o$$$$$o_____o
____________oo_____oo_____oo___o$$$$$______$$$$$$____
_________ooooo___$$o_$___oooooo___o$$$$o__o__o$$$$___
_______ooo__ooo$$$$o_$$ooooooooooo__o$$$o__oo_oo$$$o_
______oo_o$$o_$$_o$o_o$o__oooooooooo__o$$$o_oo__o$$$o
____oooooo$$$$o___oo__$$o_ooo_oooooooo__o$$o_ooo_o$$$
___ooooooo__o___oooo__$$ooooo$_oooooooo__o$$__ooo_$$$
_$$o_ooooo___o$$$$$o__o$o__o_$o__oooooooo_o$$o_oo__$$
_$$$o_ooo_________o$$_$$o____$$o_ooooooooo_$$$o_oo_$$
__oo________o$$o____o_$$o____o$ooooooooooo_o$$o_oo_o$
___o$$$$$$$$$$$$$o___$$$o____$$o_oooooooooo_$$$o_o_o$
________o__oo$$$$$o__$$$o____$$o____oooooo__$$$o_o_o$
_________$$$$$$$$$o__$$_____$$$o___________$$$oooooo_
__________o$$$$$$$o_________$$___________o$o___oooooo
___________o$$$$o_______________ooooo__oo$__ooo__oooo
________________________________ooo_$$oo___oooo$o____
________________________________oooo_$$$$$o___oo$$$o_
________________________________ooooo_o$$$$$o_____$$$
________________________________oooooo_o$$$$$$ooo___o
________________________________ooooooo__o$$$$$o_____
*/
#include<bits/stdc++.h>
#define ll long long
#define ft first
#define sd second
#define HageBaIO_KPOCCbI int LOL;scanf("%d", &LOL);for(int i = 0; i < LOL; i++)
using namespace std;
//BY |3 |<
const int dx[] = {1, 0, -1,  0};
const int dy[] = {0, 1,  0, -1};
//Where I am?
const ll N = 1e5 + 5;
const ll MOD = (1e9 + 7);
const ll MOD1 = 998244353;
const double PI = 3.14159265;
const int INF32 = 2e9;
const ll INF64 = 2e18;
//Don`t believe!!!//
int n, m, arr[N], sum, x;
void KEK(){
	scanf("%d%d", &n, &m);
	for(int i = 0; i < n; i++){
		scanf("%d", &arr[i]);
		sum += arr[i];
	}
	int i = 0;
	x = (sum / (m << 2)) + (sum % (m << 2) > 0);
	while(i < n && m){
		if(arr[i] >= x)m--;
		i++;
	}
	if(m)printf("No");
	else printf("Yes");
}
int main(){
	//HageBaIO_KPOCCbI
	KEK();
}
//TAUMAC, 9| BbIWEJI 3A TObOU!!!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 



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

typedef struct _DICE DICE;
struct _DICE{
    int a[6];
    char b[101];
};


int main(int argc, const char * argv[]) {
    DICE Dice;
    int i,j,length;
    int a0,a1,a2,a3,a4,a5;
    
    for(i=0;i<6;i++){
        scanf("%d",&Dice.a[i]);
    }
    
    scanf("%s",Dice.b);
    length=(int)strlen(Dice.b);
    
    for(j=0;j<length;j++){
        if(Dice.b[j]=='N'){
            a0=Dice.a[0];
            a1=Dice.a[1];
            a4=Dice.a[4];
            a5=Dice.a[5];
            
            Dice.a[0]=a1;
            Dice.a[1]=a5;
            Dice.a[4]=a0;
            Dice.a[5]=a4;
            
        }else if(Dice.b[j]=='E'){
            a0=Dice.a[0];
            a2=Dice.a[2];
            a3=Dice.a[3];
            a5=Dice.a[5];
            
            Dice.a[0]=a3;
            Dice.a[2]=a0;
            Dice.a[3]=a5;
            Dice.a[5]=a2;
            
        }else if(Dice.b[j]=='S'){
            a0=Dice.a[0];
            a1=Dice.a[1];
            a4=Dice.a[4];
            a5=Dice.a[5];
            
            Dice.a[0]=a4;
            Dice.a[1]=a0;
            Dice.a[4]=a5;
            Dice.a[5]=a1;
            
        }else if(Dice.b[j]=='W'){
            a0=Dice.a[0];
            a2=Dice.a[2];
            a3=Dice.a[3];
            a5=Dice.a[5];
            
            Dice.a[0]=a2;
            Dice.a[2]=a5;
            Dice.a[3]=a0;
            Dice.a[5]=a3;
        }
    }
    printf("%d\n",Dice.a[0]);
    
    return 0;
}



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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int n;
    cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];

    a.push_back(0);
    sort(all(a));
    a.push_back(0);

    vc<bool> tf(a[n]+1,true);
    int ans=0;

    repa(i,1,n+1){
        while(a[i]==a[i+1])i++;
        if(tf[a[i]] && a[i-1]!=a[i])ans++;
        for(int j=1;a[i]*j<=a[n];j++){
            tf[a[i]*j]=false;
        }
    }

    cout<<ans<<"\n";

    return 0;

}

Measured memory_bytes: 4844
n =int(input())
a = list(int(i) for i in input().split())
b = list(int(i) for i in input().split())
ans = 'Yes'
ct =0
ct2 = 0
kaisuu = 0
if sum(a) > sum(b) :
  ans = 'No'
elif sum(a) == sum(b) and a != b:
  ans ='No'
else:
  kaisuu = sum(b)-sum(a)
  for i in range(n):
   if a[i] >= b[i]:
    ct += a[i]-b[i]
   else:
    ct2 += (b[i]-a[i]+1)//2
if ct <= kaisuu and ct2 <= kaisuu:
  pass
else:
  ans = 'No'
  
  
print(ans)

Measured memory_bytes: 4596
#include <stdio.h>

#define NO_DATA -1
#define MAX_COUNT 200
int main(int argc, const char * argv[]) {
    // insert code here...
    int result[MAX_COUNT];
    int data[MAX_COUNT][2];
    int scanResult;
    
    for (int i = 0; i < MAX_COUNT; i++ ) {
        result[i] = NO_DATA;
    }
    
    scanResult = scanf("%d %d", &data[0][0], &data[0][1]);
    int digit=0;
    int number;
    int count=0;
    while (scanResult!=EOF) {
        number=data[count][0]+data[count][1];
        while(number!=0){
           number = number / 10;
           digit++;
        }
        result[count]=digit;
        digit=0;
        count++;
        scanResult = scanf("%d %d", &data[count][0], &data[count][1]);
    }
    
    for (int i=0;i<count;i++) {
        printf("%d\n", result[i]);
    }
    return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
const int INF = 10000100;
int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int a[12][12];
    int c[12];
    rep(i, n) {
        cin >> c[i];
        rep(j, m)  cin >> a[i][j];
    }
    int ans = INF;
    rep(s, 1<<n) {
        int cost = 0;
        vector<int> d(m, 0);
        rep(i, n) {
            if (s>>i & 1) {
                cost += c[i];
                rep(j, m) d[j] += a[i][j];
            }
        }
        bool ok = true;
        rep(j, m)  if (d[j] < x)  ok = false;
        if (ok)  ans = min(ans, cost);
    }
    if (ans == INF)  cout << -1 << endl;
    else  cout << ans << endl;
    return 0;    
}

Measured memory_bytes: 3552
N=int(input())
CSF=[list(map(int,input().split())) for _ in range(1,N)]
for i,csf in enumerate(CSF):
    c,s,f=csf[0],csf[1],csf[2]
    ans=c+s
    for j in range(i+1,N-1):
        csf_=CSF[j]
        c_,s_,f_=csf_[0],csf_[1],csf_[2]
        if ans<s_:
            ans=s_
        elif ans%f_!=0:
            ans=ans+f_-ans%f_
        ans+=c_
    print(ans)
print(0)

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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  
  int a = A * X + B * Y;
  int b = 2 * C * max(X, Y);
  int c;
  if (X > Y) {
    c = 2 * C * Y + A * (X - Y);
  } else {
    c = 2 * C * X + B * (Y - X);
  }
  int ans = min({a, b, c});
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a) \
    REP(i, (a).size()) { cout << (a[i]) << (i == (a).size() - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
    ll K, N;
    cin >> K >> N;
    vi A(N);
    REP(i, N)
    {
        cin >> A[i];
    }

    ll x = (A[0] + K) - A[N - 1];
    REP(i, N - 1)
    {
        x += A[i + 1] - A[i];
    }
    ll ans = x - ((A[0] + K) - A[N - 1]);
    REP(i, N - 1)
    {
        ans = min(ans, x - (A[i + 1] - A[i]));
    }
    OUT(ans);
}
#pragma endregion template

Measured memory_bytes: 1792
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	ans := n
	m := make([]int, n)
	for i, _ := range m{
		fmt.Scan(&m[i])
	}
	
	sort.Sort(sort.IntSlice(m))
	
	for j := 0; j < n; j++ {
		x -= m[j]
	}
	
	ans += int(x/m[0])
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,s1,s2,s3;
	cin>>s;
	int k=s.size(),k1=(k-1)/2,k2=(k+3)/2;
	s2=s.substr(0,k1);
	s3=s.substr(k2-1);
	s1=s;
	reverse(s.begin(),s.end());
	if(s==s1&&s2==s3)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = [list(map(lambda x: int(x)-1, input().split())) for _ in range(n)]
N = n*(n-1)//2
index = {}
ind = 0
from collections import defaultdict
ns = defaultdict(list)
for i in range(n):
    for j in range(i+1,n):
        index[i,j] = ind
        index[j,i] = ind
        ind += 1
for i in range(n):
    for j in range(n-2):
        u = index[i,a[i][j]]
        v = index[i,a[i][j+1]]
        ns[u].append(v)
### サイクル検出 cycle detection
seen = [False] * N
done = [False] * N
vals = [None] * N
def dfs(u):
    s = [u]
    while s:
        u = s.pop()
        if u>=0:
            seen[u] = True
            s.append(~u)
            for v in ns[u]:
                if done[v]:
                    continue
                elif not seen[v]:
                    s.append(v)
                else:
                    # 閉路発見
                    return True
        else:
            u = ~u
            done[u] = True
            # ここに帰りがけ処理を書く
            val = 0
            for v in ns[u]:
                val = max(val, vals[v]+1)
            vals[u] = val
    return False

ans = -float("inf")
for u in range(N):
    if seen[u]:
        continue
    pos = dfs(u)
    if pos:
        print(-1)
        break
else:
    print(max(vals)+1)

Measured memory_bytes: 287492
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nx = readln.split.to!(long[]);
    auto N = nx[0];
    auto x = nx[1];
    auto as = readln.split.to!(long[]);
    long[] bs;
    foreach (a; as) bs ~= a;

    long min_s = long.max;
    foreach (k; 0..N) {
        long s;
        long[] cs;
        if (k == 0) {
            cs = bs;
        } else {
            cs.length = N;
            foreach (i; 0..N) {
                cs[(i+1)%N] = min(bs[(i+1)%N], bs[i]);
            }
        }
        bs = cs;
        foreach (i; 0..N) {
            s += bs[i];
        }
        min_s = min(min_s, s + k*x);
    }
    writeln(min_s);
}

Measured memory_bytes: 4348
#include <stdio.h>

int main (){
    int a = 0;
    int b = 0;

    scanf("%d %d",&a,&b);

    if ( a == b ){
        printf("Draw\n");
    } else if (a == 1){
        printf("Alice\n");
    } else if (b == 1){
        printf("Bob\n");
    } else if (a < b) {
        printf("Bob\n");
    } else {
        printf("Alice\n");
    }


    return 0;
}

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

int main()
{
    long long n;
    std::vector<long long> tr(6);
    std::cin>>n;
    for(int i=0;i<5;i++)std::cin>>tr[i];
    long long min=100000000000000000;
    for(int i=0;i<5;i++)min = std::min(tr[i],min);
    long long time;
    time = (n+min-1) / min + 4;
    std::cout<<time<<std::endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int x1,x2;

    cin >> n;
    x1 = n * 100 / 108;
    x2 = (n + 1) * 100 / 108;
    if((n+1)*100%108==0){
        if (n * 100 % 108 == 0){
            cout << x1 << endl;
        }
        else if (x1 < x2 - 1){
            cout << x1 + 1 << endl;
        }else{
            cout << ":(" << endl;
        }
    }
    else if (n * 100 % 108 == 0)
    {
        cout << x1 << endl;
    }else{
        if(x1 != x2){
            cout << x2 << endl;
        }else{
            cout << ":(" << endl;
        }
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, K;
vector<int> H;

void read() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int h;
    cin >> h;
    H.push_back(h);
  }
}

int main() {
  read();

  vector<int> DP;
  DP.push_back(0);

  for (int i = 1; i < N; i++) {
    int cost = INT_MAX;
    for (int k = 1; k <= K; k++) {
      if (i - k >= 0) {
        cost = min(cost, DP.at(i - k) + abs(H.at(i) - H.at(i - k)));
      }
    }
    DP.push_back(cost);
  }

  cout << DP.back() << endl;
}


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

#define deb(x) cout << #x << " " << x << "\n";
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)
#define endl "\n"
#define ll long long
#define vi vector<int>

// memset(arr, value, size);
void A() {
	string s;
	cin >> s;
	cout << s << (s[s.length() - 1] - 's' ? "s" : "es");
}

void B() {
	int i, t, a, b, count = 0;

	cin >> t;
	fo(i , t) {
		cin >> a >> b;
		if (a == b) count++;
		else count = 0;
		if ( count == 3) {
			cout << "Yes";
			return;
		}
	}
	cout << "No";
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);

	B();

	return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N,M;
    cin >> N >> M;
    vector< pair<int,int> > P(M);
    for ( int i = 0; i < M; i++ ) {
        int a,b;
        cin >> a >> b;
        if ( a > b ) { swap(a,b); }
        P[i] = make_pair(a,b);
    }
    sort( P.begin(), P.end() );
    int r = P[0].second;
    int ans = M;
    for ( int i = 1; i < M; i++ ) {

        if ( P[i].first < r ) {
            ans--;
            r = min( r, P[i].second );
        }
        else { r = P[i].second; }

    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

ll mod = 1000000000+7;
#define NMAX 1000010
ll fac[NMAX];
ll inv[NMAX];

ll mod_pow(ll a, ll n, ll mod){
    ll ret = 1;
    while(n > 0){
        if(n & 1) ret = (ret*(a % mod))%mod;
        a = ((a%mod)*(a%mod)) % mod;
        n = n >> 1;
    }
    return ret;
}

ll mod_inv(ll a, ll mod){
    return mod_pow(a, mod-2, mod);
}

void mae_nck(){
    fac[1] = 1;
    inv[1] = 1;
    for(ll i = 2; i < NMAX; i++){
        fac[i] = (fac[i-1] * i)%mod;
        inv[i] = (inv[i-1] * mod_inv(i, mod))%mod;
    }
}

ll mod_nck(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    if(k == 0 || k == n) return 1;
    ll ret = ((fac[n] * inv[k])%mod * inv[n-k])%mod;
    return ret;
}

int main() {
    mae_nck();
    ll s;
    cin >> s;
    ll ans = 0;
    rep(i, 1, s+1) {
        if(i * 3 > s) break;
        ll rem = s - 3 * i;
        ans += mod_nck(rem+i-1, i-1);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19244
open Printf
open Scanf

let () =
        let s = read_line() in
        let alpha = "abcdefghijklmnopqrstuvwxyz" in
        let rec iter i =
                (if (i = (String.length alpha)) then
                        "None"
                else if (String.contains s alpha.[i]) then
                        (iter (i + 1))
                else (String.make 1 alpha.[i])
                ) in
        printf "%s\n" (iter 0)


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;
char a[5000];
ll x,y,z;

int main()
{
     int n,k;
     cin>>n;
     for(int i=0;i<n;i++)
     {
         cin>>a[i];
         if(a[i]=='R')
         {
             x++;
         }
         else if(a[i]=='G')
         {
             y++;
         }
         else
         {
             z++;
         }
     }
     ll ans=x*y*z;
     for(int i=0;i*2<n;i++)
     {
         for(int j=0;j+2*i<n;j++)
         {
             if(a[j]!=a[j+i]&&a[j+i]!=a[j+2*i]&&a[j]!=a[j+2*i])
             {
                 ans--;
             }
         }
     }
     cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3552
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int a[400][400];
int now[400];
int cnt[400];
int used[400];

int main()
{
  int i,j,n,m,ma,bi,ans;
  scanf("%d%d",&n,&m);
  for (i=0;i<n;i++)
    for (j=0;j<m;j++)
    {
      scanf("%d",&a[i][j]);
      a[i][j]--;
    }
  memset(cnt,0,sizeof(cnt));
  for (i=0;i<n;i++)
    cnt[a[i][0]]++;
  memset(used,0,sizeof(used));
  memset(now,0,sizeof(now));
  ans=n;
  while (1)
  {
    ma=0;
    for (i=0;i<m;i++)
      if (cnt[i]>ma)
      {
        ma=cnt[i];
        bi=i;
      }
    if (ma==0) break;
    if (ma<ans) ans=ma;
    used[bi]=1;
    for (i=0;i<n;i++)
    {
      while ((now[i]<m)&&(used[a[i][now[i]]]==1))
      {
        cnt[a[i][now[i]]]--;
        now[i]++;
        if (now[i]<m)
          cnt[a[i][now[i]]]++;
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 768
n,k = map(int,input().split())
w = []

for loop in range(n):
    w.append(int(input()))

left = max(w)
right = 100000 * 10000
mid = (left+right)//2
ans = right

def check(P):
    tmp_sum = 0
    cnt = 1
    for loop in range(n):
        if tmp_sum + w[loop] <= P:
            tmp_sum += w[loop]
        else:
            tmp_sum = w[loop]
            cnt += 1
            if cnt > k:
                return False
    return True

while left <= right:
    if check(mid):
        ans = mid
        right = mid - 1
    else:
        left = mid + 1
    mid = (left+right)//2

print(ans)


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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define MOD 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
int a,b;
cin>>a>>b;
if(a>12) cout<<b<<endl;
else if(6>a) cout<<0<<endl;
else{
    cout<<b/2<<endl;

}
return 0;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  vector<P> v[n],g;
  for(int i=0; i<m; i++) {
    int x,y,z;
    cin >> x >> y >> z;
    x--,y--;
    v[x].push_back(P(y,z));
    if(y==n-1) g.push_back(P(x,z));
  }
  int d[n];
  fill(d,d+n,1<<29);
  d[0]=0;
  priority_queue<P,vector<P>,greater<P> > que;
  que.push(P(0,0));
  while(!que.empty()) {
    P p=que.top();que.pop();
    int x=p.second,cc=p.first;
    if(d[x]<cc) continue;
    for(int i=0; i<v[x].size(); i++) {
      int y=v[x][i].first,c=v[x][i].second;
      if(d[y]>c&&d[x]<=c) {
        d[y]=c;
        que.push(P(c,y));
      }
    }
  }
  int ans=-1;
  for(int i=0; i<g.size(); i++) {
    int x=g[i].first,c=g[i].second;
    if(d[x]<=c) ans=max(ans,c);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> X(n), Y(n), P(n);
  rep(i, n) cin >> X[i] >> Y[i] >> P[i];
  vector<vector<ll>> xmin(1<<n, vector<ll>(n)), ymin(1<<n, vector<ll>(n));
  rep(i, 1<<n) {
    rep(j, n) {
      xmin[i][j] = abs(X[j]);
      ymin[i][j] = abs(Y[j]);
    }
    rep(k, n) {
      if((i>>k)&1) {
        rep(j, n) {
          xmin[i][j] = min(abs(X[j]-X[k]), xmin[i][j]);
          ymin[i][j] = min(abs(Y[j]-Y[k]), ymin[i][j]);
        }
      }
    }
  }
  vector<ll> ans(n+1, longinf);
  auto dfs = [&](auto dfs, int i, ll xb, ll yb) -> void {
    if(i == n) {
      ll cost = 0;
      rep(j, n) cost += P[j] * min(xmin[xb][j], ymin[yb][j]);
      int cnt = __builtin_popcount(xb) + __builtin_popcount(yb);
      if(cnt > n) return;
      ans[cnt] = min(cost, ans[cnt]);
      return;
    }
    dfs(dfs, i+1, xb, yb);
    dfs(dfs, i+1, xb|(1<<i), yb);
    dfs(dfs, i+1, xb, yb|(1<<i));
  };
  dfs(dfs, 0, 0, 0);

  /* dummy */
  vector<ll> pw(n+1);
  pw[0] = 1;
  rep(i, n) pw[i+1] = pw[i] * 3;
  rep(i, pw[n]) {
    ll x = 0, y = 0;
    rep(j, n) {
      if(i/pw[j]%3 == 1) {
        x |= 1<<j;
      } else if(i/pw[j]%3 == 2) {
        y |= 1<<j;
      }
    }
    ll cur = 0;
    rep(j, n) cur += P[j] * min(xmin[x][j], ymin[y][j]);
    int cnt = __builtin_popcount(x) + __builtin_popcount(y);
    if(cnt > n) continue;
    (cur < ans[cnt]);
  }
  /* dummy */

  rep(i, n+1) cout << ans[i] << "\n";
  return 0;
}


Measured memory_bytes: 12960
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;
// scanf
#pragma warning(disable: 4996)
// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// vector 要素の総和算出
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// vector 最大値( return ite )
#define _max_element(v) max_element(v.begin(),v.end())
// vector 最大値が格納されている要素値
#define _max_element_number(v) distance(v.begin(),max_element(v.begin(),v.end()))
// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値
#define _ceil(x) ceil(x)
// 指定された要素以上の値が現れる最初の位置のイテレータを取得する
#define _lower_bound(v,min) lower_bound(v.begin(), v.end(), min)
// 指定された要素より大きい値が現れる最初の位置のイテレータを取得する
#define _upper_bound(v,min) upper_bound(v.begin(), v.end(), min)

// 順列 n個の数が与えられる
// 0,1,2,...,n-1
// 全ての並べ方を1行ごとに出力する
// ex 0 1 2 / 0 2 1 / 1 0 2 / 1 2 0 / 2 0 1 / 2 1 0
#define _next_permutation(v) do {   \
	for (auto num : v) {            \
		printf("%d ", num);         \
	}                               \
	printf("\n");                   \
} while (next_permutation(v.begin(), v.end()))

// 絶対値
static int32_t _abs(const int32_t x) { return  (x > 0 ? x : -x); }

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

	vector<uint32_t> v(n-1);

	uint32_t last_v = (uint32_t)1e5;
	uint32_t result = 0;

	for (uint32_t i = 0; i < n-1; i++) {
		cin >> v[i];

		if (last_v <= v[i]) {
			result += last_v;
		}
		else {
			result += v[i];

		}
		last_v = v[i];
	}

	result += last_v;
	printf("%d\n", result);

	return 0;
}


Measured memory_bytes: 256