akhauriyash/Code-Regression huggingface dataset:
h, w = map(int, input().split())
a = []
for i in range(h):
    a.append(list(map(int, input().split())))
move = []
b = [1, -1]
for i in range(h):
    for j in range(w):
        if j == w - 1:
            if i == h - 1:
                pass
            else:
                if a[i][j * b[i % 2] + (w - 1) * (i % 2)] % 2 == 1:
                    move.append([i + 1, j * b[i % 2] + (w - 1) * (i % 2) + 1, i + 2, j * b[i % 2] + (w - 1) * (i % 2) + 1])
                    a[i + 1][j * b[i % 2] + (w - 1) * (i % 2)] += 1
        else:
            if a[i][j * b[i % 2] + (w - 1) * (i % 2)] % 2 == 1:
                move.append([i + 1, j * b[i % 2] + (w - 1) * (i % 2) + 1, i + 1, (j + 1) * b[i % 2] + (w - 1) * (i % 2) + 1])
                a[i][(j + 1) * b[i % 2] + (w - 1) * (i % 2)] += 1
print(len(move))
for i in move:
    print(i[0], i[1], i[2], i[3])

Measured memory_bytes: 30272
import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str

isdelim(x::UInt8, xs::Set{UInt8}) = x in xs

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        if !isdelim(c, delims)
            break
        end
    end
    push!(out, c)
    if eof(s)
        return out
    end
    while !eof(s)
        c = read(s, UInt8)
        if isdelim(c, delims)
            break
        end
        push!(out, c)
    end
    return out
end

delimset = Set([0x0a, 0x20])

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

readvec(tys::Tuple , len::Signed)::Vector{Tuple{tys...}} = @inbounds Tuple{tys...}[reads(tys...) for i in 1:len]

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i = 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

function main()
    K, S = reads(Int, String)
    if length(S) <= K
        println("$S")
    else
        println("$(S[begin:K])...")
    end
end

main()


Measured memory_bytes: 188984
#include<iostream>
#include<string>
#include<queue>
#include<map>
using namespace std;
typedef pair<int,int> P;
int main(){
  string st[15],s;
  while(cin>>s){
    int i,j,k;
    st[0]="00000000000000";
    st[1]="0"+s+"0";
    for(i=0;i<11;i++){
      cin >> s;
      st[i+2]="0"+s+"0";
    }
    st[13]="00000000000000";
    int ans=0;
    for(i=1;i<=12;i++){
      for(j=1;j<=12;j++){
	if(st[i][j]=='1'){
	  ans++;
	  queue<P> q;
	  P p;
	  q.push(P(i,j));
	  while(!q.empty()){
	    p=q.front();q.pop();
	    if(st[p.first][p.second]=='0') continue;
	    st[p.first][p.second]='0';
	    int ax[]={1,-1,0,0};
	    int ay[]={0,0,1,-1};
	    for(k=0;k<4;k++){
	      if(st[p.first+ay[k]][p.second+ax[k]]=='1')
		q.push(P(p.first+ay[k],p.second+ax[k]));
	    }
	  }
	}
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main(){

   string s;
   cin>>s;
   if(s[2]==s[3]&&s[4]==s[5]){
       cout<<"Yes"<<endl;
   }
   else{
       cout<<"No"<<endl;
   }

}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
#define EPS 1e-10
int n;
double sx,sy,tx,ty,px[20],py[20];

double dis(double a,double b,double c,double d)
{return sqrt((a-c)*(a-c)+(b-d)*(b-d));}
double dis(int a,int b){return dis(px[a],py[a],px[b],py[b]);}

bool dfs(int S,int pos,double cost){
  if(S==(1<<n)-1)return true;
  for(int i=0;i<n;i++){
    if((S>>i)&1)continue;
    if(cost+dis(pos,i)>=dis(tx,ty,px[i],py[i]))return false;
  }
  for(int i=0;i<n;i++){
    if((S>>i)&1)continue;
    if(cost+dis(pos,i)>=dis(tx,ty,px[i],py[i]))continue;
    if( dfs(S|(1<<i),i,cost+dis(pos,i)) )return true;
  }
  return false;
}

bool solve(){
  for(int i=0;i<n;i++){
    if(dis(sx,sy,px[i],py[i])>=dis(tx,ty,px[i],py[i]))continue;
    if( dfs((1<<i),i,dis(sx,sy,px[i],py[i])) )return true;
  }
  return false;
}

int main(){
  while(1){
    cin>>n>>sx>>sy>>tx>>ty;
    if(n==0)break;
    for(int i=0;i<n;i++)cin>>px[i]>>py[i];
    cout<<(solve()?"YES":"NO")<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n, W;
int mx[4];
const int maxN = 105;
int w[maxN], v[maxN];
ll dp[maxN][maxN][3 * maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n >> W;
    for (int i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
    }
    for (int i = 0; i <= n; i++) {
        for (int cnt = 0; cnt <= n; cnt++) {
            for (int j = 0; j <= 3 * i; j++) {
                dp[i][cnt][j] = -1e18;
            }
        }
    }
    dp[0][0][0] = 0;
    ll ans = 0;
    for (int i = 0; i + 1 <= n; i++) {
        for (int j = 0; j <= i; j++) {
            for (int k = 0; k <= 3 * j; k++) {
                dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
                dp[i + 1][j + 1][k + w[i + 1] - w[1]] = max(dp[i + 1][j + 1][k + w[i + 1] - w[1]], dp[i][j][k] + v[i + 1]);
            }
        }
    }
    for (int cnt = 0; cnt <= n; cnt++) {
        for (int a = 0; a <= 3 * cnt; a++) {
            if (1LL * w[1] * cnt + a > W) continue;
            ans = max(ans, dp[n][cnt][a]);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 26880
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;

typedef long long ll;
ll INF = 1LL << 60;

int 
main() {

  int N, M; cin >> N >> M;
  vector<pair<int, int>> vec(N);
  rep(i, 0, N){
    vec[0].first = 0;
    vec[0].second= 0;
  }

  rep(i, 0, M){
    int p; cin >> p; p--;
    string s; cin >> s;
    if(s == "AC"){
      if(vec[p].first == 0){
        vec[p].first = 1;
      }
    } else{
      if(vec[p].first == 0){
        vec[p].second++;
      }
    }
  }
  int ans = 0;
  int wa = 0;
  rep(i, 0, N){
    if(vec[i].first == 1){
      ans++;
      wa += vec[i].second;
    }
  }

  cout << ans << " " << wa << endl;

}


Measured memory_bytes: 1024
using System;

class MyClass
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');
        int W = int.Parse(str[0]);
        int H = int.Parse(str[1]);
        int x = int.Parse(str[2]);
        int y = int.Parse(str[3]);
        int r = int.Parse(str[4]);
        if (x - r < 0 || x + r > W || y - r < 0 || y + r > H)
        {
            Console.WriteLine("No");
        }
        else
        {
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 19572
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(15) << fixed;

  ll n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll q; cin >> q;
  ll total = accumulate(all(a), 0LL);
  map<ll, ll> Counter;
  rep(i, n) Counter[a[i]]++;
  vector<ll> ans(q);
  rep(i, q) {
    ll b, c;
    cin >> b >> c;
    total = total + (c - b)*Counter[b];
    Counter[c] += Counter[b];
    Counter[b] = 0; 
    ans[i] = total;
  }
  for (ll i : ans) cout << i << endl;
}


Measured memory_bytes: 10800
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()

    ans = 0
    for i in range(1, N + 1):
        num = N // i
        e = num * i
        ans += (i + e) * num // 2

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10072
#define _CRT_SECURE_NO_WARNINGS
#define TASK "complex"
#pragma comment(linker, "/STACK:2010886400")
#include <cstdio>
#include <iostream>
#include <iomanip> 
#include <cmath>
#include <chrono>
#include <cstdlib>
#include <cstring>
#include <assert.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <random>
#include <complex>
using namespace std;

const int MOD = 1000000007;
const int INF = 1000000001;
const long double EPS = 1e-9;
const int HASH_POW = 29;
const long double PI = acos(-1.0);
mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

long long nextLong(long long l, long long r) {
	uniform_int_distribution <long long> foo(l, r);
	return foo(rnd);
}

double nextDouble(double l, double r) {
	uniform_real_distribution <double> foo(l, r);
	return foo(rnd);
}

double workTime() {
	return double(clock()) / CLOCKS_PER_SEC;
}

void myReturn(int code = 0) {
#ifdef MYDEBUG
	cout << "\nTime = " << fixed << setprecision(3) << workTime() << endl;
#endif
	exit(code);
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef MYDEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	/*freopen(TASK".in", "r", stdin);
	freopen(TASK".out", "w", stdout);*/
	/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);*/
#endif

	map <int, int> cnt;
	int n;
	cin >> n;
	while (n-- > 0) {
		int x;
		cin >> x;
		++cnt[x];
	}

	int ans = 0;
	for (auto it : cnt) {
		if (it.second >= it.first) {
			ans += it.second - it.first;
		}
		else {
			ans += it.second;
		}
	}
	printf("%d\n", ans);

	myReturn();
}

Measured memory_bytes: 4736
#include <stdio.h>

int main(void) {
	
		int W,H,x,y,r;
	
	
		scanf("%d",&W);
		scanf("%d",&H);
		scanf("%d",&x);
		scanf("%d",&y);
		scanf("%d",&r);
	
	if( 0 <= (x-r) && W >= (x+r) && 0 <= (y-r) && H >= (y+r)  ){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 584
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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

ll keta(ll n)
{
  ll k=0;
  while(n!=0)
  {
    n/=10;
    k++;
  }
  return k;
}  

int main() 
{
  ll N; cin>>N;
  ll ans=INF;
  for(ll a=1;a*a<=N;a++)
  {
    if(N%a==0)
    {
      chmin(ans,keta(N/a));
      //int b=1;
    }
    //cout<<a;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
	int n, m, q;
	int rui[501][501] = {};
	cin >> n >> m >> q;
	int l, r;
	for (int i = 0; i < m; ++i)
	{
		cin >> l >> r;
		++rui[l][r];
	}
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= n; ++j)
		{
			rui[i][j] += rui[i][j-1];
		}
	}
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= n; ++j)
		{
			rui[j][i] += rui[j-1][i];
		}
	}
	for (int Q = 0; Q < q; ++Q)
	{
		cin >> l >> r;
		int ma = max(l, r);
		int mi = min(l, r);
		cout << rui[ma][ma] - rui[ma][mi-1] - rui[mi-1][ma] + rui[mi-1][mi-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1920
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int a,b;
	cin>>a>>b;
	if((a+b)&1)cout<<"IMPOSSIBLE";
	else cout<<(a+b)/2;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3568
import java.util.*;

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

        int divideX = (int) (X / 100);

        if(X > 2000) {
            System.out.println(1);
        } else if(divideX * 100 <= X && X <= divideX * 105){
            System.out.println(1);
        } else {
            System.out.println(0);
        }
    }
}



Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define inf 1<<29
#define linf 1e16
#define eps (1e-8)
#define mod 1000000007
#define pi acos(-1)
#define phi (1.0+sqrt(5))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int main()
{
  int n,a,c=0;

  cin>>n;
  FOR(i,0,n){
    cin>>a;
    if(a%2)c++;
  }
  if(c%2)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
  return 0;
}



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

#define N 100000

int a[3][N];

int main()
{
	long long ans = 0;
	int n;

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

	sort( a[0], a[0] + n );
	sort( a[2], a[2] + n );
	for( int j = 0; j < n; j++ ) {
		long long an = lower_bound( a[0], a[0] + n, a[1][j] ) - a[0];
		long long cn = &a[2][n] - upper_bound( a[2], a[2] + n, a[1][j] );
		ans += an * cn;
	}

	cout << ans << endl;

	return 0;
}


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

int main(){
    int a,b;
    cin>>a>>b;
    REP(i,2000){
        double at,bt;
        at = i*0.08;
        bt = i*0.1;
        if(floor(at)==a&&floor(bt)==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() 
{
  int taka,aoki,count;
  cin >> taka >> aoki >> count;
  int i;
  for(i = 0;i < count/2;i++){
    if(taka % 2 == 1){
      taka--;
    }
    aoki += taka/2;
    taka = taka/2;
    if(aoki % 2 == 1){
      aoki--;
    }
    taka += aoki/2;
    aoki = aoki/2;
  }
  if(count % 2 == 1){
    if(taka % 2 == 1){
      taka--;
    }
    aoki += taka/2;
    taka = taka/2;
  }
  cout << taka << " " << aoki << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n, m;
const int maxN = (int)1e5 + 100;
vector < int > g[maxN];
int edges = 0;
vector < pair < int, int > > ans;
bool used[maxN];
int total[maxN];
void dfs(int v, int par) {
    used[v] = true;
    for (int to : g[v]) {
        if (used[to] && to != par) {
            ans.emplace_back(v, to);
            total[v] ^= 1;
        }
    }
    for (int to : g[v]) {
        if (!used[to]) dfs(to, v);
    }
    if (v != 1) {
        if (total[v] == 1) {
            ans.emplace_back(v, par);
            total[v] = 0;
        } else {
            ans.emplace_back(par, v);
            total[par] ^= 1;
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    if (m % 2 == 1) {
        cout << -1;
        return 0;
    }
    dfs(1, -1);
    assert(ans.size() == m);
    for (int i = 1; i <= n; i++) assert(total[i] == 0);
    for (auto it : ans) {
        cout << it.first << " " << it.second << '\n';
    }
    return 0;
}

Measured memory_bytes: 14580
n = int(input())
t = list(map(int, input().split()))
m = int(input())
ans = []

a = sum(t)
for i in range(m):
    p, x = map(int, input().split())
    ans.append(a - t[p - 1] + x)

for i in range(m):
    print(ans[i])


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

int main(){
    //freopen("in.txt","r",stdin);
    int n, m, l;
    cin>>n>>m>>l;
    vector<vector<long> > A(n, vector<long>(m));
    vector<vector<long> > B(m, vector<long>(l));
    vector<vector<long> > C(n, vector<long>(l));
    int i,j, k;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin>>A[i][j];
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            cin>>B[i][j];
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            for(k=0;k<m;k++){
                C[i][j] += A[i][k]*B[k][j];
            }
            cout<<C[i][j];
            if(j!=l-1)cout<< ' ';
        }
        cout << endl;
    }

    return 0;
}

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

int main() {
  int A,B;
  cin >> A >> B;
  if(A<10 && B<10){
    cout << A*B << endl;
  }else{
    cout << -1 << endl;
  }
  
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lc "\n"
#define fast_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define c(a,n) for(int i = 0; i < n; i++) cin >> a[i];
#define ffor(n) for(int i = 0; i < n; i++)
#define float long double
typedef vector<int> vi;
typedef vector<float> vf;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef map<string,int> msi;
typedef map<int,int> mii;
typedef unordered_map<string,int> umsi;
 
 
int32_t main()
{
    fast_io;
    int n;
    cin>>n;
    vi a(n);
    c(a,n); 
    vi pre(n);
    int m=1e9+7;
    pre[n-1]=a[n-1];
    for(int i=n-2;i>=0;i--)pre[i]=((a[i]%m)+(pre[i+1]%m))%m;
    int ans=0;
    for(int i=1;i<n;i++)
    ans=(ans%m + ((a[i-1]%m)*(pre[i]%m))%m)%m;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 6360
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b){
  if (a < b)
    return gcd(b, a);

  if (b == 0)
    return a;

  return gcd(b, a % b);
}

int main(void){
  ll a, b;

  cin >> a >> b;


  ll g = gcd(a, b);

  int s = 1;
  for (ll i = 2; i <= sqrt(g); i++){
    if (g % i == 0){
      s++;
      while (g % i == 0){
        g /= i;
      }
    }
  }



  cout << s + (g == 1 ? 0 : 1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll mod = 2019;

int main() {
    ll l, r;
    cin >> l >> r;
    map<ll, ll> m;
    for (ll i = l; i <= r && i <= l+5000; i++){
        m[i%mod]++;
    }
    ll ans = 2020;
    vector<ll> a;
    for (auto x: m){
        rep1(i, x.second) a.push_back(x.first);
    }
    ll n = a.size();
    for (ll i=0; i<(n); i++){
        for (ll j=i+1; j<(n); j++){
            ans = min(ans, a[i]*a[j]%2019);
        }
    }
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 3828
#include<stdio.h>
long long a[105];
long long gcd(long long a,long long b)
{
	return a%b==0?b:gcd(b,a%b);
}
int main()
{
	int n,i,j;
	long long sum,flag;
	scanf("%d",&n);
	scanf("%lld",&a[0]);
	sum=flag=a[0];
	for(i=1;i<n;i++)
	{
		scanf("%lld",&a[i]);
		flag=gcd(sum,a[i]);
		sum=sum/flag*a[i];
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 128
def solve (i, m, n, ary)

  #現時点で作成した数がmと一致したらTRUEを返す．
  if m == 0
    return true
  #iがnを超えた場合，aryを用いてmを作ることができないのでfalseを返す．
  elsif i >= n
    return false
  end

  #どちらの条件も満たさなかった場合，今参照しているary[i]を用いる場合と用いない場合で再度関数を呼び出す．
  res = solve(i + 1, m, n, ary) || solve(i + 1, m - ary[i], n, ary)
  return res
end


size_of_ary  = gets.to_i
ary          = gets.split.map &:to_i
size_of_aryM = gets.to_i
aryM         = gets.split.map &:to_i

aryM.each do |m|
  puts solve(0, m, size_of_ary, ary) ? :yes: :no
end



Measured memory_bytes: 8956
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool> vecbool;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<vecint> vec2int;
typedef vector<vecbool> vec2bool;
int dx[4]{-1, +1, 0, 0};
int dy[4]{0, 0, -1, +1};
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main() {
  init();
  int n;
  cin >> n;
  vec2int g(n, vecint(n, 0));
  REP(i, n) REP(j, n) cin >> g[i][j];
  vector<vecll> dp(n + 1, vecll((1 << n), 0));
  dp[0][0] = 1;
  REP(i, n) {
    for (int j = 0; j < n; j++) {
      if (g[i][j] == 0) continue;
      for (int bit = 0; bit < (1 << n); bit++) {
        if (!((bit >> j) & 1)) {
          dp[i + 1][(bit | 1 << j)] += dp[i][bit];
          dp[i + 1][(bit | 1 << j)] %= MOD;
        }
      }
    }
  }
  cout << dp[n][(1 << n) - 1] << endl;
}


Measured memory_bytes: 377216
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(c<=a+b)
		printf("%d\n",b+c);
	else
		printf("%d\n",a+b+b+1);
	return 0;
}


Measured memory_bytes: 256
import math
n = int(input())
l = []
for i in range(n):
    x,y = map(int,input().split())
    l.append([x,y])
ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        ans += (math.sqrt((l[i][0]-l[j][0])**2 + (l[i][1]-l[j][1])**2))*2/n
print(ans)

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
	bool ret = true;
	if (x < 2) {
		ret = false;
	}
	for (LL i = 2; i <= sqrt(x); i++) {
		if (x%i == 0) {
			ret = false;
		}
	}
	return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code

int main(int argc, char const* argv[])
{
    int n;
    cin >> n;
    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < 15; j++) {
            if (i*4 + j*7 == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, K, Q;
	cin >> N >> K >> Q;
	vector<int> A(N);
	set<int> B;
	for (auto& x : A) {
		cin >> x;
		B.insert(x);
	}
	int r = 1<<30;
	for (int x : B) {
		vector<vector<int>> aa;
		int c = 0;
		for (int i = 0; i < N; ++ i) {
			if (A[i] >= x) {
				++ c;
				if (c == K) {
					aa.push_back(vector<int>());
					for (int j = i-c+1; j <= i; ++ j) aa.back().push_back(A[j]);
				} else if (c > K) {
					aa.back().push_back(A[i]);
				}
			} else {
				c = 0;
			}
		}
		vector<int> b;
		for (auto& a : aa) {
			sort(a.begin(), a.end());
			for (int i = 0; i+K <= (int)a.size(); ++ i) b.push_back(a[i]);
		}
		if (Q > (int)b.size()) break;
		sort(b.begin(), b.end());
		r = min(r, b[Q-1] - b[0]);
	}
	cout << r << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
#define ll long long
ll L=1,R=1e9+10;
struct T
{
	int v,w;
};
vector<T>V[N];
bool vis[N];
struct H
{
	int f;ll v;
}has[N];
void ff(T k,int f,ll v1)
{
	if((!f)==has[k.v].f&&v1!=has[k.v].v)R=-1;
	else if((!f)!=has[k.v].f){
		ll p=has[k.v].v+v1;
		if(p%2==0){
			R=min(p/2,R);L=max(p/2,L);
		}else R=-1;
	}
}
void dfs(int No,int f,ll v)
{
	vis[No]=true;
	for(auto k:V[No]){
		if(f==1){
			if(!vis[k.v]){
				R=min(k.w+v-1,R);
				has[k.v]={!f,k.w+v};
				dfs(k.v,!f,k.w+v);
			}else {
				ff(k,f,k.w+v);
			}
		}else{
			if(!vis[k.v]){
				L=max(1+v-k.w,L);
				has[k.v]={!f,v-k.w};
				dfs(k.v,!f,v-k.w);
			}else {
				ff(k,f,v-k.w);
			}
		}
	}
}
int main()
{
	//freopen("/home/zz7/CFInput","r",stdin);
	int n,m;scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		V[u].push_back({v,w});
		V[v].push_back({u,w});
	}has[1]={1,0};
	dfs(1,1,0);
	ll cnt=R-L+1;
	if(cnt>0)cout<<cnt<<'\n';
	else cout<<0<<'\n';
}



Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int N = 1e5+9;

int n;
ll load[N];

int main() {
    fill_n(load, N, 1);
    cin >> n;
    for(int i = 0; i < n; i++) {
        int a; cin >> a;
        int index = upper_bound(load, load+N, -a) - load;
        load[index] = -a;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        if(load[i] != 1)  ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false
	

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

	bool rect[101][101] = {};
	for (int i = 0; i < N; i++) {
		int x, y, a;
		cin >> x >> y >> a;

		int x_min, x_max, y_min, y_max;
		if (a == 1) { x_min = 1; x_max = x; y_min = 1; y_max = H; }
		else if (a == 2) { x_min = x + 1; x_max = W; y_min = 1; y_max = H; }
		else if (a == 3) { x_min = 1; x_max = W; y_min = 1; y_max = y; }
		else { x_min = 1; x_max = W; y_min = y + 1; y_max = H; }

		for (y = y_min; y <= y_max; y++) {
			for (x = x_min; x <= x_max; x++) {
				rect[y][x] = true;
			}
		}
	}
	int ans = 0;
	for (int y = 1; y <= H; y++) {
		for (int x = 1; x <= W; x++) {
			if (!rect[y][x]) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define int long long

typedef pair<int, int> ii;

const int N = 2e5 + 5;

int n, h[N], dp[N], k;

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    //dp[0] = 0;
    for(int i = 1; i <= N - 5; i++)
        dp[i] = LLONG_MAX;
    dp[1] = 0;
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> h[i];
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= k; j++) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
        }
    }
    cout << dp[n];
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>
#include <math.h>

 
 
int main()
 {
	int k,a;
	char s[101],t[101];


	scanf("%d",&k);
	scanf("%s",&s);

	a=strlen(s);

	if(a<=k){
		printf("%s",s);
	}

	else {

		strncpy(t,s,k);
		t[k]='\0';
			printf("%s...",t);
		}
			return 0;
	}


	







Measured memory_bytes: 1732
s = input()
n = len(s)
ans = 0

for i in range(2**(n-1)):
    f = s[0]
    
    for j in range(n-1):
        if i>>j & 1:
            f += '+'
        f += s[j+1]
        
    ans += eval(f)
    
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >> N;
    cout << (N+1)/2 << endl;



}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int s[110000];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n>>a>>b;
	swap(a,b);
	for(i=0;i<n;i++){
		if(i<b)s[i]=a;
		else s[i]=a+1;
		if(s[i]>1e9)s[i]=1;
	}
	array_show(s,n);
}

Measured memory_bytes: 1664
import numpy as np
import itertools

N, M, X = map(int, input().split())

all_df = np.zeros((1,M+1))
for n in range(N):
  A = [int(i) for i in input().split()]
  all_df = np.vstack([all_df, np.array(A).reshape(1,-1)])
all_df = all_df[1:]

cost = N * (10**6)
for pattern in itertools.product([0,1], repeat=N):
  result = all_df[np.array(pattern).astype(bool)].sum(axis=0)

  if (X > result[1:]).sum() > 0:
    pass
  else:
    if result[0] < cost:
      cost = result[0]

if cost == N * (10**6):
  print(-1)
else:
  print(int(cost))

Measured memory_bytes: 27284
N = int(input())
A = list(map(int,input().split()))

S = sum(A)
chk = 0
i = 2
while i < N:
    chk += A[i-1]
    i += 2
chk *= 2
M = [0] * N

#print(chk,S)
M[0] = S - chk

for i in range(1,N):
    M[i] = 2 * A[i-1] - M[i-1]
print(*M)

Measured memory_bytes: 90440
function main(arg) {
  const price = parseInt(arg)
  const a = Math.ceil(price / 1.08)
  const b = Math.floor(price / 1.08)

  if (Math.floor(a * 1.08) === price) {
    console.log(a)
  } else if (Math.floor(b * 1.08) === price) {
    console.log(b)
  } else {
    console.log(':(')
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 9420
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int n;
  cin >> n;
  int c[2][n];
  vector<int> sum(n);
  rep(i, 2) {
    rep(j, n) { cin >> c[i][j]; }
  }
  rep(i, n) {
    int s = 0;
    rep(j, i + 1) { s += c[0][j]; }
    for (int k = i; k < n; ++k) {
      s += c[1][k];
    }
    sum.push_back(s);
  }
  cout << *max_element(sum.begin(), sum.end()) << endl;
  return 0;
}


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

using namespace std;

int main(int argc, char * argv[]) {
    int x, y;
    cin >> x >> y;
    if (x < 10 && y < 10) {
        cout << x * y << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
ABC = [list(map(int, input().split())) for _ in range(3)]

ABC[2].append(0)

flg = -100
cnt = 0
for n in range(N):
    cnt += ABC[1][n]
    if flg == ABC[0][n] - 1:
      cnt += ABC[2][flg - 1]
    flg = ABC[0][n]
print(cnt)

Measured memory_bytes: 3064
#include<string>
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<ios>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<type_traits>
#include<random>
#include<vector>

using namespace std;

	

int main()
{
	int N;
	cin >> N;
	int h[N];
	for(int in=0;in<N;in++)
	{
		cin >> h[in] ;
	}
	int count = 0;
	for(int i=0;i<N;i++)
	{
		int dx = N-i;
		for(int j=0;j<i+1;j++)
		{
			int minh = h[j];
			for(int k=0;k<dx-1;k++)
			{
				if(minh>h[j+k+1])
				{
					minh = h[j+k+1];
				}
			}
			for(int l=0;l<dx;l++)
			{
				h[j+l] = h[j+l] - minh;
			}
			count = count + minh;
		}
	}
	cout << count <<endl;
}




Measured memory_bytes: 256
import itertools
N = int(input())
Ps = tuple(map(int, input().split()))
Qs = tuple(map(int, input().split()))

d_list = list(itertools.permutations(range(1, N + 1)))

#print(d_list)

#print(type(d_list[0]))
Pindex = d_list.index(Ps)
Qindex = d_list.index(Qs)


print(abs(Pindex - Qindex))

Measured memory_bytes: 8052
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(void){
	int a, b;

	cin >> a >> b;

	int num = 0;

	for (int i = a; i <= b; i++){
		if (i % 10 == i / 10000 && (i % 100) / 10 == (i % 10000) / 1000)
			num++;
	}


	cout << num << endl;
}

Measured memory_bytes: 256
# coding: utf-8
n = int(input().rstrip())

for i in range(n):
    line = input().rstrip().split(" ")
    lineMax = int(line[1])
    lineIndex = 0
    for j in range(n):
        if lineIndex >= lineMax:
            print(0, end = "")
        else:
            if j + 1 == int(line[lineIndex + 2]):
                print(1, end = "")
                lineIndex += 1
            else:
                print(0, end = "")
        if j + 1 != n:
            print(" ", end ="")
    print()

Measured memory_bytes: 7680
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int A1 = stdIn.nextInt();
        int B = stdIn.nextInt();
        int C = stdIn.nextInt();
        stdIn.close();
 
        if (A1 == B && B != C) {
            System.out.println("Yes");
        } else if(A1== C && B != C) {
            System.out.println("Yes");
        } else if(B == C && A1 != C) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

typedef struct node *link;
struct node{
    int key;
    link left, right;
};

link head = NULL;

//root????????¨????????¨???z????????\??????
void insert(link root, link z){
    link y = NULL;
    link x = head;
    
    while(x!=NULL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    
    if(y==NULL){
        head = z;
    }else if(z->key < y->key){
        y->left = z;
    }else{
        y->right = z;
    }
    return;
}

//???????????????
void printInorder(link node){
    if(node==NULL) return;
    printInorder(node->left);
    printf(" %d",node->key);
    printInorder(node->right);
}

//???????????????
void printPreorder(link node){
    if(node==NULL) return;
    printf(" %d",node->key);
    printPreorder(node->left);
    printPreorder(node->right);
}

void findKey(link node,int value){
    link x = node;
    
    while(x!=NULL){
        if(x->key == value){
            printf("yes\n");
            return;
        }
        
        if(x->key > value){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    
    printf("no\n");
    return;
}

int main(){
    int n,i,j,k;
    
    scanf("%d",&n);
    
    int value=0;
    char com[100];
    for(i=0;i<n;i++){
        scanf("%s",com);
        
        if(!strcmp(com,"insert")){
            scanf("%d",&value);
            
            link z;
            z = malloc(sizeof(struct node));
            z->key = value;
            z->left = z->right = NULL;
            
            insert(head,z);
            
        }else if(!strcmp(com,"find")){
            scanf("%d",&value);
            findKey(head,value);
            
        }else if(!strcmp(com,"print")){
            printInorder(head);
            printf("\n");
            printPreorder(head);
            printf("\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 13116
/*
 * Author: NomadThanatos
 * Created Time:  2011/8/31 13:51:49
 * File Name: J.cpp
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;

#define out(v) cerr << #v << ": " << (v) << endl
#define SZ(v) ((int)(v).size())

const int MAXINT = -1u>>1;
const int base[] = {1,5,10,50,100,500};

int num[6];

int calcGive(int mo) {
    int res = 0;
    for(int i = 5 ; i >= 0 ; i--) {
        int toGive = mo / base[i];
        if (toGive > num[i]) {
            toGive = num[i];
        }
        res += toGive;
        mo -= toGive * base[i];
    }
    if (mo) return -1;
    return res;
}

int calcReturn(int mo) {
    int res = 0;
    for(int i = 5 ; i >= 0 ; i--) {
        res += mo / base[i];
        mo %= base[i];
    }
    return res;
}

int main() {
    int sum,P;
    while(scanf("%d",&P) == 1) {
        sum = 0;
        for(int i = 0 ; i < 6 ; i++) {
            scanf("%d",num + i);
            sum += num[i] * base[i];
        }
        if (P == 0) break;
        int minm = MAXINT;
        //printf("%d %d",P,sum);
        for(int p = P ; p < sum + 1 ; p++) {
            int give = calcGive(p);
            int ret = calcReturn(p - P);
            if (give != -1) {
                minm = min(minm,give + ret);
            }
        }
        printf("%d\n",minm);
    }
    return 0;
}

Measured memory_bytes: 876
n = int(input())
h = [list(map(int,input().split()))]
ans = 0
h = h[0]
max_ans = 0

for i in range(n-1):
    if h[i] >= h[i+1]:
        ans += 1
        if max_ans < ans:
            max_ans = ans
    elif h[i] < h[i+1]:
        if ans != 0:
          if max_ans < ans:
            max_ans = ans
        ans = 0
print(max_ans)
    

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

ll GCD(ll a, ll b)
{
	if (b == 0) return a;
	else return GCD(b, a%b);
}

int main(int argc, char **argv)
{
	ll n;
	cin >> n;
	vector<ll> x(n), y(n);
	for (int i = 0;i < n; ++i)
		cin >> x[i] >> y[i];

	if (n == 1)
	{
		std::cout << 1 << std::endl;
		return 0;
	}

	ll res{n};
	for (int i = 0; i < n; ++i )
	{
		for (int j = 0; j < n; ++j)
		{
			if (i == j) continue;
			ll dx = x[i] - x[j];
			ll dy = y[i] - y[j];

			ll c{0};
			for (int ii = 0 ;ii < n; ++ii)
			{
				for (int jj = 0; jj < n; ++jj)
				{
					if (ii == jj) continue;
					if (x[ii] - x[jj] == dx && y[ii] - y[jj] == dy)
						++c;
				}
			}
			res = min(res, n-c);
		}
	}

	std::cout << res << std::endl;
}

Measured memory_bytes: 256
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue(優先度付きキュー)：最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using ll = long long;
using namespace std;
/*ビットxにi番目のフラグが立っているかどうか
if(x & (1 << i))
↑ a << b == a*pow(b,2)
/*{0, 1, ..., n-1} の部分集合の全探索
for (int bit = 0; bit < (1 << n); ++bit)
*/

int main(){
  int n,m,c;  cin >> n >> m >> c;
  vi b(m);
  rep0(i,m){
    cin >> b[i];
  }
  int ans = 0;
  rep0(i,n){
    int sum = 0;
    rep0(j,m){
      int a;  cin >> a;
      sum += a*b[j];
    }
    if(sum + c > 0){
      ans++;
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#import generator


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

"""
with open('generator.txt', 'r') as f:
    read = f.read().split('\n')
    N = int(read[0])
    A = list(map(int, read[1].split()))
    B = list(map(int, read[2].split()))
    C = list(map(int, read[3].split()))
"""
A.sort()
C.sort()


def binary_search(lst, value, high):
    l = 0
    r = N - 1
    while l <= r:
        mid = (l + r) // 2
        if lst[mid] < value:
            l = mid + 1
        elif lst[mid] > value:
            r = mid - 1
        else:
            # lstの中にある場合
            if high:
                # 真に大きい
                return binary_search(lst, value + 0.5, high)
            else:
                # 真に小さい
                return binary_search(lst, value - 0.5, high)
    if high:
        return l
    else:
        return r


def main():
    ans = 0
    # Bの値でループしてそれより小さいA、大きいCの個数を求めて掛け合わせる
    for middle in B:
        lower = binary_search(A, middle, False) + 1 # 0-indexedで返るので+1する
        higher = N - binary_search(C, middle, True)
        ans += lower * higher
    print(ans)

    
# 愚直解
def main2():
    ans = 0
    for a in A:
        for b in B:
            for c in C:
                if a < b < c:
                    ans += 1
    print(ans)
    

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

Measured memory_bytes: 105616
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+5;
#define ll long long
#define inf 0x3f3f3f3f

int main()
{
    string s,ss;
    cin>>s;
    int len=s.length();
    int sum=0;
    for(int i=0;i<len;i++)
    {
        if(s[i]!=s[len-i-1]) sum++;
    }
    cout<<sum/2<<endl;
return 0;
}


Measured memory_bytes: 256
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

int main() {
	int L;
	cin >> L;
	
	int N = 1, x=1;
	for (; 2*x<=L; x*=2) ++N;
	
	int R = L - x;
	int M = 2 * (N-1) + bitCount(R);
	
	cout << N << " " << M << endl;
	
	for (int i=1, w=1; i<N; ++i, w*=2) {
		cout << i << " " << i+1 << " " << 0 << endl;
		cout << i << " " << i+1 << " " << w << endl;
	}
	
	int add = x;
	for (int i=N-2; i>=0; --i) {
		add /= 2;
		if (R >> i & 1) {
			cout << i+1 << " " << N << " " << x << endl;
			x += add;
		}
	}
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;


void getAC() {	
	ios_base :: sync_with_stdio(false); cin.tie(0);
	int K, X; cin >> K >> X;
	puts(K * 500 >= X ? "Yes" : "No");
}
 
int main() {	
	getAC();
	return 0;
}

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

int main() {
  int K,N;
  cin >> N >> K;
  int A = 1;
  for(int i = 0;i < N;i++){
    if(A < K){
      A *=2;
    }
    else{
      A += K;
    }
  }
  cout << A << endl;
}



Measured memory_bytes: 256