akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
int main(void) {
	char S[200];
	int l, i, c , f = 0;
	scanf("%s", S);
	l = strlen(S) - 2;
	for (i = 0; i < 100; i++) {
		c = 0;
		while (c < (l / 2)) {
			if (S[c] != S[c + (l / 2)]) break;
			c++;
			if (c == (l / 2)) f = 1;
		}
		if (f == 1) break;
		l -= 2;
		if (l < 0) break;
	}
	printf("%d\n", l);
	return 0;
}

Measured memory_bytes: 128
//ex2_3
//TKC001

#include <stdio.h>

int main(void){
    //N:1辺の長さ、A:白に塗る数
    int N, A;
    //1辺の長さの入力
    scanf("%d", &N);
    scanf("%d", &A);
    
    printf("%d\n", N*N-A);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
    int t;
    cin >> t;
    while(t--){
        int n, k, ans = 0;
        cin >> n >> k;

        for(int i = 0; i < 7; i++){
            if(k & (1<<i)){
                // 1, odd
                // 1st odd < n
                int x = n;
                if(x%2 == 0)
                    x--;
                ans += x*(1<<i);
            }
            else{
                // 0, even
                // 1st even < n
                int x = n;
                if(x%2 == 1)
                    x--;
                ans += x*(1<<i);
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1e9+7;

ll f(pair<string,ll>&x ,pair<string,ll>&y) 
{
	if(x.first == y.first) 
	{
		return x.second>y.second;
	}
	else 
	{
		return x.first<y.first;
	}
}
 
void solve()
{
	ll n;
	cin>>n;
	vector<ll> a(n);
	for(ll i=0;i<n;i++)
		cin>>a[i];
	ll ans=1;
	ll mx=a[0];
	for(ll i=1;i<n;i++)
	{
		if(max(a[i],mx)==a[i])
		{
			ans++;
			mx=a[i];
		}
	}
	cout<<ans;
	return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int N = 100000;
    vector<PII> odd(N);
    vector<PII> even(N);
    REP(i,N){
        odd[i].first = 0;
        odd[i].second = i+1;
        even[i].first = 0;
        even[i].second = i+1;
    }

    REP(i,n){
        int a;
        cin>>a;
        if((i+1) % 2 == 0)odd[a-1].first++;
        else even[a-1].first++;
    }
    SORT(odd);
    SORT(even);
    int o1_n = odd[N-1].first;
    int o2_n = odd[N-2].first;
    int o1_v = odd[N-1].second;
    int e1_n = even[N-1].first;
    int e2_n = even[N-2].first;
    int e1_v = even[N-1].second;
    if(o1_v == e1_v){
        int a1 = (n/2 - o1_n) + (n/2 - e2_n);
        int a2 = (n/2 - o2_n) + (n/2 - e1_n);
        PUTS(min(a1,a2));
    }else{
        PUTS((n/2 - o1_n) + (n/2 - e1_n));
    }
}

Measured memory_bytes: 1792
N=int(input())
Z=list()
for i in range(N):
  Z.append(list(map(int,input().split())))
S=list()
for i in range(N):
  S.append(sum(Z[i]))
L=list()
for i in range(N):
  L=list(range(N))
  del L[i]
  for j in range(3):
    for k in range(N-1):
      if Z[L[k]][j]==Z[i][j]:
        S[i]=S[i]-Z[i][j]
        break
for i in range(N):
  print(S[i])


Measured memory_bytes: 5652
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<string> ans;
	map<string, int> m;
	int n; cin >> n;
	int cnt = 0;
	rep(i, n) {
		string s;
		cin >> s;
		if (m.find(s) != m.end()) {
			m[s]++;
		}
		else {
			m[s] = 0;
		}
		if (m[s] > cnt) {
			cnt = m[s];
			ans.resize(0);
		}
		if(m[s] >=cnt)
		ans.emplace_back(s);
	}
	sort(all(ans));
	for (auto a : ans) {
		cout << a << endl;
	}
}

Measured memory_bytes: 26352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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 S; cin >> S;
    rep(i,S.size()) cout << 'x';
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int sum=0, n;
    string s;
    cin>>s;
    for(int i=0; i<s.size(); i++)
    {
        sum+=s[i]-'0';
    }
    stringstream ss(s);
    ss >> n;
    if(n%sum==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  vector<Int> h(n);
  for(Int i=0;i<n;i++) cin>>h[i];
  sort(h.begin(),h.end());
  Int ans=h.back()-h.front();
  for(Int i=0;i+k-1<n;i++)
    chmin(ans,h[i+k-1]-h[i]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
fun main(args: Array<String>) {
val dts = nextIntList()


    

    val r = if(dts[1]*dts[2] >= dts[0])
        "Yes"
    else "No"

    println(r)

}

fun next() = readLine()!!
fun nextIntList() = next().split(" ").map{ it.toInt() }

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

int main(){
  
  int n; cin >> n;
  int alice=0;
  int bob=0;
  
  vector<int> a(n);
  
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  for(int i=0; i<n; i++){
    if(i%2 == 0){
      alice += a[i];
    }else{
      bob += a[i];
    }
  }
  cout << alice - bob;
}

Measured memory_bytes: 256
n,a,b,c = map(int, input().split())
l = [int(input()) for _ in range(n)]

def find(i, A, B, C):
	if i == n:
		return abs(A-a) + abs(B-b) + abs(C-c) if min(A, B, C) > 0 else 9999999999999999999999999999
	else:
		return min(
			find(i + 1, A       , B       , C       ),
			find(i + 1, A + l[i], B       , C       ) + (10 if A > 0 else 0),
			find(i + 1, A       , B + l[i], C       ) + (10 if B > 0 else 0),
			find(i + 1, A       , B       , C + l[i]) + (10 if C > 0 else 0),
		)

print(find(0, 0, 0, 0))


Measured memory_bytes: 3064
//code written by a living bruh moment
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.util.Random;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        long n = in.nextLong();
        if(n%2==0 && n>=10){
            long count = 0;
            long current = 10;
            while(n>=current){
                count = count + n/current;
                current*=5;
            }
            out.println(count);
        }
        else{
            out.println(0);
        }
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong()
        {
            return Long.parseLong(next());
        }
        public double nextDouble()
        {
            return Double.parseDouble(next());
        }
        public String nextLine()
        {
            try
            {
                return reader.readLine();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }
        public boolean hasNext()
        {
            String next=null;
            try
            {
                next=reader.readLine();
            }
            catch(Exception e)
            {
            }
            if(next==null)
            {
                return false;
            }
            tokenizer=new StringTokenizer(next);
            return true;
        }
    }
}

Measured memory_bytes: 32996
# -*- coding: utf-8 -*-
import sys


S = input()
if len(S)%2==1:
    print('No')
else:
    for i in range(len(S)//2):
        if S[2*i]=='h' and S[2*i+1]=='i':
            None
        else:
            print('No')
            sys.exit()
    print('Yes')
    sys.exit()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cassert>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

#define forsn(i,s,n) for (int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
#define F first
#define C second

typedef long long int tint;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s; tint k;
	cin >> s >> k;
	
	vector<tint> v;
	int last = 0;
	forn(i, s.size() + 1) {
		if (i == (int)s.size() || (i && s[i] != s[i - 1])) {
			v.push_back(i - last);
			last = i;
		}
	}
	
	tint res = 0;
	if (v.size() == 1) {
		res = (s.size() * k) / 2;
	} else if (s[0] != s[s.size() - 1]) {
		forn(i, v.size()) res += v[i] / 2;
		res *= k;
	} else {
		forsn(i, 1, v.size() - 1) res += (v[i] / 2);
		res *= k;
		
		res += v[0] / 2;
		res += v.back() / 2;
		
		res += (k - 1) * ((v[0] + v.back()) / 2);
	}
	
	cout << res << endl;
}


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

int vs[110];
const int cs[] = {400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 10000};
int hist[100];

int main(void) {
  int n;
  cin >> n;
  REP(i, n) {
    cin >> vs[i];
    REP(j, 9) {
      if(vs[i] < cs[j]) {
        hist[j]++;
        break;
      }
    }
  }

  int common = 0;
  REP(i, 8) {
    if(hist[i]) {
      common++;
    }
  }
  int mini = common == 0 ? 1 : common;
  int maxi = common + hist[8];
  printf("%d %d\n", mini, maxi);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  int n;
  string news;
  string o;
  int ans=0;
  cin>>n>>news;
  for(int i=0;i<n;i++){
    bool check=true;
    cin>>o;
    for(int j=0;j<o.size()&&check;j++){
      if(o[j]==news[0]){
	for(int k=1;k<o.size()-j-1;k++){
	  int a=1;
	  for(int l=j+k;l<o.size();l+=k){
	    if(o[l]==news[a]){
	      a++;
	    }
	    else{
	      break;
	    }
	  }
	  if(a>=news.size()&&check){
	    ans++;
	    check=false;
	  }
	}
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1208
#include "bits/stdc++.h"

typedef long long ll;

using namespace std;

vector<vector<pair<int, int>>> G;
vector<int> res;
void dfs(int v, int p, int c) {
	res[v] = c;
	for (auto e : G[v]) {
		if (e.first == p) {continue;}
		if (e.second & 1) { dfs(e.first, v, 1 - c); }
		else { dfs(e.first, v, c); }
	}
}

int main() {
	int N;
	cin >> N;
	G.assign(N, vector<pair<int, int>>());
	for (int i = 0; i < N - 1; ++i) {
		int u, v, w; 
		cin >> u >> v >> w;
		--u, --v;
		G[u].push_back(pair<int, int>(v, w));
		G[v].push_back(pair<int, int>(u, w));
	}
	res.assign(N, 0);
	dfs(0, -1, 1);
	for (auto v : res) cout << v << endl;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double

using namespace std;

    const ll N = 1e2 + 7;
    const ll mod = 1e9 + 7;
    const ld eps = 1e-9;

ll mx , cur = 1000 , n , x;
ll a[N];

void solve(){
    cin >> n;
    for(int i = 1; i <= n; ++ i){
        cin >> a[i];
    }
    for(int i = 1; i <= n; ++ i){
        if(a[i] < a[i + 1]){
            x = cur % a[i];
            cur = cur / a[i];
            cur *= a[i + 1];
            cur += x;
        }
    }

    cout << cur;

}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
    //cin >> tt;
    while(tt --){
            solve();
    }
}

/**

**/


Measured memory_bytes: 3568
# encoding: utf-8
# N = int(input())
# S = input()
# N, M = map(int, input().split())
# A = list(map(int, input().split()))

N, x = map(int, input().split())
A = list(map(int, input().split()))

x_tmp = x
for i, Ai in enumerate(sorted(A)):
    x_tmp -= Ai
    if x_tmp == 0:
        ans = i + 1
        break
    elif x_tmp < 0:
        ans = i
        break
    else: continue
else: ans = i

print(ans)

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

typedef long long ll;

#define for0(i, n) for (ll i = 0; i < ll(n); ++i)         // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= ll(n); ++i)        // 1 based indexing
#define forc(i, l, r) for (ll i = ll(l); i <= ll(r); ++i) // closed llerver from l to r r inclusive
#define forr0(i, n) for (ll i = ll(n) - 1; i >= 0; --i)   // reverse 0 based.
#define forr1(i, n) for (ll i = ll(n); i >= 1; --i)       // reverse 1 based

#define pb push_back
#define fi first
#define se second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end()  //Forward traversal
#define rall(x) (x).rbegin(), (x).rend() //reverse traversal

bool isPowerOfTwo(int n)
{
    if (n == 0)
        return false;

    return (ceil(log2(n)) == floor(log2(n)));
}

// traversal function to avoid long template definition.
#define tr(c, i) for (__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)

// find if a given value is present in a container. Container version. Runs in log(n) for set and map
#define present(c, x) ((c).find(x) != (c).end())

//find version works for all containers. This is present in std namespace.
#define cpresent(c, x) (find(all(c), x) != (c).end())

// Avoiding wrap around of size()-1 where size is a unsigned int.
#define sz(a) ll((a).size())

using namespace std;

// Shorthand for commonly used types
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;
ll maxx = INT_MIN;
ll minn = INT_MAX;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout.tie(0);
    // #ifdef LOCAL
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    ll n;
    cin>>n;
    vll a(n);
    for0(i,n) cin>>a[i];
    vll dp(n);
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for (ll i=2; i<n; i++) {
        dp[i] = min (dp[i-1] + abs(a[i-1] - a[i]), dp[i-2] + abs(a[i-2]- a[i]));
    }
    cout<<dp[n-1];
    return 0;
}

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

char p[100005];
int S[100005],P[100005],n; 

int main(){
	scanf("%d%s",&n,&p);
	for(int i=0;i<n;i++){
		if(p[i]=='o') P[i+1]=0;
		else P[i+1]=1;
	}
	P[n+1]=P[1];
	for(int i=0;i<8;i++){
		S[0]=i&1;
		S[1]=(i>>1)&1;
		S[2]=(i>>2)&1;
		for(int j=2;j<=n+1;j++){
			S[j+1]=S[j-2]^P[j];
		}
		if((S[0]^S[1]^S[n]^S[n+1])||(S[1]^S[2]^S[n+1]^S[n+2])) continue;
		for(int j=1;j<=n;j++){
			printf("%c",(S[j-1]^S[j])?'W':'S');
		}
		return 0;
	}
	printf("-1\n");
	return 0;
} 

Measured memory_bytes: 1280
#include<cstdio>
#include<queue>

using namespace std;

struct node{
    int parent;
    int left;
    int right;
    int sibling;
    int degree;
    int depth;
    int height;
};

node tree[25];

queue<int> anspre,ansin,anspost;

void pre(int id){
    anspre.push(id);
    if(tree[id].left >= 0)
        pre(tree[id].left);
    if(tree[id].right >= 0)
        pre(tree[id].right);
}

void in(int id){
    if(tree[id].left >= 0)
        in(tree[id].left);
    ansin.push(id);
    if(tree[id].right >= 0)
        in(tree[id].right);
    
}

void post(int id){
    if(tree[id].left >= 0)
        post(tree[id].left);
    if(tree[id].right >= 0)
        post(tree[id].right);
    anspost.push(id);
}


int main(void){
    int n;
    scanf("%d",&n);

    for(int i = 0;i < n;i++){
        tree[i].sibling = -1;
        tree[i].degree = 0;
        tree[i].parent = -1;
    }
    for(int i = 0;i < n;i++){
        int id,left,right;
        scanf("%d%d%d",&id,&left,&right);
        tree[id].left = left;
        tree[id].right = right;
        if(left >= 0){
            tree[left].parent = id;
            tree[id].degree++;
        }
        if(right >= 0){
            tree[right].parent = id;
            tree[id].degree++;
        }
        if(left >= 0 && right >= 0){
            tree[left].sibling = right;tree[right].sibling = left;
        }
    }
    int root;
    for(int i = 0;i < n;i++)
        if(tree[i].parent == -1){
            root =  i;
            break;
        }

    pre(root);
    in(root);
    post(root);
    printf("Preorder\n ");
    for(int i = 0;i < n;i++){
        printf("%d",anspre.front());
        anspre.pop();
        if(i < n - 1)
            printf(" ");
    }
    printf("\nInorder\n ");
    for(int i = 0;i < n;i++){
        printf("%d",ansin.front());
        ansin.pop();
        if(i < n - 1)
            printf(" ");
    }
    printf("\nPostorder\n ");
    for(int i = 0;i < n;i++){
        printf("%d",anspost.front());
        anspost.pop();
        if(i < n - 1)
            printf(" ");
    }
    printf("\n");
    
    


    return 0;
}

Measured memory_bytes: 2756
#include <iostream>

#define imax(N1,N2) (N1>N2?N1:N2)

int main(int argc, char **argv)
{

  int H, W, N;
  scanf("%d",&H);
  scanf("%d",&W);
  scanf("%d",&N);
  int n = imax(H,W);
  int ans = N/n + (N%n==0 ? 0 : 1);
  printf("%d\n",ans);

}


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

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

    int remain;
    string result;
    remain = n % 500;
    if (remain <= a) {
        result = "Yes";
    } else {
        result = "No";
    }

    cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int,Int> p;

const Int M = 1000;

int main(){
    Int X; cin >> X;

    vector<Int> gojou;

    for(Int i=0; i<=M; i++){
        gojou.push_back(i*i*i*i*i);
    }

    rep(i,M){
        for(int j=i; j<=M; j++){
            if(gojou[i] + gojou[j] == X){
                cout << i << " " << -j << endl;
                return 0;
            } else if (gojou[j] - gojou[i] == X){
                cout << j << " " << i << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,r;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>r;
    if(n>=10){
        print(r);
    }else{
        ll ans = r + 100*(10-n);
        print(ans);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, z, w;
int a[2005];
int main() {
	scanf("%d%d%d", &n, &z, &w);
	for (int i = 0; i < n; ++ i) {
		scanf("%d", &a[i]);
	}
	printf("%d\n", n == 1 ? abs(a[0] - w) : max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1])));
	return 0;
}

Measured memory_bytes: 256
fun main(arg: Array<String>) {
    val N = nextInt()
    val S = next()
    val A = BooleanArray(N + 1)
    val B = BooleanArray(N + 1)
    val C = BooleanArray(N + 1)
    for (n in 1 .. N) A[n] = S[n - 1] == 'o'
    for (b in 0 .. 3) {
        B[1] = (b and 1) != 0
        B[2] = (b and 2) != 0
        for (n in 1 .. N) C[n] = A[n]
        for (n in 1 .. N) {
            C[n] = C[n] xor B[n]
            if (n in 2 .. N - 1) B[n + 1] = B[n - 1] xor C[n]
        }
        if ((B[1] == (B[N - 1] xor C[N])) && (B[N] == (B[2] xor C[1]))) {
            val sb = StringBuilder()
            for (n in 1 .. N) sb.append(if (B[n]) 'S' else 'W')
            return println(sb.toString())
        }
    }
    println(-1)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta


Measured memory_bytes: 34612
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
typedef long long ll;

int asc(const void* a, const void* b) { return *(int*)a - *(int*)b; }

int main() {
	ll n, count[1000001] = {};
	scanf("%lld", &n);
	ll s = pow(n, 0.5);
	for (int i = 1; i <= s; i++) {
		for (int j = 1; j <= s; j++) {
			for (int k = 1; k <= s; k++) {
				count[i * i + j * j + k * k + i * j + j * k + k * i]++;
			}
		}
	}
	for (int i = 1; i <= n; i++)printf("%lld\n", count[i]);

	return 0;
}


Measured memory_bytes: 9904
"use strict";

function Main(input) {
  input = input.split(" ");
  let result = 0;
  for (let i = 1; i <= input[0]; i++) {
    let n = String(i).split("");
    let sum = 0;
    for (const m of n) {
      sum = sum + parseInt(m);
    }
    if (sum <= input[2] && sum >= input[1]) {
      result = result + i;
    }
  }
  console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf-8"));


Measured memory_bytes: 25096
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
using namespace std;

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

int l[10];
int v1,v2;
char t;
int len;
double tim;
double L;

int main(){
	while(cin>>l[0]){
		rep(i,9){
			cin>>t>>l[i+1];
		}
		cin>>t>>v1>>t>>v2;
		v2+=v1;
		len = 0;
		rep(i,10) len+=l[i];
		tim = (double)len / v2;
		L = v1*tim;
		rep(i,10){
			if(L<=l[i]){
				l[0] = i;
				break;
			}
			else{
				L-=l[i];
			}
		}
		cout<<l[0]+1<<endl;
	}
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;  // or pb_ds;

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#ifndef DEBUG
// #define endl "\n"
#endif
#define fff ff
#define sss ss.ff
#define ttt ss.ss
#define INF (1 << 30)
#define LLF (1ll << 60)
#define PRIME (1000000007)
#define FASTIO std::ios::sync_with_stdio(false)
#ifdef DEBUG
#define debug(x) cerr << #x << " = " << x << endl
#else
#define debug(x)
#endif
#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define FILE_INPUT                  \
  freopen("input.txt", "r", stdin); \
  freopen("output.txt", "w", stdout)

#define all(x) x.begin(), x.end()

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<string> vs;

template <typename T, typename B = null_type>
using oset =
    tree<T, B, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order / order_of_key

const ld eps = 1e-12;

/*-----------------END TEMPLATE-----------------*/

int gg[201][201];

void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vi r, g, b;
  for (int i = 0; i < n; i++) {
    char c = s[i];
    if (c == 'R')
      r.pb(i);
    else if (c == 'G')
      g.pb(i);
    else
      b.pb(i);
  }

  ll sum = 0;

  for (int i = 0; i < n; i++) {
    char ci = s[i];
    for (int j = i + 1; j < n; j++) {
      char cj = s[j];
      if (ci == cj) continue;
      vi& search =
          ((ci == 'R' || cj == 'R') && (ci == 'G' || cj == 'G'))
              ? b
              : ((ci == 'R' || cj == 'R') && (ci == 'B' || cj == 'B')) ? g : r;

      // between [j+1, j+(j-i)]
      int idxStart =
          upper_bound(search.begin(), search.end(), j) - search.begin();
      int idxEnd =
          lower_bound(search.begin(), search.end(), j + j - i) - search.begin();

      sum += idxEnd - idxStart;

      // more then j+(j-i);
      auto idxStart2 = upper_bound(search.begin(), search.end(), j + j - i);
      int count = search.end() - idxStart2;
      sum += count;
    }
  }

  cout << sum << endl;
}

int(((((((((((((((main)))))))))))))))() {
  FASTIO;
  int n;
  // cin >> n;
  n = 1;
  int i = 1;
  while (n--) {
    solve();
  }
}

/*


00100
00

*/

Measured memory_bytes: 3660
def main():
    n = int(input())
    a = list(map(int, input().split()))
    d = [None]*(2**n)
    d[0] = [a[0], 0, -1, -1]
    ans = 0
    for i, t1 in enumerate(a[1:]):
        i += 1
        t2, t3, t4 = i, -1, -1
        for j in range(len(bin(i))-2):
            k = i & ~(1 << j)
            if k == i:
                continue
            t5, t6, t7, t8 = d[k]
            if t5 > t1:
                t1, t2, t3, t4 = t5, t6, t1, t2
            elif t5 > t3:
                if t6 != t2:
                    t3, t4 = t5, t6
            if t7 > t3:
                t3, t4 = t7, t8
        d[i] = [t1, t2, t3, t4]
        ans = max(ans, t1+t3)
        print(ans)


main()

Measured memory_bytes: 57620
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<int, P > PP;
#define MAX 10000000
int cc=1;
int A,B,C,N;
set< PP > s;
vector< PP > t;
  
map< P , set< P > > xy,yz,zx;
  
int par[MAX],rak[MAX];
  
void init(){
  for(int i=0;i<MAX;i++)
    par[i]=i,rak[i]=1;
}
  
int find(int x){
  if(par[x]==x)return x;
  return par[x]=find(par[x]);
}
  
void unite(int x,int y){
  x=find(x),y=find(y);
  if(x==y)return;
  if(rak[x]<rak[y])swap(x,y);
  par[y]=x;
  rak[x]+=rak[y];
}
  
void calc(map< P , set<P> > &mp){
  map< P , set<P> > :: iterator it;
  for(it=mp.begin();it!=mp.end();it++){
    set<P> :: iterator si=it->second.begin();
    set<P> :: iterator ti=it->second.end();
    set<P> :: iterator A=si,B;
    while(1){
      B=A;
      B++;
      if(B==ti)break;
      if(A->second>0&&B->second>0){
        unite(A->second,B->second);
      }
      A=B;
    }
  }
}
  
void add(int nx,int ny,int nz){
  if(nx<0||A<=nx||ny<0||B<=ny||nz<0||C<=nz)return;
  if(s.count(PP(nx,P(ny,nz))))return;
  s.insert( PP(nx,P(ny,nz)) );
  xy[ P(nx,ny) ].insert( P(nz,cc) );
  yz[ P(ny,nz) ].insert( P(nx,cc) );
  zx[ P(nz,nx) ].insert( P(ny,cc) );     
  cc++;
}
  
int main(){
  init();
  scanf("%d %d %d %d",&A,&B,&C,&N);
  t.resize(N);
 
  for(int i=0;i<N;i++){
    int x,y,z;
    scanf("%d %d %d",&x,&y,&z);
    s.insert( PP(x,P(y,z)) );
    t[i]=PP(x,P(y,z));
 
    xy[ P(x,y) ].insert( P(z,0) );
    yz[ P(y,z) ].insert( P(x,0) );
    zx[ P(z,x) ].insert( P(y,0) );     
  }
 
 
  add(0,0,0);
 
  
  for(int i=0;i<(int)t.size();i++){
    int x=t[i].first;
    int y=t[i].second.first;
    int z=t[i].second.second;
      
    for(int dx=-1;dx<=1;dx++){
      for(int dy=-1;dy<=1;dy++){
        for(int dz=-1;dz<=1;dz++){
          add(x+dx,y+dy,z+dz);
  
          add(x+dx,0,0);
          add(0,y+dy,0);
          add(0,0,z+dz);
  
          //          add(x+dx,B-1,C-1);
          //          add(A-1,y+dy,C-1);
          //          add(A-1,B-1,z+dz);
  
          //          add(x+dx,B-1,0);
          //          add(A-1,y+dy,0);
          //          add(A-1,0,z+dz);
  
          //          add(x+dx,0,C-1);
          //          add(0,y+dy,C-1);
          //          add(0,B-1,z+dz);
  
          add(x+dx,y+dy,0);
          add(0,y+dy,z+dz);
          add(x+dx,0,z+dz);
  
          //          add(x+dx,y+dy,C-1);
          //          add(A-1,y+dy,z+dz);
          //          add(x+dx,B-1,z+dz);
        }
      }
    }
  }
    
  
  calc(xy);
  calc(yz);
  calc(zx);
  
  int ans=0;
  for(int i=1;i<cc;i++)
    if(find(i)==i)ans++;
  
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 416688
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> A(N); rep(i, 0, N) {
		cin >> A[i];
	}
	int M = accumulate(all(A), 0LL);

	int ans = INF;
	int t = 0;
	rep(i, 0, N - 1) {
		t += A[i];
		chmin(ans, abs(t - (M - t)));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
cost_a,cost_b,cost_ab,num_a,num_b = map(int,input().split())
if num_a > num_b:
  num_ab = num_b * 2
  need_a = num_a - (num_ab // 2)
  cost1 = need_a * cost_a + num_ab * cost_ab
  
  num_ab = num_a * 2
  cost3 = num_ab * cost_ab
  cost1 = min(cost1,cost3)
elif num_a < num_b:
  num_ab = num_a * 2
  need_b = num_b - (num_ab // 2)
  cost1 = need_b * cost_b + num_ab * cost_ab

  num_ab = num_b * 2
  cost3 = num_ab * cost_ab
  cost1 = min(cost1,cost3)
else:
  num_ab = num_b * 2  
  cost1 = num_ab * cost_ab

cost2 = cost_a * num_a + cost_b * num_b
ans = min(cost1,cost2)
print(ans)




Measured memory_bytes: 3064
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main(void) {
  string s;
  int K;
  cin >> s >> K;

  map<string, int> m;
  for (int i = 0; i < s.size(); ++i) {
    for (int j = 1; j <= 5; ++j) {
      string temp = s.substr(i, j);
      m[temp] = 1;
    }
  }

  int count = 1;
  for (auto const& entry : m) {
    if (count == K) {
      cout << entry.first << endl;
      break;
    }
    count++;
  }
  
  return 0;
}


Measured memory_bytes: 4728
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    A, B = map(int, input().split())
    if A >= 13:
        print(B)
    elif 6<= A <=12:
        print(B//2)
    else:
        print(0)

#%%
if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
#include<stdio.h>


int main() {
	char inp_str[210];

	fgets(inp_str, 210, stdin);

	for (int i = 0; inp_str[i] != '\n'; i++) {
		if (inp_str[i] >= 'a'&&inp_str[i] <= 'z')inp_str[i] -= 32;
		printf("%c", inp_str[i]);
	}
	printf("\n");
	


	return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  string S,T;
  cin>>S>>T;
  ll ans=0;
  for(int i=0;i<S.size();i++)if(S[i]!=T[i])ans++;
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main(void){
    unsigned long long  N, K;
    cin >> N >> K;
    unsigned long long ans = 0;
    
    // a = b
    if(K == 0) ans += N;

    // a < b
    for(unsigned long long  a=max<unsigned long long>(K, 1);a<=N;a++){
        ans += N-a;
    }

    // a > b
    for(unsigned long long b=N;b>K;b--){
        unsigned long long u = (N-b+1)/b;
        unsigned long long d = (N-b+1)%b;
        unsigned long long a = (b-K)*u + (d>=K?d-K:0);
        if(K == 0) a--;
        ans += a;
    }

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

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

using namespace std;

const int mod = 1e9 + 7;

long long dp[5005][5005];

int main()
{
  int N;
  string S;

  cin >> N;
  cin >> S;

  dp[0][0] = 1;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < 5003; j++) {
      (dp[i + 1][max(0, j - 1)] += dp[i][j]) %= mod;
      (dp[i + 1][j + 1] += dp[i][j] * 2 % mod) %= mod;
    }
  }
  int ret = dp[N][S.size()];
  for(int i = 0; i < S.size(); i++) ret = 1LL * ret * 500000004 % mod;
  cout << ret << endl;
}

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (a); i > (b); i--)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

void solve() {
  int N;
  in(N);
  vi H(N);
  each(x, H) in(x);
  rrep(i, N - 2, -1) {
    if (H[i] > H[i + 1]) {
      if (--H[i] != H[i + 1]) {
        print("No");
        return;
      }
    }
  }
  print("Yes");
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_B&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    n = int(input())
    S = dict()
    H = dict()
    C = dict()
    D = dict()

    for _ in range(n):
        suit, num = input().strip().split()
        num = int(num)
        if suit == 'S':
            S[num] = num
        elif suit == 'H':
            H[num] = num
        elif suit == 'C':
            C[num] = num
        else:
            D[num] = num


    for name, s in [('S', S), ('H', H), ('C', C), ('D', D)]:
        for i in range(1, 13+1):
            if i not in s:
                print('{} {}'.format(name, i))


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7804
#include <iostream>

int A, B;

int main(void){
    std::cin >> A >> B;
    if(A%3 == 0 || B%3 == 0 || (A+B)%3 == 0){
        std::cout << "Possible\n";
    }else{
        std::cout << "Impossible\n";
    }
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,m;
int main()
{
	cin>>a;
	cin>>b;
	cin>>c;
	cin>>n;
    for(int i=0;i<=a;i++){
    	for(int j=0;j<=b;j++){
    		for(int x=0;x<=c;x++){
    			if(i*500+j*100+x*50==n){
    				m++;
    			}
    		}
    	}
    }
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

struct edge {
    int from, to;
    ll cost;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<edge> edges(n);
    for(int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        edges.emplace_back(edge{a - 1, b - 1, c});
    }
    vector<ll> d(n, -LLINF);
    vector<bool> neg(n, false);
    d[0] = 0;
    for(int i = 0; i < n; i++) {
        for(auto e : edges) {
            if(d[e.from] != -LLINF && d[e.to] < d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }
    for(int i = 0; i < n; i++) {
        for(auto e : edges) {
            if(d[e.from] != -LLINF && d[e.to] < d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                neg[e.to] = true;
            }
            if(neg[e.from]) {
                neg[e.to];
            }
        }
    }
    if(neg[n - 1]) {
        cout << "inf" << endl;
    } else {
        cout << d[n - 1] << endl;
    }
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int a[55][55];
int h,w,sum;
char c;
int main(){
	cin>>h>>w;
	memset(a,0,sizeof(a));
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++){
			cin>>c;
			if(c=='#')a[i][j]=1;
		}		
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(a[i][j]==0){
				sum=0;
				for(int ia=i-1;ia<=i+1;ia++)
					for(int ja=j-1;ja<=j+1;ja++)
						sum+=a[ia][ja]; 
				cout<<sum;
			}
			else cout<<'#';
		}
		cout<<endl;
			
	}
	
}

Measured memory_bytes: 256
N = int(input())
C = [0]*4
for i in range(N):
    S = input()
    if S == 'AC':
        C[0] += 1
    elif S == 'WA':
        C[1] += 1
    elif S == 'TLE':
        C[2] += 1
    elif S == 'RE':
        C[3] += 1

print('AC x '+str(C[0]))
print('WA x '+str(C[1]))
print('TLE x '+str(C[2]))
print('RE x '+str(C[3]))

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n;
    cin >> n;
    vector<int> a(n);
    int ans = 0;
    rep(i, n) cin >> a[i];

    rep(i, n){
        rep(j, n){
            if(i != j){
                ans = max(ans, abs(a[i] - a[j]));
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [int(input()) for _ in range(N)]

sumv = sum(S)
if sumv % 10 != 0:
    print(sumv)
    exit()

S.sort()
for s in S:
    if s % 10 != 0:
        sumv -= s
        print(sumv)
        exit()
print(0)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << endl
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rrep(i,n) for(int i=(n); (i)>0; --(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
#define maxemt(v) *max_element(v.begin(), v.end())
#define minemt(v) *min_element(v.begin(), v.end())
#define lb(v,x) v[lower_bound(v.begin(), v.end(), x) - v.begin()]
#define ub(v,x) v[upper_bound(v.begin(), v.end(), x) - v.begin()]
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool print(T& x){ cout << x << endl; return true; }
template<class T> inline bool print_(T& x){ cout << x << " "; return true; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
ll lcm(ll x, ll y){
  return x/gcd(x,y)*y;
} 
 int main(){
  int n; cin >> n;
  vector<int> t(n+1), x(n+1), y(n+1); reps(i,1,n+1) cin >> t[i] >> x[i] >> y[i];
  t[0]=0, x[0]=0, y[0]=0;
  reps(i,1,n+1){
    if(t[i]-t[i-1] < abs(x[i]-x[i-1]) + abs(y[i]-y[i-1])){cout << "No"; return 0;}
    if((t[i]-t[i-1] - abs(x[i]-x[i-1]) - abs(y[i]-y[i-1]))%2 != 0){cout << "No"; return 0;}
  }
  cout << "Yes";
  
  return 0;
 }


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main(){
    int a, b,c;
    cin >> a >> b>>c;	
	if(c>a && c>b){
		cout << "No" << endl;
	}
	else if(c<a &&c<b){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define PB push_back
#define MP make_pair
#define V first.first
#define D first.second
#define C second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<pii> vii;
typedef vector<piii> viii;

const int MOD = 1e9+7;
const int INF = 1e9;
const int MAX_N = 100000;
const int MAX_M = 100000;
const int MAX_Q = 100000;
const int MAX_D = 10;

int N, M, Q;
vvi edges(MAX_N);
viii query;
vector<bool> used(MAX_N, false);
vector<vector<bool> > finished(MAX_N, vector<bool>(MAX_D+1));
vi colors(MAX_N, 0);

void dfs(int v, int d, int c) {
  if (used[v]) return;

  if (finished[v][d]) return;
  for (int i = 0; i <= d; i++) {
    finished[v][i] = true;
  }
  if (colors[v] == 0) {
    colors[v] = c;
  }
  if (d == 0) return;

  used[v] = true;
  for (vi::iterator it = edges[v].begin(); it != edges[v].end(); ++it) {
    dfs(*it, d-1, c);
  }

  used[v] = false;
}

int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= 10; j++) {
      finished[i][j] = false;
    }
  }
  for (int i = 0; i < M; i++) {
    int a, b;
    scanf("%d %d", &a, &b); a--; b--;
    edges[a].PB(b);
    edges[b].PB(a);
  }
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int v, d, c;
    scanf("%d %d %d", &v, &d, &c); v--;
    query.PB(MP(MP(v, d), c));
  }
  reverse(query.begin(), query.end());
  for (viii::iterator it = query.begin(); it != query.end(); ++it) {
    int v = it->V, d = it->D, c = it->C;
    dfs(v, d, c);
  }

  for (int i = 0; i < N; i++) {
    cout << colors[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 15476
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;

int main(void) {
  ll i, j, k, h, w, l;
  int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
  char dir[6] = "NESW";
  while( 1 ) {
  ll x, y, d, cycle;
  scanf("%lld%lld%lld", &h, &w, &l);
  if(!h && !w && !l) break;
  ll a[h][w][4];
  char c[h][w + 10];
  for(i = 0; i < h; ++i) {
    scanf("%s", c[i]);
    for(j = 0; j < w; ++j) {
      if(c[i][j] == 'N') x = j, y = i, d = 0;
      else if(c[i][j] == 'E') x = j, y = i, d = 1;
      else if(c[i][j] == 'S') x = j, y = i, d = 2;
      else if(c[i][j] == 'W') x = j, y = i, d = 3;
    }
  }
  for(i = 0; i < h; ++i) for(j = 0; j < w; ++j) for(k = 0; k < 4; ++k) a[i][j][k] = -1;
  a[y][x][d] = 0;
  for(i = 0; i < l; ) {
    if(x + dx[d] >= w || y + dy[d] >= h || x + dx[d] < 0 || y + dy[d] < 0 || c[y + dy[d]][x + dx[d]] == '#') {
      d = (d + 1) % 4;
      if(a[y][x][d] == -1) a[y][x][d] = i;
      else {
        cycle = i - a[y][x][d];
        break;
      }
    } else {
      y += dy[d], x += dx[d], ++i;
      if(a[y][x][d] == -1) a[y][x][d] = i;
      else {
        cycle = i - a[y][x][d];
        break;
      }
    }
  }
  if(i == l) {
    printf("%lld %lld %c\n", y + 1, x + 1, dir[d]);
    continue;
  }
  l -= i;
  l %= cycle;
  for(i = 0; i < (!l ? cycle : l); ) {
    if(x + dx[d] >= w || y + dy[d] >= h || x + dx[d] < 0 || y + dy[d] < 0 || c[y + dy[d]][x + dx[d]] == '#') {
      d = (d + 1) % 4;
    } else {
      y += dy[d], x += dx[d], ++i;
    }
  }
  /*for(i = 0; i < h; ++i) {
    for(j = 0; j < w; ++j) printf("%lld/%lld/%lld/%lld ", a[i][j][0], a[i][j][1], a[i][j][2], a[i][j][3]);
    printf("\n");
  }*/
  printf("%lld %lld %c\n", y + 1, x + 1, dir[d]);
  }
  return 0;
}


Measured memory_bytes: 2896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
	string s1, s2;
	cin >> s1 >> s2;
	bool flag = true;
	for(int i = 0; i < 3; ++i){
		if(s1[i] != s2[2-i])
			flag = false;
	}
	if(flag){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256