akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vector<vector<int>> g(N);
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    auto dfs = [&](auto f, int v, int p) -> int {
        int ret = 0;
        FORE(w, g[v]) {
            if (w == p) continue;
            ret ^= f(f, w, v) + 1;
        }
        return ret;
    };
    cout << (dfs(dfs, 0, -1) == 0 ? "Bob" : "Alice") << endl;
    return (0^_^0);
}



Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<string> w(n);
  set<string> S;
  int si;
  rep(i,n){
    cin>>w[i];
  }
  rep(i,n){
    int si2=0;
    si=S.size();
    S.insert(w[i]);
    if(i==0){
      continue;
    }
    si2=S.size();
    if(si!=si2){
      si=w[i-1].size();
      if(w[i-1][si-1]!=w[i][0]){
        cout<<"No"<<'\n';
        return(0);
      }
    }
    else{
      cout<<"No"<<'\n';
      return(0);
    }
  }
  cout<<"Yes"<<'\n';
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <cassert>
#include <ctime>
#define rep(i,m,n) for(i=m;i<=(int)n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define ls rt<<1
#define rs rt<<1|1
#define sys system("pause")
const int maxn=1e5+10;
const int N=1e2+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,m,k,t,a[maxn],c,d,pos[maxn];
ll fac[maxn],inv[maxn];
void init()
{
    fac[0]=1;
    for(int i=1;i<=maxn-10;i++)fac[i]=fac[i-1]*i%mod;
    inv[maxn-10]=qpow(fac[maxn-10],mod-2);
    for(int i=maxn-11;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
}
ll C(int x,int y)
{
    if(x<y||x<0||y<0)return 0;
    return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main()
{
    int i,j;
    init();
    scanf("%d",&n);
    rep(i,1,n+1)
    {
        scanf("%d",&a[i]);
        if(pos[a[i]])c=pos[a[i]],d=i;
        pos[a[i]]=i;
    }
    rep(i,1,n+1)
    {
        if(i==1)printf("%d\n",n);
        else
        {
            ll ret=C(n-1,i);
            (ret+=(C(n-1,i-1)*2%mod-C(c+n-d,i-1)+mod))%=mod;
            (ret+=C(n-1,i-2))%=mod;
            printf("%lld\n",ret);
        }
    }
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void) {
	int N;
	cin >> N;
	ll x;
	cin >> x;
	ll mn = x;
	ll ans = -2 * 1e9;
	for (int i = 1; i < N; ++i) {
		ll x;
		cin >> x;
		ans = max(ans, x - mn);
		mn = min(mn, x);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3096
p=1
m=10**9+7
s=[0]*2
n=int(input())
q=sorted([[int(input()),i//n]for i in range(2*n)])
for i in q:
    if s[1-i[1]]==0:
        s[i[1]]+=1
    else:
        p=(p*s[1-i[1]])%m
        s[1-i[1]]-=1
print(p)

Measured memory_bytes: 32312
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl

/*--------------------template--------------------*/

int main() {
    cin >> n >> k;
    vi v(n);
    REP(i, n) {
        cin >> v[i];
    }
    if (n == k) {
        cout << 1 << endl;
        return 0;
    }
    n -= k;
    ans++;
    k -= 1;
    ans += (n + k - 1) / k;
    cout << ans << endl;
}

Measured memory_bytes: 1024
from fractions import gcd
mod = 10**9+7
def lcm(a,b):
  return a*b//gcd(a,b)
def inv(a):
  return pow(a,mod-2,mod)
n = int(input())
a = list(map(int,input().split()))
f = [inv(a[i]) for i in range(n)]
x = 1
for i in range(n):
  x = lcm(x,a[i])
print(x%mod*sum(f)%mod)

Measured memory_bytes: 67816
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int RSPtoPnt(char jan, int r, int s, int p, string &st){
	if(jan == 'r'){
		st += 'p';
		return p;
	}
	if(jan == 's'){
		st += 'r';
		return r;
	}
	if(jan == 'p'){
		st += 's';
		return s;
	}
}

char win(char jan){
	if(jan == 'r') return 'p';
	if(jan == 's') return 'r';
	if(jan == 'p') return 's';
}

int main(void) {
	int n,k; cin >> n >> k;
	int r,s,p; cin >> r >> s >> p;
	string t; cin >> t;
	int ans = 0;
	string st;
	rep(i,n){
		if(i<k){
			ans += RSPtoPnt(t[i],r,s,p,st);
//			out(ans);
//			out(st);
			continue;
		}
		if(win(t[i])==st[i-k]){
			if(i+k<n){
				st += t[i+k];
				continue;
			}
			st += 'r';
//			out(ans);
//			out(st);
			continue;
		}
		ans += RSPtoPnt(t[i],r,s,p,st);
//		out(ans);
//		out(st);
	}
	out(ans);

}




Measured memory_bytes: 640
#include <stdio.h>

int main(void) 
{
  int n, x, min, max;
  long sum;
  int i;

  scanf("%d", &n);
  scanf("%d", &x);
  min = max = sum = x;
  for (i = 1; i < n; i++) {
    scanf("%d", &x);
    sum += x;
    if (max < x) max = x;
    if (min > x) min = x;
  }
  printf("%d %d %ld\n", min, max, sum);

  return 0;
}

Measured memory_bytes: 600
N = int(input())
L = list(map(int,input().split()))
accum = 0
cnt = 0
for i in range(N):
    accum += L[i]
    if i % 2 == 0 and accum <= 0:
        cnt += 1 - accum
        accum += (1 - accum)
    if i % 2 == 1 and accum >= 0:
        cnt += accum - (-1)
        accum -= (accum + 1)
  #  print(cnt,accum,"1")
ans = cnt
accum = 0
cnt = 0
for i in range(N):
    accum += L[i]
    if i % 2 == 1 and accum <= 0:
        cnt += 1 - accum
        accum += 1 - accum
    if i % 2 == 0 and accum >= 0:
        cnt += accum - (-1)
        accum -= accum + 1
  #  print(cnt,accum)
ans = min(ans,cnt)
print(ans)


Measured memory_bytes: 63344
#include<iostream>
#include<string>

using namespace std;

int main() {
	int A, B, C;		cin >> A >> B >> C;

	if (A == B) {
		cout << C << endl;
		return 0;
	}
	else if (B == C) {
		cout << A << endl;
		return 0;
	}
	
	cout << B << endl;

	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scanner()
	idxs := make([]int, 0)
	r := make([]rune, 0)
	for i, v := range s {
		if string(v) != "x" {
			idxs = append(idxs, i)
			r = append(r, v)
		}
	}
	f := true
	for i := 0; i < len(r)/2; i++ {
		if r[i] != r[len(r)-i-1] {
			f = false
		}
	}
	if len(r) == 0 {
		fmt.Println(0)
	} else if f {
		y := len(r) / 2
		if len(r)%2 == 0 {
			y = len(r)/2 - 1
		}
		x1 := make([]int, 0)
		x2 := make([]int, 0)
		for i := y; i > 0; i-- {
			x1 = append(x1, idxs[i]-idxs[i-1])
		}
		if len(r)%2 == 0 {
			y = len(r) / 2
		}
		for i := y; i < len(r)-1; i++ {
			x2 = append(x2, idxs[i+1]-idxs[i])
		}
		ans := 0
		for i := 0; i < len(x2); i++ {
			ans += abs(x1[i] - x2[i])
		}
		ans += abs(idxs[0] - (len(s) - 1 - idxs[len(r)-1]))
		fmt.Println(ans)
	} else {
		fmt.Println(-1)
	}
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = 2000000000;
  for (int i = -100; i <= 100; i++) {
    int x = 0;
    for (int j = 0; j < n; j++) {
      int temp = abs(a[j] - i);
      x += temp * temp;
    }
    ans = min(ans, x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
use v5.18;
use warnings;
use List::Util qw( reduce );

sub get_str {
  chomp(my $str = <>);
  $str;
}

my ($ball_num, $color_num) = split / /, get_str;
say reduce { $a * $b } map { $_ == 0 ? $color_num : $color_num - 1 } 0 .. $ball_num - 1;


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;
int N,K,maxi=0,ans=0;
vector<int> G[MAX],dis(MAX);

void DFS(int u,int p){
    for(int i=0;i<G[u].size();i++){
        int a=G[u][i];
        if(a==p) continue;
        DFS(a,u);
        dis[u]=max(dis[u],dis[a]+1);
    }
    if(u==0) return;
    
    if(p==0){
        if(dis[u]==K){
            ans++;
            //cout<<u<<endl;
            dis[u]=-1;
        }
    }else{
        if(dis[u]==K-1){
            ans++;
            //cout<<u<<endl;
            dis[u]=-1;
        }
    }
}

int main(){
    
    cin>>N>>K;
    int a;cin>>a;
    if(a!=1) ans++;
    for(int i=1;i<N;i++){
        int a;cin>>a;
        a--;
        G[a].push_back(i);
        //G[i].push_back(a);
    }
    DFS(0,-1);
    
    cout<<ans<<endl;
    
    
}





Measured memory_bytes: 13952
import re
S=input()
flg=True
if re.match(r"^[^A]",S):
  flg=False
if len(re.findall(r"C",S[2:-1])) != 1:
  flg=False
for i in range(1,len(S)):
  if S[i]!="C" and S[i].isupper():
    flg=False
print("AC" if flg else "WA")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	// your code goes here
	string s;
	cin>>s;
	sort(s.begin(),s.end());
	if(s[0]==s[2])
	{
		cout<<"No";	
	}
	else
	{
		cout<<"Yes";
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.InputStreamReader
import java.io.BufferedReader

//
fun _Do(){
    
    val scanEx = ScannerEx()
    
    //
    val X = scanEx.nextInt()
    val k = scanEx.nextInt()
    //val ia = scanEx.ints()

    println(Math.max(0,X-k))
}

//
fun main( argv : Array<String> ) {
    _Do()
}

//
class ScannerEx {
    fun nextString():String{
        if( idx == 0 || strings.size <= idx)
        {
            idx = 0
            strings = bufferedReader.readLine().split(' ')
        }
        var v = strings[idx]!!
        idx += 1
        return v
    }
    fun nextInt():Int{
        if( idx == 0 || strings.size <= idx )
        {
            idx = 0
            strings = bufferedReader.readLine().split(' ')
        }
        var v = strings[idx]!!.toInt()
        idx += 1
        return v
    }
    fun nextLong():Long{
        if( idx == 0 || strings.size <= idx)
        {
            idx = 0
            strings = bufferedReader.readLine().split(' ')
        }
        var v = strings[idx]!!.toLong()
        idx += 1
        return v
    }
    private var idx:Int = 0 //
    private var strings:List<String?> = emptyList()   //
    fun strings(): Array<String> {
        val strings = bufferedReader.readLine().split(' ')
        return Array(strings.size, { strings[it] })
    }
    fun ints(): Array<Int> {
        val strings = bufferedReader.readLine().split(' ')
        return Array(strings.size, { strings[it].toInt() })
    }
    fun longs(): Array<Long> {
        val strings = bufferedReader.readLine().split(' ')
        return Array(strings.size, { strings[it].toLong() })
    }
    private var bufferedReader = BufferedReader(InputStreamReader(System.`in`))
}


Measured memory_bytes: 35872
#include<stdio.h>
int main()
{
    int a,b,c,temp;
    scanf("%d %d %d",&a,&b,&c);
    if(b<c)
    {
        temp=b;
        b=c;
        c=temp;
    }
    if(a<b)
    {
        temp=a;
        a=b;
        b=temp;
    }
    if(b<c)
    {
        temp=b;
        b=c;
        c=temp;
    }
Solution:

    int s=(a-b)+(b-c);
    printf("%d\n",s);
    return 0;

}


Measured memory_bytes: 128
#include<stdio.h>

int main(){
  int i,j,k,n,u,v;
  int mat[101][101];

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++) mat[i][j]=0;
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      mat[u][v]=1;
    }
  }
  
  
  for(i=1;i<=n;i++){
    for(j=1;j<n;j++) printf("%d ",mat[i][j]);
    printf("%d\n",mat[i][j]);
  }
  
  return 0;
  
}



Measured memory_bytes: 2112
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<ll, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, m, s;
bool lck[MAXN][5010];
ll dp[MAXN][5010];
ll c[MAXN], d[MAXN];
vector<III> a[MAXN];
ll MAX = 1000000000000000000LL;
priority_queue<III, vector<III>, greater<III> > h;

void ijk() {
    FOR(i,1,n) FOR(j,0,5000) lck[i][j] = false;
    FOR(i,1,n) FOR(j,0,5000) dp[i][j] = MAX;
    dp[1][s] = 0;
    h.push(III(II(0, 1), s));
    while (1) {
        while (!h.empty() && h.top().FI.FI != dp[h.top().FI.SE][h.top().SE]) h.pop(); 
        if (h.empty()) break;
        int u = h.top().FI.SE, x = h.top().SE;
        h.pop();
        lck[u][x] = true;
        int w = min(int(x + c[u]), 5000);
        if (lck[u][w] == false && dp[u][w] > dp[u][x] + d[u]) {
            dp[u][w] = dp[u][x] + d[u];
            h.push(III(II(dp[u][w], u), w));
        }
        for (III r : a[u]) {
            int v = r.FI.FI, A = r.FI.SE, B = r.SE;
            if (x - A < 0) continue;
            if (lck[v][x-A] == false && dp[v][x-A] > dp[u][x] + B) {
                dp[v][x-A] = dp[u][x] + B;
                h.push(III(II(dp[v][x-A], v), x-A));
            }
        } 
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m >> s;
    s = min(s, 5000);
    FOR(i,1,m) {
        int u, v, g, h;
        cin >> u >> v >> g >> h;
        a[u].push_back(III(II(v, g), h));
        a[v].push_back(III(II(u, g), h));
    }
    FOR(i,1,n) cin >> c[i] >> d[i];
    ijk();
    FOR(i,2,n) {
        ll res = MAX;
        FOR(j,0,5000) res = min(res, dp[i][j]);
        cout << res << "\n";
    }
    return 0;
}


Measured memory_bytes: 11732
#include<iostream>
using namespace std;
int main() {
	//abc147_c
	int n;
	cin >> n;
	int bin[17];
	bin[0] = 1;
	int i, j, k;
	int x[16][16], y[16][16], a[16];
	for (i = 0; i < n; i++) {
		cin >> a[i];
		for (j = 0; j < a[i]; j++) {
			cin >> x[i][j] >> y[i][j];
			x[i][j]--;
		}
	}
	//cout << y[0][0] << ' ' <<y[1][0] << ' ' << y[2][0] << endl;
	int maxo = 0, c, flag, flag2;

	for (i = 1; i <= 16; i++)bin[i] = 2 * bin[i - 1];
	for (i = bin[n] - 1; i >= 0; i--) {
		c = 0;
		flag = 0;
		for (j = 0; j < n; j++) {
			if ((i ^ bin[j]) != (i + bin[j])) {
				c++;
				
			}
			//if (flag == 1)break;
		}
		if (c < maxo) {
			flag = 1;
		}
		//cout << "c = " << c << ", flag = " << flag << endl;
		flag2 = 0;
		if (flag == 0) {

			for (j = 0; j < n; j++) {
				if ((i ^ bin[j]) != (i + bin[j])) {
					//j番は正直者
					//cout << "i = " << i << ". j = " << j << endl;
					for (k = 0; k < a[j]; k++) {
						//cout << "i = " << i << ". j = " << j << endl;
						if (y[j][k] == 1) {
							if ((i ^ bin[x[j][k]]) == (i + bin[x[j][k]])) {
								flag2 = 1;
								//cout << "i = " << i << ", j = " << j << ", k = " << k << endl;
							}
						}
						else {
							if ((i ^ bin[x[j][k]]) != (i + bin[x[j][k]])) {
								flag2 = 1;
								//cout << "i = " << i << ", j = " << j << ", k = " << k << endl;
							}
						}
					}
				}
			}
			//cout << "i = " << i << ", c = " << c << ", flag2 = " << flag2 << endl;

			if (flag2 == 0) {
				maxo = c;
			}
		}
		//cout << "i = " << i << ", c = " << c << ", flag2 = " << flag2 << endl;
		//cout << "maxo = " << maxo << endl;



	}
	cout << maxo << endl;
	return 0;

}

Measured memory_bytes: 3604
using System;
public class Hello{
    public static void Main(){
        var N = int.Parse(Console.ReadLine());
        var C = Console.ReadLine();
        var ans = 0;
        for(var i = 0;i<=N;i++){
            if(i >= N) break;
            //Console.WriteLine("i = {0}",i);
            if(C[i] == 'W'){
                for(var n = N;n>i;N--,n--){
                    if(i >= N) break;
                    //Console.WriteLine("N = {0}",n);
                    if(C[n-1] == 'R'){
                        ans++;
                        N--;
                        break;
                    }
                    
                }
            }
        }
        Console.Write(ans);
    }
}


Measured memory_bytes: 28280
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,ll>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=2005;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,k,ans,a[MAXN],b[MAXN];
vector<int>G[MAXN];
void dfs(int x,int fa,int d,int l){if(d>l)ans++;for(auto y:G[x])if(y!=fa)dfs(y,x,d+1,l);}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),k=read();
	Rep(i,1,n-1)a[i]=read(),b[i]=read(),G[a[i]].pb(b[i]),G[b[i]].pb(a[i]);
	if(k&1){
		int Mn=n;
		Rep(i,1,n-1)ans=0,dfs(a[i],b[i],0,k>>1),dfs(b[i],a[i],0,k>>1),Mn=min(Mn,ans);
		cout<<Mn<<'\n';
	}else{
		int Mn=n;
		Rep(i,1,n)ans=0,dfs(i,0,0,k>>1),Mn=min(Mn,ans);
		cout<<Mn<<'\n';
	}
	return 0;
}




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

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()
#define INF (int)1e9
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
ll n;
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);

    cin >> n;
    vll a(n + 1);
    for (ll i = 1; i <= n; ++i)
        for (ll j = i; j <= n; j += i)
            ++a[j];

    ll ans = 0;
    for (ll i = 1; i <= n; ++i)
        ans += (a[i]) * i;

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 81316
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

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

	cout<<n*(n-1)/2<<endl;

	return 0;
}



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

int dp[100001][4];

int n;
void fillarray()
{
	int i,j;
	for(i=0;i<=100000;i++)
	{
		for(j=0;j<=3;j++)
		dp[i][j] = -1;
	}
}
int solve(int a[] , int b[], int c[],  int i , int last)
{
	if(i == n)
	return 0;

	
	if(dp[i][last] >= 0)
	return dp[i][last];
	
	int val = 0;
	
	if(last != 1)
	val = max(val ,  a[i] + solve(a , b , c, i + 1 , 1));
	
	if(last != 2)
	val = max( val , b[i] + solve(a ,b ,c  , i + 1 , 2));
	
	if(last != 3)
	val = max( val ,c[i] + solve(a , b , c , i + 1 , 3));
	
	dp[i][last] = val;
	return val;
}
main()
{
	cin>>n;
	int a[n],b[n],c[n];
	int i,j;
	
	fillarray();
	
	for(i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	
	cout<<solve(a , b , c, 0,0);
	
}

Measured memory_bytes: 12288
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			int[] s=new int[n];
			for(int i=0;i<n;i++){
				s[i]=sc.nextInt();
			}
			int[] answer=calc(s,0);
			System.out.println(answer[answer.length-1]);
			for(int i=0;i<n-1;i++){
				System.out.print(answer[i]+" ");
			}
			System.out.println(answer[n-1]);
		}
	}
	static int[] calc(int[] s,int count){
		int[] check=new int[s.length];
		for(int i=0;i<check.length;i++){
			for(int j=0;j<check.length;j++){
				if(s[i]==s[j]){
					check[i]++;
				}
			}
		}
		boolean flag=true;
		for(int i=0;i<check.length;i++){
			if(s[i]!=check[i]){
				flag=false;
				break;
			}
		}
		if(flag){
			int[] answer=new int[check.length+1];
			for(int i=0;i<answer.length-1;i++){
				answer[i]=check[i];
			}
			answer[answer.length-1]=count;
			return answer;
		}else{
			return calc(check,count+1);
		}
	}
}

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

const int MAX= 1E5+5;
const int MAXN = 205;
const int MOD = 1E9+7;

int n, X;
vector<int> a(MAXN);
int f[MAXN][MAX];

int dp(int i, int cur){
	int& ret = f[i][cur];
	if(ret != -1) return ret;
	if(i==0) return ret = (cur < a[1]? cur : 0);
	ret = (dp(i-1, cur%a[i]) + (i-1)*dp(i-1, cur))%MOD;
	return ret;
}

signed main() {
	cin >> n >> X;
	for(int i=1; i<= n; ++i) cin >> a[i];
	sort(a.begin()+1, a.begin()+n+1);
	memset(f, -1, sizeof f);
	cout << dp(n, X);
	return 0;
}

Measured memory_bytes: 160384
#include<bits/stdc++.h>
using namespace std;
#define nl '\n' 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pii pair <int,int>
ll mod=1000000007;
int main()
{
	fast;
	int n;cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		int x;cin>>x;
		a[x]=i;
	}
	for(int i=1;i<=n;i++)cout<<a[i]<<" ";
}

Measured memory_bytes: 3936
#include<iostream>

int main() {
  int depth, width;
  int map[10][10];

  //reading a given map
  std::cin >> depth >> width;

  while(depth != 0 && width != 0) {
    //map initialization
    for(int i=0; i<10; i++)
      for(int j=0; j<10; j++) {
        map[i][j] = -1;
    }

    for(int i=0; i<depth; i++)
      for(int j=0; j<width; j++) {
        std::cin >> map[i][j];
    }

    int max_cap = 0;
    for(int level=1; level<10; level++)
      for(int i=1; i<depth-1; i++)
        for(int j=1; j<width-1; j++) {
          if(map[i][j] < level && map[i-1][j] >= level && map[i][j-1] >= level && map[i-1][j-1] >= level) {
            int i_start=i, j_start=j, i_start2, j_start2, i_end, j_end;
            int ii, jj;
            int flag = 0;

            //std::cout << "level:" << level << " i_s:" << i_start << " j_s:"<< j_start << std::endl;

            for(jj=j_start; map[i_start][jj+1] < level; jj++) {
              if(map[i_start-1][jj] < level || jj==width-1) { flag = 1; break; }
            }
            if(flag==1 || map[i_start-1][jj] < level || map[i_start-1][jj+1] < level) { continue; }
            else { j_end = jj; }
            //std::cout << "j_e:" << j_end << std::endl;

            for(ii=i_start; map[ii+1][j_end] < level; ii++) {
              if(map[ii][j_end+1] < level || ii==depth-2) { flag = 1; break; }
            }
            if(flag==1 || map[ii][j_end+1] < level || map[ii+1][j_end+1] < level) { continue; }
            else { i_end = ii; }
            //std::cout << "i_e:" << i_end << std::endl;

            for(jj=j_end; map[i_end][jj-1] < level; jj--) {
              if(map[i_end+1][jj] < level || jj==1) { flag = 1; break; }
            }
            if(flag==1 || map[i_end+1][jj] < level || map[i_end+1][jj-1] < level) { continue; }
            else { j_start2 = jj; }
            //std::cout << "j_s2:" << j_start2 << std::endl;

            for(ii=i_end; map[ii-1][j_start2] < level; ii--) {
              if(map[ii][j_start2-1] < level || ii==1) { flag = 1; break; }
            }
            if(flag==1 || map[ii][j_start2-1] < level || map[ii-1][j_start2-1] < level) { continue; }
            else { i_start2 = ii; }
            //std::cout << "i_s2:" << i_start2 << std::endl;

            if(i_start != i_start2 || j_start != j_start2) { continue; }

            int cap = 0;
            for(ii=i_start; ii<=i_end; ii++) {
              for(jj=j_start; jj<=j_end; jj++) {
                if(map[ii][jj] >= level) { flag = 1; break; }
                cap = cap + (level - map[ii][jj]);
              }
              if(flag==1) { break; }
            }
            if(flag==1) { continue; }

            if(max_cap < cap) max_cap = cap;
          }
    }

    std::cout << max_cap << std::endl;

    std::cin >> depth >> width;
  }

  return 0;
}



Measured memory_bytes: 3096
// go:generate go-assets-builder > assets.go

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Split(bufio.ScanLines)
	n := readInt()
	k := readInt()
	h := make([]int, 0, n)
	for i := 0; i < n; i++ {
		h = append(h, readInt())
	}
	sort.Sort(sort.IntSlice(h))
	minInt := math.MaxInt64
	for i := 0; i < n-k+1; i++ {
		abs := h[i+k-1] - h[i]
		if abs == 0 {
			fmt.Println(0)
			return
		}
		minInt = min(minInt, abs)
	}
	fmt.Println(minInt)
}

//便利関数群
var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	i, _ := strconv.Atoi(read())
	return i
}

func max(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func min(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

func abs(x, y int) int {
	if x-y > 0 {
		return x - y
	}
	return -(x - y)
}

type XY struct {
	x, y int
}

type Points []XY

func (p Points) Len() int {
	return len(p)
}
func (p Points) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}
func (p Points) Less(i, j int) bool {
	return p[i].x < p[j].x
}
func (p Points) remove(i int) Points {
	if i >= len(p) {
		return p
	}
	return append(p[:i], p[i+1:]...)
}


Measured memory_bytes: 3072
use std::io;
fn div(h: i64) -> i64 {
    let a = h / 2;
    if a == 0 {
        return 1;
    } else {
        return div(a) * 2 + 1;
    }
}
fn main() {
    let h = {
        let mut inp = String::new();
        io::stdin().read_line(&mut inp).unwrap();
        inp.split_whitespace()
            .next()
            .unwrap()
            .parse::<i64>()
            .unwrap()
    };
    println!("{}", div(h));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
int N;
bool can[10][24*60*60];
int MAX = 24*60*60;
int factor[3] = {3600, 60, 1};
int num[10];

string f(ll x) {
    string ret;
    ll tmp = x / 3600;
    string T = to_string(tmp);
    if(T.size() == 1) T = "0" + T;
    ret = ret + T + ":";
    tmp = x / 60;
    tmp %= 60;
    T = to_string(tmp);
    if(T.size() == 1) T = "0" + T;
    ret = ret + T + ":";
    tmp = x;
    tmp %= 60;
    T = to_string(tmp);
    if(T.size() == 1) T = "0" + T;
    ret = ret + T;
    return ret;
}

void solve() {
    for(int i = 0; i < 10; i++) {
        assert(num[i] == 0);
        for(int j = 0; j < MAX; j++) {
            can[i][j] = false;
        }
    }
    for(int i = 0; i < N; i++) {
        vector<int> v(3);
        for(int j = 0; j < 3; j++) cin >> v[j];
        sort(v.begin(), v.end());
        do {
            for(int k = 0; k < 60; k++) {
                vector<int> w(3);
                for(int j = 0; j < 3; j++) {
                    w[j] = (v[j] + k) % 60;
                }
                for(int t = 0; t < MAX; t++) {
                    int a = t / 720;
                    a %= 60;
                    if(a != w[0]) continue;
                    a = t / 60;
                    a %= 60;
                    if(a != w[1]) continue;
                    a = t;
                    a %= 60;
                    if(a != w[2]) continue;
                    can[i][t] = true;
                }
            }
        } while(next_permutation(v.begin(), v.end()));
    }
    int ansl = 0;
    int ansr = MAX - 1;
    int ansinterval = MAX;
    int r = -1;
    for(int l = 0; l < MAX; l++) {
        while(true) {
            if(r == MAX) break;
            bool ok = true;
            for(int j = 0; j < N; j++) {
                if(num[j] == 0) ok = false;
            }
            if(ok) break;
            r++;
            if(r == MAX) break;
            for(int j = 0; j < N; j++) {
                if(can[j][r]) num[j]++;
            }
        }
        for(int j = 0; j < N; j++) {
            if(can[j][l]) num[j]--;
        }
        if(r == MAX) continue;
        int interval = r - l;
        if(chmin(ansinterval, interval)) {
            ansl = l;
            ansr = r;
        }
        //cerr << l << " " << r << endl;
    }
    cout << f(ansl) << " " << f(ansr) << endl;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> N) {
        if(N == 0) break;
        solve();
    }
    return 0;
}


Measured memory_bytes: 4152
fn bfs(map: &Vec<Vec<char>>, start: (i64, i64), goal: (i64, i64)) -> usize {
    let (maxh, maxw) = (map.len() as i64, map[0].len() as i64);
    let mut dist = vec![vec![std::i64::MAX; maxw as usize]; maxh as usize];
    let dhw = [(0, 1), (1, 0)];
    let mut queue = std::collections::VecDeque::new();
    if map[start.0 as usize][start.1 as usize] == '#' {
        queue.push_back((start, 1, true));
    } else {
        queue.push_back((start, 0, false));
    }
    while let Some((position, num, con)) = queue.pop_front() {
        if position == goal {
            return num as usize;
        }
        if dist[position.0 as usize][position.1 as usize] > num {
            dist[position.0 as usize][position.1 as usize] = num;
            for d in &dhw {
                let next = (position.0 + d.0, position.1 + d.1);
                if (next.0 < maxh && 0 <= next.0) && (next.1 < maxw && 0 <= next.1) {
                    if map[next.0 as usize][next.1 as usize] == '.' {
                        queue.push_front((next, num, false));
                    } else if map[next.0 as usize][next.1 as usize] == '#' {
                        if con {
                            queue.push_front((next, num, true));
                        } else {
                            queue.push_back((next, num + 1, true));
                        }
                    }
                }
            }
        }
    }
    unreachable!()
}

fn main() {
    let (h, w): (i64, i64) = (read(), read());
    let mut map: Vec<Vec<char>> = vec![];
    let start: (i64, i64) = (0, 0);
    let goal: (i64, i64) = (h - 1, w - 1);
    for _ in 0..h {
        let row: Vec<char> = read::<String>().chars().collect();
        map.push(row);
    }
    println!("{}", bfs(&map, start, goal));
}

// =========

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

// =========


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

#define st first
#define nd second
typedef long long LL;
typedef long double LLD;
typedef pair <int, int> PII;
typedef pair <LL, LL> PLL;

unordered_map < int, int > P;

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

    LL result = 0LL;
    int sum = 0;
    P[0] = 1;
    
    for (int i = 0; i < n; ++i)
    {
        int a;
        scanf("%d", &a);
        sum = (sum + a) % m;
        result += 1LL * P[sum]++;
    }    

    printf("%lld", result);

    return 0;
}

Measured memory_bytes: 3596
a, b, c, d = map(int, input().split())

arr = [a, b, c]
n = len(arr)

ans = "Yes"

for i in range(n):
    m = abs(arr[(i + 1) % n] - arr[i])

    if i != n - 1:
        if m > d:
            ans = "No"
    else:
        if m <= d:
            ans = "Yes"

print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var Rdx = ReadLine().Split().Select(long.Parse).ToArray();
        var r = Rdx[0];
        var d = Rdx[1];
        var x = Rdx[2];

        long last = x;
        for (int i = 0; i < 10; i++)
        {
            last = r * last - d;
            WriteLine(last);
        }
    }
}


Measured memory_bytes: 27940
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
std::vector<string> v ;
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
void permute(string str, string out) 
{ 
    // When size of str becomes 0, out has a 
    // permutation (length of out is n) 
    if (str.size() == 0) 
    { 
        v.pb(out); 
        return; 
    } 
  
    // One be one move all characters at 
    // the beginning of out (or result) 
    for (int i = 0; i < str.size(); i++) 
    { 
        // Remove first character from str and 
        // add it to out 
        permute(str.substr(1), out + str[0]); 
  
        // Rotate string in a way second character 
        // moves to the beginning. 
        rotate(str.begin(), str.begin() + 1, str.end()); 
    } 
}
int main()
{
    fastio();
    ll n,m;
    cin>>n>>m;
    ll a[n];
    cn(a,n);
    ll c=0,x=a[0];
    while(x%2==0)
    {
        x=x/2;
        c++;
    }
    for(int i=0;i<n;i++)
    {
        x=a[i];
        ll d=0;
        while(x%2==0)
        {
            x=x/2;
            d++;
        }
        if(c!=d)
        {
            cout<<0<<endl;
            return 0;
        }
    }
    for(int i=0;i<n;i++)
    {
        a[i] = a[i]/2;
    }
    ll lcm=a[0];
    for(int i=1;i<n;i++)
    {
        lcm = (a[i]*lcm)/gcd(a[i],lcm);
        if(lcm>m)
        {
            cout<<0<<endl;
            return 0;
        }
    }
    ll ans= (m/lcm+1)/2;
    cout<<ans<<endl;
    
    
}

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

int main(){
    int N,A,B;
    cin>>N>>A>>B;
    int P[1000];
    int nums=0,numm=0,numl=0;
    for(int i=0;i<N;i++){
        cin>>P[i];
        if(P[i]<=A) nums++;
        else if(B+1<=P[i]) numl++;
        else numm++;
    }
    cout<<min(nums,min(numl,numm));
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  for(int i=0;i<N;i++) cin>>A[i];

  vector<ll> ans(N,0);
  ll sum=0;
  for(int i=0;i<N;i++){
    if(i%2) sum-=A[i];
    else sum+=A[i];
  }

  for(int i=0;i<N;i++){
    ans[i]=sum;
    sum-=A[i];
    sum=sum*(-1);
    sum+=A[i];
  }

  for(int i=0;i<N;i++) cout<<ans[i]<<" ";
  cout<<endl;

  return 0;
}


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

int n, x, y;
const int mxn = 1e5 + 5;
vector<pair<int, int>> adj[mxn];
int col[mxn];

void dfs(int node, int parent, int pcol){
    int c = 1;
    for(pair<int, int> x : adj[node]){
        if(x.first == parent) continue;
        if(c == pcol) c++;
        col[x.second] = c;
        dfs(x.first, node, c);
        c++;
    }
}

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

    //good luck, kittu
    cin>>n;
    for(int i = 0; i<n-1; i++){
        cin>>x>>y;
        adj[x].push_back({y, i});
        adj[y].push_back({x, i});
    }

    int k = -1;
    for(int i = 1; i<=n; i++) k = max(k, int(adj[i].size()));
    cout<<k<<"\n";

    dfs(1, -5, -5);
    for(int i = 0; i<n-1; i++) cout<<col[i]<<"\n";
    return 0;
}


Measured memory_bytes: 9344
from sys import stdin

# 標準入力の受取
# sdi = stdin.readline().rstrip()
# a, b, c = stdin.readline().rstrip().split()
# a, b, c = [x for x in stdin.readline().rstrip().split()]
a, b, c = [int(x) for x in stdin.readline().rstrip().split()]
i = max(a, b)
answer = 0
hit = 0
while 1:
    if a % i == 0 and b % i == 0:
        r = i
        hit += 1
    if hit == c:
        break
    i -= 1

print(r)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path;
//***********//

int main() {
	cin >> H >> N;
	vl A(N);
	for (i = 0; i < N; i++) {
		cin >> A[i];
		ans += A[i];
	}
	if (ans >= H) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}


Measured memory_bytes: 1024
#include <iostream>

int main()
{
    long long  n,m,k; std::cin >> n >> m >> k;
    long long  a[200001], b[200001];
    // std::vector<long long>  a(n+1), b(m+1);
    a[0]=0; b[0]=0;
    for (int i=1;i<n+1;i++)
        std::cin >> a[i];
    for (int i=1; i<m+1; i++)
        std::cin >> b[i];
    
    for (int i=1; i<n+1; i++)
        a[i]+=a[i-1];
    for (int i=1; i<m+1; i++)
        b[i]+=b[i-1];

    long long ans=0, r=m;
    for (int i=0; i<n+1; i++)
    {
        if(a[i]>k) break;
        while (a[i]+b[r]>k)
            r--;
        ans = ans>=i+r?ans:i+r;
    }
    
    std::cout << ans;

    return 0;
}

Measured memory_bytes: 6760
#include<iostream>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

int main() {
  int c, r; cin >> c >> r;
  int table[110][110] = {0};
  REP(i, c) {
    int trow = 0;
    REP(j, r) {
      int v; cin >> v;
      trow += v;
      table[i][j] = v;
      table[c][j] += v;
      table[c][r] += v;
    }
    table[i][r] = trow;
  }
  REP(i, c + 1) {
    REP(j, r + 1) {
      if (j > 0) cout << ' ';
      cout << table[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 3128
a, b = map(int, input().split())
x = 300000
y = 200000
z = 100000
A = [x, y, z]
for i in range(1000):
    A.append(0)

a_ = A[a-1]
b_ = A[b-1]

if a == 1 and b == 1:
    print(a_ + b_ + 400000) 
else:
    print(a_ + b_)

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

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


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

    int n; cin >> n;
    vector<int> cost(n-1), stay(n-1), interval(n-1);
    rep(i, n-1) cin >> cost[i] >> stay[i] >> interval[i];

    rep(i, n) {
        int time = 0;
        REP(j, i, n-1) {
            if(time < stay[j]) time = stay[j];
            else if(time%interval[j] == 0);
            else time += interval[j] - time%interval[j];

            time += cost[j];
        }
        cout << time << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
//ABC130B
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main(){
	int n;
	scanf("%d",&n);
	int w[n];
	int i, j, k, l;
	int s1, s2;
	int temp[n];
	int min;
	for(i=0;i<n;i++){
		scanf("%d",&w[i]);
	}
	for(i=1;i<n;i++){
		s1 = 0;
		s2 = 0;
		for(j=0;j<i;j++){
			s1 = s1 + w[j];
		}
		for(j=i;j<n;j++){
			s2 = s2 + w[j];
		}
		if(s1<s2){
			temp[i] = s2 - s1;
		}else{
			temp[i] = s1 - s2;
		}
	}
	min = temp[1];
	for(l=1;l<n-1;l++){
		if(temp[l]<temp[l+1]){
			min = min;
		}else{
			min = temp[l+1];
		}
	}
	printf("%d",min);
}

Measured memory_bytes: 128
N = int(input())
d = len(str(N))
if d==1:
    print(N)
elif d==2:
    print(9)
elif d==3:
    print(9+N-99)
elif d==4:
    print(909)
elif d==5:
    print(909+N-9999)
elif d==6:
    print(90909)

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

int main(void) {
  ll N, H, W;
  cin >> N >> H >> W;

  cout << (N - H + 1) * (N - W + 1) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
 int i,j,temp;
 int A[3];

 scanf("%d %d %d",&A[0],&A[1],&A[2]);
 for(j=1;j>=0;j--){
  for(i=0;i<=j;i++){
   if(A[i]>A[i+1]){
    temp=A[i];
    A[i]=A[i+1];
    A[i+1]=temp;
   }
  }
 }
 printf("%d %d %d\n",A[0],A[1],A[2]);

 return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

void swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main(void) {
	int a, b, c;
	
	scanf("%d %d %d", &a, &b, &c);
	
	// ??????????????????
	if (a > b) swap(&a, &b);
	if (b > c) swap(&b, &c);
	if (a > b) swap(&a, &b);
	
	printf("%d %d %d\n", a, b, c);
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000

typedef unsigned long long ull;

using namespace std;

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

    int A, B;
    cin >> A >> B;

    for (int i = A; i <= B; ++i) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;

    return 0;
}


Measured memory_bytes: 3636