akhauriyash/Code-Regression huggingface dataset:
//id:miiifa (AOJ,PEどちらも)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
// #ifdef DEBUG 
struct process{
    string name;
    int time;
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;
    cin >> n >> q;
    process tmp;
    int ntime= 0;
    queue<process> A;

    REP(i,n){
        cin >> tmp.name >> tmp.time;
        A.push(tmp);
    }
    while (!A.empty()) {
		tmp = A.front(); A.pop();
		if (tmp.time <= q) {
			ntime += tmp.time;
			cout << tmp.name << ' ' << ntime << endl;
		}
		else {
			ntime += q;
			tmp.time -= q;
		    A.push(tmp);
		}
	}

    return 0;
}


Measured memory_bytes: 6336
#include <cstdio>
#include <iostream>
#include <string.h>
using namespace std;

int main(){
	char a[11];
	char b[11];
	char c[11];
	cin >> a; 
	cin >> b; 
	cin >> c;
	int l_a = strlen(a);
	int l_b = strlen(b);
	//int l_c = strlen(c);
	
	if( a[l_a-1] == b[0] && b[l_b-1] == c[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;

}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
typedef long long ll;
using namespace std;
int main()
{
    ll a,b,n,x,t,y;
    cin>>a>>b>>n;
    if(n>=b){
        x=a*(b-1)/b;
    }
    else {
        x=a*n/b;
    }
    cout<<x;
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
using namespace std;
int main(){
    int n,max=0,b=0;
    cin>>n;
    for(int i=0;i<n;++i){
        int a;
        std::cin>>a;
        if(a==1){
            ++b;
            if(max<b){
                max=b;
            }
        }
        else{
            if(max<b){
                max=b;
            }
            b=0;
        }
    }
    cout<<max+1<<endl;
}



Measured memory_bytes: 3128
// グラフの表現
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstdlib>
using namespace std;

const int N = 100;

int main() {

    int M[N][N];
    int n, u, k, v;
    cin >> n;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            M[i][j] = 0;
        }
    }
    
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;

        for (int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1; //uとvの間に辺を張る
        }
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j) cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
 	string s;
 	LL k;
 	cin >> s >> k;
 	LL on = 0;
 	string ss = s;
 	bool ok = 0;
 	for(int i = 1; i < ss.size(); ++i) {
 		if(ss[i] == ss[i - 1]) {
 			ss[i] = 0;
 			++on;
 		}
 		if(s[i] != s[i - 1])
 			ok = 1;
 	}
 	if(!ok) {
 		cout << 1LL * k * (LL)(ss.size()) / 2 << endl;
 		return 0;
 	}
 	LL ans = on;
 	if(s[0] == s.back()) {
 		int cnt = 0, cnt2 = 0;
 		for(int i = 0; i < s.size() && s[i] == s[0]; ++i) ++cnt;
 		for(int i = s.size() - 1; i >= 0 && s[i] == s[0]; --i) ++cnt2;
 		on -= cnt / 2 + cnt2/2;
 		on += (cnt + cnt2) / 2;
 		ans += on * (k - 1);
 		cout << ans << endl;
 	}
 	else cout << on * k << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char k[30][30];
int sum = 0;
struct node
{
    int l, r;
};
int dx[] = {1, -1 , 0,0};
int dy[] = {0, 0, 1, -1};
int h, w;
int mp[30][30];

ll qpow(ll a, ll b, ll mod) {
    ll ans = 1;
    while (b) {
        if (b & 1) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}

void bfs(int x, int y) {
   sum = 0;
   queue<node> q;
   node a, b;
   a.l = x;
   a.r = y;
   q.push(a);
   while(!q.empty()) {
      b = q.front();
      q.pop();
      int flag = 0;
      for(int i = 0; i < 4; i++) {
        int xx = b.l + dx[i];
        int yy = b.r + dy[i];
		if (xx == x && yy == y) continue;
        if(xx >= 1&&xx <= h&&yy >= 1&&yy <= w&&k[xx][yy] == '.'&&!mp[xx][yy]) {
            q.push({xx, yy});
            mp[xx][yy] = mp[b.l][b.r]+1;
            sum = max(sum, mp[xx][yy]);
        }
      }
   }
}
void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

void solve()
{
    cin >> h >> w;
    for(int i = 1; i <= h; i++) {
        scanf("%s",k[i]+1);
    }
	int xxx = 0;
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            if(k[i][j] == '.') {
                memset(mp, 0, sizeof(mp));
                bfs(i, j);
                xxx = max(xxx, sum);
            }
        }
    }
    cout << xxx << endl;
}

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


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _Ty> static _Ty tp_abs(const _Ty& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _Ty> static _Ty tp_min(_Ty a, _Ty b) {
	return a < b ? a : b;
}
template <class _Ty> static _Ty tp_max(_Ty a, _Ty b) {
	return a > b ? a : b;
}
template<class T> static void getint(T& a) {
	const char* fmt = " %d";
	if (sizeof(T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class T> static void getint(T& a, T& b) {
	const char* fmt = " %d %d";
	if (sizeof(T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class T> static void getint(T& a, T& b, T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static const int EduDp_INF = 1100000000;
static const int MOD_NUM = 1000000007;
static void A_frog2();

#if 1
int main()
{
	A_frog2();
	fflush(stdout);
	return 0;
}
#endif


static void A_frog2()
{
	int N;
	getint(N);

	std::vector<int> cost(N + 1, 0);
	for (int i = 1; i <= N; i++) {
		int h; getint(h);
		cost[i] = h;
	}

	std::vector<int> dp(N + 1, 0);
	dp[0] = dp[1] = 0;
	dp[2] = tp_abs(cost[1] - cost[2]);
	for (int i = 3; i <= N; i++) {
		int c = dp[i - 2] + tp_abs(cost[i - 2] - cost[i]);
		dp[i] = tp_min(c, dp[i - 1] + tp_abs(cost[i - 1] - cost[i]));
	}
	printf("%d\n", dp[N]);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define sz(a) int((a).size()) 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define mp make_pair
#define pb push_back 
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)
#define sd(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sl(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define sortv(a) sort(a.begin(),a.end())
#define test()  int t; cin>>t; while(t--)
#define fi first
#define se second
#define el "\n"
#define ll long long
#define ull unsigned ll
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
 
#define TRACE

#ifndef ONLINE_JUDGE
//FILE *fin = freopen("input.txt","r",stdin);
//FILE *fout = freopen("output.txt","w",stdout);
#endif 
 
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
#else
 
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
 
#endif
 
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector< PII > VPII;
 
#define MAXN 300005
ll a[MAXN],lval[MAXN],rval[MAXN];
priority_queue<ll,vector<ll> ,greater<ll> > lq;
priority_queue<ll,vector<ll> > rq;

int main()
{
	int n;
	cin>>n;
	n = 3*n;
	rep(i,n)
		cin>>a[i+1];
	ll sum = 0;
	for(int i = 1;i<=n;i++)
	{
		if(i<=n/3)
		{
			sum+=a[i];
			lq.push(a[i]);
		}
		else
		{
			ll top = lq.top();
			if(top<a[i])
			{
				lq.pop();
				lq.push(a[i]);
				sum+=(a[i]-top);
			}
		}
		lval[i] = sum;
	}
	sum = 0;
	for(int i = n;i>=1;i--)
	{
		if(i>(2*n)/3)
		{
			sum+=a[i];
			rq.push(a[i]);
		}
		else
		{
			ll top = rq.top();
			if(top>a[i])
			{
				rq.pop();
				rq.push(a[i]);
				sum+=(a[i]-top);
			}
		}
		rval[i] = sum;
	}
	ll ans = LONG_LONG_MIN;
	/*rep(i,n+1)
		cout<<lval[i]<<" ";
	cout<<endl;
	rep(i,n+1)
		cout<<rval[i]<<" ";
	cout<<endl;
	*/
	for(int i = n/3;i<=(2*n)/3;i++)
		ans = max(ans,lval[i]-rval[i+1]);
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 8948
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#define ll long long
using namespace std;
int read(){
	int f=1,x=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return f*x;
}
int n,x;
ll sum=0;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		x=read();
		sum+=x;
	}
	sum-=n;
	cout<<sum;
	return 0;
}

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

int main(){
  int a, b, c;	cin >> a >> b >> c;
  bool ok = true;;
  if(a == b || b == c || c == a) ok = false;
  if(a == b && a == c) ok = true;
  if(ok) puts("No");
  else puts("Yes");
  return 0;
}

Measured memory_bytes: 256
let _ = stdin.ReadLine()
let V = stdin.ReadLine().Split() |> Array.map int
let C = stdin.ReadLine().Split() |> Array.map int

Array.zip V C
|> Array.map (fun x -> fst x - snd x)
|> Array.filter (fun x -> x > 0)
|> Array.sum
|> stdout.WriteLine


Measured memory_bytes: 11348
#include <stdio.h>
#define N 100
int main(void){
    int num,i,j,math[N],temp,count=0,min;
    scanf("%d",&num);
    for(i=0;i<num;i++){
        scanf("%d",&math[i]);
    }
    
    for(i=0;i<=num-2;i++){
        min = i;
        for(j=i;j<=num-1;j++){
            if(math[j]<math[min]){
               min = j;
            }
        }
        
       if(i != min ){
            temp =math[min];
            math[min]=math[i];
            math[i]=temp;
            count++;
        }
    }
    
    printf("%d",math[0]);
    for(i=1;i<num;i++){
        printf(" %d",math[i]);
    }
    printf("\n%d\n",count);

    return 0;
}


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

int main()
{
    double n, m, d;
    cin >> n >> m >> d;

    double k; //２項間で差がｄの組み合わせの数
    if (d == 0) k = n;
    else k = (n - d) * 2;
    double ans = (k / (n*n)) * (m - 1);

    printf("%.10f\n", ans);
    //cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int W = sc.nextInt();
    int H = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    int r = sc.nextInt();
 
    if(0 <= x-r && x+r <= W &&  0 <= y-r && y+r <= H ){
    	System.out.println("Yes");
    }else{
    	System.out.println("No");
    }
    
    
  
  }
}

Measured memory_bytes: 26160
from math import factorial

N, K = map(int, input().split())
n_blue, n_red = K, N-K

for k in range(1, K+1):
    if k-1 > n_red:
        print(0)
        continue
    retval = (factorial(n_red+1) // (factorial(n_red-k+1) * factorial(k))) * (factorial(n_blue-1) // (factorial(n_blue-k) * factorial(k-1)))
    print(retval % (10**9 + 7))

Measured memory_bytes: 3316
def char2int(c):
    return ord(c) - ord('a')


def int2char(i):
    return chr(i + ord('a'))


def main():
    S = input()
    # 全種類使ってない場合
    # 使っていない文字の中の最小の文字を付け加える
    #     afd -> afdb
    if len(S) < 26:
        used = [0] * 26
        for c in S:
            used[char2int(c)] = 1
        unused_min_c = int2char(min([i for i in range(26) if used[i] == 0]))
        print(S + unused_min_c)
    # 全種類使っている場合
    # 右から順に見ていって、S[i - 1] < max(S[i:]) なるiがあったら
    # S[i:]の中でS[i - 1]より大きい最小の文字でS[(i - 1):]を置き換える
    #     ....xvzwy -> ...xvzy
    else:
        if S == 'zyxwvutsrqponmlkjihgfedcba':
            print(-1)
        else:
            used = [0] * 26
            for i in range(len(S) - 1, 1, -1):
                used[char2int(S[i])] = 1
                target_char = None
                for j in range(26):
                    if used[j] == 0:
                        continue
                    c = int2char(j)
                    if c > S[i - 1]:
                        if target_char is None:
                            target_char = c
                        else:
                            target_char = min(target_char, c)
                if target_char is None:
                    continue
                print(S[:(i - 1)] + target_char)
                return
            print(int2char(1 + char2int(S[0])))


if __name__ == '__main__':
    main()

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, x[101010], y[101010], t[101010];
void solve(){
	cin >> n;
	bool ok = 1;
	for(int i = 1; i <= n; i++){
		cin >> t[i] >> x[i] >> y[i];
		if(((t[i]-t[i-1]) ^ (x[i]-x[i-1]+y[i]-y[i-1])) & 1) ok = 0;
		if((t[i]-t[i-1]) < abs(x[i]-x[i-1])+abs(y[i]-y[i-1])) ok = 0;
	}
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
int main(){
    int n;
    double a=0,b=0,d=0,e=0;
    cin>>n;
    double x[n]={};
    double y[n]={};
    double c[n]={};
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    for(int i=0;i<n;i++){
        cin>>y[i];
    }
    for(int i=0;i<n;i++){
            a+=abs(x[i]-y[i]);
            b+=abs((x[i]-y[i])*(x[i]-y[i]));
            e+=abs((x[i]-y[i])*(x[i]-y[i])*(x[i]-y[i]));
    }
    printf("%.6lf\n", a);
    printf("%.6lf\n",sqrt(b));
    printf("%.6lf\n",pow(e,1.0/3.0));
    for(int i=0;i<n;i++){
            c[i]=abs(x[i]-y[i]);
            if(i==0){
                d=c[i];
            }
            else if(c[i]>=d){
                d=c[i];
            }
    }
    printf("%.6lf\n",d);
return 0;
}


Measured memory_bytes: 3384
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
//#include <bits/stdc++.h>
#define rep(i,n) for (long int i = 0; i < (n); ++i)
using namespace std;

int main(){
    long int N;
    cin>>N;
    string l;
    cin>>l;
    long int s=0,g=N-1;
    long int ans=0;
    while(s<g){
        while(l[s]=='R' && s<g) s++;
        while(l[g]=='W' && s<g) g--;
        if (s<g) ans++;
        s++;
        g--;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3716
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int mod = 998244353;
int N, K;
int main() {
	cin >> K >> N;
	vector<vector<int> > comb(N + K + 1, vector<int>(N + K + 1, 0));
	for (int i = 0; i <= N + K; ++i) {
		comb[i][0] = 1;
		for (int j = 1; j <= i; ++j) {
			comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];
			if (comb[i][j] >= mod) comb[i][j] -= mod;
		}
	}
	vector<vector<int> > dp(K + 1, vector<int>(N + 1, 0));
	dp[0][0] = 1;
	for (int i = 1; i <= K; ++i) {
		int sum = 0;
		for (int j = 0; j <= N; ++j) {
			if (i % 2 == 1) {
				dp[i][j] = dp[i - 1][j] + (j >= 1 ? dp[i - 1][j - 1] : 0);
				if (dp[i][j] >= mod) dp[i][j] -= mod;
			}
			else {
				dp[i][j] = (dp[i - 2][j] + (long long)(2) * sum) % mod;
				sum += dp[i - 2][j];
				if (sum >= mod) sum -= mod;
			}
		}
	}
	vector<int> ans(K + 1);
	for (int i = 0; i < K; ++i) {
		for (int j = 0; j <= N; ++j) {
			ans[i] = (ans[i] + (long long)(dp[i][j]) * comb[(N - j) + (K - i - 1)][K - i - 1]) % mod;
		}
	}
	ans[K] = dp[K][N];
	for (int i = 1; i <= 2 * K - 1; ++i) {
		cout << ans[min(i, 2 * K - i)] << endl;
	}
	return 0;
}

Measured memory_bytes: 78720
#include <bits/stdc++.h>
using namespace std;
constexpr int P = 1'000'000'007;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    int ans = 0;
    for (int k = 0; k < 60; ++k) {
        int c[2] = {};
        for (int i = 0; i < n; ++i)
            ++c[a[i] >> k & 1];
        ans = (ans + (1LL << k) % P * c[0] % P * c[1]) % P;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=100010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int a,b,c,d;
    a=read(), b=read(), c=read(), d=read();
    int res=a*c;
    res=max(res,a*d);
    res=max(res,b*c);
    res=max(res,b*d);
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 3760
package main

import "fmt"

func main(){
  var i1, i2 int
  var ans = 0
  fmt.Scan(&i1)
  fmt.Scan(&i2)
  for i := 1; i < 4; i++ {
    if i1 == 1 {
      if i2 == 2 {
        ans = 3
      } else {
        ans = 2
      }
    } else if i1 == 2 {
      if i2 == 1 {
        ans = 3
      } else {
        ans = 1
      }
    } else if i1 == 3 {
      if i2 == 1 {
        ans = 2
      } else {
        ans = 1
      }
    }
  }
  fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
using namespace std;

int main(){
	int n, y;
	cin >> n >> y;
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= n - i; ++j) {
			if (10000 * i + 5000 * j + 1000 * (n - i - j) == y) {
				cout << i << " " << j << " " << n - i - j << endl;
				return 0;
			}
		}
	}
	cout <<  "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
// デバッグ実行：Ctrl+F5
 
using System;
 
class Program
{
    static void Main(string[] args)
    {
        String line;
        //line = Console.ReadLine();
        //String[] words = line.Split(' ');
 
        string S = Console.ReadLine();
        string T = Console.ReadLine();
 
        int[] Scount, Tcount;
        Scount = new int[26];
        Tcount = new int[26];
        for (int i = 0; i < 26; i++)
        {
            Scount[i] = 0;
            Tcount[i] = 0;
        }
        for(int i = 0; i < S.Length; i++)
        {
            Scount[S[i] - 'a']++;
            Tcount[T[i] - 'a']++;
        }
        // 後はソートするだけ
        Array.Sort(Scount);
        Array.Reverse(Scount);
        Array.Sort(Tcount);
        Array.Reverse(Tcount);
 
        // 判定
        bool result = true;
        for (int i = 0; i < Scount.Length; i++)
        {
            if (Scount[i] != Tcount[i])
            {
                result = false;
                break;
            }
        }
        if (result) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
int main() {
	ll n;
	cin>>n;
	ll ch[200010];
	for(ll i=0;i<n;i++){
		cin>>ch[i];
	}
	ll ans[200010]={};ll ans2=0;
	for(ll i=n-1;i>=0;i--){
		ll now=i+1;
		ll keta=2;
		ll cnt=0;
		while(now*keta<=n){
			if(ans[now*keta]){
				cnt++;
			}
			keta++;
		}
		if(cnt%2!=ch[i]){
			ans[i+1]=1;
			ans2++;
		}
	}
	cout <<ans2<<endl;
	for(ll i=1;i<=n;i++){
		if(ans[i]==1){
		cout <<i<<" ";
		}
	}
	// your code goes here
	return 0;
}

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

int main(){
  int S; 
  cin >> S;
  
  int S12,S34;
  S12 = S/100;
  S34 = S%100;
  
  string ans;
 
  if(1<=S12&&S12<=12){
    if(1<=S34&&S34<=12){
      ans = "AMBIGUOUS";
    }else{
      ans = "MMYY";
    }
  }else{
    if(1<=S34&&S34<=12){
      ans = "YYMM";
    }else{
      ans = "NA";
    }
  }
  cout << ans << endl;
}


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

#define CodeTyper main
#define Bye return 0
#define ll long long

using namespace std;


void solve(){
    ll n, i, j; cin>>n;
    
    int cont = 0;
    for (int i=1; i<n; i++)
        for (int j=1; j*i<n; j++)
            cont++;

    cout<<cont<<endl;
}

int CodeTyper(){
    solve();
    Bye;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a, b, c, d;
  cin >> N;
  a = N / 1000; // 1000の位
  b = N / 100 - a * 10; // 100の位
  c = N / 10 - (a * 100 + b *10);  // 100の位
  d = N - (a * 1000 + b *100 + c * 10);
  
  if ((a == b && b == c)||(b == c && b == d)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int main (){
    int a , ac = 0 , wa = 0 , tle = 0 , re = 0 ;
    cin >> a ;
    string b ;
    for (int i = 0 ; i < a ; i ++){
        cin >> b ;
        if (b == "AC")
            ac ++ ;
        else if (b == "WA")
            wa ++ ;
        else if (b == "TLE")
            tle ++ ;
        else
            re ++ ;


    }
    cout << "AC x " << ac << endl << "WA x " << wa << endl << "TLE x " << tle << endl << "RE x " << re << endl ;
}


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

int main() { int N, K;
  cin >> N >> K;
  int s = 1;

  for (int i = 0; i < N; i++){
      if(s<K){
        s = 2 * s;
      }
      else{
        s = s + K;
      }

  }
  cout << s << endl;

}


Measured memory_bytes: 3576
n,x=map(int,input().split())
list=list(map(int,input().split()))
bound_list=[0]
flag=0

for i in range(len(list)):
    bound_list.append(list[i]+bound_list[i])
    if bound_list[len(bound_list)-1]>x:
        print(i+1)
        flag=1
        break

if flag == 0:
    print(n+1)


Measured memory_bytes: 3060
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>

const long long INF = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    llong N;
    cin >> N;
    for(int i=1; i<=9; i++){
        for(int j=1; j<=9; j++){
            if(i*j==N){
                cout << "Yes" << endl;
                exit(0);
            }
        }
    }
    cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 3096
import math

#n = int(input())
#a = int(input())
a,b = list(map(int,input().split(" ")))
#ls = list(input().split(" "))
#ls = list(map(int,input().split(" ")))
#a,b = list(input().split())
string = input()
#ls = [int(input()) for i in range(n)]
try:
  int(string[0:a])
  int(string[a+1:a+b+1])
  if string[a] == "-":
    print("Yes")
  else:
    print("No")
except:
  print("No")


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

main(){
  vector <int> a(3);
  int A,B;
  cin >>A>>B;
  a.at(0)=1;
  a.at(1)=1;
  a.at(2)=1;
  a.at(A-1)=0;
  a.at(B-1)=0;
  if(a.at(0)==1) cout <<1<<endl;
  if(a.at(1)==1) cout <<2<<endl;
  if(a.at(2)==1) cout <<3<<endl;
  return 0;
}

  
  

Measured memory_bytes: 256
while True:
    n=input()
    if n==0:break
    A=map(int,raw_input().split())
    i,num=0,32
    while num>0:
        num-=(num-1)%5
        print num
        num-=A[i%n]
        if num>0:
            print num
        else:
            print 0
        i+=1

Measured memory_bytes: 4224
while (ls = gets.split.map{|i|i.to_i})!=[0]
  ls.map!{|i|[i,10].min}
  ans=ls.inject(:+)
  if ans>21
    ans=0
  else
    c=ls.count(1)
    for i in 1..c
      ans+=10 if ans+10 <= 21
    end
  end
  puts ans
end

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

int main(){
	int N, D, X;
	cin >> N >> D >> X;

	int A[N];
	for (int i=0; i<N; i++) cin >> A[i];

	int ans = X;
	for (int i=0; i<N; i++){
		ans += (D-1)/A[i] + 1;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
mod = 10 ** 9 + 7

ans = 0
cs = [0] * (n+2)
for i in range(n+1):
    cs[i+1] = cs[i] + (i+1)
for i in range(k,n+2):
    ans += (cs[n+1] - cs[n+1-i] - cs[i] + 1)
    ans %= mod
print(ans)

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

int main(void){
    int n, k;
    cin >> n >> k;
    int f[n + 1] = {};
    for(int i = 0; i < k; i++){
        int d;
        cin >> d;
        for(int j = 0; j < d; j++){
            int a;
            cin >> a;
            if(!f[a]) n--;
            f[a] = 1; 
        }
    }
    cout << n << endl;
    return 0;
}

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

int main(void) {
  int i,len,sum;
  char num[1002];
  while(1){
    fgets(num,sizeof(num), stdin);
    len = strlen(num);
    if(num[0] == 48 && len == 2){
      break;
    }
    for(i = 0; i < len - 1; i++){
      sum += num[i];
      sum -= 48;
    }
    printf("%d\n",sum);
    sum = 0;
    len = 0;
  }
  return 0;
}


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

int main(){
    using namespace std;
    long A, B;
    cin >> A >> B;
    
    long ans{0};
    if(A < B)swap(A, B);
    ans += A;
    --A;
    if(A < B)swap(A, B);
    ans += A;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
   int i,n,ac=0,wa=0,tle=0,re=0;
   scanf("%d",&n);
   char res[n][4];

   for(i=0;i<n;i++)
      scanf("%s",res[i]);

   for(i=0;i<n;i++){
      if(res[i][0]=='A') ac++;
      else if(res[i][0]=='W') wa++;
      else if(res[i][0]=='T') tle++;
      else re++;
   }

   printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",ac,wa,tle,re);
   return 0;
}

Measured memory_bytes: 2072
// Created by Nikolay Budin

#ifdef LOCAL
#  define _GLIBCXX_DEBUG
#else
#  define cerr __get_ce
#endif
#include <bits/stdc++.h>
#define ff first
#define ss second
#define szof(x) ((int)x.size())

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef unsigned long long ull;
int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;
#ifdef LOCAL
	mt19937 tw(9450189);
#else
	mt19937 tw(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
uniform_int_distribution<ll> ll_distr;
ll rnd(ll a, ll b) { return ll_distr(tw) % (b - a + 1) + a; }

const int MOD = 1000000007;

void solve() {
	int n;
	string s;
	cin >> n >> s;
	vector<int> cnt(26);
	for (char c : s) {
		cnt[c - 'a']++;
	}
	int ans = 1;
	for (int i = 0; i < 26; ++i) {
		ans = (ll) ans * (cnt[i] + 1) % MOD;
	}

	ans = (ans + MOD - 1) % MOD;

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


int main() {
#ifdef LOCAL
	auto start_time = clock();
	cerr << setprecision(3) << fixed;
#endif
	cout << setprecision(15) << fixed;
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int test_count = 1;
	// cin >> test_count;
	for (int test = 1; test <= test_count; ++test) {
		solve();
	}
	
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    string S;
    cin >> N;
    cin >> S;
    if(N % 2 == 0)
    {
        string subS_front = S.substr(0, N /2);
        string subS_back = S.substr(N / 2);
        //cerr << subS_front << ":" << subS_back << endl;
        if(subS_front == subS_back) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else cout << "No" << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
    #include<string>
    using namespace std;
     
     
    int main()
    {
        string s;cin>>s;
        int check = 0;
        for(int i=0; i<3; i++)
        {
            if(s[i] == '7')
                check = 1;
        }
        if(check)
            cout<<"Yes";
        else
            cout<<"No";
    }

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define MOD (ll)(1e9 + 7)
#define MAX (ll)(2e5 + 4)
#define INF (ll)(1e17)
using namespace std;
using ll =  long long;
using ld = long double;

bool vis[MAX];
int main () {
	int n;
	cin >> n;
	pair<int,  int> ar[n], br[n];
	int per[n];
	for (int i = 0; i < n; i++) {
		cin >> ar[i].first;		
		ar[i].second = i;
	}
	for (int i = 0; i < n; i++) {
		cin >> br[i].first;		
		br[i].second = i;
	}
	sort (ar, ar + n);
	sort (br, br + n);
	for (int i = 0; i < n; i++) {
		if (ar[i].first > br[i].first) {
			cout << "No\n";
			return 0;
		}
		per[ar[i].second] = br[i].second;
	}
	for (int i = 1; i < n; i++) {
		if (ar[i].first <= br[i - 1].first) {
			cout << "Yes\n";
			return 0;
		}
	}
	int cc = 0;
	for (int i = 0; i < n; i++) {
		if (!vis[i]) {
			cc++;
			vis[i] = 1;
			int ne = per[i];
			while (!vis[ne]) {
				vis[ne] = 1;
				ne = per[ne];
			}
		}
	}
	if (cc == 1) {
		cout << "No\n";
	}
	else {
		cout << "Yes\n";
	}
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int n;cin>>n;
    set<int> data;
    REP(i,n){
        int t;cin>>t;
        if(data.count(t)==0){
            data.insert(t);
        }else{
            data.erase(t);
        }
    }
    cout<<(int)data.size()<<endl;
    return 0;
}


Measured memory_bytes: 4864
n, k = map(int, input().split())
h = list(map(int,input().split()))

if k > n:
    k = n-1

'''
n番目の場所に到達する時
n-1番目から、1つ飛んでくる
n-2番目から、２つ飛んでくる
...
n-K番目から、kつ飛んでくる

可能性がある　その時の最小値を考える

初期条件
dp[0] = 0
dp[1~Kまで]を計算

*** n-j
dp[n] = dp[n-j] + abs(h[n] - h[n-j])

漸化式
n >= 2
dp[n] = min(jump_list)

1~K
jump_list = [1 ~ j で dp[n] = dp[n-j] + abs(h[n] - h[n-j])]

k~N
jump_list = [j-k ~ j で dp[n] = dp[n-j] + abs(h[n] - h[n-j])]

'''

#初期値
dp = [0]

def create_jump_list(j,i):
    alist = []
    for x in range(j, i):
        alist.append(
            dp[x] + abs(h[i] - h[x])
        )
    return alist

# kまで
for i in range(1, k+1):
    jump_list = create_jump_list(0,i)
    dp.append(
        min(jump_list)
    )

for i in range(k+1,n):
    jump_list = create_jump_list(i-k, i)
    dp.append(
        min(jump_list)
    )
print(dp[n-1])


Measured memory_bytes: 58464
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

const int lim = 100000 + 100;

int N;
vec<int, 2> G;

ll MOD;
ll dp[lim], ans[lim];

void dfs(int v, int p = -1) {
  dp[v] = 1;
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if (u == p) continue;
    dfs(u, v);
    dp[v] = dp[v] * (1 + dp[u]) % MOD;
  }
}

void dfs2(int v, int p = -1, ll pv = 0) {
  vector<ll> f(G[v].size(), 1);
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if (u == p) continue;
    f[i] = (1 + dp[u]) % MOD;
  }
  vector<ll> L(G[v].size() + 1, 1), R(G[v].size() + 1, 1);
  for (int i = 0; i < G[v].size(); i++) L[i + 1] = L[i] * f[i] % MOD;
  for (int i = G[v].size() - 1; i >= 0; i--) R[i] = R[i + 1] * f[i] % MOD;
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if (u == p) continue;
    ll ev = (1 + pv) * L[i] % MOD * R[i + 1] % MOD;
    dfs2(u, v, ev);
  }
  ans[v] = (1 + pv) * dp[v] % MOD;
}

int main() {
  while (cin >> N >> MOD) {
    G.clear();
    G.resize(N);
    for (int i = 0; i < N - 1; i++) {
      int x, y;
      cin >> x >> y;
      --x;
      --y;
      G[x].push_back(y);
      G[y].push_back(x);
    }
    dfs(0);
    dfs2(0);
    for (int v = 0; v < N; v++) cout << ans[v] << endl;
  }
  return 0;
}


Measured memory_bytes: 22016
N = int(input())

city = []
for _ in range(N):
    x, y = map(int,input().split(" "))
    city.append((x,y))
    
ans = 0
for i in range(N-1):
    for j in range(i+1,N):
        x1, y1 = city[i]
        x2, y2 = city[j]
        
        ans += ( ( (x2-x1)**2 + (y2-y1)**2 )**0.5 )*(2/N)
        
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

int main(){

int b,r,g,c,s,t,S=0;
while(1){

scanf("%d %d %d %d %d %d",&b,&r,&g,&c,&s,&t);
if(b==r==g==c==s==t)break;
S=100;


//g=g-b*5-r*3;
S+=g*7+c*2+b*15+r*15;
S+=b*5*16+r*3*16;
t=t-s;
S-=t*3;

printf("%d\n",S);
}
return 0;
}

Measured memory_bytes: 1028
import itertools

N, C = map(int, input().split())
D = [list(map(int, input().split())) for i in range(C)]
c = [list(map(int, input().split())) for i in range(N)]#kokomadeha wakaru

indices = [2, 0, 1]
count_color = [[0] * C for i in range(3)]
for i in range(N):
  idx = indices[i%3]
  for j in range(N):
    count_color[idx][c[i][j]-1] += 1#1 minus surunoha list ni awaserutame iro to amari no kakezan
    idx = (idx + 1) % 3#koreha indices wo yatteirudake
    
# 色の対応関係をC_P_3通り全て試す
ans = float('inf')
correspondence = list(itertools.permutations(range(C), 3))
# (i+j)%3のマス目をcorr[(i+j)%3]に書き換える
for corr in correspondence:
  cost = 0
  for idx in range(3): # idx : (i+j)%3
    for color in range(C):
      cost += count_color[idx][color] * D[color][corr[idx]]
  ans = min(ans, cost)

print(ans)

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

int main(){
    int D, G;
    cin >> D >> G;
		vector<int> p(D, 0), c(D, 0);

    for(int i = 0; i < D; ++i){
        cin >> p[i] >> c[i];
    }

		// 問題の最大値
    int result = 1e9;


    for(int mask = 0; mask < (1 << D); ++mask){
			int sum = 0, num = 0, rest_max = -1;

			for(int i = 0; i < D; ++i){
				if(mask >> i & 1) {
						sum += 100 * (i+1) * p[i] + c[i]; // 点数計算 100点 * i問目 * 問題数 + ボーナス点
						num += p[i]; // 問題数にプラス
				} else {
						rest_max = i;
				}
			}
			// printf("rest: %d, sum: %d, num: %d\n", rest_max, sum, num);

			// 目標点に到達していない場合
			if(sum < G){
					int sum_1 = 100 * (rest_max + 1);
					int need = (G - sum + sum_1 - 1) / sum_1;
					if(need >= p[rest_max]){
							continue;
					}
					num += need;
			}
			result = min(result, num);
    }
    cout << result << endl;
}


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

        if(h > w)
        {
          int l=n % h;
            if(l==0)
            cout<<n/h;

            else
            cout<<n/h +1;
        }
       else
       {
         int l=n % w;
           if(l==0)
           cout<<n/w;

           else
           cout<<n/w +1;
       }
}


Measured memory_bytes: 256
#include <cstdio>

int main (){
    int a,b,c;
    int sum = 0;
    scanf("%d%d%d",&a,&b,&c);
    for(int i = a;i <= b;i++){
        if(c % i == 0){
          sum++;
        }
    }
    printf("%d\n",sum);
    return 0;
}



Measured memory_bytes: 2740
n = int(input())
t, a = map(int, input().split())
temp = 10 ** 6
ans = 0
height = list(map(int, input().split()))
for i, h in enumerate(height):
    diff = abs(a - (t - h * 0.006))
    if temp > diff:
        temp = diff
        ans = i + 1
print(ans)

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

using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);i++)

int r,c;
int s[25][25211];

int main(){
  while(true){
    scanf("%d%d",&r,&c);
    if(r==0 && c==0)break;
    REP(i,r)REP(j,c)scanf("%d",&s[i][j]);
    int ans = 0;
    REP(msk,1<<r){
      int arr[25];
      REP(i,r)arr[i]=(msk>>i)&1;
      int tmp = 0;
      REP(j,c){
        int k=0;
        REP(i,r)k+=s[i][j]^arr[i];
        tmp+=max(k,r-k);
      }
      ans=max(ans,tmp);
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1616
N = int(input())
a = w = t = r = 0
for i in range(N):
    s = input()
    if s == "AC":
        a += 1
    elif s == "WA":
        w += 1
    elif s == "TLE":
        t += 1
    elif s == "RE":
        r += 1

print("AC x {}".format(a))
print("WA x {}".format(w))
print("TLE x {}".format(t))
print("RE x {}".format(r))

Measured memory_bytes: 9228
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x,a,b;cin>>x>>a>>b;
  int A=abs(a-x),B=abs(b-x);
  if(A>B)cout <<"B"<<endl;
  if(A<B)cout <<"A"<<endl;
}

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

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
/* func */
int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int32_t a, int32_t b){return a * b / GCD(a, b);}
int64_t LCM(int64_t a, int64_t b){return a * b / GCD(a, b);}
 

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001
 
/*global*/
 
 
//for dfs, I prepare container(tree) at global
vector<int> to[200005];
vector<int> ans;
void dfs(int v, int p = -1){
	for(int u: to[v]){
		if(u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}
 
//#define int int64_t
signed main()
{
	int n, q; cin >> n >> q;
	for(int i = 0, i_len = (int)n-1; i < i_len; ++i){
		int a, b;
		cin >> a >> b;
		--a;--b;
		to[a].emplace_back(b);
		to[b].emplace_back(a);		
	}
	ans.resize(n);
	for(int i = 0, i_len = (int)q; i < i_len; ++i){
		int p, x;
		cin >> p >> x;
		--p;
		ans[p] += x;
	}
	dfs(0);
 
	for(int i = 0, i_len = (int)n; i < i_len; ++i){
		cout << ans[i] << "\n";
	}
 
}

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0;i < n;i++){
    cin >> p[i];
  }
  int ans = 0;
  
  for (int i = 1;i < n-1;i++){
    if (p[i-1] < p[i] && p[i] < p[i+1]){
      ans++;
    }
    else if (p[i-1] > p[i] && p[i] > p[i+1]){
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long
int m = 0,z;

#undef int
int main(){
    #define int long long
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n ,W; cin>>n>>W;
	m=0;
	z = W;
    if( n == 0 ){
    	cout << "0" << endl;
        return 0;
    }
    vector<int > w(n);
    vector<int > v(n);
    for(int i=0;i<n;i++)
        cin>> w[i] >> v[i] ;
    vector<vector<int > > dp(n,vector<int > (100001,INT_MAX));
    dp[0][v[0]] = w[0];
    for(int i=0;i<n;i++)
        dp[i][0] = 0;
    for(int i=1;i<n;i++){
        for(int j=1;j<=100000;j++){
            dp[i][j] = dp[i-1][j];
            if( v[i]<=j ) dp[i][j] = min( dp[i][j] , w[i]+dp[i-1][j-v[i]]);
        }
    }
    for(int i=1;i<100001;i++){
        if( dp[n-1][i]<=W )
            m = i;
    }
    
    cout << m << endl;
    return 0;
	
}

Measured memory_bytes: 79488
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
   
    cin>>a>>b;
    if(a%3==0||b%3==0||(a+b)%3==0) 
	cout<<"Possible"<<endl;
    else 
	cout<<"Impossible"<<endl;
	
    return 0;
}
 

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


int main(){
  int H, W;
  cin >> H>> W;
  vector<string> S(H);
  for (int row=0;row<H;row++) cin >> S.at(row); 
  
  int memo[H][W] = {};
  
  for (int row=0;row<H;row++){
    for (int col=0;col<W;col++){
      if (S.at(row).at(col)=='#') {
        memo[row][col] = -10;
        if (row>0) memo[row-1][col]++;
        if (row<H-1) memo[row+1][col]++;
        if (col>0) memo[row][col-1]++;
        if (col<W-1) memo[row][col+1]++;
        if (row>0 && col>0) memo[row-1][col-1]++;
        if (row<H-1 && col>0) memo[row+1][col-1]++;
        if (row>0 && col<W-1) memo[row-1][col+1]++;
        if (row<H-1 && col<W-1) memo[row+1][col+1]++;
      }
    }
  }
  

  for (int row=0;row<H;row++){
    for (int col=0;col<W;col++){
      if (memo[row][col]>=0) cout << memo[row][col];
      else cout << "#";
    }
    cout << endl;
  }

}
 

Measured memory_bytes: 256
N=int(input())
A=[int(i) for i in input().split()]
S=[0 for i in range(N+1)]
for i in range(N):
    S[i+1]=A[i]+S[i]
D=dict()
for i in range(N+1):
    x=D.get(S[i],0)
    x+=1
    D[S[i]]=x
ans=0
for k in D:
    ans+=(D[k]*(D[k]-1))//2
print(ans)


Measured memory_bytes: 41152
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: usize = read_as_vec()[0];

    let mut investigate : Vec<(i32, i32, i32)> = Vec::new();

    let mut tmp_res = (0, 0, 0);

    for _ in 0..n{
        let line: Vec<i32> = read_as_vec();
        investigate.push((line[0], line[1], line[2]));
    }

    for i in 0..n{
        if investigate[i].2 > 0{
            tmp_res = investigate[i];
            break;
        }
    }

    for x in 0..101{
        for y in 0..101{
            let tmp_top = (x - tmp_res.0).abs() + (y - tmp_res.1).abs() + tmp_res.2;
            let mut correct = true;
            for inv in &investigate{
                if inv.2 != cmp::max(tmp_top-(x-inv.0).abs() - (y-inv.1).abs(),0){
                    correct = false; break;
                }
            }
            if correct{
                println!("{} {} {}", x, y, tmp_top);
                return;
            }
        }
    }
}


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

int main() {
  int n;
  cin >> n;
  int res = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 2 == 0) continue;

    int cnt = 0;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) { cnt++; }
    }
    if (cnt == 8) res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import copy
import sys
input = sys.stdin.readline
n=int(input())
A = [int(input()) for _ in range(n)]
A2 = copy.deepcopy(A)
max1 = max(A)
A.remove(max1)
max2 = max(A)
for i in range(n):
    if A2[i]==max1:
        print(max2)
    else:
        print(max1)

Measured memory_bytes: 14568
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	int N, K;
	cin >> N >> K;

	vector<int> A(N + 1, 0);
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}

	for (int i = K + 1; i <= N; i++) {
		if (A[i-K] < A[i]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

	return 0;
}

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

signed main(){
    int N,K;
    cin >> N >> K;
    
    int A[N];
    map<int,int> mp;
    for(int i=0;i<N;i++){
        cin >> A[i];
        mp[A[i]]++;
    }
    
    if(mp.size()<=K){
        cout << 0 << endl;
        return 0;
    }
    
    vector<int> v;
    for(auto it = mp.begin();it != mp.end();it++){
        v.push_back(it -> second);
    }
    
    sort(v.begin(),v.end());
    
    int ans = 0;
    for(int i=0;i<mp.size()-K;i++){
        ans += v[i];
    }
    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 16500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif
void no(){
	printf("-1\n");
	exit(0);
}

#define N 112345
typedef pair<ll, int> pli;
typedef pair<ll, pii> plii;
vector<plii> es[N];
ll d[N] = {};

priority_queue<plii, vector<plii>, greater<plii>> que;

int main(){
	int n, m; scanf("%d%d", &n, &m);
	REP(i, m){
		int l, r; ll c; scanf("%d%d%lld", &l, &r, &c);
		es[l].EB(c, MP(l, r));
	}
	
	int k = 1;
	d[1] = 0;
	for(auto &e : es[1]) que.push(e);
	while(que.size()){
		auto tp = que.top(); que.pop();
		ll c = tp.first;
		int l = tp.second.first, r = tp.second.second;
		if(k < l) no();
		// check
		while(k + 1 <= r){
			k = k + 1;
			d[k] = c;
			for(auto &e : es[k]){
				que.emplace(d[k] + e.first, e.second);
			}
		}
	}
	if(k < n) no();
	printf("%lld\n", d[n]);

	// int k = 1;
	// d[1] = 0;
	// FOR(i, 1, n){
	// 	sort(ALL(es[i]));
	// 	for(auto &e : es[i]){
	// 		ll c = e.first;
	// 		int j = e.second;
	// 		DEBUG("%d => %d [%lld]\n", i, j, c);
	// 		if(k < i) no();
	// 		while(k + 1 <= j){
	// 			k++;
	// 			d[k] = d[i] + c;
	// 			DEBUG("  d[%d] = %lld\n", k, d[k]);
	// 		}
	// 	}
	// }
	// if(!d[n]) no();
	// printf("%lld\n", d[n]);
}


Measured memory_bytes: 7928