akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;


int main(){
    int H, W;
    cin >> H >> W;
    int a[555][555];
    for(int i=0; i<H; i++)
        for(int j=0; j<W; j++)
            cin >> a[i][j];

    vector<pair<int, int>> path;
    for(int i=0; i<H; i++){
        if(i % 2 == 0)
            for(int j=0; j<W; j++)
                path.emplace_back(i, j);
        else
            for(int j=W-1; j>=0; j--)
                path.emplace_back(i, j);
    }

    vector<pair<pair<int, int>, pair<int, int>>> mvs;
    bool carry = a[path[0].first][path[0].second] % 2;
    for(int i=0; i<path.size()-1; i++){
        if(carry){
            mvs.emplace_back(path[i], path[i+1]);
        }
        if(a[path[i+1].first][path[i+1].second] % 2)
            carry = !carry;
    }

    cout << mvs.size() << endl;
    for(auto x : mvs){
        cout << x.first.first+1 << " ";
        cout << x.first.second+1 << " ";
        cout << x.second.first+1 << " ";
        cout << x.second.second+1 << endl;
    }
    return 0;

}

Measured memory_bytes: 7280
#include<vector>
#include<queue>
#include<stdio.h>
#include<map>
#include<set>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#define mp make_pair
using namespace std;
typedef long long ll;
inline ll in()
{
    ll res=0,p=1;
    char c=getchar();
    while(c<'0'||c>'9') {if(c=='-') p=-1; c=getchar();}
    while(c>='0'&&c<='9') res=res*10+c-48,c=getchar();
    return p*res;
}
void out(ll x)
{
    if (x>9) out(x/10);
    putchar(x%10+48);
}
void outn(ll x)
{
    if (x<0){
        putchar('-');
        out(-x);
    }else out(x);
    putchar(10);
}
const int mod = 1e9 + 7, inf = 0x3f3f3f3f;
//const double pi = acos(-1.0);
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int dx[4] = {0, 0, -1, 1}, dy[4] = {1, -1, 0, 0};

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll quickpow(ll x, int k)
{
    ll res = 1;
    while(k){
        if(k & 1) res = (res * x) % mod;
        k >>= 1, x = (x * x) % mod;
    }
    return res;
}
ll fac[200005] = {1};
ll C(int n, int m){return (fac[n] * quickpow((fac[m] * fac[n - m]) % mod, mod - 2)) % mod;}
const int maxn = 1e5 + 5;

int main()
{
    for (int i = 1; i < 200005; ++i) fac[i] = (fac[i - 1] * i) % mod;
    int h, w, a, b;
    h = in(); w = in(); a = in(); b = in();
    ll ans = 0;
    for (int i = b + 1; i <= w; ++i)
        ans = (ans + C(i - 1 + h - a - 1, min(i, h - a) - 1) * C(w - i + a - 1, min(w - i, a - 1))) % mod;
    outn(ans);
    return 0;
}


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

void query(string &l, string &r)
{
  int T;
  cin >> T;
  if (T == 1)
  {
    swap(l, r);
    return;
  }
  int F;
  char c;
  cin >> F >> c;
  if (F == 1)
  {
    l += c;
  }
  else
  {
    r += c;
  }
}

void show_ans(string &l, string &r)
{
  reverse(l.begin(), l.end());
  cout << l << r << endl;
}

int main()
{
  string s_l, s_r;
  int Q;
  cin >> s_r >> Q;
  for (int i = 0; i < Q; i++)
  {
    query(s_l, s_r);
  }
  show_ans(s_l, s_r);
}


Measured memory_bytes: 960
d, g = map(int, input().split())
g = g//100
p = [0] * (d+1)
c = [0] * (d+1)
for i in range(1, d+1):
    p[i], c[i] = map(int, input().split())
    c[i] = c[i]//100

def dfs(h, s):
    if h == 0:
        return 10**9
    tmp = min(p[h], s//h)
    score = tmp * h
    if tmp == p[h]:
        score += c[h]
    if score < s:
        tmp += dfs(h-1, s-score)
    return min(tmp, dfs(h-1, s))

print(dfs(d, g))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

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

    map<string, vector<pi> > mp;
    REP(i, N) {
        string s; int p;
        cin >> s >> p;
        if (mp.count(s)) {
            mp[s].pb(pi(p, i+1));
        } else {
            vector<pi> vec;
            vec.pb(pi(p, i+1));
            mp.emplace(s, vec);
        }
    }
    for (auto p: mp) {
        vector<pi> v = p.second;
        sort(v.begin(), v.end(), [](pi a, pi b){
            return a.first > b.first;
        });
        for (auto e: v) {
            cout << e.second << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
K = [[0] for i in range(M)]
adjacent = [[0]*N for i in range(M)]
for i in range(M):
    A = list(input().split())
    K[i] = A[0]
    for j in A[1:]:
        adjacent[i][int(j)-1] = 1
P = list(input().split())
X = 0
for i in range(2**N):
  a = 0
  b = [0]*N
  for j in range(N):
    if i%2 == 1:
      b[j] = 1
    i = i//2
  for j in range(M):
    if  sum([x*y for (x,y) in zip(b, adjacent[j])])%2 == int(P[j]):
      a += 1
  if a == M:
    X += 1
print(X)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, W;
  cin >> N >> W;
  vector<long long> w(N), v(N);
  for (int i = 0; i < N; i++){
    cin >> w[i] >> v[i];
  }
  vector<vector<int>> v2(4);
  for (int i = 0; i < N; i++){
    v2[w[i] - w[0]].push_back(v[i]);
  }
  for (int i = 0; i < 4; i++){
    sort(v2[i].begin(), v2[i].end());
    reverse(v2[i].begin(), v2[i].end());
  }
  vector<vector<int>> sum(4);
  for (int i = 0; i < 4; i++){
    sum[i].push_back(0);
    for (int j = 0; j < v2[i].size(); j++){
      sum[i].push_back(sum[i].back() + v2[i][j]);
    }
  }
  int ans = 0;
  for (int i = 0; i <= v2[0].size(); i++){
    for (int j = 0; j <= v2[1].size(); j++){
      for (int k = 0; k <= v2[2].size(); k++){
        for (int l = 0; l <= v2[3].size(); l++){
          if (w[0] * i + (w[0] + 1) * j + (w[0] + 2) * k + (w[0] + 3) * l <= W){
            ans = max(ans, sum[0][i] + sum[1][j] + sum[2][k] + sum[3][l]);
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
from itertools import combinations

def main():
    n,k = map(int,input().split())
    A = list(map(int,input().split()))
    counter=0
    mod = 10**9+7
    
    for i  in range(n-1):
        for j in range(i+1,n):
            if A[i] > A[j]: counter+=1

    y =0
    for a1 in A:
        for a2 in A:
            if a1 > a2: y+=1

    ans=(counter*k+y*k*(k-1)//2)%mod
    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 9220
#include <iostream>
#include <cstdio>

#include <vector>

#include <algorithm>

using namespace std;

#define repeat(n) for(int _ = 1; _ <= (n); _++)

int main()
{
	ios::sync_with_stdio(false);
#ifdef CAI_WEI_HAN
	freopen("test.in", "r", stdin);
#endif
	
	int n, m;
	cin >> n >> m;
	
	vector< pair<int, int> > v;
	for(int i = 1; i <= n; i++) {
		int a, b;
		cin >> a >> b;
		
		v.push_back({a,b});
	}
	sort(v.begin(), v.end());
	
	int now = 0;
	long long ans = 0;
	for(auto pa : v) {
		if(now + pa.second < m) {
			now += pa.second;
			ans += (long long)pa.first * pa.second;
		}
		
		else {
			cout << ans + (long long)(m - now) * pa.first;
			return 0;
		}
	}
}


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

void fnInput(int& rnMaxNum, int& rnTrgNum)
{
  cin >> rnMaxNum >> rnTrgNum;
}

int fnCaseCount(int nMaxNum, int nTrgNum)
{
  int nAllDiff = 0;
  int nSameTwo = 0;
  int nAllSame = 0;

  for (int i = 0; i <= nMaxNum; i++)
    for (int j = 0; j <= i; j++)
    {
      int nRestNum = nTrgNum - (i + j);
      if (0 <= nRestNum && nRestNum <= j)
        if      (i == j && j == nRestNum)
          nAllSame++;
        else if (i == j || j == nRestNum || nRestNum == i)
          nSameTwo++;
        else
          nAllDiff++;
    }

  return (nAllDiff * 6 + nSameTwo * 3 + nAllSame);
}

int main()
{
  int nMaxNum, nTrgNum;

  fnInput(nMaxNum, nTrgNum);
  cout << fnCaseCount(nMaxNum, nTrgNum) << endl;

  return 0;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll a, b; cin >> a >> b;
  if(a == 1) a = MAX;
  if(b == 1) b = MAX;
  if(a > b) fin("Alice")
  else if(a < b) fin("Bob")
  else fin("Draw")
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//SET PRECIOSION   cout << fixed ;  cout << setprecision(n) << ans << endl;
#define ll long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector <ll> adj[100009];
int color[100090];
ll x,y,z,a,b,c,sum,ans,total,t,cnt,n,m,k,p,kase;
ll dfs(ll x)
{
     ll p = 0;
     if(color[x]!=0)
        return color[x];
    for(ll i = 0; i<adj[x].size(); i++)
    {
      ll y = 1+dfs(adj[x][i]);
        p = max(p,y);
    }
    return  color[x]=p;

}
int main()
{
	FAST;
	cin>>n>>m;
	for(ll i=0; i<m; i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
    }
    for(ll i =1; i<=n; i++)
    {
        if(color[i]==0)
            ans = max(dfs(i),ans);
    }
    cout<<ans<<endl;
	//clear vectors and maps you idiot
	// check array size dumb
	// use long long instead of int too
	return 0;
}


Measured memory_bytes: 11500
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// How to use 「map」
/*
  - 宣言
    map<{key_type}, {value_type}> salary;
  - 要素の挿入
    salary["Alice"] = 1000;
  - 要素の取得 O(logn)
    salary.at("Alice");
  - 要素の削除
    salary.erase("Alice");
  - キー検索
    salary.find("Alice"); -> true
    salary.find("Bob");   -> false
  - イテレーション
    for(auto& [key, value] : salary) {...}
 */
// -------------------------------------


// How to use 「lower_bound」, 「upper_bound」
/*
  vector<int> a = {1, 2, 3, 4, 5};
  auto iter1 = lower_bound(all(a), 3);  <- 第二引数「以上」の最小イテレータが返る
  auto iter2 = upper_bound(all(a), 3);  <- 第二引数「より大きい」最小のイテレータが返る
 */
// -------------------------------------


// How to use 「struct sort」
/*
  struct Person {
    string name;
    int age;

    Person(string _name, int _age) {
      name = _name;
      age = _age;
    }

    bool operator<(const Person &another) const {
      return age < another.age;
    }
  };

  vector<Person> people;
  people.pb(Person("Alice", 20));
  people.pb(Person("Bob", 19));
  people.pb(Person("John", 40));
  people.pb(Person("Chris", 30));
  sort(all(people));
 */
 // -------------------------------------

// -------------------------------------------------------------------------------------



int main() {
  int n, k;
  cin >> n >> k;
  if(n % k == 0) cout << 0 << endl;
  else cout << 1 << endl;

  return 0;
}

Measured memory_bytes: 256
from collections import deque
n = int(input())
a = [int(x) for x in input().split()]
b = deque()

for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])

for i in range(n):
    if n%2!=0:
        i=n-i-1
    print(str(b[i]) + " ", end="")
print()

Measured memory_bytes: 25664
#include <stdio.h>
int main() {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if ((a <= c && c <= b) || (b <= c && c <= a)) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n = I()
Count = Counter(readInts())
ans = 0
for k,v in Count.items():
    if k < v:
        ans += v - k
    if v < k:
        ans += v
print(ans)


Measured memory_bytes: 23096
package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	fmt.Scanf("%d", &n)
	fmt.Scanln(&s)

	mid := n / 2
	flag := true

	for i := 0; i < n/2; i++ {
		if string(s[i]) != string(s[mid]) {
			flag = false
			break
		}
		mid++
	}

	if flag && n%2 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N,M;
    cin >> N >>M;
    string arr(N,'x');
    for(int i = 0;i < M;i++){
        int a;
        char b;
        cin >> a >> b;
        if (arr[a-1] == 'x' || arr[a-1] == b)
        {
            arr[a-1] = b;
        }
        else 
        {
            cout << "-1" << endl;
            return 0;
        }
    }
    if(arr[0] == '0' && N>=2)
    {
            cout << "-1" << endl;
            return 0;
    }
    if(N==1 && arr[0] =='x')
    {
        cout << "0" << endl;    
        return 0;
    }
    for(int i = 0; i< N; i++)
    {
        if(arr[i] == 'x' && i!=0) arr[i] = '0';
        else if(arr[i] == 'x')arr[i] = '1';
    }
    cout << arr << endl;
}

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

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

    int ans = 0, m = 0;
    for (int i = 0; i < N; i++) {
        int pi;
        cin >> pi;
        ans += pi;
        m = max(m, pi);
    }
    ans -= m / 2;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  int n;
  string s;
  cin >> n >> s;
  int cnt = 0;
  for (auto e : s) {
    if (e == 'R')
      cnt++;
  }
  if (cnt > n/2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
n,q = map(int,input().split())
li = []
for i in range(n):
    li.append([])

for i in range(q):
    x = list(map(int,input().split()))
    if len(x) == 3:
        li[x[1]].append(x[2])
    else:
        if x[0] == 1:
            if li[x[1]] != []:
                print(li[x[1]][0])
        else:
            if li[x[1]] != []:
                li[x[1]].remove(li[x[1]][0])


Measured memory_bytes: 13692
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(int[]);

    int ans = 1;

    foreach (i ; 0 .. n) {
        ans *= 2^^(!(a[i] & 1));
    }

    ans = 3^^n - ans;

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
n,m = map(int,input().split())
s,c = [0 for i in range(n)],[0 for i in range(n)]

dict_cand = {}
for i in range(1,n+1):
    if i == n and n >= 2:
        dict_cand[i] = set(range(1,10))
    else:
        dict_cand[i] = set(range(0,10))

for i in range(m):
    s,c = map(int,input().split())
    dict_cand[n+1-s] = dict_cand[n+1-s] & set([c])

flag_number = True
for i in range(1,n+1):
    if len(dict_cand[i]) == 0:
        flag_number = False

if flag_number is True:
    number = 0
    for i in range(1,n+1):
        number += min(dict_cand[i]) * 10**(i-1)
    print(number)
else:
    print(-1)
        

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  ll n, x, m, cnt = 0, tot = 0, ans = 0, stot = 0;
  cin >> n >> x >> m;
  unordered_map<ll, ll> mp;
  vector<ll> v;
  while (mp.count(x) == 0) {
    mp[x] = cnt++;
    v.push_back(x);
    tot += x;
    x = x * x % m;
  }

  if (n <= cnt) {
    rep(i, n) ans += v[i];
    cout << ans << endl;
    return 0;
  }

  n -= mp[x];
  rep(i, v.size()) {
    if (v[i] == x) break;
    stot += v[i];
  }
  ll num = n / (cnt - mp[x]);
  ll mod = n % (cnt - mp[x]);
  ll pln = tot - stot;
  ans = pln * num + stot;
  for (int i = mp[x]; i < mp[x] + mod; ++i) ans += v[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5616
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
const int MAXN = 2e5+5,mod = 1e9+7,inv2 = 500000004;
int n,u,v,sz[MAXN],bas[MAXN],ans;
vector<int> G[MAXN],vec[MAXN];
il add_edge(int u,int v){
	G[u].push_back(v);
	G[v].push_back(u);
}
it add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
it mul(int x,int y){return 1ll*x*y%mod;}
il inc(int &x,int y){x=add(x,y);}
il DFS(int u,int fa){
	sz[u]=1;
	for(auto v:G[u]){
		if(v==fa) continue;
		DFS(v,u),sz[u]+=sz[v];
		vec[u].push_back(sz[v]);
	}
	if(n-sz[u]) vec[u].push_back(n-sz[u]);
	if((int)vec[u].size()==1) return ;
	int res=bas[n-1];
	for(auto a:vec[u])
		inc(res,mul(add(1,mod-bas[a]),bas[n-1-a]));
	res=add(1,mod-res),res=mul(res,inv2);
	inc(ans,res);
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),bas[0]=1;
	for(ri i=1;i<n;++i)
		read(u),read(v),add_edge(u,v);
	for(ri i=1;i<=n;++i)
		bas[i]=mul(bas[i-1],inv2);
	DFS(1,0);
	print(ans);
	return 0;
}

Measured memory_bytes: 30336
n, d = map(int, input().split())
lst = [list(map(int, input().split())) for i in range(n)]
#pair = []

cnt = 0

for i in range(n-1):
  for j in range(i+1,n):
    sum = 0
    for k in range(d):
      sum += (lst[i][k]-lst[j][k])**2
    sum = pow(sum,1/2)
    #print(111,sum)
    if sum == int(sum):
      cnt+=1
print(cnt)
    

Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    ll n, x;
    cin >> n >> x;
    ll ans = n, a = n-x, b = x;
    if (a < b) swap(a, b);
    while (b > 0){
        ans += (2*(a/b))*b;
        ll c = a % b;
        a = b;
        b = c;
    }
    ans -= a;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;


typedef long long ll;
typedef vector<int> VI;
    
vector<pair<int, int> > vp;

struct Less {
    bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
        return x.first > y.first;
    }
};
#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

//グラフの隣接リスト
VI g[200010];
//頂点の入次数を管理
int h[100010];
ll N, K;
string s;
int arr[26];
int main(void) {
    cin >> s;
    for(int i=0; i<s.size(); ++i){
        arr[(s[i]-'a')]++;
    }
    if(s=="zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl;
        return 0;
    }
    if(s.size()<=25){
        cout << s;
        for(int i=0; i<26; ++i){
            if(arr[i]!=1) {
                cout << (char)('a'+i) << endl;
                break;
            }
        }
    }else{
        queue<char> q;
        q.push(s[s.size()-1]);
        int i = s.size()-1;
        while(s[i-1]>s[i]){
            i--;
            q.push(s[i]);
        }
        i--;
        while(!q.empty()){
            char r = q.front(); q.pop();
            if(r > s[i]){
                cout << s.substr(0, i) << r << endl;
                break;
            }
        }
        
    }
	return 0;
}


Measured memory_bytes: 5120
from collections import Counter
N = int(input())
*A, = map(int, input().split())
Q = int(input())
s = sum(A)
c = Counter(A)

for _ in range(Q):
    B, C = map(int, input().split())
    s -= B*c[B]
    s += C*c[B]
    c[C] += c[B]
    c[B] = 0
    print(s)

Measured memory_bytes: 24172
fun main(args: Array<String>) {
    val di = listOf(-1, -1, 0, 1, 1, 1, 0, -1)
    val dj = listOf(0, 1, 1, 1, 0, -1, -1, -1)

    val (h, w) = readLine()!!.split(' ').map { it.toInt() }
    val grid = (0 until h).map { readLine()!! }

    val ans = (0 until h).map { grid[it].toCharArray() }

    for (i in 0 until h) {
        for (j in 0 until w) {
            if (grid[i][j] == '#') continue

            var cnt = 0
            for (k in 0 until 8) {
                val ni = i + di[k]
                val nj = j + dj[k]

                if (ni !in 0 until h) continue
                if (nj !in 0 until w) continue

                if (grid[ni][nj] == '#') cnt++
            }
            ans[i][j] = cnt.toString()[0]
        }
    }

    ans.forEach { println(it.joinToString("")) }
}


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

int main()
{

    int h, w;

    cin >> h >> w;

    if(h*w==2) cout << 3 <<endl;
    if(h*w==3) cout << 2 <<endl;
    if(h*w==6) cout << 1 <<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		int[] Days=new int[N+1];
		Arrays.fill(Days,-1);
		int[][][] flag=new int[N+1][4][2];
		for(int i=0;i<N+1;i++){
			for(int j=0;j<4;j++){
				for(int k=0;k<2;k++){
					flag[i][j][k]=0;
				}
			}
		}
		for(int i=0;i<K;i++){
			Days[sc.nextInt()]=sc.nextInt();
		}
		int sum=0;
		//
		if(Days[1]==-1){
			flag[1][1][0]=1;
			flag[1][2][0]=1;
			flag[1][3][0]=1;
		}
		else{
			flag[1][Days[1]][0]=1;
		}
		//
		for(int i=2;i<=N;i++){
			if(Days[i]==-1){
				for(int j=1;j<=3;j++){
					for(int k=1;k<=3;k++){
						if(j!=k){
							flag[i][j][0]+=flag[i-1][k][0]%10000;
							flag[i][j][0]+=flag[i-1][k][1]%10000;
						}
						else{
							flag[i][j][1]+=flag[i-1][k][0]%10000;
						}
					}
				}
			}
			else{
				for(int k=1;k<=3;k++){
					if(Days[i]!=k){
						flag[i][Days[i]][0]+=flag[i-1][k][0]%10000;
						flag[i][Days[i]][0]+=flag[i-1][k][1]%10000;
					}
				}
				flag[i][Days[i]][1]+=flag[i-1][Days[i]][0]%10000;
			}
		}
		//
		for(int i=1;i<=3;i++){
			for(int j=0;j<2;j++){
				sum+=flag[N][i][j];
			}
		}
		//
		System.out.println(sum%10000);
	}
}

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

int main() {
  int h,w;

  scanf("%d %d",&h,&w);
  while( h!=0 || w!=0) {
      for(int i=0;i<h;i++)
      {
          for(int j=0;j<w;j++)
          {
              if( (i+j) % 2 == 0)
                  cout << "#";
              else
                  cout << ".";
          }
          cout << endl;
      }
      cout << endl;
      scanf("%d %d",&h,&w);
  }

  return 0;
}

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

int main(){
  int64_t A;
  int64_t B;
  int64_t K;
  cin >> A >> B >> K;
  
  if(A >= K){
    A = A-K;
  }
  
  else if(A + B >= K){
    B = A+B-K;
    A = 0;
  }
  
  else {
    A = 0;
    B = 0;
  }
  
  cout << A << " " << B << endl;
}

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


int main() {

    int N;
    cin >> N;
  
    vector<int> A(N);
    bool flag=false;
  
	for(int i=0;i<N;i++){
      cin >> A.at(i);
    }
    
    for(int i=0;i<N;i++){
      if(A.at(i)%2==0){
      	if(A.at(i)%3==0){
       	  flag=true;
     	}else if(A.at(i)%5==0){
       	  flag=true;
        }else{
          flag=false;
          break;
        }
      }else
        flag=true;
    }
  
   if(flag)
      cout << "APPROVED" << endl;
    else
      cout << "DENIED" << endl;
  
  

    return 0;    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7
#define LINF 1e18+10  
using ll = long long; 

using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
using Ps=pair<int,string>;

using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}

//const ll mod=998244353;
const ll mod=1e9+7;
const ll MAX=300000;

//////////////////////////////////////


int main(){
    int a,b;
    cin>>a>>b;
    int d;
    cin>>d;
    int ans=0;
   arep(i,a,b+1){
       if(i%d==0)ans++;
   }
   cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
s = input()

def judge(s):
    n = len(s)
    for i in range(n//2):
        if s[i] == s[n-1-i]:
            continue
        else: return 0
    return 1

temp1 = s[:len(s)//2]
temp2 = s[len(s)//2+1:]

if judge(s) and judge(temp1) and judge(temp2):
    print("Yes")
else:
    print("No")

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

struct P
{
    int A;
    vector<int> x;
    vector<int> y;
};

vector<vector<int>> bit_comb(int n)
{
    vector<vector<int>> ret;
    for (int bit = 0; bit < (1 << n); ++bit)
    {
        vector<int> S;
        for (int i = 0; i < n; ++i)
        {
            if (bit & (1 << i))
            {
                S.push_back(i);
            }
        }
        ret.push_back(S);
    }
    return ret;
}

int main()
{
    int N;
    cin >> N;
    vector<P> list;
    rep(i, N)
    {
        P p;
        int A;
        cin >> A;
        vector<int> x(A), y(A);
        rep(i, A) cin >> x[i] >> y[i];
        p.A = A;
        p.x = x;
        p.y = y;
        list.push_back(p);
    }

    vector<vector<int>> comb = bit_comb(N);
    int maxi = 0;
    //組み合わせの個数回(2^n)繰り返す
    //debug : i = 2
    rep(i, comb.size())
    {
        // cout << "aaa" << endl;
        int flag = 1;
        vector<int> TF(N, 0);
        for (int m : comb[i])
        {
            TF[m] = 1;
        }
        //組み合わせ内のbitが立っている個数回繰り返す
        rep(j, comb[i].size())
        {
            // cout << "bbb" << endl;
            auto V = list[comb[i][j]];
            // cout << "ccc" << endl;
            //一人の発言回数回繰り返す
            rep(l, V.A)
            {
                // cout << "i:" << i << " j:" << j << " l:" << l << endl;
                if (V.y[l] != TF[V.x[l] - 1])
                {
                    flag = 0;
                    // cout << "break" << endl;
                    break;
                }
            }
        }
        if (flag)
            maxi = max(maxi, int(comb[i].size()));
    }
    cout << maxi << endl;
}


Measured memory_bytes: 2488
// abc078_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, M;
    cin >> N >> M;

    int p = (int)pow(2, M);
    int ans = p * (1900 * M + 100 * (N-M));

    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;

vector<int> vec;
int hai[212345];
int main(){
  int n;
  cin>>n;
  rep(i,n){
    int a;
    cin>>a;
    vec.push_back(a);
    hai[i]=a;
  }
  sort(all(vec));
  reverse(all(vec));

  int xa=vec[n/2-1];
  int xb=vec[n/2];



  rep(i,n){
    if(hai[i]>=xa){
      cout<<xb<<endl;
    }else{
      cout<<xa<<endl;
    }
  }


}


Measured memory_bytes: 3828
// package whatever; // don't place package name!


import java.io.*;
import java.util.*;

class Main {
    
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A[] = new int[N];
        int i = 0;
        while(sc.hasNext()){
          A[i] = sc.nextInt();
          i++;
        }
        
          
        List<Integer> cardsAlice = new ArrayList<Integer>();
        List<Integer> cardsBob = new ArrayList<Integer>();
        
        for(int j = 0; j < N; j++){
          
          int[] cardInfo = getMaxCardInfo(A);
          
          if(j % 2 == 0){
            cardsAlice.add(cardInfo[0]);           
          } else if (j % 2 == 1){
            cardsBob.add(cardInfo[0]);           
          }
          A[cardInfo[1]] = 0;
        }
      
        int sumAlice = getSum(cardsAlice);
        int sumBob = getSum(cardsBob);
        
        System.out.println(sumAlice-sumBob);

    }

    private static int[] getMaxCardInfo(int[] tgtArray){
      
      int max = 0;
      int max_idx = 0;
      int[] maxPoint = new int[2];
      for (int i = 0; i < tgtArray.length; i++) {
        int v = tgtArray[i];
          if (v > max) {
              max = v;
              max_idx = i; 
          }
          
      }
      
      maxPoint[0] = max;
      maxPoint[1] = max_idx;
      
      return maxPoint;
      
    }

    private static int getSum(List<Integer> tgtArrayList){
      
      Integer sum = new Integer(0);
      for (int num :tgtArrayList){
        sum += num;
      }
      return sum.intValue();
      
    }
  
}


Measured memory_bytes: 22996
in1 = list(map(int,input().split()))
x = in1[2]-in1[0]
y = in1[3]-in1[1]
r = ""
for i in range(y):
  r+= "U"
for i in range(x):
  r+= "R"
for i in range(y):
  r+= "D"
for i in range(x):
  r+= "L"
r+= "L"
for i in range(y+1):
  r+= "U"
for i in range(x+1):
  r+= "R"
r+="D"
r+="R"
for i in range(y+1):
  r+= "D"
for i in range(x+1):
  r+= "L"
r+="U"
print(r)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i, n, t, a, b;
    scanf("%d %d", &n, &t);
    vector <int> v;
    for(i = 0; i < n; i++)
    {
        scanf("%d %d", &a, &b);
        if(b <= t)
            v.push_back(a);
    }
    if(!v.size())
    {
        printf("TLE");
        return 0;
    }
    sort(v.begin(), v.end());
    printf("%d", v[0]);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

double max(double a, double b)
{
    if (a > b){
        return (a);
    }
    return (b);
}

int main(void)
{
    int i, j, k;
    int n, m;
    double gr[100][100];
    double dp[100][100];
    double ans;
    int upd;
    
    while (1){
        scanf("%d%d", &n, &m);
        
        if (n + m == 0){
            break;
        }
        
        for (i = 0; i < n; i++){
            for (j = 0; j < n; j++){
                scanf("%lf", &gr[i][j]);
            }
        }
        
        memset(dp, 0, sizeof(dp));
        for (i = 0; i < n; i++){
            dp[0][i] = 1.00;
        }
        
        ans = 0.00;
        for (i = 1; i < m; i++){
            for (j = 0; j < n; j++){
                upd = 0;
                for (k = 0; k < n; k++){
                    if (upd == 0){
                        dp[i][j] = dp[i - 1][k] * gr[k][j];
                        upd = 1;
                    }
                    else {
                        dp[i][j] = max(dp[i][j], dp[i - 1][k] * gr[k][j]);
                    }
                }
            }
        }
        
        for (i = 0; i < n; i++){
            ans = max(ans, dp[m - 1][i]);
        }
        
        printf("%.2f\n", ans);
        
    }
    
    return (0);
}

Measured memory_bytes: 0
/**
  *  @Author: Pranta Sarker
  *
  */

#include<bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio(0)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define pfn(x , k) printf(k , x)
#define nl puts("")
#define psb push_back
#define mset(c,v) memset(c , v , sizeof c)
#define loop0(n) for(int i=0; i<n; i++)
#define loop1(n) for(int i=1; i<=n; i++)
#define mpair(x , y) make_pair(x , y)
#define all(x) x.begin(), x.end()
#define pi acos(-1.0)
#define psb push_back
#define clr clear()

typedef unsigned long long ull;
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef vector<string>vs;
typedef map<int, int>mpii;
typedef map<string, int>mpsi;
typedef map<char, int>mpci;
typedef map<LL, LL>mpll;

const int mod = 1000007;
const int high = 1002;

int main()
{
	fast;
    string s;
    cin >> s;
    int len = s.length() , i;
    cout << s[0];
    int cnt=0;
    for(i=1; i<len-1; i++) cnt++;
    cout << cnt << s[len-1] << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,k,j;
    long long a[100005];
    long long dp[100005];
    cin>>n>>k;
    for(i=0;i<n+2;++i)
     dp[i]=10000000000000;
    for(i=1;i<=n;++i)
      cin>>a[i];
    dp[1]=0;
   for(i=1;i<=n;++i)
   {
   	  for(j=1;j<=k;++j)
   	  {
   	  	 if((i+j)<=n)
   	  	 {
   	  	 	dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
		 }
	  }
   }
// for(i=1;i<=n;++i)
// cout<<dp[i]<<" ";
cout<<dp[n];
}

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

int main(){
    int n, q; cin >> n >> q;
    vector<stack<int>> a(n);
    rep(i , q){
        int s , t , value;
        cin >> s;
        if( s == 0 ){
            cin >> t >> value;
            a[t].push(value);
        } else if ( s == 1 ){
            cin >> t;
            if(a[t].empty()) continue;
            cout << a[t].top() << endl;
        } else {
            cin >> t;
            if(a[t].empty()) continue;
            a[t].pop();
        }
    }
}


Measured memory_bytes: 4356
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%lld", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
int main(){
        ll h;
        while(~getI(h)){
                ll ans=0,mul=1;
                while(h){
                        ans+=mul;
                        h/=2;
                        mul*=2;
                }
                printf("%lld\n",ans);
        }
}

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

int main(){
  int n, d;
  cin >> n >> d;
  
  int one = 2*d+1;
  
  if (n%one == 0)
    cout << n/one << endl;
  else
    cout << n/one + 1 << endl;
}

Measured memory_bytes: 3592
/**
*    author:  Dooloper
*    created: 25.07.2020 20:56:00
**/

#include <bits/stdc++.h>

#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int,int>;
using ll = long long;

const double PI = acos(-1);
const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long 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 {
        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;
        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;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  for(int i = 0; i < k; i++){
    if(a >= b){
      b *= 2;
      continue;
    }
    if(b >= c){
      c *= 2;
      continue;
    }
  }
  if(a < b && b < c){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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

void dfs(int node, vector<int> &color, vector<vector<int> > &g, int c){
    color[node] = c;
    int nextcolor = (c == 1) ? 2 : 1;
    for(int i = 0; i < g[node].size(); i++){

        int nextnode = g[node][i];
       //未訪問なら
       if(color[nextnode] == 0){
           dfs(nextnode, color, g, nextcolor);
       }else if(color[nextnode] == c){
           color[node] = 3;
           return;
       }
    }
    return;
    
}

int main(){

    while(1){
        int n, m; cin >> n >> m;
        if(!n)break;
    
        vector<vector<int> > g(n);
        for(int i = 0; i < m; i++){
            int a, b; cin >> a >> b; a--; b--;
            g[a].push_back(b);
            g[b].push_back(a);
        }
        vector<int> color(n, 0);
        dfs(0, color, g, 1);
        int cnt = 0;
        for(int i = 0; i < n; i++){
            if(color[i] == 1) cnt++;
            else if(color[i] == 3){
                cnt = -10000000;
            }
        }

        if(cnt <= 0) cout << 0 << endl;
        else{
            int cnt2 = n - cnt;
            vector<int> ans;
            if(cnt % 2 == 0) ans.push_back(cnt / 2);
            if(cnt2 % 2 == 0) ans.push_back(cnt2 / 2);
            
            sort(ans.begin(), ans.end());
            ans.erase(unique(ans.begin(), ans.end()), ans.end());
            

            cout << ans.size() << endl;            
            for(int i = 0; i < ans.size(); i++){
                cout << ans[i] << endl;
            }
                        
        }
    }
    return 0;
}


Measured memory_bytes: 3204
n,k=map(int, input().split())
if(k==0):
  print(n*n)
  quit()
ans=(n-k+1)*(n-k)//2
for i in range(k+1,n+1):
  ans+=(n//i-1)*(i-k)+max(0,n%i-k+1)
print(ans)


Measured memory_bytes: 3064
/*=====Bismillahir Rahmanir Rahim=====*\
!                                      !
!(^,^)Ron is back(-o,o-)               !
!         MD. TAREK MAHMUD RONY        !
!            CSE 12th Batch            !
!           Comilla University         !
\*====================================*/
//Think positive, be positive and never use negative words
#include<bits/stdc++.h>
#define ll               long long int
#define test             ll t;cin>>t;while(t--)
#define nl               endl
#define mp(a,b)          make_pair(a,b)
#define F                first
#define S                second
#define vc               vector<int>
#define vcl              vector<ll>
#define pb               push_back
#define vc_sum(a)        accumulate(a.begin(),a.end(),0)
#define vc_max(a)        *max_element(a.begin(),a.end())
#define vc_min(a)        *min_element(a.begin(),a.end())
#define vc_sort(a)       sort(a.begin(),a.end())
#define vc_gsort(a)      sort(a.begin(),a.end(),greater<int>())
#define vc_uni(a)        a.erase(unique(a.begin(),a.end()),a.end())
#define ulta(a)          reverse(a.begin(),a.end())
#define RON              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define yes              cout<<"YES"<<nl
#define no               cout<<"NO"<<nl
#define M                1000000007
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b
using namespace std;
int main()
{
    RON;
    ll i, n=5, a[n];
    for(i=0; i<n; i++) cin>>a[i];
    ll pos=0;
    for(i=0; i<n; i++)
    {
        if(a[i]==0) pos=i+1;
    }
    cout<<pos<<nl;
    return 0;
}



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

int main(){
        int n, c, w, v;
        cin >> n >> c;
        vector<pair <int, int>> p(n);
        for(int i = 0; i < n; i++){
                cin >> v >> w;
                p[i] = make_pair(v, w);
        }
        int a[n + 1][c + 1] = {};
        for(int j = 0; j <= c; j++){
                for(int i = 0; i <= n; i++){
                        if(i == 0 || j == 0) a[i][j] = 0;
                        else if(j - p[i - 1].second < 0) a[i][j] = a[i - 1][j];
                        else{
                                a[i][j] = max({a[i - 1][j], a[i - 1][j - p[i - 1].second] + p[i - 1].first, a[i][j - p[i - 1].second] + p[i - 1].first});
                                //cout << a[i][j] << endl;
                        }
                }
        }
        cout << a[n][c] << endl;
        return 0;
}



Measured memory_bytes: 7024
(defn create-data [s]
  (map #(Long/parseLong %) (.split s " ")))

(defn sum [xs]
  (reduce + xs))

(defn zip [xs ys]
  (map vector xs ys))

(defn candies3 [n ys1 ys2]
  (->> (zip
        (reductions + ys1)
        (reductions - (sum ys2) ys2))
       (map sum)
       (apply max)))

(println (candies3 (Long/parseLong (read-line)) (create-data (read-line)) (create-data (read-line))))


Measured memory_bytes: 69820
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m,c;
  cin >> n >> m >> c;
  ll b[m];
  rep(i,m) R b[i];
  ll ans=0;
  while(n--) {
    ll a[m],x=0;
    rep(i,m) {
      R a[i];
      x+=a[i]*b[i];
    }
    x+=c;
    if(x>0) ans++;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256