akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"

struct frame {
	int type;
	vector<int>pins;
	int score;
	frame():type(0), pins(), score(0){

	}
};
int getscore() {
	vector<frame>frames(10);
	int now = 0;
	int num = 0;
	int sum = 0;
	vector<pair<int, int>>ps;
	bool flag = false;
	while (1) {
		int n; cin >> n;
		if (now != 9) {
			if (num == 0) {
				frames[now].pins.push_back(n);
				sum += n;
				if (sum == 10) {
					now++;
					num = 0;
					sum = 0;
					ps.push_back(make_pair(2, n));
				}
				else {
					num++;
					ps.push_back(make_pair(0, n));
				}
			}
			else if (num == 1) {
				frames[now].pins.push_back(n);
				sum += n;
				if (sum == 10) {
					ps.push_back(make_pair(1, n));
				}
				else {
					ps.push_back(make_pair(0, n));
				}
				sum = 0;
				num = 0;
				now++;
			}
		}
		else {
			if (num == 0) {
				sum += n;
				if (sum == 10) {
					sum = 0;
					ps.push_back(make_pair(0, n));
					flag = true;
				}
				else {
					ps.push_back(make_pair(0, n));
				}
			}
			else if (num == 1) {
				sum += n;
				if (sum == 10) {
					sum = 0;
					ps.push_back(make_pair(0, n));
					flag = true;
				}
				else {
					ps.push_back(make_pair(0, n));
				}
				if (!flag)break;
			}
			else if (num == 2) {
				sum += n;
				ps.push_back(make_pair(0, n));
				break;
			}
			num++;
		}
		
	}
	int score = 0;
	for (int i = 0; i < ps.size(); ++i) {
		for (int j = i; j <= i + ps[i].first; ++j) {
			score += ps[j].second;
		}
	}
	return score;
}

int main() {
	
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<pair<int, int>>ps;
		for (int i = 0; i < N; ++i) {
			int num; cin >> num;
			int ans = getscore();
			ps.emplace_back(ans, 10000 - num);
		}
		sort(ps.begin(), ps.end(), greater<pair<int, int>>());
		for (auto p : ps) {
			cout << 10000 - p.second << " " << p.first << endl;
		}
	}
	return 0;
}

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

int mod_pow(int n, int e, int mod){
    int ans = 1;
    n = n % mod;
    while(e != 0){
        if(e % 2 == 1){
            ans = (ans * n) % mod;
        }
        e /= 2;
        n = (n * n) % mod;
    }
    return ans;
}

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int m, n;
    cin >> m >> n;
    int mod = 1e9 + 7;
    cout << mod_pow(m, n, mod) << endl;

    return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
 
#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
 
int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}
 
int n,m;
int ans = 0;
vector<vp> v;
 
void dfs(vi used, vs s, int cnt){
    ans = max(ans, cnt);
    rep(i,26)if(used[i] == 0 && v[i].size()){
        int diff = abs(v[i][0].first - v[i][1].first) + abs(v[i][0].second - v[i][1].second);
        if(diff <= 1)continue;
        bool c = true;
        if(v[i][0].first == v[i][1].first){
            int x = v[i][0].first;
            int mi = min(v[i][0].second,v[i][1].second);
            int ma = max(v[i][0].second,v[i][1].second);
            vi alph(26);
            loop(y,mi+1,ma){
                if(s[x][y] != '.')c = false;
            }
        }else if(v[i][0].second == v[i][1].second){
            int y = v[i][0].second;
            int mi = min(v[i][0].first,v[i][1].first);
            int ma = max(v[i][0].first,v[i][1].first);
            vi alph(26);
            loop(x,mi+1,ma){
                if(s[x][y] != '.')c = false;
            }
        }else{
            bool f = false;
            int xmi = min(v[i][0].first,v[i][1].first);
            int xma = max(v[i][0].first,v[i][1].first);
            int ymi = min(v[i][0].second,v[i][1].second);
            int yma = max(v[i][0].second,v[i][1].second);
            rep(z,2){
                int p = v[i][z].first, q = v[i][!z].second;
                if(s[p][q] != '.')continue;
                bool cc = true;
                loop(y,ymi+1,yma){
                    if(s[p][y] != '.')cc = false;
                }
                loop(x,xmi+1,xma){
                    if(s[x][q] != '.')cc = false;
                }
                if(cc){
                    f = true;
                }
            }
            if(f == false)c = false;
        }
        if(c){
            //cout << i << endl;
            used[i]++;
            rep(j,2)s[v[i][j].first][v[i][j].second] = '.';
            cnt++;
            dfs(used,s,cnt);
return;
            used[i]--;
            rep(j,2)s[v[i][j].first][v[i][j].second] = 'A'+i;
            cnt--;
        }
    }
}
 
signed main(void) {
    cin >> n >> m;
    vs s(n);
    rep(i,n) cin >> s[i];
    v = vector<vp> (26);
    rep(i,n)rep(j,m)if(s[i][j] != '.'){
        int a = s[i][j] - 'A';
        v[a].push_back(pii(i,j));
    }
    dfs(vi(26,0),s,0);
    cout << ans*2 << endl;
}


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

int main()
{
	int a,b,c,x,i,j,k,s=0;
	cin>>a>>b>>c>>x;
	
	for(i=0;i<=a;i++)
		for(j=0;j<=b;j++)
			for(k=0;k<=c;k++)
			{
				if(i*500+j*100+k*50==x) s++;
			}
	
	cout<<s<<endl;
}

Measured memory_bytes: 256
N=int(input())
lis=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
l2.sort(key=lambda x:x[2],reverse=True)
for i in lis:
    n=N
    l=0
    for j in l2:
        k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
        if j[2]==0:
            if k>l:
                n-=1
            else:
                if l==k or l==0:
                    l=k
                    n-=1
                else: break
        else:
            if l==k or l==0:
                l=k
                n-=1
            else: break
        if n==0:
            m=(i[0],i[1],l)
print('{} {} {}'.format(m[0],m[1],m[2]))

Measured memory_bytes: 4084
#include <stdio.h>

int main(void){

	char line[11],line1[30];
	int i=0,sum=0;

	scanf("%s",line);
		while(line[i]){
			if(isupper(line[i]))
				line[i]=tolower(line[i]);
			i++;
		}
		for(;i=0,scanf("%s",line1),strcmp(line1,"END_OF_TEXT");){
			while(line1[i]){
				if(isupper(line1[i]))
					line1[i]=tolower(line1[i]);
				i++;
			}
			if(!strcmp(line1,line))
				sum++;
			}
		printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 552
#include<bits/stdc++.h>
using namespace std;
int n, m, q, ss[2007][2007], s1[2007][2007], s2[2007][2007];
char s[2007][2007];
int read()
{
	int num = 0;
	char c = getchar();
	while (c < '0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
int main()
{
	scanf("%d%d%d", &n, &m, &q);
	for (int i = 1; i <= n; i++)
		scanf("%s", s[i] + 1);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			if (s[i][j] == '1')
				ss[i][j]++;
	for (int i = 2; i <= n; i++)
		for (int j = 1; j <= m; j++)
			if (s[i][j] == '1' && s[i - 1][j] == '1')
				s1[i][j]++;
	for (int i = 1; i <= n; i++)
		for (int j = 2; j <= m; j++)
			if (s[i][j] == '1' && s[i][j - 1] == '1')
				s2[i][j]++;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			ss[i][j] += ss[i - 1][j];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			ss[i][j] += ss[i][j - 1];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			s1[i][j] += s1[i - 1][j];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			s1[i][j] += s1[i][j - 1];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			s2[i][j] += s2[i][j - 1];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			s2[i][j] += s2[i - 1][j];
	for (int i = 1; i <= q; i++)
	{
		int x1 = read(), y1 = read(), x2 = read(), y2 = read();
		int res = (ss[x2][y2] - ss[x1 - 1][y2] - ss[x2][y1 - 1] + ss[x1 - 1][y1 - 1]);
		res -= (s1[x2][y2] - s1[x1][y2] - s1[x2][y1 - 1] + s1[x1][y1 - 1]);
		res -= (s2[x2][y2] - s2[x1 - 1][y2] - s2[x2][y1] + s2[x1 - 1][y1]);
		printf("%d\n", res);
	}
	return 0;
}

Measured memory_bytes: 52864
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		long m = sc.nextInt();

		System.out.println(Math.abs((n - 2) * (m - 2)));

		sc.close();

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(), (x).end()
// #define LOCAL
using namespace std;
int main()
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	cout << (n + n % 2) / 2;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define PI 3.1415926
int main(void){
	int a,b,c;
	double S,L,h,rad;
	scanf("%d%d%d",&a,&b,&c);
	rad = PI * c/180;
	h = b * sin(rad);
	S = a * h / 2;
	L = a + b + sqrt(a*a + b * b - 2 * a * b * cos(rad));
	printf("%lf\n%lf\n%lf\n",S,L,h);
	return 0;
}

Measured memory_bytes: 632
a = list(map(int,input().split()))
x = []
y = []
for i in range(a[1]):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
 
#s = str(2)
#print(s[-1])

def start(n):
  if n == 1:
    return 0
  else:
    return 10**(n-1)
    
flag = False
for i in range(start(a[0]),10**a[0]):
  s = str(i)
  flag = True
  for j in range(len(x)):
    if str(y[j]) != s[x[j]-(a[0]+1)]:
      flag = False
      break
  if flag:
    break
      

if flag:
  print(i)
else:
  print(-1)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

vint getPrimeTable(int x)
{
	vint res(x + 1);
	
	REP(i, 2, x + 1)
	{
		res[i] = 1;
		
		for(int j = 2; j * j <= i; j++)
		{
			if(i % j == 0)
			{
				res[i] = 0;
				break;
			}
		}
	}
	
	return res;
}

int main()
{
    vint table(getPrimeTable(10000));
	
	for(int x; cin >> x && x;)
	{
		for(int i = x; 0 <= x; i--) if(table[i] && table[i - 2])
		{
			cout << i - 2 << " " << i << endl;
			break;
		}
	}
}

Measured memory_bytes: 0
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        s: Chars
    }

    if s.len() == 2 {
        if s[0] == s[1] {
            println!("1 2");
        } else {
            println!("-1 -1");
        }
        return;
    }

    for i in 0..s.len()-3 {
        let ss = &s[i..i+3];
        if ss[1..].contains(&ss[0]) {
            println!("{} {}", i+1, i+3);
            return;
        }
    }
    println!("-1 -1");
}


Measured memory_bytes: 2464
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int h,w,K;cin>>h>>w>>K;
    char s[h][w];
    rep(i,h)rep(j,w) cin>>s[i][j];
    int res=1000000;
    for(int tmp=0;tmp<(1<<h);tmp+=2){
        vector<int> id;
        int now=0;
        id.push_back(0);
        bitset<10> t(tmp);
        rep(i,h)if(t[i]==1&&i!=0)id.push_back(i);
        id.push_back(h);
        int x=id.size();
        now=x-2;
        bool jud=false;//この横の切り込み方では1通りも完成しないフラグ
        vector<int> buf(x-1,0);
        rep(i,w){
            //iは現在左から何マス目を見ているのか、jは区画の番号、kはその区画で上から何番目を見ているのか
            vector<int> cur(x-1,0);
            bool jud2=false;//一つ手前で切り込みを入れるべきフラグ
            rep(j,x-1){
                int r=id[j],l=id[j+1];
                for(int k=r;k<l;k++) if(s[k][i]=='1')cur[j]++;
                if(cur[j]>K){
                    jud=true;
                    break;
                }
                if(buf[j]+cur[j]>K){
                    jud2=true;
                    continue;
                }
            }
            
            if(jud)break;
            if(jud2){
                //cout<<i<<endl;
                now++;
                rep(j,id.size()-1)buf[j]=cur[j];
            }
            else rep(j,id.size()-1){
                buf[j]+=cur[j];
            }
        }
        if(jud)continue;
        res=min(res,now);
    }
    cout<<res<<endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef pair<ll,P>  PP;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;
typedef priority_queue<PP, vector<PP>, greater<PP>> PPQueue;

#define fi          first
#define se          second
#define sfi         se.fi
#define sse         se.se
#define pb          push_back
#define INF         INT_MAX
#define MOD         1000000007
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     (upper_bound(all(x),y)-x.begin())
#define lb(x,y)     (lower_bound(all(x),y)-x.begin())
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
ll n;
string s;

bool same_num(bool ta, char ts){
  return(ta == 0 && ts == 'o' || ta == 1 && ts == 'x');
}

bool judge(Vector &a,ll i){
  if(same_num(a[i],s[i]))return a[(n+i+1)%n] == a[(n+i-1)%n];
  else return a[(n+i+1)%n] != a[(n+i-1)%n];
}

Vector ans;
bool dfs(ll idx, Vector &a){
  if(idx == n-1){
    if(judge(a,n-1) && judge(a,0)){
      ans = a;
      return true;
    }else return false;
  }

  if(same_num(a[idx],s[idx])){
    a[idx+1] = a[idx-1];
    return dfs(idx+1,a);
  }else{
    a[idx+1] = (a[idx-1]+1) % 2;
    return dfs(idx+1,a);
  }
}

int main(){
  cin.sync_with_stdio(false);
  cin >> n;
  cin >> s;
  Vector a(n,-1);
  bool jd = false;
  a[0] = 0;
  a[1] = 0;
  jd = jd || dfs(1,a);
  a[0] = 0;
  a[1] = 1;
  jd = jd || dfs(1,a);
  a[0] = 1;
  a[1] = 0;
  jd = jd || dfs(1,a);
  a[0] = 1;
  a[1] = 1;
  jd = jd || dfs(1,a);

  if(jd){
    rep(i,n)cout << (ans[i] == 0 ? 'S' : 'W');
    cout << endl;
  }else{
    cout << -1 << endl;
  }
}


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

int main() {
	//ios_base::sync_with_stdio(false);
	//cout<<setprecision(20);
	int a,b;
	cin>>a>>b;
	if(a+b==15){ 
	    cout<<"+";
	    return 0;
	}
	if(a*b==15){
	    cout<<"*";
	    return 0;
	}
	cout<<"x";
	return 0;
}

Measured memory_bytes: 256
a = input()
b = input()
c = input()

ans = ''
next = a[0]
a = a[1:]
for i in range(len(a) + len(b) + len(c)):
    if next == 'a':
        if len(a) == 0:
            ans = 'A'
            break
        next = a[0]
        a = a[1:]
    if next == 'b':
        if len(b) == 0:
            ans = 'B'
            break
        next = b[0]
        b = b[1:]

    if next == 'c':
        if len(c) == 0:
            ans = 'C'
            break
        next = c[0]
        c = c[1:]

print(ans)

Measured memory_bytes: 3064
#include<iostream>

using namespace std;
int main(){
    string n;
    cin>>n;
    long long int ans=0;
    for(int i=0;i<n.size();i++){
        ans+=int(n[i]-'0');
        
    }
ans%=9;
    if(ans==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


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

#define MOD 1000000007 // 10^9 + 7
#define MAX 20000
using namespace std;


long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  // 前処理
  COMinit();

  int n, k;

  scanf("%d%d", &n, &k);

  for (int i = 1; i <= k; i++) {
    long long int ans = ( COM(k-1, i-1) * COM(n-k+1, i) ) % MOD;
    printf("%lld\n", ans);
  }

  return 0;
}


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  string s, t;
  cin >> s >> t;

  int a = stoi(s + t);

  if ((int)sqrt(a) * (int)sqrt(a) == a) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long aa,bb,n;
	scanf("%lld%lld%lld",&n,&aa,&bb);
	if(aa==0)
	{
		printf("0\n");
		return 0;
	}
	long long ans=n/(aa+bb)*aa;
	ans+=min(n%(aa+bb),aa);
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<pair<int,int>> v;
  for(int i=0;i<n;i++){
     int t;
     cin>>t;
     v.push_back(make_pair(t,i));
  }
  sort(v.begin(),v.end());
  for(int j=0;j<n;j++){
    cout<<v[j].second +1<<" ";
  }

}



Measured memory_bytes: 1780
N,M,Q = map(int, input().split())
abcd = [tuple(map(int, input().split())) for _ in range(Q)]

ans = 0

def check(lst):
    global ans
    tmp = 0
    for i in range(Q):
        a,b,c,d = abcd[i]
        if lst[b-1] == lst[a-1] + c:
            tmp += d
    ans = max(ans, tmp)

def solve(idx, lst):

    if idx >= N:
        check(lst)
        return
    
    if idx <= 0:
        lo = 1
    else:
        lo = lst[idx-1]

    for i in range(lo, M+1):
        
        lst[idx] = i
        solve(idx+1, lst)


lst = [0] * N
for i in range(1, M+1):
    solve(0, lst)
    

print(ans)

Measured memory_bytes: 79464
from itertools import product
from itertools import chain


H, W, K = map(int, input().split())
res = 0



C = []
for _ in range(H):
    C.append(list(input()))

for a in product(*((0, 1) for _ in range(H))):
    for b in product(*((0, 1) for _ in range(W))):
        D = []
        E = []
        for i in range(H):
            if a[i]:
                D.append(C[i])
        if not D:
            break
        D = list(zip(*D))
        for j in range(W):
            if b[j]:
                E.append(D[j])
        F = list(chain.from_iterable(E))
        if F.count("#") == K:
            res += 1

print(res)

Measured memory_bytes: 69004
#include <bits/stdc++.h>
#define N 4
using namespace std;
typedef long long ll;
bool used[N];
  
ll SumD(ll a,ll d,ll n){return (n*(2*a+(n-1)*d))/2;}
  
bool mark(ll n){
  bool res=1;
  for(ll i=1;i*i<=N;i++)res&=!used[i],used[i]=1;
  return res;
}
  
int main(){
  while(1){
    ll n,m,p[21];
    cin>>n>>m;
    if(!n&&!m)break;
    for(int i=0;i<m;i++)cin>>p[i];
    sort(p,p+m);
    
    ll sum=0,cnt=0;
    for(int i=0;i<m;i++){
      sum+=SumD(p[i],p[i],n/p[i]);
      cnt+=n/p[i];
      memset(used,0,sizeof(used));
      for(int j=0;j<i;j++){
    ll lcm=(p[i]/__gcd(p[i],p[j]))*p[j];
    if(!mark(lcm))continue;
    sum-=SumD(lcm,lcm,n/lcm);
    cnt-=(n/lcm);
      }
    }
    printf("%.8f\n",(1.0*SumD(1,1,n)-sum)/max(1LL,(n-cnt)));
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

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() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    vi h(n+2);
    REP(i,n)cin>>h[i];
    vi dp(n+5, INT_MAX);
    dp[0]=0;

    FOR(i,0,n-1){
        chmin(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
        if(i<n-2)
            chmin(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
        //DEBUG_VEC(dp);
    }
    
    int ans = dp[n-1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define sum(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}
vector<vector<pair<int, int>>> graph(100000);
vector<int> color(100000, 0);

void paint(int now) {
  FOR(i, graph[now]) {
    if (color[i.first] != 0) continue;
    if (i.second % 2) {
      color[i.first] = color[now] * -1;
      paint(i.first);
    } else {
      color[i.first] = color[now];
      paint(i.first);
    }
  }
}

class DEvenRelation {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    cin >> N;
    rep(i, N - 1) {
      int u, v, w;
      cin >> u >> v >> w;
      graph[u - 1].emplace_back(v - 1, w);
      graph[v - 1].emplace_back(u - 1, w);
    }
    color[0] = 1;
    paint(0);
    rep(i, N) {
      if (color[i] == 1) {
        cout << 0 << endl;
      } else {
        cout << 1 << endl;
      }
    }
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  DEvenRelation solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 9472
x, y = gets.split.map(&:to_i)

ans = 'No'

if y.odd?
  ans = 'No'
elsif y/2 == x
  ans = 'Yes'
elsif y/2 > x
  ((y/2)/2).times{|i|
    cras = (y/2) - 2*(i+1)
    turs = (i+1)
    if cras + turs == x
      ans = 'Yes'
    end
    }
end

puts ans

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

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

    vector<char> s;
    int now = 0;
    int bit = 1;
    if (n == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    while (n != 0)
    {
        if (n % 2 != 0) 
        {
            s.push_back('1');
            n -= 1;
        }
        else
            s.push_back('0');
        
        n /= -2;
    }
    reverse(s.begin(), s.end());
    rep(i, s.size())
        cout << s[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define lli long long int
#define INF 1e9+5
using namespace std;
int absdiff(int a, int b){
	if(a>b)
	return a-b;
	else return b-a;
}
int main()
{
	int n;
	cin>>n;
	vector<int> h;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		h.push_back(x);
	
	}
	//dp[i] minimum cost to reach this step
	vector<int> dp(n,INF);
	dp[0]=0, dp[1]=absdiff(h[1],h[0]);
	for(int i=2;i<n;i++){
		
		dp[i]=min(dp[i-1]+absdiff(h[i],h[i-1]),dp[i-2]+absdiff(h[i],h[i-2]));
	
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int 

//power of 2 ...n&(n-1)==0


int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//for(ll t=0;t<testcase;t++)
	{
		string s,t;
		cin>>s>>t;
		int ans=0;
		for(int i=0;i<(int)s.length();i++)
		{
			if(s[i]!=t[i])
				ans++;
		}
		cout<<ans<<'\n';
			
	}
	return 0;
}




























Measured memory_bytes: 3792
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)

int main() {

	int n, cnt = 0; cin >> n;

	vector<int> p(n);
	rep(i, 0, n) cin >> p[i];

	rep(i, 1, n - 1) {
		if (p[i] > p[i - 1] && p[i] < p[i + 1]) cnt++;
		else if (p[i] < p[i - 1] && p[i] > p[i + 1]) cnt++;
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
/**
 * Created by hiroqn on 13/10/08.
 */
var fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();

function main() {
  var
      isMinus = input[0][0] === '-',
      str = isMinus ? input[0].slice(1) : input[0],
      ss1, ss2,//separate string
      si1, si2,
      i,
      ans = 0;
  if ((str - 0) % 2 === 0) {
    ans++;
  }
  for (i = 1; i < str.length; i++) {
    ss1 = str.slice(0, i);
    ss2 = str.slice(i);
    if (ss2[0] === '0') {
      continue;
    }
    si1 = ss1 - 0;
    si2 = ss2 - 0;
//    console.log(ss1, ss2);
    if (si1 > si2) {
      break;
    }
    if ((si1 + si2) % 2 === 0) {
      ans++;//      console.log((si1 + si2) / 2, (si2 - si1) / 2);
    }
  }
  console.log(ans);
}

Measured memory_bytes: 7388
#include <iostream>
#include<string>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;


int main() {
	int A, B, K;
	const string NG = "IMPOSSIBLE";
	cin >> A >> B;
	if ((A + B) % 2 == 0) {
		cout << (A + B) / 2 << endl;
	}
	else {
		cout << NG << endl;
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

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 * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ld ans = 0;
  // ll n;
  // cin >> n;
  // ll n, m;
  // cin >> n >> m;
  ld a, b, x;
  cin >> a >> b >> x;
  if(x * 2 >= a * a * b)
    ans = atan2(2 * (a * a * b - x) / (a * a), a);
  else
    ans = atan2(b, 2 * x / (a * b));
  cout << setprecision(9) << ans * 180 / pi << endl;
  return 0;
}



Measured memory_bytes: 256
N,D = map(int,input().split())
X = []
for i in range(N):
    X.append(list(map(int,input().split())))

ans = 0
for i in range(N):
    for j in range(i+1,N):
        d = 0
        for k in range(D):
            d += (X[i][k] - X[j][k])**2
        d = d**(1/2)
        if int(d) == d:
            ans +=1

print(ans)    

Measured memory_bytes: 9356
N, K  = map(int, input().split())

ans = 0
for i in range(K, N+2):
    minN = (i-1) * i //2
    maxN = (2*N-i+1) * i //2
    ans += (maxN - minN + 1) % (pow(10,9)+7)

print(ans % (pow(10,9)+7))

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
void output(const vector<int>& a) {
	for (int c : a) {
		cout << ((c&1)?"#":".");
	}
	cout << endl;
	for (int c : a) {
		cout << ((c&2)?"#":".");
	}
	cout << endl;
}
int main() {
	int N;
	cin >> N;
	int mode = 0;
	vector<int> a;
	for (;;) {
		if (!mode) {
			a.push_back(0);
		} else {
			a.insert(a.begin(), 0);
		}
		for (int i = 0; i < 4; ++ i) {
			a[mode ? 0 : a.size()-1] = i;
			output(a);
			string s;
			cin >> s;
			if (s == "end") return 0;
			if (s == "T") goto next;
		}
		if (mode) throw 1;
		a.pop_back();
		mode = 1;
		next:;
	}
}


Measured memory_bytes: 596
import java.util.*;

public class Main {
	public static void main(String[] args) {
		C();
		return;
	}
	
	public static void A() {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		if(A==B) System.out.println(C);
		else if(B==C) System.out.println(A);
		else System.out.println(B);
	}

	// #を読めば、その周囲に数字を入れる
	// -1は#に対応する 空間O(n)
	//あるいは、ますの８方向を確認する　時間O(n)　空間O(1）
	
	public static void calc8(char[][] cell ,int h, int w) {
		if(cell[h][w] == '#') System.out.print('#');
		else {
			int[] hs = new int[] {h-1,h,h+1};
			int[] ws = new int[] {w-1,w,w+1};
			int sum = 0;
			for(int nh: hs) {
				for(int nw : ws) {
					if(nh<cell.length && nh>=0 && nw >=0 && nw < cell[0].length) {
						if(cell[nh][nw]=='#') sum++;
					}
				}
			}
			System.out.print(sum);
		}
		if(w == cell[0].length-1) System.out.println("");
	}
	
	public static void B() {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		char[][] cell = new char[H][W];
		for(int i=0;i<H;i++) {
			String s = sc.next();
			for(int j=0; j<W;j++) {
				cell[i][j] = s.charAt(j);
			}
		}
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				calc8(cell,i,j);
			}
		}
	}
	
	
	//グラフが大きいならば、双方向探索も有効
	//最初は連結と仮定した場合
	// 隣接行列matに置いて、iとjが連結か調べる　WFS
	public static boolean connect(int[][] mat, int i, int j) {
		boolean[] visit = new boolean[mat.length];
		LinkedList<Integer> que = new LinkedList<Integer>();
		que.add(i);
		while(!que.isEmpty()) {
			int check = que.removeFirst();
			if(check == j) return true;
			//System.out.println(check + " check");
			visit[check] = true;
			for(int w=0;w<mat.length;w++) {
				if (mat[check][w] == 1 && (!visit[w])) {
					//System.out.println(mat[check][w] + "e");
					que.add(w);
					visit[w] = true;
				}
			}
		}
		return false;
	}
	public static void C() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[][] mat = new int[N][N];
		int[][] edge = new int[M][2];
		for(int i=0;i<M;i++) {
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			mat[a][b] = mat[b][a] = 1;
			edge[i] = new int[] {a,b};
		}
		int count = 0;
		for(int i=0;i<M;i++) {
			int a = edge[i][0];
			int b = edge[i][1];
			mat[a][b] = mat[b][a] = 0;
			if(!connect(mat,a,b)) count++;
			mat[a][b] = mat[b][a] = 1;
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 25172
#include <iostream>

using namespace std;

int main() {
  int n,x;
  int ans;
  while(true){
    ans = 0;
    cin >> n >> x;
    if(n == 0 && x == 0) break;
    for(int i = 1; i <= n-2; ++i){
      for(int j = i+1; j <= n-1; ++j){
        if(i == j) continue;
        for(int k = j+1; k <= n; ++k){
          if(i == k || j == k) continue;
          if(i+j+k == x){
            ++ans;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;

int main()
{
	ll a, b;
	cin >> a >> b;
	if(b - a >= 2019) {
		cout << 0 << endl;
		return 0;
	}
	a %= 2019;
	b %= 2019;
	ll mi = 1e9;
	ll ans = 0;
	
	for(ll i = a; i <= b; i++) {
		for(ll j = a; j <= b; j++) {
			if(j == i) continue;
			ans = (i*j) % 2019;
			mi = min(mi, ans);
		}
	}
	cout << mi << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <queue>
#define inf 0x3f3f3f3f
#define cases(t) for (int cas = 1; cas <= int(t); ++cas)
typedef long long ll;
typedef double db;
using namespace std;

#ifdef NO_ONLINE_JUDGE
#define LOG(args...) do { cout << #args << " -> "; err(args); } while (0)
void err() { cout << endl; }
template<typename T, typename... Args> void err(T a, Args... args) { cout << a << ' '; err(args...); }
#else
#define LOG(...)
#endif

ll i, o, t, j, l, s, z;

int main() {
    scanf("%lld%lld%lld%lld%lld%lld%lld", &i, &o, &t, &j, &l, &s, &z);
    ll mn = min(i, min(j, l));
    ll ans1 = o * 2 + mn * 6;
    ans1 += (i - mn) / 2 * 4 + (j - mn) / 2 * 4 + (l - mn) / 2 * 4;
    mn = max(mn - 1, 0ll);
    ll ans2 = o * 2 + mn * 6;
    ans2 += (i - mn) / 2 * 4 + (j - mn) / 2 * 4 + (l - mn) / 2 * 4;
    printf("%lld\n", max(ans1, ans2) / 2);
    return 0;
}


Measured memory_bytes: 256
n, m, l = map(int, input().split())

A = [list(map(int,input().split())) for i in range(n)]

B = [list(map(int,input().split())) for i in range(m)]

C = [[0 for i in range(l)] for j in range(n)]

for i in range(0, n):
  for j in range(0, l):
    for k in range(0, m):
      C[i][j] = C[i][j] + A[i][k] * B[k][j] 

for i in range(0, n):
  print(*C[i])   
      


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

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

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;

int main() {
    vector<int> AB(6);
    vector<int> cnt(4);
    for (int i = 0; i < 6; i++) {
        cin >> AB[i];
        cnt[AB[i] - 1]++;
    }

    int res1 = 0, res2 = 0;
    for (int i = 0; i < 4; i++) {
        if (cnt[i] == 1) res1++;
        else if (cnt[i] == 2) res2++;
    }
  
    if (res1 == 2 && res2 == 2) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cassert>
using namespace std;
const int MAXN = 2e4 + 10;

int n, p[MAXN], a[MAXN], b[MAXN];
int mb;

int main(){
	scanf("%d", &n);
	for ( int i = 0; i < n; i++ ){
		scanf("%d", p + i); --p[i]; }
	
	for ( int i = 0; i < n; i++ )
		a[i] = 2 * i + 1;
	for ( int i = 0; i < n; i++ )
		b[i] = n - i;
	
	bool flag = true;
	for ( int rekt = 0; flag && rekt < n; rekt++ ){
		flag = false;
		for ( int i = n - 2; i + 1; i-- ){
			int x = p[i], y = p[i + 1];
			
			if ( a[x] + b[x] < a[y] + b[y] )
				continue;
			int offs = a[x] + b[x] - a[y] - b[y] + 1;
			
			flag = true;
			
			for ( int j = 0; j < x; j++ )
				b[j] += offs;
			for ( int j = x + 1; j < n; j++ )
				a[j] += offs;
			
		}
	}
	
	for ( int i = 0; i < n; i++ ) printf("%d ", a[i]); printf("\n");
	for ( int i = 0; i < n; i++ ) printf("%d ", b[i]); printf("\n");
	
	return 0;
}


Measured memory_bytes: 768
// C++ program to find Excel 
// column name from a given 
// column number 
#include <bits/stdc++.h> 
#define MAX 80 
using namespace std; 
#define int long long 
// Function to print Excel column name for a given column number 
void printString(int n) 
{ 
	char str[MAX]; // To store result (Excel column name) 
	int i = 0; // To store current index in str which is result 

	while (n > 0) { 
		// Find remainder 
		int rem = n % 26; 

		// If remainder is 0, then a 'Z' must be there in output 
		if (rem == 0) { 
			str[i++] = 'z'; 
			n = (n / 26) - 1; 
		} 
		else // If remainder is non-zero 
		{ 
			str[i++] = (rem - 1) + 'a'; 
			n = n / 26; 
		} 
	} 
	str[i] = '\0'; 

	// Reverse the string and print result 
	reverse(str, str + strlen(str)); 
	cout << str << endl; 

	return; 
} 

// Driver program to test above function 
int32_t main() 
{ 
    int n;
    cin>>n;
	printString(n); 
	return 0; 
} 


Measured memory_bytes: 3592
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def ii(): return int(stdin.readline())
def li(): return map(int, stdin.readline().split())
S = stdin.readline()
L = len(S)
cnt = 0
cnt1 = 0
# 0101010101
for i, s in enumerate(S):
    if i & 1 == 1:
        incr = 1 if s == '1' else 0
        cnt += incr
    else:
        incr = 1 if s == '0' else 0
        cnt += incr
for i, s in enumerate(S):
    if i & 1 == 1:
        incr = 1 if s == '0' else 0
        cnt1 += incr
    else:
        incr = 1 if s == '1' else 0
        cnt1 += incr
print(min(cnt, cnt1))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>d(n);
    for(int i=0;i<n;i++)cin>>d.at(i);
    
    sort(d.begin(),d.end());
    cout<<d.at(n/2)-d.at((n/2)-1)<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> grh;
int s, t;
void dfs (int crr, int prt) {
  if (crr != prt && crr == s) {
    cout << "Yes" << '\n';
    exit(0);
  }
  for (int nxt : grh[crr]) {
    if (nxt != prt && nxt != t) {
      dfs(nxt, crr);
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> dgr(n, 0);
  grh.resize(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    dgr[--a]++;
    dgr[--b]++;
    grh[a].push_back(b);
    grh[b].push_back(a);
  }
  vector<int> pts;
  for (int i = 0; i < n; i++) {
    if (dgr[i] & 1) {
      cout << "No" << '\n';
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (dgr[i] >= 6) {
      cout << "Yes" << '\n';
      return 0;
    } else if (dgr[i] == 4) {
      pts.push_back(i);
    }
  }
  if (pts.size() >= 3) {
    cout << "Yes" << '\n';
    return 0;
  } else if (pts.size() <= 1) {
    cout << "No" << '\n';
    return 0;
  }
  s = pts[0];
  t = pts[1];
  dfs(s, s);
  cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 7680
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = np.array(list(readline().decode()), 'U1')[:-1]
T = np.array(list(readline().decode()), 'U1')[:-1]

def longest_common_subsequence(S, T):
    """compute table dp satisfying: 
    dp[i,j] = LCS(S[:i], T[:j])"""
    LS, LT = len(S), len(T)
    dp = np.zeros((LS + 1, LT + 1), np.int32)
    for n in range(1, LS + 1):
        dp[n, 1:] = dp[n - 1, :-1] + (S[n - 1] == T)  # 左上から
        np.maximum(dp[n], dp[n - 1], out=dp[n])  # 上から
        np.maximum.accumulate(dp[n], out=dp[n])  # 左から
    return dp

dp = longest_common_subsequence(S, T)

answer = []
i, j = len(S), len(T)
while i > 0 and j > 0:
    if dp[i, j] == dp[i - 1, j - 1] + (S[i - 1] == T[j - 1]):
        i, j = i - 1, j - 1
        if S[i] == T[j]:
            answer.append(S[i])
    elif dp[i, j] == dp[i - 1, j]:
        i -= 1
    elif dp[i, j] == dp[i, j - 1]:
        j -= 1
    else:
        raise ValueError

answer = ''.join(reversed(answer))
print(answer)

Measured memory_bytes: 62472
i,j,k,s;main(x){char a[99],b[99];for(scanf("%s%d",a,&x);x--;){scanf("%s",b);for(i=0;i<10;i++){k=0;if(a[k]==b[i]){for(j=i;1;){j++;k++;j=j>9?0:j;if(a[k]=='\0'){s++;i=11;break;}if(a[k]!=b[j])break;}}}}printf("%d\n",s);exit(0);}

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



int main() {
  ll A,B,C,D;
  cin>>A>>B>>C>>D;
  ll num1,num2;
  num1=C/B;
  if(C%B!=0)
  {
    num1++;
  }
  num2=A/D;
  if(A%D!=0)
  {
    num2++;
  }
  if(num1<=num2)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }  
  return 0;
}


Measured memory_bytes: 3596
"""
# keywords
Counter
# impression
Counterを使わない場合、処理を間違えずに書くのに以外と苦労
"""
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
from collections import Counter

def main():
    n = II()
    vv = MII()
    ee = Counter(vv[0::2])
    oo = Counter(vv[1::2])
    minv = 10**5
    ee1 = ee.most_common()[0]
    oo1 = oo.most_common()[0]
    if ee1[0] != oo1[0]:
        minv = min(minv, n - (ee1[1] + oo1[1]))
    else:
        ee2 = ee.most_common()[1] if len(ee) > 1 else (0, 0)
        oo2 = oo.most_common()[1] if len(oo) > 1 else (0, 0)
        minv = min(minv, n - (ee1[1] + oo2[1]))
        minv = min(minv, n - (ee2[1] + oo1[1]))
    print(minv)

if __name__ == '__main__':
    main()


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

int main(void){
    string A;
    cin>>A;
    
    ll c[26]={0};
    ll N=A.length();
    ll ans=N*(N-1)/2+1;
    
    ll i;
    for(i=0;i<N;i++){
        c[A[i]-'a']++;
    }
    
    for(i=0;i<26;i++){
        ans-=c[i]*(c[i]-1)/2;
    }
    
    cout<<ans<<endl;

}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;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--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTS(s) printf("%s\n",(s))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

typedef long long ll;

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}

void Swap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}
void ShowData(int x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		Swap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}

int main() {
	int n, a[100];
	scanf("%d", &n);
	REP(i, n) {
		scanf("%d", &a[i]);
	}
	QSort(a, 0, n - 1, 0);
	int ans = 0;
	REP(i, n) {
		if (i % 2 == 0) {
			ans += a[i];
		}
		else {
			ans -= a[i];
		}
	}
	PRINTD(ans);
}

Measured memory_bytes: 128