akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void){
        int i = 1;
        int a;
        while(1){
                scanf("%d",&a);
                if(a == 0){
                        break;
                }
                printf("Case %d: %d\n",i,a);
                i = i+1;
        }
        return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>


#define rep(i,p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

//131 B
int main(void) {
	int n, l;
	cin >> n >> l;
	ll ans = 0;
	ll mn = 1000;
	rep(i, 0, n) {
		ll apple = l + i;
		ans += apple;
		if (abs(mn) > abs(apple)) mn = apple;
	}
	cout << ans - mn << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	final boolean DEBUG = false;
	final int MAX_N = 1000000;
	final int INF = Integer.MAX_VALUE;
	void run() {
		Scanner scan = new Scanner(System.in);
		int[] dp1 = new int[MAX_N + 1];
		int[] dp2 = new int[MAX_N + 1];
		for (int i = 1; i <= MAX_N; i++)
			dp1[i] = dp2[i] = INF;

		int[] pollock = new int[MAX_N]; //{ 1, 4, 10, 20, 35 };
		int pCount = 0;
		for (int i = 1;;i++) {
			int p = (i * (i + 1) * (i + 2)) / 6;
			if (p > MAX_N)
				break;
			pollock[pCount++] = p;
			if (DEBUG)
				System.out.println(pollock[pCount - 1]);
		}
		if (DEBUG)
			System.out.println(pCount);

		for (int i = 1; i <= MAX_N; i++) {
			for (int j = 0; j < pCount; j++) {
				if (i - pollock[j] < 0)
					continue;

				dp1[i] = Math.min(dp1[i], dp1[i - pollock[j]] + 1);
				if (pollock[j] % 2 == 1)
					dp2[i] = Math.min(dp2[i], dp2[i - pollock[j]] + 1);
			}
		}
		while (true) {
			int n = scan.nextInt();
			if (n == 0)
				return;
			System.out.println(dp1[n] + " " + dp2[n]);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 39100
#include <cstdio>
#include <iostream>
#include <set>
using namespace std;
inline char nc() {
	static char buf[100000], *l = buf, *r = buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x) {
	x = 0; int f = 1, ch = nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x *= f;
}
int X, Y, Z;
multiset<string> s; 
int main() {
//	freopen("testdata.in", "r", stdin);
	read(X), read(Y), read(Z);
	for(int i = 1; i <= X; ++i) {
		s.insert("a");
	}
	for(int i = 1; i <= Y; ++i) {
		s.insert("b");
	}
	for(int i = 1; i <= Z; ++i) {
		s.insert("c");
	}
	set<string> :: iterator it;
	while(s.size() > 1) {
		string a, b;
		it = s.begin(); a = *it;     s.erase(it);
		it = s.end();   b = *(--it); s.erase(it);
		s.insert(a + b);
	}
	cout << *s.begin() << endl;
	return 0;
}

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

const int MOD = 1000000007;
const int LOG = 100;

vector<pair<LL, LL> > num[LOG];

inline LL read() {
	char c = getchar(); LL ret = 0, f = 1;
	for (; c < '0' || c > '9'; f = c == '-'? -1: 1, c = getchar());
	for (; '0' <= c && c <= '9'; ret = ret * 10 + c - '0', c = getchar());
	return ret * f;
}

inline void solve(LL A, LL B) {
	if (A < num[2][0].first || B < num[2][0].second) {
		printf("1 %d\n", A * B % MOD);
		return;
	}
	for (int i = 2; i < LOG; i++) {
		//cout<<i<<' '<<A<<' '<<num[i + 1][0].first<<' '<<B<<' '<<num[i + 1][0].second<<endl;
		if (A < num[i + 1][0].first || B < num[i + 1][0].second) {
			int cnt = 0;
			for (int j = 0; j < (int)num[i].size(); j++) {
				LL a = num[i][j].first, b = num[i][j].second;
				cnt = (cnt + (a <= A && b <= B? (B - b) / a + 1: 0)) % MOD;
				cnt = (cnt + (b <= A && a <= B? (A - b) / a + 1: 0)) % MOD;
			}
			printf("%d %d\n", i, cnt);
			return;
		}
	}
}

inline void prework() {
	num[0] = vector<pair<LL,LL> >{make_pair(1, 1)};
	for (int i = 1; i < LOG; i++) {
		for (int j = 0; j < (int)num[i - 1].size(); ++j) {
			LL a = num[i - 1][j].first, b = num[i - 1][j].second;
			num[i].push_back(make_pair(b, a + b));
		}
		LL a = num[i - 1][0].first, b = num[i - 1][0].second;
		num[i].push_back(make_pair(a + b, 2 * a + b));
		//cout<<num[i][0].first<<' '<<num[i][0].second<<endl;
	}
}

int main() {
	//freopen("11input.in", "r", stdin);
	prework();
	for (int T = read(); T; T--) {
		LL A = read(), B = read();
		solve(min(A, B), max(A, B));
	}
	return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b) { return b ? gcd(b, a%b) : a; }

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    ll a=h1*60+m1,b=h2*60+m2;
    cout<<b-a-k<<endl;
    return 0;
}


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

int main()
{
	string s,t,u;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	cin>>u;
	if(u==s)
	  cout<<a-1<<' '<<b;
	else cout<<a<<' '<<b-1;
	return 0;
}

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

int main() {
  int k,x;
  cin >> k >> x;
  int a=x+k-1;
  for(int i = x-(k-1); i <=a; i++){
    if(i<a){
      cout<<i<<" ";
    }else{
      cout<<i<<endl;
    }
  }
}

Measured memory_bytes: 3524
S = input()
ori = len(S)

while True:

    if len(S)%2 == 0 and S[:len(S)//2] == S[len(S)//2:] and ori != len(S):

        #print(S[:len(S)//2], S[len(S)//2:])
        print (len(S))
        break

    else:

        S = S[:len(S)-1]

Measured memory_bytes: 38384
n = int(input())
h = list(map(int, input().split()))

ans = 0
cnt = 0
for i in range(len(h)-1):
    if(h[i] >= h[i+1]):
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 14224
h, w, a, b = map(int, input().split())
ans_matrix = [['0'] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if j >= a and i < b:
            ans_matrix[i][j] = '1'
        elif j < a and i >= b:
            ans_matrix[i][j] = '1'
for i in range(h):
    print(''.join(ans_matrix[i]))


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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define F first
#define S second
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif




int p[200010]; 
int main(void) 
{
	
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#endif 


	int n, k; 
	scanf("%d %d", &n, &k); 
	for (int i=0; i<n; i++) 
	{
		scanf("%d", &p[i+1]); 
		p[i+1]+=p[i]; 
	}
	int ans = 0; 
	for (int i=k; i<=n; i++) 
		ans = max(ans, p[i]-p[i-k]); 

	cout << fixed << setprecision(9) << (double) (ans+k)*0.5 << '\n'; 




 
 
 
	return 0;   
}













Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//


int main(void) {

    
    ll X; cin >> X;
    ll t_min = INF;
    for (ll t = 0; t < 100000; ++t) {
        if (t * (t + 1) / 2 >= X) {
            t_min = min(t_min, t);
        }
    }
    out(t_min);






    


    return 0;
}











Measured memory_bytes: 256
n = gets.to_i

_x = 0
_y = 0
_t = 0
n.times do
  t, x, y = gets.split.map(&:to_i)
  dt = t - _t
  dx = (x - _x).abs
  dy = (y - _y).abs
  if dt < (dx + dy)
    puts "No"
    exit
  end
  if (dt - (dx + dy)).odd?
    puts "No"
    exit
  end
end

puts "Yes"


Measured memory_bytes: 1788
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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; }

int n, a, b, c, ans = 1e9;
vector<int> l;

void dfs(int depth, int alen, int blen, int clen, int mp) {
    if(depth > n) {
        // 目標の竹は1以上が確約されているのでずっとAだけ～のようなパターンを排斥
        if(alen && blen && clen) ans = min(ans, abs(a - alen) + abs(b - blen) + abs(c - clen) + mp);
        return ;
    }
    dfs(depth + 1, alen, blen, clen, mp); // この竹を使用しない
    dfs(depth + 1, alen + l[depth], blen, clen, mp + 10 * (alen > 0)); // aを作るのに使用 (alen > 0) は一本目を選ぶときの状態を除くため
    dfs(depth + 1, alen, blen + l[depth], clen, mp + 10 * (blen > 0)); // bを作るのに使用
    dfs(depth + 1, alen, blen, clen + l[depth], mp + 10 * (clen > 0)); // cを作るのに使用
}

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

    cin >> n >> a >> b >> c;
    l.resize(n + 1);
    rep(i, n) cin >> l[i + 1];
    dfs(1, 0, 0, 0, 0);
    cout << ans << endl;
}


Measured memory_bytes: 256
def comb(n, k, nk, mod):
    return (n * pow(k * nk, mod - 2, mod)) % mod


def main():
    n, m, k = map(int, input().split())
    mod = 998244353
    ans = 0
    base = pow(m - 1, n - 1 - k, mod)
    fact = [1 for _ in range(n + 1)]
    for i in range(1, n + 1):
        fact[i] = fact[i - 1] * i
        fact[i] %= mod
    for i in range(k, -1, -1):
        ans += base * comb(fact[n - 1], fact[i], fact[n - i - 1], mod)
        ans %= mod
        base *= m - 1
        base %= mod
    ans *= m
    ans %= mod
    print(ans)


if __name__ == '__main__':
    main()



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

int main(){
  map<string,int> s;
  int n;
  cin >>n;
  vector<string> t(n);
  rep(i,n) cin >> t[i];
  int c=1;
  rep(i,n){
    if(s.find(t[i])==s.end()){
      s.insert(make_pair(t[i],1));
    }
    else {
      ++s.at(t[i]);
      c= max(c,s.at(t[i]));
    }
  }
  for(auto itr = s.begin(); itr != s.end(); ++itr){
    if(itr->second==c) cout << itr->first << endl;
  }
  return 0;
}


Measured memory_bytes: 25080
# Author: cr4zjh0bp
# Created: Tue Mar 24 00:01:43 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from itertools import permutations

n, m = na()
ab = nan(m)
g = [[] for _ in range(n)]
for i in range(m):
    a, b = ab[i]
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

def dfs(i, c, p):
    if p[c] == i:
        if c == n - 1:
            return 1
    else:
        return 0
    res = 0
    for j in g[i]:
        res = max(res, dfs(j, c + 1, p))
    return res

ans = 0
for p in permutations(range(n)):
    if p[0] == 0:
        ans += dfs(0, 0, p)

print(ans)

Measured memory_bytes: 3188
def main():
    a, b, c = map(int, input().split())
    m = max(a, b, c)
    d = m * 3 - sum([a, b, c])
    ans = d // 2
    if d % 2 == 0:
        print(ans)
    else:
        print(ans + 2)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <unordered_map>
#define has(g, i) (g.find(i) != g.end())
#define ll long long
#define MAX 100000
using namespace std;
#define ll long long
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vvll vector<vll>
#define pq priority_queue
#define x first
#define y second

ll mod = 1e9 + 7;
ll binpow(ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)
			res = (res * a) % mod;
		a = (a * a) % mod;
		n >>= 1;
	}
	return res;
}

ll rev(ll a) {
	return binpow(a, mod - 2);
}

vector<ll> fact;

ll comb(int i, int j) {
	if (i > j) {
		return 0;
	}

	ll prod = rev((fact[i] * fact[j - i]) % mod);
	return (fact[j] * prod) % mod;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	fact.resize(n + 2);
	fact[0] = 1;
	
	for (int i = 1; i < fact.size(); ++i) {
		fact[i] = (fact[i - 1] * i) % mod;
	}
	
	
	vector<ll> arr(n + 1);
	vector<ll> check(n, -1);
	int first = -1, second = -1;
	for (int i = 0; i <= n; ++i) {
		cin >> arr[i];
		if (check[arr[i] - 1] != -1) {
			first = check[arr[i] - 1];
			second = i;
		}
		else {
			check[arr[i] - 1] = i;
		}
	}
	
	for (int k = 1; k <= n + 1; ++k) {
		ll res = comb(k, n + 1);

		res = (res + mod - comb(k - 1, n + 1 - (second - first + 1)) ) % mod;
		cout << res << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
using vint = vector<int>;
using vLL = vector<LL>;

int main(){
	int a, p;
	cin >> a >> p;
	int s = 3*a+p;
	s /= 2;
	cout << s << endl;
}

Measured memory_bytes: 256
from itertools import groupby

R = lambda: map(int, input().split())
n, k = R()
a = list(R())
w = [0] * n

def merge(b, e):
    m = b + (e - b) // 2
    i, j = b, m
    r = k = 0
    while i < m and j < e:
        if a[i] <= a[j]:
            w[k] = a[i]
            i += 1
        else:
            r += m - i
            w[k] = a[j]
            j += 1
        k += 1
    a[e - m + i: e] = a[i: m]
    a[b: b + k] = w[:k]
    return r        
    
def mergesort(b, e):
    if e - b < 2:
        return 0
    m = b + (e - b) // 2
    return mergesort(b, m) + mergesort(m, e) + merge(b, e)


r = k * mergesort(0, n)
c = n * (n - 1) // 2
for _, g in groupby(a):
    x = sum(1 for _ in g)
    c -= x * (x - 1) // 2
print((r + c * k * (k - 1) // 2) % (10**9 + 7))


Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,m;
    cin>>n>>m;
    vi a(m);
    rep(i,m)cin>>a[i];
    int ans=n-accumulate(all(a),0ll);
    if(ans<0)ans=-1;
    cout<<ans<<endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
                using namespace std;
                typedef long long ll;
                #define INPUT()              freopen("input.txt", "r", stdin)
                #define OUTPUT()             freopen("output.txt", "w", stdout)
                #define F                    first
                #define S                    second
            //Templatefunctions
                template<typename T>T gcd(T x, T y) { if (y == 0)return x; else return gcd(y, x%y);}
                template <class T> T euclideanDistance(T x1 , T x2 , T y1 , T y2){return sqrt(( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ));}
                template <class T> T digitSum(T n){T sum = 0;while(n > 0)sum += n % 10,n /= 10;return sum;}
            //datatypes
                typedef long long int ll;
                typedef unsigned long long int ull;
                typedef long double ld;
            //constants
                const double INF = 1e+9;
                const double INFLL = 1e+18;
                const double EPS = 1e-9;
                const double PI = acos(-1);
                const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
                       //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
                       //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
                const int dx[] = {0 , 1 , 0 , -1};
                const int dy[] = {1 , 0 , -1 , 0};
            //helpers
                //#define MOD         1000000007LL
                #define MAX         1000005
                const ll MOD = 998244353;
                int arr[MAX];
            //Global Variables



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

                        string arr[x];

                        for(int i = 0 ; i < x ; i++)
                        {
                            cin>>arr[i];
                            //cout<<arr[i]<<"\n"<<arr[i]<<"\n";
                        }
                        for(int i = 0 ; i < x ; i++)
                        {
                            //cin>>arr[i];
                            cout<<arr[i]<<"\n"<<arr[i]<<"\n";
                        }
                }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
    ll n; cin>>n;
    vector<int> v;
    for(int i=0;i<n;i++){
        int x; cin>>x;
        x=-x;
        auto it=upper_bound(v.begin(),v.end(),x);
        if(it==v.end()) v.pb(x);
        else *it=x;       
    }
    cout<<v.size()<<endl;  
}

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

int main(){
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  if(L > R){
    cout << "Left" << endl;
  }else if(L == R){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        Map<String, Map<Integer, Integer>> gidebook = new TreeMap<>();
        List<Integer> ansList = new ArrayList<>();

        for (int i = 1; i <= num; i++) {
            String inCity = sc.next();
            if (!gidebook.containsKey(inCity)) {
                gidebook.put(inCity, new TreeMap<Integer, Integer>(Comparator.reverseOrder()));
            }
            gidebook.get(inCity).put(sc.nextInt(), i);
        }

        for (String city : gidebook.keySet()) {
            for (Integer score : gidebook.get(city).values()) {
                System.out.println(score);
            }
        }

    }
}


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

int main()
{
    int N, M;
    std::cin >> N >> M;

    //std::vector<int> K(N);
    //std::vector<std::vector<int>> A(N);

    std::vector<int> S(M, 0);

    for (int i = 0; i < N; i++) {
        int K;
        std::cin >> K;
        //std::cin >> K[i];
        //A[i].resize(K[i]);
        for (int j = 0; j < K; j++) {
            //std::cin >> A[i][j];
            int A;
            std::cin >> A;
            S[A-1]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < M; i++) {
        if (S[i] == N) ans++;
    }

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

    return 0;
}

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

using namespace std;

int dp[2666][2666];

int main() {
    int sx, sy, tx, ty;
    cin>>sy>>sx>>ty>>tx;
    for(int i = 0 ; i < tx - sx; i++)
        putchar('U');
    for(int i = 0; i < ty - sy; i++)
        putchar('R');
    for(int i = 0 ; i < tx - sx; i++)
        putchar('D');
    for(int i = 0; i < ty - sy; i++)
        putchar('L');

    putchar('L');
    for(int i = 0 ; i < tx - sx + 1; i++)
        putchar('U');
    for(int i = 0; i < ty - sy + 1; i++)
        putchar('R');
    putchar('D');

    putchar('R');
    for(int i = 0 ; i < tx - sx + 1; i++)
        putchar('D');
    for(int i = 0; i < ty - sy + 1; i++)
        putchar('L');
    putchar('U');
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  REP(i, s.length()) {
    if (s[i] == 'U' || s[i] == 'D') continue;
    if ((i + 1) % 2 == 0) {
      if (s[i] != 'L') {
        cout << "No" << endl;
        return 0;
      }
    } else {
      if (s[i] != 'R') {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

string s;
map<string,int>mp;
int n;

int counter=0;

void f(string frr,int a,int b,int c)
{
     //cout<<frr<<endl;
       if(frr.size()>s.size())return;

    if(a>0&&b>0&&c>0&&(frr<=s||frr.size()<s.size()))
    {
       // cout<<frr<<endl;
        if(mp[frr]==0)
        {
            counter++;
            mp[frr]=1;
        }
    }

    string krr,arr,lrr;
    krr=frr;
    arr=frr;
    lrr=frr;
    f(krr+='3',a+1,b,c);
    f(arr+='5',a,b+1,c);
    f(lrr+='7',a,b,c+1);
}

int main()
{
   cin>>s;
   n=s.size();
    string frr;
    f(frr,0,0,0);
    cout<<counter<<endl;
}


Measured memory_bytes: 3456
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	double L; cin >> L;
	printf("%.9f\n", L*L*L / 27.0);


	return 0;
}



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

using namespace std;

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

const double inf=1e20;

inline int sign(const double &x){
    if(x>EPS) return 1;
    else if(x<-EPS) return -1;
    return 0;
}

/*   点  */
struct Point{
    double x,y;

    Point(double x=0,double y=0):x(x),y(y){}

    Point operator + (Point p) { return Point(x+p.x,y+p.y); }
    Point operator - (Point p) { return Point(x-p.x,y-p.y); }
    Point operator * (double k) { return Point(k*x,k*y); }
    Point operator / (double k) { return Point(x/k,y/k); }

    //向量的大小
    inline double abs(){ return sqrt(norm()); }
    inline double norm() { return x*x+y*y; }

    bool operator < (const Point & p) const{
        return x!=p.x?x<p.x:y<p.y;
    }

    bool operator == (const Point & p) const {
        return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
    }
};

//两点间的距离
inline double getDistance(Point a,Point b){
    return (a-b).abs();
}

/*   向量  */
typedef Point Vector;

//向量a和b的内积
double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}
//向量a和b的外积
double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

// *********圆***********
struct Circle{
    Point c;
    double r;
    Circle(Point c = Point() ,double r = 0.0 ):c(c),r(r){}
};

//两个圆的位置关系
const int SEPARATION = 4;        //相离
const int EXTERNAL_CUT = 3;      //外切
const int INTERSECTION = 2;      //相交
const int INTERNAL_CUT = 1;      //内切
const int INCLUDE = 0;           //内含

int getCircleToCircle(Circle c1,Circle c2){
    double dis=getDistance(c1.c,c2.c);
    if(c1.r+c2.r<dis){
        return SEPARATION;
    }else if(c1.r+c2.r==dis){
        return EXTERNAL_CUT;
    }else {
        if(sign(fabs(c1.r-c2.r)-dis)==0) return INTERNAL_CUT;
        else if(sign(fabs(c1.r-c2.r)-dis)==1) return INCLUDE;
        return INTERSECTION;
    }
}


int main(){
    double x,y,r;
    scanf("%lf%lf%lf",&x,&y,&r);
    Circle c1(Point(x,y),r);
    scanf("%lf%lf%lf",&x,&y,&r);
    Circle c2(Point(x,y),r);
    printf("%d\n",getCircleToCircle(c1,c2));
    return 0;
}



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

int q(int p){ cout<<p<<endl; string s; cin>>s; return s[0]=='M' ? 0 : s[0] =='F' ? 1 : 2; }

void solve(int le, int ri, int tl, int tr){
	//int tl = q(le), tr = q(ri);
	if(le == ri){ q(le); return; }
	int m = (le+ri)/2;
	int tm = q(m);
	if(tm == 2) return;
	if(tm == (tl^((m-le)&1))) solve(m+1, ri, tm^1, tr);
	else solve(le, m, tl, tm);
}

int main(){
	int n;
	cin>>n;
	//int t0 = q(0), t1 = q(n-1), t2 = q(n-2);
	//if(t0==0 || t1==0 || t2==0) return 0;
	int t = q(n-1);
	if(t == 2) return 0;
	solve(0, n-2, t^1, t^1);

	return 0;
}


Measured memory_bytes: 852
N,X=map(int,input().split())

lv_len=[1]
lv_pad=[1]

for i in range(N):
  lv_len.append(lv_len[i]*2+3)
  lv_pad.append(lv_pad[i]*2+1)

def solve(n,x):
  if n==0:
    return 1
  elif x==1:
    return 0
  else:
    if x <= lv_len[n]//2:
      return solve(n-1,x-1)
    elif x == lv_len[n]//2 +1:
      return 1 + solve(n-1,x-2)
    else:
      return lv_pad[n-1] + 1 + solve(n-1,x-(lv_len[n-1]+2))
    
print(solve(N,X))

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

ll N;

void solve() {
  ll h, n, w;
  for (h = 1; h <= 3500; h++) {
    for (n = 1; n <= 3500; n++) {
      if (4 * h * n - N * (h + n) > 0 &&
          (N * h * n) % (4 * h * n - N * (h + n)) == 0) {
        w = (N * h * n) / (4 * h * n - N * (h + n));
        cout << h << " " << n << " " << w << "\n";
        return;
      }
    }
  }
}

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

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm: canFind;

void main() {
	string[] inputs = split(readln());
	int A = to!int(inputs[0]);
	int B = to!int(inputs[1]);
	int C = to!int(inputs[2]);
	
	if(C >= A && C <= B) "Yes".writeln;
	else "No".writeln;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;

vector<int> ans;

void make(int a){
  if(a==0){
    for(int i=1;i<=9;i++){
      ans.push_back(i);
      make(i);
    }
  }else{
    int number=a%10;
    if(number!=0){
      if(a*10 + number - 1 <= 3234566667){
	ans.push_back(a*10 + number - 1);
	make(a*10 + number - 1);
      }
    }
    if(a*10 + number <= 3234566667){
      ans.push_back(a*10 + number);
      make(a*10 + number);
    }
    if(number!=9){
      if(a*10 + number+1 <= 3234566667){
	ans.push_back(a*10 +( number+1));
	make(a*10 + (number+1));
      }
    }
  }
}


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int k;
  cin>>k;
  make(0);
  sort(ans.begin(),ans.end() );
  cout<<ans[k-1]<<endl;
  return 0;
}


Measured memory_bytes: 1400
// 23.07.2017

/*
D - Insertion

Time limit : 2sec / Memory limit : 256MB
Score : 400 points
Problem Statement
You are given a string S of length N consisting of ( and ).
Your task is to insert some number of ( and ) into S to obtain a correct bracket sequence.
Here, a correct bracket sequence is defined as follows:
    () is a correct bracket sequence.
    If X is a correct bracket sequence, the concatenation of (, X and ) in this order is also a correct bracket sequence.
    If X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence.
    Every correct bracket sequence can be derived from the rules above.
Find the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one.
Constraints
    The length of S is N.
    1 <= N <= 100
    S consists of ( and ).
Input
Input is given from Standard Input in the following format:
N
S
Output
Print the lexicographically smallest string among the shortest correct bracket sequences
that can be obtained by inserting some number of ( and ) into S.
Sample Input 1
3
())
Sample Output 1
(())
Sample Input 2
6
)))())
Sample Output 2
(((()))())
Sample Input 3
8
))))((((
Sample Output 3
(((())))(((())))


*/




# include <iostream>
# include <iomanip>
# include <cstdio>
# include <cstdlib>
# include <cmath>
# include <cstring>
# include <vector>
# include <stack>
# include <queue>
# include <algorithm>


//# define __TRR__

using namespace std;

const int N = 222;

int n, m, k, mi, ma;
char s [N];


int main ()
{
# ifdef __TRR__
   freopen ("D.TXT", "r", stdin);
   freopen ("D.OUT", "w", stdout);
# endif

   cin >> n >> s;

# ifdef __TRR__
   cout << n << endl << s << endl;
# endif

   for ( int i=0; i < n; i++ )
   {
      if ( s [i] == '(' )
         k ++;
      else
         k --;
      if ( k < mi )
         mi = k;
   }

   if ( k - mi > ma )
      ma = k - mi;

   for ( int i=0; i < -mi; i++ )
      cout << "(";

   cout << s;

   for ( int i=0; i < ma; i++ )
      cout << ")";

//system ("pause");
   return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np

n = int(sys.stdin.readline().rstrip())
a = np.array(sys.stdin.readline().split(), dtype=np.int64)

def main():
    res = np.bincount(np.minimum(a // 400, 8), minlength=9)
    
    ans_min = np.count_nonzero(res[:8])
    ans_max = ans_min + res[8]
    if ans_min == 0:
        ans_min = 1
 
    return ans_min, ans_max

if __name__ == '__main__':
    ans = main()
    print(*ans, sep=' ')

Measured memory_bytes: 12508
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  while(scanf("%d %d %d",&a,&b,&c)!=EOF){
    int sum=a+b,cnt=0;
    for(int i=1;i<=10;i++){
      if(sum + i<=20 && i!=a && i!=b && i!=c) cnt++;
    }
    printf("%s\n",cnt>=4?"YES":"NO");
  }
}

Measured memory_bytes: 1168
// ABC110_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値

int main() {
    // input
    ll N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<ll> vec_X(N), vec_Y(M);
    REP(i, N) cin >> vec_X[i];
    REP(i, M) cin >> vec_Y[i];
    vec_X.push_back(X);
    vec_Y.push_back(Y);
    
    
    // calculation
    ll max_X = *MAX(vec_X);
    ll min_Y = *MIN(vec_Y);
    if (max_X < min_Y) {
        cout << "No War" << "\n";
    } else {
        cout << "War" << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi(init, n) for(int i = init; i < n; i++)
#define fj(init, n) for(int j = init; j < n; j++)
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef long long ll;
using namespace std;

int main()
{
	ios
	int n;
	cin >> n;
	if(n%1000)
		cout << 1000-n%1000;
	else
		cout << 0;
	
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>

using namespace std;

class info {
public:
    int tid;
    int pen;
    int cor;
    int p[10];
    info() {
        tid = 0;
        pen = 0;
        cor = 0;
        for (int i = 0; i < 10; i++)
            p[i] = 0;
    }
};

bool cmp(const class info &a, const class info &b)
{
    return (a.cor > b.cor) || (a.cor == b.cor && a.pen < b.pen) ||
        (a.cor == b.cor && a.pen == b.pen && a.tid < b.tid);
}

int main()
{
    int t, p, r;

    while (cin >> t >> p >> r, t || p || r) {
        info m[50];

        for (int i = 0; i < t; i++)
            m[i].tid = i + 1;

        for (int i = 0; i < r; i++) {
            int tid, pid, tm;
            string mes;

            cin >> tid >> pid >> tm >> mes;

            if (mes == "WRONG") 
                m[tid - 1].p[pid - 1]++;
            else if (mes == "CORRECT") {
                m[tid - 1].cor++;
                m[tid - 1].pen += m[tid - 1].p[pid - 1] * 1200 + tm;
            }
        }

        sort(m, m + t, cmp);

        for (int i = 0; i < t; i++)
            cout << m[i].tid << " " << m[i].cor << " " << m[i].pen << endl;
    }

    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_output(v) for(auto it=v.begin();it!=v.end();it++){if(it!=v.begin())cout<<" ";cout<<*it;}cout<<endl;
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);
long long int combination(long long int,long long int);
long long int series_sum(long long int);

int main(){
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            cout<<i<<"x"<<j<<"="<<i*j<<endl;
        }
    }
}


Measured memory_bytes: 3040
/*
 Author: LargeDumpling
 Email: LargeDumpling@qq.com
 Edit History:
	2017-08-06	File created.
*/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int num[3],n;
int main()
{
	//freopen("code.in","r",stdin);
	//freopen("code.out","w",stdout);
	int x;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if(!(x%4)) num[2]++;
		else if(!(x%2)) num[1]++;
		else num[0]++;
	}
	if(num[1]) n-=(num[1]-1);
	if((n/2)<=num[2]) printf("Yes");
	else printf("No");
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <sstream>
#include <complex>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using iii = pair<int, ii>;
using viii = vector<iii>;

using ll = long long int;
using vc = vector<char>;
using vb = vector<bool>;
using ib = pair<int, bool>;
using vib = vector<ib>;

#define MOD 1000 * 1000 * 1000 + 7
#define INF 1000 * 1000 * 1000
#define EMPTY -10
#define mp(a, b) make_pair(a,b)

bool resuelveCaso() {
	int n;
	cin >> n;
	if (!cin) return false;

	int a = n / 2;
	int b;
	if (n % 2 == 0) b = n / 2;
	else b = n / 2 + 1;

	cout << a * b << '\n';

	return true;
}

int main() {
	while (resuelveCaso()) {}
	return 0;
}

Measured memory_bytes: 256
class UnionFindTree:
    def __init__(self, n):
        self.__parents = [-1] * n

    def find(self, x):
        p = self.__parents[x]
        if p < 0:
            return x
        p = self.find(p)
        self.__parents[x] = p
        return p

    def union(self, x, y):
        p = self.__parents
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if p[x] > p[y]:
            x, y = y, x
        p[x] += p[y]
        p[y] = x
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)


N = int(input())
uft = UnionFindTree(N)
cur = 0
buttons = list(map(lambda x: int(x) - 1, (input() for _ in range(N))))
count = 0
while True:
    n = buttons[cur]
    count += 1
    if not uft.union(cur, n):
        count = -1
        break
    if n == 1:
        break
    cur = n
print(count)

Measured memory_bytes: 7860
import sys
from collections import deque as dq
input = sys.stdin.readline
H, W, K = map(int, input().split())
x, y, u, v = map(int, input().split())
x -= 1
y -= 1
u -= 1
v -= 1
a = [list(input())[: -1] for _ in range(H)]
Q = dq([(0, x * W + y)])
inf = H * W + 1
dp = [inf] * (H * W)
dp[x * W + y] = 0
while len(Q):
  cost, t = Q.popleft()
  dp[t] = cost
  p = t // W
  q = t % W
  if (p, q) == (u, v):
    print(cost)
    exit(0)
  for i in range(1, K + 1):
    pp = p + i
    if pp in range(H):
      if a[pp][q] == "@": break
      if dp[pp * W + q] <= dp[t]: break
      if dp[pp * W + q] != inf: continue
      dp[pp * W + q] = dp[t] + 1
      Q.append((dp[t] + 1, pp * W + q))
  for i in range(1, K + 1):
    pp = p - i
    if pp in range(H):
      if a[pp][q] == "@": break
      if dp[pp * W + q] <= dp[t]: break
      if dp[pp * W + q] != inf: continue
      dp[pp * W + q] = dp[t] + 1
      Q.append((dp[t] + 1, pp * W + q))

  for i in range(1, K + 1):
    qq = q + i
    if qq in range(W):
      if a[p][qq] == "@": break
      if dp[p * W + qq] <= dp[t]: break
      if dp[p * W + qq] != inf: continue
      dp[p * W + qq] = dp[t] + 1
      Q.append((dp[t] + 1, p * W + qq))

  for i in range(1, K + 1):
    qq = q - i
    if qq in range(W):
      if a[p][qq] == "@": break
      if dp[p * W + qq] <= dp[t]: break
      if dp[p * W + qq] != inf: continue
      dp[p * W + qq] = dp[t] + 1
      Q.append((dp[t] + 1, p * W + qq))
print(-1)


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

#define ff first
#define ss second
using namespace std;
#define maxn 2000006
#define pb push_back
#define ll long long
#define lll __int128
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)
inline void fastio(){ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);}

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



int main(){
	fastio();

	string s; cin>>s;

	f(i,0,s.length()-1){
		if(i%2==0 and s[i]=='L'){
			cout<<"No";
			exit(0);
		}

		if(i%2==1 and s[i]=='R'){
			cout<<"No";
			exit(0);
		}
	}

	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
N=int(input())
suits=["S","H","C","D"]
cards=[]
for _ in range(N):
    s,n=input().split()
    if s=="S":
        cards.append(int(n))   
    elif s=="H":
        cards.append(13+int(n))   
    elif s=="C":
        cards.append(26+int(n))
    else:
        cards.append(39+int(n))

for i in range(1,53):
    if i not in cards:
        print(suits[(i-1)//13],(i-1)%13+1)


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

int partition(int* a, int p, int r) {
    int x = a[r], n = p-1;
    for(int i = p; i < r; i++) {
        if (a[i] <= x){
            n++;
            swap(a[n], a[i]);
        }
    }
    swap(a[n+1], a[r]);
    return n+1;
}

int main() {
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int p = partition(a, 0, n-1);
    for(int i = 0; i < n; i++){
        if(p != i) cout << a[i];
        else cout << "[" << a[i] << "]";
        if(i != n-1) cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 3476
#include<bits/stdc++.h>
using namespace std;
int dp[3009][3009];
main()
{
    vector<char> v;
    string a,b;
    cin >> a;
    cin >> b;
    int A=a.size();
    int B=b.size();
    int mx=0;
    for(int i = 1 ; i <= A ; ++i)
    {
        for(int j = 1 ; j <= B ; ++j)
        {
            if(a[i-1]==b[j-1])
            {
            dp[i][j]=dp[i-1][j-1]+1;
            }
            else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    /*for(int i = 1 ; i <= A ; ++i)
    {
        for(int j =1 ; j <= B ; ++j)
        {
        printf("%d ",dp[i][j]);
        }
        printf("\n");
    }*/
    int cn=dp[A][B];
    if(cn!=0)
    {
    while(1)
    {
        if(!dp[A][B])break;
        if(dp[A][B]-1==dp[A-1][B-1]&&dp[A-1][B]==dp[A][B-1])
        {
        v.emplace_back(b[B-1]);
        --A;--B;
        }
        else if(dp[A-1][B]==dp[A][B])
        {
        --A;
        }
        else if(dp[A][B-1]==dp[A][B])
        {
        --B;
        }
    }
    reverse(v.begin(),v.end());
    for(auto it : v)cout << it;
    }
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const long long MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

int main () {

    ll h,w;cin>>h>>w;

    if (h==1||w==1) {
        cout<<1<<endl;
        return 0;
    }

    if (h*w%2==0) {
        cout<<(h*w)/2<<endl;
    } else {
        cout<<(h*w+1)/2<<endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>

#define ll long long
#define ull unsigned long long
#define mod 1000000007

using namespace std;

struct work{
    int a;
    int b;
};

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

    int n, m;
    work* works;
    cin >> n >> m;
    works = new work[n];
    for(int i = 0; i < n; ++i){
        cin >> works[i].a >> works[i].b;
    }

    sort(works, works+n, [](work &x, work &y){
        if(x.a == y.a){
            return x.b > y.b;
        }else{
            return x.a < y.a;
        }
    });

    ll sum = 0;
    int date = 1;
    priority_queue<int> que;
    for(int i = 0; i < n && date <= m; ++i){
        if(works[i].a <= date){
            que.push(works[i].b);
        }else if(!que.empty()){
            sum += que.top();
            que.pop();
            ++date;
            --i;
        }else{
            ++date;
            --i;
        }
    }

    for(int i = 0; date <= m && !que.empty(); ++date){
        sum += que.top();
        que.pop();
    }

    cout << sum << "\n";
    delete[] works;
    return 0;
}


Measured memory_bytes: 1660