akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
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;}
//cout << fixed << setprecision(10);
ll fac(ll x){if(x==0) return 1;  return x*fac(x-1);}

int main(){
  ll h,a;
  cin>>h>>a;
  cout<<(h+a-1)/a<<endl;

} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   int d,t,s;
           cin>>d>>t>>s;
           Yes(d<=t*s);
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }

int main(){
    ll N,K;
    string S;
    cin >> N >> K;
    ll sum=0;
    for(ll i = K;i<=N+1;i++){
        sum += i*(N+N-i+1)/2 - i*(0+i-1)/2 + 1;
        sum %= mo;
        //cout << i*(N+N-i+1)/2 - i*(0+i-1)/2<< " " <<i*(N+N-i+1)/2 << " "<<i*(0+i-1)/2<< endl;
    }
    cout << sum <<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<vector<int>> edges;
const int mod = 1e9 + 7;
vector<int> dfs(int i, int par)
{
    int white = 1, black = 1;
    for (int j : edges[i])
    {
        if (par != j)
        {
            vector<int> temp = dfs(j, i);
            int w = temp[0];
            int b = temp[1];
            white = (white % mod * (w+b) % mod ) % mod;
            black = (black % mod * w % mod) % mod;
        }
    }
    return {white, black};
}
int32_t main()
{
    int n,m;
    cin >> n;// >> m;
    m=n-1;
    edges = vector<vector<int>>(n);

    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    vector<int> ans = dfs(0, -1);
    ans[0] = (ans[0] % mod + ans[1] % mod) % mod;
    cout << ans[0];
    return 0;
}


Measured memory_bytes: 18480
# import sys
# input = sys.stdin.readline()
n,m = map(int, input().split())
ab = []
for i in range(m):
  a,b = map(int, input().split())
  ab.append([a,b])

class UnionFind:
  def __init__(self,N):
    self.parent = [i for i in range(N)]
    self._size = [1] * N
    self.count = 0
  def root(self,a):
    if self.parent[a] == a:
      return a
    else:
      self.parent[a] = self.root(self.parent[a])
      return self.parent[a]
  def is_same(self,a,b):
    return self.root(a) == self.root(b)
  def unite(self,a,b):
    ra = self.root(a)
    rb = self.root(b)
    if ra == rb: return
    if self._size[ra] < self._size[rb]: ra,rb = rb,ra
    self._size[ra] += self._size[rb]
    self.parent[rb] = ra
    self.count += 1
  def size(self,a):
    return self._size[self.root(a)]


uf = UnionFind(n)

for i in range(m):
  a, b = ab[i][0],ab[i][1]
  a -= 1
  b -= 1
  if uf.is_same(a,b):
    continue
  uf.unite(a,b)
x = 0
for i in range(n):
  x = max(x, uf._size[i])
print (x)

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

int main(){
  int h,w;
  char maps[1010][1010];
  char kun[10];
  int cnt;
  int ans=0;
  string str;
  int best;
  char joi[3];
  //旗の入力
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>maps[i][j];
    }
  }
  //勲章入力
  cin>>str;
  kun[0]=str[0];
  kun[1]=str[1];
  cin>>str;
  kun[2]=str[0];
  kun[3]=str[1];
  cnt=0;
  //昔の旗の勲章の数
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(kun[0]==maps[i][j] && kun[1]==maps[i][j+1] && kun[2]==maps[i+1][j] && kun[3]==maps[i+1][j+1])cnt++;
    }
  }
  if(ans<cnt)ans=cnt;
  best=cnt;
  //白紙のパターン
  joi[0]='J';
  joi[1]='O';
  joi[2]='I';
  int miruy[]={-1,-1,0,0,-1,-1,0,0,0,0,1,1,0,0,1,1};
  int mirux[]={-1,0,-1,0,0,1,0,1,-1,0,-1,0,0,1,0,1};
  int ima;
  char kari;
  for(int s=0;s<h;s++){
    for(int r=0;r<w;r++){
      cnt=0;
      kari=maps[s][r];
      for(int i=0;i<13;i+=4){
	if(kun[0]==maps[s+miruy[i]][r+mirux[i]]){
	  if(kun[1]==maps[s+miruy[i+1]][r+mirux[i+1]]){
	    if(kun[2]==maps[s+miruy[i+2]][r+mirux[i+2]]){
	      if(kun[3]==maps[s+miruy[i+3]][r+mirux[i+3]])cnt++;
	    }
	  }
	}
      }
      ima=cnt;
      best-=ima;
      for(int m=0;m<3;m++){
	maps[s][r]=joi[m];
	cnt=0;
	for(int i=0;i<13;i+=4){
	  if(kun[0]==maps[s+miruy[i]][r+mirux[i]]){
	    if(kun[1]==maps[s+miruy[i+1]][r+mirux[i+1]]){
	      if(kun[2]==maps[s+miruy[i+2]][r+mirux[i+2]]){
		if(kun[3]==maps[s+miruy[i+3]][r+mirux[i+3]])cnt++;
	      }
	    }
	  }
	}
	if(ans<best+cnt)ans=best+cnt;
	//	cout<<best<<" "<<cnt<<" "<<s<<","<<r<<" "<<joi[m]<<endl;
      }
      maps[s][r]=kari;
      best+=ima;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2200
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

const ll INF = 1LL<<60;

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> s(n+1); //累積和
  s[0] = 0;
  for (int i = 1; i <=n; ++i) {
    s[i] = a[i-1];
    s[i] += s[i-1];
  }
  ll ans = INF;
  for (int r = 1; r < n; ++r) {
    ll x = s[r], y = s[n] - s[r];
    debug(x,y);
    chmin(ans, (ll)fabs(x-y));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3456
n = int(input())
t = [int(input()) for i in range(n)]

def g(a, b):
    while b != 0:
        a, b = b, a%b
    return a

def l(a, b):
    return a * b // g(a, b)

for i in range(n-1):
    t[i+1]=l(t[i+1], t[i])
print(t[n-1])

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if ((0 <= i && i < B && 0 <= j && j < A)
                    ||(B <= i && i < H && A <= j && j < W)) {
                    System.out.print("0");
                } else {
                    System.out.print("1");
                }
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 46020
import java.io.*;

public class Main {

    public static void main(String[] args) throws IOException {
	// write your code here
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw =new PrintWriter(new OutputStreamWriter(System.out));
        char n = br.readLine().charAt(0);
        pw.println((char)(((int)n)+1));pw.flush();
    }
}


Measured memory_bytes: 21076
n = int(raw_input())
p = list(map(float, raw_input().split()))

dp = [[0]*(i+2) for i in range(n)]
dp[0][0] = 1-p[0]
dp[0][1] = p[0]

for i in range(1, n):
    for j in range(i+2):
        if j < i+1:
            dp[i][j] += dp[i-1][j]*(1-p[i])
        if j > 0:
            dp[i][j] += dp[i-1][j-1] * p[i]

print(sum(dp[n-1][(n//2)+1:]))


Measured memory_bytes: 136584
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;


typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

vector<int> G[100005];
std::vector<P> tree[100010];

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

#define p(x) cout<<x<<endl;
#define e cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)

ll i,j,k,l,ii,jj;
ll n,m,ans=0,sum,num=0;
ll a,b,c;
ll big,small;


int main(){
    cin>>n;
    for(a=1;a<=3500;a++){
        for(b=1;b<=3500;b++){
            big = n*a*b;
            small = 4*a*b-n*b-n*a;
            if(small != 0 && big%small == 0 && big/small>0){
                pe(a);pe(b);pe(big/small);e;return 0;
            }
        }
    }
    return 0;
    
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

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

int main() {
    init();
    ll N,P;
    cin >> N >> P;
    map<ll, ll> mp;
    repe(i,2,(ll)sqrt(P)+1){
        while(P%i==0){
            P /= i;
            mp[i]++;
        }
    }
    if (P != 1) mp[P]++;

    ll ans = 1;
    for(auto p:mp){
        ll x, cnt;
        tie(x, cnt) = p;
        // cout << x << " " << cnt << endl;
        while (cnt >= N) ans *= x, cnt -= N;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    int a, b;
    cin>>a>>b;
    a = max(a, b);
    b = max(b, a);
    if(a+b <= 16)
        cout<<"Yay!";
    else
        cout<<":(";
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3616
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

from collections import deque,defaultdict,Counter
def main():
    H,W,N = map(int,input().split())
    point = [tuple(map(int,input().split())) for _ in range(N)]
    ans = [0] * 10

    dic = defaultdict(int)
    for p,q in point:
        for dy in (-1,0,1):
            for dx in (-1,0,1):
                if p + dy <= 1 or p + dy >= H:
                    continue
                if q + dx <= 1 or q + dx >= W:
                    continue
                center = (p + dy,q + dx)
                ans[dic[center]] -= 1
                dic[center] += 1
                ans[dic[center]] += 1
    ans[0] += (H - 2)*(W - 2)
    print('\n'.join(map(str,ans)))
if __name__ == '__main__':
    main()

Measured memory_bytes: 180336
import sys
import numpy as np
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
H, W, K = map(int, readline().split())
C = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W]
 
C = 1 * (C == b'#')
 
def f(C, x, y):
    rows = [i for i in range(H) if x & (1<<i)]
    cols = [i for i in range(W) if y & (1<<i)]
    D = C[rows][:,cols]
    return D.sum() == K
 
ans = 0
for x in range(1 << H):
    for y in range(1 << W):
        ans += f(C, x, y)
print(ans)

Measured memory_bytes: 27232
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int a,b,c;
  cin >> a >> b >> c;
  int coin = 0;
  int ans = 0;
  while(coin<c){
    coin += a;
    if(ans%7==6) coin += b;
    ans++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3116
class UnionFind:
    def __init__(self, n: int) -> None:
        self.forest = [-1] * n

    def union(self, x: int, y: int) -> None:
        x = self.findRoot(x)
        y = self.findRoot(y)
        if x == y:
            return
        if self.forest[x] > self.forest[y]:
            x, y = y, x
        self.forest[x] += self.forest[y]
        self.forest[y] = x
        return

    def findRoot(self, x: int) -> int:
        if self.forest[x] < 0:
            return x
        else:
            self.forest[x] = self.findRoot(self.forest[x])
            return self.forest[x]

    def issame(self, x: int, y: int) -> bool:
        return self.findRoot(x) == self.findRoot(y)

    def size(self, x: int) -> int:
        return -self.forest[self.findRoot(x)]


n,q = map(int,input().split())
uf = UnionFind(n)
for i in range(q):
    ti,ui,vi = map(int,input().split())
    if ti:
        print(int(uf.issame(ui,vi)))
    else:
        uf.union(vi,ui)


Measured memory_bytes: 11612
w, h, x, y, r = map(int, input().split())
ok = True
if x - r >= 0 and x + r <= w:
    if y - r >= 0 and y + r <= h:
        pass
    else:
        ok = False
else:
    ok = False
    
if ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

// snukeさんのmodint
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// mint N;
//cout << N.x << endl;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    const int MAX_A = 1000500;
    vector<int> era(MAX_A,0);
    era[0] = era[1] = 1;
    for(int i=2; i<MAX_A; i++){
        if(!era[i]){
            for(int j=i+i; j<MAX_A; j+=i){
                era[j] = i;
            }
        }
    }
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    map<int,int> mp;
    for(int i=0; i<N; i++){
        int temp = A[i];
        map<int,int> te;
        while(era[temp] != 0 and temp != 1){
            te[era[temp]]++;
            temp /= era[temp];
        }
        te[temp]++;
        for(auto m: te){
            if(mp[m.first] < m.second){
                mp[m.first] = m.second;
            }
        }
    }
    mint sum = 1;
    for(auto m: mp){
        mint temp = m.first;
        temp = temp.pow(m.second);
        sum *= temp;
    }
    mint ans = 0;
    for(int i=0; i<N; i++){
        mint a = A[i];
        ans += sum/a;
    }
    cout << ans.x << enld;
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

int main()
{
	int m;
	while (cin >> m, m) {
		vector<int> x(m), y(m);
		for (int i = 0; i < m; i++) {
			cin >> x[i] >> y[i];
		}
		int n;
		cin >> n;
		set<pii> st;
		for (int i = 0; i < n; i++) {
			int a, b;
			cin >> a >> b;
			st.emplace(a, b);
		}
		for (auto p : st) {
			int cx = p.first - x[0], cy = p.second - y[0];
			bool ok = true;
			for (int i = 1; i < m; i++) {
				if (!st.count(pii(x[i] + cx, y[i] + cy))) {
					ok = false;
					break;
				}
			}
			if (ok) {
				cout << cx << ' ' << cy << endl;
				break;
			}
		}
	}
	return 0;
}



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

dist_from_X = list(abs(i - (X - 1)) for i in range(N))
dist_from_Y = list(abs(i - (Y - 1)) for i in range(N))

ans_list = [0] * N

for i in range(N):
    for j in range(i, N):
        i_X_Y_j = dist_from_X[i] + 1 + dist_from_Y[j]
        i_Y_X_j = dist_from_Y[i] + 1 + dist_from_X[j]
        i_j = abs(i - j)
        min_dist_i_j = min(i_X_Y_j, i_Y_X_j, i_j)
        ans_list[min_dist_i_j] += 1

for num in ans_list[1:]:
    print(num)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define inf 9e18
#define pii pair<int,int>
#define ALL(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
using namespace std;
int n,K;
vector<int> v;
int dp[100005][2];
bool play(int k,int turn){
    if(k==0)
        return turn==0;
    if(dp[k][turn]!=-1)
        return dp[k][turn];
    bool ans;
    if(turn)
        ans=0;
    else
        ans=1;

  //  bool picked = 0;
    for(int &i:v){
        if(i<=k){
          //  picked = 1;
            if(turn)
                ans = play(k-i,turn^1)||ans;
            else
                ans = play(k-i,turn^1)&&ans;
        }
    }
    return dp[k][turn]=ans;
}
int32_t main()
{
    
    fastio
     
    
    cin>>n>>K;
    for(int i=0;i<n;i++){
        int b;
        cin>>b;
        v.pb(b);
    }
    for(int i=0;i<=K;i++)
        dp[i][0]=dp[i][1]=-1;
    bool ans = play(K,1);
    if(ans)
        cout<<"First";
    else
        cout<<"Second";


    return 0;
}

Measured memory_bytes: 8064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main() {
    int N;
    char mozi[10000];
    scanf("%d", &N);
    scanf("%s", mozi);
    int n=strlen(mozi);

    for (int i = 0; i < n; i++) {
        int x=mozi[i]-'A';
        x=(x+N)%26;
        putchar(x+'A');}
 }


Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main(){
    char a[3];
    cin >> a;
    int ans = 700;
    for(int i=0;i<3;i++){
        if(a[i] == 'o'){
            ans += 100;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
int main()
{
  int n; cin >> n;
  vector<string> s(n);
  vector<int> p(n);
  rep(i,n) cin >> s[i] >> p[i];

  using psii = pair<pair<string,int>,int>;
  vector<psii> vec(n);
  rep(i,n) {
    vec[i] = { {s[i], p[i]}, i+1};
  }

  sort(vec.begin(), vec.end(), [](psii a, psii b) {
				 if(a.first.first == b.first.first) return a.first.second > b.first.second;
				 else return a.first.first < b.first.first;
			       });

  rep(i,n) cout << vec[i].second << "\n";
  
  return 0;
}


Measured memory_bytes: 3588
N,M=map(int,input().split()) #N...ken M..hon
A=[list(map(int,input().split())) for i in range(N)]
A=sorted(A) #A...en B..hon
#print(A)
price=0
num=0
for i in range(N):
    if num+A[i][1]<M:
        price+=A[i][0]*A[i][1]
        num+=A[i][1]
    elif num<M and num+A[i][1]>=M:
        price+=A[i][0]*(M-num)
        break
    else:
        break
print(price)


Measured memory_bytes: 28656
(n,k)=gets.split.map(&:to_i)
a=gets.split.map{|s| s.to_i - 1 }

memo=[0]
idx=nil
use_num = [1]
loop {
    c = a[memo[-1]]
    if use_num[c] == 1
        idx = memo.index(c)
        break
    end
    use_num[c] = 1
    memo << c
}

if k >= memo.size
    k = (k - idx) % (memo.size - idx) + idx
end

print memo[k]+1

Measured memory_bytes: 30380
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long ,long long>pll;
 
ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}
 
const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
 
long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}
 
void solve(){
   ll n,d,a;
   cin >> n >> d >> a;
   vector<pll>m(n);
   for(int i = 0;i<n;i++){
    cin >> m[i].first >> m[i].second;
   }
   sort(m.begin(),m.end());
   queue<pll>q;
   ll total = 0;ll ans = 0;
   for(int i = 0;i<n;i++){
    ll x = m[i].first;
    ll h = m[i].second;
    while(q.size()&&q.front().first<x){
         total -= q.front().second;
         q.pop();
    }
    h -= total;
    if(h>0){
        ll num = (h+a-1)/a;
        ans += num;
        total += num*a;
        q.push({x+2*d,num*a});
    }
   }
   cout << ans;
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 7860
import sys
import math
from collections import deque


def bisect(ng, ok, x, q):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if q[mid][0] >= x:
            ok = mid
        else:
            ng = mid
    return ok


def solve_greedy(N, D, A, XH):
    ret = 0
    q = deque([(0, 0)])
    for i, (x, h) in enumerate(XH):
        if q[-1][0] < x:
            damaged = 0
        else:
            i = bisect(0, len(q) - 1, x, q)
            damaged = q[-1][1] - q[i - 1][1]
            # q = q[i-1:]
        if h <= damaged:
            continue
        tmp = math.ceil((h - damaged) / A)
        ret += tmp
        q.append((x + 2 * D, A * tmp + q[-1][1]))
    return ret


input = sys.stdin.readline
N, D, A = map(int, input().split())
XH = sorted([list(map(int, input().split()))
             for _ in range(N)], key=lambda x: x[0])
ans = solve_greedy(N, D, A, XH)
print(ans)


Measured memory_bytes: 117376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(x) (x).begin(),(x).end()
const int MAX=4003,INF=1<<30;
const ll mod=998244353;

ll inv[MAX],fac[MAX],finv[MAX];

void make(){
    
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    
    for(int i=2;i<MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll)i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
    
}

ll comb(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}

ll rui(ll a,ll b){
    if(b==1) return a%mod;
    else if(b==0) return 1;
    else if(b%2==0) return (rui(a,b/2)*rui(a,b/2))%mod;
    else return (rui(a,b-1)*a)%mod;
}


int main(){
    
    make();
    
    ll K,N;cin>>K>>N;
    vector<ll> S;
    
    for(ll i=2;i<=K+1;i++){
        ll ans=0;
        if(i%2==1){
            ll to=i/2,Y=K-to*2;
            for(ll j=0;j<=to;j++){
                ans+=comb(to,j)*rui(2,j)%mod*comb(Y+N-1,Y-1+j)%mod;
                ans=ans%mod;
            }
            S.push_back(ans);
        }else{
            ll to=i/2-1,Y=K-to*2-1;
            for(ll j=0;j<=to;j++){
                ans+=comb(to,j)*rui(2,j)%mod*comb(Y+N-1,Y-1+j)%mod;
                ans=ans%mod;
            }
            for(ll j=0;j<=to;j++){
                ans+=comb(to,j)*rui(2,j)%mod*comb(Y+N-2,Y-1+j)%mod;
                ans=ans%mod;
            }
            S.push_back(ans);
        }
    }
    
    for(int i=0;i<S.size();i++){
        cout<<S[i]<<endl;
    }
    reverse(all(S));
    for(int i=1;i<S.size();i++){
        cout<<S[i]<<endl;
    }
}



Measured memory_bytes: 384
/*
  AUTHOR:SOURABH
  CREATED:31:05:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pii , null_type, less< pii >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 998244353
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t;
    ll a;
    ld b;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>a>>b;
        cout<<(ll)(a*b);
    }
    return 0;
}







Measured memory_bytes: 3760
n=int(input())
a=[int(j)for j in input().split()]
s=sum(a)
import collections
c=collections.Counter(a)
q=int(input())
for i in range(q):
    x,y=map(int,input().split())
    s+=c[x]*(y-x)
    c[y]+=c[x]
    c[x]=0
    print(s)






Measured memory_bytes: 23844
#include<stdio.h>
int main()
{
    int a[10][10],i,j;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        scanf("%c",&a[i][j]);
        getchar();
    }
    printf("%c%c%c",a[0][0],a[1][1],a[2][2]);
}


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

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    int x = a.size()-1;
    int y = b.size()-1;
    if (a[x] == b[0] && b[y] == c[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
using namespace std;
#define sci(n) scanf("%lld", &(n))
#define scd(n) scanf("%Ld", &(n))
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> pll;
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	LL n; cin >> n;
	n++;
	LL ans = 0;
	while (n>0) {
		n--;
		if (n == 0)break;
		string s = to_string(n);
		if (s.length() % 2 == 1) {
			ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで毎回include
//以下プログラム

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	vector<int>A = { a,b,c };
	sort(A.begin(), A.end());
	if ((A[2] - A[0] + A[2] - A[1]) % 2 == 0) {
		cout << (A[2] - A[0] + A[2] - A[1]) / 2 << endl;
	}
	else {
		cout << (A[2] - A[0] + A[2] - A[1]) / 2 + 2 << endl;
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define mod 1000000007
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N=1e5+4;
string s1,s2;
int dp[3005][3005]= {};
inline int solve(int idx1,int idx2)
{
    if (idx1>=(int)s1.size()||idx2>=(int)s2.size())
        return 0;
    int &ret=dp[idx1][idx2];
    if (~ret)
        return ret;
    ret=0;
    if (s1[idx1]==s2[idx2])
        ret=max(ret,solve(idx1+1,idx2+1)+1);
    ret=max(ret,solve(idx1+1,idx2));
    ret=max(ret,solve(idx1,idx2+1));
    return ret;
}
inline void output(int idx1,int idx2)
{
    if (idx1>=s1.size()||idx2>=s2.size())
        return;
    int &ret=dp[idx1][idx2];
    if (s1[idx1]==s2[idx2]&&ret==solve(idx1+1,idx2+1)+1)
    {
        cout<<s1[idx1];
        output(idx1+1,idx2+1);
        return;
    }
    if (ret==solve(idx1+1,idx2))
    {
        output(idx1+1,idx2);
        return;
    }
    if (ret==solve(idx1,idx2+1))
    {
        output(idx1,idx2+1);
        return;
    }
}
int main()
{
#ifdef ONLINE_JUDGE
    FAST;
#endif
    memset(dp,-1,sizeof(dp));
    cin>>s1>>s2;
    solve(0,0);
    output(0,0);
    return 0;
}

Measured memory_bytes: 36352
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define REP(i,n) for (int i = 0; i < n; ++ i)
#define FOR(i,a,b) for (int i = a; i <= b; ++ i)
#define FORD(i,b,a) for (int i = b; i >= a; -- i)
#define debug(x) cerr << #x << ": " << x << "\n"
#define task ""
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> li;
typedef vector<int> vi;

int main() {
	//ios_base::sync_with_stdio(0);
	//cin.tie(0); cout.tie(0);
	//freopen(task".inp", "r", stdin);
	//freopen(task".out", "w", stdout);
	int n;
	scanf("%d", &n);
	int pre = -1, cnt = 0, res = 0;
	FOR(i, 1, n) {
		int val;
		scanf("%d", &val);
		if (val == pre) cnt ++;
		else {
			res += cnt / 2;
			pre = val;
			cnt = 1;
		}
	}	
	printf("%d", res + cnt / 2);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;


int main() {
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
}


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

int main() {
  int a, b, c, diff = 0;  
	cin >> a >> b >> c;
  if(1 <= b && b <= a && a <= 20 && 1 <= c && c <= 20)
    diff = c - (a - b);
  if(diff >= 0)
    cout << to_string(diff);
  else
    cout << '0';
  return 0;
}

Measured memory_bytes: 256
cnt = [0]*100002

n = int(input())

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



for x in a:

	cnt[x] += 1

	if x > 0 : cnt[x-1] += 1

	cnt[x+1] += 1

	

answer = 0

for n in cnt:

	answer = max(answer, n)



print(answer)

Measured memory_bytes: 11480
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int f(int n) {
	return n*(n + 1) / 2;
}

int main() {
	int a, b;
	cin >> a >> b;
	int c = b - a;
	cout << f(c) - b << endl;
	return 0;
}

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

#define HP(a, b) pow((a-b), 2)

int main() {
  int N;
  cin >> N;
  int X[N];
  int min = 101;
  int max = -1;
  for (int i = 0; i < N;i++)
  {
    cin >> X[i];
    if(min > X[i])
    {
      min = X[i];
    }

    if(max < X[i])
    {
      max = X[i];
    }
  }

  int sum = INT32_MAX;
  for (int i = min; i <= max;i++)
  {
    int tmp = 0;
    for (int j = 0; j < N;j++)
    {
      tmp += HP(i, X[j]);
    }
    if(sum > tmp)
    {
      sum = tmp;
    }
    else if(sum < tmp)
    {
      break;
    }
  }

  cout << sum << endl;
}

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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

ll solve(ll N, ll M, vi& a, vi& b) {
    if (N <= 3) return 0;

    vvi next(N);
    rep(i,M) {
        next[a[i]].pb(b[i]);
        next[b[i]].pb(a[i]);
    }

    vi side(N, -1);
    queue<ii> q;
    q.emplace(0, 0);
    while (!q.empty()) {
        ii t = q.front(); q.pop();
        int n = t.first, s = t.second;
        if (side[n] == -1) {
            side[n] = s;

            for (int ch : next[n]) {
                q.emplace(ch, 1-s);
            }
        } else {
            if (side[n] != s) {
                return N*(N-1)/2 - M;
            }
        }
    }
    vll st(2, 0);
    rep(i,N) st[side[i]]++;
    return st[0] * st[1] - M;
}

int main() {
    int N, M; scanf("%d%d", &N, &M);
    vi a(M), b(M);
    rep(i,M) {
        scanf("%d%d", &a[i], &b[i]);
        --a[i]; --b[i];
    }
    cout << solve(N,M,a,b) << endl;
    return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
 
if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
cout<< "vowel" <<endl;
}else{
cout<< "consonant" <<endl;
}
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var ret = 0;
        var pre = a[0];
        var cont = 1;
        for (int i = 1; i < n; i++)
        {
            if (a[i] == pre) cont++;
            else
            {
                ret += cont / 2;
                cont = 1;
            }
            pre = a[i];
        }
        ret += cont / 2;
        Console.WriteLine(ret);
    }
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
const int MOD=1000000007;
const int INF=LLONG_MAX/2;

signed main() {cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    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
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;


int main()
{
  int n;
  int ans;
  while(cin >> n)
  {
    ans = 0;
    for(int a = 0; a < 10; a++)
    {
      for(int b = 0; b < 10; b++)
      {
        for(int c = 0; c < 10; c++)
        {
          for(int d = 0; d < 10; d++)
          {
            if(a + b + d + c == n)
            {
              ans++;
              break;
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>

int a[110];

int main()
{

    int n, m;
    std::cin >> n >> m;

    int sum = 0;
    for (int i = 0; i < n; ++i)
    {
        std::cin >> a[i];
        sum += a[i];
    }

    int l = (sum % (4 * m)) ? sum / (4 * m) : sum / (4 * m) - 1;

    int cnt = 0;

    for (int i = 0; i < n; ++i)
    {
        if (a[i] > l)
            ++cnt;
    }

    if (cnt >= m)
        std::cout << "Yes" << std::endl;
    else
    {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
/* Dijkstra's Algorithm ( O(|V|^2) ) */

#include<cstdio>
#include<climits>
#include<algorithm>

using namespace std;

int adj[20][20],n;

int dijkstra(int s,int g)
{
	int d[20];
	bool visited[20];
	for(int i=1;i<=n;i++)	d[i]=INT_MAX,visited[i]=false;

	d[s]=0;
	while(1){
		// find next u
		int u,cmin=INT_MAX;
		for(int i=1;i<=n;i++){
			if(!visited[i] && d[i]<cmin)	cmin=d[i],u=i;
		}
		if(cmin==INT_MAX)	break;

		visited[u]=true;

		// update d[v]
		for(int v=1;v<=n;v++){
			if(visited[v] || adj[u][v]==INT_MAX)	continue;
			d[v]=min(d[v],d[u]+adj[u][v]);
		}
	}
	return d[g];
}

int main()
{

	int m;	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)adj[i][j]=INT_MAX;
	for(int i=0;i<m;i++){
		int a,b,c,d;	scanf("%d,%d,%d,%d",&a,&b,&c,&d);
		adj[a][b]=c;
		adj[b][a]=d;
	}
	int x1,x2,y1,y2;	scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);

	printf("%d\n",y1-y2-dijkstra(x1,x2)-dijkstra(x2,x1));

	return 0;
}

Measured memory_bytes: 0
import bisect

n = int(input())
ll = list(map(int, input().split()))
ll.sort()

ans = 0
for i in range(n-2):
    e1 = ll[i]
    for j in range(i+1, n-1):
        e2 = ll[j]
        comb = bisect.bisect_left(ll[j+1:], e1+e2)
        # comb -= (j+1)
        ans += max(comb,0)

print(ans)



Measured memory_bytes: 74800
#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 MAX_N = 200005;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(MAX_N);

vector<int> to[MAX_N];

struct DP {
  mint dp;
  int t;
  DP(mint dp=1, int t=0):dp(dp),t(t) {}
  DP& operator+=(const DP& a) {
    dp *= a.dp;
    dp *= comb(t+a.t, t);
    t += a.t;
    return *this;
  }
  DP operator-(const DP& a) const {
    DP res(*this);
    res.t -= a.t;
    res.dp /= comb(res.t+a.t, res.t);
    res.dp /= a.dp;
    return res;
  }
  DP addRoot() const {
    DP res(*this);
    res.t++;
    return res;
  }
};

vector<DP> dp[MAX_N];
DP dpSum[MAX_N];

DP dfs(int v, int p=-1) {
  dp[v] = vector<DP>(to[v].size());
  rep(i,to[v].size()) {
    int u = to[v][i];
    if (u == p) continue;
    dp[v][i] = dfs(u,v);
    dpSum[v] += dp[v][i];
  }
  return dpSum[v].addRoot();
}
void bfs(int v, const DP& dpP=DP(), int p=-1) {
  if (p != -1) dpSum[v] += dpP;
  rep(i,to[v].size()) {
    int u = to[v][i];
    if (u == p) {
      // dp[v][i] = dpP;
      continue;
    }
    DP d = dpSum[v] - dp[v][i];
    bfs(u, d.addRoot(), v);
  }
}

int main() {
  int n;
  cin >> n;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  dfs(0);
  bfs(0);
  rep(i,n) {
    cout << dpSum[i].addRoot().dp << endl;
  }
  return 0;
}


Measured memory_bytes: 34292
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <stack>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
double pi = 3.141592658;
int main(){
	double a, b, x;
	cin >> a >> b >> x;

	double S = x/a;

	if(S>=0.5*a*b){
		double l = 2.0*S/a - b;

		double theta = atan(a/(b-l));
		cout << fixed << setprecision(9) << 90 - 180*theta/pi <<endl;

	}else{
		double h = 2.0*S/b;
		double theta = atan(h/b);
		cout << fixed << setprecision(9) << 90 - 180*theta/pi <<endl;
	}
    
  	return 0;
}













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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n; cin >> n;
    cout << fixed << setprecision(6);
    if(n&1) {
        cout << ((n+1)/2.0)/n << '\n';
    } else {
        cout << (n/2.0)/n << '\n';
    }
    return 0;
}

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

int main()
{
    int X;
    cin >> X;
    int maxpower = 0;
    if(X==1){
        cout << "1" << endl;
        return 0;
    }
    for(int b=2;b<32;b++){
        int power = b;
        while(1){
            power *= b;
            if(power == X){
                cout << power << endl;
                return 0;
            }
            else if(power > X){
                break;
            }
            else if(power > maxpower){
                maxpower = power;
            }
        }
    }
    cout << maxpower << endl;
    return 0;
}


Measured memory_bytes: 256