akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MAXN 100010
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const ll mod = 1e18 + 7;
map<pii, int> m;
ll w, h, a, b;

void add(int a, int b){
    if (a < 0 || a >= h || b < 0 || b >= w){
        return;
    }
    m[{a, b}]++;
}


int main (){
    int n, count[10]={};
    cin >> h >> w >> n;


    for (int i=0; i<n; i++){
        cin >> a >> b;
        a--, b--;
        for (int j=-2; j<=0; j++){
            for (int k=-2; k<=0; k++){
                add(a+j, b+k);
            }
        }
    }

    ll soma = 0;

    for (auto it: m){
        if (it.ff.ff < h-2 and it.ff.ff >=0 and it.ff.ss < w-2 and it.ff.ss >= 0){
            count[it.second]++;
            soma++;
        }
    }

    cout << (h-2LL)*(w-2LL) - soma << endl;


    for (int i=1; i<=9; i++){
        cout << count[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 56448
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
    ll N,min=1e6,o=1e9+1;
    cin >> N;
    vector<long long> A(N,0);
    for (int i = 0; i < N-1; i++) {
        ll a; cin >> a;
        A.at(a-1)++;
    }
    
    for (int i = 0; i < N; i++) {
        cout << A.at(i) << endl;
    }
}

Measured memory_bytes: 4840
#include <iostream>

using namespace std;

int main()
{
    char weather[10];
    cin >> weather;

    if(weather[0] == 'S'){
        cout << "Cloudy";
    }
    else if(weather[0] == 'C'){
        cout << "Rainy";
    }
    else{
        cout << "Sunny";
    }
    cout << endl;
}

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

int main() {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  int sum;
  if (N<=K) {
    sum = X*N;
  }
  else{
    sum = X*K + Y*(N-K);
  }
  cout << sum <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI acos(-1)
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 
const int N = 0;
 
typedef long long int ll;
 
using namespace std;


 
int main(){
    FIN;
    //freopen("../input.txt", "r", stdin);
    int s;cin>>s;
    vector<int> graph[s+1];
    fore(i,0,s-1){
        int boss;cin>>boss;
        graph[boss].pb(i);
    }

    fore(i,1,s+1){
        cout<<graph[i].size()<<"\n";
    }

    return 0;
}

// ============== Notes =============== //
// common bugs
// - remove reader 
// - fastio
// - int overflow (especially intermediate expressionns)
// - array bounds (indices bigger than MAXN?, is MAXN correct?)
// - special cases (n=1, graph not connected?)
// - re-initialize efficiently between test cases

Measured memory_bytes: 14528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )
#define SORT(x) sort(x.begin(), x.end())

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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; }


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

    ll N, x; cin >> N >> x;
    vector<ll> a(N + 1);
    ll ans = 0;
    rep(i, N) {
        cin >> a[i];
        if(a[i] > x) { ans += a[i] - x; a[i] = x; }
    }
    for (int i = 0; i < N - 1; i++) {
        if (a[i] + a[i + 1] > x) {
            ll k = a[i] + a[i + 1] - x;
            ans += k;
            a[i + 1] -= k; 
        }
    }
    COUT(ans);
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <iomanip>
#include <cstring>
#include <climits>
#include <cstdio>

#define nl '\n'

using namespace std;

int n, r;

int main(){

    cin >> n >> r;

    if(n >= 10){
        cout << r;
    } else{
        cout << r + (100*(10-n));
    }





    
}
 
//g++ -std=c++14 comp.cpp -o c && c.exe
//g++ -std=c++14 comp.cpp -o c; ./c.exe
//g++ -std=c++14 comp.cpp && ./a.out


//Surely this is going to AC

Measured memory_bytes: 256
a=input()
flag = 0
for i in range(len(a)-1):
  if flag == 0:
    if a[i]==a[i+1]:
      print("{0} {1}".format(i+1,i+2))
      flag = 1
    elif i+2!=len(a) and a[i]==a[i+2]:
      print("{0} {1}".format(i+1,i+3))
      flag = 1
if flag == 0:
  print("-1 -1")

Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
    char A[105], B[105], C[105];
    scanf("%s %s %s", A, B, C);
    int a = ((int)strlen(A))-1;
    int b = ((int)strlen(B))-1;

    if (A[a] == B[0] && B[b] == C[0]) {
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
using namespace std;
#pragma warning(disable : 4996)
vector<int> d1, d2;
vector<vector<int>> g;
void dfs(int v, int p = -1, int d = 0) {
	d1[v] = d;
	for (auto i : g[v]) {
		if (i != p) {
			dfs(i, v, d + 1);
		}
	}
}


void dfs1(int v, int p = -1, int d = 0) {
	d2[v] = d;
	for (auto i : g[v]) {
		if (i != p) {
			dfs1(i, v, d + 1);
		}
	}
}

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, a, b;
	cin >> n;
	cin >> a >> b;
	a--; b--;
	d1.resize(n);
	d2.resize(n);
	g.resize(n);
	for (int i = 0; i < n - 1; i++) {
		int from, to;
		cin >> from >> to;
		from--; to--;
		g[from].push_back(to);
		g[to].push_back(from);
	}
	dfs(a);
	dfs1(b);
	int best = -1;
	for (int i = 0; i < n; i++) {
		if (d1[i] < d2[i]) {
			best = max(best, d2[i]);
		}
	}
	cout << best - 1;
}

Measured memory_bytes: 10368
S = input()
s = S[0]
ans = 0
def dfs(n,S,s):
    global ans
    s_0 = s + "+" + S[n]
    s_1 = s + S[n]
    if n == len(S) - 1:
        ans += eval(s_0) + eval(s_1)
    else:
        dfs(n+1,S,s_0)
        dfs(n+1,S,s_1)
if len(S) == 1:
    print(int(S))
else:
    dfs(1,S,s)
    print(ans)
        

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

int kansuu(int a, int b)
{
	int tempa = max(a, b);
	int tempb = min(a, b);
	if (tempa % tempb == 0) {
		return tempb;
	} else {
		return kansuu(tempb, tempa % tempb);
	}
}

int gcd(int a, int b, int c)
{
	return kansuu(kansuu(a, b), c);
}

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

	int ans = 0;
	for (int i = 1; i <= k; i++) {
		for (int j = 1; j <= k; j++) {
			for (int l = 1; l <= k; l++) {
				ans += gcd(i, j, l);
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  
  int N;
  while(cin >> N && N) {
    int lunch_cnt = 0, dinner_cnt = 0, midnight_cnt = 0;
    int lok = 0, dok = 0, mok = 0;
    for(int i=0; i<N; i++) {
      int h, m, mm; char colon;
      cin >> h >> colon >> m >> mm;
      if(h < 2) { h+=24; }
      if(m > mm) { mm+=60; }

      if(11 <= h && h < 15) {
        lunch_cnt ++;
        if(mm-m <= 8) { lok ++; }
      }
      else if(18 <= h && h < 21) {
        dinner_cnt ++;
        if(mm-m <= 8) { dok ++; }
      }
      else if(21 <= h && h < 26) {
        midnight_cnt ++;
        if(mm-m <= 8) { mok ++; }
      }
    }
    
    cout << "lunch ";
    if(lunch_cnt) { cout << 100*lok/lunch_cnt << endl; }
    else cout << "no guest\n";
    cout << "dinner ";
    if(dinner_cnt) { cout << 100*dok/dinner_cnt << endl; }
    else cout << "no guest\n";
    cout << "midnight ";
    if(midnight_cnt) { cout << 100*mok/midnight_cnt << endl; }
    else cout << "no guest\n";
  }
  
  return 0;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

int q;

multiset<ll, greater<ll>> med1;
multiset<ll> med2;
ll total1 = 0, total2 = 0;

ll med() {
  return *med1.begin();
}

void ins(ll v) {
  if (*med1.begin() >= v) {
    med1.insert(v);
    total1 += v;
  } else {
    med2.insert(v);
    total2 += v;
  }

  if (med1.size() > med2.size()+1) {
    auto it = med1.begin();
    total1 -= *it;
    total2 += *it;
    med2.insert(*it);
    med1.erase(it);
  }

  if (med1.size() < med2.size()) {
    auto it = med2.begin();
    total1 += *it;
    total2 -= *it;
    med1.insert(*it);
    med2.erase(it);
  }
}

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> q;

  int v;
  ll a,b;
  cin >> v >> a >> b;
  q--;

  assert(v == 1);

  ins(a);

  ll bs = b;

  while (q--) {
    cin >> v;
    if (v == 1) {
      cin >> a >> b;
      bs += b;

      ins(a);

    } else {
      ll m = med();
      printf("%lld %lld\n", m, m*(ll)med1.size() - total1 + total2 - m*(ll)med2.size() + bs);
    }
  }

  return 0;
}


Measured memory_bytes: 9600
h, w = (int(x) for x in input().split())
s = []
for _ in range(h): s.append(input())
s_num = [[0 for _ in range(w)] for _ in range(h)]
d = [-1, 0, 1]
for i in range(h):
    for j in range(w):
        if s[i][j] == "#": continue
        else:
            c = 0
            for h_i in d:
                if i + h_i == -1 or i + h_i == h: continue
                else:
                    for w_i in d:
                        if j + w_i == -1 or j + w_i == w or (h_i == 0 and w_i == 0): continue
                        if s[i+h_i][j+w_i] == "#": c += 1
            s_num[i][j] = "{}".format(c)
for h_i in range(h):
    for w_i in range(w):
        if s[h_i][w_i] == "#": s_num[h_i][w_i] = "#"
        else: continue
for i in range(h): print("".join(s_num[i]))

Measured memory_bytes: 3064
str = gets.chomp
gets.to_i.times do
  com, a, b, w = gets.chomp.split
  a = a.to_i
  b = b.to_i
  case com
  when 'replace'
    str[a..b] = w
  when 'reverse'
    str[a..b] = str[a..b].reverse
  when 'print'
    puts str[a..b]
  end
end

Measured memory_bytes: 6148
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int n; vector<int> a;

int main(void){
	int input;

	scanf("%d", &n);
	for( int i = 0 ; i < n ; i++ ){
		scanf("%d", &input);
		a.push_back(input);
	}

	reverse(a.begin(), a.end());

	for( int i = 0 ; i < n ; i++){
		printf("%d", a[i]);
		if( i == n - 1) printf("\n");
		else printf(" ");
	}

	return 0;
}

Measured memory_bytes: 2788
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;



int main(){
	string S;
	cin >> S;
	string T;
	cin >> T;
	ll counter=0;
	for(ll i=0;i<3;i++){
		if(S[i]==T[i])counter++;
	;}
	cout<<counter<<endl;
return 0;
}  



Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	char A[15], B[15], C[15];
	scanf("%s %s %s", A, B, C);

	char *FirstB = B;
	char FirstB2 = FirstB[0];
	char *FirstC = C;
	char FirstC2 = FirstC[0];

	char *LastA = A;
	char LastA2;
	for (int i = 0;LastA[i] != '\0';i++)
	{
		LastA2 = LastA[i];
	}
	char *LastB = B;
	char LastB2;
	for (int h = 0;LastB[h] != '\0';h++)
	{
		LastB2 = LastB[h];
	}

	if (LastA2 == FirstB2 && LastB2 == FirstC2)
	{
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N, Q;
  string S;
  cin >>  N >> Q >> S;
  vector <int> l(Q), r(Q);
  rep(i,Q) cin >> l[i] >> r[i];
  vector <int> sum(N + 1);
  //一つ左にずらした累積和
  for (int i = 1; i < N; i++){
    if (S[i - 1] == 'A' && S[i] == 'C'){
      sum[i + 1] = sum[i] + 1;
    }else{
      sum[i + 1] = sum[i];
    }
  }
  rep(i,Q){
    int ans = sum[r[i]] - sum[l[i]];
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 4580
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  ll a[LIMIT2]={0};
  int aCount=0;
  
  scanf("%lld",&n);
  for(i=1;i<=min(9,n);i++){
    a[aCount]=i;
    aCount++;
  }
  j=0;
  for(i=10;i<=n;i++){
    if(a[j]%10!=0){
      a[aCount]=a[j]*10+a[j]%10-1;
      aCount++;
    }
    a[aCount]=a[j]*10+a[j]%10;
    aCount++;
    if(a[j]%10!=9){
      a[aCount]=a[j]*10+a[j]%10+1;
      aCount++;
    }
    j++;
  }
  printf("%lld",a[n-1]);
  return 0;
}



Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll a[100005];
ll sum,zz;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i],sum+=a[i];
	for(int i=2;i<=n;i+=2)
	zz+=a[i];
	ll a1=sum-2*zz;
	cout<<a1<<" ";
	ll cur=a1/2;
	for(int i=2;i<=n;i++)
	{
		ll aa=a[i-1]-cur;
		cout<<2*aa<<" ";
		cur=aa;
	}
	cout<<endl;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n,r;cin>>n>>r;
    if(n>=10){
        cout<<r<<endl;
    }else{
        cout<<r+100*(10-n)<<endl;
    }
    return 0;
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<P> vp;
typedef vector<ll> vll;


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

    string s;
    cin >> s;
    string pre_s;
    while (s != pre_s) {
        pre_s = s;
        rep(i, s.size() - 2) {
            if (s.substr(i, 3) == "mew") {
                bool flag1 = false;
                bool flag2 = false;
                bool flag3 = false;
                rep(j, i) {
                    if (s[j] == 'm') flag1 = true;
                    if (s[j] == 'e') flag2 = true;
                }
                rep2(j, i + 3, s.size()) {
                    if (s[j] == 'e') flag2 = true;
                    if (s[j] == 'w') flag3 = true;
                }
                if (flag1 && flag2 && flag3) {
                    s.replace(i, 3, "");
                    break;
                }
            }
        }
    }

    if (s == "" || s == "mew") {
        cout << "Cat" << endl;
    } else {
        cout << "Rabbit" << endl;
    }

}

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

using namespace std;
typedef long long ll;

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

    vector<int> p(n);
    for(int i=0; i < n; i++) cin >> p[i];
    sort(p.begin(), p.end());

    int sum = 0;
    for(int i=0; i < n-1; i++) {
        sum += p[i];
    }

    sum += p[n-1]/2;

    cout << sum;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int a[100000],b[100000];
int main() {
	int n, t, i, ans = 1;
	scanf("%d%d", &n, &t);
	for (i = 0; i < n; i++) scanf("%d", &a[i]);
	b[n - 1] = a[n - 1];
	for (i = n - 2; i >= 0; i--) b[i] = a[i] > b[i + 1] ? a[i] : b[i + 1];
	for (i = 0; i < n; i++)b[i] -= a[i];
	std::sort(b, b + n);
	for (i = n - 2; i >= 0 && b[i] == b[i + 1]; i--)ans++;
	printf("%d", ans);
	return 0;
}

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

typedef long long ll;
const int N = 1e5 + 100;

int a, b;
string s;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> s;
	for (int i = 0; i < s.length(); i++)
		a += (s[i] - '0') ^ (i & 1), b += !((s[i] - '0') ^ (i & 1));
	cout << min(a, b);
	return 0;
}

Measured memory_bytes: 512
A,B,M = [int(x) for x in input().split()]
A_list = [int(x) for x in input().split()]
B_list = [int(y) for y in input().split()]
discount = []
min = 1000000
for _ in range(M):
  case = [int(x) for x in input().split()]
  discount.append(case)
 
min_a = sorted(A_list)[0]
min_b = sorted(B_list)[0]
 
for i in range(M):
  temp = A_list[discount[i][0]-1] + B_list[discount[i][1]-1] - discount[i][2]
  if temp < min:
    min = temp
    
if min_a + min_b > min:
  print(min)
else:
  print(min_a + min_b)

Measured memory_bytes: 33772
N = int(input())
X = list(map(int, input().split()))
tmp = X[:]
tmp.sort()
mid = N // 2 - 1
low = tmp[mid]
high = tmp[mid + 1]
all = sum(tmp)
for a in X:
    if a <= low:
        print(high)
    else:
        print(low)

Measured memory_bytes: 93908
N = int(input())
lista = []
for n in range(N):
    sn = sorted(list(input()))
    #print(sn)
    lista.append(sn)
listaa = sorted(lista)    
ans = 0
count = 0
for a in range(1,N):
    if listaa[a] == listaa[a-1]:
        count += 1
        ans = ans + count
    else:
        count = 0
print(ans)        

Measured memory_bytes: 25420
NIL = -1

class Node:
    def __init__(self, parent=NIL, left=NIL, right=NIL):
        self.parent = parent
        self.left = left
        self.right = right


def preParse(tree, u):
    if u == NIL:
        return
    print(' %d' % u, end='')
    preParse(tree, tree[u].left)
    preParse(tree, tree[u].right)


def inParse(tree, u):
    if u == NIL:
        return
    inParse(tree, tree[u].left)
    print(' %d' % u, end='') 
    inParse(tree, tree[u].right)


def postParse(tree, u):
    if u == NIL:
        return
    postParse(tree, tree[u].left)
    postParse(tree, tree[u].right)
    print(' %d' % u, end='') 


n = int(input())
tree = [Node() for i in range(n)]

for i in range(n):
    value, left, right = [int(v) for v in input().split()]
    tree[value].left = left
    tree[value].right = right
    if left != NIL:
        tree[left].parent = value
    if right != NIL:
        tree[right].parent = value

root = 0
for i in range(n):
    if tree[i].parent == NIL:
        root = i
        break

print('Preorder')
preParse(tree, root)
print()
print('Inorder')
inParse(tree, root)
print()
print('Postorder')
postParse(tree, root)
print()


Measured memory_bytes: 5616
#include<iostream>
using namespace std;
int main()
{
    
    string n,a;
    cin >> n;
    if(n=="Sunny"){
        a="Cloudy";
    }else if(n=="Cloudy"){
        a="Rainy";
    }else if(n=="Rainy"){
        a="Sunny";
    }

    cout << a;
}

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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e3 + 10;

int N, M, Vis[MAX_N][MAX_N], Re[MAX_N][MAX_N];
vector<int> Ed[MAX_N];
vector<pi> EdList;
void getVis() {
	for(int st=1; st<=N; st++) {
		queue<int> Q; int *vis = Vis[st];
		Q.emplace(st); vis[st] = true;
		while(!Q.empty()) {
			int v = Q.front(); Q.pop();
			for(int w : Ed[v]) if(not vis[w]) vis[w] = true, Q.emplace(w);
		}
	}
}
int Val[2][MAX_N][MAX_N];
void dfs(int v, int st, int ix, int* val, function<int(int, int)> f) {
	if(v == st) return;
	if(val[v] == ix or f(val[v], ix) != ix) return;
	val[v] = ix;
	for(int w : Ed[v]) dfs(w, st, ix, val, f);
}
void getMnMx() {
	int base[2] = {INF, -INF};
	function<int(int, int)> func[2] = {[](int a, int b) {return min(a, b);}, [](int a, int b) {return max(a, b);}};
	for(int k=0; k<2; k++) for(int st=1; st<=N; st++) {
		int *val = Val[k][st];
		for(int i=1; i<=N; i++) val[i] = base[k];
		for(int w : Ed[st]) dfs(w, st, Re[st][w], val, func[k]);
		//for(int w : Ed[st]) printf("%d -> %d : %d\n", st, w, val[w]);
		reverse(ALL(Ed[st]));
	}
}
bool canGo(int x, int y) {return Val[0][x][y] != Re[x][y] or Val[1][x][y] != Re[x][y];}
int main() {
	cin >> N >> M;
	for(int i=0; i<M; i++) {
		int x, y; scanf("%d%d", &x, &y);
		Re[x][y] = SZ(Ed[x]);
		Ed[x].emplace_back(y);
		EdList.emplace_back(x, y);
	}
	getVis();
	getMnMx();
	for(int i=0; i<M; i++) {
		int x, y; tie(x, y) = EdList[i];
		//printf("[%d %d] : ", Vis[y][x], canGo(x, y));
		puts(((Vis[y][x]) ^ (canGo(x, y))) ? "diff" : "same");
	}
	return 0;
}


Measured memory_bytes: 20464
#include <bits/stdc++.h>
using namespace std;
#define repr(i,k,n) for(int i = (k); i < (n); i++)
#define rep(i,n) repr(i,0,n)
#define ALL(a) begin(a),end(a)
const int INF = 114514810;
const int MOD = 1000000007;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,s,cnt=0,mi=100;
	cin >> N ;
	rep(i,N){
		cin>>s;
		cnt+=s;
		if (mi>s&&s%10!=0){
			mi=s;
		}
	}
	if (cnt%10!=0){
		cout << cnt << endl;
	}else if(cnt-mi>=0&&(cnt-mi)%10!=0){
		cout << cnt-mi << endl;
	}else {
    	cout << '0' << endl;
    }
}

Measured memory_bytes: 256
import sys
import heapq
import bisect
import itertools

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def LI_(): return([int(x)-1 for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])

def GCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def LCM(a,b):
    return a * b // GCD(a,b)

def Eratosthenes(N):
    r = [True]*(N+1)
    r[0] = False
    r[1] = False
    i = 2
    while i*i<=N:
        if r[i]: 
            j = i
            while i*j<=N:
                prime[i*j]=False
                j+=1
        i+=1
    return(r)

def main():
    N,M = LI()
    ll = [[] for _ in range(N)]
    dic = {}
    for i in range(N):
        KL = LI()
        ll[i] = [j-1 for j in KL[1:]]
        for l in KL[1:]:
            dic[l-1] = dic.get(l-1,[])
            dic[l-1].append(i)

    flagk = [True] * N
    flagl = {}
    for l in dic:
        flagl[l] = True

    que = [0]
    while que:
        k = que.pop()
        if flagk[k]:
            flagk[k] = False
            for l in ll[k]:
                if flagl[l]:
                    flagl[l] = False
                    for nxt in dic[l]:
                        if flagk[nxt]:
                            que.append(nxt)
    for x in flagk:
        if x:
            return("NO")
    return("YES")



if __name__ == "__main__":
    print(main())


Measured memory_bytes: 71152
//This is the Property of Rishabh Agarwal
#include <bits/stdc++.h>
#define F first
#define S second
#define MAX 10000003
using namespace std;
 
typedef long long int ll;
const ll mod =998244353;
ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll temp=power(a,b/2)%mod;
    if(b%2==0){
        return (temp*temp)%mod;
    }
    else{
        return ((a*temp)%mod*temp)%mod;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,k;
    cin>>n>>m>>k;
    ll ans=0;
    ans+=((m%mod)*(power(m-1,n-1)%mod))%mod;
    ans%=mod;
    ll count = 1;
    for(ll x=1; x<=k; x++){
        count= ((count*(n-x))%mod * power(x,mod-2)%mod )%mod;
        count%=mod;
        //cout<<count<<" ";
        ans+=((((count%mod)*(m%mod))%mod)*(power(m-1,n-1-x)%mod))%mod;
        ans%=mod;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3696
from bisect import bisect_left, bisect_right, insort_left
q = int(input())
M = {}
tbl = []
for i in range(q):
    query, *x = input().split()
    if query == "0":
        x[1] = int(x[1])
        if x[0] not in M:
            insort_left(tbl, x[0])
        M[x[0]] = x[1]
    elif query == "1":
        print(M[x[0]] if x[0] in M and M[x[0]] != 0 else 0)
    elif query == "2":
        M[x[0]] = 0
    else:
        L = bisect_left( tbl, x[0])
        R = bisect_right(tbl, x[1])
        for i in range(L, R):
            if M[tbl[i]] != 0:
                print(tbl[i], M[tbl[i]])


Measured memory_bytes: 38788
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
    
int dple[3010][3010];
int dpri[3010][3010];
int main(){
	int n,t;
    cin>>n>>t;
    vector<int> tim(n);
    vector<int> val(n);
    REP(i,n){
        cin>>tim[i]>>val[i];
        dple[0][i]=0;
        dpri[n][i]=0;
    }
    REP(i,n){
        REP(j,t-1){
            if(j-tim[i]<0){
                dple[i+1][j]=dple[i][j];
            }else{
                dple[i+1][j]=max(dple[i][j],dple[i][j-tim[i]]+val[i]);
            }
        }
    }
    for(int i=n;i>0;i--){
        REP(j,t-1){
            if(j-tim[i-1]<0){
                dpri[i-1][j]=dpri[i][j];
            }else{
                dpri[i-1][j]=max(dpri[i][j],dpri[i][j-tim[i-1]]+val[i-1]);
            }
        }
    }
    int ans=0;
    int tmp=0;
    for(int i=0;i<n;i++){
        REP(j,t){
            tmp=max(tmp,dple[i][j]+dpri[i+1][t-1-j]);
        }
        ans=max(ans,tmp+val[i]);
        tmp=0;
    }
    OUT(ans);
	return 0;
}

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

using namespace std;

#define rep(i, a, n) for (int i = a, _n = n; i <= _n; ++i)
#define drep(i, a, n) for (int i = a, _n = n; i >= _n; --i)
#define debug(x) cout << #x << " = " << x << endl

char s[5];
bool mark[26];
int main () {
	scanf ("%s", s);
	int ans = 0;
	rep(i, 0, 3) {
		if (!mark[s[i] - 'A']) {
			mark[s[i] - 'A'] = 1;
			++ans;
		}
	}
	if (ans == 2) puts("Yes");
	else puts("No");
	return 0;
}


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

#define rep(i,n) for(int i=0;i<n;++i)
typedef vector<int> vi;

int main(){
    int n;
    cin>>n;
    vi a(n);
    bool b=true;
    rep(i,n){
        cin>>a[i];
        if(a[i]%2==0){
            if(a[i]%3!=0&&a[i]%5!=0){
                b=false;break;
            }
        }
    }
    if(b)cout<<"APPROVED";
    else cout<<"DENIED";
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

vector<pii> ans;

void mainmain(){
	int n;
	cin>>n;
	vll v(n);
	rep(i,n) cin>>v[i];
	pii mx(-INF,-1);
	pii mn(INF,-1);
	rep(i,n){
		maxs(mx, pii(v[i],i));
		mins(mn, pii(v[i],i));
	}
	if(abs(mx.fi) >= abs(mn.fi)){
		ans.PB(pii(mx.se, 0));
		ans.PB(pii(mx.se, 0));
		rep(i,1,n){
			ans.PB(pii(i-1,i));
			ans.PB(pii(i-1,i));
		}
	}
	else{
		ans.PB(pii(mn.se, n-1));
		ans.PB(pii(mn.se, n-1));
		for(int i=n-2; i>=0; i--){
			ans.PB(pii(i+1, i));
			ans.PB(pii(i+1, i));
		}
	}
	cout<<ans.size()<<endl;
	rep(i,ans.size()){
		cout<<ans[i].fi+1<<" "<<ans[i].se+1<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int g,i, n,sa, a[9];
	while (1)
	{
		g = 0;
		scanf("%d", &n);
		if (n == 0)
		{
			break;
		}
		for (i = 0; i < 9; i++)
		{
			scanf("%d", &a[i]);
			g = g + a[i];
		}
		sa = n - g;
		printf("%d\n", sa);
	}
	return 0;
}

Measured memory_bytes: 1752
#include <iostream>
#include <string>

int main()
{
	int a,b;
	std::string op;
	
	std::cin >> a >> op >> b;

	while (op != "?") {

		if (op == "+") {
			std::cout << a + b << std::endl;
		}
		else if (op == "-") {
			std::cout << a - b << std::endl;
		}
		else if (op == "*") {
			std::cout << a*b << std::endl;
		}
		else {
			std::cout << a / b << std::endl;
		}

		std::cin >> a >> op >> b;
	}
}

Measured memory_bytes: 1204
#include <iostream>
#include <queue>
#include <string>
#include <sstream>

using namespace std;

int main(){
	queue<int> qu;
	int m,n,flag = 0;
	while(1){
		cin >> m >> n;
		if(!m && !n) break;
		for(int i = 1;i <= m;i++) qu.push(i);
		for(int i = 1;i <= n;i++){
			string s;
			cin >> s;
			if(qu.size() == 1) continue;
			if(i % 3 == 0){
				if(i % 5 == 0){
					if(s != "FizzBuzz") flag = 1;
				}else{
					if(s != "Fizz") flag = 1;
				}
			}
			else if(i % 5 == 0){
				if(s != "Buzz") flag = 1;
			}
			else{
				int n;
				stringstream ss;
				ss << s;
				ss >> n;
				if(n != i) flag = 1; 
			}
			int p = qu.front();
			qu.pop();
			if(!flag) qu.push(p);
			flag = 0;
		}
		priority_queue<int,vector<int>,greater<int> > pqu;
		for(;!qu.empty();) {
			pqu.push(qu.front());
			qu.pop();
		}
		if(!pqu.empty()) {
			cout << pqu.top();
			pqu.pop();
		}
		for(;!pqu.empty();){
			cout << " " << pqu.top();
			pqu.pop();
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long int64;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int oo = 0x3f3f3f3f;
const double pi = acos(-1);
const double eps = 1e-9;

#define endl '\n'

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

	int64 n, a, b;
	cin >> n >> a >> b;

	int64 c = a + b;

	int64 ans = (n / c) * a;
	int64 rest = n % c;
	ans += min(rest, a);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    int[] a = Stream.of(sc.nextLine().split("\\s")).mapToInt(Integer::parseInt).toArray();
    sc.close();
    String[] result = new String[n];
    for (int i = 0; i < n; i++) {
      result[a[i] - 1] = String.valueOf(i + 1);
    }
    System.out.println(String.join(" ", result));
  }
}

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

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;

typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

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

int N, C;
int x[100001], c[100001];
int Rsum[100001], Lsum[100001];
int dp[2][100001];

signed main() {
	cin >> N >> C;
	for(int i = 0; i < N; ++i) {
		cin >> x[i] >> c[i];
	}
	int res = 0;
	for(int i = 0; i < N; ++i) {
		Rsum[i + 1] = Rsum[i] + c[i];
		Lsum[i + 1] = Lsum[i] + c[N - 1 - i];
	}
	for(int i = 1; i < N + 1; ++i) {
		chmax(res, Rsum[i] - x[i - 1]);
		chmax(res, Lsum[i] - (C - x[N - i]));
	}
	for(int i = 1; i < N + 1; ++i) {
		dp[0][i] = max(dp[0][i - 1], Lsum[i] - (C - x[N - i]));
		dp[1][i] = max(dp[1][i - 1], Rsum[i] - x[i - 1]);
	}
	for(int i = 1; i < N + 1; ++i) {
		chmax(res, Rsum[i] - x[i - 1] * 2 + dp[0][N - i]);
		chmax(res, Lsum[i] - (C - x[N - i]) * 2 + dp[1][N - i]);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int n; cin >> n;
    for(int i = 1; i <= n; i+=1){
        if((int)(i * 1.08) == n){
            cout << i << endl; return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

#define MAX 5005

// 最悪の記者

vector<int> G[MAX];
vector<int> out;
bool V[MAX];
int n;
char c[MAX][MAX];

void dfs(int u){
  V[u]=true;
  for(int i=0; i<G[u].size(); i++){
    int v=G[u][i];
    if(!V[v]) dfs(v);
  }
  out.insert(out.begin(), u);
}

signed main(){
  int s,t,m;
  cin>>n>>m;
  for(int i=1; i<=n; i++) V[i]=false;
  for(int i=0; i<m; i++){
    cin>>s>>t;
    G[s].push_back(t);
    c[s][t]=1;
  }
  
  for(int i=1; i<=n; i++){
    if(!V[i]) dfs(i);
  }
  
  bool ok=true;
  for(vector<int>::iterator ite=out.begin(); ite!=out.end(); ite++) {
    cout<<*ite<<en;
    if(ite!=out.end()-1)
      if(c[*ite][*(ite+1)]!=1&&ite!=out.end()-1) ok=false;
  }
  if(ok) cout<<0<<en;
  else cout<<1<<en;
}


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

int main(){
  int n;
  string str;
  char one[] = {'.',',','!','?',' '};
  int xxx[10] = {0,5,3,3,3,3,3,4,3,4};
  int yyy[10] = {0,0,0,3,6,9,12,15,19,22};
  cin >> n;
  while(n--){
    vector<char> msg;
    vector<int> msg_n;
    cin >> str;
    char curr = str[0];
    int num = 1;
    for(int i=1; i<str.size(); i++){
      if(str[i] == curr)
	num++;
      else{
	if(str[i-1] != '0'){
	  msg.push_back(str[i-1]);
	  msg_n.push_back(num);
	}
	num = 1;
	curr = str[i];
      }
    }
    if(curr != '0'){
      msg.push_back(curr);
      msg_n.push_back(num);
    }
    int pos, pres;
    for(int i=0; i<msg.size(); i++){
      if(msg[i] == '1')
	cout << one[(msg_n[i]+4)%5];
      else{
	pos = msg[i] - '0';
	pres = yyy[pos] + ((msg_n[i]+xxx[pos]-1) % xxx[pos]) + 'a';
	char ttt = pres;
	cout << ttt;
      }
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	string w;
	cin >> w;

	vector<char> c{ 'a','b','c','d','e','f','g','h','i','j','k',
		'l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

	bool ans = true;

	for (char i : c) {
		int che = count(w.begin(), w.end(), i);
		if (che % 2 != 0) { 
			ans = false;
			break;
		}
	}

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

}

Measured memory_bytes: 3620
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647

long long llpow(long long x, long long n) {
    long long ans = 1;
    if (n == 0)return 1;
    while (n != 0) {
        if (n & 1) ans = ans * x;
        x = x * x;
        n = n >> 1;
    }
    return ans;
}


int main() {
	long long N, X;
	cin >> N >> X;
    long long an = 8 * llpow(2, N - 1) - 3;
    
    long long countPutty = 0;
    while(1) {

        if (N == 1) {
            switch (X) {
            case 1:
                countPutty += 0;
                break;
            case 2:
                countPutty += 1;
                break;
            case 3:
                countPutty += 2;
                break;
            case 4:
                countPutty += 3;
                break;
            case 5:
                countPutty += 3;
                break;
            }
            break;
        }
        an = 8 * llpow(2, N - 1) - 3;
        --N;

        if ((an + 1) / 2 == X) {
            long long prean = 8 * llpow(2, N - 1) - 3;
            countPutty += (prean + 1) / 2 + 1;
            break;
        }
        else if (an == X) {
            countPutty += (an + 1) / 2;
            break;
        }
        else if ((an + 1) / 2 < X) {
            X -= (an + 1) / 2;
            long long prean = 8 * llpow(2, N - 1) - 3;
            countPutty += (prean + 1) / 2 + 1;
        }
        else {
            --X;
        }
    }

    cout << countPutty << endl;
	return 0;
}

Measured memory_bytes: 256
"""
author : halo2halo
date : 23, Jan, 2020
"""

import sys

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

R = int(readline())
print('ABC' if R < 1200 else 'ARC' if R < 2800 else 'AGC')


Measured memory_bytes: 2940
import sys


def resolve():
    sys.setrecursionlimit(10 ** 6)
    readline = sys.stdin.readline
    
    def rec(v: int):
        """メモ化再帰"""
        if dp[v] != -1:
            return dp[v]
        res = 0
        for nv in G[v]:
            res = max(res, rec(nv) + 1)
        dp[v] = res
        return dp[v]

    N, M = map(int, readline().split())
    G = [[] for _ in [0] * N]
    for _ in [0] * M:
        x, y = map(int, readline().split())
        G[x - 1].append(y - 1)

    # メモ化再帰
    dp = [-1] * N
    res = 0
    for v in range(N):
        res = max(res, rec(v))
    print(res)


resolve()


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

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

  sort(s.begin(), s.end());
  sort(t.begin(), t.end());

  for(int i = 0; i < s.size(); i++){
    for(int j = t.size() - 1; j >= 0; j--){
      if(s[i] < t[j]){
        cout << "Yes" << endl;
        return 0;
      }else if(s[i] > t[j]){
        cout << "No" << endl;
        return 0;
      }
    }
  }

  if(s.size() < t.size()){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  

  return 0;
}

Measured memory_bytes: 256
program answer
      implicit none
      character(len=6) :: S
      read(*,*) S
      if( S == 'Sunny') write(*,'(A)') 'Cloudy'
      if( S == 'Cloudy') write(*,'(A)') 'Rainy'
      if( S == 'Rainy') write(*,'(A)') 'Sunny'
      stop
      end program answer

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;


ll ans, cnt;

// 最大公約数のll版
ll gcd(ll a, ll b) {
	if (a < b) swap(a, b);
	return b == 0 ? a : gcd(b, a%b);
}


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

	ll N;
	cin >> N;

	vector<ll> A(N);
	rep(i, N) {
		ll a;
		cin >> a;
		if (i == 0) ans = a;
		else{
			ans = gcd(ans,a);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N = int(input())
    S = input()
    ans = ""
    for c in S:
        v = ord(c) - ord("A")
        ans += chr(ord("A") + ((v + N) % 26))
    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 10012
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
void marmot0814() {
    int n, W; cin >> n >> W;
    vector<LL> dp(W + 1, 0);
    while (n--) {
        LL w, v; cin >> w >> v;
        for (int i = W ; i >= w ; i--)
            dp[i] = max(dp[i], dp[i - w] + v);
    }
    cout << *max_element(dp.begin(), dp.end()) << '\n';
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t = 1, kase = 0; // cin >> t;
    while (t--) {
        // cout << "Case #" << ++kase << ":";
        marmot0814();
    }
}

Measured memory_bytes: 3980
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int sumdigit(int x){
    int count =0;
    while(x>0){
        count +=x%10;
        x /=10;
    }
    return count;
}

int main() {
    int N;
    cin>>N;
    int a =sumdigit(N);
    if(N%a ==0)cout <<"Yes"<<endl;
    else cout <<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int n;
    int ans=INF;
    cin>>n;
    rep(i,1,n){
        int x=i,y=n-i;
        int anss=0;
        while(x>0){
            anss+=x%10;
            x/=10;
        }

        while(y>0){
            anss+=y%10;
            y/=10;
        }
        ans=min(ans,anss);
    }
    cout<<ans<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [[]] + [list(map(int, input().split())) for _ in range(N)]

c = [0 for _ in range(N + 1)]
p = []
for i in range(1, N + 1):
    j = A[i][c[i]]
    if i == A[j][c[j]] and i < j:
        p.append((i, j))
ans = 0
while p:
    # print(p)
    q = []
    for i, j in p:
        c[i] += 1
        c[j] += 1
        if c[i] < N - 1:
            k = A[i][c[i]]
            if A[k][c[k]] == i:
                q.append((i, k))
        if c[j] < N - 1:
            k = A[j][c[j]]
            if A[k][c[k]] == j:
                q.append((j, k))
    ans += 1
    p = q

ans = (
    ans if all(c[i] == N - 1 for i in range(1, N + 1)) else
    -1
)
print(ans)


Measured memory_bytes: 55772
#include <iostream>
#define MAX 500
using namespace std;

int n, q;
int A[MAX], M;

//處理 
bool solve(int p, int t)
{
	if (p == n+1) return false;
	if (t == A[p]) return true;
	return solve(p+1, t) || solve(p+1, t-A[p]);
}

int main ()
{
	//輸入 
	cin >> n;
	for (int i = 0;i < n;i++)
	{
		cin >> A[i];
	}
	cin >> q;
	
	while(q--)
	{
		cin >> M;
		
		//輸出 
		if (solve(0,M))
		{
			cout << "yes\n";
		}
		else
		{
			cout << "no\n";
		}
	}
	return 0;
 } 


Measured memory_bytes: 3104
#include<stdio.h>

int main(void){

    long long int N,A,B,ans;

    scanf("%lld %lld %lld",&N,&A,&B);

    if((B-A)%2 == 0){
        ans = (B-A)/2;
    }else{
        if((B-A) < 3) ((N-A) < (B-1)) ? (ans = N-A) : (ans = B-1);
        else{
            if((A-1) < (N-B)) ans = A+(B-A-1)/2;
            else ans = (N-B)+1+(N-(A+(N-B)+1))/2;
        }
    }

    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128