akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	LL n,s,b=-1;
	cin>>n>>s;

	if(n==s){
		cout<<n+1;
		return 0;
	}
	int t=sqrt(n)+3;
	FOR(i,2,t){
		LL ii=i,nn=n,d=0;
		while(nn>0){
			d+=nn%ii;
			nn/=ii;
		}
		if(d==s){
			b=ii;
			break;
		}
	}
	if(b==-1){
		FOR(p,1,t){
			LL pp=p,q=s-p,d=(n-q)/p;
			if(q>=0&&d>=0&&n==p*d+q&&q<d){
				b=d;
				//cerr<<p<<"*"<<d<<"+"<<q<<"="<<n<<endl;
			}
		}
	}
	cout<<b;
    return 0;
}


Measured memory_bytes: 256
from sys import stdin

n, m, k = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

A,B = [0],[0]

for i in range(n):
    A.append(A[i]+a[i])

for i in range(m):
    B.append(B[i]+b[i])

ans = 0
j = m
for i in range(n + 1):
    if A[i] > k:
        break
    while A[i]  > k- B[j]:
        j -= 1
    ans = max(ans, i + j)

print(ans)

Measured memory_bytes: 47276
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define print_time cerr << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
    if(y==0)
        return x;
    else
        return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
        if(m%2)
            r=(r*n)%p;
        n=(n*n)%p;
        m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}
int32_t main()
{
   IOS;
 /*  #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);
   #endif
   /********************* Code starts here ***********************/	
   string s;
   cin>>s;
   int k;
   cin>>k;
   int c=0;
   int n=s.size();
   while(c<n)
   {
   	cout<<s[c];
   	c=c+k;
   }
} 	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int x, t;
  cin >> x >> t;
  x -= t;
  cout << max(0, x) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <fstream> //ofstream
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
std::vector<int> v;
int n,tmp,ct=1;
void solve(){
        rep(i,n){
                if(v.at(i)==ct) {
                        ct++;
                }
        }
        if(ct==1) {
                cout<<"-1"<<endl;
        }else{
                cout<<n-ct+1<<endl;
        }
}

int main(){
        cin>>n;
        rep(i,n){
                cin>>tmp;
                v.push_back(tmp);
        }

        solve();
        return 0;
}


Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
#include<cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b > c + d) puts("Left");
    else if(a+b < c+d) puts("Right");
    else puts("Balanced");
}

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

int main() {
	string s;
	int n;
	cin >> n;
  	cin >> s;
  
    for(int i = 0; i < s.length(); i++){
      	s[i] = s[i] + n;
     	if(s[i] > 90){
          s[i]-=26;
        }
    }
  
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <string>

using namespace std;

const int MAX_N = 100001;

typedef pair<int, int> P;

int par[MAX_N];
int rank[MAX_N];
int cost[MAX_N];

void init(int n){
	for(int i=0;i<n;i++){
		par[i] = i;
		rank[i] = 0;
		cost[i] = 0;
	}
}

P find(int x){
	if(par[x] == x){
		return P(x, 0);
	}else{
		P tmp = find(par[x]);
		tmp.second += cost[x];
		par[x] = tmp.first;
		cost[x] = tmp.second;
		return tmp;
	}
}

void unite(int x, int y, int c){
	P px = find(x);
	P py = find(y);
	/*cout << x << ' ' << y << ' ' << c << endl;
	cout << "px = (" << px.first << ", " << px.second << ")" << endl;
	cout << "py = (" << py.first << ", " << py.second << ")" << endl;*/
	if(px.first == py.first) return;
	if(rank[px.first] < rank[py.first]){
		par[px.first] = py.first;
		cost[px.first] = c - px.second + py.second;
	}else{
		par[py.first] = px.first;
		cost[py.first] = -(c - px.second + py.second);
		if(rank[px.first] == rank[py.first]){
			rank[px.first]++;
		}
	}
}

bool same(int x, int y){
	return find(x).first == find(y).first;
}

void print(P p){
	cout << "(" << p.first << ", " << p.second << ")" << endl;
}

int main(){
	int sum[MAX_N];
	fill(sum, sum+MAX_N, 0);
	int n, q;
	cin >> n >> q;
	init(n+1);
	for(int i=0;i<q;i++){
		string op;
		cin >> op;
		int a, b, c;
		if(op == "IN"){
			cin >> a >> b >> c;
			unite(a, b, c - (sum[b] - sum[a]));
			sum[a] += c;
			sum[b] += c;
		}else if(op == "COMPARE"){
			cin >> a >> b;
			if(!same(a, b)) cout << "WARNING" << endl;
			else{
				/*print(find(a));
				print(find(b));
				cout << sum[a] << ' ' << sum[b] << endl;*/
				cout << find(a).second - find(b).second + sum[b] - sum[a] << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2776
N = int(input())
S = []
for i in range(0,N):
	s = str(input())
	S.append(s)

T=[]
M = int(input())
for j in range(0,M):
	t = str(input())
	T.append(t)

S_uniq = list(set(S))

num = []
for p in S_uniq:
	s_count = S.count(p)
	t_count = T.count(p)
	counts = s_count - t_count
	num.append(counts)

num.sort()
num.reverse()
if(num[0] < 0):
	print("0")
else:
	print(num[0])


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int a[100];
int cells[100][100]; // r * c

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

  string ans = "No";
  rep1(i, 9) rep1(j, 9) if (i * j == N ) ans = "Yes";

  cout << ans << BR;
  return 0;
}

Measured memory_bytes: 256
def main():
    """"ここに今までのコード"""

n = int(input())
A = [int(a) for a in input().split()]
mod=10**9+7

ans=0
for i in range(60):
    l=sum([a>>i & 1 for a in A])
    ans+= l*(n-l) <<i
    ans%= mod
    
print(ans) 

if __name__ == '__main__':
    main()

Measured memory_bytes: 138168
#include <stdio.h>
int main()
{
    int N;

    scanf("%d", &N);

    int a;

    if (N % 2 == 0) {
        a = N / 2;
    }
    else {
        a = (N + 1) / 2;
    }

    printf("%d",a);

    return 0;
}



Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    int N;
    string S;
    cin >> N >> S;
    vector<vector<int>> pos(10);
    rep(i,N){
        int x=S[i]-'0';
        pos[x].push_back(i);
    }
    int ans=0;
    rep(i,10){
        if (pos[i].empty()) continue;
        int p=pos[i][0];
        rep(j,10){
            if (upper_bound(pos[j].begin(),pos[j].end(),p)==pos[j].end()) continue;
            int q=*upper_bound(pos[j].begin(),pos[j].end(),p);
            rep(k,10){
                if (upper_bound(pos[k].begin(),pos[k].end(),q)==pos[k].end()) continue;
                ++ans;
            }
        }
    }
    cout << ans << endl;
}

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



#define MAX 100002

int n;
int m;


vector<int> v[MAX];


int cnt[MAX];
bool flag[MAX];

int main(){
	cin >> n >> m;
	for (int i = 0; i < n; i++){
		cnt[i] = 1;
	}
	flag[0] = true;
	for (int i = 0; i < m; i++){
		int x, y;
		scanf("%d%d", &x, &y);
		x--;
		y--;
		if (flag[x] == false){
			cnt[y]++;
			cnt[x]--;
		}
		else{
			cnt[x]--;
			cnt[y]++;
			if (cnt[x]){
				flag[y] = true;
			}
			else{
				flag[x] = false;
				flag[y] = true;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++){
		if (flag[i]){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <ctime>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define make make_pair
#define fi first
#define se second
#define vi std::vector<int>;
#define DEBUG cout << "debug" << endl
#define CLOSE ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define CASE int Kase=0;cin>>Kase;for(int kase=1;kase<=Kase;kase++)
const int N = 1e5 + 5;
const int M = 1e6 + 5;
const int MOD = 1e9 + 7;
const int CM = 998244353;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
template <typename T>
T MAX(T a, T b) { return a > b ? a : b; }
template <typename T>
T MIN(T a, T b) { return a > b ? b : a; }
template <typename T>
T GCD(T a, T b){ return b == 0 ? a : GCD(b, a % b); }
template <typename T>
T LCM(T a, T b){ return a / GCD(a, b) * b; }
template <typename T>
T ABS(T a, T b) { return a > 0 ? a : -a; }
template <typename T>
T ADD(T a, T b, T MOD){ return (a + b) % MOD; }
template <typename T>
T DEL(T a, T b, T MOD) { return ((a - b) % MOD + MOD) % MOD; }
ll fabs(ll a){
    return a > 0 ? a : -a;
}
ll min(ll a, ll b){
    if(fabs(a) > fabs(b)) return b;
    return a;
}
void solve(){
    ll x, k, d;
    cin >> x >> k >> d;
    ll ans = 1e16;
    if(x < 0) {
        ll num = -x / d;
        if(num <= k) {
            ll now = x + d * num;
            if((k - num) % 2 == 1) {
                now = min((now + d), (now - d));
            }
            ans = min(ans, now);
            now = x + d * (num - 1);
            if((k - (num - 1)) % 2 == 1) now = min((now + d), (now - d));
            ans = min(ans, (now));
            printf("%lld\n", fabs(ans));
        }else {
            ll now = x + d * k;
            printf("%lld\n", fabs(now));
        }
    }else if(x > 0){
        ll num = x / d;
        if(num <= k) {
            ll now = x - d * num;
            if((k - num) % 2 == 1) now = min((now + d), (now - d));
            ans = min(ans, (now));
            now = x - d * (num - 1);

            if((k - (num - 1)) % 2 == 1) now = min((now + d), (now - d));
            ans = min(ans, (now));
            printf("%lld\n", fabs(ans));
        }else {
            ll now = x - d * k;
            printf("%lld\n", fabs(now));
        } 
    }else {
        if(k % 2 == 0) {
            printf("%lld\n", fabs(x));
        }else printf("%lld\n", fabs(d));
    }
}
void TIME(){
    clock_t start, finish;
    double totaltime;
    start = clock();

    // 待测程序

    // CASE {
        solve();
    // }
    // 待测程序

    finish = clock();
    totaltime = (double)(finish - start) / CLOCKS_PER_SEC;
    printf("\nTime:%lfms\n", totaltime * 1000);
}
int main(){
    #ifdef ONLINE_JUDGE
        // CLOSE;
        // CASE {
            solve();
        // }
    #else
        // freopen("./data/a.txt", "r", stdin);
        // freopen("./data/a.txt", "w", stdout);
        TIME();
    #endif
    return 0;
}










Measured memory_bytes: 3256
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}
#[allow(unused_imports)]
use std::io::{stdout, Write};
fn main() {
    let mut v: Vec<i32> = read_vec();
    let mut count = 0;
    while v[0] != v[1] || v[1] != v[2] || v[2] != v[0] {
        v.sort();
        let sa = v[2] - v[1];
        count += sa;
        v[1] += sa;
        v[0] += sa;
        let bi = (v[1] - v[0] + 1) / 2;
        count += bi;
        v[0] += bi * 2;
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int x,y;cin>>x>>y;
    cout<<x+y/2<<endl;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define M_MAX 10000000000000

int main()
{
  ll n;cin>>n;
  vector<ll> a(n+1);
  ll i,j;
  rep(i,n+1)cin>>a[i];
  bool ok=true;
  ll left=1;
  vector<ll> marg(n+1);
  rep(i,n+1)
  {
    left-=a[i];
    if(left<0)
    {
      ok=false;
      break;
    }
    marg[i]=left;
    if(left>=M_MAX)
    {
      ok=true;
      for(j=i;j<=n;j++)
      {
        marg[j]=M_MAX;
      }
      break;
    }
    left*=2;
  }
  if(!ok)cout<<-1<<endl;
  else
  {
    ll ans=0;
    ll kuki=0;
    for(i=n;i>=0;i--)
    {
      if(i!=0)
      {
        ans+=(kuki+a[i]);
        kuki=min(marg[i-1],kuki+a[i]);
      }
      else ans+=(a[i]+kuki);
    }
    cout<<ans<<endl;
  }
  
}


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

using namespace std;

int main (void) {
    string s;
    cin >> s;
    int s_len = s.size();

    deque<char> dq;
    for ( int i = 0; i < s_len; i++ ) {
        if ( s.at(i) != 'B' )
            dq.push_back(s.at(i));
        else if ( !dq.empty() )
            dq.pop_back();
    }

    while ( !dq.empty() ) {
        cout << dq.front();
        dq.pop_front();
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int saidaikouyakusuu(int a,int b){
    if(b==0) return a;
    return saidaikouyakusuu(b,a%b);
}
int saisyoukoubaisuu(int a,int b){
    return a*b/saidaikouyakusuu(a,b);
}
int n,m,cnt=0,aa[220000],ab[220000];
pair<int,int> pp[220000];
string s,ss[220000];
char c,ca;
queue<int> que;
signed main(){
    cin>>n>>m;
    rep(i,n){
        cin>>aa[i];
        ab[max((long long)0,i-aa[i])]++;
        ab[min(n,i+aa[i]+1)]--;
    }
    rep(i,min(m,(long long)100)){
        rep(j,n){
            aa[j]=ab[j]+aa[j-1];
            ab[j]=0;
        }
        rep(j,n){
            ab[max((long long)0,j-aa[j])]++;
            ab[min(n,j+aa[j]+1)]--;
        }
    }
    rep(i,n){
        cout<<aa[i]<<' ';
    }
}


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

int main(){
  
  int a,b;
  cin >> a >> b;
  
  if( a%3 == 0 || b%3 == 0 ){
    
    cout << "Possible" << endl;
    
  }
  
  else if( (a+b)%3 == 0 ){
    
    cout << "Possible" << endl;
    
  }
  
  else{
    
    cout << "Impossible" << endl;
    
  }
  
}


Measured memory_bytes: 3576
import java.util.Scanner;
public class Main {
    public static void main(String args[] ) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (a+b==0) {
                break;
            }
            boolean[] bl = new boolean[10];
            int[] num = new int[4];
            for(int i=0;i<4;i++) {
                num[i] = a%10;
                bl[a%10] = true;
                a/=10;
            }
 
            int hit = 0;
            int blow = 0;
 
            for(int i=0;i<4;i++) {
                if(num[i]==b%10) {
                    hit++;
                }else if(bl[b%10]) {
                    blow++;
                }
                b/=10;
            }
            System.out.println(hit+" "+blow);
        }
        sc.close();
    }
}

Measured memory_bytes: 49656
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
#define pb push_back
int N, a, b;
vector<vector<int>> edge;  //頂点aと隣接するi番目の頂点
vector<P> edge_pair;     //辺を頂点ペア形式で格納
vector<int> degree;      //次数
map<P, int> color;
int max_degree = 0;  //最大次数
void dsf(int ver, int par, int c){
    int L = edge[ver].size(), d = 0;
    color[{par, ver}] = c;
    for(int i = 0; i < L; i++){
        if(i+1 == c) ++d;
        dsf(edge[ver][i], ver, i+1+d);
    }
}
int main(){
    cin >> N;
    edge.resize(N+1);
    degree.assign(N+1, 0);
    for(int i = 0; i < N-1; i++){
        cin >> a >> b;
        edge[a].pb(b);
        edge_pair.pb({a,b});
        ++degree[a]; ++degree[b];
        max_degree = max(max_degree, degree[a]);
    }
    cout << max_degree << endl;
    dsf(1, 0, 0);
    for(int i = 0; i < N-1; i++){
        P p = edge_pair[i];
        cout << color[p] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 15172
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <tuple>
#include <functional>

template <typename Weight>
struct edge {
  using value_type = Weight;
  size_t src, dst;
  value_type cost;

  edge(size_t src, size_t dst, value_type cost = 1):
    src(src), dst(dst), cost(cost)
  {}

  bool operator <(edge<value_type> const& rhs) const {
    if (cost != rhs.cost) return cost < rhs.cost;
    if (src != rhs.src) return src < rhs.src;
    return dst < rhs.dst;
  }
};

template <typename Weight>
struct graph: public std::vector<std::vector<edge<Weight>>> {
  using value_type = Weight;
  graph(size_t n): std::vector<std::vector<edge<value_type>>>(n) {}

  void connect_to(size_t src, size_t dst, value_type cost = 1) {
    (*this)[src].emplace_back(src, dst, cost);
  }

  void connect_with(size_t src, size_t dst, value_type cost = 1) {
    connect_to(src, dst, cost);
    connect_to(dst, src, cost);
  }
};

template <class Tp>
constexpr Tp inf = Tp(1) << (8*sizeof(Tp)-3);

template <class Weight>
std::vector<Weight> shortest(const graph<Weight>& g, size_t s) {
  // based on Dijkstra algorithm
  std::vector<Weight> res(g.size(), inf<Weight>);
  using pair_type = std::pair<Weight, size_t>;
  std::priority_queue<pair_type, std::vector<pair_type>, std::greater<>> q;
  res[s] = 0;
  q.emplace(0, s);
  while (!q.empty()) {
    Weight w;
    size_t v;
    std::tie(w, v) = q.top();
    q.pop();
    if (w > res[v]) continue;
    for (const auto& e: g[v]) {
      if (res[e.dst] > w + e.cost) {
        res[e.dst] = w + e.cost;
        q.emplace(res[e.dst], e.dst);
      }
    }
  }
  return res;
}

int main() {
  size_t N, M, K;
  scanf("%zu %zu %zu", &N, &M, &K);

  std::vector<intmax_t> P(N);
  for (auto& pi: P) scanf("%jd", &pi);

  std::vector<size_t> c(N);
  for (auto& ci: c) {
    scanf("%zu", &ci);
    --ci;
  }

  std::vector<intmax_t> J(N);
  for (auto& ji: J) scanf("%jd", &ji);

  graph<intmax_t> g(N);
  for (size_t i = 0; i < M; ++i) {
    size_t u, v;
    intmax_t t;
    scanf("%zu %zu %jd", &u, &v, &t);
    --u, --v;
    g.connect_with(u, v, t);
  }

  auto d0 = shortest(g, 0);

  using pair_type = std::pair<intmax_t, size_t>;
  std::priority_queue<pair_type, std::vector<pair_type>, std::greater<>> pq;
  std::vector<intmax_t> res0(N, 2e9);
  for (size_t i = 0; i < N; ++i) {
    pq.emplace(d0[i]-P[i], i);
    res0[i] = d0[i]-P[i];
  }
  while (!pq.empty()) {
    intmax_t w;
    size_t v;
    std::tie(w, v) = pq.top();
    pq.pop();
    for (auto const& e: g[v]) {
      if (res0[e.dst] > w + e.cost) {
        res0[e.dst] = w + e.cost;
        pq.emplace(res0[e.dst], e.dst);
      }
    }
  }

  std::vector<intmax_t> res(K, -2e17);
  for (size_t i = 0; i < N; ++i) {
    intmax_t cur = J[i]-res0[i]-d0[i];
    // fprintf(stderr, "c[%zu]=%jd: J[%zu]=%jd, res0[%zu]: %jd, d0[%zu]=%jd\n",
    //         i, c[i], i, J[i], i, res0[i], i, d0[i]);
    res[c[i]] = std::max(res[c[i]], cur);
  }

  for (auto ri: res) printf("%jd\n", ri);
}



Measured memory_bytes: 25628
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
const int maxn = 5e3 + 10;
char s[maxn];
int k,cnt = 0;
string str[maxn*100];

int main()
{
    scanf("%s%d",s,&k);
    int len = strlen(s);
    for(int i=0;s[i];i++){
        string ss = "";
        for(int j=0;j<10;j++){
            if(i+j>=len) break;
            ss += s[j+i];
            str[cnt++] = ss;
        }
    }
    sort(str, str+cnt);
    int ct = 1;
    if(k==1) {
        cout<<str[0]<<endl;
        return 0;
    }
    for(int i=1;i<cnt;i++) {
        if(str[i-1]!=str[i]) ct++;
        if(ct==k){
            cout<<str[i]<<endl;
            return 0;
        }
    }
    
    return 0;
}


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

int N, a[100009], p[100009], q[100009], maxn = 1000009; vector<pair<int, int>>V;

int main() {
	cin >> N; int t1 = 0, t2 = 0;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
		if (i % 2 == 1) { p[a[i]]++; t1++; }
		if (i % 2 == 0) { q[a[i]]++; t2++; }
	}
	for (int i = 1; i <= 100000; i++) V.push_back(make_pair(q[i], i));
	sort(V.begin(), V.end(), greater<pair<int, int>>());
	for (int i = 1; i <= 100000; i++) {
		int sum1 = (t1 - p[i]);
		int sum2 = (t2 - V[0].first); if (V[0].second == i) sum2 = (t2 - V[1].first);

		maxn = min(maxn, sum1 + sum2);
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 2552
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h> 
using namespace std;
#define for8 for(int i=0;i<2;i++)for(int j=0;j<2;j++)for(int l=0;l<2;l++)
typedef long long ll;
int n,m;
ll x[1003],y[1003],z[1003];
ll dp[1003][1003][2][2][2];
int num[2]={1,-1};
int main(){
	cin>>n>>m;
	for (int k=0;k<1003;k++) for(int q=0;q<1003;q++) for8 dp[k][q][i][j][l]=-1e16;
	memset (dp[0][0],0,sizeof(dp[0][0]));
	for (int k=1;k<=n;k++){
		cin>>x[k]>>y[k]>>z[k];
		for (int q=0;q<=m;q++)
			for8{
				dp[k][q][i][j][l]=dp[k-1][q][i][j][l];
				if (q-1>=0 && dp[k-1][q-1][i][j][l]!=-1e16)
					dp[k][q][i][j][l]=max(dp[k][q][i][j][l],dp[k-1][q-1][i][j][l]+num[i]*x[k]+num[j]*y[k]+num[l]*z[k]);
			}
	}
	ll ans=-1e18;
	for8 ans=max(ans,dp[n][m][i][j][l]);
	cout<<ans;
}

Measured memory_bytes: 63104
#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        r: f64
    }
    println!("{}", r * 2f64 * std::f64::consts::PI);
}


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

using namespace std;
using ll = long long int;

ll powmod(ll base, ll exp, ll mod) {
    if (exp == 0) {
        return 1;
    }
    if (exp % 2 == 0) {
        ll t = powmod(base, exp / 2, mod);
        return (t * t) % mod;
    }
    return (base * powmod(base, exp - 1, mod)) % mod;
}

unordered_map<ll, ll> primefactordecomp(ll n) {
    unordered_map<ll, ll> ans = unordered_map<ll, ll>();
    ll m = pow(n, 0.5) + 1;
    for (ll i = 2; i < m; i++) {
        while (n > 1) {
            if (n % i != 0) {
                break;
            } else {
                ans[i] = ans[i] + 1;
                n = ll(n / i);
                continue;
            }
        }
    }
    if (n > 1) {
        ans[n] = 1;
    }
    return ans;
}

int main() {
    int N;
    unordered_map<ll, ll> total_primes = unordered_map<ll, ll>();
    vector<unordered_map<ll, ll>> each_primes = vector<unordered_map<ll, ll>>();

    ll M = pow(10, 9) + 7;
    cin >> N;
    ll A[N];
    for (int i = 0; i < N; i++) {
        ll c;
        cin >> c;
        A[i] = c;

        unordered_map<ll, ll> primes = primefactordecomp(c);
        for (pair<ll, ll> p: primes) {
            if (total_primes.count(p.first) == 0) {
                total_primes[p.first] = 0;
            }
            total_primes[p.first] = max(p.second, total_primes[p.first]);
        }
    }

    ll lcm = 1;
    for (pair<ll, ll> p: total_primes) {
        lcm *= powmod(p.first, p.second, M);
        lcm %= M;
    }

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += (lcm * powmod(A[i], M - 2, M)) % M;
        ans %= M;
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k) cout << s << endl;
    else cout << s.substr(0, k) << "..." << endl;
}


Measured memory_bytes: 3556
# SはストックのS 存在するぶんだけTと相殺できる
# 消した数じゃなくて残った数を数えるってのを読み飛ばしてて1WA
# 変数ミスで1WA

x = input()
stock = 0
count = 0
for a in x:
    if a == "S":
        stock += 1
    else:
        if stock > 0:
            count += 2
            stock -= 1
print(len(x)-count)


Measured memory_bytes: 3500
type dice = { one : int; two : int; three : int; four : int; five : int; six : int}

type direction = N | S | W | E

let move {one=a;two=b;three=c;four=d;five=e;six=f} = function
    N -> {one=b;two=f;three=c;four=d;five=a;six=e}
  | S -> {one=e;two=a;three=c;four=d;five=f;six=b}
  | W -> {one=c;two=b;three=f;four=a;five=e;six=d}
  | E -> {one=d;two=b;three=a;four=f;five=e;six=c}

let str_to_list str =
  let rec iter l = function
      0 -> l
    | i -> iter (str.[i-1]::l) (i-1)
  in iter [] (String.length str)

let () =
  let dice = Scanf.sscanf (read_line ()) "%d %d %d %d %d %d"
      (fun a b c d e f -> {one=a;two=b;three=c;four=d;five=e;six=f}) in
  let directions = read_line ()
                   |> str_to_list
                   |> List.map
                     (fun d -> match d with 'N'->N | 'S'->S | 'W'->W | _->E) in
  let {one=top;two=_;three=_;four=_;five=_;six=_} =
    List.fold_left (fun dice direction -> move dice direction) dice directions in
  Printf.printf "%d\n" top

Measured memory_bytes: 2344
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	long long N, K;
	cin >> N >> K;

	vector<int> port(N, 0);
	for (int i = 0; i < N; i++)
	{
		cin >> port[i];
		port[i]--;
	}

	vector<bool> visited(N, false);

	int curr = 0;
	int cycle_start = 0;
	while (true)
	{
		visited[curr] = true;
		int next = port[curr];

		if (visited[next])
		{
			cycle_start = next;
			break;
		}

		curr = next;
	}

	long long before_cycle = 0;
	curr = 0;
	while (true)
	{
		if (curr == cycle_start)
			break;
		before_cycle++;
		curr = port[curr];
	}

	long long in_cycle = 1;
	curr = cycle_start;
	while (true)
	{
		int next = port[curr];
		if (next == cycle_start)
			break;
		in_cycle++;
		curr = next;
	}

	if (K > before_cycle)
	{
		K -= before_cycle;
		K %= in_cycle;

		curr = cycle_start;
		int result = cycle_start;
		for (int i = 0; i < K; i++)
		{
			result = port[curr];
			curr = result;
		}
		cout << result + 1;
	}
	else
	{
		int result = 0;
		curr = 0;
		for (int i = 0; i < K; i++)
		{
			result = port[curr];
			curr = result;
		}

		cout << result + 1;
	}

	return 0;
}

Measured memory_bytes: 3992
#include<iostream>
using namespace std;
/*
int digtop(int n)
{
  int b;
  while (n > 0)
  {
    b = n;
    n /= 10;
  }
  return b;
}
*/
int main(){
  int n;
  cin >> n;

  int tmp1, tmp2;
  long long int pair[11][11] = {0};

  for (int i = 1; i <= n; i++){

    if(i%10 != 0){
      tmp1 = i % 10;
      tmp2 = i;
      while (tmp2 > 9)
      {
        tmp2 /= 10;
      }
      //cout << digtop(i) << " " << tmp2 << "\n";
      //cout << tmp2 << tmp1 << "\n";
      pair[tmp2][tmp1]++;
    }
  }

  long long int ans = 0;

  for (int i = 0; i<=9; i++){
    for (int j = 0; j<=9; j++){
      ans += pair[i][j] * pair[j][i];
    }
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int main() {
    int n, m;
    cin >> n >> m;
    int mx = 1;
    rep(i, n) mx *= 10;
    vector<bool> ans(mx, true);
    rep(i, m) {
        int s, c;
        cin >> s >> c;
        for(int j = 0; j < mx; j++) if(to_string(j)[s - 1] != c + '0') ans[j] = false;
    }
    for(int i = 0; i < mx; i++) if(to_string(i).size() != n) ans[i] = false;
    int i;
    for(i = 0; !ans[i] && i < mx; i++);
    cout << (i < mx ? i : -1) << endl;
}

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

int main(){
    int N; cin >> N;
    int D,X; cin >> D >> X;
    int cnt=0;
    rep(i,N){
        int k=0;
        int A; cin >> A;
        while(1){
            if (1+k*A>D) break;
            else {
                cnt++;
                k++;
            }
        }
    }
    cout << cnt+X;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define STSIZE 100


void push(int);
int pop(void);

int stack[STSIZE];
int top = 0;

int main(){
  int i=0,j=0,num,num2;
  char wd[1000000];
  while(scanf("%s",wd) != EOF){
    if(wd[0] == '+'){
      num=pop();
      num2=pop();
      push(num+num2);
    }
    else if(wd[0] == '-'){
      num=pop();
      num2=pop();
      push(num2-num);
    }
    else if(wd[0] == '*'){
    num=pop();
    num2=pop();
    push(num2*num);
    }
    else {
      num = atoi(wd);
      push(num);
    }
  }
  i++;
  
  printf("%d\n",pop());
  return 0;
}

void push(int num){
  stack[top] = num;
  top++;
}

int pop(void){
  top--;
  return stack[top];
}



Measured memory_bytes: 2052
#include <stdio.h>

using namespace std;

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

long max(long l, long r) {
    return l > r ? l : r;
}

int main() {
    // a, b は N 以下
    // a を b で割った余りが K 以上

    long N, K;
    scanf("%ld %ld", &N, &K);

    if (K == 0) {
        printf("%ld\n", N * N);
        return 0;
    }

    long ans = 0;
    rep(1, b, N) {
        long p = N / b;
        ans += p * max(0, b - K);
        long r = N % b;
        ans += max(0, r - K + 1);
    }

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

    return 0;
}


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

int main()
{
	int a, b;
	char op;
	
	while(1)
	{
		cin >> a >> op >> b;
		if(op == '?') break;
		
		if(op == '+')
		    cout << a + b << endl;
		else if(op == '-')
		    cout << a - b << endl;
		else if(op == '*')
		    cout << a * b << endl;
		else if(op == '/')
		    cout << a / b << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

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

    string s;
    cin>>s;
    bool flag=0;
    for(int i=1;i<s.size();i++)
    {
        if(s[i]==s[i-1])
        {
            flag=1;
            cout<<i<<" "<<i+1<<endl;
            break;
        }
        else if(i>1 && s[i]==s[i-2])
        {
            flag=1;
            cout<<i-1<<" "<<i+1<<endl;
            break;
        }
    }
    if(flag==0)
        cout<<"-1 -1"<<endl;

    return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll S;
  cin >> S;
  ll x1, y1, x2 = 1000000000, y2 = 1;
  x1 = (x2 - S % x2) % x2;
  y1 = (S + x1) / x2;
  printf("0 0 1000000000 1 %lld %lld\n", x1, y1);
  return 0;
}

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

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
int dy8[] = {0,1,1,1,0,-1,-1,-1};
int dx8[] = {1,1,0,-1,-1,-1,0,1};

/*==================================================*/
/*variable*/
string S;
int K;
/*==================================================*/
/*function*/

/*==================================================*/

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

    priority_queue<string> v;
    set<string> st;
//    REP(i,0,S.size()){
//        REP(j,1,S.size()-i+1){
//
//            if(v.size() == K){
//                if(v.top() > S.substr(i, j)) {
//                    if(st.find(S.substr(i, j)) == st.end()) {
//                        v.pop();
//                        v.push(S.substr(i, j));
//                        st.insert(S.substr(i, j));
//                    }
//                }else{
//                    break;
//                }
//            }else{
//                if(st.find(S.substr(i, j)) == st.end()) {
//                    v.push(S.substr(i, j));
//                    st.insert(S.substr(i, j));
//                }
//            }
//
//        }
//    }
//    cout<<v.top()<<endl;

    vector<string> sv;
    REP(i,0,S.size()){
        REP(j,1,min((int)S.size()-i+1, K+1)){
            if(st.find(S.substr(i, j)) == st.end()) {
                sv.push_back(S.substr(i, j));
                st.insert(S.substr(i, j));
            }
        }
    }
    sort(sv.begin(), sv.end());
    cout<<sv[K-1]<<endl;

//    REP(i,0,sv.size()){
//        cout<<""<<sv[i]<<endl;
//    }

    return 0;
}


Measured memory_bytes: 2432
def main():
  N = int(input())
  A = [0] + [int(_) for _ in input().split()] + [0]
  l = 0
  for i in range(N+1):
    l += abs(A[i+1] - A[i])
  for i in range(1, N+1):
    print(l - abs(A[i]-A[i-1]) - abs(A[i+1]-A[i]) + abs(A[i+1]-A[i-1]))

if __name__ == '__main__':
  main()
  

Measured memory_bytes: 14048
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
	char S[11];
 	char T[11];
  
  scanf("%s %s",S,T);
  int a,b;
  scanf("%d %d",&a,&b);
  char U[11];
  scanf("%s",U);
  if(strcmp(S,U)==0){
	  printf("%d %d",a-1,b);
  }else{
	  printf("%d %d",a,b-1);
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ll n;
	cin>>n;
	ll A[n][3];
	for(int i=0;i<n;i++){
		cin>>A[i][0]>>A[i][1]>>A[i][2];
	} 	
	
	ll dp[n+1][3];
	dp[0][0]= A[0][0];
	dp[0][1]= A[0][1];
	dp[0][2]= A[0][2];
	
	for(int i=1;i<n;i++){
		dp[i][0]= max(dp[i-1][1],dp[i-1][2])+A[i][0];
		dp[i][1]= max(dp[i-1][0],dp[i-1][2])+A[i][1];
		dp[i][2]= max(dp[i-1][0],dp[i-1][1])+A[i][2];
	}	
	ll ans= max(dp[n-1][0],dp[n-1][1]);
	ans= max(ans, dp[n-1][2]);
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 8236
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String A = sc.nextLine();
		String B = sc.nextLine();

		String[] a = A.split("");
		String[] b = B.split("");


		//System.out.println(Arrays.toString(a));
		if (a[0].equals(b[2]) && a[2].equals(b[0])){
			if(a[1].equals(b[1])){
				System.out.println("YES");
			}
			else{
				System.out.println("NO");
			}
		}
		else{
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21972
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main(){
	string b;
	cin >> b;
	if (b == "A"){
		cout << "T";
	}
	else if (b == "T"){
		cout << "A";
	}
	else if (b == "G"){
		cout << "C";
	}
	else cout << "G";
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readIntBS = fst . fromJust . BS.readInt

main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]

  a <- all (\l -> even $ length l) . group . sort . concat . map (map readIntBS . BS.words) . BS.lines <$> BS.getContents :: IO Bool
  
  putStrLn $ if a then "YES" else "NO"


Measured memory_bytes: 31100
n, k = map(int, input().split())
from collections import defaultdict
dic = defaultdict(lambda : 0)
for a in input().split():
    a = int(a)
    dic[a] += 1
diff = len(dic.keys()) - k
if n == k or diff <= 0:
    print(0)
else:
    count = sum(sorted(dic.values())[:diff])
    print(count)

Measured memory_bytes: 41508
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    double d,t,s;
    cin >> d >> t >> s;

    if(d/t > s){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 3720
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;
    if (a + b < 10) {
        cout << a + b << endl;
    }
    else {
        cout << "error" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int w,h,x,y,r;
    scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
    if(x>=r&&y>=r&&(w-r)>=x&&((h-r)>=y))
    printf("Yes\n");
    else
    printf("No\n");
    return 0;
}




Measured memory_bytes: 2128
K = int(input())

minMax = list(map(int,input().strip().split()))

A = minMax[0]
B = minMax[1]

a = list(range(A,B+1)) 

b = list(map(lambda x: x % K, a))

if 0 in b:
     print("OK")
else:
     print("NG")

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

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

// ========================================================================= //

const int N = 100179;

int main() {
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    if (sz(s) == 26) {
        set<char> have(all(s));
        if (is_sorted(all(s), greater<char>())) {
            cout << "-1\n";
        } else {
            while (true) {
                have.erase(s.back());
                s.pop_back();
                for (char c = s.back() + 1; c <= 'z'; ++c)
                    if (!have.count(c)) {
                        s.back() = c;
                        cout << s << "\n";
                        return 0;
                    }
            }
        }
    } else {
        set<char> have(all(s));
        char c;
        for (c = 'a'; have.count(c); ++c);
        s += c;
        cout << s << "\n";
    }

    return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, long long T, std::vector<long long> t){
    LL ans = T;
    sort(ALL(t));
    REP(i, N-1) {
        if (t[i] + T < t[i+1]) {
            ans += T;
        } else {
            ans += t[i+1] - t[i];
        }
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long T;
    scanf("%lld",&T);
    std::vector<long long> t(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&t[i]);
    }
    solve(N, T, std::move(t));
    return 0;
}


Measured memory_bytes: 1792