akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/foreach.hpp>
using namespace std;
#define pi 2*asin(1.0)
#define MAX 10000000
#define MOD 1000000007
#define _GLIBCXX_DEBUG
 
vector<long> fac(MAX);
vector<long> finv(MAX);
vector<long> inv(MAX);
vector<long> Primelist;
//template functions
/////////////////////////
void Prinit(){
long PR=10000001;
vector<long> P(PR,0);
for(long i=2;i*i<PR;i++){
    if(P.at(i)==0){
        long j=i;
      j+=i;
        while(j<PR){
            P.at(j)=1;
             j+=i;         
        }
    }
}

for(long i=2;i*i<PR;i++){//Primelist.size()=446
    if(P.at(i)==0){
        Primelist.push_back(i);
    }
}
}

void Cominit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(long i=2;i<MAX;i++){
      fac.at(i)=(fac.at(i-1)*i)%MOD;
      inv.at(i)=MOD-inv.at(MOD%i)*(MOD/i)%MOD;
      finv.at(i)=finv.at(i-1)*inv.at(i)%MOD;
  }
}

long facComb(long N,long M){// nCm%
if(N<M) return 0;
if(N<0||M<0) return 0;
return fac.at(N)*(finv.at(M)*finv.at(N-M)%MOD)%MOD;
}

long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}

long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}

long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

long strtolong(string str){
istringstream ss;
ss=istringstream(str);
long num;
ss>>num;
return num;
}

long chartolong(char ch){
long num;
num=ch-'0';
return num;
}

long Max2(long a,long b){
if(a>b){
    return a;
}else{
    return b;
}
}

long Min2(long a,long b){
if(a>b){
    return b;
}else{
    return a;
}
}


string longtostr(long N){
    string str;
    str=to_string(N);
    return str;
}









/////////////////////////


//Answer


int main() {
string S,T;
cin>>S;
if(S.at(S.size()-1)=='s'){
    T=S+"es";
}else{
    T=S+"s";
}
cout<<T<<endl;
}



Measured memory_bytes: 237504
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)


//template functions
/////////////////////////
long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}
long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}
/////////////////////////



//Answer


int main() {

long N;
cin>>N;
string A;
int AC=0,WA=0,TLE=0,RE=0;
for(long i=0;i<N;i++){
    cin>>A;
    if(A=="AC"){
        AC++;
    }else if(A=="WA"){
        WA++;
    }else if(A=="TLE"){
        TLE++;
    }else if(A=="RE"){
        RE++;
    }
 
}

cout<<"AC x "<<AC<<endl;
cout<<"WA x "<<WA<<endl;
cout<<"TLE x "<<TLE<<endl;
cout<<"RE x "<<RE<<endl;



}




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

typedef long long ll;
const double pi = acos(-1);
ll X1,Y1,X2,Y2,n,a[200020],d[200020],len;
map<ll,ll> x,y;

int main(){
    ios::sync_with_stdio(false);
    cin >> X1 >> Y1 >> X2 >> Y2 >> n;
    if(X2 < X1){
        swap(X1,X2);
        swap(Y1,Y2);
    }
    for(int i = 1,u,v;i <= n;++i){
        cin >> u >> v;
        x[u] = v;
        y[v] = u;
    }
    double qc = 5 * pi, ans = 0;
    if(X1 == X2){
        ll p = min(Y1,Y2), q = max(Y1,Y2);
        ans = 100 * (q - p);
        if(x.count(X1) && x[X1] > p && x[X1] < q) ans += 2*qc - 20;
        cout << fixed << setprecision(12) << ans << endl;
        return 0;
    }
    if(Y1 == Y2){
        ll p = min(X1,X2), q = max(X1,X2);
        ans = 100 * (q - p);
        if(y.count(Y1) && y[Y1] > p && y[Y1] < q) ans += 2*qc - 20;
        cout << fixed << setprecision(12) << ans << endl;
        return 0;
    }

    ll cnt = 0, mny = min(Y1,Y2), mxy = max(Y1,Y2);
    ans = 100 * (X2 - X1 + mxy - mny);
    for(auto p: x){
        if(p.first < X1 || p.first > X2) continue;
        if(p.second >= mny && p.second <= mxy) a[++cnt] = (Y1 < Y2 ? 1 : -1) * p.second;
    }

    for(int i = 1;i <= cnt;++i){
        int pos = lower_bound(d+1,d+1+len,a[i]) - d;
        if(pos == len + 1) len++;
        d[pos] = a[i];
    }

    ans -= (20 - qc) * len;
    if(len > min(X2 - X1,mxy - mny)) ans += qc;

    cout << fixed << setprecision(12) << ans << endl;

    return 0;
}


Measured memory_bytes: 28416
#include <cstring>
#include <iostream>
using namespace std;
int n, sx, sy, tx, ty; bool ok[11][10][10];
int main() {
	while (cin >> sx >> sy, sx + sy) {
		cin >> n; memset(ok, false, sizeof(ok));
		ok[0][sy][sx] = true;
		for (int i = 1; i <= n; i++) {
			cin >> tx >> ty;
			for (int j = 0; j < 1000; j++) {
				if (!ok[i - 1][j / 10][j % 10]) continue;
				for (int l = -2; l <= 2; l++) {
					for (int m = -2; m <= 2; m++) {
						if (0 <= j / 10 + l && j / 10 + l < 10 && 0 <= j % 10 + m && j % 10 + m < 10) {
							if (abs(ty - j / 10 - l) <= 1 && abs(tx - j % 10 - m) <= 1) {
								if ((abs(l) == 2 || abs(m) == 2) && abs(l * m) != 4) {
									ok[i][j / 10 + l][j % 10 + m] = true;
								}
							}
						}
					}
				}
			}
		}
		int ret = 0;
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				if (ok[n][i][j]) ret = 1;
			}
		}
		cout << (ret ? "OK" : "NA") << endl;
	}
}

Measured memory_bytes: 2964
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		int w, n, c, time = 0;
		while(!(string = reader.readLine()).equals("0")){
			w = Integer.valueOf(string);
			n = Integer.valueOf(reader.readLine());
			c = 0;
			int value[] = new int[n];
			int weiht[] = new int[n];
			int brionac[][] = new int[1001][10001];
			for(int i = 0; i < n; i++){
				string = reader.readLine();
				value[i] = Integer.valueOf(string.split(",")[0]);
				weiht[i] = Integer.valueOf(string.split(",")[1]);
			}
			for(int i = n - 1; i >= 0; i--){
				for(int j = 0; j <= w; j++){
					if(j < weiht[i]){
						brionac[i][j] = brionac[i + 1][j];
					}
					else{
						if(brionac[i + 1][j] > brionac[i + 1][j - weiht[i]] + value[i]){
							brionac[i][j] = brionac[i + 1][j];
						}else{
							brionac[i][j] = brionac[i + 1][j - weiht[i]] + value[i];
						}
					}
				}
			}
			for(int i = 0; i <= w; i++){
				if(brionac[0][i] < brionac[0][i + 1]) c = i + 1;
			}
			System.out.println("Case " + ++time + ":\n" + brionac[0][w] + "\n" + c);
		}
		
		reader.close();
	}
}

Measured memory_bytes: 178592
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //StringTokenizer st = new StringTokenizer(br.readLine());
        //PrintWriter pw = new PrintWriter("Main.out");

        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a - 2*b > 0){
            System.out.println(a-2*b);
        }
        else{
            System.out.println(0);
        }

    }
}

Measured memory_bytes: 21716
import numpy as np

N = int(input())
d = sorted(map(int, input().split()))

med = np.median(d)
if med in d:
  print(0)
  
else:
  lar = [x for x in d if x>med]
  sma = [x for x in d if x<med]

  print(lar[0]-sma[-1])

Measured memory_bytes: 39120
def f():
    n,k=map(int,input().split())
    l=list(map(int,input().split()))
    now=1

    for i in range(k.bit_length()):
        if k%2:now=l[now-1]
        l=tuple(l[l[i]-1]for i in range(n))
        k//=2
    print(now)
if __name__ == "__main__":
    f()

Measured memory_bytes: 32176
from collections import deque 
n = int(input())

a = list(input().split())
b = []

q = deque()

for i in range(n):
    x = a[i]
    if n%2 == i%2:
        q.append(x)
    else:
        q.appendleft(x)

    
print(" ".join(q))    

Measured memory_bytes: 26568
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>

#define ll long long

using namespace std;

int main(){
    int N,M;
    cin >>N >> M;
    vector<pair<int,int>> L;
    int l,r;
    for(int i=0;i<M;i++){
        cin >> l >> r;
        L.push_back(make_pair(l,r));
    }
    vector<int> x(1000001,0);
    for(int i=0;i<M;i++){
        x[L[i].first]++;
        x[L[i].second+1]--;
    }
    vector<int> ans(1000001,0);
    ans[0]=x[0];
    for(int i=1;i<ans.size();i++){
        ans[i]=ans[i-1]+x[i];
    }
    int cnt=0;
    for(int i=0;i<=N;i++){
        if(ans[i]==M){
            cnt++;
        }
    }
    cout <<cnt << endl;
    return 0;
}


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

int main() {
    int N,K;
    cin>>N>>K;
    int ball=N-K;
    if(K==1){
        cout<<0<<endl;
    }else{
        cout<<ball<<endl;
    }
return 0;}
/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N;
	cin >> N;
	vector<int>T(N);
	rep(i, N) {
		cin >> T[i];
	}
	int M;
	cin >> M;
	vector<int>P(M);
	vector<int>X(M);
	rep(i, M) {
		cin >> P[i] >> X[i];
	}
	int sum = 0;
	rep(i, N) {
		sum += T[i];
	}
	rep(i, M) {
		cout << sum - T[P[i] - 1] + X[i] << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    long long l, r;
    cin >> l >> r;
    long long ans = 2018;
    for (long long i = l; i < r; i++)
    {
        for (long long j = i + 1; j <= r; j++)
        {
            ans = min(ans, (i * j) % 2019);
            if (ans == 0)
                break;
        }
        if (ans == 0)
            break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    int A, P;
    cin >> A >> P;

    P += 3 * A;

    cout << P / 2 << endl;

    return 0;
}

Measured memory_bytes: 3560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 172_B
		Scanner sc = new Scanner(System.in);
		int iRes = 0;

		String str1 = sc.nextLine();
		String str2 = sc.nextLine();
		String[] strArray1 = str1.split("");
		String[] strArray2 = str2.split("");

		for(int i = 0; i < str1.length(); i++) {
			if (!strArray1[i].equals(strArray2[i])) {
				iRes++;
			}
		}
		System.out.println(iRes);
	}

}


Measured memory_bytes: 65632
#include <stdio.h>

int main(void)
{
	
	int m, n, r, temp, count;
	
	while(1){
		
		scanf("%d %d", &m, &n);
		
		if(m == 0 && n == 0){
			
			break;
			
		}
		
		if(m < n){
			
			temp = m;
			m = n;
			n = temp;
			
		}
		
		count = 0;
		
		while(n != 0){
			
			r = m%n;
			
			m = n;
			
			n = r;
			
			count++;
		}
		
		printf("%d %d\n", m, count);
		
	}
	
	
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define pb push_back
#define N 1005

using namespace std;

int n, m;
vector<int> G[N];
bool visit[N], ok = false;
int mini = (1<<30), nodo, d[N], p[N];

void bfs( int u ){
	visit[u] = true;
	queue <int> Q;
	d[u] = 0;
	Q.push(u);
	while(!Q.empty()){
		int q = Q.front();
		Q.pop();
		for( int i = 0; i < G[q].size(); i++ ){
			int v = G[q][i];
			if( v == u ){
				ok = true;
				if( mini > d[q] ){
					mini = d[q]+1;
					nodo = u;
				}
				return;
			}
			
			if( !visit[v] ){
				Q.push(v);
				d[v] = d[q]+1;
				visit[v] = true;
			}
		}	
	}
}


int bfs2( int u ){
	visit[u] = true;
	p[u] = -1;
	queue <int> Q;
	d[u] = 0;
	Q.push(u);
	while(!Q.empty()){
		int q = Q.front();
		Q.pop();
		for( int i = 0; i < G[q].size(); i++ ){
			int v = G[q][i];
			if( v == u ){
				return q;
			}
			
			if( !visit[v] ){
				Q.push(v);
				p[v] = q;
				visit[v] = true;
			}
		}	
	}
}


int main( void ){
	scanf("%d%d",&n,&m);
	for( int i = 0; i < m; i++ ){
		int x, y;
		scanf("%d%d",&x,&y);
		x--; y--;
		G[x].pb(y);
	}
	
	for( int i = 0; i < n; i++ ){
		memset( visit, false, sizeof visit );
		memset( d, -1, sizeof d );
		bfs(i);
	}
	if(!ok) puts("-1");
	else{
		cout << mini << endl;
		memset( visit, 0, sizeof visit );
		memset( p, -1, sizeof p );
		int z = bfs2(nodo);
		while( p[z] != -1 ){
			cout << z+1 << endl;
			z = p[z];
		}
		cout << z+1 << endl;
	}

	return 0;
}





Measured memory_bytes: 256
import sys
input = sys.stdin.readline

k = int(input())

n = 1

if k % 2  == 0:
    n = -1
else:
    r = 7 % k
    s = r

    while True:
        if r == 0:
            break
        elif n > 1000000:
            n = -1
            break
        else:
            r = (r * 10 + s) % k
            n += 1


print(n)

Measured memory_bytes: 9164
N,M=map(int,input().split())
P,S=[],[]
ans,pen=0,0
task=[0]*N
for _ in range(M):
    A,B=map(str,input().split())
    P.append(int(A))
    S.append(B)

for j in range(M):
    if task[P[j]-1]!=-1 and S[j]=="WA":
        task[P[j]-1]+=1
    elif task[P[j]-1]!=-1 and S[j]=="AC":
        ans+=1
        pen+=task[P[j]-1]
        task[P[j]-1]=-1
print(ans,pen)

Measured memory_bytes: 14132
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vi x(n+1),a(n+1),ans(n+1);
  rep(i,n){
    cin >> a[i+1];
  }
  for(int i = n;i>=1;i--){
    int cnt = 0;
    for(int j=i;j<=n;j+=i){
      cnt+=ans[j];
    }
    if(cnt%2 == a[i])continue;
    ans[i]+=1;
  }
  int sum = 0;
  rep(i,n) sum+=ans[i+1];
  cout<<sum<<endl;
  if(sum==0){
    return 0;
  }
  rep(i,n){
    if(ans[i+1])
    cout<<i+1<<" ";
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3200
n, q = map(int, input().split())
s = input()

lc = [0]
c = 0
for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        c += 1
    lc.append(c)

for i in range(q):
    l, r = map(int, input().split())
    print(lc[r-1]-lc[l-1])


Measured memory_bytes: 6100
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

int main()
{
  int a, b;
  cin >> a >> b;
  for(int x = 1 ; x <= 1e6 ; x++) {
    if(x * 2 / 25 == a && x / 10 == b)
      return cout << x << endl, 0;
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
a=[0]*26
w='abcdefghijklmnopqrstuvwxyz'
try:
    while True:
        s=list(input().upper())
        for i in s:
            if i=='A':
                a[0]+=1
            elif i=='B':
                a[1]+=1
            elif i=='C':
                a[2]+=1
            elif i=='D':
                a[3]+=1
            elif i=='E':
                a[4]+=1
            elif i=='F':
                a[5]+=1
            elif i=='G':
                a[6]+=1
            elif i=='H':
                a[7]+=1
            elif i=='I':
                a[8]+=1
            elif i=='J':
                a[9]+=1
            elif i=='K':
                a[10]+=1
            elif i=='L':
                a[11]+=1
            elif i=='M':
                a[12]+=1
            elif i=='N':
                a[13]+=1
            elif i=='O':
                a[14]+=1
            elif i=='P':
                a[15]+=1
            elif i=='Q':
                a[16]+=1
            elif i=='R':
                a[17]+=1
            elif i=='S':
                a[18]+=1
            elif i=='T':
                a[19]+=1
            elif i=='U':
                a[20]+=1
            elif i=='V':
                a[21]+=1
            elif i=='W':
                a[22]+=1
            elif i=='X':
                a[23]+=1
            elif i=='Y':
                a[24]+=1
            elif i=='Z':
                a[25]+=1 

except EOFError:
    pass

for i in range(26):
    print(w[i:i+1], ':', str(a[i]))

Measured memory_bytes: 7536
// https://atcoder.jp/contests/dp/tasks/dp_k

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mod 1000000007
#define gcd __gcd
// #define inf INT_MAX
#define inf 1e9+1
#define INF LLONG_MAX
#define minf INT_MIN
#define MINF LLONG_MIN
#define pb push_back
#define all(v) v.begin(),v.end()
#define print(v) for(auto x:v) cout<<x<<" "; cout<<"\n";
#define printn(v) for(auto x:v) cout<<x<<"\n";
#define F first
#define S second
#define mp make_pair

string k_stones(vector<int>&v, int k) {
	int dp[k + 1] = {};
	for (int i = 1; i <= k; i++) {
		for (int move : v) {
			if (i - move >= 0 && dp[i - move] == 0) dp[i] = 1;
		}
	}
	return dp[k] == 1 ? "First" : "Second";
}

int32_t main() {
	fastio;
	int n, k;
	cin >> n >> k;
	vector<int>v(n);
	for (int i = 0; i < n; i++) cin >> v[i];
	cout << k_stones(v, k) << endl;
}

Measured memory_bytes: 3980
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#define eps 1e-7;
typedef long long ll;
using namespace std;
const int maxn=100005;

ll h[maxn],hi;
//ll hi[maxn];
ll a,n,b;
ll in=1e10;

bool c(ll x)
{
    ll t=x;
   // for(ll i=0;i<n;i++)
    //    hi[i]=h[i];
    for(ll i=0;i<n;i++)
    {
        hi=h[i];
        hi-=x*b;
        if(hi<=0) continue;
        ll y;
        if(hi%(a-b)==0)
            y=hi/(a-b);
        else
            y=hi/(a-b)+1;
        t-=y;
    }
    if(t>=0)
        return true;
    return false;
}

void slove()
{
    sort(h,h+n);
    ll l=0,r=in;
    while(r-l>1)
    {
        ll mid=(r+l)/2;
        if(c(mid))
            r=mid;
        else
            l=mid;
    }
    printf("%lld\n",r);
}
int main()
{
    scanf("%d%d%d",&n,&a,&b);
    for(int i=0;i<n;i++)
        scanf("%d",&h[i]);
    slove();
    return 0;
}


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

using namespace std;
using ll = long long;

int main()
{
    ll n, m, d;

    cin >> n >> m >> d;

    double ans;

    if(d == 0) {
        ans = static_cast<double>(m-1) / n;
    } else {
        ans = static_cast<double>(m-1) * (n-d) * 2.0 / (n*n);
    }

    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main(){

	ll N;
	vector<ll> A;
	cin >> N;
	for(ll i = 0; i < N; i ++){
		ll a;
		cin >> a;
		A.pb(a);
	}
	sort(A.begin(), A.end());
	while(A.size() > 1){
		ll zeroNum = 0;
		for(int i = 1; i < A.size(); i ++){
			A[i] = A[i]%A[0];
			if(A[i] == 0)zeroNum++;
		}
		sort(A.begin(), A.end());
		A.erase(A.begin(), A.begin() + zeroNum);
	}
	cout << A[0] << endl;

	return 0;
}


Measured memory_bytes: 1400
require 'matrix'

loop do
  s = gets.chomp.chop
  break if s == ''

  #lookahead(?!  )
  s.gsub!(/([A-Z\)])(?![a-z\d])/, '\11')
  s.gsub!(/([A-Z][a-z])(?!\d)/, '\11')
  s.gsub!(/\((.+?)\)(\d*)/){
    as, n = $1, $2
    as.gsub(/([a-zA-Z])(\d+)/){"#{$1}#{$2.to_i * n.to_i}"}
  }
  atoms = s.scan(/[A-Z][a-z]?/)
  atoms.uniq!
  molecules = s.split('->').map{|ms| ms.split('+')}
  l = molecules[0].size
  molecules.flatten!
  m = molecules.size - 1
  n = atoms.size

  a = Matrix.build(n, m){|y, x|
    atom = atoms[y]
    molecules[x].scan(/#{atom}(\d+)/).reduce(0){ |sum, a|
      x < l ? sum + a[0].to_i : sum - a[0].to_i
    }.to_r
  }.to_a

  b = [0] * n
  atoms.each do |atom|
    molecules[-1].scan(/(#{atom})(\d+)/).each{|a, k|
      b[atoms.index(a)] = k.to_r
    }
  end

  # Gauss-Jordan elimination
  (0...[n,m].min).each do |i|
    pv = (i...n).max{|k| a[k][i].abs}
    a[i], a[pv] = a[pv], a[i]
    b[i], b[pv] = b[pv], b[i]
    (0...n).each do |j|
      next if i == j
      r = a[j][i] / a[i][i]
      (i...m).each do |k|
        a[j][k] -= r * a[i][k]
      end
      b[j] -= r * b[i]
    end
  end

  ans = (Matrix[*a[0,m]].inv * Vector[*b[0,m]]).to_a + [1.to_r]
  lcm = ans.map(&:denominator).reduce(&:lcm)
  puts ans.map{|x| (x * lcm).to_i} * ' '
end

Measured memory_bytes: 9948
def g;gets.to_i;end
g.times{|n|gets
m=(1..8).map{gets}
q=[[g-1,g-1]]
(x,y=q.pop;x<8&&x>=0&&y<8&&y>=0&&m[y][x]>?0&&(m[y][x]=?0;q.push *(-3..3).flat_map{|i|[[x,y+i],[x+i,y]]}))while q!=[]
puts "Data #{n+1}:",m}

Measured memory_bytes: 6116
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define pb(x) push_back(x)
#define int long long

template<class T>
bool compTwo(const vector<T>& a, const vector<T>& b) {
  return a[0]-a[1] > b[0]-b[1];
}

signed main(void) {
  int N;
  cin >> N;

  int V[N];
  vector< vector<int> > pair;
  rep(i, N) {
    cin >> V[i];
  }
  rep(i, N) {
    vector<int> tmp;
    int tmpC;
    cin >> tmpC;
    tmp.pb(V[i]);
    tmp.pb(tmpC);
    pair.pb(tmp);
  }

  int ans;
  // sort by value
  sort(pair.begin(), pair.end(), compTwo<int>);
  ans = 0;
  rep(i, N) {
    int tmp = pair[i][0]-pair[i][1];
    if (tmp >= 0) {
      ans += tmp;
    } else {
      // cout << pair[i][0] << pair[i][1] << endl;
      break;
    }
  } 

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import math
n, d = map(int, input().split())
lst = [0]*n
for i in range(n):
    lst[i] = list(map(int, input().split()))
ans = 0
for i in range(n):
    if math.sqrt(lst[i][0]**2 + lst[i][1]**2) <= d:
        ans += 1
print(ans)


Measured memory_bytes: 45384
require "prime"
arr = [[]]
1.upto(20000){|x| arr << Prime.prime_division(x)}

while true
    n = gets.to_i
    break if n == 0
    h = {2=>0, 5=>0}
    n.downto(2){|x|
        arr[x].each{|prime, beki|
            h[prime] += beki if prime == 2 || prime == 5
            break if prime > 5
        }
    }
    puts h.values.min
end


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

#define rep(i, first, to) for(ll i = first; i < to; ++i)

using namespace :: std;
typedef long long ll;

struct Node {
	int key;
	Node *prev, *next;
};
Node *first;
Node *back;

void init() {
	first = new Node();
	back = first;
	first->next = new Node();
	first->next->prev = first;
	first = first->next;
}
bool isEmpty() {
	return back == first->prev;
}
	
void insert(int x) {
	first->key = x;
	first->next = new Node();
	first->next->prev = first;
	first = first->next;
}
void deleteValue(int x) {
	Node *now = first->prev;
	while(!(now == back)) {
		//cout << "(" << now->key << ", " << x << ")" << endl;
		if(now->key == x) {
			now->prev->next = now->next;
			now->next->prev = now->prev;
			delete now;
			break;
		}
		now = now->prev;
	}
}
int deleteFirst() {
	int v = first->prev->key;
	deleteValue(v);
	return v;
}
int deleteLast() {
	int v = back->next->key;
	Node *n = back->next;
	back->next = back->next->next;
	back->next->prev = back;
	delete n;
	return v;
}
void solve() {
	init();
	int n;
	cin >> n;
	string s;
	int v;
	rep(i, 0, n) {
		//cout << i << endl;
		cin >> s;
		if (s == "deleteFirst") {
			deleteFirst();
		} else if (s == "deleteLast") {
			deleteLast();
		} else {
			cin >> v;
			if (s == "insert") {
				insert(v);
				//cout << "insert : " << v << endl;
			} else if (s == "delete") {
				deleteValue(v);
			}
		}
	}
	if (!isEmpty()) {
		cout << deleteFirst();
	}
	while(!isEmpty()) {
		cout << " " << deleteFirst();
	}
	cout << endl;
}

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

Measured memory_bytes: 34248
import java.util.*;
import java.io.*;

class Main {

	void solve() {
		
		out.println("ABC" + instr());
		
	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}
	
	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}
	
	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

Measured memory_bytes: 21332
sz = int(input(''))
ary = []
for i in range(0,sz):
  s = input()
  ary.append(s)

map = {}
for w in ary:
  if not w in map:
    map[w] = 1
  else:
    map[w] +=1

max = 0
maxes = []
for k,v in map.items():
  if v > max:
    max = v

for k,v in map.items():
  if v == max:
    maxes.append(k)

for m in sorted(maxes):
  print(m)

Measured memory_bytes: 35220
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_027
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long n = long.Parse(input[0]);
            long x = long.Parse(input[1]);
            input = Console.ReadLine().Split(' ');
            var xs = new long[n];
            for (int i = 0; i < n; i++)
            {
                xs[i] = long.Parse(input[i]);
            }
            long[] sums = new long[n];
            sums[0] = xs[0];
            for(int i = 1; i < n; i++)
            {
                sums[i] = sums[i - 1] + xs[i];
            }
            decimal res = decimal.MaxValue;
            for(long k = 1; k <= n; k++)
            {
                decimal tmp = 0;
                decimal cnt = 1;
                for(long now = n - k; now >= 0; now -= k)
                {
                    if (cnt == 1)
                    {
                        tmp += sums[now + k - 1] * 5;
                        if (now > 0) tmp -= sums[now - 1] * 5;
                    }
                    else
                    {
                        tmp += sums[now + k - 1] * (2 * cnt + 1);
                        if (now > 0) tmp -= sums[now - 1] * (2 * cnt + 1);
                    }
                    cnt++;
                }
                long margin = n % k;
                if (margin > 0)
                {
                    tmp += sums[margin - 1] * (2 * cnt + 1);
                }
                tmp += (k + n) * x;
                res = Math.Min(res, tmp);
            }
            Console.WriteLine(res);
        }
    }
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

vector<PLL> G;
vector<PLL> vs;

int64 lcm(int64 a, int64 b) {
	return a / __gcd(a, b) * b;
}

int64 dfs(int64 v) {
	if (v == -1) return 1;
	int64 lw = dfs(G[v].fs), rw = dfs(G[v].sc);
	int64 g = __gcd(vs[v].fs*lw, vs[v].sc*rw);
	int64 lc = vs[v].sc*rw / g, rc = vs[v].fs*lw/g;
	return lc*lw+rc*rw;
}

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

	int64 n;
	while (cin >> n && n) {
		G = vector<PLL>(n);
		vs = vector<PLL>(n);
		vector<int> cnt(n, 0);
		REP(i, n) {
			int64 p, q, r, b;
			cin >> p >> q >> r >> b; r--; b--;
			G[i] = PLL(r, b);
			if (r >= 0) cnt[r]++;
			if (b >= 0) cnt[b]++;
			vs[i] = PLL(p, q);
		}
		int root = -1;
		REP(i, n) {
			if (cnt[i] == 0) root = i;
		}
		cout << dfs(root) << endl;
	}
}



Measured memory_bytes: 3076
var N,K,i,G,A,M:Longint;
function gcd(a,b:Longint):Longint;
begin
if b=0 then gcd:=a else gcd:=gcd(b,a mod b);
end;
begin
read(N,K);
for i:=1 to N do begin
read(A);
G:=gcd(A,G);
if M<A then M:=A;
end;
if(M>=K)and(K mod G=0)then writeln('POSSIBLE')else writeln('IMPOSSIBLE');
end.

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
	int n,pm,pe,pj,i;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&pm,&pe,&pj);
			if(pm==100 || pe==100 || pj==100){
				printf("A\n");
			}else if(((pm+pe)/2)>=90){
				printf("A\n");
			}else if(((pm+pe+pj)/3)>=80){
				printf("A\n");
			}else if(((pm+pe+pj)/3)>=70){
				printf("B\n");
			}else if(((pm+pe+pj)/3)>=50 && (pm>=80 || pe>=80)){
				printf("B\n");
			}else{
				printf("C\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 584
n = list(input())
ans = 0
idx = 0
res = []
flag = 0
while True:
  if idx == 0:
    res.append(n[idx])
    idx += 1
  elif idx == len(n)-1:
    if res[-1] == n[idx]:
      pass
    else:
      res.append(n[idx])    
    flag = 1
  elif res[-1] == n[idx]:
    res.append(n[idx]+n[idx+1])
    idx += 2
  else:
    res.append(n[idx])
    idx += 1
  if idx == len(n):
    flag = 1
  if flag:
    break
  
print(len(res))

Measured memory_bytes: 62192
#include<stdio.h>
int main (){
    int a,b,c,d,e,i,j,k;
    scanf("%d",&a);
    scanf("%d",&b);
    c = a+b;
    d = a-b;
    e = a*b;

    if(c>=d && c>=e)
    {
        printf("%d",c);
    }
    else if(e>=d && e>=c)
    {
        printf("%d",e);
    }
    else  if(d>=c && d>=e)
    {
        printf("%d",d);
    }



}


Measured memory_bytes: 128
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int n;
string s;
map<pair<ll,ll>,int>mapi;
map<ll,int>mapi1;
int compute(int x){
	string s1="",s2="";
	int i;
	rep(i,n){
		if(x&(1<<i)){
			s1+=s[i+1*n];
		}
		else{
			s2+=s[i+1*n];
		}
	}
	ll hash=0;
	rep(i,s1.length()){
		hash=hash*31LL;
		hash+=s1[i]-'a'+2;
		hash%=mod;
	}
	ll hash1=0;
	rep(i,s2.length()){
		hash1=hash1*31LL;
		hash1+=s2[i]-'a'+2;
		hash1%=mod;
	}
	mapi[mp(hash,hash1)]++;
}
int get(int x){
	int i;
	ll val;
	string s1="",s2="",s3="";
	rep(i,n){
		if(x&(1<<i)){
		 	s1+=s[i];
		}
		else{
			s2+=s[i];
		}
	}
	ll hash=0;
	fd(i,s1.length()-1,0){
		hash=hash*31LL;
		hash+=s1[i]-'a'+2;
		hash%=mod;
	}
	ll hash1=0;
	fd(i,s2.length()-1,0){
		hash1=hash1*31LL;
		hash1+=s2[i]-'a'+2;
		hash1%=mod;
	}
	return mapi[mp(hash1,hash)];
}
int main(){
	std::ios::sync_with_stdio(false);
	ll res=0,i,val;
	cin>>n;
	cin>>s;
	val=(1<<n);
	f(i,1,val-1){
		compute(i);
	}	
	rep(i,s.length()){
		if(s[i]!=s[s.length()-1-i]){
			break;
		}
	}
	if(i==s.length()){
		res+=2;
	}
	f(i,1,val-1){
		res+=get(i);
	}
	cout<<res<<endl;
} 
	

Measured memory_bytes: 33024
#                         author:  kagemeka 
#                         created: 2019-11-06 21:30:22(JST)
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    n, m = (int(x) for x in sys.stdin.read().split())
    if n == 1 and m == 1:
        ans = 1
    elif n == 1:
        ans = m - 2
    elif m == 1:
        ans = n - 2
    else:
        ans = (n - 2) * (m - 2)
    
    print(ans)

if __name__ == "__main__":
    # execute only if run as a script
    main()


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

int main() {
    int ans=0, n;
    string s, t;
    cin >> s >> t;
    if(s==t) cout << ans << endl;
    else{
        n = s.size();
        rep(i,n){
        if(s.at(i) != t.at(i)) ans++;
        }
    cout << ans << endl;
    }
}


Measured memory_bytes: 3864
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

pair<int, int> cnt[2][100010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int a[100010];
    rep(i, n) cin >> a[i];
    rep(i, 100001) cnt[0][i] = cnt[1][i] = {0, i};
    rep(i, n) {
        cnt[i % 2][a[i]].first++;
    }
    sort(cnt[0], cnt[0] + 100000, greater<pair<int, int>>());
    sort(cnt[1], cnt[1] + 100000, greater<pair<int, int>>());
    int half = n / 2;
    if(cnt[0][0].second != cnt[1][0].second) {
        cout << n - cnt[0][0].first - cnt[1][0].first << endl;
    } else {
        int b = n - cnt[0][0].first - cnt[1][1].first;
        int c = n - cnt[0][1].first - cnt[1][0].first;
        cout << min(b, c) << endl;
    }

    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define sec second
#define pii pair<int, int>
int n, m, k, x, y, sum, ans;
int main () {
	scanf("%d %d %d", &n, &x, &y);
	for (int i=0; i<n; i++) {
		scanf("%d", &k);
		if (k<x||k>=y)ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#include<tgmath.h>
#include<stdlib.h>
#include<assert.h>
#include<stdio.h>



#define ll long long


/*
_
_._ _..._ . - ',     _.._(`))
'-. `     ' / -._. - '    ', /
)         \            '.
/ _    _ | \
| a    a    /              |
\   . - .;
'-('' ).-', '       ;
'-;           |      .'
\           \    /
| 7.__  _. - \   \
| |  |  ``/ / `  /
/, _|  |   /, _/   /
/, _ / '`-'
*/
using namespace std;

int gcd(int a, int b)
{
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

int main()
{
    /*int n;
    cin >> n;
    ll sum = 0;
    ll i;
    for (i = 1; i <= n; ++i) {
        if (i % 3 == 0 || i % 5 == 0) {

        }
        else {
            sum += i;
        }
            
           
    }
    cout << sum;
    */
    
    /*int k;
    cin >> k;
    ll sum = 0;
    int i, j, l;
    for (i = 1; i <= k; ++i) {
        for (j = 1; j <= k; ++j) {
            for (l = 1; l <= k; ++l) {
                sum += gcd(gcd(i, j), l);
            }
        }
    }
    cout << sum;
    */

    int n;
    cin >> n;
    string str;
    cin >> str;
    int i, j, k;
    vector<int> red(n), blue(n), green(n);
    ll count_r = 0,count_b=0,count_g=0;
    for (i = n - 1; i >= 0; --i) {
        red[i] = count_r;
        blue[i] = count_b;
        green[i] = count_g;
        if (str[i] == 'R') {
            count_r++;
        }
        if (str[i] == 'B') {
            count_b++;
        }
        if (str[i] == 'G') {
            count_g++;
        }
        
    }
    ll sum = 0;
    


    for (i = 1; i < n; ++i) {
        for (j = 0; j < i; ++j) {
            char color = 'R' + 'B' + 'G' - str[i] - str[j];
            

            if (str[i] != str[j]) {
                
                if (color == 'R') {
                    sum += red[i];
                }
                else if (color == 'B') {
                    sum += blue[i];
                }
                else if (color == 'G') {
                    sum += green[i];
                }

                if (i+i-j<n&&(str[i + i - j] != str[i] && str[i + i - j] != str[j])) {
                    sum--;
                }
            }
        }
    }

    cout << sum;
    

}



Measured memory_bytes: 3692
package main

import (
	"bufio"
	"fmt"
	"os"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	S, T := nextLine(), nextLine()
	if S == T[:len(T)-1] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()

	ans := 1
	if n == 2 {
		ans--
	}
	nn := n - 1
	for i := 2; i*i <= nn; i++ {
		if nn%i == 0 {
			ans += 2
		}
		if i*i == nn {
			ans--
		}
	}

	fn := func(a int) bool {
		t := n
		for t%a == 0 {
			t /= a
		}
		if t%a == 1 {
			return true
		}
		return false
	}

	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			a := i
			b := n / i
			if a != 1 && fn(a) {
				ans++
			}
			if a != b && fn(b) {
				ans++
			}
		}
	}

	fmt.Fprintln(wr, ans)

}


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

int main() {
  int N;
  cin >> N;
  vector<double> X(N), Y(N);

  double sum = 0;

  for (int i = 0; i < N; i++) {
    cin >> X.at(i) >> Y.at(i);
    for (int j = 0; j < i; j++) {
      sum += hypot(X.at(i) - X.at(j), Y.at(i) - Y.at(j));
    }
  }

  cout << setprecision(16) << sum / N * 2 << "\n";
}

Measured memory_bytes: 256
#include<cstdio>
int a[2001][2001],sum1[2001][2001],sum2[2001][2001],sum[2001][2001],n,m,q;
char c[2005];
int main()
{
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;++i){
		scanf("%s",c);
		for(int j=0;j<m;++j)a[i][j+1]=c[j]-48,sum[i][j+1]=sum[i-1][j+1]+sum[i][j]-sum[i-1][j]+a[i][j+1];
	}
	for(int i=1;i<n;++i)for(int j=1;j<=m;++j)sum1[i][j]=sum1[i-1][j]+sum1[i][j-1]-sum1[i-1][j-1]+(a[i][j]&a[i+1][j]);
	for(int i=1;i<=n;++i)for(int j=1;j<m;++j)sum2[i][j]=sum2[i-1][j]+sum2[i][j-1]-sum2[i-1][j-1]+(a[i][j]&a[i][j+1]);
	while(q--){
		int x,y,z,w,b,c,d;
		scanf("%d%d%d%d",&x,&y,&z,&w);
		b=sum[z][w]-sum[z][y-1]-sum[x-1][w]+sum[x-1][y-1];
		c=sum2[z][w-1]-sum2[z][y-1]-sum2[x-1][w-1]+sum2[x-1][y-1];
		d=sum1[z-1][w]-sum1[z-1][y-1]-sum1[x-1][w]+sum1[x-1][y-1];
		printf("%d\n",b-c-d);
	}
	return 0;
}

Measured memory_bytes: 64256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;
 
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; }
 
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }
 
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
 
inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}
 
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

char G[1005][1005];
int cost[1005][1005];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int h,w; cin>>h>>w;
  rep(i,h)rep(j,w) cin>>G[i][j];
  memset(cost,-1,sizeof(cost));
  
  queue<pii> q;
  rep(i,h) rep(j,w){
    if(G[i][j]=='#'){
      q.emplace(i,j);
      cost[i][j]=0;
    }
  }
  
  while(!q.empty()){
    int y=q.front().first;
    int x=q.front().second;
    q.pop();
    rep(i,4){
      int ny=dy[i]+y;
      int nx=dx[i]+x;
      if(inside(ny,nx,h,w) && G[ny][nx]=='.'){
        if(cost[ny][nx]==-1){
          cost[ny][nx]=cost[y][x]+1;
          q.emplace(ny,nx);
        }
      }
    }
  }
  
  int ans=0;
  rep(i,h) rep(j,w) chmax(ans,cost[i][j]);
  cout<<ans<<endl;
}

Measured memory_bytes: 13328
#include<stdio.h>

/*各桁の和を求める関数*/
int sumOFDecimal(int n)
{
	int ret = 0;
	while(n!=0){
		ret += n%10;
		n/=10;
	}
	return ret;
}

int main(void)
{
	int N,A,B;
	int ans = 0;
	int i;
	scanf("%d %d %d",&N,&A,&B);
	
	/*1からNまでの整数のうち、各桁の和がA以上B以下のものを足していく*/
	for (i=1;i<=N;i++){
		int tmp = sumOFDecimal(i);
		if(tmp>=A&&tmp<=B){
			ans += i;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
n = int(input())
s = []
while True:
    try:
        s.append(input())
    except EOFError:
        break

word_counter = {}
for word in s:
    if word in word_counter:
        word_counter[word] += 1
    else:
        word_counter[word] = 0

results = sorted(word_counter.items(), key=lambda x: x[1], reverse=True)
max_v = results[0][1]

pick_ups = [result[0] for result in results if result[1] == max_v]
sorted_pick_ups = sorted(pick_ups)
print(*sorted_pick_ups, sep='\n')

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

int main(void)
{
  int n, a;
  
  int c = 0, j = 0;
  cin >> n;
  
  for(int i = 0; i < n; i++) {
    cin >> a;
    if(a == j+1) {
      j++;
    } else {
      c++;
    }
  }
  if(j > 0) {
	cout << c << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
s = input()

l = list(s)
#l=list(set(l))
#l.sort()
#print(l)

l_abc = list("abcdefghijklmnopqrstuvwxyz")

l = list(set(l_abc) - set(l))
l.sort()

#print(l)
#print(len(l))

if len(l) == 0:
	print("None")
else:
	print(l[0])


Measured memory_bytes: 3956