akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=INF,a,b,c,d,cmpp[ohara],m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      vector<ll> cmp(3);
      cin>>cmp[0]>>cmp[1]>>cmp[2];
      sort(all(cmp));

      do{
        cnt=0;
        rrep(i,1,3){
          cnt+=abs(cmp[i]-cmp[i-1]);
        }
        ans=min(ans,cnt);

      //  rep(i,n)cout<<cmp[i]<<" ";
        //cout<<"\n";

      }
      while(next_permutation(all(cmp)));
      
      Cout(ans);
      

       
return 0;
}


Measured memory_bytes: 256
import math
# from itertools import permutations,combinations,combinations_with_replacement
# from collections import deque,Counter
# import re
# from bisect import bisect_left
# from heapq import heappush,heappop
# from numba import njit
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from fractions import gcd

# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb,perm #permはnPk

# slist = "abcdefghijklmnopqrstuvwxyz"
MOD = 10**9 + 7
A,B,H,M = map(int,input().split())

kakuH = 30 * H + 0.5 * M
kakuM = 6 * M

xH = A*math.cos(math.radians(kakuH))
yH = A*math.sin(math.radians(kakuH))
xM = B*math.cos(math.radians(kakuM))
yM = B*math.sin(math.radians(kakuM))

ans = (xH-xM)**2 + (yH-yM)**2
ans = math.sqrt(ans)
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 9488
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const double PI = 3.14159265358979;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

int main() {
	ll R, G, B, N; cin >> R >> G >> B >> N;

	ll cnt = 0;
	repe(r, 0, 3000) repe(g, 0, 3000) {
		ll T = N - (r * R + g * G);
		if (T < 0)continue;
		if (T == 0 || T % B == 0) {
			cnt++;
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const int INF = INT_MAX / 2;

int main(){
    ll X; cin >> X;
    ll ans;
    ll start = (ll)((sqrt(1+8*X) - 1.)/2.);
    for (int i = start; i <= X; i++)
    {
        if(i*(i+1)/2>=X){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    
}

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

using namespace std;

vector<int> e;

int cnt(int m) {
  int ans = 0;
  for (auto x : e) {
    if (x >= m - 1) {
      ans += 1;
    }
  }
  return ans;
}

void solve(int N) {
  e.resize(N + 1, 0);
  for (int i = 2; i <= N; i++) {
    int cur = i;
    for (int j = 2; j <= i; j++) {
      while (cur % j == 0) {
        e[j] += 1;
        cur /= j;
      }
    }
  }
  int ans = cnt(75) + cnt(25) * (cnt(3) - 1) + cnt(15) * (cnt(5) - 1) +
            cnt(5) * (cnt(5) - 1) * (cnt(3) - 2) / 2;
  printf("%d\n", ans);
}

int main() {
  int N;
  cin >> N;
  solve(N);
  return 0;
}


Measured memory_bytes: 888
N,M,X,Y=map(int,raw_input().split())
xN=map(int, raw_input().split())
yM=map(int, raw_input().split())
    
flag=0

maxx=1+max(xN)
miny=min(yM)

if X>=maxx:
	flag=1

if Y<miny:
	flag=1

if maxx>miny:
	flag=1

if flag==0:
	print 'No War'
else:
	print 'War'

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

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

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int main()
{
    int n,m; cin >> n >> m;
    vector<ll> x;
    for(int i = 1; i*i <= m; i++){
        if(m % i == 0){
            if(m == i*i){
                x.push_back(i);
            }else{
                x.push_back(i);
                x.push_back(m/i);
            }
        }
    }
    sort(all(x));
    reverse(all(x));
    if(m%n==0){
        cout << m/n << endl;
    }else{
        ll k = m/n; 
        for(int i = 0; i < n; i++){
            if(x[i] <= k){
                cout << x[i] << endl;
                break;
            }
        }
    }
}

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

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using Pair = pair<int, int>;
const ll mod = 1e9 + 7;

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  // 1-index
  BIT(int n=0): n(n), d(n+1) {}
  void add(int i, T x=1) {
    for (++i; i<=n; i+=i&(-i)) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (++i; i; i-=i&(-i)) {
      x += d[i];
    }
    return x;
  }
};

int main(int argc, char const* argv[])
{
  ll n, d, a;
  cin >> n >> d >> a;
  vector<pair<ll, ll>> p;
  for (ll i = 0; i < n; i++) {
    ll x, h;
    cin >> x >> h;
    p.emplace_back(x, h);
  }
  sort(ALL(p));

  BIT<ll> bit(n+1);
  ll ans = 0;
  REP(i, n) {
    ll x = p[i].first;
    ll h = p[i].second;
    // cout << "i: " << i << ", x: " << x << ", h: " << h << endl;

    h -= bit.sum(i);
    if (h > 0) {
      // 残った体力分新たな爆弾でダメージを与える
      ll count = (h+a-1)/a;
      ans += count;
      ll damage = a * count;
      // ↓違う。x, x+2*d+1に対応するindexだ。
      // bit.add(x, damage);
      // bit.add(x+2*d+1, -damage);
      bit.add(i, damage);
      // ll limit = upper_bound(p.begin(), p.end(), pair<ll,ll>(x+2*d, -1)) - p.begin();
      // cout << "x+2*d: " << x+2*d << ", limit: " << limit << endl;
      ll limit = upper_bound(p.begin(), p.end(), pair<ll,ll>(x+2*d+1, -1)) - p.begin();
      bit.add(limit, -damage);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6256
#include<stdio.h>

int search(int A[], int n, int key) {
	int i = 0;
	A[n] = key;
	while (A[i] != key) {
		i++;
	}
	return i != n;
}

int main() {
	int i, n, A[10000+1], q, key, sum = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}

	scanf("%d", &q);
	for (i =  0; i < q; i++) {
		scanf("%d", &key);
		if (search(A, n, key)) sum++;
	}
	printf("%d\n", sum);

	return 0;

}



Measured memory_bytes: 2772
import java.util.*;
import java.io.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int c = 0;
    int l = s.length();
    for(int i=0;i<l/2;i++) {
      c+= s.charAt(i)==s.charAt(l-i-1)?0:1;
    }
    System.out.println(c);
  }
}

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(m);
  rep(i, m) {
    int k;
    cin >> k;
    a[i].resize(k);
    rep(j, k) {
      cin >> a[i][j];
      --a[i][j];
    }
  }
  vector<int> p(m);
  rep(i, m) cin >> p[i];
  
  int ans = 0;
  for(int i = 0; i < (1 << n); ++i) {
    bool flag = true;
    for(int j = 0; j < m; ++j) {
      int cnt = 0;
      for(int k : a[j]) {
        if((i >> k) & 1) ++cnt;
      }
      if(cnt % 2 != p[j]) flag = false;
    }
    if(flag) ++ans;
  }
  
  cout << ans << endl;
  return 0;
}

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

int main() {
    string s;
    int m;
    int b;
    string s_tmp;
    cin >> s;
    while (s != "-") {
        cin >> m;
        for (int i = 0; i < m; i++) {
            cin >> b;
            s = s.substr(b, s.size() - b) + s.substr(0, b);
        }
        cout << s << endl;
        cin >> s;
    }
}


Measured memory_bytes: 3204
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# bit全探索
D, G = lr()
PC = [lr() for _ in range(D)]
answer = 10 ** 5
for pattern in range(1<<D):
    # patternが1のところはコンプリートボーナス
    temp = 0
    cnt = 0
    for i in range(D):
        if pattern>>i & 1:
            temp += PC[i][1] + (i+1) * 100 * PC[i][0]
            cnt += PC[i][0]
    j = D-1  # 残りは配点の多い問題から, 0-indexed
    while temp < G:
        if j < 0:
            break
        if pattern>>j & 1:
            j -= 1
            continue
        remain = G - temp
        point = (j + 1) * 100
        problems = (remain + point - 1) // point
        problems = min(problems, PC[j][0])
        cnt += problems
        temp += point * problems
        j -= 1
    else:
        if cnt < answer:
            answer = cnt

print(answer)


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0)
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000

ll solve(ll &a, ll &b, ll &x) {
  ll res = (int)(a * x / b) - a * (int)(x / b);
  return res;
}

int main()
{
  ll a, b, n; cin >> a >> b >> n;
  ll x = 0;
  if (b <= n) x = b - 1;
  else x = n;
  cout << solve(a, b, x) << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
    long n,k,ans=0;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i+1<n;i++){
        for(int j=i+1;j<n;j++){
            if(a[i]>a[j])ans+=k*(k+1)/2;
            if(a[i]<a[j])ans+=k*(k-1)/2;
            ans%=1000000007;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main{
	public static void main(String[] args) {
    	Scanner itr = new Scanner(System.in);
      	String s = itr.next();
      	
      	int a = 0;
      	int b = 0;
      	for (char i : s.toCharArray()) {
        	if (i == 'A') a++;
          	else b++;
        }
      
      	if (a == 0 || b == 0)
          System.out.println("No");
      	else
          System.out.println("Yes");
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;
vector<int> B;
int A;
//=============================
void input()
{
    cin>>N>>A;

}
//=============================
void func(){}
//=============================
void solve()
{
    N %= 500;
    cout<<(N<=A ? "Yes" : "No")<<endl;

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
# NとKを数値入力させる
N, K = map(int, input().split())

# 例えば'1 2 3 4 5'などを配列に数値として格納したい場合，こう書けばいける
A = list(map(int, input().split()))

# リストAをソートする．このとき引数にreverse = Trueを設定すると降順になる（デフォルトは昇順）
A = sorted(A, reverse = True)

# 現在リストAには大きい順に棒の長さが格納されている．
# 大きい方からK本の長さの総和が最大値なので初期値0にしてK本分足していく
ans = 0
for i in range(K):
    ans += A[i]

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k;
  cin >> n >> k;
  int d,x; d=0;
  for(int i=0;i<n;i++){
    cin >> x;
    d+=2*min(x, abs(x-k));
  }
  cout << d << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	if(b.size()-a.size()!=1){
		cout<<"No";
		return 0;
	}
	for(int i=0;i<a.size();i++){
		if(a[i]!=b[i]){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3624
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

    static class Drink {
        long a;
        int b;

        public Drink(long a, int b) {
            this.a = a;
            this.b = b;
        }

        public long getA() {
            return a;
        }

    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Drink> drink = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            drink.add(new Drink(sc.nextLong(), sc.nextInt()));
        }
        long yen = 0;
        int count = 0;
        drink.sort(Comparator.comparing(Drink::getA));

        for (int i = 0; i < drink.size(); i++) {
            for (int j = 0; j < drink.get(i).b; j++) {
                yen += drink.get(i).a;
                count++;
                if (count >= m) {
                    System.out.println(yen);
                    return;
                }
            }
        }
    }

}


Measured memory_bytes: 91196
#!/usr/bin/php
<?php
function process($s){
	$bidx=strpos($s,'(');
	while($bidx!==FALSE){
		$count=1;
		$eidx=$bidx+1;
		for(;$count;$eidx++){
			if($s{$eidx}=='(')$count++;
			if($s{$eidx}==')')$count--;
		}
		$s=substr($s,0,$bidx).process(substr($s,$bidx+1,$eidx-1-($bidx+1))).substr($s,$eidx);
		$bidx=strpos($s,'(');
	}
	$matches=null;
	while(preg_match("/^(.*?)(-?\\d+)([*\\/])(-?\\d+)(.*)$/",$s,$matches)){
		if($matches[3]=='*')
			$s=$matches[1].($matches[2]*$matches[4]).$matches[5];
		else
			$s=$matches[1].intval($matches[2]/$matches[4]).$matches[5];
	}
	while(preg_match("/^(.*?)(-?\\d+)([+Z])(-?\\d+)(.*)$/",$s,$matches)){
		if($matches[3]=='+')
			$s=$matches[1].($matches[2]+$matches[4]).$matches[5];
		else
			$s=$matches[1].($matches[2]-$matches[4]).$matches[5];
	}
	return $s;
}
for($n=fgets(STDIN)^0;$n;$n--){
//while($s=fgets(STDIN)){
	$s=str_replace('-','Z',rtrim(fgets(STDIN)));
	echo process(substr($s,0,strlen($s)-1))."\n";
}
?>

Measured memory_bytes: 6820
#include <iostream>
using namespace std;
int main() {
	int c=0;
	string s,x,pre;
	cin >> s;
	for (int i=0; i<s.length(); i++) {
		x += s[i];
		if (x != pre) {
			pre = x;
			x.clear();
			c++;
		}
	}
	cout << c;
}


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

using namespace std;
bool isGood(int n, vector<int> dislike) {
	while (n) {
    	if (find(dislike.begin(), dislike.end(), n % 10) != dislike.end())
          return false;
      n /= 10;
    }
  return true;
}

int solve(int n, vector<int> dislike) {
	for (int i = n; true; ++i) {
  		if (isGood(i, dislike))
			return i;
    }
}

int main() {

    int n, k;
  cin >> n >> k;
  vector<int> dislike(k);
  for(int &d : dislike)
        cin >> d;
  
  cout << solve(n, dislike) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define n 500000
#define mem(arr) memset(arr, 0, sizeof(arr))
using namespace std;
typedef long long lli;
typedef double llf;
typedef pair<int, int> P;
void solve();
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int times = 1;
//	cin >> times;
	for(int i=0; i<times; i++)
	{
		solve();
		cout << '\n';
	}
	return 0;
}
int a, b, c, d, e, f, g, h;
int arr[n + 50], arr1[n + 50], arr2[n + 50];

//type here

void solve()
{
	cin >> a >> b >> c;
	int cnt[a + 50] = {0};
	for(int i=0; i<c; i++)
	{
		int tmp; cin >> tmp;
		cnt[tmp] ++;
	}
	for(int i=1; i<=a; i++)
	{
		if(cnt[i] + b - c <= 0) cout << "No";
		else					cout << "Yes";
		cout << '\n';
	}
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define btinpct(x) __builtin_popcountll((x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?b:gcd(b%a,a); }

#define ll long long int 
#define ld long double
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
typedef pair <ll, ll> pi; typedef pair <ll, pi> spi; typedef pair <pi, pi> dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (2002)
ll n;
int W[MAXN], B[MAXN];
ll wdp[MAXN][MAXN], bdp[MAXN][MAXN], dp[MAXN][MAXN];
int main()
{
	FAST
	cin>>n;
	FOR(i,0,2*n-1) {
		char c; ll a; cin>>c>>a;
		if(c=='W') W[a]=i;
		else B[a]=i;
	}
	// wdp[i][j] = cost to append the white ball i th
	FOR(i,1,n) {
		FOR(j,1,i-1) {
			wdp[i][0] += (W[i] < W[j]);
		}
		FOR(j,1,n) wdp[i][j] = wdp[i][j-1] + (W[i]<B[j]);
	}
	FOR(i,1,n) FOR(j,1,n) {
		// cerr<<wdp[i][j]<<" \n"[j==n];
	}
	FOR(i,1,n) {
		FOR(j,1,i-1) {
			bdp[i][0] += (B[i]<B[j]);
		}
		FOR(j,1,n) bdp[i][j] = bdp[i][j-1] + (B[i]<W[j]);
	}
	FOR(i,0,n) FOR(j,0,n) {
		dp[i][j] = min((i>0?dp[i-1][j] + wdp[i][j]:LLINF), (j>0?dp[i][j-1] + bdp[j][i]:LLINF));
		if(i==0&&j==0) dp[i][j]=0;
	}
	cout<<dp[n][n]<<'\n';
}


Measured memory_bytes: 94208
[n, x] = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]

cnt = 0
for i in range(n):
    cnt += l[i]
    if cnt > x:
        print(i + 1)
        break
    if (i == n - 1):
        print(n + 1)


Measured memory_bytes: 2940
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut itr = s.split_whitespace().map(|e| e.parse().unwrap());
    let x: i32 = itr.next().unwrap();
    let y: i32 = itr.next().unwrap();
    let z: i32 = itr.next().unwrap();

    println!("{} {} {}", z, x, y);
}


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

int main() {
    vector<vector<int>> bingo(3, vector<int>(3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> bingo[i][j];
        }
    }

    int N, b;
    cin >> N;
    vector<vector<bool>> select(3, vector<bool>(3));
    for (int i = 0; i < N; i++) {
        cin >> b;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (bingo[i][j] == b) {
                    select[i][j] = true;
                }
            }
        }
    }

    for (int i = 0; i < 3; i++) {
        if (select[0][i] && select[1][i] && select[2][i]) {
            cout << "Yes" << endl;
            return 0;
        }
        if (select[i][0] && select[i][1] && select[i][2]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (select[0][0] && select[1][1] && select[2][2]) {
        cout << "Yes" << endl;
        return 0;
    }
    if (select[0][2] && select[1][1] && select[2][0]) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
'use strict'

function main(input) {

    input = input.split('\n')
    let ary = input[1].split('')
    // let half = Math.ceil(Number(input[0]) / 2); //half
    let a, b = [];
    let cnt = 0
    let max = 0 //answer
    let matched = {};

    for (let i = ary.length; i >= 0; i--) {
        //配列を真ん中で分断

        a = ary.slice(0, i)
        b = ary.slice(i, ary.length)

        if (i >= max) { // max が 配列数より大きかったら停止

            cnt = 0
            matched = {}

            for (let j = 0; j < i; j++) {
                b.find(element => {

                    if (element == a[j]) {
                        matched[a[j]] = true
                    }
                })
            }
            cnt = Object.keys(matched).length

            max = (max > cnt) ? max : cnt

        }


    }
    console.log(max)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
from operator import itemgetter
from collections import deque

def main():
    x,y,r,g,b = map(int,input().split())
    red = deque(sorted(list(map(int, input().split())),reverse=True)[:x])
    grn = deque(sorted(list(map(int, input().split())),reverse=True)[:y])
    non = sorted(list(map(int, input().split())),reverse=True)
    for i in non:
        dic = {
            'r' : red.pop(),
            'g' : grn.pop(),
            'b' : i,
        }
        # valueで並べ替えてそのうち大きい2つをとる。
        # さらにkeyで並べ替える (b が後ろに来るように)
        res = sorted(dic.items(), key=itemgetter(1))[-2:]
        res.sort(key=itemgetter(0),reverse=True)

        key = [i[0] for i in res]
        val = [i[1] for i in res]
        if key == ['r','g']:
            red.append(val[0])
            grn.append(val[1])
        elif key == ['r','b']:
            red.append(val[0])
            grn.appendleft(val[1])
        else:
            grn.append(val[0])
            red.appendleft(val[1])

    print(sum(red)+sum(grn))



if __name__ == '__main__':
    main()


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

const int MAX_N = 405;
int N, H, fa[MAX_N], in[MAX_N], out[MAX_N], ok[MAX_N];
bool vis[MAX_N];

int find(int x) {
  return fa[x] == x ? x : fa[x] = find(fa[x]);
}

int main() {
  scanf("%d%d", &N, &H);
  for (int i = 1; i <= H << 1; ++i) fa[i] = i;
  
  for (int i = 1; i <= N; ++i) {
    int A, B, C, D, u, v;
    scanf("%d%d%d%d", &A, &B, &C, &D);
    if (C == 0) out[A]++, u = A;
    else out[C + H]++, u = C + H;
    
    if (D == 0) in[B + H]++, v = B + H;
    else in[D]++, v = D;

    vis[u] = vis[v] = 1;
    if (find(u) != find(v)) fa[find(u)] = find(v);
  }

  bool flag = 1;
  for (int i = 1; i <= H; ++i)  {
    if (in[i] > out[i]) flag = 0;
    if (in[i + H] < out[i + H]) flag = 0;
    if (in[i] != out[i]) ok[find(i)] = 1;
    if (in[i + H] != out[i + H]) ok[find(i + H)] = 1;
  }
  for (int i = 1; i <= H << 1; ++i)
    if (vis[i] && !ok[find(i)]) flag = 0;
  
  if (flag) puts("YES");
  else puts("NO");
  
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i < N; i++) {
        ans += (N-1)/i;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	ll n, m = INT_MIN, tmp;
	cin >> n;
	REP(i, 0, 5){
		cin >> tmp;
		m = max((n-1)/tmp, m);
	}
	cout << m +5;
}


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

using namespace std;

int main()
{
	int N;
  	cin >> N;
	vector<char> S(N);
  	for(int i = 0; i < N; i++){
      	cin >> S.at(i);
    }
  	bool a = false;
  	for(int i = 0; i < N; i++){
      	if(S.at(i) == 'Y'){
          	a = true;
          	break;
        }
    }
  	if(a){
      	cout << "Four";
    }else{
      	cout << "Three";
    }
  	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i,j,N;
	long sum = 0;
	scanf("%d",&N);

	for (i = 1;i <= N;i++){
		if (i % 3 != 0 && i % 5 != 0){
			sum += i;
		}
	}

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

}


Measured memory_bytes: 1728
n, m = map(int ,input().split(" "))
h = list(map(int, input().split(" ")))

candidates = {}
for i in range(m):
    x, y = map(int, input().split(" "))

    if h[x - 1] <= h[y -1]:
        candidates[x] = False
    if h[x - 1] >= h[y -1]:
        candidates[y] = False

ans = 0
for i in range(1, n + 1):
    is_highest = candidates.get(i, True)
    if is_highest:
        ans += 1

print(ans)

Measured memory_bytes: 20116
#include <iostream>
#define MIN(X,Y) ((X)<(Y)?(X):(Y))
using namespace std;


int main(void){
  string st;;
  int k;
  
  cin >> k >> st;
  for (int i=0; i<MIN(st.size(), k); i++){
    cout << st[i];
  }
  if (st.size()>k) cout << "...";
  cout << endl;
  
  return 0;
}
    

Measured memory_bytes: 3616
#import <stdio.h>
#define M 1000000007
typedef long long INT;

int main(){
    @autoreleasepool {
        INT N;
        scanf("%lld ", &N);
        INT a[26] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
        for(INT i=0;i<N;i++){
            char c;
            scanf("%c",&c);
            a[c-'a']++;
        }
        INT count = 1;
        for(int i=0;i<26;i++){
            count = ((a[i] % M) * count) % M;
        }
        printf("%lld", count-1);
    }
}


Measured memory_bytes: 9124
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long



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

    string s; cin >> s;
    if(s.at(2) == s.at(3) && s.at(4) == s.at(5)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
/**
 *  author: mahfuzz
 *  created: 08.12.2019
**/
 
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;
#define debug(x) cout << #x << ':' << x << "\n";
//~ const double pi = 2*acos(0.0);
//~ const long long mod = 1e9+7;
//~ const int max_n = 1e6+5;
typedef long long ll;


int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    int n; cin >> n;
    
    cout << setprecision(10) << fixed << (double)((n+1) / 2) / n << "\n";
    
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
 
static const int N = 200000;
 
int main(){
  int n,i,j, R[N];
  int maxv,minv;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++)
    scanf("%d",&R[i]);
 
    minv = R[0];
    maxv = R[1]-R[0];
 
    for(i=1;i<n;i++){
      if(R[i]-minv>maxv) maxv = R[i]-minv;
      if(R[i]<minv) minv = R[i];
    }
 
 
  printf("%d\n",maxv);
 
  return 0;
}

Measured memory_bytes: 1376
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static int i, j;
        static void Main (string[] args)
        {
            string[] str = Console.ReadLine ().Split (' ');

            int N = int.Parse (str[0]);
            int K = int.Parse (str[1]);

            int[] d = new int[K];
            bool[, ] A = new bool[N, K];

            int count = 0;

            for (int k = 0; k < K; k++)
            {
                str = Console.ReadLine ().Split (' ');
                d[k] = int.Parse (str[0]);

                str = Console.ReadLine ().Split (' ');

                for (i = 0; i < d[k]; i++)
                {
                    A[int.Parse (str[i]) - 1, k] = true;
                }
            }

            for (i = 0; i < N; i++)
            {
                for (j = 0; j < K; j++)
                {
                    if (A[i, j] == true) break;
                    if (j == K - 1) count++;
                }
            }

            Console.WriteLine (count);
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

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

using namespace std;

int main() {
    int a,b,c;
    cin>>a>>b;
    if((a == 1 && b == 2)||(a == 2 && b == 1))
        cout<<"3\n";
    else if((a == 2 && b == 3)||(a == 3 && b == 2))
        cout<<"1\n";
    else if((a == 1 && b == 3)||(a == 3 && b == 1))
        cout<<"2\n";
    return 0;
}

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

int main()
{
  int H,N;
  cin>>H>>N;
  int A[1010][2]={0};
  for(int i=0;i<N;i++)cin>>A[i][0]>>A[i][1];
  int dam[10010]={0};
  for(int i=0;i<=H;i++)dam[i]=100000000;
  for(int i=1;i<=H;i++){
    for(int j=0;j<N;j++){
      if(i<=A[j][0])dam[i]=min(dam[i],A[j][1]);
      else dam[i]=min(dam[i],dam[i-A[j][0]]+A[j][1]);
    }
  }
  cout<<dam[H]<<endl;
}

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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define ll long long
#define ld long double
#define ok puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

inline ll min(ll a, ll b) {
    return (a > b) ? b : a;
}

inline ll max(ll a, ll b) {
    return (a > b) ? a : b;
}

const int N = 2e5 + 7;
const int inf = 1e9 + 7;
const ll linf = 1e18 + 9;

int u1[N], u2[N];
int comp[N], comp1[N];
int cnt = 1;
int ans[N];

vector < int > gr[N], gr1[N];

void dfs (int v) {
    u1[v] = cnt;
    for (int to : gr[v]) {
        if (!u1[to]) {
            dfs(to);
        }
    }
}
void dfs1 (int v) {
    u2[v] = cnt;
    for (int to : gr1[v]) {
        if (!u2[to]) {
            dfs1(to);
        }
    }
}

map < pair < int, int >, int > mp;

int main() {
    // freopen("arsenal.in", "r", stdin); freopen("arsenal.out", "w", stdout);
    int n, k, l; scanf ("%d %d %d", &n, &k, &l);
    for (int i = 1; i <= k; i++) {
        int a, b; scanf ("%d %d", &a, &b);
        gr[a].pb(b); gr[b].pb(a);
    }
    for (int i = 1; i <= n; i++) {
        if (!u1[i]) {
            dfs(i);
            cnt++;
        }
    }
    cnt = 1;
    for (int i = 1; i <= l; i++) {
        int a, b; scanf ("%d %d", &a, &b);
        gr1[a].pb(b); gr1[b].pb(a);
    }
    for (int i = 1; i <= n; i++) {
        if (!u2[i]) {
            dfs1(i);
            cnt++;
        }
        mp[{u1[i], u2[i]}]++;
    }
    for (int i = 1; i <= n; i++) {
        printf ("%d ", mp[{u1[i], u2[i]}]);
    }
}


Measured memory_bytes: 30208
n, y = map(int, input().split())
ans = ''
for i in range(n + 1):
  for j in range(n + 1 - i):
    k = n - i  - j
    if 10000 * i + 5000 * j + 1000 * k == y:
      ans = f'{i} {j} {k}'
      break
  if ans:
    break
print(ans if ans else '-1 -1 -1')

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> PII;
typedef map<int, int> MII;
typedef priority_queue<int> P_QI;
typedef priority_queue<string> P_QS;
typedef vector<int> VI;
typedef vector<long long> VLL;
typedef vector< int > :: iterator $$;

#define $ vector< int > :: iterator

#define m_p make_pair
#define p_b push_back
#define rep(i, n) for(auto i=0; i<(n); i++)
#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n - 1); i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)

#define forv(i,v) rep(i,SZ(v))
#define forit(i,s) for(auto i=(s).begin();i!=(s).end();++i)

#define Boost ios_base::sync_with_stdio(0); cin.tie(0)
#define all(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define _ <<" "<<

const int MOD = 1e9+7;
const int inf = 1e9+9;
const long long INF = 1e18+3;
const ld eps = 1e-9;
const ld PI=acos(-1.0);


int main() {
 Boost;
 int n,a,f=1,ans=0,c=1;
 cin>>n;
 rep(i,n) {
    cin>>a;
    if(i+1==a){
            ans++;
        if(f) f=0;
        else c++;
    }
    else ans-=c/2,f=1,c=1;
 }
 ans-=c/2;
 cout<<ans<<endl;

 return 0;
}


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

int main(){
    int x, n, p[100];
    cin >> x >> n;
    for(int i=0;i<n;++i) cin >> p[i];
    bool ng[102] = {0};
    for(int i=0;i<n;++i) ng[p[i]] = true;
    int cand = 100000;
    for(int y=0;y<=101;++y){
        if(ng[y]) continue;
        if(abs(x-y) < abs(x-cand)) cand = y;
    }
    cout << cand << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<P> ab, cd;
    rep(i,n){
        int a,b; cin>>a>>b;
        ab.push_back(make_pair(a,b));
    }
    rep(i,n){
        int a,b; cin>>a>>b;
        cd.push_back(make_pair(a,b));
    }
    sort(all(ab)); sort(all(cd));
    int ans = 0;

    // 条件に合うやつの中で一番yが近いやつをえらぶ
    multiset<int> m;
    const int INF = 1e9;
    int ind = 0; ans = 0;
    for(auto x : cd){
        while(ind < ab.size() && ab[ind].first < x.first) {
            m.insert(ab[ind].second);
            ind++;
        }
        auto it = m.lower_bound(x.second);
        if(it != m.begin()){
            ans++;
            m.erase(prev(it));
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES // for C++  
#include <cmath> 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
#include <functional>


using namespace std;

int main() {
	string o, e;
	cin >> o >> e;
	auto itr_o = o.begin();
	auto itr_e = e.begin();

	for (size_t i = 0; i < (o+e).size(); i++)
	{
		if (i % 2 == 0)
		{
			cout << *itr_o;
			++itr_o;
		}
		else
		{
			cout << *itr_e;
			++itr_e;
		}
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
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; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
	int n, m; cin >> n >> m;
	vector<int> a(m), b(m);
	vector<vector<int>> c;
	rep(i, m) 
	{
		cin >> a[i] >> b[i];
		vector<int> tmp(b[i]);
		rep(j, b[i])cin >> tmp[j];
		c.push_back(tmp);
	}
	vector<int> dp(1 << n, INF);
	dp[0] = 0;
	rep(now, 1 << n)
	{
		rep(i, m)
		{
			int key = 0;
			for(auto e : c[i])key += 1 << (e-1);
			int next = now | key;
			chmin(dp[next], dp[now] + a[i]);
		}
	}
	if(dp[(1 << n) - 1] == INF)cout << -1 << endl;
	else cout << dp[(1 << n) - 1] << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
typedef long long int ll;
using namespace std;
int n;

int main(){
  cin >> n;
  vector<int> a(n), r(n);
  for(int i=0;i<n;i++) {
    cin >> a[i];
    r[i] = a[i];
  }
  sort(r.begin(), r.end(), greater<int>());
  for(int i=0;i<n;i++){
    if (a[i] == r[0]) cout << r[1] << endl;
    else cout << r[0] << endl;
  }
  return 0;
}
  

Measured memory_bytes: 3200
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 

 
void solve()
{
    int  n , m ;
    cin>>n>>m ;
    multiset<ll, greater<ll>>a ;
    rep(i  ,n) {
    	ll temp  ;
    	cin>>temp  ;
    	a.insert(temp) ;
    }
    
    while(m--){
    	auto it = a.begin() ; 
    	ll temp = (*it) / 2 ;
    	a.erase(it) ; 
    	a.insert(temp) ;
    }
    ll ans = 0 ;
    for(auto it = a.begin() ; it!=a.end(); it++){
    	ans += (*it) ;
    }
    cout<<ans<<endl;
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 8452
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	//static String eikomoji[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
	
	
	public static void main(String[] args) {
	String s=sc.next();
	String t=sc.next();
	int a =sc.nextInt();
	int b =sc.nextInt();
	String u=sc.next();
	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	//ArrayList<String> cc = new ArrayList<>(n);
	if(s.equals(u)) {
		a--;
	}else if(t.equals(u)) {
		b--;
	}
	System.out.print(a+" "+b);

	
	
	
	
 }
}

Measured memory_bytes: 22868
#include <iostream>
#include <vector>
#include <algorithm>
#define M 10001
using namespace std;

typedef struct {
  int n;  // PC ÌÔ
  int in,out; // OCEOAEgÌ
} U;


int main(){
  int n,m, r,q;
  int tt,nn,mm,ss;
  int ts,te, ans;
  vector<U> students[M];
  U u;

  while( cin>>n>>m && (n||m) ){

    for( int i=0;i<M;i++ )
      students[i].clear();

    cin >> r;
    for( int i=0;i<r;i++ ){
      cin >> tt >> nn >> mm >> ss;
      if( ss==1 ){  // login
	u.n=nn; u.in=tt; u.out=-1;
	students[mm].push_back( u );
      }else{ // logout
	for( int j=students[mm].size()-1;j>=0;--j ){
	  if( students[mm][j].n==nn ){
	    students[mm][j].out = tt; break;
	  }
	}
      }
    }

    // pÔÌvZ
    for( int i=1;i<=m;i++ ){
      bool f;
      do{
	f=false;
	for( int j=0;j<students[i].size();j++ ){
	  for( int k=0;k<students[i].size();k++ ){
	    if( j==k ) continue;

	    if( students[i][j].in <= students[i][k].in &&
		students[i][k].in <= students[i][j].out ){

	      if( students[i][j].out < students[i][k].out )
		students[i][j].out = students[i][k].out;
	      students[i].erase( students[i].begin()+k );
	      f=true; continue;
	    }
	  }
	}
      }while( f );
    }

    cin >> q;
    for( int loop=0;loop<q;loop++ ){
      cin >> ts >> te >> mm;
      ans=0;

      if( false && q==5 )
      cout << ts << " "<< te << " " << mm << endl;
      for( int i=0;i<students[mm].size();i++ ){
	u = students[mm][i];
	
	if( false && q==5 )
	  cout << "  PC" << u.n << " login:" << u.in
	       << " logout:" << u.out << endl;

	if( u.in<=ts && u.out>ts )
	  ans += ( min(u.out,te)-ts );
	else if( u.in>ts && u.in<te )
	  ans += ( min(te,u.out)-u.in );
      }
      cout << ans << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 0
from sys import stdin

def main():
    input = stdin.readline

    N,C,K = map(int,input().split())

    T = [0] * N

    for i in range(N):
        T[i] = int(input())

    T.sort()

    bus_num = 1
    jyokyaku = 1
    bus_start = T[0]

    for i in range(1,N):
        jyokyaku = jyokyaku + 1
        # jyokyakuが乗れる人数を超えると新しいバスを用意
        if(C < jyokyaku):
            bus_num = bus_num + 1
            bus_start = T[i]
            jyokyaku = 1
        elif(T[i] - bus_start > K):
            bus_num = bus_num + 1
            bus_start = T[i]
            jyokyaku = 1

    
    print(bus_num)


if __name__ == "__main__":
    main()

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

int main()
{
	int n;
	cin>>n;
	vector<long long> A(n+1);
	for(int i=0;i<n;i++) cin>>A[i+1];
	vector<vector<long long>> dp(n+1,vector<long long>(n+1,-1e18-5));
	for(int i=1;i<=n;i++) dp[i][i]=A[i];
	for(int j=1;j<=n;j++)
	{
		for(int i=j;i>1;i--)
		{
			dp[i-1][j]=max({dp[i-1][j],A[i-1]-dp[i][j],A[j]-dp[i-1][j-1]});
		}
	}
	for(int i=n;i>0;i--)
	{
		for(int j=i;j<n;j++)
		{
			dp[i][j+1]=max({A[i]-dp[i+1][j+1],dp[i][j+1],A[j+1]-dp[i][j]});
		}
	}

	// for(int i=1;i<=n;i++)
	// {
	// 	for(int j=1;j<=n;j++)
	// 	{
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	
	cout<<dp[1][n]<<endl;	
}

Measured memory_bytes: 70784
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Hauptteil

(defun main ()
  (let* ((time (read))
         (x (read)))
    (println (float (/ time x) 1d0))))

#-swank(main)


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

using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    vector<long long> hoge(n);
    
    for(int i=0;i<n;i++) cin>>hoge.at(i);
    
    long long ans=100000000000;
    
    for(int i=0;i<=n-k;i++){
        ans=min(ans,min(abs(hoge.at(i+k-1)-hoge.at(i))+abs(hoge.at(i)),abs(hoge.at(i)-hoge.at(i+k-1))+abs(hoge.at(i+k-1))));
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
A = list(map(int,input().split()))
c = [0]*10
add = 0
for i in range(n) :
    if A[i]>=3200 :
        add += 1
        continue
    a = A[i]//400
    c[a] = 1

print(max(sum(c),1),sum(c)+add)

Measured memory_bytes: 3064
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int H, W;
	cin >> H >> W;

	vector<vector<int>> A(H, vector<int>(W));
	vector<vector<int>> B(H, vector<int>(W));
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> A[i][j];
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> B[i][j];

	const int offset = 6500;
	auto dp = make_vec(W + 1, offset * 2 + 1, char(0));
	dp[0][offset] = 1;
	for (int i = 0; i < H; i++) {

		for (int j = 0; j < W; j++) {

			for (int k = 0; k <= 2 * offset; k++) {

				if (0 <= k + A[i][j] - B[i][j] && k + A[i][j] - B[i][j] <= 2 * offset) {
					dp[j + 1][k] |= dp[j][k + A[i][j] - B[i][j]];
				}
				if (0 <= k - A[i][j] + B[i][j] && k - A[i][j] + B[i][j] <= 2 * offset) {
					dp[j + 1][k] |= dp[j][k - A[i][j] + B[i][j]];
				}
				
			}

		}
		DMP(dp);

		if (i == H - 1) break;
		auto tmp = make_vec(W + 1, offset * 2 + 1, char(0));
		for (int j = 1; j <= W; j++) {
			for (int k = 0; k <= 2 * offset; k++) {
				if (0 <= k + A[i + 1][j - 1] - B[i + 1][j - 1] && k + A[i + 1][j - 1] - B[i + 1][j - 1] <= 2 * offset) {
					tmp[j][k] |= dp[j][k + A[i + 1][j - 1] - B[i + 1][j - 1]];
				}
				if (0 <= k - A[i + 1][j - 1] + B[i + 1][j - 1] && k - A[i + 1][j - 1] + B[i + 1][j - 1] <= 2 * offset) {
					tmp[j][k] |= dp[j][k - A[i + 1][j - 1] + B[i + 1][j - 1]];
				}
			}
		}
		swap(tmp, dp);
		DMP(dp);

	}

	int ans = INF;
	for (int i = 0; i <= 2 * offset; i++) {
		if(dp[W][i]) chmin(ans, abs(i - offset));
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 2456