akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;

void BubbleSort(vector<int> &A, int &count)
{
	bool flag = true;
	while(flag){
		flag = false;
		for(int j = A.size() - 1; j >= 1; j--){
			if(A[j] < A[j-1]){
				swap(A[j], A[j-1]);
				flag = true;
				count++;
			}
		}
	}
}

void Output(vector<int> A)
{
	int n = A.size() - 1;
	for(int i = 0; i < n; i++) cout << A[i] << ' ';
	cout << A[n] << endl;
}

vector<int> Input()
{
	int N;
	cin >> N;
	vector<int> A;
	A.resize(N);
	for(int i = 0; i < N; i++) cin >> A[i];
	return A;
}

int main()
{
	vector<int> A = Input();
	int count = 0;
	BubbleSort(A, count);
	Output(A);
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  map<int, int> m;

  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
    m[A[i]]++;
  }

  for(auto &p : m){
    if(p.second%2 == 0) p.second = 2;
    else p.second = 1;
  }

  int cnt = 0;
  for(auto p : m){
    if(p.second == 2) cnt++;
  }

  int ans = m.size();
  if(cnt%2 == 1) ans--;

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 7296
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        int[] numbers = IntStream.range(0,3).map(i->sc.nextInt()).toArray();
        Arrays.sort(numbers);

        int ans = numbers[2] - numbers[0];
        out.print(ans);

        out.println();
        out.close();
    }

    // -----------http://codeforces.com/blog/entry/7018---------------------------------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    // --------------------------------------------------------
}


Measured memory_bytes: 26452
<?php
$Rectangle=trim(fgets(STDIN));
$ab = explode(" ", $Rectangle);
$a=$ab[0];
$b=$ab[1];
if(-1000<=$a && $a<=1000 && -1000<=$b && $b<=1000){
    if($a > $b){
        echo "a > b";
    }
    else if($a < $b){
        echo "a < b";
    }
    else{
        echo "a == b";
    }
}
?>

Measured memory_bytes: 15368
def f(i):
    if i == n:
        on = [0] * m
        for j in range(m):
            for k in range(1, s[j][0] + 1):
                if t[s[j][k] - 1]:
                    on[j] += 1
        for j in range(m):
            if not on[j] % 2 == p[j]:
                return
        global ans
        ans += 1
        return
    t[i] = 1
    f(i + 1)
    t[i] = 0
    f(i + 1)
    return

n, m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
t = [0] * n
f(0)
print(ans)

Measured memory_bytes: 9148
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    int plus = a + b;
    int minus = a - b;
    int multi = a * b;
    
    if (plus >= minus && plus >= multi) {
      System.out.println(plus);
    } else if (minus >= plus && minus >= multi) {
      System.out.println(minus);
    } else if (multi >= plus && multi >= minus) {
      System.out.println(multi);
    }
  }
}

Measured memory_bytes: 21204
#include <stdio.h>

typedef long long ll;

ll a[100005];

int main(){

	int N;

	ll x;

	scanf("%d %lld",&N,&x);

	int i;

	for(i=0;i<N;i++){
		scanf(" %lld",&a[i]);
	}

	ll ans=0ll;

	for(i=0;i<=N-2;i++){
		if(a[i]+a[i+1]>x){
			if(a[i+1]>0ll){
				if(a[i]+a[i+1]-x<=a[i+1]){
					ans+=a[i]+a[i+1]-x;
					a[i+1]-=a[i]+a[i+1]-x;
				}
				else{
					ans+=a[i]+a[i+1]-x;
					a[i]-=a[i]-x;
					a[i+1]=0ll;
				}
			}
			else{
				ans+=a[i]-x;
				a[i]-=a[i]-x;
			}
		}
	}

	printf("%lld\n",ans);


	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdint.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define MIN(a,b) ((a<b) ? a : b)

int main(void) {
  int n;
  scanf("%d", &n);

  int64_t a[100000];
  rep(i, n) {
    scanf("%ld", &a[i]);
  }

  //+ start
  int64_t P_ANS = 0;
  int64_t P_SUM = 0;
  rep(i, n) {
    P_SUM += a[i];
    if((i % 2) == 0) {// Even-Plus
      if(P_SUM <= 0) {
	P_ANS += (1 - P_SUM);
	P_SUM = 1;
      }
    } else {// Odd-Minus
      if(P_SUM >= 0) {
	P_ANS += (1 + P_SUM);
	P_SUM = -1;
      }
    }
  }

  //- start
  int64_t M_ANS = 0;
  int64_t M_SUM = 0;
  rep(i, n) {
    M_SUM += a[i];
    if((i % 2) == 1) {// Odd-Plus
      if(M_SUM <= 0) {
	M_ANS += (1 - M_SUM);
	M_SUM = 1;
      }
    } else {// Even-Minus
      if(M_SUM >= 0) {
	M_ANS += (1 + M_SUM);
	M_SUM = -1;
      }
    }
  }

  int64_t ANS = MIN(P_ANS, M_ANS);
  printf("%ld\n", ANS);
  return 0;
}


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

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

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N, M,V,P;
ll A[101010];
ll i, j, k, ans;

bool bs(ll ii){
    ll S = (V - 1) * M;
    ll i = 0;
    ll a = A[ii - 1] + M;
    fornum(i,P-1,N){
        if(i==ii-1)
            continue;
        if(A[i]>a)
            return false;
        S -= min(a - A[i], M);
    }
    //printf("%lld,%lld\n", ii, S);
    return S <= 0;
}

int main(){
    scanf("%lld%lld%lld%lld", &N, &M, &V, &P);
    fornum(i,0,N){
        scanf("%lld", &A[i]);
    }
    sort(A, A + N,greater<ll>());
    V -= P - 1;
    V = max(V, 1ll);
    fornum(i, 0, P-1)
    {
        j += A[i];
    }
    ll l = P - 1, r = N;
    while(l<r){
        ll c = (l + r + 1) / 2;
        if(bs(c)){
            l = c;
        }else{
            r = c - 1;
        }
    }
    printf("%lld", l);

    return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(java.util.Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: java.util.Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val A = Array(N) { sc.next().toLong() }
        val X = Array(N) { 0L }
        for (i in 1 until N) {
            X[(i * 2) % N] = X[(i * 2 - 2) % N] + A[(i * 2 - 1) % N] - A[(i * 2 - 2) % N]
        }
        val d = (A.sum() - X.sum() * 2) / N
        pw.println(X.map { it * 2 + d }.joinToString(" "))
    }
}


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

using namespace std;

int n, w;
long long weight[101];
long long value[101];
long long dp[100001][101];

int main()
{
    cin >> n >> w;
    for(int i = 1; i <= n; i++)
    {
        cin >> weight[i] >> value[i];
    }

    for(int i = 0; i <= w; i++)
    {
        dp[i][0] = 0;
    }

    for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j <= w; j++)
        {
            if(j - weight[i] >= 0) dp[j][i] = max(dp[j][i-1], dp[j - weight[i]][i-1] + value[i]);
            else dp[j][i] = dp[j][i-1];
        }
    }

    long long mx = 0;
    for(int i = 1; i <= w; i++)
    {
        if(dp[i][n] > mx) mx = dp[i][n];
    }

    /*for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j <= w; j++)
        {
            cout << dp[j][i] << ' ';
        }
        cout << endl;
    }*/

    cout << mx << endl;

}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 500005;

int a, b;

int main() {
scanf("%d %d", &a, &b);

if (a == 1 || b == 1) printf("1\n"); else if (a % 2 == 0 || b % 2 == 0) printf("%lld\n", a * 1LL * b / 2); else printf("%lld\n", a * 1LL * b / 2 + 1);
return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<algorithm>
#include<vector>

#define maxn 2000005
#define MOD 1000000007

using namespace std;

inline int getint()
{
	int num=0,flag=1;char c;
	while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
	while(c>='0'&&c<='9')num=num*10+c-48,c=getchar();
	return num*flag;
}

int x3,y3,x4,y4;
long long fac[maxn],inv[maxn];
struct node{int x,y,k;}a[4],b[4];

inline long long F(int x1,int y1,int x2,int y2)
{return fac[x2-x1+y2-y1]*inv[x2-x1]%MOD*inv[y2-y1]%MOD;}

inline long long sol(node p,node q)
{
	int x1=p.x,y1=p.y,x2=q.x,y2=q.y;
	long long res=0;
	for(int i=x3;i<=x4;i++)res=(res+F(x1,y1,i,y3-1)*F(i,y3,x2,y2)%MOD*(-i-y3)%MOD)%MOD;
	for(int j=y3;j<=y4;j++)res=(res+F(x1,y1,x3-1,j)*F(x3,j,x2,y2)%MOD*(-j-x3)%MOD)%MOD;
	for(int i=x3;i<=x4;i++)res=(res+F(x1,y1,i,y4)*F(i,y4+1,x2,y2)%MOD*(i+y4+1)%MOD)%MOD;
	for(int j=y3;j<=y4;j++)res=(res+F(x1,y1,x4,j)*F(x4+1,j,x2,y2)%MOD*(j+x4+1)%MOD)%MOD;
	return res;
}

int main()
{
	int x1,x2,x5,x6,y1,y2,y5,y6;
	x1=getint(),x2=getint(),x3=getint(),x4=getint(),x5=getint(),x6=getint();
	y1=getint(),y2=getint(),y3=getint(),y4=getint(),y5=getint(),y6=getint();
	fac[0]=inv[0]=inv[1]=1;
	for(int i=1;i<maxn;i++)fac[i]=fac[i-1]*i%MOD;
	for(int i=2;i<maxn;i++)inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
	for(int i=1;i<maxn;i++)inv[i]=inv[i]*inv[i-1]%MOD;
	a[0]=(node){x2,y2,1},a[1]=(node){x2,y1-1,-1},a[2]=(node){x1-1,y2,-1},a[3]=(node){x1-1,y1-1,1};
	b[0]=(node){x6+1,y6+1,1},b[1]=(node){x6+1,y5,-1},b[2]=(node){x5,y6+1,-1},b[3]=(node){x5,y5,1};
	long long ans=0;
	for(int i=0;i<4;i++)for(int j=0;j<4;j++)ans=(ans+1ll*(a[i].k*b[j].k)*sol(a[i],b[j])%MOD)%MOD;
	printf("%lld\n",(ans+MOD)%MOD);
}

Measured memory_bytes: 31360
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;



int main(){
	int r;
	cin >> r;
	cout << r*r << endl;
	return 0;
}

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



int main()
{
    long long count[100001]={0};
    long long sum=0;
	int n;
    cin>>n;
    long long int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
        count[a[i]]+=1;
    }
    int q;
    cin>>q;
    while(q--)
    {
        int x,k;
        cin>>x>>k;
        sum+=(k-x)*count[x];
        count[k]+=count[x];
        count[x]=0;
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 5148
N = input()
state = 0
max = 0
min = 0
prev = 0
len = 0
ANS = 1
S = input()
A = list(map(int,S.split()))
 
for i in range(0,int(N)):
  len = len + 1
  if state in {0}:	# Initial state
      prev = A[i]
      state = 1
  elif state in {1}: # Newtral state
    if A[i] > prev:
      state = 2
    elif A[i] < prev:
      state = 3
  elif state in {2}: # Acsending state
    if A[i] < prev:
      state = 1
      ANS = ANS + 1
      len = 0
  elif state in {3}: # Descending state
    if A[i] > prev:
      state = 1
      ANS = ANS + 1
      len = 0
  prev = A[i]
#  print('s=', state, 'in=', A[i], 'prev=', prev, 'ANS=', ANS, 'len=', len)
print(ANS)

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

int p[MAXN];

int deg[MAXN];

int pc[2][MAXN];

int active[MAXN];

int len[MAXN];

int used[MAXN];

int comp_cnt[MAXN];

ll dp[MAXN];

void solve(){
	int n;
	
	// Read data
	scanf("%d", &n);
	REPN(i, 1, n){
		scanf("%d", &p[i]);
		deg[p[i]]++;
		pc[0][i] = p[i];
	}
	
	// Find active (in cycles)
	int maxlog = 18;
	REP(j, 0, maxlog){
		int ind = j & 1;
		REPN(i, 1, n){
			pc[ind ^ 1][i] = 0;
		}
		REPN(i, 1, n){
			pc[ind ^ 1][i] = pc[ind][pc[ind][i]];
		}
	}
	REPN(i, 1, n){
		active[pc[maxlog & 1][i]] = 1;
	}
	
	/*REPN(i, 1, n){
		printf("%d %d\n", i, active[i]);
	}*/
	
	// Check by degree
	REPN(i, 1, n){
		if (deg[i] > 2 || deg[i] == 2 && !active[i]){
			printf("0\n");
			return;
		}
	}
	
	// Fill tail lengths
	REPN(i, 1, n){
		if (deg[i] == 0){
			int cur_len, s;
			for(s = i, cur_len = 0; !active[s]; cur_len++, s = p[s]);
			len[s] = cur_len;
			
			//printf("%d %d\n", s, len[s]);
		}
	}
	
	ll ans = 1ll;
	
	// Process all tailed components
	REPN(i, 1, n){
		if (active[i] && !used[i] && len[i] > 0){
			int cur_len, s;
			for(s = i, cur_len = 0; ; cur_len++, s = p[s]){
				if (cur_len > 0 && len[s]){
					if (len[s] < cur_len){
						ans = (ans * 2ll) % MOD;
					} else if (len[s] > cur_len){
						ans = 0ll;
					}
					cur_len = 0;
				}
				if (used[s]){
					break;
				}
				used[s] = 1;
			}
		}
	}
	
	// Process all non-tailed components (cycles)
	
	// 1. Find components lengths
	REPN(i, 1, n){
		if (active[i] && !used[i]){
			int cur_len, s;
			for(s = i, cur_len = 0; !used[s]; cur_len++, s = p[s]){
				used[s] = 1;
			}
			comp_cnt[cur_len]++;
		}
	}
	
	// 2. Process components 
	REPN(i, 1, n){
		ll mul = 1;
		if (i > 1 && (i & 1)){
			mul = 2;
		}
		dp[0] = 1;
		dp[1] = mul;
		REPN(j, 2, comp_cnt[i]){
			ll v1 = (dp[j - 1] * mul) % MOD;
			ll v2 = (i * (j - 1) * dp[j - 2]) % MOD;
			dp[j] = (v1 + v2) % MOD;
		}
		ans = (ans * dp[comp_cnt[i]]) % MOD;
		
		//printf("%d %d %lld\n", i, comp_cnt[i], dp[comp_cnt[i]]);
	}
	
	printf("%lld\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 3328
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    string s; cin >> s;

    int l = s.size();
    string v, u;

    for(int i=0; i<l; i++){
        if(i>=(l-i-1)) break;
        if(s.at(i)!=s.at(l-i-1)){
            cout << "No" << endl;
            return 0;
        }
    }

    for(int i=0; i<(l-1)/2; i++){
        v.push_back(s.at(i));
    }

    int vl = v.size();
    for(int i=0; i<vl; i++){
        if(i>=(vl-i-1)) break;
        if(s.at(i)!=s.at(vl-i-1)){
            cout << "No" << endl;
            return 0;
        }
    }


    for(int i=(l+3)/2-1; i<l; i++){
        u.push_back(s.at(i));
    }

    int ul = u.size();
    for(int i=0; i<ul; i++){
        if(i>=(ul-i-1)) break;
        if(s.at(i)!=s.at(ul-i-1)){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  string str = "aiueo";
  string ans = "consonant";
  
  cin >> c;
  
  for(int i = 0; i < str.size(); i++){
    if(c == str.at(i)){
      ans = "vowel";
      break;
    }
	
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3552
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/agc006/tasks/agc006_a
N = read_a_int()
s = input()
t = input()
# tの先頭とsの末尾の一致具合を見る(Nが100なので全探索可能)

ans = 0
for i in range(1, N + 1):
    # print(s[-i:], t[:i])
    if s[-i:] == t[:i]:
        ans = i
print(N * 2 - ans)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
#define ALL(x) (x).begin(),(x).end()
inline cpp_int between(cpp_int n, cpp_int x) {
  if(n >= 0)
    return (n/x)+1;
  else
    return 0;
}

int main () {
  string s;
  cin >> s;
  int count = 0;
  int idx;

  if(s[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  }

  REPI(i, 2, s.size()-1){
    if(s[i] == 'C') {
      idx = i;
      count++;
    }
  }

  if(count != 1) {
    cout << "WA" << endl;
    return 0;
  }

  REPI(i, 1, s.size()){
    if(i != idx && !islower(s[i])) {
      cout << "WA" << endl;
      return 0;
    }
  }

  cout << "AC" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long N = input.nextLong();
		long M = input.nextLong();
		int n = (int)(N);
		int m = (int)(M);
		long mod = (long)(1e9+7);
		if (Math.abs(M-N)>=2) System.out.println(0);
		else {
			long[] fact = new long[1000005];
			fact[1]=1;
			for (long i = 2; i <= 100000; i++) {
				int index = (int)(i);
				fact[index]=fact[index-1]*i;
				fact[index]%=mod;
			}
			long ans = fact[n]*fact[m]; //Only one arrangement possible disregarding distinguishability
			ans%=mod;
			if (Math.abs(N-M)==1) {
				System.out.println(ans);
			}else {
				ans*=2; //Swapping is allowed when N=M
				ans%=mod;
				System.out.println(ans);
			}
		}
	}
}

Measured memory_bytes: 29396
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 1e18
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;

string S;
ll dp[101010][13];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>S;
    int n = S.size();
    dp[0][0] = 1;
    REP(i,n){
        int c;
        if(S[i] == '?') c = -1;
        else c = S[i] - '0';
        for(int j=0;j<10;j++){
            if(c != -1 && c != j) continue;
            for(int ki=0;ki<13;ki++){
                dp[i+1][(ki*10+j)%13] += dp[i][ki];
            }
        }
        for(int j=0;j<13;j++) dp[i+1][j] %= MOD;
    }
    cout<<dp[n][5]<<endl;
}

Measured memory_bytes: 10704
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

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


int main(){
    int N, a, b, c, d;
    cin >> N >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;

    string s;
    cin >> s;

    bool ok = true;
    for(int i = a; i <= c-1; i++){
        if(s[i] == '#' && s[i+1] == '#'){
            ok = false;
        }
    }
    for(int i = b; i <= d-1; i++){
        if(s[i] == '#' && s[i+1] == '#'){
            ok = false;
        }
    }

    if(c > d){
        bool ok2 = false;
        for(int i = b; i <= d; i++){
            if(i-1 >= 0 && i+1 < s.length()){
                if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.'){
                    ok2 = true;
                }
            }
        }
        if(!ok2){
            ok = false;
        }
    }

    if(ok){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

ll N;
map<ll, ll> mp;

signed main(){
    cin >> N;
    ll a;
    bool ok = true;
    REP(i, N){
        cin >> a;
        mp[a]++;
        if(mp[a] > 1) ok = false;
    }
    if(ok) PRINT("YES");
    else PRINT("NO");
    return 0;
}

Measured memory_bytes: 16080
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <queue>
#define ll long long
using namespace std;

int main() {
	priority_queue<int> que;
	int n, m;
	ll	ans = 0;
	int bn;

	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> bn;
		que.push(bn);
	}

	for (int i = 0; i < m; i++) {
		bn = que.top();
		que.pop();
		bn /= 2;
		que.push(bn);
	}

	for (int i = 0; i < n; i++) {
		ans += que.top();
		que.pop();
	}
	
	cout << ans;

	return 0;
}

Measured memory_bytes: 1020
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <array>

template<class T, std::size_t N>
class static_vector {
	std::array<T, N> data;
	std::size_t size;
public:
	constexpr static_vector() noexcept : data{}, size(0) {}
	constexpr void push_back( T e ) { data.at( size ) = std::move( e ); ++size; }
	constexpr auto begin() noexcept { return data.begin(); }
	constexpr auto end() noexcept { return data.begin() + size; }
};

std::array<static_vector<std::int32_t, 100000>, 54> q;
std::array<bool, 100000> visited;

int main() {
	std::int32_t K;
	std::cin >> K;

	for( int t = 1; t < 10; ++t ) {
		const std::int32_t cost = (K*t) % 10;
		const std::int32_t rem = (K*t) / 10;
		q.at( cost ).push_back( rem );
	}

	for( int i = 0; i <= 45; ++i ) {
		for( auto it = q[i].begin(); it != q[i].end(); ++it ) {
			const std::int32_t r = *it;

			if( r == 0 ) { std::cout << i << std::endl; return 0; }

			if( visited.at( r ) ) { continue; }
			visited.at( r ) = true;

			for( int t = 0; t < 10; ++t ) {
				const std::int32_t cost = (r+K*t) % 10;
				const std::int32_t rem = (r+K*t) / 10;
				q.at( i + cost ).push_back( rem );
			}
		}
	}
}


Measured memory_bytes: 18816
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
int main()
{
    ios;
    int n;
    cin>>n;
    int k;
    k=n%10;
    if(k==2||k==4||k==5||k==7||k==9)
        cout<<"hon"<<endl;
    else if(k==0||k==1||k==6||k==8)
        cout<<"pon"<<endl;
    else
        cout<<"bon"<<endl;

}


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

int main() {
  int N;
  cin >> N;
  int ans1 = 1;
  int ans2 = 1;
  int a;
  for (int i=0; i<N; i++) {
    cin >> a;
    ans1 *= 3;
    if (a%2 == 0) {
      ans2 *=2;
    }
  }
  
  cout << ans1 - ans2 << endl;
  return 0;
}

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

int main() {
 int n,sum=0;cin >> n;
 vector<int> w(n);
 for(int i=0;i<n;i++){
   cin >> w[i];
   sum+=w[i];
   }
 int stl=0;
 long long dif=10000000;
 for(int i=0;i<n;i++){
   stl+=w[i];
   sum-=w[i];
   long long d=abs(stl-sum);
   dif=min(dif,d);
 }

 cout << dif << endl;
}


Measured memory_bytes: 256
using System;

namespace ABC087
{
    class B
    {
        static void Main(string[] args)
        {
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());
            var C = int.Parse(Console.ReadLine());
            var X = int.Parse(Console.ReadLine());
            var res = 0;
            for (int i = 0; i < A + 1; i++)
                for (int j = 0; j < B + 1; j++)
                    for (int k = 0; k < C + 1; k++)
                        if (500 * i + 100 * j + 50 * k == X) res++;
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
int main(){
  int h,w,dx[8] = {0,1,1,1,0,-1,-1,-1},dy[8] = {1,1,0,-1,-1,-1,0,1};
  scanf("%d %d",&h,&w);
  char s[h][w + 1];
  for(int i = 0;i < h;i++){
    scanf("%s",&s[i]);
  }
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      if(s[i][j] == '.'){
        int cnt = 0;
        for(int d = 0;d < 8;d++){
          int x = j + dx[d],y = i + dy[d];
          if(-1 < x && x < w && -1 < y && y < h){
            if(s[y][x] == '#'){
              cnt++;
            }
          }
        }
        printf("%d",cnt);
      }else{
        printf("#");
      }
    }
    printf("\n");
  }
  return 0;
}

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

using namespace std;

int main() {

	string s;
	cin>>s;
	if (s == "AAA" || s == "BBB" || s == "CCC") {
		cout<<"No"<<endl;
	}
	else
	{
		cout<<"Yes"<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int N, M,h[1010][1010] = { 0 }, l[1010] = { 0 }, t[1010] = { 0 },i,j;
    cin >> N >> M;
    for (i = 0; i < N; i++){
        cin >> l[i];
    }
    for (j = 0; j < M; j++){
        cin >> t[j];
    }
    for (j = 0; j < N; j++){
        for (i = j; i < j + M-N+1; i++){
            if (j == 0){
                h[j][i] = l[j] * t[i];
                if (h[j][i] >= h[j][i - 1] && i != 0){
                    h[j][i] = h[j][i - 1];
                }
            }
            else{
                h[j][i] = h[j - 1][i - 1] + l[j] * t[i];
                if (h[j][i] >= h[j][i - 1] && i != j){
                    h[j][i] = h[j][i - 1];
                }
            }
        }
    }
    cout << h[N - 1][M - 1] << endl;
    return 0;
}

Measured memory_bytes: 7080
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;
using Graph = Vvec<int>;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

void dfs(Graph& graph, vector<ll>& dp, int tmp, int from, ll M)
{
    if(from!=-1 && graph[tmp].size()==1){
        dp[tmp] = 1;
        return;
    }

    dp[tmp] = 1;
    for(auto& to: graph[tmp]){
        if(to != from){
            dfs(graph, dp, to, tmp, M);
            dp[tmp] *= dp[to]+1;
            dp[tmp] %= M;
        }
    }
}

void dfs2(Graph& graph, vector<ll>& dp, vector<ll>& ans, int tmp, int from, ll p, ll M)
{
    ++p;
    ans[tmp] = dp[tmp] * p % M;
    vector<ll> s(graph[tmp].size()+1);
    s.back() = 1;
    for(int i=graph[tmp].size()-1; i>=0; i--){
        int v = graph[tmp][i];
        s[i] = (v==from) ? s[i+1] : s[i+1] * (dp[v]+1);
        s[i] %= M;
    }

    for(int i=0; i<graph[tmp].size(); i++){
        int v = graph[tmp][i];
        if(v == from) continue;
        dfs2(graph, dp, ans, v, tmp, p*s[i+1]%M, M);
        p *= dp[v]+1;
        p %= M;
    }
}

int main()
{
    ll N, M;
    cin >> N >> M;
    Graph graph(N);
    for(int i=0; i<N-1; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    vector<ll> dp(N), ans(N);
    dfs(graph, dp, 0, -1, M);
    // debug(dp);
    dfs2(graph, dp, ans, 0, -1, 0, M);

    for(auto& x: ans) cout << x << endl;
}

Measured memory_bytes: 19584
#include <iostream>
#include <vector>
#include <cstdint>
using namespace std;

int main() {
    uint64_t sum = 0;
    uint32_t n; cin >> n;
    vector<uint32_t> t(n);
    for (auto &e : t) {
        cin >> e;
        sum += e;
    }
    uint32_t m; cin >> m;

    uint32_t p, x;
    while (m--) {
        cin >> p >> x;
        cout << (sum - t[p - 1] + x) << endl;
    }
}



Measured memory_bytes: 3544
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

"""
dp[i][j]を
「i文字目まででj回Sの文字を使ったか」とする

K = 5
S = 'oof'
dp = [[0] * (len(S) + 1) for i in range(K + len(S) + 1)]
dp[0][0] = 1

for i in range(1, K + len(S) + 1):
    for j in range(len(S) + 1):
        if j < len(S):
            dp[i][j] += dp[i - 1][j] * 25
        else:
            dp[i][j] += dp[i - 1][j] * 26 # j回使い切るともうSは関係なくなるので *= 26になる
        if j >= 1:
            dp[i][j] += dp[i - 1][j - 1]

l_s = len(S)
どのタイミングで「この先ずっと*= 26」になるか
後ろからi文字目にSを使い切る: pow(25, K - k, mod) * cmb(N + K - k - 1, N - 1) * pow(26, k, mod)
...
"""

lim = 2 * (10 ** 6) + 1
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, lim + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    # 累計
    factinv.append((factinv[-1] * inv[-1]) % mod)

def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    if r == 0:
        return 1
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % mod

K = getN()
S = input()
N = len(S)

ans = 0
# l_s + i文字目に文字を使い切る
# 次から *= 26
for k in range(K + 1):
    # 逆からやってる
    ans += cmb(N + K - k - 1, N - 1) * pow(26, k, mod) * pow(25, K - k, mod) % mod
    ans %= mod

print(ans)

Measured memory_bytes: 232744
#include<iostream>
#include<math.h>

using namespace std;

int main(void){

    int W , H , x , y , r;

    cin >> W >> H >> x >> y >> r;

    if((x >= r) && (y >= r) && (x <= W - r) && (y <= H - r)){

        cout << "Yes" << endl;
    
    }

    else{

        cout << "No" << endl;

    }

return 0;

}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, buf; 
P a[100008];
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	rep(i, 0, n-1){
		cin >> buf;
		a[i] = P(buf, i+1);
	}
	
	sort(a, a+n);
	
	ll ans = 0;
	rep(i, 0, n-1){
		if((i+1)%2 != a[i].second%2){
			ans++;
		}	
	}
	
	print(ans/2)
	return 0;
}

Measured memory_bytes: 1792
H,W,D = map(int,input().split(" "))
mass = [[0 for _ in range(W)] for _ in range(H)]
num = [[0,0] for _ in range(H * W + 1)]
DP = [0 for _ in range(H * W + 1)]
for i in range(H):
  mass[i] = list(map(int,input().split(" ")))
for i in range(H):
  for i2 in range(W):
    num[mass[i][i2]] = [i,i2]
for i in range(D,W * H + 1):
  DP[i] = DP[i - D] + abs(num[i][0] - num[i - D][0]) + abs(num[i][1] - num[i - D][1])
L = 0
R = 0
ans = 0
Q = int(input())
for i in range(Q):
  ans = 0
  L,R = map(int,input().split(" "))
  print(DP[R] - DP[L])

Measured memory_bytes: 71456
#include <cassert>
#include <vector>
#include <iostream>
using namespace std;

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};


template<typename T>
struct Combination {
private:
  int sz;
  vector<T> F, F_;
public:
  Combination(int sz) : sz(sz), F(sz+1), F_(sz+1) {
    F[0] = 1;
    for(int i = 0; i < sz; ++i) F[i+1] = F[i]*(i+1);
    F_.back() = (T)1/F.back();
    for(int i = sz-1; i >= 0; --i) F_[i] = F_[i+1]*(i+1);
  }
  T C(int n, int k){
    assert(n <= sz);
    if(n < 0 or k > n) return (T)0;
    return F[n]*F_[k]*F_[n-k];
  }
};


int main(){
  using mint = modint<1000000007>;
  Combination<mint> comb(3000);
  int S;
  cin >> S;
  mint ans = 0;
  for(int i = 1; i <= S; ++i){
    int r = S - i*3;
    if(r < 0) break;
    ans += comb.C(r+i-1,i-1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3676
N, M = map(int, input().split())
G = [[] for i in range(N+1)]
for i in range(M):
    u, v = map(int, input().split())
    G[u].append(v)
s, t = map(int, input().split())

d = [-1] * (N + 1)

S = set()
S.add(s)
d[s] = 0
x = 1
while len(S) > 0:
    Q1 = set()
    for u in S:
        for v in G[u]:
            Q1.add(v)
    Q2 = set()
    for u in Q1:
        for v in G[u]:
            Q2.add(v)
    Q3 = set()
    for u in Q2:
        for v in G[u]:
            if d[v] < 0:
                d[v] = x
                Q3.add(v)
    x += 1
    S = Q3

print(d[t])


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

ll cnt[100005];
const int mod=1000000007;
   

int main() {
  int n;
  cin>>n;
  string s;
  cin>>s;
  int ans=0;
  rep(i,10) {
    rep(j,10) {
      rep(k,10) {
	bool flag=false;
	int now=0;
	while (now<n) {
	  if (s[now]-'0'==i) break;
	  now++;
	}
	now++;
	while (now<n) {
	  if (s[now]-'0'==j) break;
	  now++;
	}
	now++;
	while (now<n) {
	  if (s[now]-'0'==k) {
	    flag=true;
	    break;
	  }
	  now++;
	}
	if (flag) ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
// AOJ 1173 "世界の天秤" (ICPC国内予選 2011 Problem B)
import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            String s = sc.nextLine(); // 空白も考慮する(Scanner.next()はだめ)
            if (s.equals(".")) {
                break;
            }
            
            Stack<Character> st = new Stack<Character>();
            boolean isBalanced = true;
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                if (c == '(' || c == '[') {
                    st.push(c);
                } else if (c == ')' || c == ']') {
                    if (st.empty()) {
                        isBalanced = false;
                        break;
                    }
                    char tmp = st.pop();
                    // 括弧が対応しているかどうか
                    if (!(c == ')' && tmp == '(') &&
                        !(c == ']' && tmp == '[')) {
                        isBalanced = false;
                        break;
                    }
                }
            }
            if (!st.empty()) {
                isBalanced = false;
            }
            
            if (isBalanced) {
                System.out.println("yes");
            } else {
                System.out.println("no");
            }
        }
    }
}

Measured memory_bytes: 32736
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

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


int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())
#define rSORT(v) std::sort(v.begin(), v.end(),std::greater<int>())
int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a%b);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<int> L(n), R(n);
    for (int i = 0; i < n - 1; ++i) {
        L[i + 1] = gcd(L[i], a[i]);
    }
    for (int i = n - 1; i >= 1; --i) {
        R[i - 1] = gcd(R[i], a[i]);
    }
    int ans = 1;
    for (int i = 0; i < n; ++i) {
        ans = max(ans, gcd(L[i], R[i]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

template <class _container, class _Ty>
inline bool contains(_container _C, const _Ty &_Val) { return std::find(_C.begin(), _C.end(), _Val) != _C.end(); }

int main() {
    int x, n;
    cin >> x >> n;
    vi p(n);
    rep(i, n) cin >> p[i];
    sort(all(p));
    int res = INF;
    int ans;
    int idx = 0;
    repeat(i, -100, 200) {
        int z = abs(i - x);
        if (idx < n and p[idx] == i) {
            idx++;
            continue;
        }
        if (z < res) {
            ans = i;
            res = z;
        }
    }
    out(ans);
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
    double x[3];
    double y[3];
    for(int i = 0;i < 3;i++)cin >> x[i] >> y[i];
    vector<double> l(3);
    double s = 0;
    for(int i = 0;i < 3;i++){
        l[i] = sqrt(((x[(i+1)%3]-x[i])*(x[(i+1)%3]-x[i])+(y[(i+1)%3]-y[i])*(y[(i+1)%3]-y[i])));
        s += l[i];
        //cout << l[i] << endl;
    }
    s /= 2;
    sort(l.begin(),l.end());
    double r = sqrt(s*(s-l[0])*(s-l[1])*(s-l[2]))/s;
    double ans = (r*l[2])/(2*r+l[2]);
    cout << setprecision(11) << ans << endl;
    //cin >> r;
}

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

int main (void){
int c;
char x[101];
cin >> c;
cin >> x;
int r;
for (int i=0;i<c;i++){
  if (x[i]=='R') r++;
}
if(r>c-r){cout<<"Yes"<<endl;}
else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256
def examB():
    N = I()
    S = SI()
    cur = 0
    for i in range(N-1):
        d1 = set()
        d2 = set()
        for j in S[:i]:
            d1.add(j)
        for j in S[i:]:
            d2.add(j)
        curS = d1&d2
        cur = max(cur,len(curS))
    print(cur)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 39408
name = ['A', 'B', 'C', 'D', 'E']
shop = []

while True:
    a,b = map(int, input().split())
    if a == 0 and b == 0:
        break
    shop.append(a+b)
    if len(shop) == 5:
        m = max(shop)
        print(name[shop.index(m)], m)
        shop = []  
    


Measured memory_bytes: 5600
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;

int main()
{
	int a,b,c;
	scanf("%d%d",&a,&b);
	if(a>b)	swap(a,b);
	if(a==1&&b==2)	c=3;
	if(a==1&&b==3)	c=2;
	if(a==2&&b==3)	c=1;
	printf("%d",c);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <queue>
 
using namespace std;
 
#define inf (1<<27)

struct State {
    int x,y,l,r,o,c;
    State(int xx,int yy,int ll,int rr,int oo,int cc) {
        x=xx,y=yy,l=ll,r=rr,o=oo,c=cc;
    }
};
 
bool operator > (const State &left,const State &right) {
	return left.c>right.c;
}

int map[10][10];
int cost[10][10][10][10][51];

int main() {
	int W,H,f,m,o;
	while(scanf("%d %d",&W,&H),W) {
		memset(cost,0x10,sizeof(cost));
		scanf("%d %d %d",&f,&m,&o);
		for(int j=0;j<H;j++)for(int i=0;i<W;i++) {
			scanf("%d",&map[i][j]);
		}
		if(o<=1){printf("NA\n");continue;}
		priority_queue<State,vector<State>,greater<State> > que;
		for(int i=0;i<W;i++) {
			int oo=o-1,cc=0;
			if(map[i][0]<0) {
				cc-=map[i][0];
			}else {
				oo+=map[i][0];
				if(oo>m)oo=m;
			}
			que.push(State(i,0,i,i,oo,cc));
		}
		int res=inf;
		while(!que.empty()) {
			State s=que.top();
			que.pop();
			s.o--;
			if(s.y==(H-1)){res=s.c;break;}
			if(s.o==0){continue;}
			State ns=s;
			ns.y++;ns.l=ns.r=ns.x;
			if(ns.y<H) {
				if(map[ns.x][ns.y]>0) {
					ns.o+=map[ns.x][ns.y];
					if(ns.o>m)ns.o=m;
				}else {
					ns.c-=map[ns.x][ns.y];
				}
				if(cost[ns.x][ns.y][ns.l][ns.r][ns.o]>ns.c) {
					cost[ns.x][ns.y][ns.l][ns.r][ns.o]=ns.c;
					que.push(ns);
				}
			}
			ns=s;
			ns.x++;
			if(ns.x<W) {
				if(ns.x>ns.r) {
					ns.r=ns.x;
					if(map[ns.x][ns.y]>0) {
						ns.o+=map[ns.x][ns.y];
						if(ns.o>m)ns.o=m;
					}else {
						ns.c-=map[ns.x][ns.y];
					}
				}
				if(cost[ns.x][ns.y][ns.l][ns.r][ns.o]>ns.c) {
					cost[ns.x][ns.y][ns.l][ns.r][ns.o]=ns.c;
					que.push(ns);
				}
			}
			ns=s;
			ns.x--;
			if(ns.x>=0) {
				if(ns.l>ns.x) {
					ns.l=ns.x;
					if(map[ns.x][ns.y]>0) {
						ns.o+=map[ns.x][ns.y];
						if(ns.o>m)ns.o=m;
					}else {
						ns.c-=map[ns.x][ns.y];
					}
				}
				if(cost[ns.x][ns.y][ns.l][ns.r][ns.o]>ns.c) {
					cost[ns.x][ns.y][ns.l][ns.r][ns.o]=ns.c;
					que.push(ns);
				}
			}
		}
		if(res<=f)printf("%d\n",res);
		else printf("NA\n");
	}
}

Measured memory_bytes: 3172
#include<iostream>
#include <string>
#include <vector>

using namespace std;

int main(void)
{
	vector<int> alp(26, 0);
	string S;
	cin >> S;
	for (int i = 0; i < 4; i++){
		alp[S[i] - 'A']++;
	}
	int cnt = 0;
	for (int i = 0; i < alp.size(); i++){
		if (alp[i] == 2){
			cnt++;
		}
	}
	if (cnt == 2){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256