akhauriyash/Code-Regression huggingface dataset:
n=int(input())
a=list(map(int,input().split()))

a.sort()

maxa=max(a)
ans=0
ch=0

for i in range(n-1):
  b=maxa-a[i]
  c=min(b,a[i])
  if c>=ch:
    ans=a[i]
    ch=c
    
print(str(maxa)+' '+str(ans))

Measured memory_bytes: 20132
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
    string m = "Monday", tu = "Tuesday", w = "Wednesday", th = "Thursday", f = "Friday",
        sa = "Saturday", su = "Sunday";
    while(1) {
        int a=0, b=0;
        cin >> a >> b;
        if(a == 0 && b == 0)
            return 0;

        switch(a) {
        case 12:
            b += 30;
        case 11:
            b += 31;
        case 10:
            b += 30;
        case 9:
            b += 31;
        case 8:
            b += 31;
        case 7:
            b += 30;
        case 6:
            b += 31;
        case 5:
            b += 30;
        case 4:
            b += 31;
        case 3:
            b += 29;
        case 2:
            b += 31;
        default:
            ;
        }
        //cout << b << ' ';
        if(b % 7 == 0)
            cout << w << endl;
        if(b % 7 == 1)
            cout << th << endl;
        if(b % 7 == 2)
            cout << f << endl;
        if(b % 7 == 3)
            cout << sa << endl;
        if(b % 7 == 4)
            cout << su << endl;
        if(b % 7 == 5)
            cout << m << endl;
        if(b % 7 == 6)
            cout << tu << endl;
    }
}


Measured memory_bytes: 3052
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

int main(){
    ll n;
    cin >> n;
    vector<ll>p(n);
    rep(i,n){
        cin>>p[i];
        p[i]--;
    }
    vector<ll>q(n);
    rep(i,n){
        ll now = p[i];
        q[now] = i;
    }
    ll l = 1;
    ll ans = 1;
    rep(i,n-1){
        if(q[i+1]>q[i]){
            l++;
            chmax(ans,l);
        }
        else{
            l = 1;
            chmax(ans,l);
        }
    }
    cout << n-ans << endl;
    return 0;
}


Measured memory_bytes: 3328
//Name: Electro-Fly
//Level: 2
//Category: 数学
//Note: 

/**
 * それぞれの座標軸について周期を求め、最小公倍数を取ればよい。
 * 周期は a^k ≡ 1 (mod m) となる最小の k>1 だが、これはシミュレーションで求められる。
 *
 * オーダーは O(M)。
 */
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>

using namespace std;

int period(int a, int m) {
    vector<int> p(m, -1);
    int cur = a % m;
    for(int i = 0; i < m; ++i) {
        if(p[cur] >= 0) return i - p[cur];
        p[cur] = i;
        cur = (cur * a) % m;
    }
    assert(false);
}

template<typename T>
T gcd(T a, T b) {
    if(a < b) swap(a, b);
    while(b > 0) {
        const T tmp = a % b;
        a = b;
        b = tmp;
    }
    return a;
}

long long lcm(long long a, long long b) {
    return a*b / gcd(a,b);
}

bool solve() {
    int a1, m1, a2, m2, a3, m3;
    cin >> a1 >> m1 >> a2 >> m2 >> a3 >> m3;
    if(!a1 && !m1 && !a2 && !m2 && !a3 && !m3) return false;

    const int p1 = period(a1, m1);
    const int p2 = period(a2, m2);
    const int p3 = period(a3, m3);
    cout << lcm(p1, lcm(p2, p3)) << endl;

    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1320
#include <stdio.h>


int main(void)
{
	int N, T;
	int c[100], t[100];
	int cmin = 1001;

	scanf("%d %d", &N, &T);

	for (int i = 0; i < N; i++){
		scanf("%d", &c[i]);
		scanf("%d", &t[i]);
		if ((cmin>c[i])&&(t[i]<=T)){
			cmin = c[i];
		}
	}

	if (cmin==1001){
		printf("TLE\n");
	}
	else{
		printf("%d\n", cmin);
	}



	return 0;
}



Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;
 
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;
 
int n,m,s[2001],t[2001],sumarray[2001]={0};

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> t[i];
    }
    int out = 1;
 
    for (int i = 0; i < m; i++) {
        int temp = 0;
        for (int j = 0; j < n; j++) {
            if (j == 0) {
                temp += sumarray[j];
                if (t[i] == s[j]) {
                    sumarray[j] += 1;
                }
            } else {
                if (t[i] == s[j]) {
                    int prev = temp + sumarray[j];
                    sumarray[j] += (temp + 1) % MOD;
                    temp = prev;
                } else {
                    temp += sumarray[j];
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        out += sumarray[i];
        out %= MOD;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3648
# coding: utf-8
# Your code here!
n,d=map(int,input().split())
x=[]
ans=0
for i in range(n):
    x.append(list(map(int,input().split())))

for i in range(n):
    for j in range(i+1,n):
        tmp=0
        for k in range(d):
            tmp+=(x[i][k]-x[j][k])**2
        if tmp**(1/2)%1==0:
            ans+=1
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<long> a;
int N, K;

long solve() {
  long answer = 0;
  for(long aa: a) answer += aa > 0 ? aa : 0;
  long z_sum = 0, sum = 0;
  long ret = 0;
  for(int i = 0; i < K; i++) {
    z_sum += max(0L, a[i]);
    sum += a[i];
  }
  for(int i = 0; i <= N - K; i++) {
    ret = max(ret, answer - z_sum);
    ret = max(ret, answer - z_sum + sum);
    if(i == N - K) break;
    z_sum -= max(0L, a[i]);
    z_sum += max(0L, a[i + K]);
    sum -= a[i];
    sum += a[i + K];
  }
  return ret;
}

int main() {
  cin >> N >> K;
  a = vector<long>(N);
  for(auto &aa: a) cin >> aa;
  long ans = solve();
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void)
{
    vector<int> r = {0, 0, 0, 0};
    int ai, bi;
    cin >> ai >> bi; r[ai -1]++; r[bi - 1]++;
    cin >> ai >> bi; r[ai -1]++; r[bi - 1]++;
    cin >> ai >> bi; r[ai -1]++; r[bi - 1]++;
    sort(r.begin(), r.end(), greater<int>());
    cout << ((r[0] <= 2) && (r[3] != 0) ? "YES" : "NO") << endl;
    return 0;
}

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

int main() {

	int n; cin >> n;
	string s; cin >> s;

	const int p = 26;
	int ans = 0;
	for (int i = 1; i < n - 1; i++) {
		vector<int> alphaNumL(p, 0);
		vector<int> alphaNumR(p, 0);

		for (int j = 0; j < i; j++) {
			alphaNumL[(int)(s[j] - 'a')] = 1;
		}
		for (int j = i; j < n; j++) {
			alphaNumR[(int)(s[j] - 'a')] = 1;
		}

		int cnt = 0;
		for (int j = 0; j < p; j++) {
			if (alphaNumL[j] == 1 && alphaNumR[j] == 1) {
				cnt++;
			}
		}
		ans = max(ans, cnt);
	}

	cout << ans << endl;
	return 0;
}

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

int main(void) {
    int N,sum;
    cin >> N;
    vector<int> A(N+2,0);
    vector<bool> bs(N+1,false);

    // 経由地点が間にあるかどうかを判定する
    sum = 0;
    for(int i=0;i<N;i++) {
        cin >> A[i+1];
        if(i) {
            // 2個前と1個前と現在を見て1個前を確定
            if(((A[i+1] >= A[i]) && (A[i] >= A[i-1]))
                || ((A[i+1] <= A[i]) && (A[i] <= A[i-1]))) {
                bs[i] = true;
            }
        }
        sum += abs(A[i+1] - A[i]);
    }

    // 最後を確定
    if(((A[N+1] >= A[N]) && (A[N] >= A[N-1]))
                || ((A[N+1] <= A[N]) && (A[N] <= A[N-1]))) {
        bs[N] = true;
    }
    sum += abs(A[N+1] - A[N]);


    for(int i=1;i<=N;i++){ 
        if(bs[i]) {
            cout << sum << endl;   
        } else {
            cout << sum - abs(A[i]-A[i-1]) - abs(A[i+1]-A[i]) + abs(A[i+1]-A[i-1]) << endl;
        }
    }
    return 0;
}


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

using namespace std;

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int N, X;
    cin >> N >> X;
    N--;
    for(int i = -1000000; i<=1000000; i++){
        if(abs(i-X) <= N){
            cout << i << " ";
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int flag;
vector <string> mozi(1000,"###");

void test(int x){
  int a=mozi.at(x-1).size();
  if(mozi.at(x-1).at(a-1)!=mozi.at(x).at(0)) flag=0;
  for(int i=0;i<x;i++){
  if(mozi.at(i)==mozi.at(x)) flag=0;
  }


}

int main(){
int N;
  cin>>N;
  //vector <string> mozi(N,"##");
  for(int i=0;i<N;i++) cin>>mozi.at(i);
  
   flag=1;
  
  for(int j=1;j<N;j++) test(j);
  
  if(flag==0) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  


return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
int main() {
    int n; cin >> n;
    int c = 0;
    while (1) {if (n - 25 >= 0) {n -= 25; c++;} else break;}
    while (1) {if (n - 10 >= 0) {n -= 10; c++;} else break;}
    while (1) {if (n - 5 >= 0) {n -= 5; c++;} else break;}
    while (1) {if (n - 1 >= 0) {n -= 1; c++;} else break;}
    cout << c << endl;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

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

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

#define LL long long
#define MAXN 10000

int main(){
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	std::vector<int> s;
	std::vector<int> w;
	for(int i=0;i<f;i++){
		for(int j=0;j<f;j++){
			int x = (i*c)+(j*d);
			if(x<=f&&x>=0){
				s.push_back(x);
			}
			int y = (i*100*a)+(j*100*b);
			if(y<=f&&y>0){
				w.push_back(y);
			}
		}
	}
	float max = 0;
	int maxx = 0;
	int maxy = 100*a;
	int m = s.size();
	int n = w.size();
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			int x = s[i];
			int y = w[j];
			if((((float)x/(float)y)<=((float)e/(float)100))&&(x+y<=f)){
				if((float)x/(float)(x+y)>(float)max){
					max = (float)x/(float)(x+y);
					maxx = x;
					maxy = y;
				}
			}
		}
	}
	if(maxy==0){
		maxy=100*a;
	}
	cout<<maxx+maxy<<" "<<maxx;
	return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>

int main(){
    
    int n;
    int w,i;
    int tmp;
    
    scanf("%d",&n);
    
    for(i=1;i<=n;i++){
        if(i%3==0){
            printf(" %d",i);
        }else{
            tmp=i;
            for(w=1000;w>=1;w=w/10){
                if(tmp/w==3){
                    printf(" %d",i);
                    break;
                }else{
                    tmp=tmp%w;
                }
            }
        }
    }
    printf("\n");

    
    return 0;
}

Measured memory_bytes: 1776
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define Max(a,b) ((a) < (b) ? (b) : (a))
#define Min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}


int main() {
	int i, j, k;
	
	int N, M, K;

	cin >> N;
	int A[100000];
	int B[100000] = { 0 };

	rep(i, 0, N) {
		int a;
		cin >> a;
		A[i] = a;
		int b = N - 1 - a;
		if (b % 2 == 1) {
			cout << 0 << endl;
			return 0;
		}
		j = b / 2;
		B[j]++;
		if (B[j] > 2) {
			cout << 0 << endl;
			return 0;
		}
	}

	if (N % 2 == 1) {
		if (B[N/2 ] != 1) {
			cout << 0 << endl;

			return 0;
		}
		M = (N - 1) / 2;
	}
	else {
		M = N / 2;
	}
	ll ans = 1;
	rep(i, 0, M) {
		ans *= 2;
		ans %= AAA;
	}
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 640
/*
 * main.cpp
 *
 *  Created on: 2011/04/01
 *      Author: satoki
 *      11:40 ~ 11:55 Accepted
 */
#include <iostream>
#include <string.h>

using namespace std;

int iMountain[10];
int iMax[3];

void init() {
  memset(iMax, 0, sizeof(iMax));
}

void input() {
  int i;
  for (i = 0; i < 10; i++) {
    scanf("%d", iMountain + i);
  }
}

void manage() {
  int i, j, k;
  for (i = 0; i < 10; i++) {
    for (j = 0; j < 3; j++) {
      if (iMax[j] < iMountain[i]) {
        for (k = 2; k > j; k--) {
          iMax[k] = iMax[k - 1];
        }
        iMax[j] = iMountain[i];
        break;
      }
    }
  }
}

int main() {
  int i;
  init();
  input();
  manage();
  for (i = 0; i < 3; i++) {
    printf("%d\n", iMax[i]);
  }
  return 0;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define MAX_N 100000

int N;
vector<int> A;

int main(){
    cin>>N;
    rep(i,N){
        int a;
        cin>>a;
        A.PB(a);
    }
    vector<int> tmp(A);
    sort(ALL(tmp));
    map<int,int> mp;
    for(int i=0;i<N;i++) mp[tmp[i]]=i;
    for(int i=0;i<N;i++) A[i] = mp[A[i]];
    map<int,int> v;
    for(int i=0;i<N;i++) v[A[i]]=i;

    int ans=0;
    for(auto m:v){
        if(m.first % 2 != m.second % 2) ans++;
    }
    cout << ans / 2 << endl;
}


Measured memory_bytes: 10360
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	string s,st="CODEFESTIVAL2016";
	cin>>s;
	int count=0;

	for (int i = 0; i < 16; i++){
		if(s[i]!=st[i])
			count++;
	}

	cout<<count<<endl;
}

Measured memory_bytes: 256
#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 <stack>
#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 PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;
LL N,M,V,P;

int check(const vector<int>& a, int vidx){
    int v=a[vidx];
    int of1=P-1;
    int of2=upper_bound(a.begin(),a.end(),v)-a.begin();
    int ar=N-P+1,al=of2,tgt=v+M;
    int alpha=V-of1-of2;
    cerr<<"\n v:"<<v<<" "<<of1<<" "<<of2<<" alpha:"<<alpha<<endl;
    if(a[N-P]<=tgt){
    }else{
        return 0;
    }
    if(alpha<=0){
        return 1;
    }
    int nn=ar-al,f=0;
    vector<int> b(nn);
    LL sm=0;
    cerr<<"al:"<<al<<" ar:"<<ar<<" nn:"<<nn<<" "<<endl;
    FOR(i,0,nn){
        b[i]=a[al+i];
        sm+=min((int)M,tgt-b[i]);
    }
    if(sm<1LL*alpha*M){
        return 0;
    }

    return 1;
}

int main(){
    LL n,m,v,p;
    cin>>n>>m>>v>>p;
    N=n;M=m;V=v;P=p;
    vector<int> a(n);
    FOR(i,0,n){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    FOR(i,0,n){
        //cerr<<a[i]<<" ";
    }
    if(check(a,0)){
        //cerr<<"all"<<endl;
        cout<<n<<endl;
        return 0;
    }
    int l=0,r=n-p;//l:ng r:ok
    int mm=(l+r+1)/2;
    while(r!=mm){
        if(check(a,mm)){
            r=mm;
        }else{
            l=mm;
        }
        mm=(l+r+1)/2;
        //cerr<<"mm:"<<mm<<endl;
    }

    cout<<n-mm<<endl;

}


Measured memory_bytes: 1044
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int A, B;
    cin >> A >> B;
    int ans = 0;
    for (int i = A; i <= B; i++) {
        string s = to_string(i);
        if (s == string(s.rbegin(), s.rend())) { ans++; }
    }
    cout << ans << endl;
}


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

using namespace std;

int main(void){
    int n, m;
    cin >> n >> m;
    if(13 <= n){
        cout << m << endl;
    }else if(6 <= n){
        cout << m/2 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    int n; cin>>n;
    cout<<n*n*n<<endl;
}

Measured memory_bytes: 256
var data = require('fs').readFileSync('/dev/stdin', 'utf8');
var input = data.trim().split("\n");
var line = 0;
while (true) {
    var nm = input[line].split(" ").map(Number);
    line++;
    var n = nm[0];
    var m = nm[1];
    if (n == 0 && m == 0)
        break;
    var infected = [];
    for (var i = 0; i < n; i++)
        infected[i] = true;
    infected[0] = false;
    var tsd = [];
    for (var i = 0; i < m; i++) {
        var packet = input[line].split(" ").map(Number);
        line++;
        tsd.push([packet[0], packet[1] - 1, packet[2] - 1]);
    }
    tsd.sort(function (a, b) {
        return a[0] - b[0];
    });
    tsd.forEach(function (packet) {
        var s = packet[1];
        var d = packet[2];
        if (!infected[s])
            infected[d] = false;
    });
    var answer = 0;
    infected.forEach(function (packet) {
        if (!packet)
            answer++;
    });
    console.log(answer);
}

Measured memory_bytes: 81592
x = int(input())
a,b = 0,0
if x // 500 >= 1:
    a = x // 500
    x = x - a*500
if x // 5 >=1:
    b = x // 5
    x = x - b*5
if a >=1 or b >=1:
    print(a*1000+b*5)
else:
    print(0)

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

const int MOD = 1000000007;

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

  vector<long long int> count(26, 1);

  for(int i=0;i<n;i++) {
    count[s[i]-'a']++;
  }

  long long int ans = 1;

  for(int i=0;i<26;i++) {
    ans = (ans * count[i]) % MOD;
  }

  cout << ans - 1LL << endl;
}

Measured memory_bytes: 512
using System;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string[] s = new string[n];
        s = Console.ReadLine().Split(' ');
        int[] a = new int[s.Length];
        for(int i = 0;i < s.Length; i++)
        {
            a[i] = int.Parse(s[i]);
        }

        int[] a2 = new int[a.Length];
        for(int i = 0;i <a.Length; i++)
        {
            a2[i] = a[a.Length - 1 - i];
        }

        for (int i = 0; i < a.Length; i++)
        {
            if(i != a.Length - 1)
            {
                Console.Write("{0} ", a2[i]);
            }
            else
            {
                Console.WriteLine("{0}", a2[i]);
            }
        }
    }
}

Measured memory_bytes: 9116
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		long K = sc.nextLong();
		long count = 0;
		char ans = '1';
		if( S.charAt(0)!='1' ){
			ans = S.charAt(0);
		}else{
			for( int i=0; i<S.length(); i++ ){
				if( S.charAt(i)=='1' ){
					count++;
				}else{
					if( count<K ){
						ans = S.charAt(i);
					}
					break;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;

ll modpow(ll a, ll b, ll p){
  ll ret = 1;
  while(b>0){
    if(b%2) ret = ret * a % p;
    a = a * a % p;
    b >>= 1;
  }
  return ret;
}

ll modncm(ll n, ll m, ll p){
  ll ret = 1, inv = 1;
  REP(i, m) ret = ret * (n-i) % p, inv = inv * (m-i) % p;
  return ret * modpow(inv, p-2, p) % p;
}

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

  REP(i, k){
    cout << modncm(n-k+1, i+1, mod) * modncm(k-1, i, mod) % mod << endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for (int &t: v)
        cin>>t, t--;
    static int C[2][100000] = {};
    for (int i=0; i<n; i++)
        C[i%2][v[i]]++;
    vector<pair<int,int>> P1, P2;
    for (int i=0; i<100000; i++)
        P1.push_back(make_pair(-C[0][i], i)),
        P2.push_back(make_pair(-C[1][i], i));
    sort(P1.begin(), P1.end());
    sort(P2.begin(), P2.end());

    int ans;
    if (P1[0].second != P2[0].second)
        ans = n + P1[0].first + P2[0].first;
    else
        ans = n + min(P1[1].first + P2[0].first, P1[0].first + P2[1].first);
    cout<<ans<<endl;
}


Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
int main(){
	set<char> S;
	for(char i='a';i<='z';i++) S.insert(i);

	string str;
	cin>>str;
	for(int i=0;i<str.size();i++){
		S.erase(str[i]);
	}

	if(S.empty()==0) cout<< (*S.begin()) <<endl;
	else cout<< "None" <<endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int n,t;
int a[1000];
int b[1000];
int main(){
	cin>>n>>t;
	rep(i,n)cin>>a[i]>>b[i];
	int ans=11451419;
	for(int i=0;i<n;i++){
		if(b[i]<=t)ans=min(ans,a[i]);
	}
	if(ans==11451419)puts("TLE");
	else cout<<ans<<endl;
	return 0;
}


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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;

void solve(int X, int Y, int P) {
    set<tuple<int, int, int, int>> ng;
    FOR(i, 0, P) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        ng.insert(make_tuple(y1, x1, y2, x2));
        ng.insert(make_tuple(y2, x2, y1, x1));
    }

    vector<vector<LL>> dp(Y + 2, vector<LL>(X + 2, 0));
    dp[0][0] = 1;
    FOR(y, 0, Y + 1) {
        FOR(x, 0, X + 1) {
            if (ng.find(make_tuple(y, x, y + 1, x)) == ng.end()) {
                dp[y + 1][x] += dp[y][x];
            }
            if (ng.find(make_tuple(y, x, y, x + 1)) == ng.end()) {
                dp[y][x + 1] += dp[y][x];
            }
        }
    }

    if (dp[Y][X] == 0) {
        print("Miserable Hokusai!");
    }
    else {
        print(dp[Y][X]);
    }
}

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

    int N;
    cin >> N;
    FOR(_, 0, N) {
        int X, Y, P;
        cin >> X >> Y;
        cin >> P;

        solve(X, Y, P);
    }
	return 0;
}


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

typedef long long LL;
LL a, b, c;

int main(){
	while(~scanf("%lld %lld %lld", &a, &b, &c)){
		if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
			puts("0");
		} else {
			printf("%lld\n", min(a*b, min(a, b)*c));
		}
	}
	return 0;
}


Measured memory_bytes: 128
n = int(input())
count = 0
t = 1
for _ in range(n):
  a, b = map(int,input().split())
  if a==b:
    count += 1
  if a!=b:
    count = 0
  if count == 3:
    t = 0
if t:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 9008
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int x, y;
    while (cin >> x >> y, x != 0 || y != 0) {
        if (x > y) swap(x, y);
        printf("%d %d\n", x, y);
    }
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

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

  int a[n];
  REP(i, n) cin >> a[i];

  int p = 1;
  while(p * (k - 1) + 1 < n) p++;

  cout << p;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[100010];
int D[100010];
int C[100010];
int B[100010];
int E[100010];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	
	D[0]=3;
	REP(i,N){
		B[i]=D[A[i]];
		D[A[i]]--;
		D[A[i]+1]++;
	}
	int ans=1;
	REP(i,N){
		ans*=B[i];
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <limits>
using namespace std;
typedef long long ll;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FOREACH(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
 
template <class T> struct MaxFlow {
   const T INF = 1e9;
   struct  Edge {
      int to,rev; T cap;
      Edge(){}
      Edge(int _to, int _rev, T _cap){
         to = _to; rev = _rev; cap = _cap;
      }
   };
   vector< vector<Edge> > G;
   vector< bool > used;
   MaxFlow(int size){
      G.resize(size+10);
      used.resize(size+10);
   }
   void add_edge(int from, int to, int cap){
      G[from].push_back(Edge(to,(int)G[to].size(),cap));
      G[to].push_back(Edge(from,(int)G[from].size()-1,0));
   }
   T dfs(int v, int t, T f){
      if(v==t)return f;
      used[v] = true;
      for(int i=0;i<G[v].size();i++){
         Edge &e = G[v][i];
         if(!used[e.to] && e.cap>0){
            T d = dfs(e.to, t, min(f,e.cap));
            if(d>0){
               e.cap -= d;
               G[e.to][e.rev].cap += d;
               return d;
            }
         }
      }
      return 0;
   }
   T getmax(int source, int sink){
      T flow = 0;
      while(true){
         for(int i=0;i<used.size();i++)used[i]=false;
         T f = dfs(source, sink, INF);
         if(f==0)return flow;
         flow += f;
      }
   }
};
 
int H,W;
char a[110][110];
 
int sx,sy;
int gx,gy;
 
MaxFlow<int> inst(20000);
set<pair<int,int> >  used;
 
int main() {
 
    cin >> H >> W;
    REP(i,H)REP(j,W) cin >> a[i][j];
 
    sx = sy = gx = gy = -1;
    REP(i,H)REP(j,W) {
        if(a[i][j] == 'S') {
            sx = j;
            sy = i;
        }
        if(a[i][j] == 'T') {
            gx = j;
            gy = i;
        }
    }
 
    if(gx == sx || gy == sy) {
        cout << -1 << endl;
        return 0;
    }

    REP(i,H)REP(j,W) {
        if(a[i][j] == 'S') {
          inst.add_edge(0,i+1000,100000);
          inst.add_edge(0,j+2000,100000);
        } else if(a[i][j] == 'T') {
          inst.add_edge(i+1000,1,100000);
          inst.add_edge(j+2000,1,100000);
        } else if(a[i][j] == 'o') {
          inst.add_edge(i+1000,j+2000,1);
          inst.add_edge(j+2000,i+1000,1);
        }
    }

    cout << inst.getmax(0,1) << endl;
 
    return 0;
}

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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const long long inf = 1e9+7;
const long long mod = 1e9+7;

int main(){
    int h,w;
    cin>>h>>w;

    vector<vector<char>>a(h,vector<char>(w));
    rep(i,h){
        rep(j,w)
            cin>>a[i][j];
    }

    vector<int>H(h,0),W(w,0);

    rep(i,h){
        rep(j,w){
            if(a[i][j]=='#'){
                H[i]=1;
                W[j]=1;
            }
        }
    }

    rep(i,h){
        if(H[i]==1){
            rep(j,w){
                if(W[j]==1){
                    cout<<a[i][j];
                }
            }
            cout<<endl;
        }
    }
}


Measured memory_bytes: 3576
def calc_temp(i):
  return T - 0.006*H[i]

N = int(input())
[T,A] = list(map(int,input().split()))
H = list(map(int,input().split()))
ans = 0
for i in range(N):
  if abs(A-calc_temp(i)) < abs(A-calc_temp(ans)):
    ans = i
print(ans+1)


Measured memory_bytes: 3060
Scanf.scanf "%d %d" (fun n k ->
    let dt = Array.init n (fun _ -> Scanf.scanf " %d %d" (fun t d -> d, t)) in
    Array.sort (fun a b -> compare b a) dt;

    let module S = Set.Make (struct type t = int       let compare = compare end) in
    let module Q = Set.Make (struct type t = int * int let compare = compare end) in

    let iset, iqueue, iscore =
        let rec loop i set queue score =
            if i = k then set, queue, score else
                let (d, t) = dt.(i) in
                if S.mem t set then loop (i + 1) set (Q.add (d, i) queue) (score + d)
                               else loop (i + 1) (S.add t set) queue (score + d)
        in
        loop 0 S.empty Q.empty 0
    in
    let ip = S.cardinal iset in
    let iscore = iscore + ip * ip in
    let rec loop i p qrest queue set curscore maxscore =
        if i = n || qrest = 0 then maxscore else
            let (d, t) = dt.(i) in
            if S.mem t set then loop (i + 1) p qrest queue set curscore maxscore else
                let q = Q.min_elt queue in
                let queue = Q.remove q queue in
                let curscore = curscore - fst q in
                let curscore = curscore + d + 2 * p + 1 in
                loop (i + 1) (p + 1) (qrest - 1) queue (S.add t set) curscore (max maxscore curscore)
    in
    loop k ip (Q.cardinal iqueue) iqueue iset iscore iscore |> Printf.printf "%d\n"
)

Measured memory_bytes: 17156
use proconio::input;

fn main() {
	input!(n: usize);
	input!(m: usize);
	input!(ab: [(i64, i64); n]);
	input!(cd: [(i64, i64); m]);

	for i in 0..n {
		let mut min: i64 = 9999999999999999;
		let mut cp = 0;
		for j in 0..m {
			let md = (ab[i].0 - cd[j].0).abs() + (ab[i].1 - cd[j].1).abs();
			if md < min {
				cp = j + 1;
				min = md;
			}
		}
		println!("{}", cp);
	}
}



Measured memory_bytes: 2164
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    double t, x;
    cin>>t>>x;
    cout<<t/x<<endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int a0=0,a2=0;
	for(int i=0;i<n;++i){
		int a; cin>>a;
		if(a%4==0)++a2;
		else if(a%2!=0)++a0;
	}
	cout<<(a2-a0>-1||a2-a0>-2&&a2+a0==n?"Yes"s:"No"s)<<"\n"s;
}

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



using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;




int main() {

	ll n;
	cin >> n;

	if (n % 2 == 0) {

		ll ans = 0;
		ll a = 10;
		while (a <= n) {
			ans += n / a;
			a *= 5;
		}
		cout << ans << endl;

	}
	else {
		cout << 0 << endl;

	}
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string a,b;
  int a1,b1;
  string c;
  cin>>a>>b;
  cin>>a1>>b1;
  cin>>c;
  if(c==a) a1--;
  else if(c==b) b1--;
  cout<<a1<<" "<<b1<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // Atcoder
    // template: cpp
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), b(n), c(m), d(m);
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, m) cin >> c[i] >> d[i];
    vector<ll> ans(n);
    ll mi;

    rep(i, n) {
        mi = pow(10, 10);
        for(int j = m - 1; j >= 0; j--) {
            if(mi >= abs(a[i] - c[j]) + abs(b[i] - d[j])) {
                mi = abs(a[i] - c[j]) + abs(b[i] - d[j]);
                ans[i] = j + 1;
            }
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
ll n,x;
ll L[55];
ll P[55];

ll solve(ll l, ll x) {
    ll ret = 0;
    // バーガー全部なら前計算の結果を返す
    if (L[l] == x) return P[l];
    
    // とりあえず下から見ていくが、一つ目はバンズなので食べたことにする
    x--;

    // まだx枚食べている途中なら(x>0なら)下半分のl-1レベルバーガーを食べられる分だけ食べてしまいましょう
    if (x > 0) {
        ll y = min(x,L[l-1]);
        ret += solve(l-1, y);
        // 食べた分xから引きます
        x -= y;
    }

    // まだx枚食べている途中なら(x>0なら)真ん中のパティを食べましょう
    if (x > 0) {
        ret++; x--;
    }

    // まだx枚食べている途中なら(x>0なら)上半分のl-1レベルバーガーを食べられる分だけ食べてしまいましょう
    if (x > 0) {
        ll y = min(x,L[l-1]);
        ret += solve(l-1, y);
        x -= y;
    }

    return ret;
}

int main(int argc, char const *argv[]) {
    cin >> n >> x;
    memset(L,0,sizeof(L));
    memset(P,0,sizeof(P));
    L[0] = P[0] = 1ll;
    REP(i,50) L[i+1] = L[i]*2+3;
    REP(i,50) P[i+1] = P[i]*2+1;
    cout << solve(n,x) << endl;
    return 0;
}

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

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;


int main(){
	fast;
	auto start = high_resolution_clock::now(); 

	ll int k , a ,b;
	cin >> k >> a >> b;

	ll int ans = -1;

	if (a+1 <= k){
		ll int m = (k - a - 1)/2;
		// trace1(m, )
		ans = b + m*(b-a) + k - (a + 1 + 2*m);
	}

	cout << max(k+1 , ans);

	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << double(duration.count()) / 1000000 << endl; 

	return 0;
}


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int a[3];
	for (auto&& i : a) {
		cin >> i;
	}
	sort(begin(a), end(a));
	cout << a[0] * a[1] / 2 << "\n";
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);


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

  int n, m;
  cin >> n >> m;
  vector<vector<ll>> x(n, vector<ll>(3));
  rep(i, n) {
    cin >> x[i][0] >> x[i][1] >> x[i][2];
  }

  ll ans = 0;
  for (int b = 0; b < 8; b++) {
    vector<ll> sum(n, 0);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 3; j++) {
        if ((b >> j) & 1) sum[i] += x[i][j];
        else sum[i] -= x[i][j];
      }
    }

    sort(ALL(sum), greater<ll>());
    ll tmp = 0;
    rep(i, m) tmp += sum[i];
    chmax(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


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

int main()
{
    string s, ans;
    cin >> s;
    for (char c : s)
    {
        if ((c == 'B') && (!ans.empty()))
        {
            ans.pop_back();
        }
        else if ((c == 'B') && (ans.empty()))
        {
        }
        else
        {
            ans.push_back(c);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

cnt = 0

if n % 2 == 1:
    cnt = 1
else:
    k = int(n/2)
    for i in range(k):
        if s[i] != s[k+i]:
            cnt = 1

if cnt == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int checked[100];
vector<vector<int>> A(0, vector<int>(0));
vector<P> T(0);
int N, M;
void dfs(int l,int ng,int before) {
  checked[l] = 1;
  REP(i, A[l].size()) {
    int a = A[l][i], b = l;
    if((a==T[ng].first&&b==T[ng].second)||(b==T[ng].first&&a==T[ng].second)){
      continue;
    }
    if (checked[a] == 1||a==before) continue;
    dfs(a, ng,l);
   }
}
int main() {
  cin >> N >> M;
  A.resize(N);
  T.resize(M);
  REP(i, M) {
    int a, b;
    cin >> a >> b, a--, b--;
    A[a].push_back(b);
    A[b].push_back(a);
    T[i] = P(a, b);
  }
  ll ans = 0;
  REP(i, M) {
    dfs(0,i,-1);
    bool t = true;
    REP(i, N) {
      if (checked[i] != 1) {
        t = false;
        break;
      }
    }
    if (!t) ans++;
    REP(i, N) checked[i] = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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() {
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n+2,0);
    repp(i,1,n+1)cin >> a[i];
    if(k >= (n+1)/2 + 1 ){
        k = (n+1)/2 + 1;
        rep(i,n)cout << n << " ";
        cout << endl;
        return 0;
    }
    rep(i,k){
        vector<ll> table(n+2,0);
        repp(j,1,n+1){
            table[max(0LL,j - a[j])]++;
            table[min(n+1,j + (a[j]+1) )]--;
        }
        repp(j,1,n+2){
            table[j] = table[j] + table[j-1];
            a[j] = table[j];
        }
    }
    repp(i,1,n+1)cout << a[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 6404