akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<pll> ans;
	rep(i,n)range(j,i+1,n){
		ll x=i+1, y=j+1;
		if(x+y!=(n%2?n:n+1))ans.emplace_back(x,y);
	}
	puta(ans.size());
	for(auto p:ans)puta(p.fs, p.sc);
	return 0;
}

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

A,B,Q = map(int,input().split())
jinjya = [-float('inf')]+[int(input()) for _ in range(A)]+[float('inf')]#範囲を絞るために両サイドに0と無限を挿入
tera =[-float('inf')]+[int(input()) for _ in range(B)]+[float('inf')]

for i in range(Q):
  x=int(input())
#出発地点の前後の神社と寺の場所を知りたい。つまり出発点より前にある対象のインデックス
  L=0
  R=A+2
  while R-L>1:
    P=(L+R)//2
    if x<jinjya[P]:
      R=P
    else:
      L=P
  jinjya_L=L
  
  L=0
  R=B+2
  while R-L>1:
    P=(L+R)//2
    if x<tera[P]:
      R=P
    else:
      L=P
  tera_L=L
#xの左側の神社と寺のインデックスがわかったのでそれらに対して距離を測って最小を探す。
  a=jinjya[jinjya_L]
  b=jinjya[jinjya_L+1]
  c=tera[tera_L]
  d=tera[tera_L+1]
  if jinjya_L==0:
    a=b
  if tera_L==0:
    c=d
  answer=min(abs(x-a)+abs(a-c),abs(x-c)+abs(c-a),abs(x-b)+abs(b-c),abs(x-c)+abs(c-b),abs(x-a)+abs(a-d),abs(x-d)+abs(d-a),abs(x-b)+abs(b-d),abs(x-d)+abs(d-b))
  print(answer)

Measured memory_bytes: 12832
s1 = []
s2 = []
a = 0
s = input()
for i in range(len(s)):
    if s[i] == "\\":
        s1.append(i)
    elif s[i] == "/" and len(s1)>0:
        j = s1.pop()#position of nearest \
        a += i-j
        a_splt = i-j
        while(len(s2) > 0 and s2[-1][0] > j):
            a_splt += s2.pop()[1]
        s2.append([j, a_splt])

print(a)
ans = ""
ans += str(len(s2))
for area in s2:
    ans += " " + str(area[1])
print(ans)


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

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

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

	vector<int> D1(N);
	vector<int> D2(N);

	for (int i = 0; i < N; ++i) {
		cin >> D1[i] >> D2[i];
	}

	string ans = "No";
	int cnt = 0;
	for (int i = 0; i < N; ++i) {
		if (D1[i] == D2[i]) {
			cnt++;

			if (cnt >= 3) {
				ans = "Yes";
				break;
			}
		}
		else {
			cnt = 0;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include<string>
#include<algorithm>

using namespace std;
int main(void){
    int L,N;
    cin>>N>>L;
    string S[N];
    
    for(int i=0;i<N;i++){
        cin>>S[i];
        
    }
    sort(S,S+N);
    string T;
    
    
    for(int i=0;i<N;i++){
        T=T+S[i];
    }
    
     
    cout<<T<<endl;
    
    return 0;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
void Digvijay()
{
   int a;
   cin>>a;
   int ans = a+a*a+a*a*a;
   cout<<ans<<"\n";
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _=1;
    //cin>>_;
    for(int __=0;__<_;__++)
    {
        Digvijay();
    }
}

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
//const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code
ll dp[105][5][5][5];

int main()
{
	int N;
	cin>>N;
	dp[0][0][0][0] = 1;
	

	rep(n, 0, N)
		rep(i, 0, 5)
			rep(j, 0, 5)
				rep(k, 0, 5)
					rep(l, 1, 5)
					{
						if(i == 1 && k == 2 && l == 3) continue;
						if(i == 1 && j == 2 && l == 3) continue;
						if(j == 1 && k == 2 && l == 3) continue;
						if(j == 1 && k == 3 && l == 2) continue;
						if(j == 2 && k == 1 && l == 3) continue;
						dp[n+1][j][k][l] = (dp[n+1][j][k][l] + dp[n][i][j][k])%M;
					}
	ll ans = 0;
	rep(i, 1, 5)
		rep(j, 1, 5)
			rep(k, 1, 5)
				ans = (ans + dp[N][i][j][k])%M;
	cout<<ans<<endl;
}


Measured memory_bytes: 384
N,C,K=map(int,input().split())
T=[int(input()) for i in range(N)]
T.sort()
S=[[T[0]]]
t=T[0]
k=0
for i in range(1,N):
    if T[i]<=t+K and len(S[k])<C:
        S[k].append(T[i])
    else:
        k+=1
        S.append([T[i]])
        t=T[i]
print(len(S))


Measured memory_bytes: 17120
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <deque>

using namespace std;

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	if (n < 1200) cout << "ABC" << endl;
	else if (n < 2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;
}

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

using namespace std;
using ll = long long;

const ll INF = 1LL << 50;
const int NMAX = 1000;
const int MMAX = 2000;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> A(MMAX), B(MMAX);
  vector<ll> C(MMAX);
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i] >> C[i];
    C[i] = -C[i];
  }
  ll dist[NMAX];

  for (int i = 0; i < N; i++) {
    dist[i] = INF;
  }
  dist[0] = 0;

  for (int loop = 0; loop < N - 1; loop++) {
    for (int i = 0; i < M; i++) {
      if (dist[A[i] - 1] == INF) continue;
      if (dist[B[i] - 1] > dist[A[i] - 1] + C[i]) {
        dist[B[i] - 1] = dist[A[i] - 1] + C[i];
      }
    }
  }
  ll res = dist[N - 1];

  vector<bool> negative(NMAX, false);

  for (int loop = 0; loop < N; loop++) {
    for (int i = 0; i < M; i++) {
      if (dist[A[i] - 1] == INF) continue;

      if (dist[B[i] - 1] > dist[A[i] - 1] + C[i]) {
        dist[B[i] - 1] = dist[A[i] - 1] + C[i];
        negative[B[i] - 1] = true;
      }

      if (negative[A[i] - 1] == true) {
        negative[B[i] - 1] = true;
      }
    }
  }

  if (negative[N - 1])
    cout << "inf" << '\n';
  else
    cout << -res << '\n';
  return 0;
}


Measured memory_bytes: 256
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()
    
    n, m = map(int, input().split())
    a = [input() for _ in range(n)]
    b = [input() for _ in range(m)]
    for i in range(n-m+1):
        for j in range(n-m+1):
            flag = True
            for k in range(m):
                for l in range(m):
                    if a[i+k][j+l] != b[k][l]:
                        flag = False
                        break
                else:
                    continue
                break
            if flag:
                break
        else:
            continue
        break
    if flag:
        print("Yes")
    else:
        print('No')
                
    

            

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9152
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var A = ReadLine().Split(' ').Select(long.Parse).ToArray();

        long GetSadness(long b) => A.Select((a, i) => Math.Abs(a - (b + i + 1))).Sum();

        var b = A.Select((v, i) => v - i - 1).OrderBy(x => x).ToArray()[N / 2];
        var ans = GetSadness(b);

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 53036
N = int(input())
robo = []
for _ in range(N):
    X, L = map(int, input().split())
    left = X - L
    right = X + L
    robo.append((left, right))

robo.sort(key=lambda x: x[1])
right = -10 ** 18
ans = N

for l, r in robo:
    if l < right:
        ans -= 1
        continue
    right = r

print(ans)


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

using namespace std;

const int N = 1e6 + 6;

vector<int> g[N];
char s[N];
int cnt[N];
int cntr, numCC;
int num[N], low[N], vis[N], cc[N];
vector<int> S;

void dfs(int v) {
  low[v] = num[v] = ++cntr;
  vis[v] = 1;
  S.push_back(v);
  for(auto u : g[v]) {
    if(num[u] == -1)
      dfs(u);
    if(vis[u])
      low[v] = min(low[v], low[u]);
  }
  if(low[v] == num[v]) {
    while(1) {
      int u = S.back(); S.pop_back(); vis[u] = 0;
      cc[u] = numCC;
      if(u == v)
        break;
    }
    ++numCC;
  }
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  scanf("%s", s);
  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    --u, --v;
    if (s[u] == s[v]) {
      g[u].push_back(v+n);
      g[v].push_back(u+n);
    }
    else {
      g[u+n].push_back(v);
      g[v+n].push_back(u);
    }
  }
  numCC = 0;
  memset(num, -1, sizeof num);
  memset(vis, 0, sizeof vis);
  for (int i = 0; i < 2 * n; ++i) {
    if (num[i] != -1) continue;
    dfs(i);
  }
  bool ok = numCC < 2 * n;
  puts(ok ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 57852
def slove():
    import sys
    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip('\n').split()))
    if (a + b) % 2 == 0:
        print((a + b) // 2)
    else:
        print("IMPOSSIBLE")


if __name__ == '__main__':
    slove()


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

int main() {
	int N;
	string S;
	int LW = 0;
	int LE = 0;
	int RW = 0;
	int RE = 0;
	cin >> N >> S;
	for (int i = 1;i<N;++i) {
		if ('E' == S[i]) {
			RE++;
		}
		else {
			RW++;
		}
	}	
	int ans = 1e9;
	for (int i = 0; i < N; ++i) {
		ans = min(ans,LW+RE);
		if ('E' == S[i]) {
			LE++;
		}
		else {
			LW++;
		}
		if (i != N-1) {
			if ('E' == S[i + 1]) {
				RE--;
			}
			else {
				RW--;
			}
		}
	}
	cout <<ans << endl;
	return 0;
}

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

string S; int N;
void input()
{
    cin >> S;
    N = S.length();
}

void solve()
{
    int zero = 0, one = 0;
    for(int i=0; i<N; ++i){
        if(S[i] == '0') ++zero;
        else if(S[i] == '1') ++one;
    }
    cout << 2*min(zero,one) << endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

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

inline bool check(int a, int b){
  if(a>b)swap(a,b);
  if(a%3 != 2 && a+1==b)return true;
  if(a<6 && a+3==b)return true;
  return false;
}

int main(){
  for(int azu=0;azu<1000;azu++){
    string s;
    cin >> s;

    bool f = true;
    for(int i=1;i<(int)s.size();i++){
      f &= check(s[i-1]-'A',s[i]-'A');
    }
    if(f)cout << s << endl;
  }
}

Measured memory_bytes: 1176
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        String s = sc.next();
        if(k < s.length()){
            for(int i = 0 ; i < k ; i++ ){
                System.out.print(s.charAt(i));
            }
            System.out.println("...");
        }else{
            System.out.println(s);
        }
        sc.close();
    }
}

Measured memory_bytes: 35716
sx, sy, gx, gy = gets.chomp.split.map(&:to_i)
diffx = gx - sx
diffy = gy - sy
res = ""

diffx.times { res << "R" }
diffy.times { res << "U" }
diffx.times { res << "L" }
diffy.times { res << "D" }

res << "D"
(diffx + 1).times { res << "R" }
(diffy + 1).times { res << "U" }
res << "L"

res << "U"
(diffx + 1).times { res << "L" }
(diffy + 1).times { res << "D" }
res << "R"

puts res

Measured memory_bytes: 1788
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))
using namespace std;

int q,num,nume;
vector<int> A(0,0); 
int main(void){
    cin >> q;
    repeat(i,q) {
        cin >> num;
        switch(num) {
            case 0:
            cin >> nume;
            A.push_back(nume);
            break;
            case 1:
            cin >> nume;
            cout << A[nume] << endl;
            break;
            case 2:
            A.pop_back();
            break;
        }
    }
}


Measured memory_bytes: 3892
N=int(input())
P=N
Q=0
R=0
L=''
if N==0:
    ans=0
else:
    while abs(P)>1:
        if P%2==0:
            Q=P/(-2)
            L+='0'
        else:
            Q=(P-1)/(-2)
            L+='1'
        P=Q
    if P==1:
        L+='1'
    else:
        L+='11'
    ans=L[::-1]
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n,k; cin>>n>>k;
  int ans =0 ;
  rep(i,n) {
    int h; cin >>h;
    if (h>=k) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) (a<<b)
#define Rshift(a,b) (a>>b)
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int seq[32] = {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 k;
    cin >> k;
    cout << seq[k - 1] << endl;
}


Measured memory_bytes: 256
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

void Main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  if(!(a[0] == a[1] && a[1] == a[2]) && (a[0] == a[1] || a[1] == a[2])) {
    cout << "Yes\n";
  } else 
  cout << "No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	int a,b,c,d; cin>>a>>b>>c>>d;
  if(a==c)cout<<"0"<<endl;
  else cout<<"1"<<endl;
  

    


	
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

ll MOD = 1e9 + 7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<bool> st(n + 1, true);
  for (int i = 0; i < m; i++) {
    int tmp;
    cin >> tmp;
    st[tmp] = false;
  }
  vector<ll> dp(n + 1, 0);
  dp[0] = 1;
  if (st[1]) {
    dp[1] = 1;
  }
  for (int i = 2; i <= n; i++) {
    if (st[i]) {
      dp[i] += dp[i - 1] + dp[i - 2];
      dp[i] = dp[i] % MOD;
    }
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.math.BigInteger;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        BigInteger X = s.nextBigInteger().abs();
        BigInteger K = s.nextBigInteger();
        BigInteger D = s.nextBigInteger();

        if (X.subtract(K.multiply(D)).signum() >= 0) {
            System.out.println(X.subtract(K.multiply(D)).toString());
        } else {
            if(X.divide(D).remainder(BigInteger.valueOf(2)).equals(K.remainder(BigInteger.valueOf(2)))) {
                System.out.println(X.remainder(D).toString());
            } else System.out.println(X.remainder(D).subtract(D).abs().toString());
        }
    }
}

Measured memory_bytes: 36060
#include<bits/stdc++.h>
 
#define hell                         1000000007
#define hell2                        998244353
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define all(v)                       v.begin(),v.end()
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(ll i=a;i<b;i++)
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'
 
const ll MAX=200005;
const ll SQN=330;
const ll LG=22;
const double PI=atan(1)*4;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    ll n;
    cin >> n;
    map<string,ll> m;
    rep(i,0,n) {
    	string s;
    	cin >> s;
    	m[s]++;
    }

    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
}


Measured memory_bytes: 3652
N,M=map(int,input().split())
A=[]
B=[]
for i in range(N):
    A.append(input())
for i in range(M):
    B.append(input())

for i in range(N-M+1):
    for j in range(N-M+1):
        f=True
        for k in range(M):
            if A[j+k][i:M+i]==B[k]:continue
            else:
                f=False
                break
        if f:
            print("Yes")
            exit()
print("No")


Measured memory_bytes: 9204
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

input = sys.stdin.readline

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, Q, STX, D):
    E = []
    for i, (s, t, x) in enumerate(STX):
        E.append((s-x, 1, x, i))
        E.append((t-x, -1, x, i))
    E.sort(reverse=True)

    q = []
    done = set()
    ans = [-1] * Q
    for j, d in enumerate(D):
        while E and E[-1][0] <= d:
            t, e, x, i = E.pop()
            if e == 1:
                heapq.heappush(q, (x, i))
            else:
                done.add((x, i))

        while q and q[0] in done:
            done.remove(heapq.heappop(q))

        if q:
            ans[j] = q[0][0]

    for i in range(Q):
        print(ans[i])


def main():
    N, Q = read_int_n()
    STX = list(read_int_n() for _ in range(N))
    D = list(read_int() for _ in range(Q))
    (slv(N, Q, STX, D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 148556
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        int N = NextInt();
        long[] a = LineLong();
        long[] b = LineLong();
        long c = 0;
        //bの構築
        for (int i = 0; i < N; i++)
        {
            if (a[i] > b[i]) { c += a[i] - b[i]; b[i] += a[i] - b[i]; }
        }
        //aの補正
        for (int i = 0; i < N; i++)
        {
            if (c <= 0) break;
            long can = (b[i] - a[i]) / 2;
            a[i] += 2 * can;
            c -= can;
        }
        Console.WriteLine((c <= 0 ? "Yes" : "No"));
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 15584
s = input()
A = int(s[:2])

B = int(s[2:])

if(0<A<13 and 0<B<13):
    print("AMBIGUOUS")
elif(0<A<13):
    print("MMYY")
elif(0<B<13):
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
#include <iostream>

int main(int argc, char** argv)
{
    int num;
    std::cin >> num;

    double ans = 0.0;
    for (int i = 0; i < num; ++i) {
        int r;
        std::cin >> r;
        ans += (1.0 / (double)r);
    }

    std::cout << (1.0 / ans) << std::endl;

    return 0;
}

Measured memory_bytes: 256
// "include" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>
// }}}
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    int amaxv = -1000;
    int bminv = INF;
    rep(i,n){
        int a;
        cin >> a;
        amaxv = max(amaxv,a);
    }
    rep(i,m){
        int b;
        cin >> b;
        bminv = min(bminv,b);
    }
    for(int i = amaxv+1;i <= bminv;++i){
        if(i > x && i <= y){
            cout << "No War\n";
            return 0;
        }
    }
    cout << "War\n";
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#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;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 1e18;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double dbl;
#define pb push_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define all(a) a.begin(),a.end()
bool debug = 0;
const int MAXN = 3e5 + 100;
const int LOG = 20;
const int mod = 1e9 + 7;
const int MX = 1e5 + 100;
typedef long long li;
const li MOD = 1000000000949747713ll;

int s[MAXN], t[MAXN];

ll dp[5010][5012];
ll bin_pow(ll a,int n){
    ll res = 1;
    while(n){
        if(n&1){
            res = (res * a)%mod;
        }
        a = (a*a)%mod;
        n>>=1;
    }
    return res;
}
void solve() {
   int n;
   cin >> n;
   string s;
   cin >>s;
   int m = sz(s);
   dp[0][0] = 1;

   for(int i=1;i<=n;++i){
       for(int j=0;j<=n;++j){
           if(j > 0)
               dp[i][j] += dp[i-1][j-1] * 2;
           else
               dp[i][j] += dp[i-1][j];
           dp[i][j] += dp[i-1][j+1];
           dp[i][j]%=mod;
       }
   }

   ll ans = dp[n][m];

   dout <<"ans "<<ans<<endl;
   ll pw = 1ll * m * (mod - 2);
   pw = pw%(mod-1);
   dout <<"pw "<<pw<<endl;
   ans = ans * bin_pow(2,pw);
   ans%=mod;
   cout << ans;

}

signed main() {
#ifdef zxc
    debug = 1;
    freopen("../input.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#else

#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(20);

    int t = 1;
    while (t--)
        solve();
    dout << endl << "time : " << (1.0 * clock() / CLOCKS_PER_SEC) << endl;
}

Measured memory_bytes: 196864
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int h, w; cin >> h;
	cout << 3 * h * h << endl;

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
N,A,B = map(int,input().split())

if abs(A-B)%2 == 0:
  print(abs(A-B)//2)
else:
  ans = 0
  tip_A = min(abs(A-1),abs(A-N))
  tip_B = min(abs(B-1),abs(B-N))
  near_tip = min(tip_A,tip_B)
  # まず、近いほうに寄る
  if near_tip == tip_A:
    if abs(A-1) <= abs(A-N):#1のが近い場合
      ans += tip_A
      A = 1
      B -= tip_A
      # もう一回移動
      ans += 1
      B -= 1
      # お互い近づく
      ans += (abs(A-B)//2)
    else:#Nのが近い場合
      ans += tip_A
      A = N
      B += tip_A
      # もう一回移動
      ans += 1
      B += 1
      # お互い近づく
      ans += (abs(A-B)//2)
  else:
    if abs(B-1) <= abs(B-N):#1のが近い場合
      ans += tip_B
      B = 1
      A -= tip_B
      # もう一回移動
      ans += 1
      A -= 1
      # お互い近づく
      ans += (abs(A-B)//2)
    else:#Nのが近い場合
      ans += tip_B
      B = N
      A += tip_B
      # もう一回移動
      ans += 1
      A += 1
      # お互い近づく
      ans += (abs(A-B)//2)
  print(ans)
      
      
      
      

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	long long n;
	cin>>n;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='1')
		{
			n--;
			if(n<=0)
			{
				cout<<'1';
				return 0;
			}
		}
		else
		{
			cout<<s[i];
			return 0;
		}
	}
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>

int main() {
	std::string s;
	std::cin >> s;
	std::sort(s.begin(), s.end());
	int nSum = 0, flag = 0;
	for (int i = 0;i < s.size(); i++) {
		if (s[i] == s[i + 1]) {
			nSum += 1;
		}
		else {
			if (nSum % 2 == 0) {
				std::cout << "No" << std::endl;
				flag = 1;
				break;
			}
			else {
				nSum = 0;
			}
		}
	}
	if (flag == 0) {
		std::cout << "Yes" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
x,n = [int(x) for x in input().split()]
arr = set([int(x) for x in input().split()])
# arr.sort()

if n == 0:
    print(x)
elif x < min(arr):
    print(x)
elif x > max(arr):
    print(x)
elif not x in arr:
    print(x)
else:
    res = -1
    min_diff = 8491654891598
    for i in range(-1,102):
        if i in arr:
            continue
        # min_diff = min(min_diff, abs(x - i))
        if abs(x - i) < min_diff:
            min_diff  = abs(x - i)
            res = i
    print(res) 

Measured memory_bytes: 9200
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String x = sc.next();
    long p = 0;
    for(int i = 0; i < n; i++) {
      if(x.charAt(i) == '1') p++;
    }
    if(p == 0) {
      for(int i = 0; i < n; i++) {
        System.out.println(1); 
      }
    } else {
      long[] r0 = new long[n];
      r0[n - 1] = 1;
      for(int i = n - 2; i >= 0; i--) {
        r0[i] = (2 * r0[i + 1]) % p;
      }
      long t0 = 0;
      for(int i = 0; i < n; i++) {
        if(x.charAt(i) == '1') t0 = (t0 + r0[i]) % p;
      }

      long[] r1 = new long[n];
      r1[n - 1] = 1;
      for(int i = n - 2; i >= 0; i--) {
        r1[i] = (2 * r1[i + 1]) % (p + 1);
      }
      long t1 = 0;
      for(int i = 0; i < n; i++) {
        if(x.charAt(i) == '1') t1 = (t1 + r1[i]) % (p + 1);
      }

      long[] r2 = new long[n];
      long t2 = 0;
      r2[n - 1] = 1;
      if(p > 1) {
        for(int i = n - 2; i >= 0; i--) {
          r2[i] = (2 * r2[i + 1]) % (p - 1);
        }
        for(int i = 0; i < n; i++) {
          if(x.charAt(i) == '1') t2 = (t2 + r2[i]) % (p - 1);
        }
      }

      for(int i = 0; i < n; i++) {
        if(x.charAt(i) == '0') {
          long s = (t1 + r1[i]) % (p + 1);
          int ans = 1;
          while(s > 0) {
            ans++;
            int d = 0;
            long s1 = s;
            while(s1 > 0) {
              d += (s1 % 2);
              s1 /= 2;
            }
            s = (s % d);
          }
          System.out.println(ans);
        } else {
          if(p == 1) {
            System.out.println(0); 
          } else {
            long s = (t2 - r2[i] + p - 1) % (p - 1);
            int ans = 1;
            while(s > 0) {
              ans++;
              int d = 0;
              long s1 = s;
              while(s1 > 0) {
                d += (s1 % 2);
                s1 /= 2;
              }
              s = (s % d);
            }
            System.out.println(ans);
          }
        }
      }
    }
  }
}

Measured memory_bytes: 73104
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();
    int n, m;
    cin >> n >> m;
    vector<int> ac(n, 0), pen(n, 0);
    rep(i, m){
        int p;
        string s;
        cin >> p >> s;
        p--;
        if(ac[p] == 1) continue;
        else if(s == "AC") ac[p] = 1;
        else pen[p]++;
    }
    rep(i, n) if(ac[i] == 0) pen[i] = 0;
    cout << accumulate(all(ac), 0) << " " << accumulate(all(pen), 0) << endl;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int K; cin >> K;
    int ans = 0;
    int a = 0;
    while(1){
        a = (a*10 + 7)%K;
        ans++;
        if(a==0){
            cout << ans << endl;
            return 0;
        }
        if(ans > K){
            cout << -1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.par = [-1 for _ in range(n)]

    def same(self, x, y):
        return self.root(x)==self.root(y)

    def root(self, x):
        if self.par[x]<0:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if x==y:
            return

        if self.par[x]>self.par[y]:
            x,y = y,x

        self.par[x] += self.par[y]
        self.par[y] = x

    def size(self,x):
        return -self.par[self.root(x)]

n,m,k = map(int, input().split())
uf = UnionFind(n+1)
dd = {}
for i in range(n):
    dd[i] = set()

for _ in range(m):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    dd[a].add(b)
    dd[b].add(a)
    uf.unite(a,b)

for _ in range(k):
    c,d = map(int, input().split())
    c -= 1
    d -= 1
    if not uf.same(c,d):
        continue
    dd[c].add(d)
    dd[d].add(c)

res = [0]*n
for i in range(n):
    res[i] = uf.size(i) - len(dd[i]) - 1

print(*res)

Measured memory_bytes: 73032
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1;
#define cni cin

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int n,ans,t=MOD;
int ave;

main(){
	cin>>n;
	int a[n];
	rep(i,n)cin>>a[i];
	rep(i,n)ave+=a[i];
	rep(i,n)a[i]*=n;
	rep(i,n){
		if(t>abs(ave-a[i])){
			t=abs(ave-a[i]);
			ans=i;
		}
	}
	dans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector <long long int, long long int> 
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int MAX = 405;
const int inf = 1e9 + 5;
char grid[MAX][MAX];
int dist[MAX];
bool vis[MAX];
vi adj[MAX];
int ans;
void init()
{
	for(int i = 0; i < MAX; i++){
		vis[i] = false;
		dist[i] = inf;
	}
}
int hsh(int x, int y, int m)
{
	return(x * m + y);
}
void bfs(int x)
{
	vis[x] = true;
	queue <int> q;
	q.push(x);
	dist[x] = 0;
	while(!q.empty()){
		int p = q.front();
		q.pop();
		for(auto v : adj[p]){
			if(!vis[v]){
				vis[v] = true;
				q.push(v);
				dist[v] = min(dist[v], dist[p] + 1);
			}
		}
	}
}
int main()
{
	boost;
	int n, m, i, j;
	cin >> n >> m;
	fo(i, 0, n){
		fo(j, 0, m)
		cin >> grid[i][j];
	}
	fo(i, 0, n){
		fo(j, 0, m){
			if(grid[i][j] == '#') continue;
			
			int v1 = hsh(i, j, m);
			if(i + 1 < n && grid[i + 1][j] != '#'){
				int v2 = hsh(i + 1, j, m);
				adj[v1].pb(v2);
				adj[v2].pb(v1);
			}
			if(j + 1 < m && grid[i][j + 1] != '#'){
				int v2 = hsh(i, j + 1, m);
				adj[v1].pb(v2);
				adj[v2].pb(v1);
			}
		}
	}
	ans = 0;
	fo(i, 0, n * m){
		init();
		bfs(i);
		fo(j, 0, n * m){
			if(dist[j] < inf)
			ans = max(ans, dist[j]);
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define PB push_back
#define INF 1000 * 1000 * 1000
#define X first
#define Y second
#define x first
#define y second
#define pt pair<int , int> 
using namespace std;
const int mod = 998244353;


int main()
{
	ios_base::sync_with_stdio(0);
	int T;
	cin >> T;
	while(T--)
	{
		int N , D;
		cin >> N >> D;
		int ans = (N - 1) * 127;
		if(!(N % 2))
			D ^= 127;
		cout << ans + D << endl;
	}
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <utility>
#include <vector>

using namespace std;

const int N = 1'009;

char s[N][N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<pair<int, int>> a;
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
    for (int j = 0; j < m; ++j) {
      if (s[i][j] == '#') {
        a.emplace_back(i, j);
      }
    }
  }
  int ans = 0;
  while (true) {
    vector<pair<int, int>> na;
    for (auto &e : a) {
      for (int di = -1; di <= 1; ++di) {
        for (int dj = -1; dj <= 1; ++dj) {
          if (abs(di) + abs(dj) != 1) {
            continue;
          }
          int ni = e.first + di;
          int nj = e.second + dj;
          if (ni < 0 || ni >= n || nj < 0 || nj >= m) {
            continue;
          }
          if (s[ni][nj] == '.') {
            na.emplace_back(ni, nj);
            s[ni][nj] = '#';
          }
        }
      }
    }
    if (na.empty()) {
      break;
    }
    ++ans;
    a = na;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 13928
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{
    int A,B;
    cin>>A>>B;

    if((A+B)>=10){
        cout<<"error"<<endl;
    }else{
        cout<<A+B<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  ll n,c;
  cin >> n >>c;
  bool a[c+1][100001];
  REP(i,c+1){
    REP(j,100001){
      a[i][j] = false;
    }
  }
  
  REP(i,n){
    int s,t,cc;
    scanf("%d %d %d",&s,&t,&cc);
    //cin >> s >> t >> cc;
    for(int j = s;j <= t;j++){
      a[cc][j] = true;
    }
  }
  int m = 0;
  REP(i,100001){
    int sum = 0;
    REP(j,c+1){
      if(a[j][i] == true)
	sum++;
    }
    
    m = max(m,sum);
  }
  printf("%d\n",m);
  return 0;
}


Measured memory_bytes: 3328
h, w = map(int, input().split())


c = [[0] * 10 for _ in range(10)]
for i in range(10):
    c[i] = list(map(int, input().split()))


a = [[0] * w for _ in range(h)]
for i in range(h):
    a[i] = list(map(int, input().split()))


arr = []
for i in range(h):
    for j in range(w):
        if a[i][j] == -1 or a[i][j] == 1:
            pass
        else:
            arr.append(a[i][j])


# 0 - 9それぞれを1に書き換える最小コストを計算
# arrに格納された数を全て最小コストで処理する
for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j],c[i][k] + c[k][j])

cost = 0
for i in range(len(arr)):
    cost += c[arr[i]][1]
print(cost)

Measured memory_bytes: 3956
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;

int main(){
  int t;
  vector<int> a;
  
  for(int i=0;i<3;i++){
    cin>>t;
    a.pb(t);
  }
  sort(a.begin(),a.end());
  
  cout<<abs(a[0]-a[1])+abs(a[1]-a[2])<<endl;
  return 0;
}


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

int main(void) {

	int a, b, c, x, sum1, sum2, sum3, i, j, k, count = 0;

	scanf("%d%d%d%d", &a, &b, &c, &x);

	for (i = 0; i <= a; i++) {
		sum1 = 500 * i;
	
		for (j = 0; j <= b; j++) {
			sum2 = 100 * j;
			
			for (k = 0; k <= c; k++) {
				sum3 = 50 * k;

				if (sum1+sum2+sum3 == x) {
					count++;
					
				}
			}
		}
	}

	printf("%d\n", count);

	return 0;
}

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



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

    if (b - a == c - b) printf("YES\n");
    else printf("NO\n");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 100
#define MAX 1000

int top,S[MAX];
void initialize();
int isEmpty();
int isFull();
void push(int);
int pop();

int main()
{
  char s[N];
  int a,b;

  while( scanf("%s",s)!=EOF ){
    if( s[0]=='+' ){
      a = pop();
      b = pop();
      push(a+b);
    }
    else if( s[0]=='-' ){
      b = pop();
      a = pop();
      push(a-b);
    }
    else if( s[0]=='*' ){
      a = pop();
      b = pop();
      push(a*b);
    }
    else{
      push(atoi(s));
    }
  }

  printf("%d\n",pop());

  
  return 0;
}

void intialize(){
  top = 0;
}

int isEmpty(){
  return top == 0;
}

int isFull(){
  return top >= MAX-1;
}

void push(int x){
  if (isFull()) printf("overfllow error");
  top++;
  S[top] = x;
}

int pop(){
  if (isEmpty()) printf("underfllow error");
  top--;
  return S[top+1];
}




Measured memory_bytes: 2100
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void){
  int a, b, c, d, e, f;
  cin >>a>>b>>c>>d>>e>>f;
  if((e-a)<=f) cout<<"Yay!"<<endl;
  else cout<<":("<<endl;
  return 0;
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1];
    auto A = readln.split.map!(to!long).array;

    auto rbt = new RedBlackTree!(long, "a < b", true)();

    foreach (len; 1..N+1) {
        long tmp = 0;
        foreach (i; 0..len) {
            tmp += A[i];
        }
        rbt.insert(tmp);
        foreach (i; len..N) {
            tmp -= A[i-len];
            tmp += A[i];
            rbt.insert(tmp);
        }
    }


    foreach_reverse (b; 0..60) {
        long m = 1L << b;
        int cnt = 0;
        long[] to_remove;
        foreach (a; rbt) {
            if (a & m) {
                cnt += 1;
            } else {
                to_remove ~= a;
            }
        }
        if (cnt < K) {
            continue;
        }
        foreach (a; to_remove) {
            rbt.removeKey(a);
        }
    }

    long ans = (1L << 60) - 1;
    foreach (a; rbt) ans &= a;

    ans.writeln;
}


Measured memory_bytes: 36604
#include "bits/stdc++.h"

template<typename T>
class myStack {
private:
  std::vector<T> m_dat;
  int mi_top;
public:
  myStack() = default;
  inline size_t count() noexcept;
  void push(T val) noexcept;
  T top() noexcept;
  void pop() noexcept;
};

template<typename T>
inline size_t myStack<T>::count() noexcept {
  return mi_top;
}

template<typename T>
void myStack<T>::push(T val) noexcept {
  if(mi_top == m_dat.size()){
    m_dat.push_back(val);
    ++mi_top;
  }
  else{
    m_dat[mi_top++] = val;
  }
}

template<typename T>
T myStack<T>::top() noexcept {
  assert(mi_top > 0);
  return m_dat[mi_top - 1];
}

template<typename T>
void myStack<T>::pop() noexcept {
  --mi_top;
}

myStack<int> st;

void operate(char ope){
  assert(st.count() >= 2);
  long long a,b,c;
  b = st.top(); st.pop();
  a = st.top(); st.pop();
  switch(ope){
    case '+':
      c = a + b;
    break;
    case '-':
      c = a - b;
    break;
    case '*':
      c = a * b;
    break;
    default:
    exit(1);
  }
  st.push(c);
}
int main(){
  std::string str;
  while(std::cin >> str) {
      if(str == "+") {
        operate('+');
      }
      else if(str == "-") {
        operate('-');
      }
      else if(str == "*"){
        operate('*');
      }else{
        st.push(stol(str));
      }
  }
  // std::cout << "st.count(): " << st.count() << std::endl;
  // std::cout << "st.top(): " << st.top() << std::endl;
  std::cout << st.top() << std::endl;
  return 0;
}


Measured memory_bytes: 3184