akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

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

int main(void) {
  int a, b, k;
  cin >> a >> b >> k;
  int cnt = 1;
  int ans = 0;
  int sm = a <= b ? a : b;
  for (int i = sm; i >= 1; i--) {
    if (a % i == 0 && b % i == 0) {
      if (k == cnt++) {
        ans = i;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
#define ll long long
#define ff first
#define ss second
#define e endl

void solve() {
	ll n; cin >> n;
	vector<ll> a;
	ll sum[200001], m = 1e9+7, y = 0;
	for(ll i = 0;i < n;i++){
		ll x; cin >> x;
		a.push_back(x);
		
	}
	memset(sum, 0, sizeof(sum));
	for(ll i = n-1;i >= 0;i--){
		if(i != n-1){
			sum[i] = (sum[i+1] + a[i+1])%m;
		}
	}
	ll x = 0;
	for(ll i = 0;i < n;i++){
		x = (x + (sum[i]*a[i])%m)%m;
	}
	
	cout << x << endl;
}

int main()
{
	//ll t; cin >> t; while (t--)
	solve();
	
}

Measured memory_bytes: 6340
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int ans = 0;
	for (int i = 0; i <= 3000; ++i) {
		for (int j = 0; j <= 3000; ++j) {
			if (i * r + j * g > n) continue;
			if ((n - (i * r + j * g)) % b == 0) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
class Program {
    static void Main(string[] args){
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]); //年齢
        int b = int.Parse(input[1]); //大人金額
        int price = b;
        if(a <= 5){
            price = 0;
        }
        else if(a <= 12){
            price /= 2;
        }
        Console.WriteLine(price);
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
int32_t main(){
    // boost;
    double pie ;
    pie =  3.141592653;
   
    double r;
    cin>>r;
    double ans = 2*pie*r;
    precise(10);
    cout<<ans<<endl;
    
}

Measured memory_bytes: 3788
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n;
  cin >> n;
  // int num[n];
  long long ans = 0;
  bool isPrevOdd = false;

  for (int i = 0; i < n; i++){
    int num;
    int pair = 0;
    cin >> num;

    if(num == 0){
      isPrevOdd = false;
    }

    if(isPrevOdd){
      pair += (num+1)/2;
      ans += pair;
      //cout << i+1 << " * " << num << " : " << pair << endl;
      num++;
    }else{
      pair += num/2;
      ans += pair;
      //cout << i+1 << " * " << num << " : " << pair << endl;
    }

    if(num % 2 != 0){
      isPrevOdd = true;
    }else{
      isPrevOdd = false;
    }

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


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

int main()
{
  int A, B;
  char op;
  cin >> A >> op >> B;
  
  if(op == '+')
  {
  	cout << A + B << endl;
  }
  else if(op == '-')
  {
    cout << A - B << endl;
  }
}

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

#define ll long long int
#define INFTY (1<<21)

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    if(a>8||b>8) cout<<":("<<endl;
    else cout<<"Yay!"<<endl;
    return 0;
}

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

int n, k, l;
double t, u, v;
bool f[10010];

int main()
{
	cin >> n >> k >> t >> u >> v >> l;
	for (int i = 0; i < n; i++){
		int d;
		cin >> d;
		f[d] = true;
	}
	
	double res = 0.0;
	double r = 0.0;
	for (int i = 0; i < l; i++){
		if (f[i]) r = min(r + t, t * (k + 1));
		if (r <= 1.0 / v){
			res += r;
			res += (1.0 - r * v) / u;
			r = 0.0;
		}
		else {
			res += 1.0 / v;
			r -= 1.0 / v;
		}
	}

	printf("%.20f\n", res);
}

Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int N,sum;
	cin>>N>>sum;
	sum/=1000;
	REP(a,N+1){
		REP(b,N-a+1){
			if((10*a+5*b+(N-a-b))==sum){
				print(a,b,N-a-b);
				return 0;
			}
		}
	}
	print(-1,-1,-1);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a=0,b=0,n, m;
  cin>>n;
  vector<int> vec(n);
  vector<int> bigger(n, 0);
  for(int i=0; i<n; i++){
    cin>>vec.at(i);
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      if(bigger.at(i)<=vec.at(j)){bigger.at(i)=vec.at(j); m=j;}
    }
    vec.at(m)=0;
  }
  for(int i=0; i<n; i++){
    if(i%2==0){
      a+=bigger.at(i);
    }else{
      b+=bigger.at(i);
    }
  }
  cout<<a-b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

class BIT {
    int n;
    VL dat;
public:
    void init(int in) {
        n = in + 1;
        dat.clear();
        dat.resize(n + 1, 0);
    }
    ll sum(int i) {
        ll ret = 0;
        while (i >= 0) {
            ret += dat[i];
            i = (i & (i + 1)) - 1;
        }
        return ret;
    }
    void add(int i, ll x) {
        while (i <= n) {
            dat[i] += x;
            i |= i + 1;
        }
    }
};

int main() {
    int n;
    cin >> n;
    VI a(n), sorted(n);
    FOR(i, 0, n) {
        cin >> a[i];
        sorted[i] = a[i];
    }
    SORT(sorted);
    int ok = 0, ng = n;
    BIT bit;

    ll border = (((ll)n * (n + 1) / 2) + 1) / 2;
    while (ng - ok > 1) {
        int mid = (ng + ok) / 2;
        int midnum = sorted[mid];
        bit.init(2 * n + 1);
        int sum = 0;
        bit.add(sum + n, 1);
        ll result = 0;
        FOR(i, 0, n) {
            sum += (a[i] >= midnum ? 1 : -1);
            result += bit.sum(sum + n);
            bit.add(sum + n, 1);
        }
        if (result >= border)ok = mid;
        else ng = mid;
    }
    cout << sorted[ok] << endl;
}


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

int a[5][5];
int x[5];
int y[5];

int main () {

	for (int i = 0; i < 3; i ++) {
		for (int j = 0; j < 3; j ++) {
			cin >> a[i][j];
		}
	}
	
	for (int i = 0; i <= 100; i ++) {
		x[0] = i;
		y[0] = a[0][0] - x[0];
		y[1] = a[0][1] - x[0];
		y[2] = a[0][2] - x[0];
		
		x[1] = a[1][0] - y[0];
		x[2] = a[2][0] - y[0];
		
		int da = 1;
		for (int j = 0; j < 3; j ++) {
			for (int k = 0; k < 3; k ++) {
				if (x[j] + y[k] != a[j][k]) {
					da = 0;
					break;
				}
			}
		}
		
		if (da == 1) {
			cout << "Yes";
			return 0;
		}
	}
	
	cout << "No";

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

start = [[0, 1000], [0, 1000]]
#0: all stack, 1: all money
max_index = [i for i, v in enumerate(A) if v == max(A)][-1]
#print(max_index)

money_list = []
for i in range(N):
  money = max([
    start[0][0] * A[i] + start[0][1],  start[1][0] * A[i] + start[1][1]
  ])
  money_list.append(money)
  start = [[money//A[i], money - (money//A[i])*A[i] ],  [0, money]]
print(max(money_list))

Measured memory_bytes: 9228
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(), v.end()
#define fori(i, j, k) for (int i = (j); i < (int)(k); i++)
#define forb(i, j, k) for (int i = (j); i >= (int)k; i--)
#define lchild(ind) 2 * ind + 1
#define rchild(ind) 2 * ind + 2
#define bug(val) cout << "# " << val << endl;
#define bugs(val) cout << '_' << val;
#define bugl(val) cout << "## " << val << endl;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
typedef pair<ll, pll> plp;
typedef pair<pll, int> ppi;
typedef pair<pll, ll> ppl;
typedef pair<pll, pll> ppp;
typedef vector<int> vi;
typedef vector<ll> vll;

const int maxn = 1e5 + 1;
const ll inf = 2e18, mod = 1e9 + 7;

int ans = mod;
string s;

bool check(string S)
{
	fori (i, 0, S.size() - 1)
		if (S[i] != S[i + 1])
			return true;
	return false;
}

int solve(char c)
{
	int cnt = 0;
	string tmp = s, nxt;
	while (check(tmp))
	{
		nxt = "";
		fori (i, 0, tmp.size() - 1)
		{
			if (tmp[i] == c || tmp[i + 1] == c)
				nxt += c;
			else
				nxt += tmp[i];
		}
		tmp = nxt;
		cnt++;
	}
	return cnt;
}

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

	cin >> s;
	for (char i = 'a'; i <= 'z'; i++)
		ans = min(ans, solve(i));
	cout << ans << endl;
}

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

    using namespace std;
    
    int main(){
        int n;
        cin >> n;
        vector<int> v(n);
        for(int i=0; i<n; i++) cin >> v[i];
        sort (v.begin(), v.end());
        double ans = v[0];
        for(int i=1; i< n; i++){
            ans = (ans+v[i])/2;
        }
        cout << ans << endl;
    }


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

using namespace std;

int main()
{
	int i, j;
	int a[100];
	int v, n;
	int k;
	
	cin >> n;
	
	for (i = 0; i < n; i++){
		cin >> a[i];
	}
	for (i = 1; i < n; i++){
		for (k = 0; k < n; k++){
			if (k != n - 1)cout << a[k] << " ";
			else cout << a[k] << "\n";
		}
		v = a[i];
		j = i - 1;
		
		while (j >= 0 && a[j] > v){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
	}
	for (k = 0; k < n; k++){
		if (k != n - 1)cout << a[k] << " ";
		else cout << a[k] << "\n";
	}
	
	return (0);
}



Measured memory_bytes: 3080
#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 - 1; 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());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

vll dx = {1, 0, -1, 0};
vll dy = {0, 1, 0, -1};

ll mod = 1e9 + 7;

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

    ll n;
    cin >> n;
    string s;
    cin >> s;

    n *= 2;
    vll a(n);
    REP(i, n){
        if(s[i] == 'B') a[i] = 1;
    }
    if(a[0] == 0){
        cout << 0 << endl;
        return 0;
    }
    vll d(n);
    REP(i, n){
        if(i) d[i] = (a[i] == a[i - 1]) ? (1 - d[i - 1]) : d[i - 1];
    }
    // d : 0 ... "(", 1 ... ")"
    ll cnt = 0;
    vll l(n), r(n);
    REP(i, n){
        if(d[i])cnt++;
        if(i != n - 1){
            r[i + 1] = r[i];
            l[i + 1] = l[i];
            if(d[i]) r[i + 1]++;
            else l[i + 1]++;
        }
    }
    if(cnt != n / 2){
        cout << 0 << endl;
        return 0;
    }
    ll res = 1;
    REP(i, n){
        if(d[i]) res *= (l[i] - r[i]);
        res %= mod;
    }
    REP(i, n / 2){
        res *= (i + 1);
        res %= mod;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 6804
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main(){
    int A,B;
    cin >> A >> B;
    int first,second,third,forth,fifth;
    int count = 0;
    for(int i = A; i <= B; i++){
        first = i % 10;
        second = (i / 10) % 10;
        third = (i / 100) % 10;
        forth = (i / 1000) % 10;
        fifth = (i / 10000);
        if(first == fifth && second == forth){
            count += 1;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
using LL = long long;
using VLL = std::vector<LL>;
using VVLL = std::vector<VLL>;
using VVVLL = std::vector<VVLL>;
using LD = long double;
using VLD = std::vector<LD>;
using VVLD = std::vector<VLD>;
using VVVLD = std::vector<VVLD>;
 
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; }

#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
#define cmax(a,b) {if(a<b){a=b;}}
#define cmin(a,b) {if(a>b){a=b;}}
//#define cmax(a,b) a = (a>b ? a:b)
//#define cmin(a,b) a = (a<b ? a:b) 


void func() {
  string S;
  cin >> S;
  if(S=="SAT"){
    cout << 1;
  }
  if(S=="FRI"){
    cout << 2;
  }
  if(S=="THU"){
    cout << 3;
  }
  if(S=="WED"){
    cout << 4;
  }
  if(S=="TUE"){
    cout << 5;
  }
  if(S=="MON"){
    cout << 6;
  }
  if(S=="SUN"){
    cout << 7;
  }
  return;
}
 
int main()
{
  func();
  return 0;
}
 

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

using namespace std;

long long dp[89];
int main(){
  long long n, a[89];
  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i];
  dp[0]=1000;
  for(int i=1;i<n;i++){
    for(int j=0;j<i;j++){
      long long have=dp[j]/a[j]*a[i]+dp[j]%a[j];
      dp[i]=max({dp[i], have, dp[j]});
    }
  }
  cout << dp[n-1] << endl;
}



Measured memory_bytes: 3640
A,B,C,X,Y = map(int,input().split())
min_xy = min(X,Y)
max_xy = max(X,Y)
ans1 = 2 * C * min_xy + A * (X-min_xy) + B * (Y-min_xy) # 無駄にならない範囲でABピザを買い、残りを買う
ans2 = A*X + B*Y # ABピザを買わない
ans3 = 2 * C * max_xy # ABピザだけを買う
print (min(ans1,ans2,ans3))

Measured memory_bytes: 3060
a = Array.new(4)
4.times { |i|
  a[i] = Array.new(3)
  3.times { |j| 
    a[i][j]= Array.new(10, 0)
  }
}

gets.to_i.times {
  b,f,r,p = gets.chomp.split(" ").map &:to_i
 
  a[b-1][f-1][r-1] += p
  a[b-1][f-1][r-1] = 0 if a[b-1][f-1][r-1] < 0
  a[b-1][f-1][r-1] = 9 if a[b-1][f-1][r-1] > 9
}
 
4.times { |i|
  3.times { |j|
   10.times { |k|
     print " #{a[i][j][k]}"
   }
   puts
  }
  if i < 3
    20.times { print "#" }
    puts
  end
}

Measured memory_bytes: 8792
#include<bits/stdc++.h>
#define fi first
#define se second
#define Mp make_pair
#define pb push_back
#define rep(i, j, k) for (int i = (j); i <= (k); i++)
#define per(i, j, k) for (int i = (j); i >= (k); i--)
const int INF = 0x3f3f3f3f, nINF = 0xcfcfcfcf, INFMEM = 0x3f, nINFMEM = 0xcf;
const int PR1 = 1e6 + 3, PR2 = 1e9 + 7;
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int, int> PII;
typedef vector<int> VI;

const int N = 203;
int n,G[N][N],v[N],co[N],ans;

bool check(int s){
    memset(co,0,sizeof(co));
    queue<int> q,dis; q.push(s); dis.push(1); co[s]=1;
    while(q.size()){
        int x=q.front(),dist=dis.front(); q.pop(),dis.pop();
        rep(i,1,n) if(G[x][i]) {
            if(co[i]==co[x]) return false;
            if(co[i]) continue;
            co[i]=(co[x]==1?2:1);
            q.push(i);dis.push(dist+1);
            ans=max(ans,dist+1);
        }
    }
    return true;
}

int main(){
    scanf("%d",&n);
    rep(i,1,n) rep(j,1,n) scanf("%1d",&G[i][j]);
    rep(i,1,n) if(!check(i)){
        printf("-1\n");
        return 0;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

ll dp[100][2];

int main() {
    ll n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    rep(i, 100) dp[i][0] = dp[i][1] = -1;

    dp[45][0] = 0LL;
    for (ll d = 44; d >= 0; --d) {
        ll mask = 1LL<<d;
        ll num = 0;
        rep(i, n) {
            if (a[i] & mask) ++num;
        }
        //cout << num << endl;
        if (dp[d+1][1] >= 0) {
            dp[d][1] = max(dp[d][1],  dp[d+1][1] + mask * max(num, n-num));
        }
        if (dp[d+1][0] >= 0) {
            if (k & (1LL<<d)) {
                dp[d][1] = max(dp[d][1], dp[d+1][0] + mask * num);
                dp[d][0] = max(dp[d][0], dp[d+1][0] + mask * (n - num));
            }
            else {
                dp[d][0] = max(dp[d][0], dp[d+1][0] + mask * num);
            }
        }
    }
    //rep(i, 45) {
    //    cout << i << " ";
    //    for(auto p: dp[i]) {
    //        cout << p << " ";
    //    }
    //    cout << endl;
    //}
    cout << max(dp[0][0], dp[0][1]) << endl;
    return 0;
}


Measured memory_bytes: 4056
#include <stdio.h>
#define N 500000
 
void merge(int *, int, int, int);
void mergeSort(int *, int, int);
 
int count=0;
 
int main()
{
  int i, p, S[N];
 
  scanf("%d", &p);
 
  for(i = 0; i < p; i++){
    scanf("%d", &S[i]);
  }
 
  mergeSort(S, 0, p);
 
  for(i = 0; i < p-1; i++){
    printf("%d ", S[i]);
  }
  printf("%d\n", S[p-1]);
  printf("%d\n", count);
 
  return 0;
}
 
void merge(int *S, int left, int mid, int right)
{
   
  int x1, x2, i, j, k;
  int L[N], R[N];
   
  x1 = mid-left;
  x2 = right-mid;
 
  for(i = 0; i < x1; i++) L[i] = S[left + i];
  for(i = 0; i < x2; i++) R[i] = S[mid + i];
 
  L[x1] = 1000000000;
  R[x2] = 1000000000;
  i = j = 0;
 
  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      S[k] = L[i];
      i++;
    }
    else{ 
      S[k] = R[j];
      j++;
    }
    count++;
  }
}
 
void mergeSort(int *S, int left, int right)
{
 
  int mid;
 
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(S, left, mid);
    mergeSort(S, mid, right);
    merge(S, left, mid, right);
  }
}



Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

pair<ll, ll> xy[51];
int main()
{
	int N, K;
	cin >> N >> K;
	REP(i, N)
	{
		cin >> xy[i].first >> xy[i].second;
	}

	sort(xy, xy + N, [](pair<ll, ll> a, pair<ll, ll> b) {return a.first > b.first; });
	ll minS = (ll)2000000000 * (ll)2000000000;
	REP(l, N - 1)
	{
		for (int r = N - 1; r > l; r--)
		{
			int k = r + 1 - l;
			vector< pair<ll, ll> > y;
			FOR(i, r + 1, l)
			{
				y.push_back(xy[i]);
			}
			sort(y.begin(), y.end(), [](pair<ll, ll> a, pair<ll, ll> b) {return a.second > b.second; });
			REP(t, y.size() - 1)
			{
				for (int u = y.size() - 1; u > t; u--)
				{
					int h = k - (t + (y.size() - 1) - u);
					if (h >= K)
					{
						ll lx = abs(xy[r].first - xy[l].first);
						ll ly = abs(y[t].second - y[u].second);
						minS = std::min(minS, lx*ly);
					}
				}
			}
		}
	}

	cout << minS << endl;
	return 0;
}

Measured memory_bytes: 256
/*
ID: jerrywcy
TASK: AtCoder ABC 104 Problem A
LINK: https://abc104.contest.atcoder.jp/tasks/abc104_a
LANG: C++
*/
#include <bits/stdc++.h>

using namespace std;

int r;

int main()
{
	cin>>r;
	if (r<1200)cout<<"ABC"<<endl;
	else if (r<2800)cout<<"ARC"<<endl;
	else cout<<"AGC"<<endl;

	return 0;
}



Measured memory_bytes: 256
#![doc = " # Bundled libraries"]
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
fn main() {
    input! { n : u64 , q : usize , query : [(i32 , u64) ; q] }
    let mut res = (n - 2) * (n - 2);
    use std::collections::BTreeMap;
    let mut row = BTreeMap::new();
    let mut col = BTreeMap::new();
    row.insert(n - 1, n - 2);
    col.insert(n - 1, n - 2);
    for (t, x) in query {
        if t == 1 {
            let y = col.range(x - 1..).next().unwrap();
            res -= y.1;
            let r = row.entry(*(y.1)).or_insert(n - 1);
            *r = std::cmp::min(*r, x - 2);
        } else {
            let y = row.range(x - 1..).next().unwrap();
            res -= y.1;
            let r = col.entry(*(y.1)).or_insert(n - 1);
            *r = std::cmp::min(*r, x - 2);
        }
    }
    println!("{}", res);
}


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

using namespace std;

int main(){
  int h, w, n, a[10009], g[109][109];
  cin >> h >> w >> n;
  for(int i=1;i<=n;i++)cin >> a[i];
  int idx=1;
  for(int i=0;i<h;i++){
    for(int j=(i%2==0?0:w-1);0<=j&&j<=w-1;j+=(i%2==0?1:-1)){
      while(a[idx]==0)idx++;
      g[i][j]=idx;
      a[idx]--;
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)cout << g[i][j] << (j==w-1?'\n':' ');
  }
}



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

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

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

typedef complex<double> P;

double cross(P a, P b) {
    return imag(conj(a) * b);
}

double dot(P a, P b) {
    return real(conj(a) * b);
}

struct L {
    P a, b, v;
    L(){}
    L(P _a, P _b) {a = _a, b = _b, v = b - a;}
    L(double _ax, double _ay, double _bx, double _by) {
        a = P(_ax, _ay), b = P(_bx, _by), v = b - a;
    }
};

// 2: parallel
// 1: orthogonal
// 0: otherwise
int relationLL(L l1, L l2) {
    if (cross(l1.v, l2.v) == 0) return 2;
    if (dot(l1.v, l2.v) == 0) return 1;
    return 0;
}

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

    int q;
    cin >> q;
    while (q--) {
        int v[4][2];
        rep(i, 4) rep(j, 2) cin >> v[i][j];
        L l1(P(v[0][0], v[0][1]), P(v[1][0], v[1][1]));
        L l2(P(v[2][0], v[2][1]), P(v[3][0], v[3][1]));
        cout << relationLL(l1, l2) << endl;
    }

}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
int n;
int ans[N],a[N],at;
vector <int> son[N];
int read(){
	int x=0;
	char ch=getchar();
	while (!isdigit(ch))
		ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x;
}
void solve(int x){
	ans[x]=1;
	for (auto y : son[x])
		solve(y);
	at=0;
	for (auto y : son[x])
		a[++at]=ans[y];
	sort(a+1,a+at+1);
	reverse(a+1,a+at+1);
	for (int i=1;i<=at;i++)
		ans[x]=max(ans[x],a[i]+i);
}
int main(){
	n=read();
	for (int i=1;i<=n;i++)
		son[i].clear();
	for (int i=2;i<=n;i++)
		son[read()].push_back(i);
	memset(ans,0,sizeof ans);
	solve(1);
	printf("%d",ans[1]-1);
	return 0;
}

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

int main(void)
{
  int n, a;

  while(1)
    {
      a = 0;
      cin >> n;
      if(n == 0) break;
      {
	while(n /= 5) a += n;
	cout << a << endl;
      }
    }
  return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long MOD = 1000000007;

int main(){
    int n, m;
    cin >> n >> m;
    if (abs(n-m) > 1) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    rep1(i, n) ans = ans * i % MOD;
    rep1(i, m) ans = ans * i % MOD;
    if (n == m) ans = ans * 2 % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3608
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val D = Array.fill(N)(sc.nextInt()).sorted

    val center = N / 2
    println(D(center) - D(center - 1))
  }

}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll k; cin>>k;
  ll a,b; cin>>a>>b;
  reps(i,1000){
    ll x=k*i;
    if(a<=x&&x<=b){
      cout<<"OK"<<endl;
      return 0;
    }
    if(x>b) break;
  }
  cout<<"NG"<<endl;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc169/tasks/abc169_c
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputArray = Console.ReadLine().Split(' ');
            var a = decimal.Parse(inputArray[0]);
            var b = decimal.Parse(inputArray[1]);

            long ret = Convert.ToInt64(Math.Floor(a * b));

            Console.WriteLine(ret);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 18160
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int
main()
{
  int n;
  
  cin >> n;
  
  vector<vector<int>> pos( n, vector<int>(2) );
 
  for ( int i = 0 ; i < n ; i++ ) {
    int x, l;
    cin >> x >> l;
    pos.at(i).at(0) = x - l;
    pos.at(i).at(1) = x + l;
  }
  
  sort( pos.begin(), pos.end() );
  
  int num = n;
  int right = pos.at(0).at(1);
  
  for ( int i = 1 ; i < n ; i++ ) {
    int left = pos.at(i).at(0);
    
    if ( left < right ) {
      int right_ = pos.at(i).at(1);
      right = right < right_ ? right : right_;
      num--;
    } else {
      right = pos.at(i).at(1);
    }
  }
  
  cout << num << endl;
}






Measured memory_bytes: 5760
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
#n = int(input())
n, k = map(int, sys.stdin.readline().split())
#n = input()
a = list(map(int, sys.stdin.readline().split()))

l = list(itertools.combinations(range(n), k))

ans = 10 ** 18
for i in range(len(l)):
    cost = 0
    m1 = 0
    p = 20
    for j in range(l[i][0]+1):
        if a[j] > m1:
            m1 = a[j]
            p = j

        if j == l[i][0]:
            if m1 == a[j]:
                if p != j:
                    cost += 1
            else:
                cost += (m1 - a[j] + 1)

    
    r = 1
    if len(l[0]) >= 2:
        q = l[i][r]
    else:
        q = 20

    m2 = a[l[i][0]] + cost

    for j in range(l[i][0]+1, n):
        if j == q:
            if a[j] > m2:
                m2 = a[j]
            else:
                m2 += 1
                cost += (m2 - a[j])

            if r != len(l[0])-1:
                r += 1
                q = l[i][r]
            
        else:
            if a[j] > m2:
                cost += a[j] - m2
                m2 = a[j]
                

    if cost < ans:
        ans = cost


print(ans)
                
        



















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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

ll dp[100];

ll f(ll n)
{
        if(n==0)return 2;
        if(n==1)return 1;
        if(dp[n]!=0)return dp[n];
        else
        {
                ll res=f(n-1)+f(n-2);
                dp[n]=res;
                return res;
        }
}

main()
{
        ll n; cin>>n;
        cout<<f(n)<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int X, Y;
	cin >> X >> Y;

	bool ok = false;
	for (int ii = 0; ii <= X; ++ii){
		int ans = 2 * ii + (X-ii) * 4;
		if (ans == Y){
			ok = true;
			break;
		}
	}


	if (ok){
		cout << "Yes" << "\n";
	} else {
		cout << "No" << "\n";
	}


	return 0;
}


Measured memory_bytes: 3632
N = int(input())
A = [0] + list(map(int, input().split())) + [0]

sum_A = sum(abs(A[i + 1] - A[i]) for i in range(N + 1))

for i in range(1, N + 1):
    ans = sum_A - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1])
    ans += abs(A[i - 1] - A[i + 1])
    print(ans)

Measured memory_bytes: 14048
#include <iostream>
using namespace std;
int main(){
  int n,q,m[100],date[50][100],i,j,k,cnt,max,result;
  while(1){
    max=0;
    cin >> n >> q;
    if(n==0&&q==0) break;
    for(i=0;i<n;i++){
      cin >> m[i];
      for(j=0;j<m[i];j++){
    cin >> date[i][j];
      }
    }
     
    for(i=1;i<100;i++){
      cnt=0;
      for(j=0;j<n;j++){
        for(k=0;k<m[j];k++){
          if(i==date[j][k]){
        cnt++;
        break;
      }
    }
      }
      if(cnt>max){
    max=cnt;
        result=i;
      }
    }
    if(max>=q) cout << result << endl;
    else cout << 0 << endl;
  }
  return 0;
}

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

int main() {
	int64_t n, y;
	cin >> n >> y;
	for (int64_t i = 0; i < 20000; i++) {
		for (int64_t j = 0; i + j <= n; j++) {
			int64_t k = n - i - j;
			if (10000 * i + 5000 * j + 1000 * k == y) {
				cout << i << ' ' << j << ' ' << k << endl;
				return 0;
			}
		}
	}
	cout << -1 << ' ' << -1 << ' ' << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
delta = {}

n = int(input())
k = 0
a = list(map(int, input().split()))

for i, e in enumerate(a):
    delta[i - e] = delta.get(i - e, 0) + 1

for i, e in enumerate(a):
    k += delta.get(e + i, 0)

print(k)

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

using namespace std;

string s;

int main(){
  	cin >> s;
  	int ans = 0;
    for (int i = 0; i < s.length(); i++) if (s[i] == 'o') ans++;
    cout << (ans + 15 - s.length() >= 8 ? "YES" : "NO");
	return 0;
}

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

int main() {
    
  int N, A;
  cin >> N >>A;
  
  int rest = N % 500;
  
  if(A >= rest){
      cout << "Yes" << endl;
  }
  else{
      cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main() 
{
	int x, h;
	double S;
	while (1) {
		cin >> x;
		cin >> h;
		if (x == 0 && h == 0) {
			break;
		}
		S = x * x + 4 * 0.5 * x * sqrt(x * 0.5 * x * 0.5 + h * h);
		cout << fixed << setprecision(6) << S << endl;
	}
	return 0;
}


Measured memory_bytes: 3120
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      String s = sc.next();
      switch (s.substring(s.length() - 1, s.length())) {
      case "2":
      case "4":
      case "5":
      case "7":
      case "9":
        System.out.println("hon");
        break;
      case "0":
      case "1":
      case "6":
      case "8":
        System.out.println("pon");
        break;
      default:
        System.out.println("bon");
        break;
      }
    }
  }
}

Measured memory_bytes: 35468
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>&);

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const pair<T, T>& x) {
	return "(" + to_string(x.fi) + "," + to_string(x.se) + ")";
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int n;

void no() {
	cout << "No\n"; exit(0);
}

ii gt(const string& str) {
	int opn = 0, cls = 0;
	for(auto el: str) {
		if(el == '(') opn++;
		else if(opn) opn--;
		else cls++;
	}
	return ii(cls, opn - cls);
}

int solve(vector<vector<int>> vc, int n) {
	int d = 0, opt = -1;
	priority_queue<ii> pq;
	for(int i = 0; i < n; i++) {
		debug(opt, d);
		while(opt < d) {
			opt++;
			if(opt < vc.size()) for(auto el: vc[opt]) pq.push(ii(el, opt));
		}
		while(pq.size() && pq.top().se > d) pq.pop();
		if(pq.empty()) return -1;
		d += pq.top().fi; pq.pop();
	}
	return d;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	cin >> n;
	vector<vector<int>> uno, dos;
	int na = 0, nb = 0;
	for(int i = 0; i < n; i++) {
		string inp;
		cin >> inp;
		ii x = gt(inp);
		auto& vc = (x.se >= 0? uno: dos);
		auto& sz = (x.se >= 0? na: nb);
		sz++;
		if(x.se < 0) {
			x.fi += x.se;
			x.se *= -1;
		}
		while(vc.size() <= x.fi) vc.push_back(vector<int>());
		debug(x);
		vc[x.fi].push_back(x.se);
	}

	//debug(uno, dos);
	auto p = solve(uno, na);
	auto q = solve(dos, nb);
	debug(p, q);
	cout << (min(p, q) == -1 || p != q? "No": "Yes") << '\n';
}




Measured memory_bytes: 25096
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
 int $(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
signed main(){
  int a,b,e=10000000000,d,f,g=0;
  cin>>a>>b;
  vector<int> c(a);
  fo(i,a)
  c.at(i)=i+b;
  for(int i=0;i<a;i++){
    d=abs(c.at(i));
    if(e>d){
      e=d;
      f=i;
    }
  }
  fo(i,a)
  g+=c.at(i);
  cout<<g-c.at(f)<<endl;
}


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

int main(){
    string s,t,u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if (u == s)
    {
        a--;
    }else if (u == t)
    {
        b--;
    }
    cout << a << " " << b << endl;
    
}

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

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	vector<int> t(n);
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	int m;
	cin >> m;
	int p, x;
	int ans = 0;
	for (int i = 0; i < m; i++) {
		cin >> p >> x;
		p--;

		ans = 0;
		for (int i = 0; i < n; i++) {
			if (i == p) {
				ans += x;
			}
			else {
				ans += t[i];
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
def main():
  n,m = list(map(int,input().split()))
  a = list(map(int,input().split()))
  ans=0
  num=sum(a)
  
  for i in range(0,n):
    if a[i] >= num/(4*m):
      ans+=1
      if ans==m:
        break
  if ans >= m:
    print("Yes")
  else:
    print("No")
  
main()

Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
const int INF = 1e9 + 7;
     
int main(){
      IOS;
      int N;
      cin>>N;
      std::vector<int> h, dp;
      for(int i=0;i<N;i++){
            int input;
            cin>>input;
            h.pb(input);
            dp.pb(0);
      }
      dp[0] = 0;
      dp[1] = abs(h[1]-h[0]);
      for(int i=2;i<N;i++){
            dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1], abs(h[i] - h[i-2]) + dp[i-2]);
            // cout<<dp[i]<<" ";
      }
      cout<<dp[N-1];
      return 0;
}

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<bool> have(N);
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      have[a - 1] = true;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (!have[i]) ans++;
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


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

int main() {
  int N ;
  cin >> N;
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
  int l, r;
   cin >> l >> r;

 
  sum +=  r - l + 1;
  }
  
  cout << sum <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N,M,X;
  cin >> N >> M >> X;
  
  long cost = 10000000;
  
  long C[N+1];
  long A[N+1][M+1];
  for(int i=1; i<N+1; i++){
    cin >> C[i];
  for(int j=1; j<M+1; j++){
    cin >> A[i][j];
  }
  }

  long temp[M+1];
  long itr = 1;
  long newCost = 0;
  //各本を買うor買わないをBit列で保持。
  for(itr=1; itr<pow(2,N); itr++){//あるbit列を選択
    for(int e=1; e<M+1; e++){
    temp[e] = 0;//理解度初期化
    }
    newCost = 0;//コスト初期化
    for(int p=1; p<N+1; p++){
      if((1<<p-1)&itr){
        //ある本を買ってるならコストと理解度を足す。
        newCost += C[p];
        for(int f=1; f<M+1; f++){
          temp[f] += A[p][f];
        }
      }
    }
    //理解度チェック
    long goal = 1;
    for(int p=1; p<M+1; p++){
      if(temp[p] < X) goal = 0;
    }
    if(goal==1){
      cost = min(cost, newCost);
      //cout << itr << ' ' << cost << endl;
    }
  }
  
  if(cost == 10000000) cost = -1;
  
  cout << cost << endl;
  return 0;
}


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

int InsertionSort(int *, int ,int);
int CreateG(int, int, int *);

int main()
{
	int i, j;
	int n;
	int *A;
	int m;
	int G[100];
	int count = 0;

	// input
	scanf("%d", &n);
	A = (int *)malloc(n * sizeof(int));
	for(i = 0; i < n; i++)
	{
		scanf("%d", &A[i]);
	}

	// shell sort
	m = CreateG(n, 0, G);
	for(i = 0; i < m; i++)
	{
		count += InsertionSort(A, n, G[i]);
	}
	
	// output
	printf("%d\n", m);
	for(i = 0; i < m - 1; i++)
	{
		printf("%d ", G[i]);
	}
	printf("%d\n%d\n", G[i], count);
	for(i = 0; i < n; i++)
	{
		printf("%d\n", A[i]);
	}
	return 0;
}

// ??????????????? g ????????¢??????????´??????????????±???¨???????????\?????????	
int InsertionSort(int A[], int n, int g)
{
	int i, j;
	int tmp;
	int count = 0;
	
	for(i = g; i < n; i++)
	{
		j = i - g;
		tmp = A[i];
		while(j >= 0 && A[j] > tmp)
		{
			A[j + g] = A[j];
			j = j - g;
			A[j + g] = tmp;
			count++;
		}
	}
	return count;
}	

// G[] ????????????????????¢??°
// G[0] <= n ?????? G[i] - G[i + 1] = 3 ^ (m - n)
// ex: 121, 40, 13, 4, 1  (n = 130)
// n: G ?????????  d: ?????????
// G[]:??????????????¨???????????????
// retval: G[] ???????´???° m
int CreateG(int n, int d, int G[])
{
	int i;
	static int m = 0;
	static int factorial = 1;
	
	d += factorial;
	factorial *= 3;
	
	if(d > n) return 0;
	CreateG(n, d, G);
	G[m] = d;
	m++;
	
	return m;
}

Measured memory_bytes: 4508
#include <stdio.h>
#define X 100000000
int n;
int A[20000000];
int Count();
void maxHeapify(int i);
void increaseKey(int n, int k);
void insert(int k);
int extractMax();
int main(){
  int i, c;
  char dist[20];
  for (i = 1; i <= 2000000; i++){
    scanf("%s", dist);
    if(dist[0] == 'i'){ // insert
      scanf("%d", &c);
      insert(c);
    } else if (dist[1] == 'x'){ // extract
      printf("%d\n", extractMax());
    } else if (dist[1] == 'n'){ // end
      break; }
  }
  return 0; }
int Count(){
  int i;
  for(i = 1; A[i] != 0; i++){
  }
  return i;
}
void maxHeapify(int i){
  int l, r, large, tmp, k;
  l = 2*i;
  r = 2*i+1;
  if(l<= n && A[l] > A[i]){
    large = l;
  } else large = i;
  if(r<= n && A[r] > A[large]){
    large = r;
  }
  if(large != i){
    tmp = A[i];
    A[i] = A[large];
    A[large] = tmp;
    maxHeapify(large);
  } }
void increaseKey(int n, int k){
  int tmp;
  A[n] = k;
  while(n>1 && A[n/2] < A[n]){
    tmp = A[n];
    A[n] = A[n/2];
    A[n/2] = tmp;
    n = n/2; }
}
void insert(int k){
  int i;
  n++;
  A[n] = -X;
  increaseKey(n, k);
}
int extractMax(){
  int i, max;
  maxHeapify(1);
  max = A[1];
  A[1] = A[n];
  n--;
  maxHeapify(1);
  return max;
}



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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

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

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(base, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)1e5+1;
int N;


int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    if(N%2 == 0)
    {
        cout << 0.5;
    }
    else
    {
        cout << double(N+1)/double(2*N);
    }
    return 0;
}


Measured memory_bytes: 256
N,M,Q=map( int , raw_input().split() )

S=[ [ 0 for i in range(N+1) ] for j in range(N+1) ]

for i in range(M):
	l,r=map( int , raw_input().split() )
	S[l][r]+=1

for i in range(1,N+1):
	for j in range(1,N):
		S[i][j+1]+=S[i][j]


for j in range(1,N+1):
	for i in range(1,N):
		S[i+1][j]+=S[i][j]


P=[ map( int , raw_input().split() ) for i in range(Q) ] 

for x,y in P:
	if x-1>0:
		print S[y][y]-S[x-1][y]-S[y][x-1]+S[x-1][x-1]
	else:
		print S[y][y]

Measured memory_bytes: 46364
#include<bits/stdc++.h>
using namespace std;
const int N=4000002;
char s[N],t[N];
int a,b,ne[N],ans,g[N],i,j;
int main(){
	scanf("%s%s",s+1,t+1),a=strlen(s+1),b=strlen(t+1);
	for (;a<b*2;a*=2)
		for (i=1;i<=a;i++) s[i+a]=s[i];
	for (i=1;i<=a;i++) s[i+a]=s[i];
	a*=2;
//	for (i=2,j=1;i<=b;i++){
//		while (j>1 && t[i]!=t[j]) j=ne[j-1];
//		if (t[i]==t[j]) j++;
//		ne[i]=j;
//	}
	ne[0]=-1;
	for (i=1;i<=b;i++){
		j=i-1;
		while (j && t[ne[j]+1]!=t[i]) j=ne[j];
		ne[i]=ne[j]+1;
	}
//	for (i=1,j=1;i<=a;i++){
//		while (j>1 && s[i]!=t[j]) j=ne[j-1];
//		if (s[i]==t[j]) j++;
//		if (j==b+1) ans=max(ans,g[i]=g[i-b]+1);
//	}
	for (i=1,j=0;i<=a;i++){
		while (~j && s[i]!=t[j+1]) j=ne[j];
		if (++j==b) ans=max(ans,g[i]=g[i-b]+1);
	}
	printf("%d",ans>=a/b-1?-1:ans);
}


Measured memory_bytes: 23040
#include <iostream>
#include <limits>

using namespace std;

int main()
{
    int n;
	int p, s, mp = numeric_limits<int>::min(), ms;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p >> s;

		if (p > mp) {
			mp = p;
			ms = s;
		}
	}

	while (ms--)
		mp++;

	cout << mp << endl;
	
	return 0;
}


Measured memory_bytes: 256
SA = input()
SB = input()
SC = input()
R = SA[0]
SA = SA[1:]
while not R == "":
    if R == "a":
        R = SA[:1]
        SA = SA[1:]
        E = "A"
    elif R == "b":
        R = SB[:1]
        SB = SB[1:]
        E = "B"
    else:
        R = SC[:1]
        SC = SC[1:]
        E = "C"
print(E)


Measured memory_bytes: 9008