akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}

//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  string S;
  cin >> S;
  int A = 0;
  for (int i = 0; i < int(S.size()); i++) {
    A += ctoi(S.at(i));
    A %= 9;
  }
  if (A == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
  
  
  

Measured memory_bytes: 3752
while True:
    N = int(input())
    if N == 0:
        break
    
    data = []
    for _ in range(N):
        inp = input().split()
        P, A, B, C, D, E, F, S, M = map(int, inp[1:])
        time = A + B + C + M * (D + E)
        money = M * F * S - P

        da = [inp[0], money/time]
        data.append(da)

    data.sort(key=lambda x:x[0])
    data.sort(key=lambda x:-x[1])
    for i in range(N):
        print(data[i][0])
    print('#')


Measured memory_bytes: 5616
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <iomanip>
#include <math.h>
using namespace std;
typedef long long ll;
 
int main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++) {
        cout << s[i] << t[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

H,W = inputIL()
h,w = inputIL()

print((H-h)*(W-w))

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

typedef long long ll;
const ll mod = 1e9 + 7;
const ll modinvtwo = 5e8 + 4;

ll power(int n, int m)
{
	ll p = 1;
	for(int i = 0; i < m; i++)	p *= n;
	return p;
}

int main()
{
	int n;	cin >> n;
	vector<ll> v(n);

	ll sump = 0, sumsq = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> v[i];
		sump = (sump + v[i]) % mod;
		sumsq = (sumsq + (v[i]*v[i]) % mod) % mod;
	}
	sump = (sump * sump) % mod;
	ll sum = ((sump < sumsq ? (sump - sumsq) + mod : sump - sumsq) * modinvtwo) % mod;

	cout << sum  << endl;
}

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

int main(){
  int A,B;
  cin >> A >> B;
  if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
}


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

public class Main {
	public static final String EOL = System.getProperty("line.separator");
    public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	String[] s;
    	int m,f,r;
    	while(true) {
    		s = br.readLine().split(" ");
    		m = Integer.parseInt(s[0]);
            f = Integer.parseInt(s[1]);
            r = Integer.parseInt(s[2]);
            if(m == -1 && f == -1 && r == -1)
            	break;
            if(m == -1 || f == -1)
            	out.println("F");
            else if (m + f >= 80)
            	out.println("A");
            else if (m + f >= 65)
            	out.println("B");
            else if (m + f >= 50)
            	out.println("C");
            else if (m + f >= 30)
            	out.println(r>=50 ? "C" : "D");
            else
            	out.println("F");
    	}
        out.flush();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
}

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

#define ll long long int 
ll mod=1e9+7;

// vector<int> g[200005];
// int vis[200005];
// queue<int> q;
// int level[200005];

// void dfs(int i)
// {
//     vis[i] = 1;
//     for(int j=0;j<g[i].size();j++)
//     {
//         int child = g[i][j];
//         if(vis[child] == 0)
//         {
//             dfs(child);
//         }
//     }
// }

// void bfs(int i)
// {
//     vis[i] = 1;
//     while(!q.empty())
//     {
//         int top = q.front();
//         int len_adj = g[top].size();
//         int j;
//         for(j=0;j<len_adj;j++)
//         {
//             int v = g[top][j];
//             if(vis[v]==0)
//             {
//                 vis[v]=1;
//                 q.push(v);
//                 level[v] = level[top] + 1;
//             }
//         }   
//         q.pop();
//     }
// }

ll modular_exponentiation(ll base, ll power)
{
    ll ans = 1;
    base = base % mod;
    while (power > 0)
    {
        if (power & 1)
        {
            ans = (ans * base) % mod;
        }

        power /= 2;
        base = (base * base) % mod;
    }
    return ans;
}

int main()
{
    /* Faster input ouput */
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    /* To read input from a file and output to a file */
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    
    int t = 1;
    // cin >> t;
    while(t--)
    {        
        ll n,i,j;
        cin >> n;
        ll arr[n];

        ll ip_ai[n];
        ll im_ai[n];
        pair<ll,ll> pr[n];

        for(i=0;i<n;i++)
        {
            cin >> arr[i];
            im_ai[i] = i - arr[i];
            ip_ai[i] = i + arr[i];
            pr[i].first = ip_ai[i];
            pr[i].second = i;
        }

        sort(pr,pr+n);
        vector<ll> negs;

        for(i=0;i<n;i++)
        {
            // cout << pr[i].first << " " <<  pr[i].second << '\n';
            negs.push_back(pr[i].first);
        }
        
        ll ans = 0;
        for(i=0;i<n;i++)
        {
            ll curr_val = im_ai[i];
            ll lower_ind = lower_bound(negs.begin(),negs.end(),curr_val) - negs.begin();
            ll upper_ind = upper_bound(negs.begin(),negs.end(),curr_val) - negs.begin();
            ans += (upper_ind - lower_ind);
        }

        cout << ans << '\n';






    }

    
    
}

Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll a, b, c;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> a >> b >> c;
	if(a%2 == 0 || b%2 == 0 || c%2 == 0){
		print(0)
	}
	else{
		print(min(a*b, min(b*c, c*a)));
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ cin >> p.first >> p.second; return s;}
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 

int main()
{
    int N, M; cin >>N>>M;
    vector<pii> seg(M);
    rep(i, M) {
        cin>>seg[i].first>>seg[i].second;
    }
    sort(all(seg), [](const pii& a, const pii& b){
        if (a.second==b.second) return a.first<b.first;
        return a.second<b.second;
    });
// rep(i,M) D2(seg[i].first, seg[i].second);
    int ans = 1;
    int prev = 0;
    rep1(i, M) {
        if (seg[i].first >= seg[prev].second) {
            ans++;
            prev = i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll A,B;
	while(cin>>A>>B) {
		ll K = (A+B)/2;
		if(abs(A-K)==abs(B-K)) {
			cout<<K<<endl;
		} else {
			cout<<"IMPOSSIBLE"<<endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  vector<int> v(100001);
  int n;
  cin >> n;
  rep(i,n) {
    int a;
    cin >> a;
    for(int i = -1; i <= 1; i++) {
      if (a + i < 0 || 100000 < a + i) continue;
      v[a + i]++;
    }
  }
  int ans = 0;
  for (int i = 1; i <= 100000; i++) {
    ans = max(ans, v[i]);
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3708
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  arr <- map digitToInt <$> getLine
  print $ minimum $ map (\i -> abs $ (arr !! i * 100 + arr !! (i + 1) * 10 + arr !! (i + 2)) - 753 ) [0..((length arr) - 3)]

Measured memory_bytes: 380
N = int(input())
S = dict()
Max = 1
for i in range(N):
    s = input()
    if s in S:
        S[s] += 1
        if S[s] > Max:
            Max = S[s]
    else:
        S[s] = 1
for key, value in sorted(S.items()):
    if value == Max:
        print(key)

Measured memory_bytes: 44124
//え？
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
inline int getintA() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return tmp;
}
char dn[1300000], *di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}
int N;
int A[200001];
int E[400001], ne[400001], he[200001], it[200001];
int V[200001], v;
int S[200001], s;

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

	N = getint();
	rep1(i, N) A[i] = getintA();
	int k = 1;
	rep(i, N - 1) {
		int u = getint(), v = getint();
		E[k] = v;
		ne[k] = he[u];
		he[u] = k++;
		E[k] = u;
		ne[k] = he[v];
		he[v] = k++;
	}

	V[v++] = 2000000000;
	S[s++] = 1;
	while (s) {
		int p = S[s - 1];
		if (p > 0) {
			S[s - 1] = -p;
			if (V[v - 1] < A[p]) {
				it[p] = v;
				swap(V[v++], A[p]);
				for (auto to = he[p]; to; to = ne[to]) {
					if (he[E[to]] > 0) {
						S[s++] = E[to];
					}
				}
			}
			else {
				it[p] = lower_bound(V, V + v, A[p]) - V;
				swap(V[it[p]], A[p]);
				for (auto to = he[p]; to; to = ne[to]) {
					if (he[E[to]] > 0) {
						S[s++] = E[to];
					}
				}
			}
			he[p] = -v;
		}
		else {
			s--;
			p = -p;
			V[it[p]] = A[p];
			v -= !A[p];
		}
	}

	rep1(i, N) putint(-he[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 10256
from collections import deque
 
jumps = [
    [1, -2], [0, -2], [-1, -2], [-2, -1], [-2, 0], [-2, 1], [-1, 2], [0, 2], [1, 2], [2, -1], [2, 0], [2, 1]
]
 
def bfs(ipy, ipx, ys, xs, n):
    q = deque()
    q.append([ipy, ipx, -1])
    while q:
        py, px, t = q.popleft()
        if t == n-1:
            return True
 
        for dy, dx in jumps:
            npy = py + dy
            npx = px + dx
            if npy in range(10) and npx in range(10) and abs(npy - ys[t+1]) <= 1 and abs(npx - xs[t+1]) <= 1:
                q.append([npy, npx, t+1])
 
    return False
 
if __name__ == '__main__':
    while True:
        try:
            ipx, ipy = map(int, input().split())
            if ipx == 0 and ipy == 0:
                break
            n = int(input())
            l = list(map(int, input().split()))
            xs = l[::2]
            ys = l[1::2]
             
            if bfs(ipy, ipx, ys, xs, n):
                print('OK')
            else:
                print('NA')
        except:
            break


Measured memory_bytes: 6004
#include <cstdio>


int main(){
	long long tmp=0;
	long long count = 0;

	int n =0,a=0;
	scanf("%d",&n);
	for(int i = 0;i<n;i++){
		scanf("%d",&a);
		if(a==0){
			count+=(tmp/2);
          	tmp=0;
		}else{
			tmp+=a;
		}
	}
			count+=(tmp/2);
        
	printf("%lld\n",count);


}

Measured memory_bytes: 128
time=[int(input()) for _ in range(5)]
t1=[10]*5
for i in range(5):
  if time[i]%10!=0:
    t1[i]=time[i]%10
last=min(t1)
t=0
a=0
for i in range(5):
  if a==0 and t1[i]==last:
    t+=time[i]
    a=1
  else:
    t+=time[i]-t1[i]+10
print(t)
  

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int a, b;
  cin >> a >> b;
  if ((a + b) % 2 == 0) {
    cout << (a + b) / 2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
from itertools import combinations
import sys
sys.setrecursionlimit(10**6)

def solve(Shogen, isHonests, manId):
  ans = True
  new_honests = []
  for x, y in Shogen[manId-1]:
    if isHonests[x-1] == -1:
      isHonests[x-1] = y
      if y == 1:
        new_honests.append(x)
    elif isHonests[x-1] != y:
      return False
  if new_honests:
    for nh in new_honests:
      ans = ans and solve(Shogen, isHonests, nh)
  return ans

N = int(input())
shogens = []
for _ in range(N):
  a = int(input())
  s = [list(map(int, input().split())) for _ in range(a)]
  shogens.append(s)
ishonests = [-1]*N
for begin in range(1, N+1):
  if ishonests[begin-1] == -1:
    tmphonests = ishonests.copy()
    tmphonests[begin-1] = 1
    if solve(shogens, tmphonests, begin):
      ishonests = tmphonests
    else:
      ishonests[begin-1] = 0
print(sum(ishonests))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int h,a[500001];
void maxHeapify(int );
void buildMaxHeap();

int main(){
  cin>>h;
  for(int i=0;i<h;i++)cin>>a[i];
  buildMaxHeap();
  for(int i=0;i<h;i++)cout<<" "<<a[i];
  cout<<endl;
  return 0;
}
void maxHeapify(int i){
  int l=i*2+1,r=i*2+2,la;
  if(l<=h && a[l]>a[i])la=l;
  else la=i;
  if(r<=h && a[r]>a[la])la=r;
  if(la!=i){
    swap(a[i],a[la]);
    maxHeapify(la);
  }
}
 
void buildMaxHeap(){
  for(int i=h/2-1;i>=0;i--)maxHeapify(i);
}



Measured memory_bytes: 5064
import sys
from collections import deque
import copy

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = list(read_func().strip().split())
    a = []
    for i in range(N):
        a.append(int(input_raw[i]))
    s = sum(a)
    min_sub = sys.maxint
    x = 0
    for i in range(N - 1):
        x += a[i]
        sub = abs(s - 2*x)
        if sub < min_sub:
            min_sub = sub
    print min_sub


if __name__ == '__main__':
    main()

Measured memory_bytes: 26328
N, A, B, C = map(int, input().split())
l = []

for i in range(N):
    l.append(int(input()))


def gen_pat(n, pat):
    if n==0:
        return [pat]
    out = []
    for s in list("ABC0"):
        out += gen_pat(n-1, pat+s)
    return out

def cal(l, x):
    return 10*(len(l)-1)+abs(sum(l)-x)

cost = 10000000000000
for p in gen_pat(len(l), ""):
    a = [l[i] for i in range(len(l)) if p[i]=="A"]
    b = [l[i] for i in range(len(l)) if p[i]=="B"]
    c = [l[i] for i in range(len(l)) if p[i]=="C"]
    if len(a)==0 or len(b)==0 or len(c)==0:
        continue

    cost = min(cost,
               cal(a, A)+cal(b, B)+cal(c, C))

print(cost)


Measured memory_bytes: 7816
function Main(input){
	var a = input.split("\n");
  for(var X = 0; X <= 100; X++){
  	for(var Y = 0; Y <= 100; Y++){
    	var valid = isValid(a,X,Y);
      if(valid){
      	return ""+X+" "+Y+" "+valid;
      }
    }
  }
}
 
function isValid(a,X,Y){
	var N = a[0]*1;
	var H = 0;
  for(var n = 1; n <= N; n++){
  	var b = a[n].split(" ");
  	var x = b[0]*1;
    var y = b[1]*1;
    var h = b[2]*1;
        
    if(h != 0){
      H = h + Math.abs(X - x) + Math.abs(Y - y);
      break;
    }
  }
  for(var n = 1; n <= N; n++){
  	var b = a[n].split(" ");
  	var x = b[0]*1;
    var y = b[1]*1;
    var h = b[2]*1;
    
    var hh = H - Math.abs(X - x) - Math.abs(Y - y);
    hh = hh < 0 ? 0 : hh;
    if(hh != h){
    	return false;
    }
  }
  return H;
}

console.log(Main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 13688
#include<bits/stdc++.h>
using namespace std;
#define REPS(i,s,e) for(int i=(s);i<(e);i++)

int main(){
  int H,W; cin >> H >> W;
  const int INF = H+W+5;
  string str;
  vector<vector<int>> table(H+2,vector<int>(W+2,INF));
  queue<tuple<int,int>> q;
  REPS(i,1,H+1){
    cin >> str;
    REPS(j,1,W+1){
      if(str[j-1]=='#'){
        q.push(make_tuple(i,j));
        table[i][j] = 0;
      }else{
        table[i][j] = INF-1;
      }
    }
  }
  int m = 0;
  while(!q.empty()){
    int i = get<0>(q.front()),
        j = get<1>(q.front()),
        c = table[i][j] + 1,
        u = table[i-1][j],
        d = table[i+1][j],
        l = table[i][j-1],
        r = table[i][j+1];
    if(u<INF&&u>c){
      table[i-1][j] = c;
      q.push(make_tuple(i-1,j));
    }
    if(d<INF&&d>c){
      table[i+1][j] = c;
      q.push(make_tuple(i+1,j));
    }
    if(l<INF&&l>c){
      table[i][j-1] = c;
      q.push(make_tuple(i,j-1));
    }
    if(r<INF&&r>c){
      table[i][j+1] = c;
      q.push(make_tuple(i,j+1));
    }
    q.pop();
    m = c-1;
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 12432
if __name__ == "__main__":
    N = int(input())
    h = [int(n) for n in input().split()]
    dp = [0] * int(1e5) # dp[i]はiにたどり着くコストの最小値
    # dp[0] = 0
    # dp[n] = min(dp[n-1] + abs(h[n] - h[n-1]), dp[n-2] + |h[n] - h[n-2]|)
    dp[0] = 0
    dp[1] = abs(h[1] - h[0])
    for i in range(2, N):
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))
    print(dp[N-1])


Measured memory_bytes: 13928
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n; cin >> n;
    n = n % 10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
        cout << "hon" << endl;
    }else if( n == 0 || n == 1 || n == 6 || n == 8){
        cout << "pon" << endl;
    }else{
        cout << "bon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;
class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int line;
		int area;
		
		while(scan.hasNext()){
			line = scan.nextInt();
			
			if(line == 1){
				area = 2;
			}else{
				area = 1 + line + (line*(line-1)/2);
			}
			System.out.println(area);
		}
		
		scan.close();
	}
}

Measured memory_bytes: 17236
// All Heil Fire Lord Zuko
// High Functioning Socialpath
// she loves it when i call her senorita

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

//#define int ll

#define all(x) x.begin() , x.end()

#define _sz(x) (int)x.size()
#define F first
#define S second
#define PB push_back

#define debug(x) cerr << #x << " = " << x << "\n"

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

const int N = 100 + 19 ;
const int Mod = 1e9 + 7 ;
const int inf = 1 << 30 ;
const ll INF = 1ll << 62 ;

string s[] = { "SUN" , "MON" , "TUE" , "WED" , "THU" , "FRI" , "SAT" } ;

int main() {
        ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;
        string n ;
        cin >> n ;
        for (int i = 0 ; i < 7 ; i ++)
                if (s[i] == n)
                        return cout << 7 - i , 0 ;
        return 0 ;
}



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

void Print(const vector<int>& xs) {
  for (const auto& x : xs) cout << x << ", ";
  cout << endl;
}

int N;
vector<vector<int>> xss;  // adjacency list.
vector<int> from1, fromN;

void DFS(int v, int d, vector<int>* distances) {
  vector<int>& ds = *distances;
  ds[v] = d;
  for (const auto& x : xss[v]) {
    if (ds[x] != -1) continue;
    DFS(x, d + 1, distances);
  }
}

int main() {
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    xss.push_back(vector<int>());
    from1.push_back(-1);
    fromN.push_back(-1);
  }
  for (int i = 1; i <= N - 1; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    xss[a].push_back(b);
    xss[b].push_back(a);
  }
  DFS(0, 0, &from1);
  DFS(N - 1, 0, &fromN);
  int fennec = 0;
  for (int i = 0; i < N; ++i) {
    if (from1[i] <= fromN[i]) ++fennec;
  }
  int snuke = N - fennec;
  if (fennec > snuke)
    cout << "Fennec" << endl;
  else
    cout << "Snuke" << endl;
}


Measured memory_bytes: 11548
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#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 chmin(x, y) x = min(x, y)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    string a, b;
    cin >> a >> b;
    string num_str = a + b;
    int num1 = stoi(num_str);

    int num2 = sqrt(num1);
    if (num1 == num2 * num2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	set<int> now;
	rep(i,3){
		int x;
		cin>>x;
		now.insert(x);
	}
	if(now.size()==2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}



int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	int a[114514];
	int cnt[114514] = {};
	cin >> N;
	REP(i, N){
		cin >> a[i];
		if(a[i] > 0)
			cnt[a[i]-1]++;
		cnt[a[i]]++;
		cnt[a[i]+1]++;
	}
	int res = 0;
	REP(i, 114514){
		res = max(res, cnt[i]);
	}
	cout << res << endl;
}


Measured memory_bytes: 1152
R=range
l=[[[0 for i in R(10)]for j in R(3)]for s in R(4)]
for i in R(int(input())):b,f,r,v=map(int,input().split());l[b-1][f-1][r-1]+=v
for i in R(4):
 for k in l[i]:print("",*k)
 if i!=3:print("#"*20)

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

int main() {
  int64_t n;
  cin>>n;

  // int count[n+1];
  int *count = (int*)malloc(sizeof(int)*(n+1));
  for(int i=0; i<n+1; i++) count[i]=1;

  int posi = 2;
  while(posi<=(n-1)/2+1) {
    count[posi]++;
    int times = 2;
    while(posi*times<=n) {
      count[posi*times]++;
      times++;
    }
    posi++;
  }
  while(posi<=n) {
    count[posi]++;
    posi++;
  }

  int64_t ans = 0;
  for(int64_t i=1; i<n+1; i++) {
    ans += i*count[i];
  }

  cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 42688
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var count = 0
    for (i in 1..n) {
        if (i % 2 == 0) continue
        var tempCount = 0
        for (j in 1..i) {
            if (i % j == 0) tempCount++
        }
        if (tempCount == 8) count++
    }
    println(count)
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int f(int n){
    int count = 0;
    for(int x = 1; x <= 100; x ++ ){
        for(int y = 1; y <= 100; y ++ ){
            for(int z = 1; z <= 100; z ++ ){
                if( (x*x + y*y + z*z + x*y + y*z + z*x ) == n ){
                    count++;
                }else if( (x*x + y*y + z*z + x*y + y*z + z*x ) > n ){
                    break;
                }
            }
        }
    }

    return count;
}

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;

    cin >> N;

    for( int i = 1; i <= N; i++ ){
        cout << f(i) << endl;
    }
}


Measured memory_bytes: 3564
import java.util.Scanner;
class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long l0=2;
		long l1=1;

		for(int i=0;i<n-1;i++){
			long buf=l1;
			l1=l1+l0;
			l0=buf;
		}
		System.out.println(l1);

	}
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
long long n,m;
long long ksm(long long a,int k)
{
    long long ans=1,y=a;
    while(k!=0)
    {
        if(k%2==1)
            ans=ans*y%mod;
        y=y*y%mod;
        k/=2;
    }
    return ans;
}
long long ans=1;
long long a[1000005];
int main()
{
    scanf("%lld%lld",&n,&m);
    a[0]=1;
    for(register int i=1;i<=1000000;i++)
        a[i]=i*a[i-1]%mod;
    for(register int i=2;i*i<=m;i++)
        if(m%i==0)
        {
            long long s=0;
            while(m%i==0)
            {
                m/=i;
                s++;
            }
            ans=ans*a[n+s-1]%mod*ksm(a[n-1],mod-2)%mod*ksm(a[s],mod-2)%mod;
        }
    if(m>1)
        ans=ans*n%mod;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

struct edge{ ll to; ll num; };
void mainsolve(){
	ll n;
	cin >> n;

	vector<vector<edge>> to(n);
	rep(i,n-1){
		ll a,b;
		cin >> a >> b;
		--a; --b;
		to[a].push_back(edge{b,i});
		to[b].push_back(edge{a,i});
	}

	vector<vector<ll>> path(n,vector<ll>(n)); // iからjへのパスで通る辺集合

	rep(i,n){
		vector<bool> isChecked(n,false);
		queue<ll> q;

		isChecked[i] = true;
		q.push(i);
		while (!q.empty()) {
			ll cur_v = q.front();
			q.pop();
			for (edge e : to[cur_v]) {
				ll next_v = e.to;
				if (isChecked[next_v] == false) {
					isChecked[next_v] = true;
					q.push(next_v);
					path[i][next_v] = path[i][cur_v] | (1ll<<(e.num));
				}
			}
		}

	}

	ll m;
	cin >> m;
	vector<ll> memo1(m); // 制約mのパスで通る辺をmemo
	rep(i,m){
		ll u,v;
		cin >> u >> v;
		--u; --v;
		memo1[i] = path[u][v];
	}

	vector<ll> memo(1<<m); // ビットで制約集合を管理。白く塗られる辺の本数が値になる。
	rep(i,1<<m){
		ll tmp = 0;
		rep(j,m){
			if((i>>j) & 1) tmp |= memo1[j];
		}

		memo[i] = __builtin_popcountll(tmp); 
	}

	ll cnt = 0; // 補集合の個数
	rep(i,1<<m){
		if(i==0) continue;

		ll bits = __builtin_popcountll(i);
		if(bits%2 == 1){
			cnt += (1ll<<(n-1-memo[i])); // n-1本から白であることが確定している本数を引く
		}
		else{
			cnt -= (1ll<<(n-1-memo[i]));
		}
	}

	cout << (1ll<<(n-1)) - cnt << endl; // 全集合から補集合を引く
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 8448
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>

using lli = long long int;
int inf = 1000000007;
using namespace std;
#define sort(X) sort(X.begin(),X.end())

int N;

int main()
{
	cin >> N;
	vector<tuple<string, int, int>> data(N);
	for (int i = 0; i < N; i++) {
		string s;
		int p;
		cin >> s >> p;
		data[i] = make_tuple(s, -p, (i + 1));
	}
	sort(data);
	for (int i = 0; i < N; i++)cout << get<2>(data[i]) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include<set>
using namespace std;
int n,k;


int main(){
    cin >> n >> k;
    int d[k];
    int A[110];
    set<int>ans;
    
    for (int i=0; i<=k-1; i++) {
        cin >>d[i] ;
        for (int j=0; j<d[i]; j++) {
            cin >> A[j];
            ans.insert(A[j]);
        }
        
    }
    int answer = n - int(ans.size());
    cout << answer << endl;
    return 0;
}


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

int main(){
    int a , b , c , tmp;
    cin >> a >> b >> c;

    if ( a > b ){
        tmp = a;
        a = b;
        b = tmp;
    }
    if ( b > c){
        tmp = b;
        b = c;
        c = tmp;       
    }
    if ( a > b ){
        tmp = a;
        a = b;
        b = tmp;
    }
    cout << a << " " << b << " " << c << endl;
    
}
    


Measured memory_bytes: 3084
N,D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N):
    Y = (X[i][0]**2 + X[i][1]**2)**(1/2)
    if Y <= D:
        ans += 1
print(ans)

Measured memory_bytes: 45824
#include <stdio.h>

int main(){
	
	/* |P = A -> B| |Q = B -> C| |R = C -> A| */
	int p=0,q=0,r=0,menor=0;

	scanf("%d %d %d",&p,&q,&r);

	menor = p + q;
	if(p + r < menor){
		menor = p + r;
	}
	if(q + r < menor){
		menor = q + r;
	}
	printf("%i\n",menor);

	return 0; 
}

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

using namespace std;
typedef long long ll;

int main() {
  string s;
  cin>>s;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '+') ans++;
    else ans--;
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

using ll = long long;

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

    reverse(s.begin(), s.end());

    map<int, int> mp;
    mp[0]++;

    ll num = 0, ten = 1;
    for (auto&& x : s) {
        num = (num + (x - '0') * ten) % 2019;
        ten = ten * 10 % 2019;
        mp[num]++;
    }

    ll ans = 0;
    for (auto&& x : mp) {
        int a = x.second;
        ans += a * (a - 1) / 2;
    }

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

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

#include <atcoder/math>
using namespace std;
using namespace atcoder;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int T;
  cin >> T;
  for (int i = 0; i < T; i++) {
    ll N, M, A, B;
    cin >> N >> M >> A >> B;
    cout << floor_sum(N, M, A, B) << "\n";
  }
}


Measured memory_bytes: 3648
#include <iostream>

using namespace std;

bool is_prime(int x) {
    for (int i = 2; i * i <= x; ++i)
        if (x % i == 0)
            return false;
    return true;
}

int main() {
    int n;
    cin >> n;
    int ans = 0;
    while (n--) {
        int x;
        cin >> x;
        if (is_prime(x))
            ans += 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3088
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))


H,K=input2()
h=input_array()

if K>=H:
	print(0)
elif K<=0:
	print(sum(h))
else:
	sorted_h=sorted(h)
	print(sum(sorted_h[:-K]))

Measured memory_bytes: 26024
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){

  ll a,b,c,d; cin>>a>>b>>c>>d;

  ll x = (a+d-1)/d, y = (c+b-1)/b;

  if(y<=x) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

}


Measured memory_bytes: 3636
from collections import Counter
mod = 10**9+7
n = int(input())
a = list(map(int,input().split()))
c = Counter(a)
c = c.most_common()
c.sort()

if n % 2 == 1:
    num = 0
    for i, v in c:
        k = 2
        if i == 0:
            k = 1
        
        if (i, v) != (num, k):
            print(0)
            exit()
        num += 2
else:
    num = 1
    for i, v in c:
        if (i, v) != (num, 2):
            print(0)
            exit()
        num += 2
print(2 ** (n//2) % mod)


Measured memory_bytes: 16096
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    int n;
    cin>>n;
    vi as(n);
    cin>>as;

    ll ans = 0;
    rep(i, n - 1) {
        if (as[i] == i + 1 && as[i + 1] == i + 2) {
            swap(as[i], as[i + 1]);
            ans++;
        }
    }
    if (as[0] == 1) {
        swap(as[0], as[1]);
        ans++;
    }
    rep(i, n - 1) {
        if (as[i + 1] == i + 2) {
            swap(as[i], as[i + 1]);
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my ($x, $y) = split / /, <STDIN>);
my $ans = abs(abs($y) - abs($x));
if ($x==0) {
  if (0<$y) {
    #$ans
  } else {
    $ans += 1;
  }
} elsif ($y==0) {
  if (0<$x) {
    $ans += 1;
  } else {
    #$ans
  }
} elsif ($x>=0 && $y>=0) {
  if (abs($x)<abs($y)) {
    #$ans
  } else {
    $ans += 2;
  }
} elsif ($x<0 && $y>=0) {
  if (abs($x)<abs($y)) {
    $ans += 1;
  } else {
    $ans += 1;
  }
} elsif ($x>=0 && $y<0) {
  if (abs($x)<abs($y)) {
    $ans += 1;
  } else {
    $ans += 1;
  }
} elsif ($x<0 && $y<0) {
  if (abs($x)<abs($y)) {
    $ans += 2;
  } else {
    #$ans
  }
}
say $ans;

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll mod = 1000000007;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<P> ba(n);
	for (int i = 0; i < n; i++) {
		cin >> ba[i].second >> ba[i].first;
	}
	sort(all(ba));
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		sum += ba[i].second;
		if (sum > ba[i].first) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll n, a, b;
	cin >> n >> a >> b;
	if (a > b || n == 1 && a != b) {
		puts("0");
		return 0;
	}
	if (n == 1) {
		puts("1");
		return 0;
	}
	ll mn = (n - 2)*a + a + b;
	ll mx = (n - 2)*b + a + b;
	cout << mx - mn + 1 << endl;
	return 0;
}

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

using namespace std;

const int mod = 1e9 + 7;

int dp[55][111][111];
int A[111];
int n, ans;

int main()
{
	int i, j, k, l, x, y, a, b;
	
	scanf("%d", &n);
	
	for(i=1; i<n+n; i++){
		scanf("%d", A + i);
	}
	
	sort(A + 1, A + n + n);
	
	dp[n][1][1] = 1;
	
	for(i=n-1; i>=1; i--){
		a = A[i] != A[i+1];
		b = A[n+n-i] != A[n+n-i-1];
		
		for(j=1; j<=n+n; j++){
			for(k=1; k<=j; k++){
				x = j + a + b;
				y = k + a;
				
				for(l=1;l<y;l++) dp[i][x-y+l+1][l] = (dp[i][x-y+l+1][l] + dp[i+1][j][k]) % mod;
				for(l=y+1;l<=x;l++) dp[i][x+y-l+1][y+1] = (dp[i][x+y-l+1][y+1] + dp[i+1][j][k]) % mod;
				dp[i][x][y] = (dp[i][x][y] + dp[i+1][j][k]) % mod;
			}
		}
	}
	
	for(i=1; i<=n+n; i++){
		for(j=1; j<=i; j++){
			ans = (ans + dp[1][i][j]) % mod;
		}
	}
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 2560
n = int(input())
s=[]
for i in range(n):
    s.append(input())

list_s = []
for j in range(n):
    #list_s.append(sorted(list(s[j])))
    list_s.append(''.join(sorted(s[j])))

m = {}
for i in range(n):
    if list_s[i] not in m:
        m[list_s[i]] = 1
    else:
        m[list_s[i]] += 1

def cmb(num):
    if num == 1:
        return 0
    elif num == 2:
        return 1
    else:
        return (num * (num-1) // 2)
  
count = 0
for k in m.keys():
        count += cmb( m[k] )


print(count)



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

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<long double> count(N);
    for (int i = 1; i <= N; ++i) {

        int counter = 0;
        int initial = i;

        do {
            if (initial >= K) {
                break;
            }

            ++counter;
            initial *= 2;
        } while (true);


        long double calc = 1;
        for (int j = 0; j < counter; ++j) {
            calc = calc * 0.50000000000000;
        }

        // cout << counter << endl;
        count[i - 1] = calc;
    }

    long double sum = 0;
    for (int i = 0; i < count.size(); ++i) {
        sum += count[i];
    }

    cout << setprecision(20) << sum / N << endl;

    return 0;
}

Measured memory_bytes: 1792