akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;

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


int main() {

	int N;

	cin >> N;

	int ans = 0;
	int temp;

	for (int i = 1; i < N+1; i++)
	{
		for (int j = 1; j < N+1; j++)
		{	
			temp = gcd(i, j);
			for (int k = 1; k < N+1; k++)
			{
				ans += gcd(temp, k);
			}
		}
	}



	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include<vector>
#include<iostream>
#include<set>
using namespace std;




int main() {
	int n,r;
	
	cin >> n >> r;
	
	if(n>=10){
		cout << r <<endl;
		return 0;
	}
	
	cout << r + 100*(10-n) <<endl;
	
	
    return 0;
}


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

using namespace std;

map <string, int> mp;

int main() {

	int n;
	cin >> n;
	vector <string> s(n);
	int maxx = 0;
	set <string> ans;
	for (int i = 0; i < n; i ++) {
		cin >> s[i];
		mp[s[i]] ++;
	}
	for (int i = 0; i < n; i ++) {
		maxx = max(maxx, mp[s[i]]);
	}
	for (int i = 0; i < n; i ++) {
		if (mp[s[i]] == maxx) {
			ans.insert(s[i]);
		}
	}
	for (auto i : ans) {
		cout << i << '\n';
	}
	return 0;
}

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

int main() {
  ll k, a, b;
  cin >> k >> a >> b;

  if (a >= b) {
    cout << k + 1 << endl;
    return 0;
  }
  if (k < a - 1) {
    cout << k + 1 << endl;
    return 0;
  }
  if (a + 1 == b) {
    cout << k + 1 << endl;
    return 0;
  }

  k -= (a - 1);

  ll ans = a;
  if (k % 2 == 0) {
    ans += (b - a) * k / 2;
  } else {
    ans += (b - a) * (k / 2) + 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
ans = 0
for i in range(n):
    x, y, z = map(int, input().split())
    if(x < y + z):
        print('No')
        ans = 1
        break
    if(x%2 == (y+z)%2):
        continue
    else:
        print('No')
        ans = 1
        break
if(ans == 0):
    print('Yes')

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

int main(){
	int R; cin >> R;
	if (R < 1200){
		cout << "ABC" << endl;
	} else if (R < 2800){
		cout << "ARC" << endl;
	} else {
		cout << "AGC" << endl;
	}
}

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

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

int tmp=0;
int cntmax=0;
int num =0;
for(int i=1;i<=n;i++){
    int cnt = 0;
    int flg = 0;
        tmp = i;
    while(!flg){
        if(tmp%2==0){
            cnt++;
            tmp /= 2;
        }else{
        flg=1;
        }
    }
    if(cntmax <= cnt){
        num = i;
        cntmax = cnt;
    };
}
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
# def main():
#     n = int(input())
#     al = list(map(int, input().split()))
#     all_xor = 0
#     for a in al:
#         all_xor = all_xor ^ a

#     ans = []
#     for a in al:
#         curr_ans = all_xor ^ a
#         ans.append(curr_ans)

#     print(*ans)


# if __name__ == "__main__":
#     main()


N_MAX = 2*(10**6)
MOD = 10**9 + 7
fac, finv, inv = [0]*N_MAX ,[0]*N_MAX, [0]*N_MAX
def com_init():
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1
    for i in range(2, N_MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

def com(n, k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


def main():
    k = int(input())
    s = input()
    n = len(s)

    com_init()

    ans = 0
    for i in range(0,k+1):
        ans += (pow(25,k-i,MOD) * pow(26,i,MOD))*com(n+k-i-1,n-1)

    print(ans%MOD)


if __name__ == "__main__":
    main()

Measured memory_bytes: 117752
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9;
const int ZERO = 0;
const int MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

signed main() {
    int X;
    cin >> X;
    int cnt = X / 100;
    int cnt2 = X - cnt * 100;
    if(cnt2 % 5 == 0) {
        if(cnt / 5 <= cnt) {
            cout << 1 << endl;
        }
        else {
            cout << 0 << endl;
        }
    }
    else if(cnt2 / 5 + 1 <= cnt) {
        cout << 1 << endl;
    }
    else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
#define N 514
string ma[N];
int dp[N][N];//どこまで戻れるか
int mx[N][N],mn[N][N];//ある層への最高・最低着地点（毎回計算する）
lint num[N],sum[N];
int main()
{
	lint out=0;
	int n;
	cin>>n;
	rep(i,n) cin>>ma[i];
	rep(i,n) rep(j,n){
		dp[i][j]=N*2;
		if(ma[i][j]=='#') continue;
		dp[i][j]=i+j;
		if(i>0) dp[i][j]=min(dp[i][j],dp[i-1][j]);
		if(j>0) dp[i][j]=min(dp[i][j],dp[i][j-1]);
	}
	for(int i=n*2-2;i>=0;i--){
		//cout<<i<<endl;
		rep(j,n+5) rep(k,min(n,i-j)+5) mx[j][k]=-N,mn[j][k]=N;
		for(int j=n-1;j>=0;j--) for(int k=n-1;k>=0;k--){
			if(j+k==i) mx[j][k]=mn[j][k]=j;
			if(j+k<i){
				if(ma[j][k]!='#'){
					if(j<n-1) mx[j][k]=max(mx[j][k],mx[j+1][k]),mn[j][k]=min(mn[j][k],mn[j+1][k]);
					if(k<n-1) mx[j][k]=max(mx[j][k],mx[j][k+1]),mn[j][k]=min(mn[j][k],mn[j][k+1]);
				}
			}
			//cout<<i<<j<<k<<mx[j][k]<<mn[j][k]<<endl;
		}
		for(int j=i-1;j>=0;j--){
			memset(num,0,sizeof(num));
			memset(sum,0,sizeof(sum));
			rep(k,n){
				int l=i-k;
				if(l>=0 && l<n && dp[k][l]<=j && ma[k][l]!='#') num[k]=(ma[k][l]-'0');
				sum[k+1]=sum[k]+num[k];
			}
			rep(k,n){
				int l=j-k;
				if(l>=0 && l<n && mx[k][l]>=mn[k][l] && ma[k][l]!='#'){
					//cout<<i<<' '<<k<<' '<<l<<' '<<mx[k][l]<<' '<<mn[k][l]<<' '<<(sum[mx[k][l]+1]-sum[mn[k][l]])<<endl;
					out+=(ma[k][l]-'0')*(sum[mx[k][l]+1]-sum[mn[k][l]]);
				}
			}
		}
	}
	cout<<out<<endl;
}


Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


int n, ans;
string s, c[102];

int main() {

	cin >> s >> n;
	rep(i, n)cin >> c[i];
	rep(i, n)c[i] += c[i];

	rep(i, n) {
		rep(j, 10) {
			int cnt = 0;
			while (cnt < s.size()) {
				if (s[cnt] == c[i][j + cnt]) {
					cnt++;
				}
				else {
					break;
				}
			}
			if (cnt == s.size()) {
				ans++;
				break;
			}
		}
	}

	cout << ans << endl;
	

	return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define fi first
#define se second
#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(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#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 pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<string,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  int n;
  scanf("%d",&n);
  vp p(n);
  cin>>p;
  string s;
  cin>>s;
  int ans = 0;
  rep(i,n) {
    ans += p[i].se;
    if (p[i].fi == s) ans = 0;
  }
  cout<<ans<<endl;
  return 0;
}






















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

int main()
{
  int N, K;
  cin >> N >> K;
  int _sum = 0;
  for (int i = 0; i < N; ++i)
  {
    int x;
    cin >> x;
    _sum += ((x < K - x) ? x : K - x);
  }
  cout << 2*_sum;
  return 0;
}


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

using namespace std;

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

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	string s, t;
	cin >> s >> t;
	ll res = 0;
	REP(i, s.length()) if (s[i] != t[i]) ++res;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3920
package main

import "fmt"

func main() {
	var w, h, n int
	fmt.Scan(&w, &h, &n)

	arr := make([][]int, h)
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			arr[i] = append(arr[i], 1)
		}
	}

	for i := 0; i < n; i++ {
		var xi, yi, a int
		fmt.Scan(&xi, &yi, &a)

		for y := 0; y < h; y++ {
			for x := 0; x < w; x++ {
				switch a {
				case 1:
					if x < xi {
						arr[y][x] = 0
					}
				case 2:
					if x >= xi {
						arr[y][x] = 0
					}
				case 3:
					if y < yi {
						arr[y][x] = 0
					}
				case 4:
					if y >= yi {
						arr[y][x] = 0
					}
				}
			}
		}
	}
	ans := 0
	for y := 0; y < h; y++ {
		for x := 0; x < w; x++ {
			ans += arr[y][x]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 768
import math
def main():

    a, b, angleC = map(float, input().split())
    radC = angleC * math.pi / 180
    S = a * b * math.sin(radC) /2
    c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(radC))
    L = a + b + c
    h = S / a * 2
    print(S, L, h)

if __name__ == '__main__':
    main()



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

static const int INF = 1000000007;
using ll = long long;
using namespace std;

int main() {
    unsigned n, k;
    cin >> n >> k;
    vector<int> v;
    int ans = INF, prv = -INF;
    int d = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        scanf("%d", &a);
        if(prv <= 0 && 0 <= a) {
            if(prv != 0) {
                v.emplace_back(0);
                d = i;
            }
        }
        v.emplace_back(a);
        prv = a;
    }

    for (int i = 0; i+k < n+1; ++i) {
        ans = min(ans, v[i+k]-v[i]+min(abs(v[i+k]), abs(v[i])));
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

int main() {
  llong N;
  vector<llong> A;
  
  cin >> N;
  A.resize(N);
  for (auto &in: A) {
    cin >> in;
  }
  sort(ALL(A));

  vector<llong> prime;
  for (int i = 2; i <= 1000; i++) {
    bool ok = true;
    for (auto &p: prime) {
      if (i % p == 0) {
        ok = false;
        break;
      }
    }
    if (ok) {
      prime.push_back(i);
    }
  }

  int cnt_one = 0;
  map<llong, llong> m;
  for (auto &a: A) {
    cnt_one += a == 1;
    for (auto &p: prime) {
      if (a % p == 0) {
        m[p]++;
        while (a % p == 0) {
          a /= p;
        }
      }
    }
    if (a != 1) {
      m[a]++;
    }
  }

  bool isN = false;
  bool all_one = true;
  for (auto it: m) {
    isN |= it.second == N;
    all_one &= it.second == 1;
  }

  if (all_one) {
    cout << "pairwise coprime" << endl;
  }
  else if (isN) {
    cout << "not coprime" << endl;
  }
  else {
    cout << "setwise coprime" << endl;
  }

  return 0;
}

Measured memory_bytes: 15784
from itertools import product
n,a,b,c = (int(i) for i in input().split())
x = [int(input()) for i in range(n)]
ans = float("inf")
def f(q):
    if any(i not in q for i in range(3)): return ans
    else:
        z,num = [0,0,0],0
        for i in range(n):
            if q[i]-3:
                if z[q[i]]: num+=10
                z[q[i]]+=x[i]
        return num+abs(z[0]-a)+abs(z[1]-b)+abs(z[2]-c)
for i in product((0,1,2,3),repeat=n): ans = min(ans,f(i))
print(ans)

Measured memory_bytes: 3064
import collections

N = int(input())
table = []
ans = []

for i in range(N):
    s = input()
    table.append(s)

c = collections.Counter(table).most_common()

pre_x = c[0][1]
for s,x in c:
    if pre_x != x:
        break
    ans.append(s)
    pre_x = x

ans.sort()
for s in ans:
    print(s)

Measured memory_bytes: 45040
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int X[13][13];

int main(){
  int N,D;
  cin >> N >> D;
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){cin >> X[i][j];}
  }
  int cnt=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      int sum=0;
      for(int k=0;k<D;k++){sum+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);}
      int q=sqrt(sum);
      if(q*q==sum)cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 384
import java.util.*
data class Neta(val t: Int, val d: Int)
fun main(args: Array<String>) {
    val (N, K) = listOfInt()
    val A = Array(N) {
        val (t, d) = listOfInt()
        Neta(t, d)
    }.sortedByDescending { it.d }
    val map = mutableMapOf<Int, Int>()
    val use = PriorityQueue<Neta>(N, Comparator { o1, o2 -> o1.d - o2.d }) //asc
    val rem = PriorityQueue<Neta>(N, Comparator { o1, o2 -> o2.d - o1.d }) //desc
    var sum = 0L
    var ans = 0L
    for (k in 0 until K) {
        use.add(A[k])
        map.put(A[k].t, map.getOrElse(A[k].t, { 0 }) + 1)
        sum += A[k].d
        ans = Math.max(ans, sum + map.size.squaredLong())
    }
    for (k in K until N) rem.add(A[k])
outside@
    while (!use.isEmpty()) {
        val u = use.poll()
if (map.get(u.t)!! >= 2) {
        while (!rem.isEmpty()) {
            val r = rem.poll()
            if (!map.containsKey(r.t)) {
                map.put(r.t, 1)
                sum += r.d - u.d
                ans = Math.max(ans, sum + map.size.squaredLong())
                continue@outside
            }
        }
        break@outside
}
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun Int.squaredLong() = this.toLong() * this.toLong()


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

using namespace std;

int n;
int h[200001];

int main()
{
	cin>>n;
	for (int i=0;i<n;++i) cin>>h[i];
	for (int i=n-1;i>=0;i-=2) cout<<h[i]<<' ';
	for (int i=n%2;i<n;i+=2) cout<<h[i]<<' ';
	cout<<endl;
}


Measured memory_bytes: 2944
# 3:07

n, m = gets.to_s.split.map{|t|t.to_i}
h    = gets.to_s.split.map{|t|t.to_i}
# a, b = Array.new(m){ gets.to_s.split.map{|t|to_i-1} }.transpose

ans = Array.new(n){ true }

m.times do
  a, b = gets.to_s.split.map{|t|t.to_i-1}
  ans[a] = false if h[a] <= h[b]
  ans[b] = false if h[b] <= h[a]
end
# p ans
puts ans.count(true)

Measured memory_bytes: 22456
//OPTIMIZATONS
#pragma GCC optimize("02")
//CODE
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;
const int N = 2e5 + 1;
int edg[N] = {0};
bool seen[N] = {0};
deque<int> path;
int last=1,k;

void bfs(int node){
	path.push_back(node);
	if(seen[edg[node]] && k>=0){
		while(!path.empty() && path.front()!=edg[node] && k>=0){
			last = path.front();
			path.pop_front();
			k--;
		}
		return;
	}
	seen[edg[node]] = true;
	bfs(edg[node]);
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>edg[i];
	bfs(1);

	if(k<0){
		cout<<last<<endl;
		return 0;
	}

	int len = path.size();
	k%=len;
	while(!path.empty() && k>=0){
		last = path.front();
		path.pop_front();
		k--;
	}
	cout<<last<<endl;
	return 0;
}


Measured memory_bytes: 6512
#include <iostream>
using namespace std;
int main()
{
	int N,K,X,Y;
	int total=0;
	cin>>N>>K>>X>>Y;
	for(int i=1;i<=N;i++){
		if(i<=K)	total+=X;
		else	total+=Y;
	}
	cout<<total<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>

using namespace std;
struct Move{
  int bx;
  int by;
  int ax;
  int ay;
  Move(int x, int y, int x1, int y1){
    bx = x;
    by = y;
    ax = x1;
    ay = y1;
  }
};

int main(){
  int W,H, a;
  int oddIndex[500];
  int oddNum=0;
  int preLastOddIndex = -1;
  vector<Move> moves;

  cin >> H >> W;
  for(int i=0; i<H; i++){
    oddNum = 0;
    for(int j=0; j<W; j++){
      //printf("#%d %d\n", j,i);
      cin >> a;
      //printf("%d is scaned\n",a);
      if(j == preLastOddIndex){
        //printf("%d(%d, %d) is inc!\n", a, j, i);
        a++;
        preLastOddIndex = -1;
      }
      if(a%2){//odd
        //printf("%d(%d, %d) is ODD!\n", a, j, i);
        oddIndex[oddNum] = j;
        oddNum++;
      }
    }

    if(oddNum % 2 && i != H-1){//sum is odd
      preLastOddIndex = oddIndex[oddNum-1];
      oddNum--;
      //printf("cast!\n");
      moves.push_back( Move(preLastOddIndex, i, preLastOddIndex, i+1) );
    }
    for(int j=0; j < oddNum; j+=2){
      if(oddNum - j == 1)
        break;
      for(int k = oddIndex[j]; k < oddIndex[j+1]; k++){
        moves.push_back(Move(k,i,k+1,i));
      }
    }
  }
  cout << moves.size() << endl;
  for(int i = 0; i < (int)moves.size(); i++)
    printf("%d %d %d %d\n", moves[i].by+1, moves[i].bx+1, moves[i].ay+1, moves[i].ax+1);

  return 0;
}







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

#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vull vector<ull>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int t; cin >> t; for(int cs = 1; cs <= t; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define reset(x,y) memset(x,y,sizeof x);
#define EPS 1e-10
#define INF 2000000000
#define mod 1000000007
#define debug(val) cerr << "The value of " << #val << " is = " << val << endl;
#define testing cerr << "--------------------------\n";

ll adj[25][25],n,dp[25][1<<21];

ll f(int nw, int mask) {
	if(nw == n) return 1;
	if(dp[nw][mask]!=-1) return dp[nw][mask];
	ll ret = 0;
	for(int i = 0; i < n; i++) {
//		debug(i)
//		debug(nw)
//		debug(adj[nw][i]);
//		debug(mask);
//		testing
		if(!(mask&(1<<i)) and adj[nw][i]) {
//			cout<<"masuk : "<<nw<<" "<<i<<endl;
//			testing
			ret = (ret + f(nw+1,mask|(1<<i)))%mod;
		}
	}
	return dp[nw][mask] = ret;
}

int main() {
	reset(dp,-1);
	IOS
	cin >> n;
	fori(i,0,n-1,1)
		fori(j,0,n-1,1)
			cin >> adj[i][j];
	cout << f(0,0) << endl;
}


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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n;
    cin >> n;
    cout << n + n*n + n*n*n << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

vector<vector<int>> v(101,vector<int>(101,INF));
ll dp[101][101];

void init(){
  rep(i,101){
    rep(j,101){
      dp[i][j]=INF;
    }
  }
}

signed main(){
  ll n,m,ans=0;cin>>n>>m;
  init();

  for(int i=0;i < m;i++)
  {
    int a,b,c;cin>>a>>b>>c;
    v[a][b]=c;
    v[b][a]=c;
    dp[a][b]=c;
    dp[b][a]=c;
  }

  for(int k=1;k < n+1;k++)
  {
    for(int i=1;i < n+1;i++)
    {
      for(int j=1;j < n+1;j++)
      {
        dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
      }
    }
  }

  for(int i=1;i < n+1;i++)
  {
    for(int j=1;j < n+1;j++)
    {
      if(i<j &&  v[i][j]<INF && dp[i][j]!= v[i][j])ans++;
    }
  }

  cout<<ans<<endl;
}

    



Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#ifdef RUBICK
#include "dbg.h"
#else
#define dbg(exp) /* nop; */
#endif

using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;

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

    vector<int> arr(n);
    for (int& e : arr)
        scanf("%d", &e);

    sort(begin(arr), end(arr));

    int ans = 0;
    for (int i = 0; i < n; i ++) {
        auto lb = lower_bound(begin(arr), end(arr), arr[i] - 1);
        auto ub = upper_bound(begin(arr), end(arr), arr[i] + 1);
        ans = max(ans, int(ub - lb));
    }

    printf("%d\n", ans);

    return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
using namespace std;
static const int MAX  = 100;
int main ()
{
  int n,u,k,v;
  cin>>n;
  int M[MAX][MAX];
  for(int i  = 0;i<n;i++)
    {
      for(int j = 0;j<n;j++)
        {
          M[i][j] = 0;
        }
    } 
  for(int i = 0;i<n;i++)
   {
     cin>>u>>k;
     u--;
     for(int j = 0;j<k;j++)
       {
         cin>>v;
         v--;
         M[u][v] = 1;
       }
   } 
   for(int i = 0;i<n;i++)
     {
       for(int j = 0;j<n;j++)
        { if(j) cout<<" ";
          cout<<M[i][j];
     }
     cout<<endl;
   }
  return 0 ;
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll =int long long;
map <int ,int> mpa,mpb;

int main (void){
  int N;
  cin >> N;
  int ans=pow(3,N);
  int A[N];
  int count=0;
  bool flag=1;
  for(int i=0;i<N;i++){
    cin >> A[i];
    if(A[i]%2==0){
      count=count+1;
      flag=0;
    }
  }
  if(flag) {
    cout << ans-1;
    return 0;
  }
  ans=ans-pow(2,count);
  cout << ans;
}

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

int b[5];
int main(){
	int n;
	cin>>n;
	char a;
	for(int i=1; i<=n; i++){
		cin>>a;
		if(a=='P'){
			b[1]=1;
		}else if(a=='W'){
			b[2]=1;
		}else if(a=='G'){
			b[3]=1;
		}else{
			b[4]=1;
		}
	}
	int s=0;
	for(int i=1; i<=4; i++){
		if(b[i]==1){
			s++;
		}
	}
	if(s==3){
		cout<<"Three"<<endl;
	}else{
		cout<<"Four"<<endl;
	}
	
	return 0;
}

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

//TO_STRING
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(char ch){
  string s;
  s += ch;
  return s;
}

string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + 
    to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + 
    to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

//DEBUG 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL //compile with -DLOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<pi> vpi;
typedef vector<char> vch;
typedef vector<string> vstr;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
typedef vector<vvi> vvvi;
typedef vector<vch> vvch;
typedef vector<vstr> vvstr;

#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front
#define fi first
#define se second  
#define sz(x) ((ll)x.size())



void solve() {
 int k, a, b;
 cin >> k >> a >> b;
 for (int i = a; i <= b; i++) {
  if (i % k == 0) {
    cout << "OK\n";
    return;
  }
 } 
 cout << "NG\n";
}

int main() {
  ios::sync_with_stdio(false);  
  cin.tie(0);cout.tie(0); 
  
  int t = 1;
  for (int tc = 1; tc <= t; tc++) {
  	solve();
  }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int m1, m2, d;cin>>m1>>d>>m2>>d;
  cout<<int(m1!=m2)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
void prime_factorize(ll n, vector<ll> & ret)
{
    if (n <= 1)	return;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            prime_factorize(i, ret);
            prime_factorize(n / i, ret);
            return;
        }
    }
    ret.push_back(n);
    return;
}
int main()
{
    /*int c; cin >> c;
    if (30 <= c) cout << "Yes" << endl;
    else cout << "No" << endl;
    */

    /*ll n, d; cin >> n >> d;
    d *= d;
    int ans = 0;
    rep(i, n) {
        ll x, y; cin >> x >> y;
        ll dd = x * x + y * y;
        if (dd <= d) ans++;
    }
    cout << ans << endl;
    */

    ll k; cin >> k;
    if (k % 2 == 0) {
        cout << -1 << endl;
        return 0;
    }
    if (k % 7 == 0) {
        k /= 7;
    }
    ll num = 1;
    rep(i, 1001000) {
        if (num % k == 0) {
            cout << i + 1 << endl;
            return 0;
        }
        num *= ll(10);
        num += ll(1);
        num %= k;
    }
    cout << -1 << endl;
    

    /*int k; cin >> k;
    string s; cin >> s;
    int num = s.size();
    int w, r;
    w = r = 0;
    for (char c : s) {
        if (c == 'R') r++;
        else w++;
    }
    if (w == 0 || r == 0) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> rnum, wnum;
    rep(i, num) {
        if (s[i] == 'R') rnum.push_back(i);
        else wnum.push_back(i);
    }
    sort(ALL(wnum));
    sort(rALL(rnum));
    num = min(wnum.size(), rnum.size());
    int ans = 0;
    rep(i, num) {
        if (rnum[i] < wnum[i]) break;
        ans++;
    }
    cout << ans << endl;
    */

    /*ll n, k; cin >> n >> k;
    vector<ll> a(n);
    ll mx = 0;
    rep(i, n) {
        cin >> a[i];
        mx = max(mx, a[i]);
    }
    ll l, r, m;
    l = 0; r = mx; // l : kより大きい回数で切らなければならない
    while (l + 1 < r) {
        m = (l + r) / ll(2);
        // 長さmにするために切る回数
        ll num = 0;
        rep(i, n) {
            if (a[i] <= m) continue;
            int tmpnum = (int)floor(double(a[i]) / double(m));
            if (a[i] % m == 0) tmpnum--;
            num += tmpnum;
        }
        if (m == 262703496) cout << m << "," << num << endl;
        if (k < num) l = m;
        else r = m;
    }
    cout << r << endl;
    */

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}



signed main(){
	int n; cin>>n;
	ll ans = 1;
	VI x(n+1,0);
	reps(i,n){
		if(i==1) continue;
		int tmp = i;
		reps(j,tmp){
			if(j==1) continue;
			while(tmp%j==0){
				tmp/=j; x[j]++;
			}
		}
	}
	reps(i,n){
		if(i==1) continue;
		ans = ans*((x[i]+1)%MOD)%MOD;
	}
	cout << ans << endl;
  return 0;
}


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

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<=n;i++)
        for(int j=0;i+j<=n;j++)
            if(i*10000+j*5000+(n-i-j)*1000==m)
            {
                cout<<i<<' '<<j<<' '<<n-i-j<<endl;
                return 0;
            }
    cout<<"-1 -1 -1\n";
}

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


int main(){
    double A,B,H,M;
    cin >> A >> B >> H >> M;
    double rad, ans;
    rad = 30.0*H+M/2.0-6.0*M;
    if(rad >= 180.0){
        rad -= 360.0;
    }
    rad = rad*M_PI/180.0;
    ans = pow(A,2.0)+pow(B,2.0)-2.0*A*B*cos(rad);
    ans = sqrt(ans);
    cout << fixed << setprecision(15) << ans <<endl;
}

Measured memory_bytes: 4224
#include <cstdio>
#include <algorithm>
#include <cassert>

enum {
  MAXN = 100000 + 5
};

typedef long long i64;
const int MOD = 1e9+7;

int n;
int dp[MAXN][2];
i64 S[MAXN];
i64 A, B;
i64 sum[MAXN];

int last;

int getminlength(int p) {
  int l = -1, r = p, mid;
  while (l+1 < r) {
    mid = l + (r-l) / 2;
    (S[p] - S[p-mid-1] >= B? r : l) = mid;
  }
  return std::max(r, 1);
}

void exec() {
  int i, j, ans(0), x;
  scanf("%d%lld%lld", &n, &A, &B);

  if (B < A) std::swap(A, B);
  
  for (i=0; i<n; ++i)
    scanf("%lld", S+i);
  dp[0][1] = 1;
  dp[1][1] = 1;

  last = -1;

  sum[1] = dp[0][1];
  
  for (i=1; i<n; ++i) {
    x = i-getminlength(i);
    // for (j=last+1; j<=x; ++j) {
    //   (dp[i+1][0] += dp[j][1]) %= MOD;
    //   if (j >= 2 && S[j] - S[j-2] >= A)
    // 	(dp[i+1][0] += dp[j][0]) %= MOD;
    // }
    if (x > last)
      (dp[i+1][0] += (sum[x+1] - sum[last+1] + MOD) % MOD) %= MOD;
    sum[i+1] = sum[i];
    (sum[i+1] += dp[i][1]) %= MOD;
    if (i>=2 && S[i]-S[i-2] >= A)
      (sum[i+1] += dp[i][0]) %= MOD;
    if (S[i]-S[i-1] >= B)
      (dp[i+1][1] += (dp[i][0] + dp[i][1]) % MOD) %= MOD;
    if (S[i] - S[i-1] < A)
      last = i-1;    
  }

  ans = (dp[n][0] + dp[n][1]) % MOD;
  
  for (i=n-1; i>=0; --i) {
    if (i<n-1 && S[i+1] - S[i] < A)
      break;
    (ans += dp[i][1]) %= MOD;
    if (i>=2 && S[i] - S[i-2] >= A)
      (ans += dp[i][0]) %= MOD;
  }
  printf("%d\n", ans);
}

int main() {
  if (fopen("C.in", "r") != NULL) {
    freopen("C.in", "r", stdin);
    freopen("C.out", "w", stdout);
  }
  exec();
  return 0;
}


Measured memory_bytes: 2560
function Main(input){
	input=input.split(" ");
	let a=parseInt(input[0],10);
	let b=parseInt(input[1],10);
	if (a < b) {
		console.log("a < b");
	} else if (a > b) {
		console.log("a > b");
	} else {
		console.log("a == b");
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15340
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<ll, ll>;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const ll MOD = 1e9 + 7;
const ll N = 1e2 + 5;

ll n, m;
ll dx[] = {1, 0};
ll dy[] = {0, 1};
ll dp[N][N];
char grid[N][N];

bool outside(ll r, ll c) {
    return r < 0 || r > n || c < 0 || c > m;
}

ll f(ll r, ll c) {
    if(r == n && c == m) return grid[r][c] == '#';
    if(dp[r][c] != -1) return dp[r][c];
    ll res = INT_MAX;
    for(ll i = 0; i < 2; i++) {
        ll nr = r + dx[i], nc = c + dy[i];
        if(outside(nr, nc)) continue;
        if(grid[r][c] == '.') res = min(res, f(nr, nc));
        else if(grid[r][c] == '#' && grid[nr][nc] == '#') res = min(res, f(nr, nc));
        else if(grid[r][c] == '#' && grid[nr][nc] == '.') res = min(res, f(nr, nc) + 1);
    }
    return dp[r][c] = res;
}

void solve() {
    cin >> n >> m;
    for(ll i = 1; i <= n; i++) {
        for(ll j = 1; j <= m; j++) {
            cin >> grid[i][j];
        }
    }
    memset(dp, -1, sizeof(dp));
    cout << f(1, 1) << "\n";
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    solve();
    
}

Measured memory_bytes: 3756
W,H,N = map(int,input().split())
x = []
y = []
a = []
for i in range(N):
    x1,y1,a1 = [int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
    a.append(a1)
block = [[True for i in range(W)]for j in range(H)]
for i in range(len(a)):
    if a[i] == 1:
        for j in range(x[i]):
            for k in range(H):
                block[k][j]=False
    elif a[i] == 2:
        for j in range(x[i],W):
            for k in range(H):
                block[k][j] = False
    elif a[i] == 3:
        for j in range(W):
            for k in range(y[i]):
                block[k][j]=False
    elif a[i] == 4:
        for j in range(W):
            for k in range(y[i],H):
                block[k][j]=False
count = 0
for i in range(W):
    for j in range(H):
        if block[j][i] == True:
            count+=1
print(count)



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

int main() {
int n,k,m=1;
 cin>>n>>k;
  for(int i=0; i<n; i++){
  if(m<k)m*=2;
    else m+=k;
  
  
  }
  cout<<m<<endl;
  
 }



Measured memory_bytes: 256
import std.stdio;
import std.ascii;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

const INF = int.max / 2;

void main() {
    int N;
    int[] P, T;
    bool input() {
        scanf("%d\n", &N);
        if (N == 0) return false;
        P = new int[N + 1];
        T = new int[N + 1];
        P[0] = T[0] = 0;
        for (int i = 1; i <= N; i++) {
            scanf("%d %d\n", &P[i], &T[i]);
        }
        return true;
    }
    int dist(int a, int b) {
        return abs(P[a] - P[b]);
    }
    void solve() {
        auto dp = new int[][](4, N + 1);
        foreach (ref L; dp) L[] = INF;
        dp[0][0] = 0; // ばんぺーさん
        dp[1][1] = T[1] < P[1] ? INF : P[1];
        for (int j = 1; j <= N; j++) {
            for (int i = 1; i <= 3; i++) {
                int ntime = T[j - 1] + dist(0, j - 1) * (i + 1) + dist(0, j) * 1;
                if (ntime <= T[j]) {
                    dp[1][j] = min(dp[1][j], dp[i][j - 1] + dist(0, j - 1) + dist(0, j));
                }
            }
            for (int i = 2; i <= 3; i++) {
                int ntime = T[j - 1] + dist(j - 1, j) * i;
                if (ntime <= T[j]) {
                    dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + dist(j, j - 1));
                }
            }
        }
        for (int j = N; j >= 0; j--) {
            int X = INF;
            for (int i = 0; i <= 3; i++) {
                X = min(X, dp[i][j]);
            }
            if (X < INF) {
                if (j == N) {
                    writeln("OK ", X + P[N]);
                } else {
                    writeln("NG ", j + 1);
                }
                break;
            }
        }
    }
    while (input) solve;
}

Measured memory_bytes: 1056
#include <iostream>
#include <string>
#include <queue>
using namespace std;
int main(){
    string str1, str2, str3;

    while(cin >> str1){
        if(str1 == "-") break;
        string ret = "";
        deque<char> qu, ql;
        char c;
        cin >> str2 >> str3;
        for(int i=0;i<str1.size();i++) qu.push_back(str1[i]);
        for(int i=0;i<str2.size();i++) ql.push_back(str2[i]);

        c = ql.front();
        ql.pop_front();
        while(!qu.empty() || !ql.empty()){
            if(str3.find(c,0) == string::npos){
                ret += c;
                if(ql.empty()){
                    c = qu.front();
                    qu.pop_front();
                }else{
                    c= ql.front();
                    ql.pop_front();
                }
            }else{
                if(qu.empty()){
                    c = ql.front();
                    ql.pop_front();
                }else{
                    c = qu.front();
                    qu.pop_front();
                }
            }
        }
        ret += c;
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
a,b=map(int,input().split())

def solve(x):
    if x <= 0 : return 0
    res = 0
    keta = 0
    limit =x
    while limit:
        if keta == 0:
            tmp=x%4
            if tmp == 1 or tmp == 2:
                res += 1
        else:
            tmp = x%(1<<(keta+1))
            tmp -= 1<<keta
            if tmp >= 0:
                if tmp %2 == 0:
                    res += 1<<keta
        keta += 1
        limit>>=1
    return res

print(solve(b)^solve(a-1))

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

vector<int> bfs(vector<vector<int>> &G, int s) {
  vector<bool> used(G.size());
  vector<int> d(G.size());
  queue<pair<int, int>> que;

  d[s] = 0;
  used[s] = true;
  que.push(make_pair(s, 0));

  while (!que.empty()) {
    pair<int, int> q = que.front(); que.pop();
    int cx = q.first;
    int ct = q.second;
    used[cx] = true;
    d[cx] = ct;

    rep (i, G[cx].size()) {
      int nx = G[cx][i];
      if (!used[nx]) {
        que.push(make_pair(nx, ct+1));
      }
    }
  }
  return d;
}

int main() {
  int n, a, b;
  cin >> n;
  vector<vector<int>> G(n);

  rep (i, n-1) {
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int s = 0;
  int g = n-1;

  vector<int> d1 = bfs(G, s);
  vector<int> d2 = bfs(G, g);

  int l = 0;
  int r = 0;

  rep (i, n) {
    if (d1[i] <= d2[i]) l++;
    else r++;
  }

  if (l > r) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;
  return 0;
}


Measured memory_bytes: 6584
use std::io;

/// ベクトル1はleft...mid-1まで、ベクトル2はmid...right-1まで
/// 昇順に整列済みのベクトル1、ベクトル2を結合する。
fn merge(vec: &mut Vec<u32>, left: usize, mid:usize, right: usize) -> u32 {
    let n = right - left;
    let mut tv: Vec<u32> = vec![0; n];
    for i in 0..(mid-left) {
        tv[i] = vec[left+i];
    }
    for i in 0..(right-mid) {
        tv[n-1-i] = vec[mid+i];
    }

    let mut l = 0;
    let mut r = n - 1;
    let mut cnt = 0;
    for i in left..right {
        if tv[l] < tv[r] {
            vec[i] = tv[l];
            l += 1;
        } else {
            vec[i] = tv[r];
            if r > 0 {
                r -= 1;
            }
        }
        cnt +=1 ;
    }
    cnt
}

fn merge_sort(vec: &mut Vec<u32>, left: usize, right: usize) -> u32 {
    let mut cnt = 0;
    if right - left >= 2 {
        let mid = (left + right) / 2;
        cnt += merge_sort(vec, left, mid);
        cnt += merge_sort(vec, mid, right);
        cnt += merge(vec, left, mid, right);
    }
    cnt
}

fn main() {
    let sin = io::stdin();
    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let _n: usize = buf.trim().parse().unwrap();

    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let mut s: Vec<u32> = buf.split_whitespace()
        .map(|v| v.parse().unwrap())
        .collect::<Vec<u32>>();
    let size = s.len();
    let cnt = merge_sort(&mut s, 0, size);
    let out = s.iter().map(|v| v.to_string())
        .collect::<Vec<String>>()
        .join(" ");
    println!("{}", out);
    println!("{}", cnt);
}



Measured memory_bytes: 37780
#include <iostream>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int f=0,s=0;
  if(a==5) f++;
  if(a==7) s++;
  if(b==7) s++;
  if(b==5) f++;
  if(c==5) f++;
  if(c==7) s++;
  if(f==2 && s==1) cout << "YES\n";
  else cout << "NO\n";
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    if(n%2==0)
    cout<<"0.5000000000";
    else
    {
    double x=(double)(n/2+1)/n;
    printf("%.10lf",x);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int a[200001];
int n,i,tg;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (i=1;i<n;i++)
    {
        cin >> tg;
        a[tg]++;
    }
    for (i=1;i<=n;i++)
        cout << a[i] << "\n";
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    int n, m; cin >> n >> m;
    V<V<int> > v(m);
    for(int i = 0; i < m; i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int s; cin >> s;
            s--;
            v[i].push_back(s);
        }
    }
    V<int> w(m);
    for(int i = 0; i < m; i++) cin >> w[i];

    int ans = 0;
    for(int bit = 0; bit < (1 << n); bit++){
        bool flag = true;
        for(int j = 0; j < m; j++){
            int cnt = 0;
            for(int k = 0; k < (int)v[j].size(); k++){
                if(bit & (1 << v[j][k])) cnt++;
            }
            if(cnt % 2 != w[j]){
                flag = false;
            }
        }
        if(flag) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

const int maxn = 2e5 + 7;

vector<int> occ[maxn];
vector< pair<int,int> > seg;
int a[maxn];
bool seen[maxn];

int bit[maxn];

void upd(int x, int v) {
    while (x < maxn) {
        bit[x] += v; x += x & (-x);
    }
}

int qry(int x) {
    int ans = 0;
    while (x > 0) {
        ans += bit[x]; x -= x & (-x);
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    string s; cin>>s; int n = s.size(); s = " " + s;
    
    fill(occ, occ + maxn, *new vector<int>());
    
    for (int i = 1; i <= n; i++) occ[s[i]].push_back(i);
    
    int odd = 0;
    
    for (int i = 0; i < 300; i++) odd += (occ[i].size()%2 == 1);
    
    if (odd > 1) { cout<<-1<<endl; return 0; }
    
    seg.clear();
    
    for (int i = 0; i < 300; i++) {
        int sz = occ[i].size();
        for (int j = 0; sz - 1 - j > j; j++) {
            seg.push_back( make_pair(occ[i][j], occ[i][sz - 1 - j]) );
            //cout<<occ[i][j]<<" , "<<occ[i][sz - 1 - j]<<endl;
        }
    }
    
    sort(seg.begin(), seg.end()); fill(seen, seen + maxn, false);
    
    for (int i = 0; i < seg.size(); i++) {
        a[i + 1] = seg[i].first; a[n - i] = seg[i].second;
        seen[seg[i].first] = true; seen[seg[i].second] = true;
    }
            
    for (int i = 1; i <= n; i++) if (!seen[i]) a[ (n + 1)/2 ] = i;
    
    /*for (int i = 1; i <= n; i++) cout<<a[i]<<" ";
    cout<<endl;*/
    
    fill(bit, bit + maxn, 0); long long ans = 0;
    
    for (int i = 1; i <= n; i++) {
        ans += i - 1 - qry(a[i]); upd(a[i], 1);
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 9548