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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, z, w; std::cin >> n >> z >> w;
  vi a(n); rep(i, n) std::cin >> a[i];
  ll ans = abs(w - a[n-1]);
  if (n > 1) chmax(ans, 1ll*abs(a[n-1] - a[n-2]));
  std::cout << ans << "\n";
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int f = sc.nextInt();
		Set<Integer> waters = new HashSet<>();
		Set<Integer> sugers = new HashSet<>();
		for(int i = 0 ; i <= f ; i++) {
			for(int j = 0 ; j <= f ; j++) {
				if(i * 100 * a + j * 100 * b <= f) waters.add(i * 100 * a + j * 100 * b);
			}
		}
		for(int i = 0 ; i <= f ; i++) {
			for(int j = 0 ; j <= f ; j++) {
				if(i * c + j * d <= f) sugers.add(i * c + j * d);
			}
		}
		int w = 1;
		int s = -1;
		for(int water : waters) {
			for(int suger : sugers) {
				if(water + suger <= f && e * water >= 100 * suger && suger * w > water * s) {
					w = water;
					s = suger;
				}
			}
		}
		System.out.println(s + w + " " + s);
	}
}

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

using namespace std;

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

  string s, sol;
  cin >> s;
  for (auto &ch : s) {
    if (ch == '0') sol += '0';
    if (ch == '1') sol += '1';
    if (ch == 'B' && !sol.empty()) sol.pop_back();
  }
  cout << sol << "\n";

}


Measured memory_bytes: 764
N = int(input())
S=[""]*N
P=[0]*N
num = [0]*N

for i in range(N):
    tmp,tmp2 = input().split()
    S[i] = tmp 
    P[i] = 100 - int(tmp2)
    num[i] = i+1

user =  list(zip(num,S,P))

test = sorted(user,key = lambda x:(x[1],x[2]))

for i in range(N):
    print(test[i][0])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dd(x) cout << #x << "=" << x << ","
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b-1);i>=a;--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl "\n"
#define lowbit(x) x&(-x)
const int N = 20000;
const int M = 1e9+7;

ll a[200010];
map<ll,ll> ap;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	int n;
	cin>>n;
	for (int i=1; i<=n; i++) cin>>a[i];
	ll ans=0;
	for (int i=1; i<=n; i++){
		ans+=ap[i-a[i]];
		ap[a[i]+i]++;
	}
	cout<<ans;
	return 0;
}


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

typedef long long ll;
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(c) c.begin(),c.end()
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
#define pu push
#define pb push_back
ll f_min(ll a,ll b){
    return (a>b)?b:a; 
}
ll f_max(ll a,ll b){
    return (a>b)?a:b;
}
ll f_abs(ll a){
    return abs(a);
}
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
const ll MOD = 1000000007;
const int inf = 1000000001;
const ll INF = 1e16;
ll i,j,k;


int main(){
    fio();
    ll num;
    cin>>num;
    long double x = num/3.0;
    long double ans = x*x*x;
    cout << setprecision(12) <<fixed<< ans << '\n';
}

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

int main(){
  int A,B;
  cin >> A >> B;
  bool a=false;
  for(int i=12;i<1000;i++){
    int C=i+1;
    int D=C*0.08,E=C*0.1;
    if(A==D && B==E){
      a=true;
      cout << C << endl;
      break;
    }
  }
  if(!a){
    cout << -1 << endl;
  }
}    

Measured memory_bytes: 3660
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,s,a[100005];
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2;
}

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

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	ll N;
	cin >> N;
	vector<ll> A(5);
	cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
	cout << N / *min_element(A.begin(), A.end()) - (N % *min_element(A.begin(), A.end()) == 0) + 5 << endl;
}


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

int main() {
    vector<vector<int>> c(3, vector<int>(3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c.at(i).at(j);
        }
    }
    for (int i = 0; i < 3; i++) {
        if (c.at(0).at(i % 3) - c.at(0).at((i + 1) % 3) != c.at(1).at(i % 3) - c.at(1).at((i + 1) % 3)
        || c.at(1).at(i % 3) - c.at(1).at((i + 1) % 3) != c.at(2).at(i % 3) - c.at(2).at((i + 1) % 3)
        || c.at(i % 3).at(0) - c.at((i + 1) % 3).at(0) != c.at(i % 3).at(1) - c.at((i + 1) % 3).at(1)
        || c.at(i % 3).at(1) - c.at((i + 1) % 3).at(1) != c.at(i % 3).at(2) - c.at((i + 1) % 3).at(2)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

using namespace std;

struct Data{
    string place;
    int point;
    int No;
};

int main(void){
    int n; cin >> n;
    vector<Data> S(n);
    for(int i=0;i<n;i++){
        cin >> S[i].place >> S[i].point;
        S[i].No = i+1;
    }

    for(int i=0;i<n-1;i++){    
        for(int j=0;j<n-1;j++){
            if(S[j].place>S[j+1].place){
                Data alt;
                alt = S[j];
                S[j] = S[j+1];
                S[j+1] = alt; 
            }
        }
    }
    for(int i=0;i<n-1;i++){    
        for(int j=0;j<n-1;j++){
            if(S[j].place==S[j+1].place){
                if(S[j].point<S[j+1].point){
                    Data alt;
                    alt = S[j];
                    S[j] = S[j+1];
                    S[j+1] = alt;
                }
            }
        }
    }
    for(int i=0;i<n;i++){
        cout << S[i].No << endl;
    }
    return 0;    
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>

#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int INF = 10e7;

int main() {
  int h, w;
  cin >> h >> w;
  int p[h + 2][w + 2];
  char a;
  for (int i = 0; i < w + 2; i++) {
    cout << "#";
  }
  cout << endl;

  for (int i = 0; i < h; i++) {
    cout << "#";
    for (int j = 0; j < w; j++) {
      cin >> a;
      cout << a;
    }
    cout << "#" << endl;
  }
  for (int i = 0; i < w + 2; i++) {
    cout << "#";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {

    char s[15];
    char ans[15];
    int n;
    int pos;
    int i;

    pos = 0;

    scanf("%s", s);

    n = strlen(s);
    for(i =0; i < n; i++) {
        if(s[i] == '0') ans[pos++] = '0';
        else if(s[i] == '1') ans[pos++] = '1';
        else {
            if(pos !=0) pos--;
        }
    }

    for(i =0; i < pos; i++) printf("%c", ans[i]);
    printf("\n");

    return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+9;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}


//************************************************************************//

//型を決めてね！！！！！！！！！！！
typedef ll MatType;

//演算の単位元も決めてね！！！！！！！！！！！！！！
const MatType plus_base = 0;
const MatType mul_base = 1;

typedef vector <MatType> Vec;
typedef vector <Vec> Mat;

//A * B = C
Mat mul(const Mat &A, const Mat &B)
{
	//大前提
	assert((int)A[0].size() == (int)B.size());

	Mat C((int)A.size(), Vec((int)B[0].size(), plus_base));

	//メモリへのアクセス的にこうしたほうが早いのです
	rep((int)A.size(), i) rep((int)B.size(), k) rep((int)B[0].size(), j)
	{
		C[i][j] += A[i][k] * B[k][j] % MOD;
		C[i][j] %= MOD;
	}

	return C;
}

// v' = A * v
//オーバーロードしているんです！！！！！！！！！！！！
Vec mul(const Mat &A, const Vec &v)
{
	//大前提
	assert((int)A[0].size() == (int)v.size());

	Vec nv((int)A.size(), plus_base);

	rep((int)A.size(), i) rep((int)v.size(), j)
	{
		nv[i] += A[i][j] * v[j] % MOD;
		nv[i] %= MOD;
	}

	return nv;
}

// A ^ N
Mat mpow(Mat A, ll N)
{
	//大前提
	assert((int)A[0].size() == (int)A.size() && N >= 0);

	Mat Res((int)A.size(), Vec((int)A.size(), plus_base));

	// A ^ 0 = E
	rep((int)A.size(), i)
	{
		Res[i][i] = mul_base;
	}

	while(N)
	{
		if (N & 1)
		{
			Res = mul(Res, A);
		}
		A = mul(A, A);
		N >>= 1;
	}

	return Res;
}

//************************************************************************//

void solve(void){
	int W, N; ll H;
	int cnt = 1;
	while(cin >> W >> H >> N)
	{
		if (!W) break;

		//obs (h, w)
		vector <P> obs(N);
		rep(N, i) cin >> obs[i].snd >> obs[i].fst;
		sort(all(obs));

		Vec V(W, 0);
		V[0] = 1;

		ll acc = 0;

		for (auto p : obs)
		{
			ll n = p.fst - 1 - acc;

			Mat M(W, Vec(W, 0));
			rep(W, i) M[i][i] = 1;
			rep(W-1, i) M[i+1][i] = 1;
			rep(W-1, i) M[i][i+1] = 1;

			M = mpow(M, n);
			V = mul(M, V);
			acc += n;
			V[p.snd-1] = 0;
		}

		Mat M(W, Vec(W, 0));
		rep(W, i) M[i][i] = 1;
		rep(W-1, i) M[i+1][i] = 1;
		rep(W-1, i) M[i][i+1] = 1;

		V = mul(mpow(M, H - acc - 1), V);

		cout << "Case " << cnt++ << ": " <<  V[W-1] << endl;

	}
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



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

int main(){
    ll h,w;
    cin >> h >> w;
    ll l,r;

    multiset <ll> mu;
    rep(i,w){
        mu.insert(0);
    }
    map <ll,ll> ma;
    rep(i,w){
        ma[i]=i;
    }

    ll k=0;
    vector <ll> ans(h);

    
    
    rep(i,h){
        cin >> l >> r;
        --l;
        --r;
        k=0;

        //cout << 12 << endl;
        auto it=ma.lower_bound(l);
        auto it2=ma.lower_bound(l);
        ll it3,it4=-1;

        //cout << 12 << endl;
        
        while(it->first <=(r+1) and it!=ma.end()){
            //cout << ma.size() << " " << it->first << endl;
            
            //cout << 2 << endl;
            mu.erase(mu.find((it->first)-(it->second)));
            //cout << 3 << endl;
            it3=it->first;
            it4=max(it4,it->second);
            
            ma.erase(it++);
            k=1;
            //cout << 1  << endl;
        }

        //cout << 0 << endl;


        if(k==1 and r<(w-1)){
            //it--;
            //ma.insert(r+1,it->second);
            //cout << 11 << endl;
            
            
            ma[r+1]=it4;
            
            //cout << 12 << endl;
            //cout << r+1-it3 << endl;    
            mu.insert(r+1-it4);
            
            //cout << 13 << endl;   
        }

        //cout << 10 << endl;

        if(mu.size()==0){
            ans[i]=-1;
        }
        else{
            
            ans[i]=(*mu.begin())+(i+1);
        }

        //cout << *mu.begin() << endl;
    }

    rep(i,h){
        cout << ans[i] << endl;
    }
    

    return 0;
}

Measured memory_bytes: 26756
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define F first
#define S second
//#define int long long

///My functions

//Constants
const int mxn = 3*1e5+5, inf = 1e9+7, mod = 1e9+7;
const long long infLL = 1e18+5;
const double EPS = 1e-9 , PI = acos(-1);

//Structs

//Variables
int n,m,Q,k,a,b,c,sum,ans,MAXans,MINans,sc,pos,acc[mxn],racc[mxn],ar[mxn],N1,M1,N2,M2;
vector<int>v,g[mxn];
bitset<mxn>flag;
bool sol ;
string s;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> N1 >> M1 >> N2 >> M2 >> k ;

    N1 *= 60 ; N2 *= 60 ; 

    M1 += N1 ; M2 += N2 ;

    if( M2 - k < M1 ) cout << 0 ;  

    else cout << ( ( M2 - k ) - M1 ) ;






    return 0;
}
























Measured memory_bytes: 10688
# inp.readline()
# int(inp.readline())
# out.write()
# raw_input()
# map(int,raw_input().split())
# map(int,inp.readline().split())
# for _ in xrange(input()):
# print "Case #"+str(_+1)+": "+ 
if __name__ == "__main__":
    from sys import stdin as inp, stdout as out,setrecursionlimit as srl
    from collections import Counter,defaultdict,deque
    from heapq import *
    for _ in xrange(1):
        n,k=map(int,inp.readline().split())
        a=[map(int,inp.readline().split()) for i in xrange(k)]
        b=[0]*(n+1)
        b[1]=1
        mod=998244353
        for i in xrange(2,n+1):
          b[i]=b[i-1]
          for l,r in a:
            b[i]=(b[i]+b[max(0,i-l)]-b[max(0,i-r-1)])%mod
        print (b[-1]-b[-2])%mod

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

int32_t main(){
    int n,d;cin>>n>>d;
    int a[n][d];
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin>>a[i][j];
        }
    }
    int count=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int x=0;
            for(int k=0;k<d;k++){
                x+=pow(a[i][k]-a[j][k],2);
            }
            int y=sqrt(x);
            if(y*y==x){
                count++;
            }
        }
    }
    cout<<count<<endl;


    return 0;
}

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

typedef long long ll;

const int M = (int)3e3;
const ll mod = (ll)998244353;

int a[M + 5];
int dp[M + 5][M + 5];
int sum[M + 5];

int main()
{
    int n, s; scanf("%d %d", &n, &s);
    for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    int ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        dp[i][a[i]] = i;
        for(int j = s; j >= a[i]; --j) dp[i][j] = (dp[i][j] + sum[j - a[i]]) % mod, sum[j] = (sum[j] + dp[i][j]) % mod;
        ans = (ans + 1ll * dp[i][s] * (n - i + 1)) % mod;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 35456
#include<stdio.h>
  
int main()
{
  int t[4][14];
  int n, i,j,c;
  char m, d;
  for(i=0; i < 4; i++){
    for(j=0; j < 14; j++){
      t[i][j]=0;
    }
  }
 scanf("%d", &c);
  for(i = 0; i < c; i++){
    scanf("%c", &d);
    scanf("%c %d", &m, &n);
    if(m == 'S'){
      t[0][n] = 1;
    }
    else if(m == 'H'){
      t[1][n] = 1;
    }
    else if(m == 'C'){
      t[2][n] = 1;
    }
    else if(m == 'D'){
      t[3][n] = 1;
    }
  }
  for(j=1; j < 14; j++){
    if(t[0][j] != 1){
      printf("S %d\n", j);
    }
  }
  
 for(j=1; j < 14; j++){
    if(t[1][j] != 1){
      printf("H %d\n", j);
    }
  }
  
 for(j=1; j < 14; j++){
    if(t[2][j] != 1){
      printf("C %d\n", j);
    }
  }
  
 for(j=1; j < 14; j++){
    if(t[3][j] != 1){
      printf("D %d\n", j);
    }
  }
 return 0;
}


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

using namespace std;

int main()
{
	string s;
	cin >> s;
	int k;
	cin >> k;
	set<string> L;
	for (int i = 0; i < (int)s.length(); ++i)
	{
		for (int j = i + 1; j <= min((int)s.length(), i + k); ++j)
		{
			string sub = s.substr(i, j - i);
			L.insert(sub);
		}
	}
	auto iter = L.begin();
	for (int i = 0; i < k - 1; ++i)
	{
		iter++;
	}
	cout << *iter << endl;
}

Measured memory_bytes: 1664
from math import pow

MOD = int(pow(10, 9)) + 7


class ModFactorial:
    def __init__(self, n):
        self._table = [0] * (n + 1)
        self._table[0] = 1
        for i in range(1, n + 1):
            self._table[i] = mod_mul(self._table[i - 1], i)

    def factorial(self, n):
        return self._table[n]


def mod_mul(n, m):
    return n * m % MOD


N, M = map(int, input().split(' '))

if abs(N - M) > 1:
    print(0)
else:
    f = ModFactorial(max(N, M))
    c = mod_mul(f.factorial(N), f.factorial(M))

    if N == M:
        c = mod_mul(c, 2)

    print(c)


Measured memory_bytes: 12928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans;
int hi;

bool fnc(ll n)
{
    int chk[10] = {};

    while (n) {
        int rem = n % 10;
        chk[rem] = 1;
        n /= 10;
    }

    if (chk[3] && chk[5] && chk[7]) return true;

    return false;
}

void dfs(ll n)
{
    if (n > hi) return;

    if (fnc(n)) ans++;

    dfs(n*10 + 3);
    dfs(n*10 + 5);
    dfs(n*10 + 7);
}

int main()
{
    scanf("%d", &hi);

    dfs(0);

    cout << ans << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, M, X, Y) = readLine()!!.split(" ").map(String::toInt)
    var x = readLine()!!.split(" ").map(String::toInt)
    var y = readLine()!!.split(" ").map(String::toInt)


    if (x.max()!! >= y.min()!!) {
        println("War")
        return
    }

    for (i in x.max()!! + 1..y.min()!!) {
        if (i in (X + 1)..Y) {
            println("No War")
            return
        }
    }

    println("War")

}

Measured memory_bytes: 38000
#include <iostream>
using namespace std;
int main() {
    string s,t,u;
    int a,b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(s==u){
        a=a-1;
    }
    if(t==u){
        b=b-1;
    } 
    cout<<a<<" "<<b;
}

Measured memory_bytes: 256
from collections import deque as dq
N,K = map(int,input().split())
td = [list(map(int, input().split())) for _ in range(N)]
td.sort(key=lambda x:x[1],reverse=True)
ls = set()
dl = dq()
ans = 0
for i in range(K):
    ans += td[i][1]
    if not td[i][0] in ls:
        ls.add(td[i][0])
    else:
        dl.append(td[i][1])
ans = ans + len(ls)**2
res = ans
for i in range(K,N):
    if not dl:
        break
    if td[i][0] in ls:
        continue
    ans -= dl[-1]
    ans -= len(ls)*len(ls)
    ls.add(td[i][0])
    ans += len(ls)*len(ls)
    ans += td[i][1]
    del dl[-1]
    res = max(res,ans)
print(res)


Measured memory_bytes: 68184
#include <iostream>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))

using namespace std;
using ll = long long;

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

    int cnt = 0;
    rep(i, n) {
        while (true) {
            if (a[i] % 2 == 0) {
                a[i] /= 2;
                cnt++;
            } else {
                break;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 384
// 126_D_Even_Relation.cpp : This file contains the 'main' function. Program execution begins and ends there.
//


//回答方針
//1.頂点を任意に1点（pとする）選んで、その点から他の点への距離を計算する。
//2.1.で計算した距離をもとに、頂点を2つのグループへ分ける。
//    pからの距離が偶数
//    pからの距離が奇数
//3.2で分けた各グループに色を1色ずつ振り分ける。

#include <iostream>
#include <vector>

using namespace std;

typedef pair<int, int> nodeAndWeight;

void calcDistance(int target, int parent, vector<nodeAndWeight>* nodes, int* distanceFromRoot)
{
	//根から親までの距離
	int distanceFromRootToParent = 0;
	if (parent != 0)
	{
		distanceFromRootToParent = distanceFromRoot[parent];
	}

	//親から自身までの距離
	int distanceFromParent = 0;
	for (nodeAndWeight i : nodes[target])
	{
		if (i.first == parent)
		{
			distanceFromParent = i.second;
		}
	}

	//根から自身までの距離を計算
	distanceFromRoot[target] = distanceFromRootToParent + distanceFromParent;

	//子を再帰
	for (nodeAndWeight i : nodes[target])
	{
		if (i.first != parent)
		{
			calcDistance(i.first, target, nodes, distanceFromRoot);
		}
	}
}


int main()
{
	//頂点数
	int n = 0;
	cin >> n;
	
	//木の枝を管理する配列
	//2次元配列で管理したいが、1<=N<=10^5のため、最大10^10個の要素が必要になり、メモリが足りない。
	vector<nodeAndWeight> *nodes = new vector<nodeAndWeight>[n+1];
	for (int i = 1; i < n; i++)
	{
		int u, v, w = 0;
		cin >> u >> v >> w;

		nodeAndWeight a;
		a.first = v;
		a.second = w;
		nodes[u].push_back(a);

		nodeAndWeight b;
		b.first = u;
		b.second = w;
		nodes[v].push_back(b);
	}

	//根の決定（どこからでもよい）
	int root = 1;
	int* distanceFromRoot = new int[n + 1]();

	//距離の計算
	calcDistance(root, 0, nodes, distanceFromRoot);

	//距離の偶奇でグループ分け
	for (int i = 1; i <= n; i++)
	{
		if (distanceFromRoot[i] % 2 == 0)
		{
			cout << 0 << endl;
		}
		else
		{
			cout << 1 << endl;
		}
	}

	return 0;
}


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

int main(){
    int a,b; cin >> a >> b;
    int count = 0;

    for (int i=1;i<=a;i++){
        if (i!=a){
            for (int j=1;j<31;j++){
                if (i==j){
                    count++;
                }
            }
        } else {
            for (int j=1;j<=b;j++){
                if (i==j){
                    count++;
                }
            }
        }


    }
    cout << count << endl;
    return 0;
}

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

int main() {
  long N,A,B,C,D,E;;
  cin >> N >> A >> B >> C >> D >> E;
  long slow = min(min(A,B),min(C,min(D,E)));
  cout << (N + slow - 1) / slow + 4 << endl;
}

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

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    int ans[4] ={0};
    for(int i = 0; i < N; i++){
        string s;
        cin >> s;

        if(s == "AC") ans[0]++;
        if(s == "WA") ans[1]++;
        if(s == "TLE") ans[2]++;
        if(s == "RE") ans[3]++;
    }

    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", ans[0], ans[1], ans[2], ans[3]);
    return 0;
}

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

int main(){
  long long n;
  cin >> n;
  
  long long x = n;
  string s = "";
  char c;
  
  while(n>26){
    x = n % 26;
    if(x==0){
      c = 'z';
      n -= 26;
    }
    else
      c = 'a' + x - 1;
    s = c + s;
    n /= 26;
  }
  

  c = 'a' + n - 1;
  s = c + s;
  
  
  cout << s << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=105,M=19,p=998244353,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,ga[1<<(M+1)];
int *g[M+1];
bitset<N> bit[N];
unordered_map<bitset<N>,int> h[N];
void check(int &x,int y){x=(x+y<p) ? (x+y) : (x+y-p);}
int pl(int x,int y){return (x+y<p) ? (x+y) : (x+y-p);}
char ch[N];
void reset(){
	n=100;
	for (int i=0;i<=M;i++) g[i]=ga+(1<<i);
	for (int i=1;i<n;i++)
	for (int j=0;j<i;j++) bit[i][j]=1;
	n=0;
}
int calc(int n,bitset<N> a){
	if (n<=M){
		int t=0;
		for (int i=0;i<n;i++)
		if (a[i]) t+=1<<i;
		return g[n][t];
	}
	if (h[n].count(a)) return h[n][a];
	int ans=calc(n-1,a>>1)*(1+a[0])%p;
	bitset<N> cur,res;
	for (int d=1;d*2<=n;d++){
		cur=a&bit[d];res=a>>d;int l=n-d;
		while (l>=d){
			l-=d;
			cur&=res;res>>=d;
			check(ans,(ll)calc(d,cur)*calc(l,res)%p);
		}
	}
	return h[n][a]=ans;
}
int main(){
	reset();
	g[0][0]=1;
	for (int i=1;i<=M;i++)
	for (int k=0;k<(1<<i);k++){
		check(g[i][k],g[i-1][k>>1]*((k&1)+1)%p);
		for (int d=1;d*2<=i;d++){
			int cur=k&((1<<d)-1),res=k>>d,l=i-d;
			while (l>=d){
				l-=d;
				cur&=res;res>>=d;
				check(g[i][k],(ll)g[d][cur]*g[l][res]%p);
			}
		}
	}
	
	scanf("%s",ch);
	n=strlen(ch);
	
	bitset<N> t;t.reset();
	for (int i=0;i<n;i++) t[i]=(ch[i]=='1');
	printf("%d\n",calc(n,t));
	return 0;
}

Measured memory_bytes: 5120
N = int(input())

ans = 0
c = [[0]*10 for i in range(10)]

for i in range(N):
	n = str(i+1)
	c[int(n[0])][int(n[-1])] += 1

for i in range(10):
	for j in range(10):
		ans += c[i][j]*c[j][i]

print(ans)

Measured memory_bytes: 3060
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <regex>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

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

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007

LL a[8][1000];
int main() {
	int n, m;
	LL xyz[3];
	cin >> n >> m;
	REP(i, n) {
		REP(j, 3)cin >> xyz[j];
		REP(j, 8) {
			if (j & 1)a[j][i] += xyz[0];
			else a[j][i] -= xyz[0];
			if (j & 2)a[j][i] += xyz[1];
			else a[j][i] -= xyz[1];
			if (j & 4)a[j][i] += xyz[2];
			else a[j][i] -= xyz[2];
		}
	}
	REP(i, 8)sort(a[i], a[i] + n, greater<LL>());
	LL ret = 0;
	REP(i, 8) {
		LL sum = 0;
		REP(j, m)sum += a[i][j];
		ret = max(ret, sum);
	}
	cout << ret << endl;
	return 0;
}

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

const int MOD = 1000000007;
long long int POW(int a,int n){
	long long int r;
	if(n==0)return 1;
	r=POW(a,(n-n%2)/2)%MOD;
	r=(r*r)%MOD;
	if(n%2)r=(a*r)%MOD;
	
	return r;
}
long long int COM(int n,int k){
	long long int p=1,q=1;
	for(int i=n;i>n-k;i--)p=(p*i)%MOD;
	for(int i=2;i<=k;i++)q=(q*i)%MOD;
	return (p*POW(q,MOD-2))%MOD;
}
int main(){
	long long int n,a,b;
	cin>>n>>a>>b;
	cout<<(POW(2,n)-1-COM(n,a)-COM(n,b)+2*MOD)%MOD;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    /*ここから下は初めの最短ルート*/
        for (int i = 0; i < ty - sy; i++) {
            cout << "U" << flush;
        }

        for (int i = 0; i < tx - sx; i++) {
        cout << "R" << flush;
        }
    /*以下はじめの復路*/
        for (int i = 0; i < ty - sy; i++) {
        cout << "D" << flush;
        }
        for (int i = 0; i < tx - sx; i++) {
        cout << "L" << flush;
        }
     
    
    /*以下2回目行き*/
            cout << "LU" << flush;
            for (int i = 0; i < ty - sy; i++) {
            cout << "U" << flush;
            }
            for (int i = 0; i < tx - sx; i++) {
            cout << "R" << flush;
            }
            cout << "RD" << flush;
    /*以下2回目かえり*/
           cout << "RD" << flush;
           for (int i = 0; i < ty - sy; i++) {
            cout << "D" << flush;
         }
         for (int i = 0; i < tx - sx; i++) {
            cout << "L" << flush;
            }
            cout << "LU" << flush;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
map<int, int> mp;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a >= 13) cout << b << endl;
	else if (a <= 5) cout << 0 << endl;
	else cout << b / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 10;
int sum1[N], sum2[N];

int main()
{
    ios::sync_with_stdio(false);
    int n, t;
    cin >> n;
    for (int i = 1;i <= n;i++)
    {
        cin >> t;
        sum1[i] = sum1[i - 1] + t;
    }
    for (int i = 1;i <= n;i++)
    {
        cin >> sum2[i];
    }    
    for (int i = n - 1;i > 0;i--)
        sum2[i] += sum2[i + 1];
    int maxn = 0;
    for (int i = 1;i <= n;i++)
        maxn = max(sum1[i] + sum2[i], maxn);
    cout << maxn;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll a,b,h,m;
cin >> a >> b >> h >> m;
long double pi = 3.141592653589794626;
long double dif = 5.5 * (60 * h + m);
dif = fmodl(dif, 360);
dif = min(dif, 360 - dif);
long double theta = pi * dif / 180;
long double ans = sqrt(a * a + b * b - 2 * a * b * cos(theta));
cout << fixed << setprecision(12) << ans << endl;

}


Measured memory_bytes: 4184
#include<stdio.h>
int main ()
{
	int a, b;
	scanf("%d %d", &a, &b);
	int x, y, z, bggst;

	x = a+b;
	y = a-b;
	z = a*b;
    bggst = (x>y)?(x>z)?x:z:(y>z)?y:z;

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

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll add(ll x, ll y)
{
    x += y;
    if (x >= MOD)
        return x - MOD;
    return x;
}
ll sub(ll x, ll y)
{
    x -= y;
    if (x < 0)
        return x + MOD;
    return x;
}
ll mult(ll x, ll y)
{
    return (x * y) % MOD;
}
ll bin_pow(ll x, ll p)
{
    if (p == 0)
        return 1;
    if (p & 1)
        return mult(x, bin_pow(x, p - 1));
    return bin_pow(mult(x, x), p / 2);
}

signed main()
{
    int n;
    cin >> n;
    vector<int> a(n + 1);
    int id;
    vector<int> v(n + 1);
    REP(i, n + 1)
    {
        cin >> a[i];
        v[a[i]]++;
        if(v[a[i]]==2){
            id = i;
        }
    }
    int idx;
    for (int i = 0; i < n + 1; i++)
    {
        if(v[a[i]]==2){
            idx = i;
            break;
        }
    }

    int A = idx ;
    int C = n - id;
    int B = id - idx - 1;
   // cerr << A << B << C << endl;
    COMinit();
    for (int k = 1; k <=n+1; k++)
    {
        cout<<(COM(n-1,k)+COM(n-1,k-2)+(2*COM(n-1,k-1))%MOD-COM(A+C,k-1)+MOD)%MOD<<endl;
    }
    

    return 0;
}

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

using namespace std;

long long v[1000010];

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

    for (int i = 0; i < n; ++i)
        cin >> v[i];

    auto ver = [&] (long long dk) {
        long long cur = 0;
        for (int i = 0; i < n; ++i) {
            if(v[i] > dk) cur += v[i] / dk;
        }
        return cur <= k;
    };

    long long a = 0, b = 1e10;

    while(b - a > 1) {
        long long mid = (a + b) / 2;
        if(ver(mid)) b = mid;
        else a = mid;
    }

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


Measured memory_bytes: 5112
package main

import "fmt"

func main() {
	var n, a int
	fmt.Scanf("%d\n", &n)

	dic := map[int]int{}
	for i := 0; i < n; i++ {
		fmt.Scanf("%d\n", &a)
		dic[a]++
	}

	total := 0
	for key := range dic {
		if dic[key]%2 == 1 {
			total++
		}
	}

	fmt.Println(total)

}


Measured memory_bytes: 9668
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define ll long long int
#define llu unsigned long long int
#define N 3001
#define MOD 1000000007
using namespace std;
vector<vector<double>> dp(N,vector<double>(N,-1));
int main(){
int n;
cin>>n;
vector<double> v(n);
for(int i=0;i<n;i++){
	cin>>v[i];
}
dp[0][0]=1-v[0];
for(int i=0;i<n;i++){
	for(int j=0;j<=n;j++){
		if(i==0&&j==0)
		continue;
		
		if(j==0){
		dp[i][j]=dp[i-1][j]*(1.0-v[i]);
		continue;
		}
		if(j>i+1){
			dp[i][j]=0;
			continue;
		}
		if(i==0&&j==1){
			dp[i][j]=v[i];
			continue;
		}
		if(i+1==j){
			dp[i][j]=dp[i-1][j-1]*v[i];
			continue;
		}
		dp[i][j]=dp[i-1][j]*(1.0-v[i])+dp[i-1][j-1]*v[i];
	}
}
double sum=0.0;

for(int i=n;2*i>n;--i){
	sum+=dp[n-1][i];
}
cout<<setprecision(12)<<sum;
return 0;
}


Measured memory_bytes: 70656
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	ll l;
	int n;
	cin>>l>>n;
	ll x[200001], xr[200001];
	ll s[200001], sr[200001]; s[0]=0, sr[0]=0;
	for(int i=1; i<=n; i++){
		cin>>x[i];
		xr[n+1-i]=l-x[i];
		s[i]=s[i-1]+x[i];
	}
	for(int i=1; i<=n; i++){
		sr[i]=sr[i-1]+xr[i];
	}
	ll ans=0;
	for(int i=1; i<=n; i++){
		int p=min(i, n-i+1);
		ans=max(ans, 2*(s[i]-s[i-p])-x[i]+2*(sr[n-i]-sr[n-i-p+1]));
	}
	for(int i=1; i<=n; i++){
		int p=min(i, n-i);
		ans=max(ans, 2*(s[i]-s[i-p])+2*(sr[n-i]-sr[n-i-p])-xr[n-i]);
	}
	for(int i=1; i<=n; i++){
		swap(x[i], xr[i]);
		swap(s[i], sr[i]);
	}
	for(int i=1; i<=n; i++){
		int p=min(i, n-i+1);
		ans=max(ans, 2*(s[i]-s[i-p])-x[i]+2*(sr[n-i]-sr[n-i-p+1]));
	}
	for(int i=1; i<=n; i++){
		int p=min(i, n-i);
		ans=max(ans, 2*(s[i]-s[i-p])+2*(sr[n-i]-sr[n-i-p])-xr[n-i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6528
#include<stdio.h>

#define WH 0
#define GR 1
#define BL 2
#define MAX 100
#define IN (1<<21)

int n,M[MAX][MAX];

void Dijkstra();

int main(){
  int i,j,e,k,c,u,v;

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      M[i][j] = IN;
    }
  }
  for(i = 0 ; i  < n ; i++){
    scanf("%d%d",&u,&k);
    for(j = 0 ; j < k ; j++){
      scanf("%d%d",&v,&c);
      M[u][v] = c;
    }
  }
  Dijkstra();

  return 0;
}

void Dijkstra(){
  int minv,u,v;
  int d[MAX],color[MAX];
  int i,j;

  for(i = 0 ; i < n ; i++){
    d[i] = IN;
    color[i] = WH;
  }
  d[0] = 0;
  color[0] = GR;
  while(1){
    minv = IN;
    u = -1;
    for(i = 0 ; i < n ; i++){
      if(minv > d[i] && color[i] != BL){
        u = i;
        minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BL;
    for(v = 0 ; v < n ; v++){
      if(color[v] != BL && M[u][v] != IN){
        if(d[v] > d[u] + M[u][v]){
          d[v] = d[u] + M[u][v];
          color[v] = GR;
        }
      }
    }
  }
  for(i = 0 ; i < n ; i++){
    printf("%d ",i);
    if(d[i] == IN) printf("%d\n",-1);
    else printf("%d\n",d[i]);
  }
}



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

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

#define fr first
#define sc second

int main(){
	ll n,a,b;
	cin >> n >> a >> b;
	if((b-a)%2 == 0)cout << (b-a)/2 << endl;
	else cout << min( ((a-1)+(b-1)+1)/2 , ((n-a)+(n-b)+1)/2 ) << endl;
}

Measured memory_bytes: 256
# coding=utf-8
N = int(raw_input().rstrip())
A = {}
for i in range(N):
    a = int(raw_input())
    if a in A:
        if A[a] == 1:
            A[a] = 0
        else:
            A[a] = 1
    else:
        A[a] = 1
print sum(A.values())

Measured memory_bytes: 17084
#include <iostream>
#include <array>

int main ()
{
  int N;
  const int maxn = 200'001;
  std::cin >> N;

  int ans = 0;
  int p;
  int cur_min = maxn;
  for (int i=0; i<N; i++)
    {
      std::cin >> p;
      if (p <= cur_min)
        {
          ans++;
          cur_min = p;
        }
    }

  std::cout << ans <<std::endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static boolean isnum(char c) {
		return ('0' <= c && c <= '9');
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();

		String s1[] = new String[n];

		for (int i = 0; i < n; i++) {
			s1[i] = sc.next();
		}

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

			if (s.equals(s1[i])) {
				System.out.println('+');
				continue;
			}
			int a = 0, b = 0;
			for (a = 0, b = 0; a < s.length() && b < s1[i].length();) {
				if (isnum(s.charAt(a)) && !isnum(s1[i].charAt(b))) {
					System.out.println('+');
					break;
				}
				if (!isnum(s.charAt(a)) && isnum(s1[i].charAt(b))) {
					System.out.println('-');
					break;
				}
				if (!isnum(s.charAt(a)) && !isnum(s1[i].charAt(b))) {
					if (s.charAt(a) < s1[i].charAt(b)) {
						System.out.println('+');
						break;
					} else if (s.charAt(a) > s1[i].charAt(b)) {
						System.out.println('-');
						break;
					}
				}
				if (isnum(s.charAt(a)) && isnum(s.charAt(b))) {
					int numa = 0, numb = 0;
					while (isnum(s.charAt(a)) && a < s.length()) {
						numa *= 10;

						numa += s.charAt(a) - '0';
						a++;

						if (a == s.length()) {

							break;
						}

					}
					while (isnum(s1[i].charAt(b)) && b < s1[i].length()) {
						numb *= 10;

						numb += s1[i].charAt(b) - '0';
						b++;
						if (b == s1[i].length()) {

							break;
						}
					}

					if (numa < numb) {
						System.out.println('+');
						break;
					}
					if (numb < numa) {
						System.out.println('-');
						break;
					}
					a--;
					b--;
				}
				a++;
				b++;
				if (a < s.length() && b >= s1[i].length()) {
					System.out.println('-');
					break;
				} else if (a >= s.length() && b < s1[i].length()) {
					System.out.println('+');
					break;
				}
			}

		}

	}
}



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

using ll = long long;
using ld  = long double;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define p_b push_back
#define SZ(x) ((ll)(x).size()) //size()がunsignedなのでエラー避けに
#define endk '\n'


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //




// --------- library end - //


int main(){

  string s = is();
  if (s.find("RRR") != string::npos) cout << 3 << endk;
  else if (s.find("RR") != string::npos) cout << 2 << endk;
  else if (s.find("R") != string::npos) cout << 1 << endk;
  else cout << 0 << endk;
  

}

Measured memory_bytes: 3532
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

void solve() {
  int n, y;
  cin >> n >> y;
  for(int a = 0; a <= n; a++) {
    for(int b = 0; a + b <= n; b++) {
      int c = n-a-b;
      if(10000 * a + 5000 * b + 1000 * c == y) {
        cout << a << " " << b << " " << c << "\n";
        return;
      }
    }
  }
  cout << "-1 -1 -1\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<utility>
#include<queue>
#include<string>

using namespace std;
 
int main(void){
 
    int n,q;
	int inp;
	string inp2;
	queue<pair<string,int> > pro;
	int now=0;

	cin>>n>>q;

	for(int i=0;i<n;i++){
		cin>>inp2>>inp;
		pro.push(pair<string,int>(inp2,inp));
	}

	while(!pro.empty()){
		if(pro.front().second - q <= 0){
			now+=pro.front().second;
			cout<<pro.front().first<<" "<<now<<endl;;
			pro.pop();
		}
		else{
			now+=q;
			pro.front().second-=q;
			pro.push(pair<string,int>(pro.front().first,pro.front().second));
			pro.pop();
		}
	}

    return 0;
}

Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(_VA_ARGS_)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int =0;_<n;++)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

typedef pair<int,int> pii;
typedef long long int ll;
typedef long double ld;

const int DMAX = 2e5+10;

inline int two(int n) { return 1 << n; }
inline int test(int n, int pos) { return (bool) (n & two(pos)); }
inline void set_bit(int &n, int b) { n |= two(b); }
inline void unset_bit(int &n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }

int n,ans;

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

    int x,y,i,nr=1;

    cin>>n;
    for(i=1;i<=n;i++){
        cin>>x;
        if(x != nr)
           ans++;
        else
           nr++;
    }
    if(nr == 1)
        cout<<"-1\n";
    else
        cout<<ans<<'\n';

    return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())


def f(x):
    if x % 2 == 0:
        if x % 4 != 0:
            return 1 ^ x
        else:
            return 0 ^ x
    else:
        if (x + 1) % 4 == 0:
            return 0
        else:
            return 1


if a == 0:
    print(f(b))
else:
    print(f(b) ^ f(a - 1))



Measured memory_bytes: 2940
// ＡＢＣのＡ過去問を解くだけだよ

// フォント:Electroharmonix
// x:小文字(ｘ)    X:大文字(Ｘ)
// +:プラス(＋)    &:アンド(＆)

#include <bits/stdc++.h>

using namespace std;

void Main()
{
    string s;
    cin >> s;

    int ret = 0;
    for (int i = 0; i < 4; ++i)
    {
        if (s[i] == '+')
            ret++;
        else
            ret--;
    }

    cout << ret;
}

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

    //std::cout << std::fixed << std::setprecision(10);

#ifdef DEBUG_BUILD
    while (true)
    {
        Main();
        cout << std::endl;
    }
#endif

    Main();
    cout << endl;

    return 0;
}

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

using namespace std;

int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  vector<ll> a(n + 1), b(m + 1);
  for(int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] += a[i - 1];
  }
  for(int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    b[i] += b[i - 1];
  }
  int o = 0;
  for(int i = 0; i <= n; i++) {
    if(a[i] > k) continue;
    int m = upper_bound(b.begin(), b.end(), k - a[i]) - b.begin() - 1;
    o = max(o, m + i);
  }
  printf("%d\n", o);
}

Measured memory_bytes: 6436