akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() {
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif
	off;
	LL a,b;
	cin>>a>>b;
	LL mi = min(a,b);
	LL ma = max(a,b);

	if((ma-mi)&1)
		cout<<"IMPOSSIBLE";
	else
	{
		LL d= (ma-mi)/2;
		LL k = mi+d;
		cout<<k;
	}

  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

const ll MOD = 1e9+7;
int main(){
  ll N; cin >> N;
  //pos[i] = 色iが直近で出現した位置
  ll MAX = 2e5;
  vector<ll> C(N), dp(N,0), pos(MAX+1,-1);
  dp[0] = 1;
  REP(i,N) cin >> C[i];
  pos[C[0]] = 0;
  FOR(i,1,N){
    if(C[i]==C[i-1] || pos[C[i]]==-1){
      (dp[i] += dp[i-1]) %= MOD;
    }else{
      (dp[i] += (dp[i-1]+dp[pos[C[i]]] )%MOD) %= MOD;
    }
    pos[C[i]] = i;
  }
  cout << dp[N-1] << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n, x;
  cin>>n>>x;
  int a[n];
  rep(i,n) cin>>a[i];
  ll ans = 0;
  rep(i,n-1) {
    if(a[i] + a[i+1] > x) {
      int diff = a[i] + a[i+1] - x;
      if(a[i+1] >= diff) {
        ans += diff;
        a[i+1] -= diff;
      } else {
        ans += diff;
        a[i+1] = 0;
        a[i] -= diff - a[i + 1];
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_E main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif

vector<queue<int>> qs;
queue<pii> game_que;
set<pii> game_st;
bool check_next_game(int i) {
    if (qs[i].empty()) return false;
    int j = qs[i].front();
    if (qs[j].empty()) return false;
    if (qs[j].front() == i) {
        pii p(i,j);
        if (p.second < p.first) swap(p.first, p.second);
        if (game_st.count(p) == 0) {
            game_que.push(p);
            game_st.insert(p);
        }
    }

    return true;
};

int main_E() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    vvi A(N, vi(N - 1));
    REP(i, N)
        REP(j, N - 1) cin >> A[i][j];

    qs = vector<queue<int>>(N);
    REP(i,N)
        REP(j,N-1) qs[i].push(A[i][j] - 1);

    // Set games for the first day
    REP(i,N) check_next_game(i);
    
    int day = 0;
    while (game_que.size() > 0) {
        queue<pii> prevQ;
        swap(prevQ, game_que);

        // Play games
        queue<pii> tmpQ = prevQ;
        while(!tmpQ.empty()) {
            pii p = tmpQ.front(); tmpQ.pop();
            int i = p.first, j = p.second;
            qs[i].pop();
            qs[j].pop();
        }

        // Set next games
        while(!prevQ.empty()) {
            pii p = prevQ.front(); prevQ.pop();
            int i = p.first, j = p.second;
            check_next_game(i);
            check_next_game(j);
        }

        day++;
    }

    REP(i,N) {
        if (!qs[i].empty()){
            day = -1;
            break;
        }
    }

    int ans = day;
    cout << ans << endl;

    game_st.clear();

    return 0;
}

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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<ll> a(n);
	rep (i, n) cin >> a[i];
	ll res = 0;
	ll p = 1;
	rep (i, 61) {
	  ll cnt = 0;
	  rep (j, n) if (a[j] & (1LL << i)) cnt++;
	  cnt *= (n - cnt);
	  cnt %= MOD;
	  res += (p * cnt) % MOD;
	  res %= MOD;
	  p *= 2;
	  p %= MOD;
	}
	cout << res << endl;
						  
    return 0;
}



Measured memory_bytes: 5556
#include<stdio.h>
#define N 100
#define MAX 1000000
#define W 0
#define Gr 1
#define B 2
int n,G[N][N],ws,way[N],iro[N];
int saitan();
int main(){
  int i,j,l,tar,k,v,c;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&tar,&k);
    way[i]=MAX;
    iro[i]=W;
    for(l=0;l<n;l++) G[i][l]=MAX;
    for(j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      G[tar][v]=c;
    }
  }
  saitan();
  return 0;
}
int saitan(){
  int i,j,tar,ws,min;
  way[0]=0;
  iro[0]=W;
  while(1){
    min = MAX;
    tar=-1;
    for(i=0;i<n;i++){
      if(min > way[i] && iro[i] != B){
	tar=i;
	min = way[i];
      }
    }
    if(tar==-1) break;
    iro[tar]=B;
    for(j=0;j<n;j++){
      if(iro[j]!=B && G[tar][j] != MAX){
	if(way[j] > way[tar] + G[tar][j]){
	  way[j]=G[tar][j] + way[tar];
	  iro[j]=Gr;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d %d\n",i,way[i]==MAX ? -1 :way[i]);
  }  
  return ws;
}


Measured memory_bytes: 2056
from collections import defaultdict
from collections import Counter
n = int(input())

li = []
for _ in range(n):
    li.append(list(map(str, input().rstrip())))

lineup = set(li[0])

for i in li[1:]:
    lineup = lineup & set(i)

d = defaultdict(int)

for i in lineup:
    d[i] = 51

for i in d.keys():
    for j in li:
        if d[i] > j.count(i):
            d[i] = j.count(i)

ans = []
for k, v in d.items():
    ans.append(k * v)

ans.sort()

print("".join(ans))

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var t2 = 0;
            var x2 = 0;
            var y2 = 0;
            for (var i = 0; i < n; i++)
            {
                var mmm = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                var t3 = mmm[0];
                var x3 = mmm[1];
                var y3 = mmm[2];
                var t = Math.Abs(t3 - t2);
                var x = Math.Abs(x3 - x2);
                var y = Math.Abs(y3 - y2);
                var d = x + y;
                if (d>t || t%2 != d%2)
                {
                    Console.WriteLine("No");
                    return;
                }
                t2 = t3;
                x2 = x3;
                y2 = y3;
            }
            Console.WriteLine("Yes");
        }

    }
}

Measured memory_bytes: 15284
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll a,b,ans=0;
    cin>>a>>b;
    ans=max(a,b);
    ans+=max(max(a,b)-1,min(a,b));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
 
  int w, d, h1, h2;
 
  while(cin>>w>>d, w){
    int cnt1[21]={}, cnt2[21]={};
    for(int i=0;i<w;i++){
      cin>>h1;
      cnt1[h1]++;
    }
    for(int i=0;i<d;i++){
      cin>>h2;
      cnt2[h2]++;
    }
     
    int ans=0;
    for(int i=1;i<=20;i++){
      ans+=max(cnt1[i], cnt2[i])*i;
    }
     
    cout<<ans<<endl;
  }
   
  return 0;
}

Measured memory_bytes: 3080
#include<stdio.h>
#include<ctype.h>

int main()

{
    char a[100],b[110],c[110];
    scanf("%s %s %s",a,b,c);
    printf("%c%c%c",toupper(a[0]),toupper(b[0]),toupper(c[0]));

    return 0;
}


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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    int x,y;
    cin >> x >> y;
    bool ans = false;

    //i == turu
    for(int i = 0; i <= x; i++){

        if((y - i * 2) % 4 == 0 && (y - i * 2) / 4 + i == x){
            ans = true;
            break;
        }
    }

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}


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

int main() {
    string S;
    long long int K;
    cin >> S;
    cin >> K;

    bool same = true;

    for (int i = 0; i < S.size() - 1; i++) {
        if (S[i] != S[i + 1]) {
            same = false;
        }
    }
    if (same) {
        long long int output = K * S.size() / 2;
        cout << output << endl;
        return 0;
    }

    long long int num = 0;
    for (int i = 0; i < S.size() - 1; i++) {
        if (S[i] == S[i + 1]) {
            num++;
            i += 1;
        }
    }

    string S2 = S + S;
    long long int num2 = 0;
    for (int i = 0; i < S2.size() - 1; i++) {
        if (S2[i] == S2[i + 1]) {
            num2++;
            i += 1;
        }
    }

    long long int output;

    output = num + (K - 1) * (num2 - num);

    cout << output << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <array>
#include <deque>
#include <iomanip>
#include <bitset>
#include <complex>
#include <sstream>
#include <algorithm>
#include <limits>
#include <cmath>
#include <utility>
#include <tuple>
#include <numeric>
#include <cassert>
using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;

template <typename T>
constexpr T INF = "Undefined";
template <>
constexpr int INF<int> = 1e9;
template <>
constexpr ll INF<ll> = 1e18;
template <>
constexpr ld INF<ld> = 1e30;

constexpr int mod = 1e9+7;
constexpr ld eps = 1e-10;
constexpr ld pi = acos(-1.0);

#define DUMP(a) cout << #a << ": " << (a) << endl


int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    int m = 0;
    for(int i=0; i<s.size(); ++i) {
        int s_pos = i;
        for(int j=0; j<s.size(); ++j) {
            if(s_pos < s.size() && s[s_pos] == t[j]) {
                m = max(m, j+1);
                s_pos++;
            } else {
                break;
            }
        }
    }
    cout << n*2 - m << endl;
}



Measured memory_bytes: 384
#include <queue>
#include <iostream>
#include <map>
using namespace std;
typedef vector<int> A;
typedef vector<A> M;
#define REP(i,x)for(int i=0;i<x;i++)
int d[4]={0,1,0,-1};
int main() {
    queue<M> que;
    map<M,int> mindist;
    M m(2,A(4));
    REP(i,2)REP(j,4)m[i][j]=i*4+j;
    que.push(m);
    while(!que.empty()){
        M now=que.front();que.pop();
        int time=mindist[now];
        REP(i,2)REP(j,4)if(now[i][j]==0)REP(k,4){
            int ni=i+d[k],nj=j+d[k^1];
            if(ni>=0&&ni<2&&nj>=0&&nj<4){
                swap(now[i][j],now[ni][nj]);
                if(mindist.count(now)==0)
                    mindist[now]=time+1,
                    que.push(now);
                swap(now[i][j],now[ni][nj]);
            }
        }
    }
    while(cin>>m[0][0]>>m[0][1]>>m[0][2]>>m[0][3]>>m[1][0]>>m[1][1]>>m[1][2]>>m[1][3])
        cout<<mindist[m]<<endl;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int a=0;
    int b=0;
    int v[MAX][3];
    for(int i=0; i<MAX; i++){
        v[i][0]=0; 
        v[i][1]=0;
        v[i][2]=0;
    }
    int j=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='1' && (s[i+1]=='0' || i==s.size()-1)){
            a++;
            v[j][2]=a;
            j++;
            v[j][0]=a;
            a=0;
        }
        else if(s[i]=='0' && (s[i+1]=='1' || i==s.size()-1)){
            b++;
            v[j][1]=b;
            b=0;
        }
        else if(s[i]=='1' && s[i+1]=='1'){a++;}
        else if(s[i]=='0' && s[i+1]=='0'){b++;}
    }
    vector<ll> sum(j+1);
    for(int i=0; i<=j; i++){
        for(int t=0; t<k; t++){
            if((i+t)>j){
                break;
            }
            sum[i]+=v[i+t][1]+v[i+t][2];
            if((t)==0){
                sum[i]+=v[i+t][0];
            }
        }
    }

    sort(sum.begin(), sum.end(), greater<ll>());

    cout << sum[0] << endl;
    return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>

int main(){
int a, b, c, d;
int s1, s2;
scanf("%d%d%d%d",&a,&b,&c,&d);
s1 = a*b;
s2 = c*d;

if(s1>s2) printf("%d", s1);
if(s1<=s2) printf("%d", s2);

return 0;
}

Measured memory_bytes: 128
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define pu push_back           
#define pp pop_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const int MOD=1e9+7 ;
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=2e5+1;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> ivc;
typedef pair<ll,ll> ipr;

vector<ll> v;
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b%a, a); 
} 

void pr(ll n) 
{  
    while (n%2 == 0) 
    { 
        v.pu(2);
        n = n/2; 
    }  
    for (ll i = 3; i <= sqrt(n); i = i+2) 
    { 
        while (n%i == 0) 
        { 
            v.pu(i);
            n = n/i; 
        } 
    } 
    if (n > 2) 
        v.pu(n); 
} 
int main()
{
    IOS();
   
    ll n,m,i;
    v.pu(1);
    cin>>n>>m;
    pr(gcd(n,m));
    sort(all(v));
    v.erase(unique(all(v)),v.end());
    cout<<v.size();



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main(int argc, char *argv[])
{
  int n;
  cin >> n;
  n = n % 10;
  set<int> hon{2, 4, 5, 7, 9};
  set<int> pon{0, 1, 6, 8};
  set<int> bon{3};

  if (hon.find(n) != hon.end())
  {
    cout << "hon" << endl;
  }
  else if (pon.find(n) != pon.end())
  {
    cout << "pon" << endl;
  }
  else
  {
    cout << "bon" << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}


ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
  ll h,n;
  cin>>h>>n;
  
  vl a(n);
  ll ans =0;
  rep(i,n ){
   cin>>a[i];
   ans +=a[i]; 
  }
  if(ans >= h)cout <<"Yes"<<endl;
  else cout << "No"<<endl;
}




Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int h,w,i,j;
  while(1){
  scanf("%d %d",&h, &w);
  if(w*h==0)break;
  for(j=0;j<h;j++){
    for(i=0;i<w;i++){
      if(i*j*(j-h+1)*(i-w+1)==0){
	printf("#");
      }	else printf("."); 
    } 
    printf("\n");
 }
  printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	string s;
	cin >> s;
	for(int i =0;i<s.size();i++)if(0x41<=s[i]&&s[i]<=0x5a)s[i]+=32;
	string t;
	int cnt = 0;
	while (cin >> t)
	{
		for(int i =0;i<t.size();i++)if(0x41<=t[i]&&t[i]<=0x5a)t[i]+=32;
		if(s==t)cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
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;}

char c[] = {'a','d','g','j','m','p','t','w'};
char cc[] = {'.',',','!','?',' '};
int a[] = {3,3,3,3,3,4,3,4};

signed main()
{
	IOS();
	int N;
	cin>>N;
	vector<string>v;
	while(N--){
		string s;
		cin>>s;
		string t="";
		int flg = -1;
		rep(i,0,s.size()){
			if(s[i]=='0'){
				if(flg==-1)continue;
				if(s[i-1]=='1'){
					t+=cc[flg%5];
				}else{
					int tt = s[i-1]-'2';
					t+=c[tt]+flg%a[tt];
				}
				flg = -1;
			}else{
				flg++;
			}
		}
		v.push_back(t);
	}
	for(auto e:v){
		cout<<e<<endl;
	}
}



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

bool check(int position, vector<char[2]> &work_list, string road_list,bool go_left) {
	for (int i = 0; i < work_list.size(); ++i) {
		char key = work_list[i][0];
		int direction = work_list[i][1] == 'L' ? -1 : 1;
		if (key == road_list[position]) {
			position += direction;
			if (go_left) {
				if (position == -1) {
					return true;
				}
				else if (position == road_list.size()) {
					return false;
				}
			}
			else {
				if (position == road_list.size()) {
					return true;
				}
				else if (position == -1) {
					return false;
				}
			}
		}
	}
	return false;
}

int main() {
	int N, Q;
	cin >> N >> Q;
	string road_list;
	cin >> road_list;
	vector<char[2]> work_list(Q);
	for (int i = 0; i < Q; ++i) {
		cin >> work_list[i][0] >> work_list[i][1];
	}
	int ln = 0, hn = N;
	while (ln < hn) {
		int mid = (ln + hn) / 2;
		if (check(mid, work_list, road_list, true)) {
			ln = mid + 1;
		}
		else {
			hn = mid;
		}
	}
	int left = ln;
	ln = 0;
	hn = N;
	while (ln < hn) {
		int mid = (ln + hn) / 2;
		if (check(mid, work_list, road_list, false)) {
			hn = mid;
		}
		else {
			ln = mid + 1;
		}
	}
	int right = ln;
	cout << right - left << endl;
	/*
	for (int i = 0; i < 2; ++i) {
		while (getchar() != '\n');
	}*/
	return 0;
}

Measured memory_bytes: 1156
gets;
S,*f='? '+?0*N=200;
*A=?!;
N.times{|i|S[i+2]=?1;i.times{|j|
S[j+2]=?1;
puts S;
S[j+2]=?0;
f<<[i,j]
};S[i+2]=?0};
$>.flush;f.map{|i,j|gets=="1
"&&A<<" (#{i},#{j})"};
print *A

Measured memory_bytes: 5456
import math

while True:
    i = int(input())
    if i == 0:
        break
    s = str(math.factorial(i))
    c = 0
    _c = 0
    for j in list(s):
        if j == '0':
            _c += 1
        else:
            _c = 0
        if c < _c:
            c = _c
    print(c)


Measured memory_bytes: 6068
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int h,w,n;
    cin>>h>>w>>n;
    int mx=max(h,w);
    cout<<(n+mx-1)/mx<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main(){
  int N,Y;
  cin >>N>>Y;
  std::vector<int> v(3,-1);
  REP(A,N+1){
    REP(B,N+1-A){
      if(9000*A+4000*B == Y - 1000 * N){
        v.at(0) = A;
        v.at(1) = B;
        v.at(2) = N-A-B;
        break;
      }
    }
  }
  cout << v.at(0)<<" "<<v.at(1)<<" "<<v.at(2)<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <queue>
#define travel(x, i) for (int i = fir[x]; i; i = e[i].nxt)
using namespace std;

const int N  = 1e6 + 5;

namespace fastIO {
#define buf_size 1000000
  bool error;
  inline char gc() {
    static char buf[buf_size + 1], *l = buf, *r = buf;
    if (l == r) {
      l = buf;
      r = buf + fread(buf, 1, buf_size, stdin);
      if (l == r) {error = 1; return -1;}
    }
    return *l ++;
  }
  inline bool blank(char ch) {
    return ch == '\n' || ch == '\t' || ch == ' ' || ch == '\r' || error;
  }
  inline void read(int &x) {
    char ch; x = 0;
    while (!isdigit(ch = gc()) && !error);
    if (error) return;
    do {x = (x << 1) + (x << 3) + ch - '0';} while (isdigit(ch = gc()) && !error);
  }
  inline void read(double &x) {
    char ch; x = 0;
    while (!isdigit(ch = gc()) && !error);
    if (error) return;
    do {x = x * 10 + ch - '0';} while (isdigit(ch = gc()) && !error);
    if (error || ch != '.') return;
    double base = 1;
    while (isdigit(ch = gc()) && !error) {
      base *= 0.1;
      x += base * (ch - '0');
    }
  }
  inline char readchar() {
    char ch = 0;
    while (blank(ch = gc()) && !error);
    return ch;
  }
  inline void write(int x) {
    if (!x) {putchar('0'); return;}
    if (x < 0) {x = -x; putchar('-');}
    static int buf[23];
    register short len = 0;
    for (; x; x /= 10) buf[++ len] = x % 10;
    for (; len; len --) putchar(buf[len] + '0');
  }
#undef buf_size
}
using namespace fastIO;

struct edge {
  int nxt, to;
} e[N];
int fir[N], cnt = 0, deg[N], val[N];
bool win[N];
queue <int> Q;

inline void addedge(int x, int y) {
  e[++ cnt] = (edge){fir[x], y};
  fir[x] = cnt; deg[y] ++;
}

int main() {
  int n;
  read(n);
  for (int i = 1; i <= n; i ++) read(val[i]);
  for (int i = 1, x, y; i < n; i ++) {
    read(x); read(y);
    if (val[x] > val[y]) addedge(y, x);
    if (val[x] < val[y]) addedge(x, y);
  }
  for (int i = 1; i <= n; i ++)
    if (deg[i] == 0) Q.push(i);
  int x;
  while (!Q.empty()) {
    x = Q.front();
    Q.pop();
    for (int i = fir[x]; i; i = e[i].nxt) {
      deg[e[i].to] --;
      win[e[i].to] |= !win[x];
      if (!deg[e[i].to]) Q.push(e[i].to);
    }
  }
  for (int i = 1; i <= n; i ++)
    if (win[i]) write(i), putchar(' ');
  return 0;
}


Measured memory_bytes: 6528
import numpy as np

N=int(input())
A=[]
PRECISION_DIGITS=9
NO_ENTRY = 0
ARR_SIZE=PRECISION_DIGITS*2+1
cnt=np.full((ARR_SIZE,ARR_SIZE),NO_ENTRY,int)
# cnt=np.zeros((PRECISION_DIGITS*2,PRECISION_DIGITS*2),int)

# print(cnt)

for n in range(N):
	tmpA = float(input())
	tmpA = round(tmpA*10**PRECISION_DIGITS)
	#print(tmpA)

	five = 0
	two = 0
	# (10**9) -> (two,five)=(9,9)
	# min = 10**-9, ignore < 10**9 ???
	while (tmpA % 2) == 0 and two < PRECISION_DIGITS*2:
		two += 1
		tmpA //= 2
	while (tmpA % 5) == 0 and five < PRECISION_DIGITS*2:
		five += 1
		tmpA //= 5

	if cnt[two][five] == NO_ENTRY:
		cnt[two][five]=1
	else:
		cnt[two][five]+=1

# print(cnt)
ans = 0

for x1 in range(ARR_SIZE):
	for y1 in range(ARR_SIZE):
		if cnt[x1][y1] == NO_ENTRY:
			continue

		for x2 in range(ARR_SIZE):
			for y2 in range(ARR_SIZE):
				if cnt[x2][y2] == NO_ENTRY:
					continue
				# 2**a(a>=0) and 5**b(b>=0) => integer
				if 0 <= x1+x2 - PRECISION_DIGITS*2 and 0 <= y1+y2 -PRECISION_DIGITS*2:
					if x1 == x2 and y1 == y2:
						# same entry
						# Total number of combinations choose 2 items
						# nC2 = n*(n-1)/2
						ans += int((cnt[x1][y1]*(cnt[x2][y2]-1))//2)
					else:
						ans += int(cnt[x1][y1]*cnt[x2][y2])

		# count up completed entry
		cnt[x1][y1] = NO_ENTRY

print(ans)



Measured memory_bytes: 27168
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String c1 = sc.nextLine();
		String c2 = sc.nextLine();
		String c3 = sc.nextLine();
		System.out.print(c1.charAt(0));
		System.out.print(c2.charAt(1));
		System.out.print(c3.charAt(2));
	}
}


Measured memory_bytes: 21844
import math

def is_prime(x):
    if x == 2:
        return True
    elif (x % 2 == 0) or (x < 2):
        return False
    else:
        i = 3
        while i <= math.sqrt(x):
            if x % i == 0:
                return False
            i += 2 
        else:
            return True


ans = 0
for _ in range(int(input())):
    ans += is_prime(int(input()))
else:
    print(ans)


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

#define endl '\n'
#define ll long long
#define LSB __builtin_ctzll
#define sc(a) scanf("%d",&a)
#define MSB 63-__builtin_clzll
#define scl(a) scanf("%lld",&a)
#define BITS __builtin_popcountll
#define mem(a , v)  memset(a , v , sizeof(a))
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9+7;
const int MAX = 1e5+55;
const int INF = 1e9+77;
const ll INFINF = 1e18+1e17;
const double PI = acos(-1.0);
vector<int> months = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y&1)
         s*=x;
         return s;
}

int n;
int x[MAX][4];
ll dp[MAX][4];

ll solve(int i,int st){
        if(i==n){
            return 0;
        }

        ll &res=dp[i][st];
        if(res!=-1){
            return res;
        }


        if(st==1){
            res=max( solve(i+1,2)+x[i][2] , solve(i+1,3)+x[i][3] );
        }
        else if(st==2){
            res=max( solve(i+1,1)+x[i][1] , solve(i+1,3)+x[i][3] );
        }
        else if(st==3){
            res=max( solve(i+1,1)+x[i][1] , solve(i+1,2)+x[i][2] );
        }
        else{
            res=max( solve(i+1,1)+x[i][1] , solve(i+1,2)+x[i][2] );
            res=max(  res  , solve(i+1,3)+x[i][3]  );
        }

        return res;


}




int main(){

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//freopen("input.txt" , "r" , stdin);
//freopen("output.txt" , "w" , stdout);





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

    mem(dp,-1);

    cout<<solve(0,0);






     return 0;

}


Measured memory_bytes: 9600
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n:u32 = read();
    let d:u32 = read();

    let d = 2*d+1;

    println!("{}", if n%d == 0 {n/d} else {n/d+1});
}

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

int main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    cout << 60 * H2 + M2 - 60 * H1 - M1 - K << endl;
    return 0;
}

Measured memory_bytes: 3640
package main

import "fmt"

func main() {
	var N int
	var S string
	fmt.Scanf("%d", &N)
	fmt.Scanf("%s", &S)
	if len(S)%2 == 1 {
		fmt.Println("No")
		return
	}
	for i := 0; i < len(S)/2; i++ {
		if S[i] != S[len(S)/2+i] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


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

using namespace std;

typedef long long ll;

const int N = 2e5 + 10;
char str[N];

void savecode() {

}

//wwbbb
int v[N];

int main() {
    scanf("%s", str + 1);
    int len = strlen(str + 1);
    int sz = 0;
    rep(i, 1, len) if (str[i] == 'W') v[++sz] = i;
    ll now = 1, ans = 0;
    rep(i, 1, sz) {
        ans += 1ll * v[i] - now;
        now++;
    }
    cout << ans;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int k;
ll p;
vector<vector<ll>>mat(50,vector<ll>(50,0));
vector<vector<ll>> mul(vector<vector<ll>> a,vector<vector<ll>> b)
{
    vector<vector<ll>> c(50,vector<ll>(50,0));
    for(int i=0;i<k;i++)
    {
        for(int j=0;j<k;j++)
        {
            ll ans=0;
            for(int x=0;x<k;x++)
            {
                ans = (ans%mod+(a[i][x]%mod*b[x][j]%mod)%mod)%mod;
            }
            c[i][j]=ans;
        }
    }
    return c;
}
vector<vector<ll>> pow(vector<vector<ll>> a,ll p)
{
    if(p==1)
    return a;
    if(p&1)
    return mul(a,pow(a,p-1));
    vector<vector<ll>> x = pow(a,p/2);
    return mul(x,x);
}
int main() {
    cin>>k>>p;
    for(int i=0;i<k;i++)
    {
        for(int j=0;j<k;j++)
        cin>>mat[i][j];
    }
    mat = pow(mat,p);
    ll res=0;
    for(int i=0;i<k;i++)
    {
        for(int j=0;j<k;j++)
        {
            res = (res%mod+mat[i][j]%mod)%mod;
        }
    }
    cout<<res;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> B(N);
    for (int i = 0; i < N; i++) cin >> B[i];

    bool flag = true;
    for (int i = 0; i < N; i++) {
        if (B[i] > i + 1) flag = false;
    }

    if (!flag) cout << "-1" << endl;
    else {
        vector<int> ans(N);
        while (B.size() > 0) {
            for (int i = B.size() - 1; i >= 0; i--) {
                if (B[i] == i + 1) {
                    ans[B.size() - 1] = i + 1;
                    B.erase(B.begin() + i);
                    break;
                }
            }
        }
        for (int i = 0; i < N; i++) {
            cout << ans[i] << endl;
        }
    }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

def main():
    N,M = map(int,input().split())
    p = list(map(int,input().split()))
    
    I = [i for i in range(N)]
    def root(x):
        if x == I[x]:
            return x
        I[x] = root(I[x])
        return I[x]

    for _ in range(M):
        x,y = map(int,input().split())
        a = root(x-1)
        b = root(y-1)
        if a != b:
            I[b] = a

    c = 0
    for i in range(N):
        if root(p[i]-1) == root(i):
            c += 1
            
    print(c)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 12392
import java.io.InputStream;
import java.util.NoSuchElementException;
public class Main {
	public static void main(String[] args)throws Exception{
		int X=nextInt();
		int N=nextInt();
		boolean p[]=new boolean[105];
		for(int i=0;i<N;i++){
			p[nextInt()]=true;
		}
		for(int i=X,j=X;i>=0;i--,j++){
			if(p[i]==false){
				System.out.println(i);
				System.exit(0);
			}
			if(p[j]==false){
				System.out.println(j);
				System.exit(0);
			}
		}
		System.out.println(-1);
	}
	//FastScanner
	static InputStream in = System.in;
	static  byte[] buffer = new byte[1024];
	static int length = 0, p = 0;
	public static boolean hasNextByte () {
		if (p < length) return true;
		else {
			p = 0;
			try {length = in.read(buffer);}
			catch (Exception e) {e.printStackTrace();}
			if (length == 0) return false;
		}
		return true;
	}
	public static int readByte () {
		if (hasNextByte() == true) return buffer[p++];
		return -1;
	}
	public static boolean isPrintable (int n) {return 33<=n&&n<=126;}
	public static void skip () {
		while (hasNextByte() && !isPrintable(buffer[p])) p++;
	}
	public static boolean hasNext () {skip(); return hasNextByte();}
	public static String next () {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int temp = readByte();
		while (isPrintable(temp)) {
			sb.appendCodePoint(temp);
			temp = readByte();
		}
		return sb.toString();
	}
	public static int nextInt () {return Math.toIntExact(nextLong());}
	public static int[] nextInts (int n) {
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = nextInt();
		return ar;
	}
	public static long nextLong () {
		if (!hasNext()) throw new NoSuchElementException();
		boolean minus = false;
		int temp = readByte();
		if (temp == '-') {
			minus = true;
			temp = readByte();
		}
		if (temp<'0' || '9'<temp) throw new NumberFormatException();
		long n = 0;
		while (isPrintable(temp)) {
			if ('0'<=temp && temp<='9') {
				n *= 10;
				n += temp - '0';
			}
			temp = readByte();
		}
		return minus? -n : n;
	}
}


Measured memory_bytes: 32536
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#define N 100005
using namespace std;
typedef long long ll;
int n,ma,mb;
int a[42],b[42],c[42];
int dp[42][405][405];
int main() {
	cin>>n>>ma>>mb;
	for (int i = 1; i <= n; ++i) {
		cin>>a[i]>>b[i]>>c[i];
	}
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= n * 10; ++j) {
			for (int k = 0; k <= n * 10; ++k) {
				dp[i][j][k] = 1000000;
			}
		}
	}
	dp[0][0][0] = 0;
	int sa = 0;
	int sb = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= sa; ++j) {
			for (int k = 0; k <= sb; ++k) {
				dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
				dp[i+1][j+a[i+1]][k+b[i+1]] = min(dp[i+1][j+a[i+1]][k+b[i+1]], dp[i][j][k] + c[i+1]);
			}
		}
		sa += a[i+1];
		sb += b[i+1];
	}
	int ans = 1000000;
	for (int i = 1; i <= sa; ++i) {
		for (int j = 1; j <= sb; ++j) {
			if (dp[n][i][j] < 1000000 && i * mb == j * ma) {
				ans = min(ans, dp[n][i][j]);
			}
		}
	}
	if (ans < 1000000) cout<<ans<<endl;
	else cout<<"-1"<<endl;
	return 0;
}

Measured memory_bytes: 26880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int A = in(),B = in(),C = in();
    if(A == B){
        cout << C << "\n";
    }else if(A == C){
        cout << B << "\n";
    }else{
        cout << A << "\n";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
void solve(){
	string s;
	cin>>s;
	ll n=sz(s);
	if(s[n-1]=='s')
		cout<<s+"es";
	else
		cout<<s+"s";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++){
        solve();
    }
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}


Measured memory_bytes: 3808
//Be Name Khoda
//me and who? :|
/*
ID: aminra81
PROG: gift1
LANG: C++11
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7;
const ll inf = (ll)1e18;
const int infint = (int)2e9;
const int MAXN = (int)3e5 + 10;
ll a[MAXN], pre[MAXN], nxt[MAXN];
int main()
{
	ll sum = 0, n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	stack<int> T;
	for (int i = 0; i < n; i++)
	{
		while(T.size() > 0 and a[i] <= a[T.top()])
			T.pop();
		if(T.size() == 0)
			pre[i] = -1;
		else
			pre[i] = T.top();
		T.push(i);
	}
	while(T.size())
		T.pop();
	for (int i = n - 1; i >= 0; i--)
	{
		while(T.size() > 0 and a[i] < a[T.top()])
			T.pop();
		if(T.size() == 0)
			nxt[i] = n;
		else
			nxt[i] = T.top();
		T.push(i);
	}
	for (int i = 0; i < n; i++)
	{
		sum += (i - pre[i]) * (nxt[i] - i) * a[i];
	}
	cout << sum;
}


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

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

  vector<int> h(N);
  for(auto& x: h){
    cin >> x;
  }
  sort(h.begin(), h.end());

  int ans = 1e9;
  for(int i = 0; i + K <= N; i++){
    ans = min(h[i + K - 1] - h[i], ans);
  }

  cout << ans << endl;
}


Measured memory_bytes: 888
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include<cstdio>
#include <vector>
#include<queue>
#include<limits.h>
#include<string.h>
#include<functional>
#include<map>
#include<set>
#include<list>
using namespace std;

bool a[4][13];
string S = "SHCD";
signed main() {
	map<char, int>M;
	M['H'] = 1;
	M['C'] = 2;
	M['D'] = 3;
	int b; cin >> b;
	for (int c = 0; c < b; c++) {
		char d; cin >> d;
		int e; cin >> e;
		a[M[d]][e - 1] = true;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (!a[i][j]) {
				printf("%c %d\n",S[i] , j + 1);
			}
		}
	}
}

Measured memory_bytes: 3212
# -*- coding: utf-8 -*-


def main():
    import sys
    input = sys.stdin.readline

    h, w, m = map(int, input().split())
    h_count = [0 for _ in range(h)]
    w_count = [0 for _ in range(w)]
    pairs = set()

    # KeyInsight:
    # x方向とy方向を独立に考える
    # 爆破できる数: x方向の最大値 + y方向の最大値
    #             x, y方向が交差する場合は-1
    for i in range(m):
        hi, wi = map(int, input().split())
        hi -= 1
        wi -= 1

        h_count[hi] += 1
        w_count[wi] += 1

        pairs.add((hi, wi))

    # 各方向の最大値を計算
    h_max = max(h_count)
    w_max = max(w_count)
    hk = list()
    wk = list()

    # 各方向で、最大値となる行もしくは列を抽出
    for index, hj in enumerate(h_count):
        if hj == h_max:
            hk.append(index)

    for index, wj in enumerate(w_count):
        if wj == w_max:
            wk.append(index)

    # 答えの候補
    ans = h_max + w_max

    # 範囲を限定して全探索
    # 合計が最大値となる組み合わせを全探索
    for _h in hk:
        for _w in wk:
            hw = (_h, _w)

            if hw in pairs:
                continue

            # 一つでも条件に合致したら、計算を打ち切る
            print(ans)
            exit()

    print(ans - 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 83560
#include <stdio.h>

int main(void)
{
	int x,y,w;
	
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0&&y==0) break;
		else if(x>y){
			w=x;
			x=y;
			y=w;
			printf("%d %d\n",x,y);
		}else{
			printf("%d %d\n",x,y);
		}
	}
	
	return 0;
}

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

using namespace std;

inline void quit(){ exit(0); }

typedef long long ll;

ll mpow(ll _x, ll _y, ll _mod){
    if(_y==0) return 1;
    if(_y==1) return _x%_mod;
    if(_y&1) return (mpow(_x, _y-1, _mod)*_x)%_mod;
    ll _tmp = mpow(_x, _y>>1, _mod);
    return (_tmp*_tmp)%_mod;
}

int n, k;
int a[1002], b[1002];
int l[1002];

int DP[1002][4096];

int main(){
    scanf("%d %d", &n, &k);
    for(int i=1; i<=k; i++){
        scanf("%d %d", &a[i], &b[i]);
        for(int j=1; j<=b[i]; j++){
            int x;
            scanf("%d", &x);
            l[i] |= (1<<(x-1));
        }
    }

    for(int i=0; i<=k; i++) for(int j=0; j<(1<<n); j++) DP[i][j] = 1e8+1;
    DP[0][0] = 0;
    for(int i=0; i<k; i++){
        for(int j=0; j<(1<<n); j++){
            if(DP[i][j] == 1e8+1) continue;
            DP[i+1][j] = min(DP[i+1][j], DP[i][j]);
            DP[i+1][j|l[i+1]] = min(DP[i+1][j|l[i+1]], DP[i][j] + a[i+1]);
        }
    }

    if(DP[k][(1<<n)-1]==1e8+1) DP[k][(1<<n)-1]=-1;
    printf("%d", DP[k][(1<<n)-1]);
}


Measured memory_bytes: 16256
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <string>
#include <map>
#include <list>
using namespace std;

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

  bool can=true;
  for(int i = 0; i < s.size(); ++i){
    if(i%2==0){
      if(s[i] == 'L'){
        can=false;
      }
    }else {
      if(s[i] == 'R'){
        can=false;
      }
    }
  }
  if(can){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}



Measured memory_bytes: 3604
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        int line = sc.nextInt()-1;
      int line2 = sc.nextInt()-1;
        System.out.println(line*line2);
    }
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

int a,b;
int main(){
	cin >> a >> b;
	if(a < b)for(int i = 0; i< b; i++)cout << a;
	else for(int i = 0; i < a; i++)cout << b;
	cout << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	const m = 100
	var d, n int
	fmt.Scan(&d, &n)

	b2i := map[bool]int{false: 0, true: 1}
	ans := (n + b2i[n == m]) * pow(m, d)
	fmt.Println(ans)
}

func pow(a, b int) int {
	res := 1
	for range make([]struct{}, b) {
		res *= a
	}
	return res
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>


#define NIL -1
#define MAX 10000
using namespace std;

struct Node{
    int parent, left, right;
};
struct Node v[MAX];

void preParse(int u){
    if(u == NIL){
        return;
    }
    cout << " " << u;
    preParse(v[u].left);
    preParse(v[u].right);
}

void inParse(int u){
    if(u == NIL){
        return;
    }
    inParse(v[u].left);
    cout << " " << u;
    inParse(v[u].right);
}

void postParse(int u){
    if (u==NIL){
        return;
    }
    postParse(v[u].left);
    postParse(v[u].right);
    cout << " " << u;
}

int main() {
    
    int n;
    cin >> n;
    for (int i= 0;i<n;i++){
        v[i].parent = NIL;
    }
    for (int i=0;i<n;i++){
        int a,l,r;
        cin >> a >> l >> r;
        v[a].left = l;
        v[a].right = r;
        v[l].parent = a;
        v[r].parent = a;
    }
    int root;
    for (int i=0;i<n;i++){
        if(v[i].parent == NIL){
            root = i;
            break;
        }
    }
  
    cout << "Preorder" << endl;
    preParse(root);
    cout << endl;
    cout << "Inorder" << endl;
    inParse(root);
    cout << endl;
    cout << "Postorder" << endl;
    postParse(root);
    cout << endl;

}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(int _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 200000

using namespace std;

ll f (ll x) {
  if (x == 0) return 0;
  if (x == 1) return 1;
  return 1 + 2LL*f(x/2LL);
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  ll n; cin >> n;
  cout << f(n);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int n;
	cin >> n;
	unordered_map<int, int> mp;

	vector<int> h(n);
	ll ans = 0;
	rep(i, n) cin >> h[i];
	rep(i, n) {
		int upper = i - h[i];
		int lower = i + h[i];
		ans += mp[upper];
		mp[lower]++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 19212