akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){
   int w,h,n;
   cin>>w>>h>>n;
   int re[w][h];
   rep(i,w){
      rep(j,h){
         re[i][j]=0;
      }
   }
   rep(i,n){
      int x,y,a;
      cin>>x>>y>>a;
      if(a==1){
         rep(p,x){
            rep(q,h){
               re[p][q]=1;
            }
         }
      }
      else if(a==2){
         for(int p=x;p<w;p++){
            rep(q,h){
               re[p][q]=1;
            }
         }
      }
      else if(a==3){
         rep(p,w){
            rep(q,y){
               re[p][q]=1;
            }
         }
      }
      else if(a==4){
         rep(p,w){
            for(int q=y;q<h;q++){
               re[p][q]=1;
            }
         }
      } 
   }
   int ans=0;
   rep(i,w){
      rep(j,h){
         if(re[i][j]==0) ans++;
      }
   }
   cout<<ans;

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;
	int miner = 0;
	bool zero = false;
	for (int i = A; i <= B; i++) {
		if (i < 0) {
			miner++;
		}
		if (i == 0) {
			zero = true;
		}
	}
	if (zero) {
		cout << "Zero" << endl;
	}
	else if (miner % 2 == 1) {
		cout << "Negative" << endl;
	}
	else {
		cout << "Positive" << endl;
	}
}

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

int main() {
  char a;
  cin >> a;
  if(('A' <= a) && (a <= 'Z')) cout << 'A' << endl;
  else cout << 'a' << endl;
}
    

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lim 100005
#define mod 1000000007
#define mp make_pair
#define sd(n) scanf("%lld",&n)
#define FIO(name) freopen(name,"r",stdin)
#define F first
#define S second
ll a[lim+1];
int main()
{
	
	//FIO("in.txt");
	string s;
	cin>>s;
	cout<<"A";
	cin>>s;
	cout<<s[0];
	cin>>s;
	cout<<"C";

	
	
	
}



Measured memory_bytes: 256
#include<stdio.h>

void trace(int A[], int N){
 int i;
 for (i = 0; i < N; i++){
  if (i > 0) printf(" ");
  printf("%d", A[i]);
 }
 printf("\n");
}

void insertionSort(int A[], int N){
 int j, i, v;
 for (i = 1; i < N; i++){
  v = A[i];
  j = i - 1;
  while (j >= 0 && A[j] > v){
   A[j + 1] = A[j];
   j--;
  }
  A[j + 1] = v;
  trace(A, N);
 }
}

int main(){
 int N, i, j;
 int A[100];

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

 trace(A, N);
 insertionSort(A, N);

 return 0;
}


Measured memory_bytes: 2108
n=gets.to_i-1
ans=(n.modulo(26)).to_s(26).tr("0-9a-p","a-z")
n=n.div(26)-1
while n>=0 do
  ans=(n.modulo(26)).to_s(26).tr("0-9a-q","a-z")+ans
  n=n.div(26)-1
end
puts ans


Measured memory_bytes: 14084
#include <cstdio>
#include <vector>
using namespace std;
int n,m,q,maxx;
int a[55],b[55],c[55],d[55];
vector<int>v;
int check(){
	int sum=0;
	for(int i=0;i<q;++i){
		if(v[b[i]-1]-v[a[i]-1]==c[i])sum+=d[i];
	}
	return sum;
}
void dfs(int p){
	if(p==n){
		int res=check();
		if(maxx<res)maxx=res;
		return;
	}
	for(int i=v.back();i<=m;++i){
		v.push_back(i);
		dfs(p+1);
		v.pop_back();
	}
}
int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=0;i<q;++i)scanf("%d%d%d%d",a+i,b+i,c+i,d+i);
	v.push_back(1);
	dfs(1);
	printf("%d\n",maxx);
	return 0;
}

Measured memory_bytes: 3224
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    d = defaultdict(int)
    for _ in range(ii()):
        d[input()] += 1
    for a in ('AC', 'WA', 'TLE', 'RE'):
        print(a, 'x', d[a])





main()



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

const int N=2e5+1e2;

typedef long long ll;

ll Ans;
int cnt[N];
int main(){
	int n,k;
	cin>>n>>k;
	int tot=n/k,L=n%k;
	for(int i=0;i<=L;i++)cnt[i]=tot+1;
	for(int i=L+1;i<k;i++)cnt[i]=tot;
	cnt[0]--;
	for(int i=0;i<k;i++){
		if(i!=0 && i+i==k)Ans+=1ll*cnt[i]*cnt[k-i]*cnt[i];
		else if(i+i==k || i==0)Ans+=1ll*cnt[i]*cnt[i]*cnt[i];
	}
	printf("%lld\n",Ans);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
	int A, B, C, D, E, F;

	cin >> A >> B >> C >> D >> E >> F;

	int a = 100*A, b = 0;

	for (int i = 0; 100 * A*i <= F; i++) {
		for (int j = 0; 100 * A*i + 100 * B*j <= F; j++) {
			for (int n = 0; C*n <= (A*i + B*j)* E; n++) {
				for (int m = 0; D*m <= (A*i + B*j)*E - C * n; m++) {
					int water = 100 * A*i + 100 * B*j;
					int sugar = C * n + D * m;
					if ((100.0*b) / (a + b) < (100.0*sugar) / (water + sugar) && water+sugar <= F){
						a = water;
						b = sugar;
					}
				}
			}
		}
	}

	cout << a + b << " " << b << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

A,B,C = [int(i) for i in input().split()]

M = []
for i in range(1,100+1):
    if (A*i)%B in M:
        break
    else:
        M.append((A*i)%B)

if C in M:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 9144
# abc086_a
# 積が奇数なら'Odd'偶数なら'Even'と出力

a, b = map(int, input().split())

answer = a * b
# % とは割り算の余りを求める演算子
if answer % 2 == 0:
    print('Even')

else:
    print('Odd')

Measured memory_bytes: 9160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9 + 7;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  vector<P> tasks(n);
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    tasks[i] = P(b, a);
  }
  sort(tasks.begin(), tasks.end());
  int time = 0;
  for (P t : tasks) {
    int a = t.second, b = t.first;
    if (time + a > b) {
      cout << "No" << endl;
      return 0;
    }
    time += a;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1792
//https://codeforces.com/contest/1328/problem/A
//BROWNIE TK

#include <bits/stdc++.h>
using namespace std;

typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()

#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en

#define le length()
#define mp make_pair
#define mt make_tuple
#define acc(v) accumulate(all(v), 0)
#define F first
#define S second

#define pll pair<lli, lli>
#define pii pair<int, int>
#define pil pair<int, lli>

#define forz(i, n) for (int i = 0; i < n; i++)
#define fore(i, m, n) for (int i = m; i <= n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rfore(i, m, n) for (int i = n; i >= m; i--)

#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)

#define bset(a, p) ((a) | (1ll << (p)))
#define bchk(a, p) ((a) & (1ll << (p)))
#define bxor(a, p) ((a) ^ (1ll << (p)));
#define brem(a, p) (bchk(a, p) ? (bxor(a, p)) : (a))
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/

#define lb lower_bound
#define ub upper_bound
#define er equal_range

#define findnot find_first_not_of

#define maxe *max_element
#define mine *min_element

#define mod 1000000007
#define mod2 998244353
#define gcd __gcd
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetlli tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements sbtriectly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order

/*STD funcions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli modi(lli a, lli m) { return power(a, m - 2, m); }
/*CODE BEGINS*/

int main()
{
    kira;
    lli n;
    cin>>n;
    lli ans=0;
    ans=(n/lli(500))*lli(1000);
    n%=lli(500);
    ans+=(n/lli(5))*lli(5);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
//IOI 2021
//this will accept, By the order of the peaky fucking blinders
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 100 * 1000 + 17;

int n, x, p[MAXN], ans, dp[MAXN], tmp, L[MAXN], dp2[MAXN], R[MAXN];
deque<int> dq;
vector<int> an;
string s;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> x;
	cin >> s;
	for (int i = n; i >= 0; i--) {
		if (dq.size() && dq.back() > i + x)
			dq.pop_back();
		if (dq.size())
			p[i] = dq.back(), R[i] = dq.front();
		else
			p[i] = -1;
		if (s[i] == '0')
			dq.push_front(i);
	}
	p[n] = 0;
	dq.clear();
	for (int i = 0; i <= n; i++) {
		if (dq.size() && dq.front() < i - x)
			dq.pop_front();
		if (dq.size())
			L[i] = dq.front();
		else
			L[i] = -1;
		if (s[i] == '0')
			dq.push_back(i);
	}
	L[0] = 0;
	int now = 0;
	for (int i = 0; i <= n; i++) {
		if (i == now) {
			if (p[now] == -1)
				return cout << -1 << endl, 0;
			now = p[now];
			ans++;
			dp[i] = ans - 1;
		}
		else
			dp[i] = dp[i - 1];
	}
	now = n;
	ans = 0;
	for (int i = n; i > 0; i--)
		if (i == now) {
			now = L[now];
			ans++;
			dp2[i] = ans - 1;
			an.pb(i - now);
		}
		else
			dp2[i] = dp2[i + 1];
	reverse(an.begin(), an.end());
	for (auto i : an)
		cout << i << ' ';
	return 0;
}


Measured memory_bytes: 3020
import java.util.*;
class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
char[] s=sc.next().toCharArray();
  char[] t=sc.next().toCharArray();
  int min=1000000;
  for(int i=0;i<s.length-t.length+1;i++){
    int a=0;
    for(int j=0;j<t.length;j++){
    	if(s[i+j]==t[j])a++;
    }
    min=Math.min(min,t.length-a);
  }System.out.println(min);
}
}

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

int main() {
  long a,b,c,k;
  cin >> a >> b >> c >> k;
  for(long i=0;i<k;i++) {
    if(a>=b&&a>=c) a*=2;
    else if(b>=a&&b>=c) b*=2;
    else if(c>=a&&c>=b) c*=2;
  }
  cout << a+b+c << endl;
}

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

struct node{
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
};

typedef struct node *Node;
#define NIL NULL

Node root;

Node find(Node u,int k){
  while(u != NIL && k != u->key){
    if(k < u->key)u = u->l;
    else u = u->r;
  }
  return u;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->r = NIL;
  z->l = NIL;

   while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->l;
      
    }else{
      x = x->r;
    }
  }
  z->p = y;
  if(y == NIL){
    root = z;
  }else{
    if(z ->key < y->key){
      y->l = z;
      
    }else{
      y->r = z;
    }
  }
}
    
void inorder(Node u){
    if(u == NIL){
  return;
}
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(Node u){
 if(u == NIL)return;
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);

   if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = find(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
      
    }
  }
  return 0;
}



Measured memory_bytes: 20452
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
X = int(input())
c = 100
d = 0
while c < X:
    c *= 1.01
    c = int(c)
    d += 1
print(d)

Measured memory_bytes: 9164
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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


void Main()
{
    int s,w;cin>>s>>w;

    if(s<=w){
        cout<<"unsafe"<<endl;
    }
    else{
        cout<<"safe"<<endl;
    }

	return;
}

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

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define F first
#define S second
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ld long double
#define pii pair <int ,int >
#define bug(x)  cout<<"passed "<<x<<endl;
long long const inf = 1e18, linf = 2e9, mod = 1e9+7;
int const mxn = 4e5+10;
 
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}



int main(){
	long long n , k ; 
	cin>>n>>k;
	n = n% k ; 
	cout<<min (abs(n - k ) , n );
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	double r;
	double men,syu;
	cin >> r;
	men=r*r*3.141592653589;
	syu=2*r*3.141592653589;
	printf("%lf %lf\n",men,syu);
	return 0;
}

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

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

int main(){
  int n;
  cin>>n;
//  double x,y;
  vector<pair<double,double>> l(n);
  rep(i,n){
    double x,y;
    cin>>x>>y;
    l[i]=make_pair(x,y);
  }
  double al=0;
  int cnt=0;
  for (int i=0;i<n;i++){
    for (int j=i+1;j<n;j++){
      double temp;
      temp=(l[i].first-l[j].first)*(l[i].first-l[j].first)+(l[i].second-l[j].second)*(l[i].second-l[j].second);
      al+=sqrt(temp);
      cnt++;
    }
  }
  double ans=al*(n-1)/cnt;
  cout<<fixed<<setprecision(10)<<ans;
  }


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

#define fir first
#define sec second
using namespace std;
typedef long long LL;

template <typename T> inline bool cmin(T & a, const T & b) { return a > b ? a = b, 1 : 0;}
template <typename T> inline bool cmax(T & a, const T & b) { return a < b ? a = b, 1 : 0;}
int inp() {
	int x = 0, f = 1;char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = -1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return x * f;
}
const int MaxN = 400;
int n, m, a[MaxN][MaxN], l[MaxN], del[MaxN], cnt[MaxN]; 
int main() {
	int i, j;
	n = inp(); m = inp();
	for(i = 1; i <= n; i++)
		for(j = 1; j <= m; j++)
			a[i][j] = inp();
	
	for(i = 1; i <= n; i++) l[i] = 1;
	
	int ans = ~0U >> 1;
	for(i = 1; i <= m; i++) {
		memset(cnt, 0, sizeof(cnt));
		//for(j = 1; j <= n; j++) printf("%d ", a[j][l[j]]);puts("");
		for(j = 1; j <= n; j++) cnt[a[j][l[j]]]++;
		int res = 0, k = 0;
		for(j = 1; j <= m; j++) if(cnt[j] > cnt[k]) k = j;
		//cerr << "k = " << k << endl;
		cmin(ans, cnt[k]); del[k] = 1;
		for(j = 1; j <= n; j++){
			while(del[a[j][l[j]]]) ++l[j];	
			if(l[j] > m) break;
		}
		if(l[j] > m) break;
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 768
/**
*    created: 07.07.2020 00:04:07
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b, c;
    cin >> a >> b >> c;
    cout << min({a+b, b+c, c+a}) << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <utility>
#include <cstdio>
#include <cmath>
#include <climits>
using namespace std;


//---- Print a Chessboard
int main(){
    int H,W;
    while(1){
        scanf("%d %d", &H, &W);
        if(H==0 && W==0){break;}
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if((i+j)%2==0){
                    printf("#");
                }
                else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}

Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  bool flag=false;
  for(int i=0;i<S.size();i++){
    S[i]=S[i]-'A';
  }
  if(S[0]!=0){
    cout << "WA" << endl;
    return 0;
  }
  int q;
  for(int i=2;i<S.size()-1;i++){
    if(S[i]==2) {
      flag=true;
      q=i;
    }
  }
  for(int i=1;i<S.size();i++){
    if(i==q)continue;
    if(S[i]<26) flag =false;
  }
  if(flag) cout << "AC" << endl;
  else cout << "WA" << endl;
  return 0;
}

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

int main() {
  int n, l, apl;
  cin >> n >> l;
  if(l>=0)
    apl = 1;
  else if(n > (0-l))
    apl = 0 - l + 1;
  else
    apl = n;
  
  int sum = 0;
  for(int i=1;i<=n;i++)
    if(i!=apl)
      sum += l + i - 1;
  
  cout << sum << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
int main(void){
    // Your code here!
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    if(A < B){
        swap(A, B);
    }
    if(A < C){
        swap(A, C);
    }
    
    cout << A * pow(2, K) + B + C << endl;
    
    
    
}


Measured memory_bytes: 384
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;


int main(){
    ll x;
    cin>>x;
    ll ans=(x+10)/11;
    ans*=2;
    if(x%11<=6 && x%11>0) ans--;
    cout<<ans<<endl;

}

Measured memory_bytes: 3188
#include <stdio.h>
int main(){
  int n,x,i,j,k,co;
 
  while(1){
    scanf("%d %d",&n,&x);
    if((n==0)&&(x==0)) break;
    for(co=0,i=1;i<=n-2;i++) for(j=i+1;j<=n-1;j++) for(k=j+1;k<=n;k++) if((i+j+k)==x) co++;
    printf("%d\n",co);
  }
 
  return 0;
}

Measured memory_bytes: 600
#include <iostream>

using namespace std;

using ll = long long;

ll dists[2000001];
ll work[2000001];
ll sum_from_left[200003];
ll sum_from_right[200003];

int main()
{
  ll l, n;
  cin >> l >> n;
  ll sum = 0;
  ll prev = 0;
  for (int i = 0; i < n; i++) {
    ll pos;
    cin >> pos;
    dists[i] = pos - prev;
    sum += dists[i];
    prev = pos;
  }
  dists[n] = l - prev;
  if (n == 1) {
    printf("%lld\n", max(dists[0], dists[1]));
    return 0;
  }

  for (int i = 0; i < n+1; i++) {
    work[n-i] = dists[i];
    // printf("dist: %lld\n", dists[i]);
  }
  sum_from_left[0] = dists[0];
  for (int i = 1; i < n+1; i++) {
    sum_from_left[i] = sum_from_left[i-1]+dists[i];
  }
  sum_from_right[n] = dists[n];
  for (int i = n-1; 0 <= i; i--) {
    sum_from_right[i] = sum_from_right[i+1]+dists[i];
  }
  sum_from_right[n+1] = 0;
  sum_from_left[n] = work[n];
  for (int i = n-1; 0 <= i; i--) {
    sum_from_left[i] = sum_from_left[i+1]+work[i];
  }
  sum_from_left[n+1] = 0;

  int i;
  ll maximum = 0;
  ll cur = 0;
  ll last = dists[n];
  for (i = 0; i < n; i++) {
    last += dists[i];
  }
  cur += last;
  maximum = cur;
  ll to_subtract = 0;
  for (i = n-1; 0 <= i; i--) {
    cur -= dists[i];
    last -= dists[i];

    // printf("last-dn+last = %lld\n", last-dists[n]+last);
    cur = last - dists[n];
    ll to_subtract_delta = (sum_from_right[i+1] - sum_from_right[n-((n-i)/2)]) * 2;
    // printf("to_subtract_delta = sum [d_%d, ... , d_%d] = %lld\n", i+1, n-((n-i)/2)-1, to_subtract_delta);
    if ((n-i)%2 == 0) {
      to_subtract_delta += dists[n-((n-i)/2)];
    }
    to_subtract += to_subtract_delta;
    cur += last + (last + sum_from_right[i] - dists[n]) * (n-i-1) - to_subtract;
    // printf("cur = %lld\n", cur);
    maximum = max(cur, maximum);
  }

  cur = 0;
  last = work[n];
  for (i = 0; i < n; i++) {
    last += work[i];
  }
  cur += last;
  maximum = max(cur, maximum);
  to_subtract = 0;
  for (i = n-1; 0 <= i; i--) {
    cur -= work[i];
    last -= work[i];
    cur = last - work[n];
    ll to_subtract_delta = (sum_from_left[i+1] - sum_from_left[n-((n-i)/2)]) * 2;
    if ((n-i)%2 == 0) {
      to_subtract_delta += work[n-((n-i)/2)];
    }
    to_subtract += to_subtract_delta;
    cur += last + (last + sum_from_left[i] - work[n]) * (n-i-1) - to_subtract;
    maximum = max(cur, maximum);
  }

  printf("%lld\n", maximum);
  return 0;
}


Measured memory_bytes: 8448
def nCr(n_, r_, m_):
  c = min(r_ , n_ - r_)
  bunshi = 1
  bunbo = 1
  for i in range(1,c+1):
    bunshi = bunshi * (n_+1-i) % m_
    bunbo = bunbo * i % m_
  return bunshi * pow(bunbo, m_-2, m_) % m_


x,y = map(int,input().split())
s = max(x,y)
t = min(x,y)
u = 2*t-s
if u%3 != 0 or u < 0:
  print(0)
else:
  a = u//3
  b = a + s - t
  ans = nCr(a+b,b,10**9+7)
  print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N =sc.nextInt();
		int L =sc.nextInt();
		int[] a = new int[N];
		int sum=0;
		int check=L;
		
		for(int i=0;i<N;i++) {
			a[i]=i+L;
			if(Math.abs(check)>Math.abs(a[i])) {
				check=Math.abs(a[i]);
				sum=i;
			}
		}
		a[sum]=0;
		sum=0;
		for(int i=0;i<N;i++) {
			sum+=a[i];
		}
		
		System.out.print(sum);
		
		sc.close();
	}
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  vector<int>ans(n,-1);
  vector<pair<int,int> >q(m);
  for(int i=0;i<m;i++)
  {
    int t,v;
    cin>>t>>v;
    q[i]=make_pair(t,v);
  }
  for(int i=0;i<m;i++)
  {
    if(q[i].first==1 && q[i].second==0 && n!=1)
    {
       cout<<-1<<endl;
       return 0;
    }
    if(ans[q[i].first-1]==-1 || ans[q[i].first-1]==q[i].second)
    	ans[q[i].first-1]=q[i].second;
    else
    {
      cout<<-1<<endl;
      return 0;
    }
  }
  for(int i=0;i<n;i++)
  {
    if(ans[i]==-1)
    {
      if(i==0 && n!=1)cout<<1;
      else cout<<0;
    }
      
    else cout<<ans[i];
  }
  
  return 0;
}
  

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Comparator;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
		String s;
		String sl[];

		s = r.readLine();
		sl = s.split(" ");

		int n = Integer.parseInt(sl[0]);
		int k = Integer.parseInt(sl[1]);

		int a[] = new int[200001];
		int z[] = new int[200001];
		s = r.readLine();
		sl = s.split(" ");

		for(int i = 0; i < n; i++)
		{
			a[i] = Integer.parseInt(sl[i]);
		}

		for(int i = 0; i < k; i++)
		{
			boolean b = true;
			for(int j = 0; j < n; j++)
			{
				z[j] = 0;
				if(a[j] < n)
				{
					b = false;
				}
			}
			if(b)
			{
				break;
			}
			for(int j = 0; j < n; j++)
			{
				if(j - a[j] < 0)
				{
					z[0]++;
				}
				else
				{
					z[j - a[j]]++;
				}

				if(j + a[j] + 1 < n)
				{
					z[j + a[j] + 1]--;
				}
			}
			a[0] = z[0];
			for(int j = 1; j < n; j++)
			{
				a[j] = a[j - 1] + z[j];
			}
		}

		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < n; i++)
		{
			sb.append(a[i] + " ");
		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 75420
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			Integer[] ps = getPrimes(55555);

			List<Integer> list = new ArrayList<>();
			for (int num : ps) {
				if (num % 5 == 1) {
					list.add(num);
				}
			}

			for (int i = 0; i < n; i++) {
				if (i == 0) {
					out.print(list.get(i));
				} else {
					out.print(" "+list.get(i));
				}
			}
			out.print("\n");

		}
	}

	public static Integer[] getPrimes(int n) {
		boolean[] isPrime = new boolean[n + 1];
		Arrays.fill(isPrime, true);
		isPrime[0] = isPrime[1] = false;
		for (int i = 2; i < isPrime.length; i++) {
			if (!isPrime[i])
				continue;
			for (int j = i + i; j < isPrime.length; j += i) {
				isPrime[j] = false;
			}
		}

		List<Integer> list = new ArrayList<>();
		for (int i = 1; i < isPrime.length; i++) {
			if (isPrime[i]) {
				list.add(i);
			}
		}
	return list.toArray(new Integer[list.size()]);
}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21460
#include "stdio.h"

int N, D, X[10][10], res = 0, buf;

int main(void){
  scanf("%d %d\n", &N, &D);
  for(int i = 0;i < N;i++){
    for(int j = 0;j < D;j++){
      scanf("%d ", &X[i][j]);
    }
    scanf("\n");
  }
  for(int i = 0;i < N;i++){
    for(int j = i;j < N;j++){
      buf = 0;
      for(int k = 0;k < D;k++){
        buf += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
      }
      for(int l = 1;l < 200;l++){
        if(buf == l * l){
          res++;
        }
      }
    }
  }
  
  printf("%d", res);
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
#include <bitset>
using namespace std;

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

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


int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a.at(i);
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    ll ans = 0;
    ans += a.at(0);
    int j = 1;
    for (int i = 1; i < n - 1; i++) {
        ans += a.at(j);
        if (i % 2 == 0) j++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4840
#include<iostream>
#include<string>

int main()
{
    int N,K;
    int hh = 0;
    std::string S;
    std::cin>>N>>K;
    std::cin>>S;

    //開始時点で幸せな人
    for(int i=0;i<N-1;i++){
        if(S[i]==S[i+1])hh++;
    }
    hh = std::min(N-1,hh+2*K);
    std::cout<<hh<<std::endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
#define REP(i, start, n) for(int i = start; i < n; ++i)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
#define debug2d(var)  do{std::cout << #var << " : \n";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;

vector<vector<double> > dp;

int main() {
    int N;
    cin >> N;

    vector<double> p(N+1);
    REP(i, 1, N+1) cin >> p[i];

    dp.assign(N+1, vector<double>(N+1));

    dp[0][0] = 1.0;

    REP(i, 0, N) REP(j, 0, i+1) {
        dp[i+1][j+1] += dp[i][j] * p[i+1];
        dp[i+1][j] += dp[i][j] * (1-p[i+1]);
    }

    double ans = 0;
    REP(i, (N+1)/2, N+1) {
        ans += dp[N][i];
    }

    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 70784
import java.util.Arrays;
import java.util.Scanner;

/**
 * @author shengboxu
 */

public class Main {
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final int M = sc.nextInt();
        
        final int[] A = new int[M];
        
        for (int j = 0; j < M; j++) {
            A[j] = 0;
        }
        
        for (int i = 0; i < N; i++) {
            final int K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                A[sc.nextInt() - 1]++;
            }
        }
        
        final long answer = Arrays.stream(A).filter(e -> e == N).count();
        System.out.println(answer);
        return;
    }
}


Measured memory_bytes: 26956
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdio>

using namespace std;

typedef unsigned long long u64;
typedef vector<int> vi;
typedef vector<u64> vy;
typedef vector<vy> vvy;
typedef vector<vvy> vvvy;

vi x;
vvvy dp;
unsigned int N, A;

u64 rec(unsigned int i, unsigned int cur, int num, vvvy &dp, vi &x) {
    if (dp[i][cur][num] < (1ull<<57)) {
        return dp[i][cur][num];
    }


    if (i == N) {
        return dp[i][cur][num] = 0;
    } else if (A*N < cur) {
        return dp[i][cur][num] = 0;
    }

    u64 res=0;
    if (A*(num+1) == cur+x[i]) res++;

    res += rec(i+1, cur, num, dp, x);
    res += rec(i+1, cur+x[i], num+1, dp, x);

    return dp[i][cur][num] = res;
}

int main(void) {
    cin >> N >> A;

    x = vi(N);
    unsigned int i;
    for (i=0; i<N; i++) {
        scanf("%d", &x[i]);
    }

    sort(x.begin(), x.end());
    vvvy dp(N+1, vvy(50*50+1, vy(N+1, 1ull<<58)));
    cout << rec(0, 0, 0, dp, x) << endl;

    return 0;
}


Measured memory_bytes: 56192
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

s = gets.chomp
ans = ""
s.each_char do |c|
  if(c == "1")
    ans += "1"
  elsif(c == "0")
    ans += "0"
  elsif(ans.size > 0)
    ans = ans[0,ans.size-1]
  end
end
puts ans

Measured memory_bytes: 1788
#include<iostream>
using namespace std;
char a;
bool flag,falg;
int main()
{
	while(cin>>a)
	{
		if(a=='C') flag=1;
		if(a=='F'&&flag)
		{
			falg=1;
			break;
		}
	}
	if(falg) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int area = a * b;
		int length = (a + b) * 2;
		System.out.println( area+" "+ length);
	}
}

Measured memory_bytes: 25956
n = int(input())

lcm = 0
gcd = 0

for i in range(n):
    t = int(input())
    if(i == 0):
        lcm, gcd = t, t
        continue
    lcm = t
    r = gcd % t
    while(r!=0):
        lcm = r
        r = t % r
    gcd *= t
    gcd //= lcm
print(gcd)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main()
{
  string N;
  cin >> N;
  if (N[0]=='7' || N[1]=='7' || N[2]=='7') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

int main(){
  int N;
  cin>>N;
  long long int sum=0;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
    sum+=a.at(i);
  }
  cout<<sum-N<<endl;
  
  
}

Measured memory_bytes: 256
private fun readIntArray(): List<Int> {
    return readLine()!!.split(" ").map{ it.toInt() }
}

private fun readInt(): Int {
    return readLine()!!.toInt()
}

private fun readTextArray(): List<String> {
    return readLine()!!.split(" ")
}

fun main(args: Array<String>) {
    val N = readInt()

    val S: MutableList<String> = mutableListOf()

    var M: Long = 0
    var A: Long = 0
    var R: Long = 0
    var C: Long = 0
    var H: Long = 0
    for(i in 0 until N) {
        val name = readLine()!!
        if(name.startsWith("M")) M++
        if(name.startsWith("A")) A++
        if(name.startsWith("R")) R++
        if(name.startsWith("C")) C++
        if(name.startsWith("H")) H++
    }

    var ans: Long = 0
    ans += M * A * R
    ans += M * A * C
    ans += M * A * H
    ans += M * R * C
    ans += M * R * H
    ans += M * C * H
    ans += A * R * C
    ans += A * R * H
    ans += A * C * H
    ans += R * C * H

    print(ans)
}


Measured memory_bytes: 37424
#include<bits/stdc++.h>
using namespace std;
long long a[20];
int main (){
	long long a,b;
	cin>>a>>b;
	long long k=(a+b)/2;
	if(k*2==(a+b))cout<<k;
	else cout<<"IMPOSSIBLE";
	
}
//|a-k|=|b-k|
//a-k=b-k			a=b;
//a-k=k-b		a+b=2k   k=(a+b)/2


	

Measured memory_bytes: 256
import sys

while True:
	n, x = [ int( val ) for val in sys.stdin.readline().split( " " ) ]
	if 0 == n and 0 == x:
		break
		
	cnt = 0
	for i in range( 1, n-1 ):
		if  x < 3*(i+1):
			break
		for j in range( i+1, n ):
			if  x <= ( i+j ):
				break
			for k in range( j+1, n+1 ):
				s = ( i + j + k )
				if x == s:
					cnt += 1
					break
				elif   x < s:
					break
	
	print( cnt )

Measured memory_bytes: 4220
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int[][] c = new int[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                c[i][j] = ni();
            }
        }
        boolean ans = true;
        
        if((c[0][0]-c[0][1]) != (c[1][0]-c[1][1])) ans = false;
        if((c[0][0]-c[0][1]) != (c[2][0]-c[2][1])) ans = false;
        if((c[0][1]-c[0][2]) != (c[1][1]-c[1][2])) ans = false;
        if((c[0][1]-c[0][2]) != (c[2][1]-c[2][2])) ans = false;
        if((c[0][0]-c[1][0]) != (c[0][1]-c[1][1])) ans = false;
        if((c[0][0]-c[1][0]) != (c[0][2]-c[1][2])) ans = false;
        if((c[1][0]-c[2][0]) != (c[1][1]-c[2][1])) ans = false;
        if((c[1][0]-c[2][0]) != (c[1][2]-c[2][2])) ans = false;
 
        if(ans){
            out.println("Yes");
        }else{
            out.println("No");
        }
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);

    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 33136
x, k, d = map(int, input().split())

left = k - (abs(x) // d)

if abs(x) // d > k:
    print(abs(x) - k*d)
else:
    ans_abs = abs(x) % d
    if left % 2 == 0:
        print(ans_abs)
    else:
        print(d - ans_abs)


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

void solve(int N, std::vector<std::string> S, std::vector<int> P){
    vector<tuple<string, int, int>> a;
    for(int i = 1; i <= N; ++i) a.emplace_back(S[i-1], -P[i-1], i);
    sort(a.begin(), a.end());
    for(int i = 0; i < N; ++i) cout << get<2>(a[i]) << endl;
}

int main(){
    int N;
    cin >> N;
    std::vector<std::string> S(N);
    std::vector<int> P(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i] >> P[i];
    }
    solve(N, std::move(S), std::move(P));
    return 0;
}


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

int n;

int main()
{
    cin >> n;
    for (int i = 1; i <= 9; i++)
        for (int j = 1; j <= 9; j++)
            if (i * j == n) { printf("Yes\n"); return 0; }
    printf("No\n");
    return 0;
}


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

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

    int g = 0;
    int mx = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        mx = max(mx, x);
        g = __gcd(g, x);
    }

    if (k % g == 0 && k <= mx) {
        puts("POSSIBLE");
    } else {
        puts("IMPOSSIBLE");
    }
}


Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = False
show_flg = True


def main():
    N, M, V, P = MI()
    A = MI()
    A = sorted(A, reverse=True)
    minp = A[P-1]
    result = 0
    td = 0
    count = 0
    tpcount = 1
    tptd = 0
    pre = minp
    for i in range(P, N):
        if pre != A[i]:
            td += tptd
            count += tpcount
            tptd = 0
            tpcount = 0
        if M * min(N-V, count) >= (minp - A[i]) * count - td and minp <= A[i] + M:
            result += 1
            tpcount += 1
            tptd += minp - A[i]
            pre = A[i]
        else:
            break
    print(result + P)
    # N, M, V, P = 10**5, 10*19, 10**4, 10**4
    # A = [i for i in range(N)]
    # MAP = {}
    # A = sorted(A, reverse=True)
    # AH = A[:P]
    # AH_min = AH[-1]
    # AT = []
    # cur = 0
    # sent_c = 0
    # for i in range(P, N):
    #     if AH_min == A[i]:
    #         sent_c += 1
    #     # else:
    #     if A[i] not in MAP:
    #         MAP[A[i]] = cur
    #     cur += 1
    #     AT.append(A[i])
    # print(AH, AT)
    # # print('M=', M, 'V=', V)
    # ans = len(AH)
    # AT_len = len(AT)
    # # print(AT, MAP)
    # # show(len(AT), V - len(AH) + 1)

    # _V = V - len(AH) + 1
    # # print('_V', _V, V, AH_min)
    # for i in range(AT_len):
    #     if AH_min == AT[i]:
    #         ans += 1
    #     elif AH_min <= (AT[i] + M):
    #         remaining = AT_len - (MAP[AT[i]] + 1)
    #         print('AT[i]', AT[i], 'ans=', ans, 'i=', i, 'remain=', remaining +
    #               1, 'V=', _V, 'AH_MIN=', AH_min, 'MAP=', MAP[AT[i]])
    #         if remaining + 1 >= _V:
    #             ans += 1

    # print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 88300