akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

int K;
string s;

int main () {
        cin >> s >> K;
        for (char& c : s) {
                if (c != 'a' && 'z' - c + 1 <= K) {
                        K -= 'z' - c + 1;
                        c = 'a';
                }
        }
        K %= 26;
        fo(i, 0, K) {
                if (s.back() == 'z') s.back() = 'a';
                else s.back()++;
        }
        cout << s << endl;
        return 0;
}


Measured memory_bytes: 512
T = input()
T = "S" + T + "S"

T_list = []
for i in range(len(T)):
    T_list.append(T[i])

for i in range(1,len(T_list)):
    
    if T[i] == "?" :
        if T[i-1] == "P":
            T_list[i] = "D"
        elif T[i+1] == "P":
            T_list[i] = "D"
        elif T[i+1] == "D":
            T_list[i] = "P"
        else:
            T_list[i] = "D"

ans = ""
for t in T_list[1:-1]:
    ans += t
print(ans)


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

#define MOD 1000000007

using namespace std;
typedef long long ll;

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

  vector<ll> x(n);
  vector<ll> y(m);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> y[i];
  }

  ll xsum = 0, xrui = x[0];
  for (int i = 1; i < n; i++) {
    xsum += (i*x[i]) % MOD; xsum %= MOD;
    xsum += (MOD - xrui)%MOD; xsum %= MOD;
    xrui += x[i]; xrui %= MOD;
  }

  ll ysum = 0, yrui = y[0];
  for (int i = 1; i < m; i++) {
    ysum += (i*y[i])%MOD; ysum %= MOD;
    ysum += (MOD - yrui)%MOD; ysum %= MOD;
    yrui += y[i]; yrui %= MOD;
  }

  cout << (xsum * ysum) % MOD << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int main(void) {
    long int input1 = 0;
    long int input2 = 0;
    scanf("%ld", &input1);
    scanf("%ld", &input2);
    long x = input1 * input2;

    if(input1<input2){
        long tmp = input1;
        input1 = input2;
        input2 = tmp;
    }

    long r = input1 % input2;
    while(r!=0){
        input1 = input2;
        input2 = r;
        r = input1 % input2;
    }
    long result = x/input2;

    printf("%ld\n", result);
    return 0;
}

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

int main(){
 int a, b, c;
 cin >> a >> b >> c;
 int i = 0;
 if(a < b){
   if(b < c){
      i = 1;
   }
 }

 if(i == 1){ cout << "Yes" << endl; }
 else{ cout << "No" << endl;}
 
}

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

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

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

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

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

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

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    vector<int> A(N+1);
    vector<int> B(N);
    for (int i = 0; i <= N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];

    int cnt = 0;

    for (int i = 0; i < N; i++) {
        int get = min(A[i], B[i]);
        cnt += get;
        B[i] -= get;

        int get2 = min(A[i+1], B[i]);
        cnt += get2;
        A[i+1] -= get2;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1792
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
 
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b;
	cin>>a>>b;
	if(a%2==b%2)cout<<(a+b)/2<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
}












Measured memory_bytes: 256
#include<stdio.h>

int main(){

	int i,j,moji[100],sum;
	char tmp[100];

	while(fgets(tmp,100,stdin)!=NULL){
		sum=0;
		i=0;
		while(tmp[i]!=10){
			if(tmp[i]=='I') moji[i]=1;
			else if(tmp[i]=='V') moji[i]=5;
			else if(tmp[i]=='X') moji[i]=10;
			else if(tmp[i]=='L') moji[i]=50;
			else if(tmp[i]=='C') moji[i]=100;
			else if(tmp[i]=='D') moji[i]=500;
			else if(tmp[i]=='M') moji[i]=1000;
			i++;
		}
		i--;
		sum=moji[i];
		for(j=i;j!=0;j--){
			if(moji[j]>moji[j-1]){
				sum+=-moji[j-1];
			}
			else if(moji[j]<=moji[j-1]){
				sum+=+moji[j-1];
			}
		}
		printf("%d\n",sum);
	}







	return 0;

}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
//#pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll n,i;
    cin>>n;
    ll a[n];
    map<ll,ll> m;
    ll ans=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        m[a[i]]++;
    }
    for(auto x:m)
        ans+=((x.S*(x.S-1))/2);
    //ll anss=ans;
    for(i=0;i<n;i++)
    {
        cout<<ans-m[a[i]]+1<<"\n";
    }
    return 0;
}


Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int ans = 0;
        int i =0;
        for(i=x; ; i++) {
            int count = 0;
            int j =1;
            for(; j<=i; j++) {
                if(i % j == 0) count++;
                if(count == 2) break;
            }
            if(j == i) {
                ans = i;
                break;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35544
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
#define REP(i, x, y) for(ll i = x; i < y; i++)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

ll b[100010];
plglg c[100010];
ll bsum[100010];
ll mark[100010];

ll bit[1000010], n;

ll sum(int i) {
    ll s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void add(int i, ll x) {
    while (i <= n) {
        bit[i] += x;
        i += i & -i;
    }
}

int main() {
    ll N;
    cin >> N;
    ll a[N];
    REP(i, 0, N) {
        cin >> a[i];
    }
    if (N == 1) {
        cout << a[0] << endl;
        return 0;
    }
    ll hi = 1e9 + 1;
    ll lo = 0;
    while (hi - lo > 1) {
        ll mid = (hi + lo) / 2;
        REP(i, 0, N) {
            if (a[i] >= mid) {
                b[i] = 1;
            } else {
                b[i] = -1;
            }
        }
        bsum[0] = b[0];
        REP(i, 1, N) {
            bsum[i] = bsum[i - 1] + b[i];
        }
        REP(i, 0, N) {
            c[i] = plglg(bsum[i], i);
        }
        sort(c, c + N);
        mark[c[0].second] = 1;
        ll tmp = 1;
        REP(i, 1, N) {
            if (c[i].first != c[i - 1].first) {
                tmp++;
            }
            mark[c[i].second] = tmp;
        }
        n = tmp + 1;
        fill(bit, bit + n + 1, 0);
        ll inv = 0;
        REP(i, 0, N) {
            inv += i - sum(mark[i]);
            add(mark[i], 1);
        }

        ll num = N * (N - 1) / 2 - inv;
        //cout << mid << " " << num << endl;
        ll pl = lower_bound(c, c + N, plglg(0, 0)) - c;
        //cout << inv << " " << pl << endl;
        if (num + (N - pl) >= (N * (N + 1) / 2 + 1) / 2) {
            lo = mid;
        } else {
            hi = mid;
        }
    }
    cout << lo << endl;
}


Measured memory_bytes: 7424
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e5;

int main(){
	lli a[7];
	rep(i,7)cin>>a[i];
	lli i=a[0],o=a[1],j=a[3],l=a[4];
	lli ans=(i/2)*2+o+(j/2)*2+(l/2)*2;
	if(i>0&&j>0&&l>0){
		lli d=((i-1)/2)*2+o+((j-1)/2)*2+((l-1)/2)*2+3;
		ans=max(ans,d);
	}
	cout<<ans;
}

Measured memory_bytes: 256
// 問題URL
// https://atcoder.jp/contests/abc152/tasks/abc152_b

import java.util.*;
import java.lang.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer x = Integer.parseInt(scanner.next());
        Integer y = Integer.parseInt(scanner.next());


        int kekka;
        String moji = new String();

        if(x > y) {
            for(int i=0; i< x; i++) {
                moji += String.valueOf(y);
            }
        } else {
            for(int i=0; i< y; i++) {
                moji += String.valueOf(x);
            }

        }

        System.out.println(moji);
    }
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ll cur = 0;
  ll l = 0;
  ll ans = 0;
  for (int r = 0; r < n; r++) {
    while (cur & a[r]) {
      cur ^= a[l];
      l++;
    }
    cur ^= a[r];
    ans += r - l + 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4836
N, W = map(int, input().split())
wv = []

for i in range(N):
    w, v = map(int, input().split())
    wv.append([w, v])

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if j - wv[i][0] >= 0:
            dp[i+1][j] = max(dp[i][j], dp[i][j-wv[i][0]]+wv[i][1])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[N][W])

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

int main() {
    int cake = 4;
    int donut = 7;
    int N;
    
    cin >> N;
    for(int i = 0; i * cake <= 100 ; ++i){
        for(int j = 0; j * donut <= 100; ++j){
            if(cake * i + donut * j == N){
                cout << "Yes";
                
                return 0;
            }
        }
    }
    cout << "No";
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */
typedef long long ll;

/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;

/* global variables */

/* function */

/* main */
int main(){

    int q; cin >> q;
    int op, x;
    string l, r;
    string key;
    multimap<string, int> M;
    using iterator  = decltype(M)::iterator;
    pair<iterator, iterator> p;

    for (int i = 0; i < q; i++) {
        cin >> op >> key;
        switch(op) {
            case 0:
                cin >> x;
                // insert(key, x) :
                // Insert an element formed by a pair of key and x to M
                M.emplace(key, x);
                break;
            case 1:
                // get(key): Print the value with the specified key
                // if M[key] is not exist
                // => M[key] = 0 and return 0
                // exist => return M[key]
                // Print all value with key
                p = M.equal_range(key);
                for (iterator it = p.first; it != p.second; ++it)
                    std::cout << it->second << std::endl;
                break;
            case 2:
                // delete(key): Delete the element with the specified key
                M.erase(key);
                break;
            case 3:
                // dump(L, R): Print all elements 
                // formed by a pair of the key and the value 
                // such that the key is greater than or equal to L 
                // and less than or equal to R in lexicographic order
                cin >> r;
                l = key;
                iterator head = M.lower_bound(l);
                iterator tail = M.upper_bound(r);
                for ( ; head != tail; head++)
                    cout << (*head).first << ' ' << (*head).second << '\n';
                break;
        }
    }

}



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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B)
    {
        cout << C << endl;
    }
    else if (A == C)
    {
        cout << B << endl;
    }
    else if (C == B)
    {
        cout << A << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll n, z, w;
vector<ll> a;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> z >> w;
  REP(i, n) {
    int t;
    cin >> t;
    a.push_back(t);
  }

  ll ans = abs(w - a[n - 1]);
  if(n > 1) ans = max(ans, abs(a[n - 1] - a[n - 2]));

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;



int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];

    set<int> color;

    int nc = 0;
    rep(i,n){
        if(a[i]>=3200) nc++;
        else color.insert(a[i]/400);
    }

    int num = color.size();
    cout<<((num!=0)?num:1)<<" "<<num+nc<<endl;

	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    l = [0 for _ in range(n + 1)]
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            l[j] += 1
    answer = 0
    for i in range(n + 1):
        answer += i * l[i]
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 225140
N=int(input())
ans,flag=0,0
S=[list(input()) for i in range(N)]
for k in range(N):
  flag=0
  for i in range(N):
    for j in range(N):
      if S[i][j]!=S[(j+k)%N][(i-k)%N]:
        flag=1
        break
    if flag==1:
      break
  if flag==0:
    ans+=N
print(ans)      
      

Measured memory_bytes: 46172
#include <stdio.h>

void right_triangle(int, int, int);

int main(){
	int N, a, b, c;
	scanf("%d", &N);
	while(scanf("%d %d %d", &a, &b, &c) != EOF){
		right_triangle(a, b, c);
	}
	return 0;
}

void right_triangle(int x, int y, int z){
	int tmp;
	if(x > z){				//sort
		tmp = z;
		z = x;
		x = tmp;
	}
	if(y > z){
		tmp = z;
		z = y;
		y = tmp;
	}

	if(z*z == x*x+y*y){			
		printf("YES\n");
	}else{
		printf("NO\n");
	}
}

Measured memory_bytes: 580
#include <stdio.h>

int main(int argc, char *argv[]){
	int n, f, i;
	long long int ID, price, num;
	long long int sum[4001];
	int ln, list[4000];
	while(1){
		scanf("%d ", &n);
		if(!n) break;
		f=0;ln=0;
		for(i=1;i<4001;i++) sum[i]=0;
		while(n--){
			scanf("%lld %lld %lld ", &ID, &price, &num);
			sum[ID] += price * num;
			list[ln++] = ID;
		}
		for(i=0;i<ln;i++)
			if(1000000 <= sum[list[i]]){
				printf("%d\n", list[i]);
				f = 1;
				sum[list[i]] = 0;
			}		
		if(!f) printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using li = long long int;
using uli = unsigned long long int;
using namespace std;

int main() {
    fastIO;
    int n, k;
    cin >> n >> k;
    int sum = 1;
    while (n--) {
        if (sum * 2 > (sum + k))
            sum += k;
        else
            sum *= 2;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <bitset>

using namespace std;

int n,sumMax,nrSums;
int nr,cnt;

bitset<4000005> bit;

int main()
{
    cin>>n;
    bit[0]=1;
    for(int i = 1; i<=n; i++)
    {
        cin>>nr;
        bit |= (bit<<nr);
        sumMax += nr;
    }
    for(int i = sumMax/2+sumMax%2; i<=sumMax; i++)
    {
        if(bit[i])
        {
            cout<<i;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2300
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")
}

fn main() {
    let x: u32 = read();
    let y: u32 = read();
    let mut flag = false;
    for s in 0..x + 1 {
        if s * 2 + (x - s) * 4 == y {
            flag = true;
            break;
        }
    }
    print!("{}", if flag { "Yes" } else { "No" });
}


Measured memory_bytes: 2116
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define reps(i,n) for(int i=1;i<=(int)n;i++)
#define all(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    int n; cin >> n;
    int cnt[10005];
    Fill(cnt, 0);
    for(int x=1;x<=100;x++){
        for(int y=1;y<=100;y++){
            for(int z=1;z<=100;z++){
                int sum = x*x+y*y+z*z+x*y+y*z+z*x;
                if(1 <= sum && sum <= n) cnt[sum]++;
            }
        }
    }
    reps(i,n){
        cout << cnt[i] << "\n";
    }
    return 0;
}

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

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

	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;

	int ans = 0; 
	if (a + b > 2 * c) {
		int t = min(x, y);
		x -= t; y -= t;
		ans += 2 * c * t;
	}

	if (x) {
		if (a > 2 * c) ans += 2 * c * x;
		else ans += a * x;
	}
	if (y) {
		if (b > 2 * c) ans += 2 * c * y;
		else ans += b * y;
	}

	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100
#define INFTY (1<<21)

using namespace std;

int n, M[N][N];
int d[N];

void bfs(int s) {
	queue<int> q;
	q.push(s);
	for(int i=0; i<n;i++) d[i]= INFTY;
	d[s] = 0;
	int u;
	while( !q.empty()) {
		u = q.front(); q.pop();
		for (int v = 0; v < n; v++) {
			if (M[u][v] == 0) continue;
			if (d[v]!= INFTY) continue;
			d[v] = d[u] + 1;
			q.push(v);
		}
	}
	for(int i=0;i<n; i++) {
		cout << i+1 << " " << ( (d[i] == INFTY) ? (-1) : d[i] ) << endl;
	}
}

int main(){
	int u, k, v;
	cin >> n;
	for(int i=0; i<n;i++) {
		cin >> u >> k;
		u--;
		for (int j =0; j<k;j++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	bfs(0);
	return 0;
}



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

int main(){
    double l;
    cin >> l;
    double a, b, c;
    a = l/3.0;
    b = a;
    c = l - (a + b);
    printf("%6lf\n", a * b * c);
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
MOD = 10**9 + 7

from collections import Counter
s = []

for i in range(n):
    b = bin(a[i])[2:]
    c = len(b)
    s.append("0"*(60-c) + b)
    
ans = 0
for i in range(60):
    zero = 0
    one = 0
    for j in range(n):
        if s[j][i] == "0":
            zero += 1
        else:
            one += 1
            
    temp = zero * one * (2 ** (59-i)) % MOD
    
    ans = (ans + temp) % MOD
    
print(ans)

Measured memory_bytes: 128912
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      String S = sc.next();
      
      // 判定
      String result = "";
      if(S.equals("ABC")){
        result = "ARC";
      }else{
        result = "ABC";
      }
      
      // 出力
      System.out.println(result);
    }

}

Measured memory_bytes: 35616
n = int(input())
D = [list(map(int, input().split())) for _ in range(n)] 
ct = 0
CT = []
for i in range(n):
    if D[i][0] == D[i][1]:
        ct += 1
        if i == n-1:
            CT.append(ct)
    else:
        CT.append(ct)
        ct = 0
for k in CT:
    if k >= 3:
        print('Yes')
        exit()
print("No")


Measured memory_bytes: 9192
program main
  implicit none
  integer(8) :: N,M
  integer(8),allocatable :: A(:),B(:)
  integer(8),allocatable :: A2(:,:)
  integer(8) :: i
  integer(8) :: nout
  integer(8) :: out
  read(*,*) N,M
  allocate(A(N),B(N))
  do i = 1,N
     read(*,*) A(i),B(i)
  end do
  allocate(A2(N,2) )
  A2(:,1) = A(:)
  A2(:,2) = B(:)

  call hsort(N,A2)
  out=0
  nout=0
  do i = 1,N
     nout = nout + A2(i,2)
     out = out +A2(i,1) * A2(i,2)
     if ( nout >= M ) THEn
        out = out - A2(i,1)*(nout-M)
        exit
     end if
  end do
  write(*,'(i0)') out
  stop
contains
  subroutine hsort(n, x)
    implicit none
    integer(8), intent(IN) :: n
    integer(8), intent(INOUT) :: x(n,2)
    ! local
    integer(8) k
    integer(8) :: tmp,tmp2
    ! external subroutine
    !external mkheap

    ! 配列 x 全体をヒープにする。
    do k = n/2, 1, -1
       tmp = x(k,1)
       call mkheap(n, x, k, n, tmp)
    enddo

    ! ヒープの根と右下の葉を交換してソートする。
    do k = n, 2, -1
       tmp = x(k,1)
       x(k,1) = x(1,1)
       tmp2 = x(1,2)
       x(1,2) =x(k,2) 
       x(k,2) = tmp2
       
       call mkheap(n, x, int(1,8), k-1, tmp)
    end do

    return
  end subroutine hsort

  subroutine mkheap(n, x, root, leaf, val)
    implicit none
    integer(8), intent(IN)    :: n, root, leaf
    integer(8), intent(INOUT) :: x(1:n,2)
    integer(8), intent(IN)    :: val
    ! local
    integer(8) :: i, j
    integer(8) :: tmp

    i = root
    j = i * 2

    do
       if (j > leaf) exit

       if (j < leaf) then
          if (x(j,1) < x(j+1,1)) j = j + 1
       end if

       if (x(j,1) > val) then
          x(i,1) = x(j,1)
          tmp = x(j,2)
          x(j,2) = x(i,2)
          x(i,2) = tmp
          i = j
          j = i * 2
       else
          j = leaf + 1
       endif
    end do

    x(i,1) = val

    return
  end subroutine mkheap
  
 end program main


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <unordered_map>
using namespace std;

int main()
{
	int h, w;
    cin >> h >> w;
	vector<vector<char>> v(h + 2, vector<char>(w + 2, '.'));
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> v[i][j];
		}
	}
	bool f = true;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (v[i][j] == '#' && v[i - 1][j] == '.' && v[i + 1][j] == '.' && v[i][j - 1] == '.' && v[i][j + 1] == '.') {
				f = false;
				break;
			}
		}
	}
	if (f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<cctype>
#include<string>
#include<iostream>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

bool match(char a,char b){
	if(a=='i' && b=='i') return true;
	if(a=='w' && b=='w') return true;
	if(a=='(' && b==')') return true;
	if(a==')' && b=='(') return true;
	return false;
}

int main(){
	string s; cin>>s;
	int len=s.length();
	int cnt=0;
	rep(i,len/2) if(!match(s[i],s[len-i-1])) cnt++;
	if(len%2==1 && !isalpha(s[len/2])) cnt++;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)
struct edge{
    int to;
    int from;
    ll weight;
    edge(int f,int t,ll w){
        to = t;
        from = f;
        weight = w;
    }
};

bool check(vector<edge> vec,int N,int pos){
    bool can[2500];
    rep(i,N) can[i] = false;
    can[pos] = true;
    rep(_,N){
        rep(i,vec.size()){
            edge e = vec[i];
            if(can[e.from]) can[e.to] = true;
        }
    }
    return can[N-1];
}

int main(){
    int N,M;
    ll P;
    cin>>N>>M>>P;
    vector<edge> vec;
    int a,b;
    ll c;
    rep(_,M){
        cin>>a>>b>>c;
        vec.push_back({a-1,b-1,c-P});
    }
    ll d[2500];
    ll INF = 10000000000;
    rep(i,N) d[i] = -INF;
    d[0] = 0;
    rep(_,N){
        rep(i,vec.size()){
            edge e = vec[i];
            if(d[e.from] == -INF) continue;
            d[e.to] = max(d[e.to],d[e.from]+e.weight);
        }
    }
    bool update[2500];
    rep(i,N) update[i] = false;
    rep(i,vec.size()){
        edge e = vec[i];
        if(d[e.from] == -INF) continue;
        if(d[e.to] < d[e.from]+e.weight) update[e.to] = true; 
    }

    rep(i,N){
        if(update[i]){
            if(check(vec,N,i)){
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    cout<<max((ll)0, d[N-1])<<endl;

    return 0;
}

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

#define ll long long
#define ld long double
#define ull unsigned long long
#define pw(x) (1LL << (x))

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"

using namespace std;

int n;
string s, a;
bool flag = false;

bool is_saying_right(char animal, char status)
{
    return (animal == 'S' && status == 'o') ||
           (animal == 'W' && status == 'x');
}

bool ok(const char &s, const char &t1, const char &t2, const char &t3)
{
    if ((s == 'o' && t1 == 'W') || (s == 'x' && t1 == 'S'))
        return t2 != t3;
    else
        return t2 == t3;
}

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

    cin >> n >> s;
    string ans = "-1";
    string initial[] = {"SS", "SW", "WS", "WW"};

    for (string &t : initial)
    {
        for (int i = 1; i < n - 1; ++i)
        {
            if (is_saying_right(t[i], s[i]))
                t += t[i - 1];
            else
                t += (t[i - 1] == 'S' ? 'W' : 'S');
        }
        if (ok(s[n - 1], t[n - 1], t[0], t[n - 2]) && ok(s[0], t[0], t[n - 1], t[1]))
        {
            ans = t;
            break;
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 976
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
    
int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
int a,b,c;
cin >> a >> b >> c;
if (a==(b+c) || b==(c+a)||c==(a+b))
{
    cout << "Yes" << endl;
}else
{
    cout << "No" << endl;
 }
















  
 
//////////////////////////////////////////////////////
return 0;}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int R0,W0,C,R;
    while(cin>>R0>>W0>>C>>R,R0||W0||C||R){
        if(C*W0-R0<0){
            cout<<0<<endl;
        }
        else{
            cout<<(C*W0-R0+R-1)/R<<endl;
        }
    }
    return 0;
}

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

using namespace std;

int n[10000]={},r[10000]={};
int p[10000][50] = {};
int c[10000][50] = {};
int i=0;

int d[50]={};
int e[50] = {}; //今の状態
int e2[50] = {};

int main(){
    while(1){
        scanf("%d %d",&n[i],&r[i]);
        if(n[i]== 0 && r[i]== 0){
            break;
        }
        for(int j=0;j<r[i];j++){
            scanf("%d %d",&p[i][j],&c[i][j]);
        }
        i++;
    }
    int times = i;
    for(i=0;i<times;i++){
        //初期化
        int s=0;
        for(int k = n[i]; k>0;k--){
            e[s] = k;
            s++;
        }
        for(int j=0;j<r[i];j++){
            s=0;
            for(int t=p[i][j]-1;t<p[i][j]+c[i][j]-1;t++){
                d[s] = e[t];
                s++;
            }
            for(int t = 0;t < n[i];t++){
                e2[t] = e[t];
            }
            for(int t = 0;t<c[i][j];t++){
                e[t] = d[t];
            }
            s = 0;
            for(int t=c[i][j];t<p[i][j]+c[i][j]-1;t++){
                e[t] = e2[s];
                s++;
            }


        }
        
        cout << e[0] << endl;
    }

    return 0;
}


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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll h, w;
	cin>>h>>w;
	if(h==1 || w==1){
		cout<<1<<endl;
		return 0;
	}
	cout<<(h*w + 1)/2<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    double count=0;
    double c1,c2,c3;
    while (cin>>c1>>c2>>c3) {
        for (int j=1;j<11;j++) {
            if (j==c1 || j==c2 || j==c3) {
                continue;
            } else {
                if (c1+c2+j<=20) {
                    count++;
                }
            }
        }
        double result=count/7;
        if (result>=0.5) {
            cout<<"YES"<<endl;
        } else {
            cout<<"NO"<<endl;
        }
        count=0;
    }
}


Measured memory_bytes: 3056
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    string S;
    cin >> S;
    if(S == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(S == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/panasonic2020/submissions/12881278
# D - String Equivalence
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())

    def dfs(S, available):
        if len(S) == n:
            print("".join(S))
            return

        for i in range(available + 1):
            S.append(chr(97 + i))
            dfs(S, max(available, i + 1))
            S.pop()

    dfs([], 0)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 4380
#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back

#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;


signed main()
{
    string a,b;cin>>a>>b;
    int as=0;
    for(int i=0;i<3;++i)
    	{as+=(a[i]==b[i]);}
    cout<<as<<"\n";
}

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

int main() {
  int n, m;
  cin >> n >> m;
  dsu d(n);

  while ( m-- > 0 ) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    d.merge(a, b);
  }

  vector<bool> b(n, true);
  int ans = -1;
  for ( int i = 0; i < n; i++ ) {
    if ( b[d.leader(i)] ) {
      b[d.leader(i)] = false;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3808
#include<iostream>
#include<fstream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include <chrono>
#include<math.h>

#define FIO ios_base::sync_with_stdio(0);  cin.tie(0);
#define PI 3.14159265358979323846
#define mod 998244353
#define ll long long
#define vll vector<long long>  
#define all(c) c.begin(), c.end()
// Used to traverse in any STL container with iterators
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
// Find whether element is present in given container or not
#define present(container, element) (container.find(element) != container.end())
// Finds whether element in present container is present in vector or not
#define cpresent(container, element) (find(all(container),element) != container.end())

using namespace std;
using namespace std::chrono; 

// void dfs(int v, vector<vector<int> >& adj, vector<bool> visited){
//     visited[v] = true;
//     for(int u: adj[v]){
//         if(!visited[u])
//             dfs(u, adj, visited);
//     }
// }

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    FIO

    int n, w;
    cin>>n>>w;
    pair<ll, ll> arr[n]; 
    for(int i=0;i<n;i++){
        cin>>arr[i].first>>arr[i].second;
    }
    ll dp[n+1][w+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=w;j++){
            if(i==0 || j ==0)dp[i][j] = 0;
            else if(arr[i-1].first <= j){
                dp[i][j] = max(arr[i-1].second + dp[i-1][j-arr[i-1].first] , dp[i-1][j]);

            }
            else dp[i][j] = dp[i-1][j]; 
        }
    }
    cout<<dp[n][w]<<endl;

    return 0;
}

Measured memory_bytes: 81960
from fractions import gcd
k=int(input())
ans=0
gcd_table=[0]*(k+1)
for a in range(1,k+1):
    for b in range(1,k+1):
        gcd_table[gcd(a,b)]+=1
for g in range(1,k+1):
    for c in range(1,k+1):
        ans+=gcd(g,c)*gcd_table[g]
print(ans)


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

int main(){
  long long x; cin >> x;
  long long ans = x / 11;
  x %= 11;
  ans *= 2;
  if (0 < x) {
    ans++;
    if (x > 6) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define REP(i, a, b) for (auto i = (a); i < (b); ++i)
using namespace std;

using ll = long long;

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

	int n; cin >> n;
	vector<int> T[n][2];
	REP(i, 0, n) {
		int a; cin >> a;
		while (a--) {
			int x, y; cin >> x >> y; --x;
			T[i][y].emplace_back(x);
		}
	}

	auto solve = [&](int s) {
		bool b[n];
		REP(i, 0, n) b[i] = (s >> i) & 1;
		REP(i, 0, n)
			if (b[i])
				REP(j, 0, 2)
					for (int x : T[i][j])
						if (b[x] != j) return false;
		return true;
	};

	int cur = 0;
	REP(s, 1, 1 << n)
		if (solve(s)) {
			cur = max(cur, __builtin_popcount(s));
		}
	cout << cur;
}

Measured memory_bytes: 256
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

tmp = [n+1 for n in range(N)]

parms = list(itertools.permutations(tmp, N))

for i in range(len(parms)):
    if parms[i] == P:
        a = i
    if parms[i] == Q:
        b = i
        
print(abs(a-b))

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    string S;
    cin >> S;

    REP(i, S.length()){
        if(S[i] == '1'){
            cout << 9;
        }
        else{
            cout << 1;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

    int a,n,o,p,q;
    
    scanf("%d", &n);
    scanf("%d", &a);
	
	q = n % 500; 
		
	if(a>=q){
		printf("Yes");
	}
	else{
		printf("No");
	}
	
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstring>
#include<iostream>
using namespace std;
#define N 10010
#define M 1000010
inline int rd()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	return f*x;
}
string S,T,U;
int a,b;
int main()
{
    cin>>S>>T;
    a=rd(),b=rd();
    cin>>U;
    if(S==U) a--;
    else if(T==U) b--;
	printf("%d %d\n",a,b);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int ans;
  if(s == "RRR") ans = 3;
  else if(s == "RRS" || s == "SRR") ans = 2;
  else if(s == "SSS") ans = 0;
  else ans = 1;
  cout << ans << endl;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int i;
    //入力
    long h,n,a,sum=0;
    cin>>h>>n;
    for(i;i<n;i++){
        cin>>a;
        sum+=a;
    }

    //処理
    //出力
    sum<h? cout<<"No"<<endl : cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define va vector<long long int> a 
#define vb vector<long long int> b
const ll M = 1e9+7;
const ll inf = 1e18+5;
const ll INF=INT_MAX;
using namespace std;
void fast(){cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);}
ll bs(ll arr[], ll l, ll r, ll x){
	ll mid=0;
    if (r >= l){
		if (arr[mid] == x) return mid; 
        if (arr[mid] > x) return bs(arr, l, mid - 1, x); 
        return bs(arr, mid + 1, r, x); 
    }
    return -1;
}
ll power(ll x,ul y,ll p){
	ll res = 1;
	x = x % p;
	if(x == 0) return 0;
	while (y > 0){
		if (y & 1) res = (res*x) % p;
		y = y>>1;
		x = (x*x) % p;
		}
	return res;
}
ll arr[500000],st[500000];
void buildtree(int si,int ss,int se){
	if(ss==se){
		st[si]=arr[ss];
		return;
	}
	int mid=ss+(se-ss)/2;
	buildtree(2*si,ss,mid);
	buildtree(2*si+1,mid+1,se);
	st[si]=min(st[2*si],st[2*si+1]);
}
int query(int si,int ss,int se,int qs,int qe){
	if(qs>se || qe<ss) //completely outside
		return INF;
	if(ss>=qs && se<=qe)
		return st[si];
	int mid=ss+(se-ss)/2;
	int l=query(2*si,ss,mid,qs,qe);
	int r=query(2*si+1,mid+1,se,qs,qe);
	return min(l,r);
}
void update(int si,int ss,int se,int qi){
	if(ss==se){
		st[si]=arr[ss];
		return;
	}
	int mid=ss+(se-ss)/2;
	if(qi<=mid) update(2*si,ss,mid,qi);
	else update(2*si+1,mid+1,se,qi);
	st[si]=min(st[2*si],st[2*si+1]);
}

void solve(){
	ll n;
	cin>>n;
	if(n>=400 && n<600) cout<<"8\n";
	else if(n>=600 && n<800) cout<<"7\n";
	else if(n>=800 && n<1000) cout<<"6\n";
	else if(n>=1000 && n<1200) cout<<"5\n";
	else if(n>=1200 && n<1400) cout<<"4\n";
	else if(n>=1400 && n<1600) cout<<"3\n";
	else if(n>=1600 && n<1800) cout<<"2\n";
	else cout<<"1\n";
 }
int main(){
	fast();
	solve();
	return 0;
}


Measured memory_bytes: 3652
import Data.Char
import Data.List

main = getContents >>= putStr . solve

solve :: String -> String
solve cs = unlines $ getall (getex cs) (zip ['a'..'z'] (repeat 0))

getex :: String -> [(Char, Int)]
getex cs = let ex = group . sort $ filter (`elem` ['a'..'z']) (map toLower cs)
            in zipWith (\x y -> (head x, y)) ex (map length ex)

getall :: [(Char, Int)] -> [(Char, Int)] -> [String]
getall ((c, n):exs) [] = (c : " : " ++ show n) : getall exs []
getall [] ((d, m):als) = (d : " : " ++ show m) : getall [] als
getall ((c, n):exs) ((d, m):als)
    | c <= d    = (c : " : " ++ show n) : getall exs als
    | otherwise = (d : " : " ++ show m) : getall ((c,n):exs) als
getall _ _ = []


Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N;
  cin >> N;
  vector<ll> P(N);
  REP(i, 0, N) cin >> P[i], P[i]--;

  vector<ll> idx(N);
  REP(i, 0, N) idx[P[i]] = i;

  ll ans = 0, x = 0;
  REP(i, 0, N) {
    x++;
    ans = max(ans, x);
    if (i + 1 < N && idx[i] > idx[i + 1]) x = 0;
  }
  cout << N - ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int		long long
#define mp		make_pair
#define pb		push_back
#define pf		push_front
#define fi 		first
#define se		second
#define sz(x)	((int)(x).size())
#define w(x)		int x; cin>>x; while(x--)
#define rep(i,a,n)		for (int i=a;i<n;i++)
#define per(i,a,n)		for (int i=n-1;i>=a;i--)
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod		1000000007
#define inf		1e18
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void c_p_c(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int32_t main(){
	c_p_c(); 
	int n,m,sum=0; cin>>n>>m;
	int a[n];
	rep(i,0,m){
		cin>>a[i];
		sum+=a[i];
	}
	if(sum>n) cout<<-1;
	else cout<<n-sum;
		
	
	return 0;
}


Measured memory_bytes: 3732
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 1000000007;

int N, M;
vector<bool> issafe; // issafe[v] := v が壊れていないかどうか

int main() {
    cin >> N >> M;
    issafe.assign(N+1, true);
    for (int i = 0; i < M; ++i) {
        int a; cin >> a;
        issafe[a] = false; // a 段目は壊れてる
    }

    // DP テーブル
    vector<int> dp(N+1, 0); // 各段について 0 で初期化しておく

    // 初期条件
    dp[0] = 1;
    if (issafe[1]) dp[1] = 1;

    // ループ
    for (int n = 2; n <= N; ++n) {
        if (issafe[n-1]) dp[n] += dp[n-1]; // n-1 段目が安全なら
        if (issafe[n-2]) dp[n] += dp[n-2]; // n-2 段目が安全なら
        dp[n] %= MOD; // 1000000007 で割る
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 3712