akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<int,int>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
   lli A,B,C,L,R,N,M,K,X=0,Y=0,W,H=INF,sum=0,num=0,flag=0;string S,T,O;
   cin >> N >> K;
   Vec(P,lli,N,0);rep(i,0,N)cin >> P[i];
   rep(i,0,N)if(P[i]%2)flag=1;
  A=pow(2,N);
  if(!flag){
      if(!K)Out(A);
      else Out(0);
   }
   else Out(A/2);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);

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

  bool easy = true;
  rep(i,s.size()) {
    if (i%2 == 0) {
      // odd
      if (s[i] == 'L') {
        easy = false;
        break;
      }
    }
    else {
      // even
      if (s[i] == 'R') {
        easy = false;
        break;
      }
    }
  }
  
  if (easy) yn;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s;
    cin>>s;
    int cnt=0,i,cnt1=0;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]=='A')
        {
            cnt++;
        }
        else
        {
            cnt1++;
        }
    }
    if(cnt>2 || cnt1>2)
    {
         cout<<"No";
    }
    else
    {
        cout<<"Yes";
    }

}


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

typedef long long ll;

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,l,n) for(int i=(l);i<(n);i++)

template<class T>
using vt = vector<T>;
template<class T>
using vvt = vector<vector<T>>;

int main(){
    int N,min=1000000000;
    cin >> N;
    vector<int> vill(N);
    for(int i=0;i<N;i++) cin >> vill[i];
    for(int x=1;x<=100;x++){
        int sum=0;
        for(int i=0;i<N;i++){
            sum += (vill[i]-x)*(vill[i]-x);
        }
        if(sum < min) min = sum;    
    }
    cout << min << endl;
    return  0;
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main()
{
    int n, m;
    int flag = 0; // †‡Xx_悪魔的行為_xX‡†
    char a[55][55];
    char b[55][55];
    char dummy;

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

    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }



    for (int i = 0; i < n - m + 1 && !flag; i++) {
        for (int j = 0; j < n - m + 1 && !flag; j++) {

            int k, l;

            k = 0;
            l = m;
            while (l == m && k < m) {
                l = 0;
                while (a[i + k][j + l] == b[k][l] && l < m) {
                    l++;
                }
                k++;
            }

            if (k == m && l == m) {
                flag = 1;
            }
            
        }
    }

    cout << (flag ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ken=[1 for i in range(n+1)]
inf=[[] for i in range(m)]
def f(x):
    m=0
    while x>0:
        m+=1
        x=x//10
    return m

for i in range(m):
    p,y=map(int,input().split())
    inf[i].append(i+1)
    inf[i].append(p)
    inf[i].append(y)
inf=sorted(inf, key=lambda x: x[2])

for i in range(m):
    inf[i].append(ken[inf[i][1]])
    ken[inf[i][1]]+=1
inf=sorted(inf)


for i in range(m):
    ans=""
    p=inf[i][1]
    y=inf[i][3]
    for j in range(6-f(p)):
        ans+="0"
    ans=ans+str(p)
    
    for j in range(6-f(y)):
        ans=ans+"0"
    ans=ans+str(y)
    print(ans)
    
    
    
    
    



    
        
        
        
          


Measured memory_bytes: 33684
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
#include <chrono>
#include <fstream>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


int dp[17][2];

int main() {
    string s;
    cin >> s;
    int len = s.size();
    dp[0][1] = -1000;
    rep(i, len) {
        dp[i + 1][0] = dp[i][0] + (s[i] - '0');
        if (s[i] != '0') dp[i + 1][1] = dp[i][0] + (s[i] - '0' - 1);
        chmax(dp[i + 1][1], dp[i][1] + 9);
    }
    cout << max(dp[len][0], dp[len][1]) << endl;
}

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

int main(){

  int n;

  scanf("%d", &n);

  n = n % 10;

  if(n == 3){
    printf("bon\n");
  }

  else if(n == 0 || n == 1 || n == 6 || n == 8){
    printf("pon\n");
  }

  else{
    printf("hon\n");
  }

  return 0;
}


Measured memory_bytes: 3760
[n,w] = [int(i) for i in input().split()]
wv = []
for i in range(n):
    wv.append([int(i) for i in input().split()])
num = 100001
#num = 30
dp = [[10 ** 13]* num for i in range(n)]

"""
dp[i][j] = 重さ
i : i品目まで見たときの値
j : 価値の総和がjになる
"""
for i in range(n):
    dp[i][0] = 0
for i in range(n):
    if i != 0:
        for j in range(num):
            if j >= wv[i][1]:
                dp[i][j] = min(dp[i][j],dp[i-1][j])
                dp[i][j] = min(dp[i][j],dp[i-1][j-wv[i][1]]+wv[i][0])
            else:
                dp[i][j] = min(dp[i][j],dp[i-1][j])
    else:
        dp[i][wv[i][1]] = wv[i][0]
ans = 0
for i in range(num):
    if dp[n-1][i] <= w:
        ans = i
print(ans)
#print(dp)
"""
6 15
______
6 5
5 6
6 4
6 6
3 5
7 2

 0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,

[0, 100, 100, 100, 100,   6, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],
[0, 100, 100, 100, 100,   6,   5, 100, 100, 100, 100,  11, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],
[0, 100, 100, 100,   6, 100, 100, 100, 100,  12,  11, 100, 100, 100, 100,  17, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],
[0, 100, 100, 100,   6, 100,   6, 100, 100, 100,  12, 100, 100, 100, 100,  18,  17, 100, 100, 100, 100,  23, 100, 100, 100, 100, 100, 100, 100, 100],
[0, 100, 100, 100,   6,   3, 100, 100, 100,   9, 100,   9, 100, 100, 100,  15, 100, 100, 100, 100,  21,  20, 100, 100, 100, 100,  26, 100, 100, 100],
[0, 100,   7, 100, 100, 100,  13,  10, 100, 100, 100,  16, 100,  16, 100, 100, 100,  22, 100, 100, 100, 100,  28,  27, 100, 100, 100, 100,  33, 100]
]
"""


Measured memory_bytes: 120940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		String[] s = new String[n];
		boolean hanbetsu = false;
		for(int i=0;i<n;i++) {
			s[i]=sc.next();
			if(s[i].equals("Y")) {
				hanbetsu = true;
				break;
			}
		}
		if(hanbetsu)
			System.out.print("Four");
			else
			System.out.print("Three");


	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

int main()
{   
 int N, l, r;
 cin >> N;
 int cnt = 0;
 for(int i = 0; i < N; i++)
 {
     cin >> l >> r;
     cnt += r - l + 1;
 }
    cout << cnt << 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[] h = new int[n];
        int[] tmp = new int[k];

        for (int i = 0; sc.hasNext(); i++) {
            h[i] = sc.nextInt();
        }

        Arrays.sort(h);

        // 値を１つずつインクリメントさせて、k個先の値との差分をとる
        int minValue = Integer.MAX_VALUE;
        for (int i = 0; i <= h.length - k; i++) {

            if (h[i + (k-1)] - h[i] < minValue) {
                minValue = h[i + (k-1)] - h[i];
            }
        }

        System.out.println(minValue);
    }
}

Measured memory_bytes: 59264
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,k;
int main(){
	cin>>n>>m>>k;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			int sum=i*m+j*n-2*i*j;
		//	cout<<i<<" "<<j<<" "<<sum<<endl;
			if(sum==k){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
}
	

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

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

  vector<int> d(K, K);
  deque<pair<int,int>> q;
  q.emplace_back(1, 1);
  while(!q.empty()) {
    auto n=q.front().first;
    auto s=q.front().second;
    q.pop_front();
    if(d[n] <= s) continue;
    d[n] = s;
    q.emplace_front((n*10)%K, s);
    q.emplace_back((n+1)%K, s+1);
  }
  cout << d[0] << endl;
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
#include<string>
#include<numeric>
#include<set>
using namespace std;

int main(){
    int n, d;
    cin >> n >> d;

    int ans = n / (2*d + 1);
    if(n % (2*d + 1) > 0) ans++;

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

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

#define MOD (long long)(1e9 + 7)
#define MAX 5000000

template <int mod>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const {
    return ModInt(*this) += p;
  }
  ModInt operator-(const ModInt &p) const {
    return ModInt(*this) -= p;
  }
  ModInt operator*(const ModInt &p) const {
    return ModInt(*this) *= p;
  }
  ModInt operator/(const ModInt &p) const {
    return ModInt(*this) /= p;
  }
  bool operator==(const ModInt &p) const {
    return x == p.x;
  }
  bool operator!=(const ModInt &p) const {
    return x != p.x;
  }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t n) const {
    ModInt ans(1), mul(x);
    while(n) {
      if(n & 1) ans *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ans;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int get_mod() { return mod; }
};

struct Combination {
  vector<ModInt<MOD>> _fact, _rfact, _inv;
  Combination(long long nsize = MAX)
      : _fact(nsize + 1), _rfact(nsize + 1),
        _inv(nsize + 1) {
    _fact[0] = _rfact[nsize] = _inv[0] = 1;
    for(int i = 1; i <= nsize; i++)
      _fact[i] = _fact[i - 1] * i;
    _rfact[nsize] /= _fact[nsize];
    for(int i = nsize - 1; i >= 0; i--)
      _rfact[i] = _rfact[i + 1] * (i + 1);
    for(int i = 1; i <= nsize; i++)
      _inv[i] = _rfact[i] * _fact[i - 1];
  }
  inline ModInt<MOD> fact(int k) const { return _fact[k]; }

  inline ModInt<MOD> rfact(int k) const {
    return _rfact[k];
  }

  inline ModInt<MOD> inv(int k) const { return _inv[k]; }

  ModInt<MOD> P(int n, int r) const {
    if(r < 0 || n < r) return 0;
    return fact(n) * rfact(n - r);
  }

  ModInt<MOD> C(int p, int q) const {
    if(q < 0 || p < q) return 0;
    return fact(p) * rfact(q) * rfact(p - q);
  }
  ModInt<MOD> H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return r == 0 ? 1 : C(n + r - 1, r);
  }
};

long long r1, r2, c1, c2;
Combination com;

ModInt<MOD> solve();

int main() {
  cin >> r1 >> c1 >> r2 >> c2;
  cout << solve() << endl;
  return 0;
}

ModInt<MOD> solve() {
  ModInt<MOD> res = 0;
  for(int i = r1; i <= r2; ++i)
    res += com.C(c2 + i + 1, i + 1) -
           com.C(c1 - 1 + i + 1, i + 1);
  return res;
}

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

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

    vector<int> data(n);
    for (int i = 0; i < n; i++){
        cin >> data.at(i);
    }

    int64_t count = 0;
    for (int i = 0; i < n; i++){
        while(data.at(i) % 2 == 0){
            count++;
            data.at(i) /= 2;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
# comb_mod(n, c, r, mod, fac, den) ≡ nCr
def prepare(n, mod):
    # fac[i] ≡ i!
    fac = [1]
    for i in range(1, n+1):
        fac.append((fac[-1] * i) % mod)

    # rec ≡ 1 / n!
    rec = pow(fac[-1], mod-2, mod)

    # den[i] ≡ 1 / i!
    den = [1 for _ in range(n+1)]
    den[n] = rec
    for i in range(n-1, 0, -1):
        rec = (rec * (i+1)) % mod
        den[i] = rec
    
    return fac, den

def comb_mod(n, r, mod, fac, den):
    return (fac[n] * den[r] * den[n - r]) % mod

n, k = map(int, input().split())
mod = 10**9 + 7
fac, den = prepare(2*n-1, mod)

if k >= n-1:
    print(comb_mod(2*n-1, n, mod, fac, den))
else:
    ans = 0
    for i in range(k+1):
        ans += comb_mod(n-1, i, mod, fac, den) * comb_mod(n, i, mod, fac, den)
        ans %= mod
    print(ans)

Measured memory_bytes: 72172
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int rrr[205],n;
    cin>>n;
    n*=2;
    for(int i=0;i<n;i++)cin>>rrr[i];

    sort(rrr,rrr+n);

    int sum=0;
    for(int i=0;i<n;i+=2)
    {
        sum+=min(rrr[i],rrr[i+1]);
    }
    cout<<sum;
}


Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H = list(map(int,input().split()))
ans= 0
tmp = 100000
for i in range(N):
    s = T - H[i]*0.006
    if tmp > abs(A - s):
        tmp = abs(A - s )
        ans = i + 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int mo = 1e9 + 7;

ll ksm(ll x, ll y) {
	ll s = 1;
	for(; y; y /= 2, x = x * x % mo)
		if(y & 1) s = s * x % mo;
	return s;
}

const int N = 2005;

int n, m; ll k;
struct P {
	int x, y; ll z;
} a[N];

int cmpa(P a, P b) {
	return a.z < b.z;
}

int f[N];
int F(int x) {
	return f[x] == x ? x : (f[x] = F(f[x]));
}

int fi[N], nt[N], to[N], v[N], tot = 1;

void link(int x, int y, ll z) {
	nt[++ tot] = fi[x], to[tot] = y, v[tot] = z, fi[x] = tot;
}

int d[N], d0, fr[N], bz[N];
ll dis(ll x, ll y) {
	fo(i, 1, n) bz[i] = 0;
	d[d0 = 1] = x; fr[x] = 0; bz[x] = 1;
	for(int i = 1; i <= d0; i ++) {
		int x = d[i];
		for(int j = fi[x]; j; j = nt[j]) {
			int y = to[j];
			if(bz[y]) continue;
			fr[y] = j;
			d[++ d0] = y;
			bz[y] = 1;
		}
	}
	ll mx = 0;
	for(int t = y; t != x; t = to[fr[t] ^ 1])
		mx = max(mx, (ll) v[fr[t]]);
	return mx;
}

int us[N];

int main() {
	scanf("%d %d", &n, &m);
	scanf("%lld", &k);
	fo(i, 1, m) {
		scanf("%d %d %lld", &a[i].x, &a[i].y, &a[i].z);
	}
	sort(a + 1, a + m + 1, cmpa);
	fo(i, 1, n) f[i] = i;
	int cnt = 0; ll sum = 0;
	fo(i, 1, m) {
		int x = F(a[i].x), y = F(a[i].y);
		if(x != y) {
			us[i] = 1;
			sum += a[i].z;
			cnt ++;
			f[x] = y;
			link(a[i].x, a[i].y, a[i].z);
			link(a[i].y, a[i].x, a[i].z);
		}
	}
	if(cnt < n - 1 || sum > k) {
		pp("0\n"); return 0;
	}
	if(sum == k) {
		ll ca = 0, cb = 0;
		fo(i, 1, m) if(a[i].z == dis(a[i].x, a[i].y)) 
			ca ++; else cb ++;
		ll ans = (ksm(2, ca) - 2 + mo) * ksm(2, cb) % mo;
		pp("%lld\n", ans);
		return 0;
	}
	ll ca = 0, cb = 0;
	fo(i, 1, m) {
		ll ds = sum - dis(a[i].x, a[i].y) + a[i].z;
		if(ds == k) ca ++;
		if(ds > k) cb ++;
	}
	pp("%lld\n", 2 * (ksm(2, ca) - 1) * ksm(2, cb) % mo);
}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXM 10000
#define MAXN 10

int n,m,ans;
bool st[MAXN+3][MAXM+3];

void Dfs(int i) {
	if(i>n) {
		int tot=0;
		for(int j=1;j<=m;j++) {
			int sum=0;
			for(int k=1;k<=n;k++)
				sum+=st[k][j];
			tot+=max(sum,n-sum);
		}
		ans=max(ans,tot);
		return ;
	}
	Dfs(i+1);
	for(int j=1;j<=m;j++)
		st[i][j]=!st[i][j];
	Dfs(i+1);
}
int main() {
	while(scanf("%d %d",&n,&m)&&n&&m) {
		ans=0;
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
				scanf("%d",&st[i][j]);
		Dfs(1); printf("%d\n",ans);
	}
	return 0;
}


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

/* #include<cstdio>*/
int main(){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (x - r < 0 || x + r > W || y - r < 0 || y + r > H){
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0; 
}



Measured memory_bytes: 3096
#include<cstring>
#include <limits.h>
#include<iostream>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b; cin>>a >> b;
	int m = a>b?a:b;
	string ans = "No";
	for (int i = a+b-m; i <= m; ++i)
	{
		/* code */
		if((a*b*i)% 2 != 0){
			ans =  "Yes";
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n ;
  cin >> n;
  vector<int> a(100005);
  for(int i= 0;i<100005;i++){
    a.at(i) = 0;
  }
  for(int i =0 ;i<n;i++){
    int b;
    cin >> b ;
    if(b != 0){
      a.at(b-1) +=1;
    }
    a.at(b) +=1;
    a.at(b+1) += 1;
  }
  int ans = 0;
  for(int i = 0 ; i<100005;i++){
    if( ans < a.at(i)){
      ans = a.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func main() {
	// read from stdin
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	n, err := strconv.Atoi(scanner.Text())
	checkErr(err)

	c := make([]*Card, n) // original
	c1 := make([]*Card, n)
	c2 := make([]*Card, n)

	scanner.Scan()
	for i, s := range strings.Split(scanner.Text(), " ") {
		c[i] = &Card{Source: s}
	}
	copy(c1, c)
	copy(c2, c)

	// bubble sort
	for i := 0; i < n; i++ {
		for j := n - 1; j > i; j-- {
			if c1[j].Value() < c1[j-1].Value() {
				tmp := c1[j]
				c1[j] = c1[j-1]
				c1[j-1] = tmp
			}
		}
	}
	printCards(c1)
	if isStable(c, c1) {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}

	// selection sort
	for i := 0; i < n; i++ {
		minj := i
		for j := i; j < n; j++ {
			if c2[j].Value() < c2[minj].Value() {
				minj = j
			}
		}
		minv := c2[minj]
		c2[minj] = c2[i]
		c2[i] = minv
	}
	printCards(c2)
	if isStable(c, c2) {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}
}

func isStable(in, out []*Card) bool {
	n := len(in)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			for a := 0; a < n; a++ {
				for b := a + 1; b < n; b++ {
					if in[i].Value() == in[j].Value() &&
						in[i].Source == out[b].Source &&
						in[j].Source == out[a].Source {
						return false
					}

				}
			}
		}
	}
	return true
}

func printCards(cards []*Card) {
	fmt.Println(
		strings.Trim(fmt.Sprint(cards), "[]"),
	)
}

type Card struct {
	Source string
}

func (c *Card) String() string {
	return c.Source
}

func (c *Card) Value() int {
	i, e := strconv.Atoi(string(c.Source[1]))
	checkErr(e)
	return i
}

func checkErr(e error) {
	if e != nil {
		log.Fatalln(e)
	}
}



Measured memory_bytes: 4636
/*
 © 2020-08-29 06:57:42 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;
const lli MOD = 1e9 + 7;
int main(){ _
  lli n; cin >> n;
  vector<lli> v(n);
  lli sum = 0;
  fore(i, 0, n){
    cin >> v[i];
    sum += v[i];
  }
  lli res = 0;
  fore(i, 0, n){
    sum -= v[i];
    res = (res + (sum % MOD * v[i] % MOD)) % MOD;
  }
  cout << res << ENDL;
  return 0;
}


Measured memory_bytes: 4784
object Main {
  def main(args: Array[String]): Unit = {
    val lines = io.Source.stdin.getLines().toSeq
    println(solve(lines))
  }

  def solve(lines: Seq[String]): String = {
    val Array(a, b, t) = lines.head.split(" ").map(_.toInt)
    var biscuits = 0
    for (i <- a until (t + 1) by a) {
      biscuits += b
    }
    biscuits.toString
  }
}


Measured memory_bytes: 25552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

int main(){
    int n;
    while(cin >> n && n){
        int mp[256] = {};
        char cc[110];
        rep(i, n){
            string s;
            cin >> s;
            cc[i] = s[0];
        }

        rep(i, n){
            char c = cc[i];
            ++mp[c];
            vector<char> v(27);
            iota(all(v), 'A');
            sort(all(v), [&](char a, char b){
                    return mp[a] > mp[b];
                });
            if(mp[v[0]] > mp[v[1]] + n-i-1){
                cout << v[0] << ' ' << i+1  << '\n';
                break;
            }
            if(i == n-1){
                cout << "TIE" << endl;
            }
        }
    }
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

typedef long long ll;
const ll INF = 1e17;




int main() {
	
	ll N, M;
	cin >> N >> M;

	ll A[200000];

	ll val;

	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}


	priority_queue<ll> q;

	for (int i = 1; i <= N; i++) {
		q.push(A[i]);

	}

	for (int i = 1; i <= M; i++) {
		val=q.top();
		q.pop();
		val = val / 2;
		q.push(val);

	}

	ll ans=0;

	for (int i = 1; i <= N; i++) {
		ans = ans + q.top();
		q.pop();
	}

	
	cout << ans;

	system("PAUSE");
}


Measured memory_bytes: 2168
n,x,y = map(int,input().split())
cnt_l = [0]*n
from collections import deque
def bfs(start):
    queue = deque()
    queue.append(start)
    isSearched = [-1]*(n+1)
    isSearched[start] = 0
    while(queue):
        i = queue.popleft()
        cnt = isSearched[i]
        if(i==x):
            nex_l = (i-1,y,i+1)
        elif(i==y):
            nex_l = (i-1,x,i+1)
        else:
            nex_l = (i-1,i+1)

        cnt += 1
        for j in nex_l:
            if(j < 1 or n < j):
                continue
            if(isSearched[j]!=-1):
                continue
            queue.append(j)
            isSearched[j] = cnt
            cnt_l[cnt] += 1
            
        
 
        
for i in range(1,n+1):
    bfs(i)
 
 
for i in range(1,n):
    print(cnt_l[i]//2)

Measured memory_bytes: 9596
use std::collections::HashMap;
use std::collections::hash_map::Entry::{Occupied, Vacant};

fn main() {
    let n = read::<usize>();
    let mut map: HashMap<String, usize> = HashMap::new();
    for _ in 0..n {
        let s = read::<String>();
        let mut v: Vec<char> = s.chars().into_iter().collect();
        v.sort();
        let s: String = v.into_iter().collect();

        match map.entry(s) {
            Occupied(mut e) => {
                let value = e.get_mut();
                *value += 1;
            }
            Vacant(e) => { e.insert(1); }
        }
    }

    let mut ret = 0;
    for (_, v) in map.iter() {
        ret += v * (v-1) / 2;
    }
    println!("{}", ret);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 15420
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

int main(){
    long long n, m, l, sum;
    cin >> n >> m >> l;
    vector<vector<long>> a;
    a = vector<vector<long>>(100,vector<long>(100));
    vector<vector<long>> b;
    b = vector<vector<long>>(100,vector<long>(100));

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> a[i][j];
        }
    }

    for(int i=0; i<m; i++){
        for(int j=0; j<l; j++){
            cin >> b[i][j];
        }
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<l; j++){
            sum = 0;
            for(int h=0; h<m; h++){
                sum += a[i][h]*b[h][j];
                if(h==m-1){
                    if(j==l-1){
                        cout << sum << endl;
                        break;
                    }
                    cout << sum << " ";
                }
            }
        }
    }


    return 0;
}



Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    string s;
    cin >> s;
    for(int i=0;i<N;i++){
        if(i+1==K){
            if(s[i]=='A'){
                s[i] = 'a';
            }else if(s[i]=='B'){
                s[i] = 'b';
            }else{
                s[i] = 'c';
            }
        }
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N; cin >> N;
	V<int> a(N); rep(i,N) cin >> a[i];
	sort(all(a));
	ll res = 0;
	rep(i,N) for(int j=i+1;j<N;j++){
		int k = lower_bound(all(a),a[i]+a[j]) - a.begin();
		res += max(k-j-1,0);
	}
	cout << res << endl;
}


Measured memory_bytes: 256
N,M = map(int, input().split())

# Mの約数を求める
yaku = [ M, 1 ]
i = 2
mm = M
while (i * i) <= M:
    if mm % i == 0:
        yaku.append(i)
        yaku.append(mm//i)
    i += 1
#print(yaku)

# Mの約数の大きい順に判定していく
yaku.sort( reverse=True )

for my in yaku:
    d = M // my
    if d >= N:
        print(my)
        break



Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)

char m[20][20] = {};
ll D[20][20] = {};
bool v[20][20] = {};
ll x[4] = {1,0,0,-1};
ll y[4] = {0,1,-1,0};
ll h, w;

ll maze(ll sy, ll sx, ll gy, ll gx) {
	queue<pair<ll, ll>> q;
	q.push(make_pair( sy,sx ));
	D[sy][sx] = 0;
	v[sy][sx] = true;


	while (!q.empty()) {

		pair<ll, ll> p = q.front(); q.pop();
		
		ll Y = p.first;
		ll X = p.second;

		if (Y == gy && X == gx) {
			if (D[gy][gx] == 1e10) {
				cout << endl;
			}
			return D[gy][gx];
		}

		rep(i, 0, 4) {
			ll ny = Y + y[i];
			ll nx = X + x[i];
			if (ny >= 0 && ny < h && nx >= 0 && nx < w && !v[ny][nx] && m[ny][nx] == '.') {
				D[ny][nx] = min(D[ny][nx], D[Y][X] + 1);
				v[ny][nx] = true;
				q.push(make_pair(ny,nx));
			}
		}
	}

	return D[gy][gx];
}

int main() {
	cin >> h >> w;
	rep(i, 0, h) {
		rep(j, 0, w) {
			cin >> m[i][j];
		}
	}

	ll maxV = 0;
	rep(sh, 0, h) {
		rep(sw, 0, w) {
			rep(gh, 0, h) {
				rep(gw, 0, w) {
					if (m[sh][sw] == '#' || m[gh][gw] == '#')continue;
					rep(i, 0, h)rep(j, 0, w) {
						v[i][j] = false;
						D[i][j] = 1e10;
					}
					if (sh == 2 && sw == 0 && gh == 0 && gw == 4) {
						cout << endl;
					}
					if (sh == gh && sw == gw) {
						maxV = max(maxV,(ll)0);
					}
					else {
						maxV = max(maxV, maze(sh, sw, gh, gw));
					}
					if (maxV == 1e10) {
						cout << endl;
					}
				}
			}
		}
	}

	cout << maxV << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{

    int n;

    void solve(){
	Scanner sc = new Scanner(System.in);

	while(true){
	    int n = sc.nextInt();
	    if(n==0) break;

	    PriorityQueue<int[]> 
		q = new PriorityQueue<int[]>(n,new Comparator<int[]>(){
			public int compare(int[] a, int[] b){
			    return a[1] - b[1];
			}
		    });
	    for(int i=0; i<n; i++){
		q.add(new int[]{sc.nextInt(),sc.nextInt()});
	    }

	    int sum = 0;
	    boolean can = true;
	    while(q.size()>0){
		int[] dd = q.poll();
		sum += dd[0];
		if(sum>dd[1]){
		    can = false;
		    break;
		}
	    }
	    
	    if(can) System.out.println("Yes");
	    else System.out.println("No");
	}
    }

    public static void main(String[] args){
	new Main().solve();
    }
}

Measured memory_bytes: 12000
h, w = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(h)]

ans = []
for i in range(h):
    for j in range(w):
        if A[i][j]%2 == 1:
            if j != w-1:
                A[i][j+1] += 1
                ans.append((i+1, j+1, i+1, j+2))
            else:
                if i != h-1:
                    A[i+1][j] += 1
                    ans.append((i+1, j+1, i+2, j+1))
print(len(ans))
for i in range(len(ans)):
    print(*ans[i])


Measured memory_bytes: 76252
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int mod=998244353;
const int N=1e5+10;
int cnt[N],n;
int main() {
	rd(n);
	int flg=1;
	for(int i=1,x;i<=n;++i) {
		rd(x),cnt[x]++;
		if(i==1&&x!=0) flg=0;
		if(i!=1&&x==0) flg=0;
	}
	int ans=flg;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=cnt[i];++j)
			ans=ans*(ll)cnt[i-1]%mod;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,A,B,C=map(int,input().split())
    n=[A,B,C]
    d={'AB':0,'BC':1,'AC':2}
    before=[[],[],[]]
    ans=[-1]*N
    for i in range(N):
        s=input()
        if n[d[s]]==0 and n[(d[s]+1)%3]==0:
            if before[d[s]] and before[(d[s]+1)%3]:
                if before[d[s]][-1][0]>before[(d[s]+1)%3][-1][0]:
                    k,l=before[d[s]].pop()
                    n[d[s]]+=2
                    n[l]-=2
                    ans[k]=d[s]
                else:
                    k,l=before[(d[s]+1)%3].pop()
                    n[(d[s]+1)%3]+=2
                    n[l]-=2
                    ans[k]=(d[s]+1)%3
            elif before[d[s]] or before[(d[s]+1)%3]:
                if before[d[s]]:
                    k,l=before[d[s]].pop()
                    n[d[s]]+=2
                    n[l]-=2
                    ans[k]=d[s]
                elif before[(d[s]+1)%3]:
                    k,l=before[(d[s]+1)%3].pop()
                    n[(d[s]+1)%3]+=2
                    n[l]-=2
                    ans[k]=(d[s]+1)%3
            else:
                print('No')
                exit()
        if n[d[s]]==0:
            ans[i]=d[s]
            n[d[s]]+=1
            n[(d[s]+1)%3]-=1
        elif n[(d[s]+1)%3]==0:
            ans[i]=(d[s]+1)%3
            n[d[s]]-=1
            n[(d[s]+1)%3]+=1
        else:
            if n[d[s]]<n[(d[s]+1)%3]:
                ans[i]=d[s]
                n[d[s]]+=1
                n[(d[s]+1)%3]-=1
                before[(d[s]+1)%3].append((i,d[s]))
            else:
                ans[i]=(d[s]+1)%3
                n[d[s]]-=1
                n[(d[s]+1)%3]+=1
                before[d[s]].append((i,(d[s]+1)%3))
    print('Yes')
    d2=['A','B','C']
    for a in ans:
        print(d2[a])

if __name__ == '__main__':
    main()


Measured memory_bytes: 75600
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 102;

int n;
int p[N];

int calc(int x) {
	int res = 0;
	for (int i = 0; i < n; i++)
		res += (x - p[i]) * (x - p[i]);
	return res;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	int sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		sum += p[i];
	}
	cout << min(calc(sum / n), calc(sum / n + 1)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    ll h;
    cin >> h;
    int cnt=0;
    while(h>0){
        h /= 2;
        cnt ++;
    }
    cnt;
    ll ans=0;
    ans = pow(2,cnt) - 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<iostream>
#include<set>
#include<map>
using namespace std;
#define mp make_pair
#define ll long long
#define re register
typedef pair<int,int> pii;
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
ll calc(ll n,ll x)
{
	if(!x)return -n;
	return calc(x,n%x)+(n/x)*2ll*x;
}
int main()
{
	ll n,x;scanf("%lld%lld",&n,&x);
	printf("%lld\n",calc(n-x,x)+n);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		int[] h = new int[100];
		int[] w = new int[100];

		int numData;
		for (int i = 0; ; i++)
		{
			int tempH = sc.nextInt();
			int tempW = sc.nextInt();

			if (tempH == 0 && tempW == 0)
			{
				numData = i;
				break;
			}

			h[i] = tempH;
			w[i] = tempW;
		}

		for (int i = 0; i < numData; i++)
		{
			for (int j = 0; j < h[i]; j++)
			{
				for (int k = 0; k < w[i]; k++)
				{
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
}


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
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; }

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


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

    ll n; cin>>n;

    ll ans = 0;

    repf(x,1,n+1){
        ll m = n/x;
        ll tmp = x*m*(m+1)/2;
        ans += tmp;
    }

    cout<<ans<<endl;
    return 0;

}

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

int main(int argc, const char * argv[]) {
   //first problem   --> sucess
    int x;
    cin>> x;
    int array[x];
    for (int i = 0; i< x; i++){
        cin>> array[i];
    }
    bool b1 = false;
    for (int i = 0 ; i< x; i++){
        for (int j = i+1; j< x; j++){ // start as 0, 1 ; end as x - 2, x - 1
            
            for (int k = 1; k<=x; k++){
                int h = k -1;
                
                if (h == i){
                    h = j;
                }
                
                else if (h == j){
                    h = i;
                }
                
                //compare
                if (k != array[h]){
                    break;
                }
                if (k == x ){
                    b1 = true;
                }
            }
            
        }
    }
    //if already in order
    for (int i = 0; i< x; i++){
        if (array[i] != i+1){
            break;
        }
        if (i == x - 1){
            b1 = true;
        }
    }
    
    if (b1){
        cout << "YES";
    }
    else {
        cout << "NO";
    }
    
    return 0;
}

Measured memory_bytes: 256
a,b,c,x,y=map(int,input().split())
ans=0
if y>x:
  ans+=(y-x)*b
else:
  ans+=(x-y)*a
if a+b>c*2:
  print(min(min(x,y)*2*c+ans,max(x,y)*2*c))
else:
  print(a*x+b*y)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#define N 100050
using namespace std;
int n,k,q,p;
int a[N];
int main()
{
	scanf("%d %d %d",&n,&k,&q);
	for(int i=1,x;i<=q;i++){
		scanf("%d",&x);
		++a[x]; --k;
	}
	for(int i=1;i<=n;i++)
		if(a[i]+k>0) printf("Yes\n");
		else printf("No\n");
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x, y;
    cin >> x >> y;
    int xx, yy;
    if(x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 12)
        xx = 0;
    else if(x == 4 || x == 6 || x == 9 || x == 11)
        xx = 1;
    else if(x == 2)
        xx = 2;
    if(y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 12)
        yy = 0;
    else if(y == 4 || y == 6 || y == 9 || y == 11)
        yy = 1;
    else if(y == 2)
        yy = 2;
    if(xx == yy) cout << "Yes";
    else cout << "No";
}


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

int main() {
  	int N, count, Ans=1, Max=0;
    cin >> N;
    for (int i=1; i<=N; i++){
    	 count=0;
         int k=i;
      while (true){
         if (k%2==0){
         	count++;
         	k/=2;
         }
         else if (k%2==1){
         		 if (count>Max){
                 	Max = count;
                    Ans = i;
                 }
                 break;
         }
      }
    }
    cout << Ans << endl;
}


Measured memory_bytes: 3592
//Author: Pakhomovee 
#include <iostream> 
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <deque>
#include <iomanip>
#include <queue>

using namespace std;
using namespace std::chrono;

void solve()
{
	int k;
	cin >> k;
	int ll = 7 % k;
	int ans = -1;
	for (int i = 0; i < 10000000; ++i)
	{
		if (ll == 0)
		{
			ans = i + 1;
			break;
		}
		ll *= 10;
		ll += 7;
		ll %= k;
	}
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	auto start = system_clock::now();

	solve();

	auto end = system_clock::now();
	cerr << "Time: " << duration_cast<milliseconds> (end - start).count() << "ms" << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cmath>

using namespace std;


int main()
{
    string S, T;
    //int S, T;
//    int count = 0;

    //double K, S;
    //double x, y, z;


    cin >> S >> T;

  
    cout << T << S << endl;
    

     return 0;

}



Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    cout << (1000 - n % 1000) % 1000 << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

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

    int nums105 = (x+104)/105; //切り上げ　105の数
    int diff105 = 105*nums105;

    if( diff105-5*nums105 <= x && x <= diff105){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}



Measured memory_bytes: 256
N = int(input())
even_num = []
for num in list(map(int, input().split())):
    if num % 2 == 0:
        even_num.append(num)

count = 0
for i in range(len(even_num)):
    if even_num[i] % 3 == 0 or even_num[i] % 5 == 0:
        count += 1

if count == len(even_num):
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
class Point {
public:
	int a;
	int lenth;
	Point(int a, int b) :a(a), lenth(b) {};
};
vector<Point>v[100001];
int visited[100001];
int n;
int key;
long long all = 0;
void dfs(int root, int total) {
	visited[root] = 1;
	if (total > all) {
		key = root;
		all = total;
	}
	for (int i = 0; i < v[root].size(); i++) {
		int k = v[root][i].a;
		if (!visited[k]) {
			dfs(k, total + v[root][i].lenth);
		}
	}
}
void solve() {
	dfs(0, 0);
	for (int i = 0; i < n; i++)visited[i] = 0;
	dfs(key, 0);
	cout << all<<endl;
}
int main(void) {
	cin >> n;
	int a, b, c;
	for (int i = 0; i < n-1; i++) {
		cin >> a >> b >> c;
		v[a].push_back(Point(b, c));
		v[b].push_back(Point(a, c));
	}
	solve();
}


Measured memory_bytes: 11976