akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

const int MAX_N = 200000;
const int MOD = 1000000007;
long long inv[MAX_N + 1], fac[MAX_N + 1], finv[MAX_N + 1];

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

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

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

long long nHk(int n, int k) {
    if (n < 0 || k < 0) return 0;
    return nCk(n + k - 1, k);
}

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

    init();
    int N, M, K;
    cin >> N >> M >> K;
    int ans = 0;
    FOR (i, 1, N) (ans += M * M % MOD * nCk(N * M - 2, K - 2) % MOD * (N - i) * i % MOD) %= MOD;
    FOR (i, 1, M) (ans += N * N % MOD * nCk(N * M - 2, K - 2) % MOD * (M - i) * i % MOD) %= MOD;
    cout << ans << endl;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

bool is753(int32 x){
    map<int32,int32> m;
    while(x > 0){
        m[x%10]++;
        x /= 10;
    }
    return m.size() == 3;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<int32> ans;
    ans.emplace_back(3);
    ans.emplace_back(5);
    ans.emplace_back(7);
    int32 i = 0;
    while(true){
        int32 nx[3] = { ans[i] * 10 + 3,
                        ans[i] * 10 + 5,
                        ans[i] * 10 + 7};
        bool flg = false;
        REP(j,3){
            if(nx[j] > n){
                flg = true;
                break;
            }
            ans.emplace_back(nx[j]);
        }
        if(flg)break;
        ++i;
    }
    int32 cnt = 0;
    for(auto x : ans){
        if(is753(x))cnt++;
    }
    ANS(cnt);
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n, m; cin >> n >> m;
	bool k[100010]; for (int i = 1; i <= n; i++)k[i] = true;
	for (int i = 0; i < m; i++){
		int a, b; cin >> a >> b;
		k[a] = !k[a];
		k[b] = !k[b];
	}
	for (int i = 1; i <= n; i++)
		if (!k[i]) { cout << "NO\n"; return 0; }
	cout << "YES\n";
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI (acos(-1))
#define ct cout<<
#define cn cin>>
#define spc <<" "<<
#define nl puts("")
#define _fl(x) puts("FLAG " #x);
#define  _(x)  cout<< #x <<" is "<< x <<endl;
#define fs first
#define sc second
#define pb push_back
#define all(v)  (v).begin(), (v).end()
#define _109 (1000000000)
#define _0(arr) memset(arr,0,sizeof ( arr ) )
#define _1(arr) memset(arr,-1,sizeof ( arr ) )
#define _ninp(n,arr) for(int i=0; i<n;i++)cin>>arr[i];
#define _nout(n,arr) for(int i=0; i<n;i++)cout<<arr[i]<<" \n"[i==n-1];
double _eps=1e-6;
long long gcd(long long a, long long b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main() {

    int arr[]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
     
     int n;
     cn n;
     ct arr[n];nl;






    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N,Q;
    cin >> N >>Q;
    int64_t ans=-1;
    if(N==Q||Q==1)
    {
        cout << ans <<endl;
    }
    else
    {
        int co=1;
        ans=N;
        bool chk=true;
        while (chk)
        {
            if(!(ans%Q==0))
            {
                chk=false;
            }
            else
            {
                co++;
                ans=ans*co;
            } 
            if(abs(ans)>1e18)
            {
                cout << -1 <<endl;
                return 0;
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 256
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  int n,i,a[200010],d[200010];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    hin(a[i]);
  }
  for(i=0;i<n;i++)d[i]=N[hout()];
  for(i=0;i<n;i++)printf("%d\n",a[i]<=d[n/2-1]?d[n/2]:d[n/2-1]);
  return 0;
}


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

int main(){
    char c;
    cin >> c;
    
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
}

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

#define rep(i,beg,end)   for (auto i=(beg);i<(end);i++)
#define rep2(name,container) for(auto name=begin(container); name != end(container);name++)
#define all(cont)           begin(cont), end(cont)
#define rall(cont)           rbegin(cont), rend(cont)
using ll = long long;
using vi = vector<ll>;
const ll INFMAX = LLONG_MAX;
const ll INFMIN = LLONG_MIN;
const ll MOD = 1000000007;


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

	vector<string> weeks{ "SUN", "MON","TUE","WED","THU","FRI","SAT" };
	string s;
	cin >> s;
	auto ite = find(all(weeks), s);
	auto days = distance(ite, end(weeks));
	cout << days << endl;

	return 0;
}


Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

vector<int> pos[10];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	vector<int> cnt(10, 0);
	int n;
	string s;
	cin >> n;
	cin >> s;
	for(int i=0;i<s.length();i++) {
		pos[s[i]-'0'].push_back(i);
	}
	int ans = 0;
	for(int i=0;i<10;i++) {
		for(int j=0;j<10;j++) {
			for(int k=0;k<10;k++) {
				if(!pos[i].size() || !pos[j].size() || !pos[k].size()) continue;
				int tmp = ans;
				if(i == j && j == k) ans += (pos[i].size()>=3);
				else if(i == j) {
					if(pos[i].size() < 2) continue;
					ans += pos[k].back() > pos[i][1];
				}
				else if(j == k) {
					if(pos[j].size() < 2) continue;
					ans += pos[i][0] < pos[j][pos[j].size()-2];
				}
				else if(i == k) {
					if(pos[i].size() < 2) continue;
					if(pos[j].back() < pos[i][0]) continue;
					int it = lower_bound(pos[j].begin(), pos[j].end(), pos[i][0]) - pos[j].begin();
					ans += pos[j][it] < pos[i].back(); 
				}
				else {
					if(pos[j].back() < pos[i][0]) continue;
					int it = lower_bound(pos[j].begin(), pos[j].end(), pos[i][0]) - pos[j].begin();
					if(pos[k].back() < pos[j][it]) continue;
					ans++;
				}
			}
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  int N;
  cin >> N;
  int wari = 0;
  wari = 200*(N/15);
  cout << 800*N - wari << endl;
}


Measured memory_bytes: 256
N = int(input())
X = list(map(int,input().split()))
Y = sorted(X)
ans1 = Y[N//2-1]#小さいほう
ans2 = Y[N//2]#大きいほう
for i in range(N):
  if X[i] <= ans1: print(ans2)
  else: print(ans1)

Measured memory_bytes: 26016
#include <iostream>
#include <math.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int n, x[1002], y[1002];
double r[1002], mat[1002][1002], shortest[1002];
bool used[1002];

void set() {

	for (int i = 0; i < n + 2; i++) {
		for (int j = 0; j < n + 2; j++) {
			double p1 = pow(x[i] - x[j], 2);
			double p2 = pow(y[i] - y[j], 2);
			mat[i][j] = max((double)0, sqrt(p1 + p2)-(r[i]+r[j]));
		}
	}

}

double dijkstra() {
	for (int i = 0; i < n + 2; i++) {
		shortest[i] = -1;
	}
	shortest[0] = 0;

	while (true) {
		int v = -1;
		for (int i = 0; i < n + 2; i++) {
			if (!used[i] && shortest[i] != -1 && (v == -1 || shortest[v] > shortest[i])) {
				v = i;
			}
		}
		if (v == -1)break;
		used[v] = true;

		for (int i = 0; i < n + 2; i++) {
			if (shortest[i] == -1) {
				shortest[i] = shortest[v] + mat[v][i];
			}
			else {
				shortest[i] = min(shortest[i], shortest[v] + mat[v][i]);
			}
		}
	}

	return shortest[1];
}

int main() {
	cin >> x[0] >> y[0] >> x[1] >> y[1] >> n;
	for (int i = 2; i < n + 2; i++) {
		cin >> x[i] >> y[i] >> r[i];
	}
	set();

	cout << fixed << setprecision(10) << dijkstra() << endl;
}

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


int main(){
ios::sync_with_stdio(0);
cin.tie(0);
    ll n,m,k;cin>>n>>m>>k;
    ll arr[n+1];
    map<ll,ll>mp;
    ll tmp;
    arr[0]=0;
    rep(i,1,n+1){
        cin>>tmp;
        arr[i]=(tmp+arr[i-1]);
    }
    ll sum=0;mp[0]=0;
    rep(i,1,m+1){
        cin>>tmp;
        sum+=tmp;
        mp[sum]=i;
    }
    //rep(i,0,n+1)cout<<arr[i]<<" ";cout<<"\n";
    tmp=0;
    ll tmp2=0,ans=0;
    rep(i,0,n+1){
        if(arr[i]<=k){
            tmp=(k-arr[i]);
            auto it=mp.lower_bound(tmp);
            if(it->first > tmp)it--;
            //cout<<arr[i] <<" "<<it->first<<" "<<arr[i]+it->first<<"\n";
            tmp2=i+it->second;
            if(tmp2>ans)ans=tmp2;
        }
        else break;
    }
    cout<<ans;
return 0;
}

Measured memory_bytes: 17708
#include<stdio.h>

#define NUM 10000000
 #define N 100

 void def(int,int);
 
int n;
int arraysi[N],arrayc[N][N];
int arrayd[N],arrayt[N][N];
 
int main(int argc,char *argv[]){

  int i,j,m;

  scanf("%d",&n);

  for(i = 0;i < n;i++){

    scanf("%d",&m);

    scanf("%d",&arraysi[m]);

    for(j = 0;j < arraysi[m];j++){

      scanf("%d",&arrayt[m][j]);

      scanf("%d",&arrayc[m][j]);
    }
  }
 
  for(i = 0;i < n;i++) arrayd[i] = NUM;
  def(0,0);
  for(i = 0;i < n;i++){
    printf("%d %d\n",i,arrayd[i]);
  }
  return 0;

}
 
void def(int p,int x){

  int i;

  arrayd[p] = x;

  for(i = 0;i < arraysi[p];i++){

    if(arrayd[arrayt[p][i]] > x + arrayc[p][i]) def(arrayt[p][i],x + arrayc[p][i]);
  }

}

Measured memory_bytes: 680
import sys
from collections import Counter
N = int(sys.stdin.readline())
S = sys.stdin.read().split()
 
count = Counter(S)
max_num = max(count.values())

max_list = [i for i,j in count.items() if j==max_num]
 
max_list.sort()
print('\n'.join(max_list))

Measured memory_bytes: 38476
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("fma,avx,avx2")

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int inf = 1e9;

int get_num(string &s) {
    int res = 0;
    int n = sz(s);
    int pos = -1;
    for (int i = 0; i < n; i++) {
        if (s[i] == '.') {
            pos = i;
            break;
        }
        res *= 10;
        res += (s[i] - '0');
    }
    res *= inf;
    if (pos != -1) {
        int pow = inf;
        for (int i = pos + 1; i < n; i++) {
            pow /= 10;
            res += pow * (s[i] - '0');
        }
    }
    return res;
}

int cnt[20][20];

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        a[i] = get_num(s);
    }
    vector<pair<int, int>> b(n);
    for (int i = 0; i < n; i++) {
        int cnt2 = 0, cnt5 = 0;
        int x = a[i];
        while (x % 2 == 0) {
            cnt2++;
            x /= 2;
        }
        while (x % 5 == 0) {
            cnt5++;
            x /= 5;
        }
        b[i] = {cnt2, cnt5};
        cnt[min(cnt2, 18ll)][min(cnt5, 18ll)]++;;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 20; j++) {
            for (int k = 0; k < 20; k++) {
                if (b[i].x + j >= 18 && b[i].y + k >= 18) {
                    ans += cnt[j][k];
                }
            }
        }
        if (2 * b[i].x >= 18 && 2 * b[i].y >= 18) {
            ans--;
        }
    }
    cout << ans / 2 << "\n";

    return 0;
}


Measured memory_bytes: 7916
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXK 1000
int dp[MAXK+5][MAXK+5];
int main()
{
	int n,k,a,b,ans=0;
	char tc;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
	{
		bool c=0;
		scanf("%d%d %c",&a,&b,&tc);
		if(tc=='B') c=1;
		int p=a/k,q=b/k,x=a%k,y=b%k;
		if((p+q)%2) c=!c;
		if(c)
			dp[k][k]++,dp[x][k]--,dp[k][y]--,dp[x][y]+=2;
		else
			dp[x][k]++,dp[k][y]++,dp[x][y]-=2;
	}
	for(int j=k;j>=0;j--)
		for(int i=k;i>=0;i--)
		{
			dp[i][j]=dp[i+1][j]+dp[i][j+1]-dp[i+1][j+1]+dp[i][j];
			ans=max(ans,max(dp[i][j],n-dp[i][j]));
		}
	printf("%d\n",ans);
}

Measured memory_bytes: 4096
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
#import itertools
#import heapq
#from collections import deque
#d = deque()

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    n=int(readline())
    x=0
    ans="No"
    for i in range(n):
        a,b=map(int, readline().rstrip().split())
        if a==b:
            x+=1
        else:
            x=0
        if x >= 3:
            ans="Yes"
    print(ans)
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16136
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, K: int):
    if K <= A:
        print(K)
    elif A < K <= A+B:
        print(A)
    elif A+B < K:
        print(A-(K-A-B))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, C, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception{
        double d,a,x,y,t;
        x = 0;
        y = 0;
        t = 90;
        Scanner sc = new Scanner(System.in).useDelimiter(",|\n");
        while(true){
            d = sc.nextDouble();
            a = sc.nextDouble();
            if ((d==0) && (a==0)){
                System.out.println((int)(x));
                System.out.println((int)(y));
                break;
            }
            x += d*Math.cos(t/180*3.141592);
            y += d*Math.sin(t/180*3.141592);
            t -= a;
        }
    }
}


Measured memory_bytes: 28092
package main

import "fmt"

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_D>
 */

func init() {
}

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)

	a := make([][]int, n)
	b := make([][]int, m)
	c := make([][]int, n)

	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
		for j := 0; j < m; j++ {
			fmt.Scanf("%d", &a[i][j])
		}
	}
	for j := 0; j < m; j++ {
		b[j] = make([]int, 1)
		for k := 0; k < 1; k++ {
			fmt.Scanf("%d", &b[j][k])
		}
	}
	for i := 0; i < n; i++ {
		c[i] = make([]int, 1)
		for k := 0; k < 1; k++ {
			for j := 0; j < m; j++ {
				c[i][k] += a[i][j] * b[j][k]
			}
		}
	}
	for i := 0; i < n; i++ {
		fmt.Println(c[i][0])
	}
}

Measured memory_bytes: 1828
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
		try{
			Scanner sc = new Scanner(System.in);
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
				System.out.println("Possible");
			}else{
				System.out.println("Impossible");
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}

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

class Dice{
    private:
        std::vector<int> d;
    public:
        Dice(std::vector<int> a) {
            d = a;
            d.push_back(0); // tmp用
        }

        void N() {
            d.at(6) = d.at(1 - 1);
            d.at(1 - 1) = d.at(2 - 1);
            d.at(2 - 1) = d.at(6 - 1);
            d.at(6 - 1) = d.at(5 - 1);
            d.at(5 - 1) = d.at(6);
        }

        void S() {
            d.at(6) = d.at(1 - 1);
            d.at(1 -1 ) = d.at(5 - 1);
            d.at(5 - 1) = d.at(6 - 1);
            d.at(6 - 1) = d.at(2 - 1);
            d.at(2 - 1) = d.at(6);
        }

        void W() {
            d.at(6) = d.at(1 - 1);
            d.at(1 - 1) = d.at(3 - 1);
            d.at(3 - 1) = d.at(6 - 1);
            d.at(6 - 1) = d.at(4 - 1);
            d.at(4 - 1) = d.at(6);
        }

        void E() {
            d.at(6) = d.at(1 - 1);
            d.at(1 - 1) = d.at(4 - 1);
            d.at(4 - 1) = d.at(6 - 1);
            d.at(6 - 1) = d.at(3 - 1);
            d.at(3 - 1) = d.at(6);
        }

        void R() {
            // 右回転
            d.at(6) = d.at(2 -1);
            d.at(2 - 1) = d.at(4 - 1);
            d.at(4 - 1) = d.at(5 - 1);
            d.at(5 - 1) = d.at(3 - 1);
            d.at(3 - 1) = d.at(6);
        }

        void L() {
            // 左回転
            d.at(6) = d.at(2 - 1);
            d.at(2 - 1) = d.at(3 - 1);
            d.at(3 - 1) = d.at(5 - 1);
            d.at(5 - 1) = d.at(4 - 1);
            d.at(4 - 1) = d.at(6);
        }

        int get_dice(int i) {
            return d.at(i - 1);
        }
 };

int main(void) {
    using namespace std;

    vector<int> a(6);
    for (int i = 0; i < 6; i++) {
        cin >> a.at(i);
    }

    vector<int> b(6);
    for (int i = 0; i < 6; i++) {
        cin >> b.at(i);
    }

    Dice dice(a);
    Dice dice2(b);

    bool flg1 = false;

    // まずは縦回転させる
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            if (dice.get_dice(1) == dice2.get_dice(1)) {
                // 1面があったら2面目にとりかかる
                // 1面は合ったので、あとは右回転させ続ける
                for (int k = 0; k < 4; k++) {
                    if (dice.get_dice(2) == dice2.get_dice(2)) {
                        // 2面目も合った場合は判定する
                        if (dice.get_dice(3) == dice2.get_dice(3) &&
                            dice.get_dice(4) == dice2.get_dice(4) &&
                            dice.get_dice(5) == dice2.get_dice(5) &&
                            dice.get_dice(6) == dice2.get_dice(6)) {
                            flg1 = true;
                        }
                    }
                    dice2.R();
                }
            } 
            dice2.N();
        }
        // 横回転させる
        dice2.W();
    }

    if (flg1 == true) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#include <map>
#include <string>

using namespace std;

int main()
{
    map<string, int> card;
    int max = 0;
    string name;
    int n, m;

    cin >> n;

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

    cin >> m;

    for (int i = 0; i < m; i++) {
        cin >> name;
        card[name]--;
    }

    for (auto x: card) {
        if (max < x.second) {
            max = x.second;
        }
    }

    cout << (max > 0 ? max : 0) << endl;

}


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

#define maxn 100010 

int n ;
ll a[maxn],b[maxn] ;
ll c[maxn*2],presum[maxn*2] ;
ll sum, ans, suma, sumb ;

int main(void) {
	//freopen("1.txt","r",stdin) ;

	scanf("%d",&n) ;
	for(int i=0; i<n; i++) {
		scanf("%lld%lld", &a[i], &b[i]) ;
		suma += a[i] ;
		sumb += b[i] ;	
	}
	ans = min(suma, sumb ) ;
	for(int i=0; i<n; i++ ) {
		c[i*2] = a[i] ;
		c[i*2+1] = b[i] ;
	}
	sort(c,c+2*n) ;
	presum[0] = c[0] ;
	for(int i=1; i<=2*n; i++) {
		presum[i] = presum[i-1]+c[i] ;
	}
	for(int i=0; i<n; i++) {
		int pos = n - 2 ;
		int tmp = 0 ;
		if( a[i]>c[pos] ) tmp += a[i] ;
		else pos ++ ;
		if( b[i]>c[pos] ) tmp += b[i] ;
		else pos ++ ;
		ans = min( ans, tmp + presum[pos-1]) ;
	}
	printf("%lld\n",ans ) ;
	return 0 ;
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    string s; cin >> s;
    int size = s.size();

    int cnt=0;
    reps(i,1, stoi(s)+1){
        string st=to_string(i);
        if(st.size()%2==1) cnt++;
    }
    out(cnt);
}

Measured memory_bytes: 3632
#include<algorithm>
#include<cstring>
#include<cstdio>
#define ll long long
int n,x,t;
int main(){
	scanf("%d%d%d",&n,&x,&t);
	int T=n/x+(!!(n%x));
	printf("%d\n",T*t);
	return 0;
}

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

int main(){
  int N,x;
  cin >> N >> x;
  int a[N];
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  sort(a,a+N);
  int i=0;
  while(x>0&&i<N){
    x =x- a[i];
    i++;
  }
  if(x==0){
    cout << i;
  }
  else{
    i--;
    cout << i;
  }
}



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

using namespace std;

template< typename Data, typename T >
struct ReRooting {

  struct Node {
    int to, rev;
    Data data;
  };

  using F1 = function< T(T, T) >;
  using F2 = function< T(T, int, int, Data) >; // ret, src, to, data


  vector< vector< Node > > g;
  vector< vector< T > > ldp, rdp;
  vector< int > lptr, rptr;
  const F1 f1;
  const F2 f2;
  const T ident;

  ReRooting(int n, const F1 &f1, const F2 &f2, const T &ident) :
      g(n), ldp(n), rdp(n), lptr(n), rptr(n), f1(f1), f2(f2), ident(ident) {}

  void add_edge(int u, int v, const Data &d) {
    g[u].emplace_back((Node) {v, (int) g[v].size(), d});
    g[v].emplace_back((Node) {u, (int) g[u].size() - 1, d});
  }

  T dfs(int idx, int par) {

    while(lptr[idx] != par && lptr[idx] < g[idx].size()) {
      auto &e = g[idx][lptr[idx]];
      ldp[idx][lptr[idx] + 1] = f1(ldp[idx][lptr[idx]], f2(dfs(e.to, e.rev), idx, e.to, e.data));
      ++lptr[idx];
    }
    while(rptr[idx] != par && rptr[idx] >= 0) {
      auto &e = g[idx][rptr[idx]];
      rdp[idx][rptr[idx]] = f1(rdp[idx][rptr[idx] + 1], f2(dfs(e.to, e.rev), idx, e.to, e.data));
      --rptr[idx];
    }
    if(par < 0) return rdp[idx][0];
    return f1(ldp[idx][par], rdp[idx][par + 1]);
  }

  vector< T > solve() {
    for(int i = 0; i < g.size(); i++) {
      ldp[i].assign(g[i].size() + 1, ident);
      rdp[i].assign(g[i].size() + 1, ident);
      lptr[i] = 0;
      rptr[i] = (int) g[i].size() - 1;
    }
    vector< T > ret;
    for(int i = 0; i < g.size(); i++) {
      ret.push_back(dfs(i, -1));
    }
    return ret;
  }
};

using vi = vector< int >;

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

  auto f1 = [](vi a, vi b) {
    for(auto &p : b) a.push_back(p);
    sort(a.rbegin(), a.rend());
    a.resize(min((int) a.size(), 2));
    return a;
  };
  auto f2 = [](vi a, int src, int to, int d) {
    a.push_back(0);
    return vi{*max_element(a.begin(), a.end()) + d};
  };

  ReRooting< int, vi > g(N, f1, f2, {});
  for(int i = 1; i < N; i++) {
    int s, t, w;
    cin >> s >> t >> w;
    g.add_edge(s, t, w);
  }

  auto v = g.solve();
  int ret = 0;
  for(auto &p : v) {
    if(p.size() >= 2) ret = max(ret, p[0] + p[1]);
    if(p.size() >= 1) ret = max(ret, p[0]);
  }
  cout << ret << endl;
}


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

int main(){
  int K,A,B;
  cin >> K >> A >> B;
  for(int i=A;i<=B;i++){
    if(i%K==0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define forn(i,n) for(int i = 0; i < (int) n; ++i)
#define ios ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

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

  vector<int> ans(n + 1);
  for(int a = 1; a * a <= n; a++)
    for(int b = 1; a * a + b * b + a * b <= n; b++)
      for(int c = 1; 1ll * a * a + b * b + c * c + a * b + a * c + b * c <= n; c++)
        ans[a * a + b * b + c * c + a * b + a * c + b * c]++;
  forn(i, n) cout << ans[i + 1] << "\n";
}


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

int main(){
    int n;
    string s;

    cin >> n >> s;

    int maxv = 0;
    for(int i = 1; i <= n; i++){
        string x, y;
        x = s.substr(0, i);
        y = s.substr(i);
        set<char> set_x;
        set<char> set_y;
        for(int j = 0; j < x.size(); j++){
            set_x.insert(x[j]);
        }
        for(int j = 0; j < y.size(); j++){
            set_y.insert(y[j]);
        }

        set<char>::iterator it;
        int count = 0;
        for(it = set_x.begin(); it != set_x.end(); it++){
            if(set_y.find(*it) != set_y.end()){
                count++;
            }
        }

        maxv = max(maxv, count);
    }

    cout << maxv << endl;

    return 0;
}

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

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> vec(N+1, 0);
    for(int m=0; m<M; m++) {
        int a, b;
        cin >> a >> b;
        vec[a]++;
        vec[b]++;
    }
    
    for(int n=1; n<=N; n++) {
        if(vec[n]%2!=0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;



    return 0;
    
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep1(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define rep(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
#define mpi map<int,int>
#define N 200005
#define pql priority_queue<ll>
#define all(v) (v).begin(),(v).end()
#define str stringstream
using namespace std;
int main() {
	int a,b,c,d,e,k;
	cin>>a>>b>>c>>d>>e>>k;
	if(e-a>k)cout<<":(";
	else cout<<"Yay!";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <queue>
#include <vector>
#include <set>


using namespace std;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

template<class T> inline bool chmin(T& a, T b) {
  //aの方が大きければ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;
}
bool compare_a_big(pair<int,int> l,pair<int,int> r){
  //firstが大きい方からソート、firstが同じならbが小さい方から
  if(l.first != r.first){
    return l.first>r.first;
  }
  else{
    return l.second < r.second;
  }
}
bool compare_a_b_big(pair<int,int> l,pair<int,int> r){
  //firstが大きい方からソート、firstが同じならbが大きい方から
  if(l.first != r.first){
    return l.first>r.first;
  }
  else{
    return l.second > r.second;
  }
}
bool compare_b_small(pair<int,int> l,pair<int,int> r){
  //secondが小さい方からソート、firstが同じならfirstが小さい方から
  if(l.second != r.second){
    return l.second<r.second;
  }
  else{
    return l.first < r.first;
  }
}
const int INF = 1e9;
const int M = 1000000007;


typedef long long int ll;
vector<ll> fac(3001); //n!(mod M)
vector<ll> ifac(3001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算、a,b<=300000でないと使えない
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<3000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

typedef long long int ll;

int pow(int a,int b){
  if(b==0) return 1;
  else{
    return a*pow(a,b-1);

  }
}

typedef struct ListNode {
    int data;
    struct ListNode *next;
} ListNode;



int main(){

  ll s;
  cin >> s;

  if(s < 3){
    cout << 0 << endl;
  }
  else{
    ll dev = s/3;
    int ans = 0;
    for(ll i=2;i<=dev;i++){
      ans = (ans +  comb(s-2*i-1,i-1))%M;
    }

    if(1+ans > 0){
      cout << (1+ans)%M << endl;
    }else{
      cout << (1+ans+M) << endl;
    }
  }




}


Measured memory_bytes: 3664
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
sumdigits(n, base=10) = sum(digits(n, base))

function main()
    n=parseInt(readline())
    ans=10^5
    for i in 1:div(n,2)+1
        ans=min(ans,sumdigits(i)+sumdigits(n-i))
    end
    println(ans)
end
main()

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

#define pb push_back
#define ins insert 
#define ers erase 
#define all(x) x.begin(), x.end()
#define F first 
#define S second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef string str;
typedef long double ld;

str s;

int main(){
	cin >> s;
	ll Cnt = 0;
	for (int i = 1; i < s.size(); i++){
		if (s[i] != s[i - 1]) Cnt ++;
	}
	cout << Cnt;
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  string S;
  cin >> S;
  bool OK = true;
  if (S.size()%2==0) {
    for (int i=0; i<S.size()-1; i++) {
      if (i%2==0) {
        if (S[i]!='h'||S[i+1]!='i') {
          OK = false;
          break;
        }
      }
      else if (S[i]!='i'||S[i+1]!='h') {
        OK = false;
        break;
      }
    }
  }
  else OK = false;
  if (OK) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 2000000

void maxHeapify(int);
void swap(int,int);
void insert(int);
int extract(void);

int array[MAX],key_count=0;
  
int main(){
  int i,key;
  char command[10];
  while(1){
    scanf("%s",command);
    if(command[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }
    else if(command[0]=='e' && command[1] =='n')break;
    else printf("%d\n",extract());
  }
  return 0;
}

void insert(int key){
  int i=key_count;
  array[key_count++]=key;
  while(i > 0 && array[(i-1)/2] < array[i]){
    swap((i-1)/2,i);
    i = (i-1)/2;
  }
}

int extract(){
  int return_number;
  return_number = array[0];
  array[0] = array[--key_count];
  maxHeapify(0);
  return return_number;
}
  
void maxHeapify(int i){
  int l,r,max;
 
  l = i*2+1;
  r = (i+1)*2;
  if(l < key_count && array[l] > array[i])max = l;
  else max = i;
  if(r < key_count && array[r] > array[max])max = r;
  if(max != i){
    swap(i,max);
    maxHeapify(max);
  }  
}

void swap(int i,int j){
  int tmp;
  tmp = array[i];
  array[i] = array[j];
  array[j] = tmp;
}



Measured memory_bytes: 5692
#include<cstdio>
#include<iostream>
#include<vector>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int a[1010];
bool cmp(long long x,long long y)
{
	return x>y;
}
long long s[1010],g[1010101];
int main()
{
	int n,k,i,j,now,l,r,cnt=0;
	long long ans=0,tmp;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		s[i]=s[i-1]+a[i]; 
	}
	for(i=1;i<=n;i++)
		for(j=i;j<=n;j++)
			g[++cnt]=s[j]-s[i-1];
	l=1,r=cnt;
	for(i=60;i>=0;i--)
	{
		sort(g+1,g+r+1,cmp);
		now=0;
		for(j=1;j<=r;j++)
		{
//			printf("%lld\n",g[j]);
			tmp=((1ll<<i)&g[j]);
			g[j]-=tmp;
			if(tmp)
				now=j; 
		}
//		printf("%d %d\n",i,now);
		if(now>=k)
			r=now,ans+=(1ll<<i);
//		printf("%d %lld\n",i,ans);
	}
	printf("%lld\n",ans);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	return 0;
}


Measured memory_bytes: 4352
n, m = [int(i) for i in input().split()]

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

for i in range(n):
    l = [abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]) for j in range(m)]
    print(l.index(min(l)) + 1)

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        if(N%K==0)System.out.println(0);
        else System.out.println(1);
    }
}

Measured memory_bytes: 21844
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a,int b){return a*b/gcd(a,b);}
//priority_queue<int, vector<int>, greater<int> > que; //昇順

using namespace std;

const int mod=1e9+7;

int ans=0;

signed main(){
    SPEED;
    string s,t;
    cin >> s >> t;
    int len = s.length();
    rep(i,len)
    {
        if(s==t)
        {
            cout << "Yes" << endl;
            return 0;
        }
        s=s.substr(len-1) + s;
        s.erase(len);
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
n = int(input())
s = input()
alph=[chr(ord('A') + i) for i in range(26)]
ans = []
for i in range(len(s)):
    alph_idx = alph.index(s[i]) + n
    if alph_idx >= 26:
        alph_idx -= 26
    ans.append(alph[alph_idx])
print(''.join(ans))


Measured memory_bytes: 3060
import math
def isPrime(x):
    if x==2:
        return True
    
    if x<2 or x%2==0:
        return False
    
    i = 3
    while i <= math.sqrt(x):
        if x%i == 0:
            return False
        i = i+2
    
    return True

if __name__ == "__main__":
    n = int(input())
    a = []
    for l in range(0,n,1):
        a.append(int(input()))
    cnt = 0
    for x in a:
        if isPrime(x):
            cnt += 1
    print(cnt)



Measured memory_bytes: 6000
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    vector<vector<int>> table(N);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            int a;
            cin >> a;
            if (a == 1) table[i].push_back(j);
        }
    }

    vector<vector<int>> dp(N+1, vector<int>(1 << N, 0));
    dp[0][0] = 1;

    for (int i = 0; i < N; i++) {
        for (int mask = 0; mask < (1 << N); mask++) {
            if (i != __builtin_popcountll(mask)) continue;

            for (int j : table[i]) {
                if ((mask & (1 << j))) continue;
                dp[i+1][mask | (1 << j)] += dp[i][mask];
                dp[i+1][mask | (1 << j)] %= MOD;
            }
        }
    }

    cout << dp[N][(1 << N) - 1] << endl;

    return 0;
}

Measured memory_bytes: 377216
#include <bits/stdc++.h>
#define IOS             ios::sync_with_stdio(false); cin.tie(nullptr)
#define deb(x)          cout << #x << " = " << x << endl
#define deb2(x, y)      cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define f0(i, a, n)     for(i = a; i < n; i++)
#define f1(i, a, n)     for(i = a; i <= n; i++)
#define tc(t)           int t; cin >> t; while(t--)
#define ini(x, y)       memset(x, y, sizeof(x))
#define all(x)          x.begin(),x.end()
#define sz(x)           x.size()
#define ll              long long int
#define vi              vector<int>
#define si              set<int>
#define pb              emplace_back
#define ppb             pop_back
#define mp              make_pair
#define M               1000000007
#define endl            '\n'
#define bits(x)         __builtin_popcountll(x)
#define zrbits(x)       __builtin_ctzll(x)

using namespace std;

void solve() {
    int n = 0;
    string s;
    cin >> s;
    
    if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') n = 3;
    else if((s[1] == 'R' && s[0] == 'R') || (s[1] == 'R' && s[2] == 'R')) n = 2;
    else if(s[1] == 'R' || s[0] == 'R' || s[2] == 'R') n = 1;
    cout << n << endl;
}

int main () {
    IOS;
    // tc(t)
    solve();
    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  string s; cin >> s;
  bool ok = true;
  if(s[0] != 'A') {
    ok = false;
  } else {
    FOR(i, 2, SZ(s)-1) {
      if(s[i] == 'C') break;
      if(i == SZ(s)-2) ok = false;
    }
    int cnt = 0;
    REP(i, SZ(s)) {
      if('A' <= s[i] && s[i] <= 'Z') cnt++;
    }
    if(cnt != 2) ok = false;
  }

  cout << (ok ? "AC" : "WA") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,s;
	cin>>a>>b;
	s=b;
	c=a*10;
	for(int i=0;;i++){
		if(s<10){
			break;
		}
		s=s/10;	
		c=c*10;
	}
	c=c+b;	
	int i=0;
	while(i*i<=c){
		if(i*i==c){	
			cout<<"Yes";
			return 0;
		}
		i++;
	}
	cout<<"No";
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    // 優先順位は自明にswap -> change
    // というかchangeいらなくない？
    ll N; cin >> N;
    string S; cin >> S;
    vector<ll> L(N + 1), R(N + 1);
    L.at(0) = 0; R.at(0) = 0;
    rep(i, S.size()){
        if (S[i] == 'R'){
            R.at(i + 1) = R.at(i) + 1;
            L.at(i + 1) = L.at(i);
        }else{
            R.at(i + 1) = R.at(i);
            L.at(i + 1) = L.at(i) + 1;
        }
    }
    ll r_total = R.at(N);
    cout << r_total - R.at(r_total) << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 6764
#include <stdio.h>
int main(void){

 int x[10000];
 int i;
 int n;

 i = 0;
 while(1){
  scanf("%d",&x[i]);
  if(x[i]==0){
   break;
  }
  i++;
 }
 n=i;

for(i=0;i<n;i++){

printf("Case %d: %d\n",i+1,x[i]);
}


 return 0;

} 

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextLong();
  string s; cin >> s;
  string t = s;
  sort(ALL(t));

  int ans = 0;
  REP(i, N) {
    if (s[i] != t[i]) ans++;
  }


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

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3984
#include<stdio.h>
#include<limits.h>
int main(){
  int n;
  int i;
  long max = LONG_MIN;
  long min = LONG_MAX;
  long sum = 0;
  int num;

  scanf("%d",&n);

  for( i=0;i<n;i++){
    scanf("%d", &num);

    if(num < min){
      min = num;
    }
    if(num > max){
      max = num;
    }
    sum += num;
  }
  
  printf("%ld %ld %ld\n",min, max, sum);
  return 0;
}



Measured memory_bytes: 2736
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> ordered_mset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
/*.....................................................................................................................*/

    const ll mod=(ll)1e9+7;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;}
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll man=(ll)1e5+5;
/*........................................................................................................................*/

signed main()
{
    fast;
    ll n;
    cin>>n;
    ll a[n];
    For(i,n)cin>>a[i];
    ll ans=1;
    ll mx=a[0];
    f(i,1,n)
    {
        if(a[i]<=mx)
        {
            ans++;
            mx=a[i];
        }
    }
    cout<<ans<<endl;
}   


Measured memory_bytes: 5168
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

bool isGumoji(vector<char> s_v) {
	if (s_v.size() % 2 != 0) {
		return false;
	}
	else {
		for (int i = 0; i < s_v.size() / 2; i++) {
			if (s_v[i] != s_v[s_v.size() / 2 + i]) {
				return false;
			}
		}
		return true;
	}
}

int main() {

	string s;
	cin >> s;
	vector<char> s_v(s.begin(), s.end());

	s_v.pop_back();
	while (true) {
		if (isGumoji(s_v)) {
			cout << s_v.size();
			return 0;
		}
		else {
			s_v.pop_back();
		}
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAX_N = 53;

int n;
int p[MAX_N];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> p[i];

	bool sorted = true;
	for (int i = 1; i < n; i++)
		sorted &= p[i] >= p[i - 1];
	if (sorted)
	{
		cout << "YES" << endl;
		return 0;
	}

	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
		{
			swap(p[i], p[j]);
			bool sorted = true;
			for (int i = 1; i < n; i++)
				sorted &= p[i] >= p[i - 1];
			if (sorted)
			{
				cout << "YES" << endl;
				return 0;
			}
			swap(p[i], p[j]);
		}
	cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int a, b;
    cin >> a >> b;

    cout << ( a*b % 2 != 0 ? "Yes" :"No" ) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    while(true){
        int h,w;
        cin >> h >> w;
        if(h == 0) break;
        rep(i,h){
            rep(j,w){
                cout << ((i+j)%2 == 0 ? '#' : '.');
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3080