akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
string s;
vector<ll>v[3];
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r,ss=0;
    cin>>n>>s;
    for(i=0;i<n;i++)
    {
        if(s[i]=='R')
        {
            v[1].pb(i);
        }
        else if(s[i]=='G')
        {
            v[2].pb(i);
        }
        else
        {
            v[3].pb(i);
        }
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            m=j-i;
            if((s[i]=='R' && s[j]=='G') || (s[i]=='G' && s[j]=='R'))
            {
                ss+=(upper_bound(v[3].begin(),v[3].end(),n)-lower_bound(v[3].begin(),v[3].end(),(j+m+1)));
                ss+=(upper_bound(v[3].begin(),v[3].end(),(j+m-1))-lower_bound(v[3].begin(),v[3].end(),j+1));
            }
            else if((s[i]=='G' && s[j]=='B') || (s[i]=='B' && s[j]=='G'))
            {
                ss+=(upper_bound(v[1].begin(),v[1].end(),n)-lower_bound(v[1].begin(),v[1].end(),(j+m+1)));
                ss+=(upper_bound(v[1].begin(),v[1].end(),(j+m-1))-lower_bound(v[1].begin(),v[1].end(),j+1));
            }
            else if((s[i]=='R' && s[j]=='B') || (s[i]=='B' && s[j]=='R'))
            {
                ss+=(upper_bound(v[2].begin(),v[2].end(),n)-lower_bound(v[2].begin(),v[2].end(),(j+m+1)));
                ss+=(upper_bound(v[2].begin(),v[2].end(),(j+m-1))-lower_bound(v[2].begin(),v[2].end(),j+1));
            }
        }
    }
    cout<<ss<<"\n";
    return 0;
}



Measured memory_bytes: 3720
/*
* @Author: 王文宇
* @Date:   2018-03-11 20:11:19
* @Last Modified by:   王文宇
* @Last Modified time: 2018-03-11 20:21:32
*/
#include <bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i=a;i<=b;i++)
long long n,m;
int main(int argc, char const *argv[])
{
	cin>>n>>m;
	if(n==1&m==1)cout<<1<<endl;
	else if(n==1)cout<<m-2<<endl;
	else if(m==1)cout<<n-2<<endl;
	else cout<<(n-2)*(m-2)<<endl;
	return 0;
}

Measured memory_bytes: 256
//Your limitation—it’s only your imagination
#include <bits/stdc++.h>

#define full(x,n) x,x+n+1
#define full(x) x.begin(),x.end()
#define finish return 0

#define putb push_back
#define f first
#define s second

#define putf push_front
#define gainb pop_back

#define gainf pop_front
#define len(x) x.size()

//Dream it. Wish it. Do it

typedef double db;
typedef long long ll;

//Never forget health

const ll ary=55;
const ll mod=1e9+7;
const ll inf=1e18;

using namespace std;
ll n,p,a[ary],dp[ary][2],ans;
int main(){
	cin>>n>>p;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}	
	dp[1][0]=(a[1]%2==0);
	dp[1][1]=a[1]%2;
	ans+=dp[1][p];
	for(int i=2;i<=n;i++){
		dp[i][a[i]%2]=1;
		for(int j=1;j<i;j++){
			if(a[i]%2){
				dp[i][1]+=dp[j][0];
				dp[i][0]+=dp[j][1];
			}
			else{
				dp[i][1]+=dp[j][1];
				dp[i][0]+=dp[j][0];
			}
		}
		ans+=dp[i][p];
	}
	cout<<ans+(!p);
}
//Push yourself, because no one else is going to do it for you


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true) {
			int N=sc.nextInt();
			if(N==0) {
				System.exit(0);
			}
			ArrayList<Integer> taro=new ArrayList<Integer>();
			ArrayList<Integer> hanako=new ArrayList<Integer>();
			int[] aa=new int[2*N];
			for(int i=0; i<2*N; i++) {
				aa[i]=i+1;
			}
			for(int i=0; i<N; i++) {
				int tmp=sc.nextInt();
				aa[tmp-1]=0;
				taro.add(tmp);
			}
			int counter=0;
			for(int i=0; i<2*N; i++) {
				if(aa[i]>0) {
					hanako.add(aa[i]);
				}
			}
			/*for(int i=0; i<N; i++) {
				p(taro.get(i)+" ");
			}
			pl("");
			for(int i=0; i<N; i++) {
				p(hanako.get(i)+" ");
			}
			pl();*/
			Collections.sort(taro);
			Collections.sort(hanako);
			int now=0;
			boolean tarohana=false;
			while(taro.size()>0 && hanako.size()>0) {
				if(tarohana==false) {	//太郎の番
					if(now==0) {
						now=taro.get(0);
						taro.remove(0);
						tarohana=true;
					}
					else {
						for(int i=0; i<taro.size(); i++) {
							if(taro.get(i)>now) {
								now=taro.get(i);
								taro.remove(i);
								tarohana=true;
								break;
							}
							else if(taro.get(i)<=now &&i==taro.size()-1) {
								now=0;
								tarohana=true;
							}
						}
					}
				}
				if(taro.size()==0 || hanako.size()==0) {
					break;
				}
				if(tarohana==true) {
					if(now==0) {
						now=hanako.get(0);
						hanako.remove(0);
						tarohana=false;
					}
					else {
						for(int i=0; i<hanako.size(); i++) {
							if(hanako.get(i)>now) {
								now=hanako.get(i);
								hanako.remove(i);
								tarohana=false;
								break;
							}
							else if(hanako.get(i)<=now &&i==hanako.size()-1) {
								now=0;
								tarohana=false;
							}
						}
					}
				}
			}
			if(taro.size()==0) {
				pl(hanako.size());
				pl(0);
			}
			else {
				pl(0);
				pl(taro.size());
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


Measured memory_bytes: 26988
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

int main()
{
	int n;
	cin >> n;
	int count = 0;
	rep(i, n) {
		int p;
		cin >> p;
		if (p != (i + 1)) count++;
	}
	if (count <= 2) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD (long)(1000000007)
long mul(long a,long b){
  return ((a%MOD)*(b%MOD))%MOD;
}
int main(){
  long n,res;
  cin>>n;
  string s,t;
  vector<bool> v;//false:|:1,true:-:2
  cin>>s>>t;
  for(int i=0;i<s.length();++i){
    if(i+1<s.length()&&s[i]==s[i+1]){
      v.emplace_back(1);
      ++i;
    }
    else v.emplace_back(0);
  }
  res=(v[0]?6:3);
  for(int i=1;i<v.size();++i){
    if(!v[i-1])res=mul(res,2);
    else if(v[i])res=mul(res,3);
  }
  cout<<res;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            long iH = long.Parse(sS[0]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            long iOut = 1;
            while (true)
            {
                iH /= 2;                        // 敵の半分の体力
                if (iH == 0) { break; }         // 0で終わり
                iOut *= 2;                      // 敵の数
            }
            iOut *= 2;                          // 攻撃回数総和 = 次の2の累乗値-1で求まる
            iOut -= 1;                          

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
S = raw_input()
a = S[0]+S[1]
b = S[2]+S[3]
yymm = 1 <= int(b) and int(b) <= 12
mmyy = 1 <= int(a) and int(a) <= 12
if yymm:
	if mmyy: print 'AMBIGUOUS'
	else: print 'YYMM'
else:
	if mmyy: print 'MMYY'
	else: print 'NA'

Measured memory_bytes: 27884
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    int s = stdIn.nextInt();
    int w = stdIn.nextInt();
    
    if (s > w){
      System.out.print("safe");
    }
    else{
      System.out.print("unsafe");
    }
  }
}

Measured memory_bytes: 35580
import heapq

X, Y, A, B, C = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
q = list(map(int, input().split(" ")))
r = list(map(int, input().split(" ")))
p.sort(); q.sort(); r.sort();
p.reverse(); q.reverse(); r.reverse();
ans = [sum(p[:X]) + sum(q[:Y])]
que = []
for pi in p[:X]:
    heapq.heappush(que, pi)
for qi in q[:Y]:
    heapq.heappush(que, qi)

for i in range(min(C, X + Y)):
    minimum = heapq.heappop(que)
    ans.append(ans[-1] - minimum + r[i])

print(max(ans))

Measured memory_bytes: 23456
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <tuple>

using namespace std;

constexpr long long mod = static_cast<long long>(1e9 + 7);

bool check(int A, int B, int C, int D, const std::vector<bool>& ans) {
    assert(ans.size() == 3);
    int sum = A;
    if(ans[0]) sum += B;
    else sum -= B;

    if(ans[1]) sum += C;
    else sum -= C;

    if(ans[2]) sum += D;
    else sum -= D;

    return sum == 7;
}

std::tuple<std::vector<bool>, bool> dfs(int A, int B, int C, int D, std::vector<bool> arr = std::vector<bool>{}){
    if(arr.size() == 3) {
        return std::make_tuple(arr, check(A, B, C, D, arr));
    } else {
        arr.push_back(true);
        auto ans1 = dfs(A, B, C, D, arr);
        if(std::get<1>(ans1)) return ans1;
        arr.back() = false;
        return dfs(A, B, C, D, std::move(arr));
    }
}

int main() {
    std::string str;
    cin >> str;
    assert(str.size() == 4);

    int A = str[0] - '0', B = str[1] - '0', C = str[2] - '0', D = str[3] - '0';

    auto ans = dfs(A, B, C, D);

    auto& a = std::get<0>(ans);

    cout << A
         << (a[0] ? "+" : "-")
         << B
         << (a[1] ? "+" : "-")
         << C
         << (a[2] ? "+" : "-")
         << D
         << "=7"
         << endl;

    return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
temp = [False for i in range(n)]
for i in range(k):
    x = int(input())
    y = list(map(int,input().split()))
    for j in y:
        if not temp[j-1]:
            temp[j-1] = True

ans = 0
for i in temp:
    if not i:
        ans += 1
print(ans)

Measured memory_bytes: 9192
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>

using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define ull unsigned long long
#define ll long long
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}


int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	string s;
	cin >> s;
	if(s.length() < 26) {

		vector<bool> appear(26, false);
		for(auto & c: s){
			appear[c-'a'] = true;
		}
		for(int i=0;i<26;++i) {
			if(!appear[i]){
				cout << s+ (char)('a'+i) << endl;
				return 0;
			}
		}

	} else {
		if (s == "zyxwvutsrqponmlkjihgfedcba") {
			cout << -1 << endl;
			return 0;
		} else {
			char tmp = 'z';
			for(int i=25;i>0;--i) {
				if(s[i] > s[i-1]) {
					string res = s.substr(0,i-1);
					cout << res;
					for(int j=25;j>=i;--j) {
						if(s[j] > s[i-1]) {
							cout << s[j] << endl;
							return 0;
						}
					}

				}
			}
		}

	}
}

Measured memory_bytes: 256
S = input()
ans = 0
for i in range(1 << len(S)-1): #2**N-1
  tmp = S[0]
  for j in range(len(S)-1):
    if ((i >> j) & 1) == 1:
      tmp += "+"
    tmp += S[j+1]      
  ans += eval(tmp)
      
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

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

    int D; cin >> D;
    vector<int> C(26); vector<vector<int>> S(D, vector<int>(26));
    REP(i, 0, 26) cin >> C[i];
    REP(i, 0, D) REP(j, 0, 26) cin >> S[i][j];


    vector<int> T(D);
    REP(i, 0, D) {
        int max_idx = 0;
        REP(j, 0, 26) {
            if (S[i][max_idx] < S[i][j]) max_idx = j;
        }
        T[i] = max_idx + 1;
    }

    vector<vector<int>> last(26, vector<int>(D, 0));
    vector<ll> ret(26, 0);
    REP(i, 0, D) {
        ret[T[i] - 1] += S[i][T[i] - 1];
        last[T[i] - 1][i] = i + 1;
        REP(j, 0, 26) {
            if (i > 0 && !last[j][i]) last[j][i] = last[j][i - 1];
            ret[j] -= C[j] * (i + 1 - last[j][i]);
        }
    }

	auto start = std::chrono::system_clock::now();
    const ll limit = 1950*1000;

    ll best = accumulate(ALL(ret), 0LL);
    mt19937_64 mt(random_device{}());
    while (1) {
        std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
        double elapsed = std::chrono::duration_cast<std::chrono::microseconds>(now-start).count();
        if(elapsed > limit) break;

        int d = mt() % D;
        int next = mt() % 26;
        int prev = T[d] - 1;
        T[d] = next + 1;
        last[prev].assign(D, 0);
        last[next].assign(D, 0);
        ret[prev] = 0;
        ret[next] = 0;
        REP(i, 0, D) {
            if (T[i] == prev + 1 || T[i] == next + 1) {
                ret[T[i] - 1] += S[i][T[i] - 1];
                last[T[i] - 1][i] = i + 1;
            }
            if (i > 0) {
                if (!last[prev][i]) last[prev][i] = last[prev][i - 1];
                if (!last[next][i]) last[next][i] = last[next][i - 1];
            }
            ret[prev] -= C[prev] * (i + 1 - last[prev][i]);
            ret[next] -= C[next] * (i + 1 - last[next][i]);
        }
        if (best >= accumulate(ALL(ret), 0LL)) {
            T[d] = prev + 1;
        } else {
            best = accumulate(ALL(ret), 0LL);
        }
    }
    
    for (auto t : T) cout << t << endl;
    return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N; cin>>N;
  rep(i,N){
    int A; cin>>A;
    if(A%2==0){
      if(A%3&&A%5){
        cout<<"DENIED\n";
        return 0;
      }
    }
  }
  cout<<"APPROVED\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int N,W,H,L;
vector<P> t;

bool check(P p,int a){
  if(p.first<p.second)
    return (p.first<=a&&a<=p.second);
  return (p.first<=a||a<=p.second);
}
int calcArg(int x,int y){
  if(x==0)return y;
  if(y==H)return H+x;
  if(x==W)return H+W+H-y;
  return H+W+H+W-x;
}
int solve(int si){
  int res=1,last=t[si].second;
  for(int i=si;i<si+N;i++){
    if(check(t[i],last)) continue;
    res++;
    last=t[i].second;
  }
  return res;
}
int main(){
  cin>>N>>W>>H;
  L=W+W+H+H;
  for(int i=0;i<N;i++){
    int x,y,s;
    char ch;
    P p;
    cin>>x>>y>>ch;
    if(ch=='N'){
      s=calcArg(x,H);
      p.first = (s-H+y+L)%L;
      p.second = (s-y+H)%L;
    }
    if(ch=='E'){
      s=calcArg(W,y);
      p.first = (s-W+x+L)%L;
      p.second = (s-x+W)%L;
    }
    if(ch=='S'){
      s=calcArg(x,0);
      p.first = (s-y+L)%L;
      p.second = (s+y)%L;
    }
    if(ch=='W'){
      s=calcArg(0,y);
      p.first = (s-x+L)%L;
      p.second = (s+x)%L;
    } 
    t.push_back(p);
  }
  for(int i=0;i<N;i++) swap(t[i].first,t[i].second);
  sort(t.begin(),t.end());
  for(int i=0;i<N;i++) t.push_back(t[i]);
  for(int i=0;i<N+N;i++) swap(t[i].first,t[i].second);
  int ans = N;
  for(int i=0;i<N;i++)ans = min(ans,solve(i));
  cout<<ans<<endl;
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<pair<long long, long long>> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i].second >> A[i].first;
    }
    
    bool jdg = true;
    long long deadline = 0;
    long long now = 0;
    sort(A.begin(), A.end());
    
    for (int i = 0; i < N; i++) {
        deadline = A[i].first;
        now += A[i].second;
        if (deadline < now) {
            jdg = false;
        }
    }
    
    cout << ((jdg) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define offset 6500
using namespace std;

struct data {
  int x, y, now;
};

long long h, w;
vector<vector<int> > a, b;
bool memo[85][85][15000] = {0};
queue<data> qu;

long long solve();

int main() {
  cin >> h >> w;
  a.assign(h, vector<int>(w, 0));
  b.assign(h, vector<int>(w, 0));
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j) cin >> a[i][j];
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j) cin >> b[i][j];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 100000000;
  qu.push({0, 0, a[0][0] - b[0][0]});
  qu.push({0, 0, b[0][0] - a[0][0]});
  memo[0][0][a[0][0] - b[0][0] + offset] =
      memo[0][0][offset + b[0][0] - a[0][0]] = 1;
  while(!qu.empty()) {
    data now = qu.front();
    qu.pop();
    for(int i = 0; i < 2; ++i) {
      data nextp = now, dummy;
      nextp.x += i;
      nextp.y += 1 ^ i;
      if(nextp.x >= h || nextp.y >= w) continue;
      dummy = nextp;

      nextp.now +=
          a[nextp.x][nextp.y] - b[nextp.x][nextp.y];
      if(!memo[nextp.x][nextp.y][nextp.now + offset]) {
        memo[nextp.x][nextp.y][nextp.now + offset] = 1;
        qu.push(nextp);
      }

      nextp = dummy;

      nextp.now +=
          b[nextp.x][nextp.y] - a[nextp.x][nextp.y];
      if(!memo[nextp.x][nextp.y][nextp.now + offset]) {
        memo[nextp.x][nextp.y][nextp.now + offset] = 1;
        qu.push(nextp);
      }
    }
  }
  for(int i = 0; i <= offset + 6400; ++i)
    if(memo[h - 1][w - 1][i]) {
      ans = min(ans, (long long)abs(i - offset));
    }
  return ans;
}

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


int main() {

    int NG = 0;

    int c11,c12,c13;
    int c21,c22,c23;
    int c31,c32,c33;

    cin >> c11 >> c12 >> c13;
    cin >> c21 >> c22 >> c23;
    cin >> c31 >> c32 >> c33;

    int d1,d2,d3;

    d1 = c12-c11;
    d2 = c22-c21;
    d3 = c32-c31;
    if (d1 != d2 || d2 != d3) NG = 1;

    d1 = c13-c12;
    d2 = c23-c22;
    d3 = c33-c32;
    if (d1 != d2 || d2 != d3) NG = 1;

    d1 = c21-c11;
    d2 = c22-c12;
    d3 = c23-c13;
    if (d1 != d2 || d2 != d3) NG = 1;

    d1 = c31-c21;
    d2 = c32-c22;
    d3 = c33-c23;
    if (d1 != d2 || d2 != d3) NG = 1;

    if (NG == 0) cout << "Yes" << endl;
    else cout << "No" << endl;


}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define a_max 200000

int main(){
    int i,N,K;
    int A[a_max]={};
    cin >> N >>K;
    int tmp;
    for(i=0;i<N;i++){
        scanf("%d",&tmp);
        A[tmp-1]+=1;
    }
    sort(&A[0],&A[a_max],greater<int>());
    int ans=0;
    for(i=0;i<K;i++){
        ans+=A[i];
    }
    printf("%d\n",N-ans);
}

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

int gcd(int x, int y)
{
    if (x % y == 0) return y;
    return gcd(y, x % y);
}

int main()
{
    int k;
    cin >> k;
    long long ans = 0;
    for (int a = 1; a <= k; a++)
    {
        for (int b = 1; b <= k; b++)
        {
            for (int c = 1; c <= k; c++)
            {
                ans += gcd(c, gcd(a, b));
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
S = input()
N = len(S)

ans1 = 0
ans2 = 0

for i in range(N):
        s = S[i]
        if i%2 == 0:
                if s != '0':
                        ans1 += 1
                if s != '1':
                        ans2 += 1
        if i%2 == 1:
                if s != '0':
                        ans2 += 1
                if s != '1':
                        ans1 += 1


print(min(ans1,ans2)) 

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#define N 16
using namespace std;

int n;
int str[N][N];
bool checkstr[N][N];

void reset();
void disp();
void loop(int i, int j, int num, int c);

int main(){
    while(cin >>n){
        if(n == 0) break;
        reset();
        str[n / 2 + 1][n / 2] = 1;
        checkstr[n / 2 + 1][n / 2] = true;
        loop(n / 2 + 2, n / 2 + 1, 2, 1);
        disp();
    }
    return 0;
}

void reset(){
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            checkstr[i][j] = false;
        }
    }
}
void disp(){
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            printf("%4d", str[i][j]);
        }
        cout <<endl;
    }
}

void loop(int i, int j, int num, int c){
    c++;
    if(c <= (n * n)){
        if(i >= n) i = 0;
        if(j >= n) j = 0;
        while(checkstr[i][j] == true){
            i++;
            j--;
            if(i >= n) i = 0;
            if(j < 0) j = n - 1;
        }
        str[i][j] = num;
        checkstr[i][j] = true;
        i++;
        j++;
        num++;
        loop(i, j, num, c);
    }
}

Measured memory_bytes: 0
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
   cout << ((a*b)%2?"Odd":"Even") << endl;
}

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

using namespace std;

int main()
{
    double n, t, a, h[1001];
    double ans[10001];
    double min = 10000001;
    int sub = 0;

    cin >> n >> t >> a;

    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    for (int i = 0; i < n; i++) {
        ans[i] = t - (h[i] * 0.006);
    }

    for (int i = 0; i < n; i++) {
        if (min > fabs(a - ans[i])) {
            min = fabs(a - ans[i]);
            sub = i;
        }
    }

    cout << sub + 1 << endl;
}



Measured memory_bytes: 256
using System;

class quiz
{
    public int solve(int N,int[] A)
    {
        bool done = false;

        while(!done)
        {
            Array.Sort(A);

            for (int i = 0; i < N; i++)
            {
                if (i == N - 1)
                {
                    done = true;
                    break;
                }

                if(A[i] != 0)
                {
                    for (int j = i + 1; j < N; j++)
                    {
                        A[j] %= A[i];
                    }

                    break;
                }
            }
        }

        return A[N - 1];
    }

    public int[] ParseIntBySpace(string str)
    {
        int[] array = new int[str.Length];
        int lastloc = 0, spaceloc = -1;

        for (int i = 0; i < str.Length; i++)
        {
            if (str[i] == ' ')
            {
                array[lastloc++] = int.Parse(str.Substring(spaceloc + 1, i - spaceloc - 1));
                spaceloc = i;
            }
            else if (i == str.Length - 1)
            {
                array[lastloc++] = int.Parse(str.Substring(spaceloc + 1, i - spaceloc));
            }
        }

        Array.Resize(ref array, lastloc);

        return array;
    }
}

class Example
{
    static void Main()
    {
        quiz ex = new quiz();
        
        Console.WriteLine(ex.solve(int.Parse(Console.ReadLine()),ex.ParseIntBySpace(Console.ReadLine())));
    }
}

Measured memory_bytes: 17760
#include<stdio.h>
int fun(int n)
{
	int a=n,m=0;
	while(a!=0)
	{
		m=m*10+a%10;
		a/=10;
	}
	if(n==m) return 1;
	return 0; 
}
int main()
{
	int n,m,s=0;
	int i,j;
	scanf("%d %d",&n,&m);
	for(i=n;i<=m;i++)
	{
		if(fun(i))
		{
			s++;
		}
	}
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<stdio.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define INF 1000000000000000
#define MAXN (int)(1e6)+1
#define MOD 1000000007
 
using namespace std;
 
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,int> pwi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector< vector<pair<int,lli > > > wGraph;
typedef vector<vector<int> > graph;
//typedef vector<vector<int> > matrix;

int main(){
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<std::fixed;
    cout<<std::setprecision(4);
    
    int n,k;
    cin>>n>>k;
    
    vi ar;
    for(int i = 0;i<n;++i){
        int v;
        cin>>v;
        ar.pb(v);
    }   
    
    int dp[n+1];
    for(int i = 0;i<n;++i){
        dp[i] = INT_MAX;
        if(i == 0){
            dp[i] = 0;
        }else if(i < k){
            dp[i] = abs(ar[0]-ar[i]);
        }else{
            for(int x = 1;x<=k;++x){
                dp[i] = min(dp[i-x]+abs(ar[i]-ar[i-x]),dp[i]);
            }
        }
        
    }
    
    cout<<dp[n-1]<<endl;
       
    return 0;
 
}

Measured memory_bytes: 1144
n,k = map(int, input().split())

# ans = 0
# for right in range(k+1, n+1):
#     for left in range(max(1,k), right):
#         while left <= n:
#             ans+=1
#             left+=right
# print(ans, flush=True)
# TLE

ans = 0
for b in range(1,n+1):
    ans += (n//b)*max(0,b-k) + max(n%b+1-k, 0)
    if k==0:
        ans -= 1
print(ans, flush=True)



Measured memory_bytes: 9192
n = gets.chomp.to_i
s = gets.chomp.split("")
red = 0
green = 0
blue = 0
term = 0
n.times do |i|
    case s[i]
    when "R"
        red += 1
    when "G"
        green += 1
    when "B"
        blue += 1
    end
end


n.times do |i|
    (i+1).upto(n-1) do |j|
        next if s[i] == s[j]
        k = j*2 - i
        next if k >= n || s[k] == s[i] || s[k] == s[j]
        term += 1
    end
end

ans = red * green * blue - term
puts ans

Measured memory_bytes: 14388
n,m = map(int,input().split())
l = [0]*n
cor = 0
pen = 0
for i in range(m):
    p,s = map(str,input().split())
    if s == "AC":
        if l[int(p)-1] != -1:
            cor += 1
            pen += l[int(p)-1]
            l[int(p)-1] = -1
    else:
        if l[int(p)-1] != -1:
            l[int(p)-1] += 1
print(cor,pen)

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

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()
{
    const double pi = 3.1415926535897932;
    double a,b,h,m; cin >> a >> b >> h >> m;
    double hraji = pi*m*6/180; double mraji = pi*(0.5*h*60+0.5*m)/180;
    double h_x = b*cos(hraji);
    double h_y = b*sin(hraji);
    double m_x = a*cos(mraji);
    double m_y = a*sin(mraji);
    
    double x = h_x - m_x; double y = h_y - m_y;
    x = pow(x,2); y = pow(y,2);
    double ans = sqrt(x+y);
    cout << fixed;
    cout << setprecision(18) << ans << endl;;
    return 0;
}



Measured memory_bytes: 4132
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
template <typename T> 
using lim = numeric_limits<T>;
template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using indexed_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = 2e5;
const int MOD = 998244353;
ll n, m, k;
ll fact[N+1];
ll ifact[N+1];

ll modpow(ll b, ll e){
    ll ans = 1;
    while(e){
        if (e&1) ans = ans*b%MOD;
        e >>= 1;
        b = b*b%MOD;
    }
    return ans;
}

ll perm(int x, int r){
    return fact[x]*ifact[x-r]%MOD;
}

ll comb(int x, int r){
    return perm(x,r)*ifact[r]%MOD;
}

ll compute(int x){
    ll ret = m*modpow(m-1,n-1-x)%MOD;
    ret = ret*comb(n-1,x)%MOD;
    return ret;
}

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

    cin >> n >> m >> k;
    
    fact[0] = 1;
    for (int i = 1; i <= N; i++){
        fact[i] = i*fact[i-1]%MOD;
    }

    
    ifact[N] = modpow(fact[N], MOD-2);
    for (int i = N-1; i >= 0; i--){
        ifact[i] = (i+1)*ifact[i+1]%MOD;
    }

    ll ans = 0;
    for (int i = 0; i <= k; i++){
        ans = (ans+compute(i))%MOD;
    }

    cout << ans << "\n";
}

Measured memory_bytes: 6760
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int w = sc.nextInt();
    int n = sc.nextInt();
    int[] values = new int[w];
    for (int i = 0; i < w; i++) {
      values[i] = i + 1;
    }
    for (int i = 0; i < n; i++) {
      String str = sc.next();
      String[] ab = str.split(",");
      int a = Integer.parseInt(ab[0]) - 1;
      int b = Integer.parseInt(ab[1]) - 1;
      int c = values[a];
      values[a] = values[b];
      values[b] = c;
    }
    for (int i = 0; i < w; i++) {
      System.out.println(values[i]);
    }
  }
}

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int mn = 114514;
    int N, X;
    cin >> N >> X;
    REP(i, N) {
        int m;
        cin >> m;
        mn = min(mn, m);
        X -= m;
    }
    int res = N + X/mn;
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1e9 + 7;
const int N = 3005;
int n, m;
int mx[N], mn[N];
int dp[N][N];
string s;

signed main()
{
	int cnt = 0;
	cin >> n >> m;
	cin >> s;
	s = "a" + s;
	for(int i = 1; i <= n; i++)
	{
		cnt += (s[i] == '1');
		mn[i] = cnt,
		mx[i] = cnt;
	}

	for(int i = 1; i <= m; i++)
	{
		int l, r;
		cin >> l >> r;
		int tmp1 = mn[r] - mn[l - 1],
			tmp2 = mx[r] - mx[l - 1];

		for(int j = l; j <= r; j++)
		{
			mn[j] = min(mn[j], mn[l - 1] + max(0LL, tmp1 - r + j));
			mx[j] = max(mx[j], mx[l - 1] + min(j - l + 1, tmp2));
		}
	}

	dp[0][0] = 1;
	for(int i = 1; i <= n; i++)
	{
		for(int j = mn[i]; j <= mx[i]; j++)
		{
			if(j > 0)
			 	dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1];
			 else
			 	dp[i][j] = dp[i - 1][j];
			dp[i][j] %= mod;
		}
		
	}
	cout << dp[n][cnt];
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i = 0; i < n; i++){
        cin >> vec[i];
    }
    vector<int> dp(n);
    dp[0] = 0;
    dp[1] = abs(vec[0] - vec[1]);
    for(int i = 2; i <n; i++ ){
        int n1 = dp[i-2] + abs(vec[i-2] - vec[i]);
        int n2 = dp[i-1] + abs(vec[i-1] - vec[i]);
        dp[i] = min(n1, n2);
    }
    cout << dp[n-1] << endl;
    return 0;
}

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

int main(){
    ll a,b,k;
    cin>>a>>b>>k;
    if(a>k){
        a-=k;
        cout<<a<<" "<<b;
    }else{
        k-=a;
        b-=k;
        if(b<0)b=0;
        cout<<0<<" "<<b;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int alpha[27];
int main()
{
        long long i,sum=0,cnt=1;
        string str;
        cin>> str;
        for(i=0;str[i];i++){
                alpha[str[i]-'a']++;
        }
        for(i=0;i<26;i++){
                cnt= alpha[i];
                if(cnt)sum-= (cnt*(cnt-1))/2;
        }
        i= str.size();
        sum+= (i*(i-1))/2;
        cout << sum+1 << endl;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> w(n), wl(n), wr(n);

    cin >> w[0];
    wl[0] = w[0];
    for (int i=1; i<n; ++i) {
        cin >> w[i];
        wl[i] = wl[i-1] + w[i];
    }
    wr[n-1] = w[n-1];
    for (int i=n-2; i>=0; --i)
        wr[i] = wr[i+1] + w[i];

    int ans = abs(wl[0] - wr[1]);
    for (int i=1; i<n-1; ++i) 
        ans = min(ans, abs(wl[i] - wr[i+1]));

    cout << ans << endl;
}


Measured memory_bytes: 888
#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++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;

long p_26(long n)
{
	long cnt = 0;
	while (n >= 26)
	{
		n /= 26;
		cnt++;
	}
	return cnt;
}

string dog_n(long n)
{
	map <long , char> mp;
	for (long i = 1; i <= 26;i++)
		mp[i] = 96 + i;
	mp[0] = 'z';
	string ans;
	string tmp;

	while (1)
	{
		if (n % 26 == 0)
		{
			string t = dog_n(n + 1);
			if (p_26(n) && t.front() == 'a' && t.back() == 'a' )
			{
				long p = p_26(n);
				// string s((n/26-26)+1, 'z');
				string s(p, 'z');
				ans = s; break;
			}
		}
		if (n <= 26)
		{
			ans += mp[n];
			break;
		}
		else
		{
			tmp += mp[n % 26];
			if (n / 26 <= 26)
			{
				if (n % 26)
					ans += mp[n / 26];
				else
					ans += mp[n / 26 - 1];
				break;
			}
			else
			{
				if (n%26)
				{
					ans += dog_n(n/26);
					break;
				}
				else
				{
					n--;
					ans += dog_n(n / 26);
					break;
				}
				n/=26;
			}
		}
	}
	return ans + tmp;
}


int  main()
{
	long n; cin >> n;
	// rep1(i, n)
	// {
	// 	cout << i << " "; 
	// 	cout << dog_n(i) << endl;
	// }
	cout << dog_n(n) << endl;
	// cout << p_26(n);
	return (0);
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <vector>
#include <array>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>

using std::string;
using std::vector;


int main(){
    double x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    double dx = x1 - x2;
    double dy = y1 - y2;
    double distance = std::sqrt(std::pow(dx, 2.0) + std::pow(dy, 2.0));
    printf("%.4lf\n", distance);
    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll n,ans=0;
	std::cin >> n;
	ll m = n;
	vll p(n);
	rep(i, 0, n) {
		std::cin >> p[i];
		if (m >= p[i]) {
			ans++;
			m = p[i];
		}
	}

	outn(ans);
	return 0;
}


Measured memory_bytes: 1792
#include<string>
#include<iostream>
#include<fstream>
#include<stack>
using namespace std;
int main()
{
	int i, j;
	string str;
	cin >> str;
	int flag = 0;
	for (i = 0; i <(int) str.size(); i++)
		if (str[i] == 'C')
			break;
	if (i == str.size())
	{
		cout << "No";
		return 0;
	}
	for(j=i+1;j<(int)str.size();j++)
		if (str[j] == 'F')
		{
			cout << "Yes";
			return 0;
		}
	cout << "No";
}

Measured memory_bytes: 256
import math
N = int(input())
L = list(map(int,input().split()))
M = list(map(int,input().split()))
cnt = 0
for i in range(N):
  if L[i] < M[i]:
    cnt += math.ceil((M[i]-L[i])/2)
if cnt <= sum(M)-sum(L):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 40560
n = gets.chomp.to_i
p = gets.chomp.split(' ').map(&:to_i)

cnt = 0

p.size.times do |i|
  a = p[i]
  b = p[i+1]
  c = p[i+2]
  break if !b || !c
  
  t = [a,b,c].sort
  
  cnt += 1 if t[1] == b
end

puts cnt

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,q,a;
    cin>>n>>q;
    fenwick_tree<ll> A(n);
    rep(i,n) cin>>a,A.add(i,a);
    rep(i,q){
        int a,b,c;
        cin>>a>>b>>c;
        if(a==0) A.add(b,c);
        else cout<<A.sum(b,c)<<"\n";
    }
}

Measured memory_bytes: 8248
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int odd = 0, even = 0;
	long a;
	for(int i = 0; i < n; i++)
	{
		cin >> a;
		if(a % 2)
			odd++;
		else
			even++;
	}
	if(odd % 2 == 0)
		cout << "YES" << endl;
	else 
		cout << "NO" << endl;
	return 0;
}



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

int main()
{
    int n;
    std::string s;

    std::cin >> n;
    std::cin >> s;

    if(n%2 == 1)
    {
        std::cout << "No" << std::endl;
    }
    else
    {
        bool flag = 1;

        for(int i = 0, j = n/2; i < (n/2), j < n; i++, j++)
        {
            if(s[i] != s[j])
            {
                flag = 0;
                break;
            }
            else
            {
                flag = 1;
            }
        }

        if(flag == 1)
        {
            std::cout << "Yes" << std::endl;
        }
        else
        {
            std::cout << "No" << std::endl;
        }
    }

    return 0;
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if(A + B > C + D)
    cout << "Left" << endl;
  
  else if(A + B < C + D)
    cout << "Right" << endl;
  
  else if(A + B == C + D)
    cout << "Balanced" << endl;
}


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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-12;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=50000;
    rep(y,1,P){
        ll x=mod(y*k);
        
        if(abs(x)<=P||x+P>=i_7){
            if(x+P>=i_7){
                x-=i_7;
            }
            cout<<x<<"/"<<y<<endl;
            //cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
typedef vector<ll> vl;
//////////////////////////


int main(){fastio
    
    string s;cin>>s;
    ll n=s.size();
    ll a=0;
    rep(i,0,n-1){
        a+=s[i]-'0';
    }
    if(a%9==0)cout<<"Yes";
    else cout<<"No";
    
    
    
    return 0;
}


Measured memory_bytes: 3776
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<int>;


int main()
{
	int Q;
	cin >> Q;
	map<int, int> mp;
	ll ans = 0;

	--Q;
	int q;
	int num = 1;
	ll a, b;
	cin >> q >> a >> b;
	mp[a] = 1;
	ans = b;
	int xj = 0; // 同じ数字の何番目を見ているか
	auto x = mp.find(a);

	for (int i = 0; i < Q; ++i)
	{
		cin >> q;
		if (q == 2)
		{
			cout << x->first << " " << ans << endl;
			continue;
		}
		cin >> a >> b;
		ans += b;
		if (num % 2 == 1)
		{
			if (mp.count(a)) { mp[a]++; }
			else { mp[a] = 1; }
			ans += abs(a - x->first);

			if (a < x->first)
			{
				if (xj == 0)
				{
					x--;
					xj = x->second - 1;
				}
				else
				{
					--xj;
				}
			}
		}
		else
		{
			if (mp.count(a))mp[a]++;
			else mp[a] = 1;
			ans += abs(a - x->first);
			if (x->first <= a) // 3
			{
				if (xj == x->second - 1)
				{
					ans += x->first;
					x++;
					xj = 0;
					ans -= x->first;
				}
				else
				{
					xj++;
				}
			}
		}
		++num;
	}


	return 0;
}

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

a = int(input())
a_list = []
b_list = []

for i in range(a):
  a_list.append(input())

b = int(input())

for i in range(b):
  b_list.append(input())
a_count = Counter(a_list)
b_count = Counter(b_list)
a_list_no_overlap = set(a_list)

point = []
for i in a_list_no_overlap:
    point.append(a_count[i]-b_count[i])

point_max = max(point)
if point_max<0:
  print(0)
else:
  print(point_max)


Measured memory_bytes: 12504
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL dp[55][5005];
int main(){
    int n, a, x;
    scanf("%d%d", &n, &a);
    dp[0][2500] = 1;
    for(int i=1;i<=n;i++){
        scanf("%d", &x);
        for(int j=0;j<=5000;j++) dp[i][j+x-a] += dp[i-1][j], dp[i][j] += dp[i-1][j];
    }
    printf("%lld\n", dp[n][2500]-1);
}

Measured memory_bytes: 2176
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;

class Program
{
    void Solve()
    {
        var N = io.Int;
        var M = io.Int;
        var A = new int[N];
        for (var i = 0; i < N; i++)
        {
            A[i] = io.Int;
        }

        var B = new int[M];
        var C = new int[M];
        for (var i = 0; i < M; i++)
        {
            B[i] = io.Int;
            C[i] = io.Int;
        }

        var cnts = new Dictionary<int, int>();
        foreach (var a in A)
        {
            if (!cnts.ContainsKey(a)) cnts[a] = 0;
            cnts[a]++;
        }

        for (var i = 0; i < M; i++)
        {
            if (!cnts.ContainsKey(C[i])) cnts[C[i]] = 0;
            cnts[C[i]] += B[i];
        }

        var takeNum = 0;
        var sum = 0L;
        foreach (var kv in cnts.OrderByDescending(kv => kv.Key))
        {
            if (takeNum + kv.Value < N)
            {
                sum += (long) kv.Value * kv.Key;
                takeNum += kv.Value;
            }
            else
            {
                var left = N - takeNum;
                sum += (long) kv.Key * left;
                break;
            }
        }

        WriteLine(sum);
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Program().Stream();

    private void Stream()
    {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}

class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] {' ', '"', ','};

    StreamWriter sw = new StreamWriter(OpenStandardOutput())
    {
#if DEBUG
        AutoFlush = true
#else
        AutoFlush = false
#endif
    };

    public SimpleIO()
    {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }

    string Next()
    {
        if (_bufferCnt < _nextBuffer.Length) return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == string.Empty) st = ReadLine();
        _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }

    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}

Measured memory_bytes: 38424
n, m = map(int, input().split())
move = [tuple(map(int, input().split())) for i in range(m)]

ball = [1] * (n+1)
red = [False] * (n+1)
red[1] = True

for x, y in move:
  ball[x] -= 1
  ball[y] += 1
  if red[x]: red[y] = True
  if ball[x] == 0: red[x] = False

ans = red.count(True)
print(ans)

Measured memory_bytes: 18136