akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int r;
    in>>r;
    cout<<r*r<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var array = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var total = 0;

            for (var i = 0; i < N; i++)
            {
                var count = 0;
                while (array[i] % 2 == 0)
                {
                    count++;
                    array[i] /= 2;
                }
                total += count;
            }
            Console.WriteLine(total);
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int a[n],b[n],c[n];
int sum[n][3];
cin>>a[0]>>b[0]>>c[0];
sum[0][0]=a[0];
sum[0][1]=b[0];
sum[0][2]=c[0];
for(int i=1;i<n;i++)
{
    cin>>a[i]>>b[i]>>c[i];
    sum[i][0]=max(sum[i-1][1]+a[i],sum[i-1][2]+a[i]);
    sum[i][1]=max(sum[i-1][0]+b[i],sum[i-1][2]+b[i]);
    sum[i][2]=max(sum[i-1][0]+c[i],sum[i-1][1]+c[i]);
}
cout<<max(max(sum[n-1][0],sum[n-1][1]),sum[n-1][2]);
}


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

long long modpow(long long a, long long n, long long mod);
long long ncr(long long n, long long r, long long mod);
long long modplus(long long val, long long m);
      
int main(){
  long long n, a, b;
  cin >> n >> a >> b;
  long long mod = pow(10, 9)+7;
  cout << modplus((modpow(2, n, mod)-ncr(n, a, mod)-ncr(n, b, mod)-1), mod) << endl;
  return 0;
}

long long modpow(long long a, long long n, long long mod){
  long long res = 1;
  while(n>0){
    if(n&1){
      res = modplus(res * a, mod);
    }
    a = modplus(a * a, mod);
    n >>= 1;
  }
  return res;
}

long long ncr(long long n, long long r, long long mod){
  r = min(r, n-r);
  if(r == 0){
  	return 1;
  }
  if(r == 1){
    return n;
  }
  long long numerator[r];
  for(long long i=0; i<r; i++){
    numerator[i] = n-r+i+1;
  }
  long long denominator[r];
  for(long long i=0; i<r; i++){
    denominator[i] = i+1;
  }
  long long pivot;
  long long offset;
  for(long long p=2; p<r+1; p++){
    pivot = denominator[p-1];
    if(pivot > 1){
      offset = modplus(n-r, p);
      for(long long k=p-1; k<r; k=k+p){
        numerator[k-offset] *= modpow(pivot, mod-2, mod);
        numerator[k-offset] = modplus(numerator[k-offset], mod);
        denominator[k] *= modpow(pivot, mod-2, mod);
        denominator[k] = modplus(denominator[k], mod);
      }
    }
  }
  long long result = 1;
  for(long long k=0; k<r; k++){
    if(numerator[k]>1){
      result *= modplus(numerator[k], mod);
      result = modplus(result, mod);
    }
  }
  return result;
}

long long modplus(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}


Measured memory_bytes: 3328
#!/usr/bin/env python3

def main():
    n, k = map(int, input().split())
    xn = []
    yn = []
    for i in range(n):
        x, y, c = input().split()
        x = int(x)
        y = int(y)
        assert c in ["W", "B"]
        if c == "W":
            y += k
        xn.append(x % (2 * k))
        yn.append(y % (2 * k))

    kibou = [[0 for x in range(2 * k + 1)] for y in range(2 * k + 1)]
    for i in range(n):
        x = xn[i]
        y = yn[i]
        squares = get_list_squares(x, y, k)
        for x1, y1, x2, y2 in squares:
            kibou[y1][x1] += 1
            kibou[y1][x2] -= 1
            kibou[y2][x1] -= 1
            kibou[y2][x2] += 1

    rui = ruiseki_2d(kibou, k)
    ma = [max(rui[y]) for y in range(2 * k)]
    print(max(ma))

def get_list_squares(x, y, k):
    # (x, y) of lower bottom
    twok = 2 * k
    assert 0 <= x < twok
    assert 0 <= y < twok
    if x >= k:
        x -= k
        y = (y + k) % (twok)
    xp = x + k
    yp = (y + k) % (twok)
    li = []
    if y < yp:
        li.append((x, y, xp, yp))
        li.append((xp, yp, twok, twok))
        if y != 0:
            li.append((xp, 0, twok, y))
        if x != 0:
            li.append((0, yp, x, twok))
        if x != 0 and  y != 0:
            li.append((0, 0, x, y))
    else:
        li.append((x, y, xp, twok))
        li.append((xp, yp, twok, y))
        if x != 0:
            li.append((0, yp, x, y))
        if y != 0:
            li.append((x, 0, xp, yp))
    return li

def ruiseki_2d(kibou, k):
    rui_1d = [[0 for x in range(2 * k)] for y in range(2 * k)]
    for y in range(k * 2):
        rui_1d[y][0] = kibou[y][0]
        for x in range(1, 2 * k):
            rui_1d[y][x] = rui_1d[y][x - 1] + kibou[y][x]

    rui_2d = [[0 for x in range(2 * k)] for y in range(2 * k)]
    for x in range(2 * k):
        rui_2d[0][x] = rui_1d[0][x]
        for y in range(1, 2 * k):
            rui_2d[y][x] = rui_2d[y - 1][x] + rui_1d[y][x]
    return rui_2d

def debug_print(arr, k):
    for y in reversed(range(2 * k)):
        print(arr[y])

main()


Measured memory_bytes: 139280
def main():
    n, m = map(int, input().split())

    balls, red = [1 for i in range(n)], [0 for i in range(n)]
    red[0] = 1

    for i in range(m):
        x, y = map(int, input().split())
        balls[x-1] -= 1
        balls[y-1] += 1

        if red[x-1] == 1:
            red[y-1] = 1
        if balls[x-1] == 0:
            red[x-1] = 0

    cnt = 0
    for i in range(n):
        if red[i] == 1:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4784
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  int D, N;
  ci(D, N);
  if(N <= 99){
    co(N * pow(100, D));
    rt;
  }
  else{
    sp(0);
    co(101 * pow(100, D));
    rt;
  }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c, x int
	fmt.Scan(&a, &b, &c, &x)
	res := 0
	var total int
	for A := 0; A <= a; A++ {
		for B := 0; B <= b; B++ {
			for C := 0; C <= c; C++ {
				total = 500*A + 100*B + 50*C
				if total == x {
					res += 1
				}
			}
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec 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=5e4+5,MAXM=1e5+5;
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,m,T;pint a[MAXM];
namespace Task1{
	bitset<MAXN>F[MAXN],tmp;int vis[MAXN],ans[MAXM];
	inline void Solve(){
		Rep(i,1,n)F[i][i]=1;
		Red(i,m,1){int x=a[i].fir,y=a[i].sec;F[x]=F[y]=F[x]|F[y];}
		tmp.set();Rep(i,1,n)tmp&=F[i];if(!tmp.any()){puts("-1");return;}
		int t=tmp._Find_first();vis[t]=1;
		Red(i,m,1){
			int x=a[i].fir,y=a[i].sec;
			if(vis[x]&&!vis[y])vis[y]=1,ans[i]=1;else if(vis[y]&&!vis[x])vis[x]=1,ans[i]=0;
		}Rep(i,1,m)putchar(ans[i]?'^':'v');puts("");
	}
}
namespace Task2{
	int bel[5],ans[MAXM],cnt[5];
	inline void Solve(){
		if(n<=2){puts("-1");return;}
		Rep(i,1,m)if(a[i].sec>3)ans[i]=1;
		Rep(i,1,3)bel[i]=i,cnt[i]=1;
		Red(i,m,1)if(!ans[i]){
			int x=a[i].fir,y=a[i].sec;
			if(bel[x]==bel[y])continue;
			if(cnt[bel[x]]>=2)cnt[bel[x]]--,bel[x]=bel[y],cnt[bel[y]]++;
			else cnt[bel[y]]--,bel[y]=bel[x],cnt[bel[y]]++,ans[i]=1;
		}Rep(i,1,m)putchar(ans[i]?'^':'v');puts("");
	}
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),m=read(),T=read();
	Rep(i,1,m)a[i]=(pint){read(),read()};
	if(T==1)Task1::Solve();else Task2::Solve();
	return 0;
}




Measured memory_bytes: 310296
#include "bits/stdc++.h"
using namespace std;

#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

static const int INF = 0x3f3f3f3f;
static const int MOD = 1000000007;

//0-origin
template <typename T>
struct FenwickTree {
	vector<T> data;
	FenwickTree(int n) : data(n, 0) {}
        //v[i] += x
	void add(int i, T x) { 
                for (int p = i; p < (int)data.size(); p |= p + 1) data[p] = data[p] + x % MOD;
        }
        //[0, i)
	T sum(int i) {
		T s = 0;
                for (int p = i - 1; p >= 0; p = (p & (p + 1)) - 1) s = s + data[p] % MOD;
		return s;
	}
        //[l, r)
	T sum(int l, int r) { return (sum(r) - sum(l) % MOD + MOD) % MOD; }
};

void solve() {
        int n;
        cin >> n;
        vector<pair<int, int>> p(n);
        for (int i = 0; i < n; i ++) cin >> p[i].first >> p[i].second;

        //compressing
        vector<int> v(n);
        for (int i = 0; i < n; i ++) v[i] = p[i].second;
        sort(all(v));
        map<int, int> zip;
        int cnt = 1;
        for (int i = 0; i < n; i ++) zip[v[i]] = cnt ++;
        for (int i = 0; i < n; i ++) p[i].second = zip[p[i].second];

        sort(all(p));
        vector<int> r(n), l(n);
        r[0] = p[0].second, l[n - 1] = p[n - 1].second;
        for (int i = 1; i < n; i ++) r[i] = max(r[i - 1], p[i].second);
        for (int i = n - 2; i >= 0; i --) l[i] = min(l[i + 1], p[i].second);
        FenwickTree<long long> ft(n + 10);
        ft.add(0, 1);
        for (int i = 0; i < n; i ++) ft.add(r[i], ft.sum(l[i] - 1, r[i] + 1));
        cout << (ft.sum(n, n + 1) % MOD + MOD) % MOD << endl;
        return;
}

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



Measured memory_bytes: 15104
#include<stdio.h>

int main(void){
int n,r,k;
scanf("%d",&n);
for(r=1;r<=n;r++){
if(r%3==0||r%10==3){
printf(" %d",r);
}else{
k=r;
while(k!=0){
k/=10;
if(k%10==3){printf(" %d",r);break;}
}
}
}
printf("\n");
return 0;
}

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

#define fi first
#define se second
#define mk(a,b) make_pair(a,b)

typedef long long ll;
typedef pair<int,int> pii;

int N,A,B;

int main()
{
    cin >>N >> A >> B;
    cout << min(A * N, B) << endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    for _ in range(K):
        arr = [0]*(N+1)
        for i, a in enumerate(A):
            left = max(0, i-a)
            right = min(N, i+a+1)
            arr[left] += 1
            arr[right] -= 1
        
        A = list(accumulate(arr[:-1]))
        if all(a == N for a in A):
           break

    print(*A, sep=" ")



if __name__ == "__main__":
    main()

Measured memory_bytes: 178400
#include<stdio.h>

int main(){


int n,i,ai;


int min=1000000,max=-1000000;


long int sum=0;


scanf("%d",&n);


for(i=0;i<n;i++){


scanf("%d",&ai);


if(min>ai){


min=ai;


}


if(max<ai){


max=ai;


}


sum+=ai;


}


printf("%d %d %ld\n",min,max,sum);


return 0;


}

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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  
  int n;
  cin >> n;
  
  vector<vector<int>> dp(2, vector<int>(3, 0));
  int cur = 0;
  for(int i=1;i<=n;++i)
  {
    vector<int> a(3);
    for(int& j: a)
      cin >> j;
    cur ^= 1;
    for(int j = 0; j < 3; ++j)
      dp[cur][j] = a[j] + max(dp[cur^1][(j+1)%3], dp[cur^1][(j+3-1)%3]);
  }
  
  cout << *max_element(dp[cur].begin(), dp[cur].end()) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,a[101],i,b[100],j,l,flg,c[100];
	scanf("%d",&n);
	while(n!=0){
	    for(i=0;i<n+1;i++){
		    scanf("%d",&a[i]);
		}
		for(i=0;i<n+1;i++){
		    l=0;
			flg=0;
		    for(j=0;j<n;j++){
			    if(i!=j){
				    b[j]=a[l];
				}
				else{
				    l++;
				    b[j]=a[l];
				}
				l++;
			}
			for(j=0;j<n;j++){
			    c[j]=b[j+1]-b[j];
			}
			for(j=0;j<n-1;j++){
			    if(c[j]!=c[j+1]&&j!=n-2){
				    flg=1;
				}
				else if(c[j-1]!=c[j]&&j==n-1){
				    flg=1;
				}
			}
			if(flg==0){
			    printf("%d\n",a[i]);
				break;
			}
		}
		scanf("%d",&n);
	}
	return 0;
}


Measured memory_bytes: 2760
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(){
    vector<vector<int>> c(3, vector<int>(3));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++) cin >> c[i][j];
    }

    vector<int> diff1(3, 0);
    for(int i = 1; i < 3; i++) diff1[i] = c[0][i] - c[0][0];

    string res = "Yes";
    for(int i = 1; i < 3; i++){
        for(int j = 1; j < 3; j++){
            if(c[i][j] - c[i][0] != diff1[j]) res = "No";
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3576
import scala.io.StdIn.{readLine, readInt};
object Main {
    def main(args: Array[String]): Unit = {
        readInt;
        val s = readLine.split(" ").map(_.toLong);
        readInt;
        val t = readLine.split(" ").map(_.toLong);
        val ret = t.foldLeft(0) { (cnt, i) => if (binSearch(i, s)) {cnt + 1}else {cnt}};
        println(ret);
    }
    
    def binSearch(target: Long, arr: Array[Long]): Boolean = {
        def go(first: Int, last: Int): Boolean = {
            if ((last - first) <= 1) {
                (first to last).exists(arr(_) == target);
            } else {
                val pivot = (first + last) / 2;
                if (target < arr(pivot)) go(first, pivot) else if (target > arr(pivot)) go(pivot + 1, last) else true;
            }
        }
        go(0, arr.length - 1);
    }
}


Measured memory_bytes: 80376
#include<bits/stdc++.h>
using namespace std;
int k,M=1e9+7;
int64_t ans;
vector<set<int>> tree;

void comp_tree(int p){
  for (auto i: tree[p]){
    tree[i].erase(p);
    comp_tree(i);
  }
  return;
}

void cal(int p, int n){
  int color=k;
  for (auto i: tree[p]){
    ans*=color-n;
    ans%=M;
    cal(i,2);
    color--;
  }
  return;
}

int main(){
  int n,a,b;
  cin>> n >> k;
  set<int> s;
  tree.assign(n,s);
  for (int i=0; i<n-1; i++){
    cin>> a >> b; a--; b--;
    tree[a].insert(b); tree[b].insert(a);
  }
  comp_tree(0);
  
  ans=k;
  cal(0,1);
  
  cout<< ans <<endl;
}

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

int main() {
    // your code goes here
    ll h,a;
    cin >> h >> a;
    if(h%a==0) cout << h/a << endl;
    else cout << (h-h%a)/a+1 << endl;
    return 0;
}

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

const int mod = 1e9+7;
const int INF = 2000000;

int main() {
    int N,M;
    cin >> N >> M;
    int n = pow(2, M);
    cout << (1900*M+100*(N-M))*n << endl;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(int argc, char const *argv[])
{
    int N;
    cin>>N;
    vector<float> v;
    float a;
    for(int i=0;i<N;i++){
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
 
    float V=v[0];
    for (int i=1;i<N;i++){
        V = (V+v[i])/2;
    }
    cout<<V<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        if (a > 12) {
            System.out.println(b);
        }
        else if (a > 5) {
            System.out.println(b/2);
        }
        else {
            System.out.println(0);
        }

    }
}


Measured memory_bytes: 23252
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>

#define REP(i,n) for(int i=0;i<n;i++)
#define ll long long int

using namespace std;

int to_int(string s) {
  return atoi(s.c_str());
}
int main() {
  int n;
  int a;
  cin >> n;
  REP(i,n) {
    int tmp;
    cin >> tmp;
    a += tmp;
  }
  cout << a - n << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  string S;
  cin >> S;
  bool visited[26];
  fill(visited, visited+26, false);
  for (auto x : S) {
    if (!visited[x - 'a']){
      visited[x - 'a'] = true;
    } else {
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
}


Measured memory_bytes: 256
$N = <STDIN>;
$s = <STDIN>;
my @dat =  split(/ /,$s);
#print "$N\n";
#print "@dat\n";

my @data;
for(my$i=0;$i<$N;$i++){
  $data[$i]=0;
}
for(my$i=0;$i<$N;$i++){
  $data[$dat[$i]] ++;
}
$all = 0;
for(my$i=0;$i<=$N;$i++){
  if($data[$i] <=1 ){next;}
  $A = $data[$i]*($data[$i] -1);
  $all = $all + $A;
  #print "$i $data[$i]  $all\n";
}
#print "ALL $all\n";
#print "ans\n";

for(my$i=0;$i<$N;$i++){
  if($data[$dat[$i]] <=1 ){
    $ans = $all/2;
    print "$ans\n";;
  }else{
    $P = $data[$dat[$i]];
    $A = $P*($P -1);
    $B = ($P -2)*($P -1);
    $C = $all - $A + $B;
    #print "i$i $dat[$i] $data[$dat[$i]] A$A B$B $C  \n";
    $ans = $C/2;
    print "$ans\n";;
  }
}


Measured memory_bytes: 37420
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
#define P pair<int, int>
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;

ll a, b;

ll xor0(ll n)
{
	if (n % 2 == 1)
	{
		if (((n + 1) / 2) % 2 == 1)return 1;
		else return 0;
	}
	else
	{
		if ((n/2) % 2 == 1)return n + 1;
		else return n;
	}
}

int main()
{
	cin >> a >> b;
	ll a_0 = xor0(a-1);
	if (a == 0)a_0 = 0;
	ll b_0 = xor0(b);
	ll ans = a_0 ^ b_0;
	co(ans);
	return 0;
}


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

using namespace std;

int main(){
	vector<int> vec(5, 0);
	int i;
	
	for(i = 0; i < vec.size(); i++)
		cin >> vec[i];
	sort(vec.begin(), vec.end());
	
	for(i = vec.size() - 1; i >= 0; i--){
		cout << vec[i];
		if(i != 0)
			cout << " ";
		else cout << endl;
	}
	
	return 0;
}

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

struct Hline {
	int x, sy, ey;
};

struct Wline {
	int y, sx, ex;
};

int N, M, SY = -1, SX = -1;
vector<int> Y, X;
vector<Hline> H;
vector<Wline> W;
map<int, int> newY, newX;
ll area[7070][7070];
bool vis[7070][7070], cutY[7070][7070], cutX[7070][7070];
int dir[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

void DFS(int y, int x)
{
	vis[y][x] = true;
	for(int i=0; i<4; i++)
	{
		int ny = y + dir[i][0], nx = x + dir[i][1];
		if (nx < x && cutX[y][x]) continue;
		if (x < nx && cutX[y][x+1]) continue;
		if (ny < y && cutY[y][x]) continue;
		if (y < ny && cutY[y+1][x]) continue;
		if (ny < 0 || nx < 0 || ny >= (int)Y.size()-1 || nx >= (int)X.size()-1)
		{
			printf("INF");
			exit(0);
		}
		if (vis[ny][nx]) continue;
		DFS(ny, nx);
	}
}

void BFS(int sy, int sx)
{
	queue<pair<int, int> > q;
	q.push({sy, sx}); vis[sy][sx] = true;
	while(!q.empty())
	{
		int y = q.front().first, x = q.front().second; q.pop();
		for(int i=0; i<4; i++)
		{
			int ny = y + dir[i][0], nx = x + dir[i][1];
			if (nx < x && cutX[y][x]) continue;
			if (x < nx && cutX[y][x+1]) continue;
			if (ny < y && cutY[y][x]) continue;
			if (y < ny && cutY[y+1][x]) continue;
			if (ny < 0 || nx < 0 || ny >= (int)Y.size()-1 || nx >= (int)X.size()-1)
			{
				printf("INF");
				exit(0);
			}
			if (vis[ny][nx]) continue;
			q.push({ny, nx}); vis[ny][nx] = true;
		}
	}
}

int main()
{
	scanf("%d %d", &N, &M);
	for(int i=1; i<=N; i++) // 세로선
	{
		int sy, ey, x;
		scanf("%d %d %d", &sy, &ey, &x);
		H.push_back({x, sy, ey});
	}
	for(int i=1; i<=M; i++) // 가로선
	{
		int y, sx, ex;
		scanf("%d %d %d", &y, &sx, &ex);
		W.push_back({y, sx, ex});
	}

	// 좌표 압축
	for(int i=0; i<H.size(); i++)
	{
		X.push_back(H[i].x);
		Y.push_back(H[i].sy);
		Y.push_back(H[i].ey);
	}
	for(int i=0; i<W.size(); i++)
	{
		X.push_back(W[i].sx);
		X.push_back(W[i].ex);
		Y.push_back(W[i].y);
	}
	sort(Y.begin(), Y.end());
	sort(X.begin(), X.end());
	Y.erase(unique(Y.begin(), Y.end()), Y.end());
	X.erase(unique(X.begin(), X.end()), X.end());

	for(int i=0; i<Y.size(); i++)
		newY[Y[i]] = i;
	for(int i=0; i<X.size(); i++)
		newX[X[i]] = i;

	// 영역 넓이 전처리
	for(int i=0; i<(int)Y.size()-1; i++)
	{
		for(int j=0; j<(int)X.size()-1; j++)
		{
			area[i][j] = (ll)(Y[i+1]-Y[i])*(X[j+1]-X[j]);
			if (Y[i] <= 0 && 0 < Y[i+1] && X[j] <= 0 && 0 < X[j+1]) //
				SY = i, SX = j;
		}
	}

	// 컷 구하기
	for(int i=0; i<H.size(); i++)
	{
		int x = H[i].x, sy = H[i].sy, ey = H[i].ey;
		x = newX[x]; sy = newY[sy]; ey = newY[ey];
		for(int y=sy; y<ey; y++)
			cutX[y][x] = true;
	}
	for(int i=0; i<W.size(); i++)
	{
		int y = W[i].y, sx = W[i].sx, ex = W[i].ex;
		y = newY[y]; sx = newX[sx]; ex = newX[ex];
		for(int x=sx; x<ex; x++)
			cutY[y][x] = true;
	}

	// 상하좌우 밖으로 나갔을 때 예외 처리
	if (SY == -1 && SX == -1) return !printf("INF");
	// 도달 가능한 넓이 구하기
	BFS(SY, SX);

	ll res = 0;
	for(int i=0; i<7070; i++)
		for(int j=0; j<7070; j++)
			if (vis[i][j])
				res += area[i][j];
	printf("%lld", res);
	return 0;
}

Measured memory_bytes: 133208
import java.util.*;
import java.io.*;

 class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String i1[]=br.readLine().split(" ");
		int n=Integer.parseInt(i1[0]);
		int k=Integer.parseInt(i1[1]);
		
		long a[]=new long[n+1];
		int count=0;
		String line = br.readLine();
		while ( line != null  &&  !line.equals("")) {
		    
	    	int snack=Integer.parseInt(line);
			String users[]=br.readLine().split(" ");
			for(int i=0;i<users.length;i++)
			{
				a[Integer.parseInt(users[i])-1]++;
			}
			
			line=br.readLine();
		}
		for(int i=0;i<n;i++)
		{
			if(a[i]==0)
			{
				count++;
			}
		}
		
		System.out.println(count);
	}

}


Measured memory_bytes: 33500
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	static int ans=0;
	static int[][] lines;
	static boolean[] path;
	static boolean[][] connected;
	
	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N=sc.nextInt();
		int M=sc.nextInt();
		lines=sc.nextIntsNM(M, 2);
		connected=new boolean[N][N];
		for(int i=0;i<M;i++) {
			connected[lines[i][0]-1][lines[i][1]-1]=true;
			connected[lines[i][1]-1][lines[i][0]-1]=true;
		}
		path=new boolean[N];
		solver(0,path);
		System.out.println(ans);

	}

	public static void solver(int point,boolean[] path) {
		if(path[point]) {
			return;
		}
		path[point]=true;
		for(int i=0;i<path.length;i++) {
			if(!path[i]) {
				break;
			}
			if(i==path.length-1) {
				ans++;
				break;
			}
		}
		for(int i=0;i<path.length;i++) {
			if(connected[point][i]) {
				solver(i, path);
			}
		}
		
		path[point]=false;
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
	
	public char[][] nextCharsHW(int H,int W){
		char[][] chars=new char[H][W];
		for(int i=0;i<H;i++) {
			String str=next();
			for(int j=0;j<W;j++) {
				chars[i][j]=str.charAt(j);
			}
		}
		return chars;
	}
	
	public int[][] nextIntsNM(int N,int M){
		int[][] ints=new int[N][M];
		for(int i=0;i<N;i++) {
			for(int j=0;j<M;j++) {
				ints[i][j]=nextInt();
			}
		}
		return ints;
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
#define INF 1000000
#define white 0
#define gray 1
#define black -1

int prim();
int n,M[100][100];
int main (){
  int e,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      M[i][j] = e;
      if(e==-1)M[i][j]=INF;
    }
  }
  printf("%d\n",prim());

  return 0;
}
int prim(){
  int i,u,mv,d[100],p[100],color[100],sum=0,v;

  // Initialize
  for(i=0;i<n;i++){
    d[i]=INF;
    p[i]=-1;
    color[i]=white;
  }

  // determine Start Node
  d[0]=0;

  // Do Prim's Algorithm
  while(1){
    mv=INF;
    u=-1; // Canditate Node of Minimal Spaning Tree
    for(i=0;i<n;i++){
      if(mv>d[i]&&color[i]!=black){
	u=i;
	mv=d[i];
      }
    }
    if(u==-1)break; // If it can't find any node to add
    color[u]=black;
    for(v=0;v<n;v++){
      if(color[v]!=black&&M[u][v]!=INF){
	if(d[v]>M[u][v]){
	  d[v]=M[u][v];
	  p[v]=u;
	  color[v]=gray;
	}
      }
    }
  }
  
  for(i=0;i<n;i++){
    if(p[i]!=-1)sum+=M[i][p[i]];
  }
  return sum;
}



Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

const int N=1e5+100,S=1e5+1;
int n,a[N],s[N],tr[N<<1];
LL L;

void Add(int x)
{
	while(x<=S+S) tr[x]+=1,x+=(x&(-x));
}

LL Query(int x)
{
	LL ret=0;
	while(x>0) ret+=tr[x],x-=(x&(-x));
	return ret;
}

bool check(int x)
{
	LL ret=0;
	for(int i=1;i<=n;++i)
	{
		if(a[i] <= x) s[i]=s[i-1]-1;
		else s[i]=s[i-1]+1;
		//cout<<s[i]<<endl;
	}
	memset(tr,0,sizeof(tr));
	Add(S);
	for(int i=1;i<=n;++i)
	{
		ret+=i-Query(S+s[i]);
		//cout<<Query(S+s[i])<<endl;
		Add(S+s[i]);
	}
	//cout<<x<<" "<<ret<<endl;
	return ret>=L/2+1;
}

int main()
{
	scanf("%d",&n);
	L=1ll*n*(n+1)/2;
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	int l=0,r=1e9+100;
	while(l<r-1)
	{
		int mid=(l+r)>>1;
		if(check(mid)) r=mid;
		else l=mid;
	}
	printf("%d",r);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

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

int main(){
    string s;
    cin >> s;
    s += (s[(int)s.size()-1] == 'B' ) ? 'W' : 'B';
    int n = s.length();
    vector<char> s_shrink;
    rep(i, n-1) {
        if ( s[i] != s[i+1] ) s_shrink.push_back(s[i]);
    }
    cout << int(s_shrink.size()-1) << endl;
    return 0;
}


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

const int mod = 1e9 + 7;
vector<int> ps;
vector<int> phi;

long long my_pow(long long a, long long b) {
    long long ans(1);
    while (b) {
        if (b % 2) ans = ans * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return ans;
}

vector<int> p(int n) {
    vector<int> ans(n + 1);
    phi.resize(n + 1);
    phi[1] = 1;
    ans[0] = ans[1] = 1;

    for (int i = 2; i <= n; ++i) {
        if (!ans[i]) {
            ps.push_back(i);
            phi[i] = i - 1;
        }
        
        for (int j = 0; j < ps.size() && ps[j] * i <= n; ++j) {
            ans[i * ps[j]] = 1;
            if (i % ps[j] == 0) {
                phi[i * ps[j]] = phi[i] * ps[j];
                break;
            } else {
                phi[i * ps[j]] = phi[i] * phi[ps[j]];
            }
        }
    }
    
    return ps;
}

int main() {
    int n, k;
    cin >> n >> k;
    long long ans(0);
    p(k);
    for (int i = 1; i <= k; ++i) { // k
        // log(n) + n * log(n)
        ans += my_pow(k / i, n) * phi[i] % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
int main()
{
    ll ans,n,m;
    scanf("%lld%lld",&n,&m);
    if(n==1&&m==1)
        ans=1;
    else if(n==1)
    {
        ans=m-2;
    }
    else if(m==1)
    {
        ans=n-2;
    }
    else ans=(n-2)*(m-2);
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,m,ans=0,a,b;
    cin>>n;
    int t[n+1];
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    cin>>m;
    int px[m+1][3];
    for(int j=0;j<m;j++){
        for(int c=0;c<2;c++){
            cin>>px[j][c];
        }
        
        
    }
    for(int k=0;k<m;k++){
        a=px[k][0]-1;
        b=t[a];
        t[a]=px[k][1];
        for(int l=0;l<n;l++){
            ans+=t[l];
        }
        cout<<ans<<endl;
        t[a]=b;
        ans=0;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    long n = 0 , capacity = 0 , maxValue = 0 ; 
    cin >> n >> capacity ; 
    long weight[n+1] , value[n+1] , WeightforValue[n+1][100000+1] ;
    for(long i = 0 ; i <= n ; i++){
        weight[i] = value[i] = 0 ;
        for(long val = 0 ; val <= 100000 ; val++){
            WeightforValue[i][val] = 0 ;
        }
    }
    for(long i = 1 ; i <= n ; i++)
        cin >> weight[i] >> value[i] ;
    for(long i = 1 ; i <= n ; i++){
        for(long val = 0 ; val <= 100000 ; val++)
            WeightforValue[i][val] = WeightforValue[i-1][val] ;
        for(long val = 0 ; val <= 100000 ; val++){
            if(WeightforValue[i-1][val] != 0){
                if(WeightforValue[i][val+value[i]] == 0) 
                    WeightforValue[i][val+value[i]] = WeightforValue[i-1][val] + weight[i] ;
                else WeightforValue[i][val+value[i]] = min(WeightforValue[i][val+value[i]] , WeightforValue[i-1][val] + weight[i]) ;
            }
        }
        if(WeightforValue[i][value[i]] == 0) WeightforValue[i][value[i]] = weight[i] ;
        else WeightforValue[i][value[i]] = min(WeightforValue[i][value[i]] , weight[i]) ;
    }
    for(long i = 1 ; i <= n ; i++)
        for(long val = 1 ; val <= 100000 ; val++)
            if(WeightforValue[i][val] != 0 && WeightforValue[i][val] <= capacity)
                maxValue = max(maxValue, val) ;
    cout << maxValue ;
}

Measured memory_bytes: 82536
package main
 
import (
  "fmt"
)
 
func main() {
  var p, q, r int
  fmt.Scanf("%d %d %d", &p, &q, &r)
  
  ans := p + q + r
  max := p
  if max < q {
    max = q
  }
  if max < r {
    max = r
  }
  
  ans -= max
  fmt.Printf("%d\n", ans)
}

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

using namespace std;

void solver() {
    vector<int> m;
    REP(i,10){
        int n;
        cin>>n;
        m.push_back(n);
    }
    sort(m.begin(),m.end(),greater<int>());
    REP(i,3){
        cout<<m[i]<<endl;
    }
}

int main() {
    solver();
    return 0;
}

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();		//遊ぶ人数
		int k=sc.nextInt();		//身長制限
		int count=0;
		
		for(int i=0;i<n;i++) {
			int h=sc.nextInt();
			if(k<=h) {
				count+=1;
			}
		}
		System.out.println(count);

	}

}

Measured memory_bytes: 48092
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (int)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>        P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	ll A, B, N;
	cin >> N >> A >> B;

	ll ans = (N / (A + B)) * A;
	ll amari = min(N % (A + B), A);
	ans += amari;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
def devide_rl(s,n):
    tmp = "R"
    x = []
    y = []
    count = 0
    for i in range(n):
        if "R" == tmp and "L" == s[i]:
            count = i - 1
        else:
            pass

        if "L" == tmp and "R" == s[i]:
            y.append((x,count))
            x = []
            x.append(s[i])
            tmp = s[i]
        else:
            x.append(s[i])
            tmp = s[i]

    else:
        y.append((x,count))

    return y

def gathering_childern(s,n):
    y = devide_rl(s,n)
    ylen = len(y)
    ans = [0]*n
    last = 0
    for i in range(ylen):
        a,p= y[i]
        alen = len(a)
        rtotal, ltotal = 0, 0

        for j in range(last,last+alen):
            if p%2==j%2:
                rtotal += 1
            else:
                ltotal += 1
        last = j+1
        ans[p] = rtotal
        ans[p+1] = ltotal

    return ans


if __name__ == '__main__':
    s = raw_input()
    n = len(s)
    a = gathering_childern(s,n)

    for i in range(n):
        print(a[i]),
    print("")

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

int main() {
    long N, K, a, b;
    cin >> N >> K;


    a = N % K;
    b = a-K;
    if (b<0) {
        b = -b;
    }

    cout << min(a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
/* ex5_3
   tamayama */

#include<stdio.h>
#define SIZE 100

int main(void){
    int table_height,table_width;
    char table[SIZE][SIZE];
    int i,j,k,l,m,n,x,y;
    int count = 0;

    scanf("%d %d",&table_height,&table_width);   /*.や#を入力する*/
    for(i=0;i<table_height;i++){
        for(j=0;j<table_width;j++){
            scanf(" %c",&table[i][j]);
        }
    }
    for(i=0;i<table_height;i++){    /*.のみの行をxに変換する*/
        for(j=0;j<table_width;j++){
            if(table[i][j] == '.'){
                count++;
                if(count == table_width){
                    for(k=0;k<table_width;k++){
                        table[i][k] = 'x';
                    }
                }
            }
        }count = 0;
    }
    for(l=0;l<table_width;l++){    /*.またはxの行をxに変換する*/
        for(m=0;m<table_height;m++){
            if(table[m][l] == '.' || table[m][l] == 'x'){
                count++;
                if(count == table_height){
                    for(n=0;n<table_height;n++){
                        table[n][l] = 'x';
                    }
                }
            }
        }count = 0;
    }

    for(x=0;x<table_height;x++){    /*xを無視して出力する*/
        for(y=0;y<table_width;y++){
            if(table[x][y] != 'x'){
            printf("%c",table[x][y]);
            }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        try {
            String line;
            line = br.readLine();
            st = new StringTokenizer(line);
            long m = Long.parseLong(st.nextToken());
            long n = Long.parseLong(st.nextToken());
            long r = 1;
            ArrayDeque<Long> deque = new ArrayDeque<>(factorize(n));
            for (Long aLong : deque) {
                r = 1;
                for (long i = 0; i < aLong; i++) {
                    r = r * m;
                    if (r >= 1000000007) {
                        r = r % 1000000007;
                    }
                }
                m = r;
            }
            System.out.println(r);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    private static ArrayDeque<Long> factorize(long n) {
        ArrayDeque<Long> deque = new ArrayDeque<>();
        return factorize(deque, n, 3);
    }

    private static ArrayDeque<Long> factorize(ArrayDeque<Long> deque, long n, long r) {
        if (n == 1) {
            return deque;
        } else if (isPrime(n)) {
            deque.add(n);
            return deque;
        } else if (n % 2 == 0) {
            deque.add((long)2);
            n = n / (long) 2;
            factorize(deque, n, r);
        } else {
            for (long i = r; i <= n; i += 2) {
                if (n % i == 0) {
                    r = i;
                    deque.add(i);
                    n = n / i;
                    factorize(deque, n, r);
                    break;
                }
            }
        }
        return deque;
    }

    private static boolean isPrime(long n) {
        if (n == 2) {
            return true;
        }
        if (n < 2 || n % 2 == 0) {
            return false;
        }

        int i = 3;
        while (i <= Math.sqrt((double) n)) {
            if (n % i == 0) {
                return false;
            }
            i = i + 2;
        }
        return true;
    }
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int n = read(), pre = 0, ans = 0;
  REP(i, n) {
    int h = read();
    if (h > pre) ans += h - pre;
    pre = h;
  }
  print(ans);
}


Measured memory_bytes: 256
//
// Created by moono on 2018/10/27.
//

#include <vector>
#include <iostream>
using namespace std;

bool check(vector<int> A){
    for(int i: A){
        if(i % 2 == 1) return false;
    }
    return true;
}


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

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


    //
    int ans = 0;
    while(check(A)){
        for (int i = 0; i < N; ++i) {
            A[i] = A[i]/2;
        }
        ans++;
    }


    cout << ans << endl;

    return 0;
}

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

static const int MAX = 1e+5;
int f[MAX];

int main(){
    int n;
    cin >> n;
    for(int x = 1; x * x <= n; x++){
        for(int y = 1; y * y <= n; y++){
            for(int z = 1; z * z <= n; z++){
                f[x*x + y*y + z*z + x*y + y*z + z*x]++;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        cout << f[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3824
n    = gets.to_i
ary  = gets.split.map(&:to_i)
aryC = Array.new((n + 1) / 2, 0)

ary.each do |i|
  if aryC[i / 2] >= 2 || n % 2 == i % 2
    puts 0
    exit
  else
    aryC[i / 2] += 1
  end
end

for i in 1 .. (n - 1) / 2
  if aryC[i] != 2
    puts 0
    exit
  end
end

ans = 1
(n / 2).times do
  ans = (ans * 2) % (1E9 + 7)
end

puts ans.to_i


Measured memory_bytes: 8452
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  ll N,K; cin>>N>>K;
  char S[N];
  rep(i,N){
    cin>>S[i];
  }
  
  vector<ll> hand;
  
  if(S[0]=='0') hand.push_back(0);
  if(N==1) hand.push_back(S[0]-'0');
  else{
    ll count=1;
    rep(i,N-1){
      if(S[i]==S[i+1]){
        count++;
        if(i==N-2) hand.push_back(count);
        continue;
      }
      else{
        hand.push_back(count);
        count=1;
        if(i==N-2) hand.push_back(count);
      }
    }
  }
    if(S[N-1]=='0') hand.push_back(0);
    
    ll M=hand.size();
    ll judge=(M-1)/2;
    
    //累積和
    vector<ll> ad;
    
    ll count1=0;
    ad.push_back(count1);
    rep(i,M){
      count1+=hand[i];
      ad.push_back(count1);
    }
    ll ans=0;
    if(K>=judge) cout<<ad[M]<<endl;
    else{
      ll volu=(M-2*K-1)/2+1;
      rep(i,volu){
        ll volu2=i*2;
        ll ans1=ad[volu2+2*K+1]-ad[volu2];
        ans=max(ans,ans1);
      }
      cout<<ans<<endl;
    }
}
  
    
      

Measured memory_bytes: 2676
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		
		if(a>b)System.out.println("a > b");
		else if(a==b)System.out.println("a == b");
		else if(a<b)System.out.println("a < b");
	}
}

Measured memory_bytes: 17160
a,b,c,x = (int(input()) for i in range(4))
d = 0

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500 * i + 100 * j + 50 * k == x:
        d += 1
        
print(d)

Measured memory_bytes: 3064
# Belongs to : midandfeed aka asilentvoice
w = str(input()).lower()
ans = 0
while(1):
	s = str(input())	
	if s == "END_OF_TEXT":
		break
	else:
		ans += sum([1 for x in s.split() if x.lower() == w])
		
print(ans)

Measured memory_bytes: 7584
import math
n = int(input())
prime = [2]
res = [2]
for i in range(3, 55555):
    isp = True
    for j in prime:
        if int(math.sqrt(i)) < j:
            break
        if i % j == 0:
            isp = False
            break
    if isp:
        prime.append(i)
        if i % 5 == 2:
            res.append(i)
            if len(res) == n:
                break
for i in range(0, n):
    print(res[i], end="")
    if i == n - 1:
        break
    print(" ", end="")


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

int main() {
  long N=0, sum=0, ans=0;
  cin >> N ;
  for (int i = 0; i < N; i++) {
    sum ++;
    if(sum % 3 == 0 || sum % 5 == 0)   continue;
    else ans += sum;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
n = int(input())
p = [int(_) for _ in input().split()]
flg = False
flg1 = True
for i in range(n):
    for j in range(n):
        flg1 = True
        q = p[:]
        q[i]=p[j]
        q[j]=p[i]
        for k in range(n):
            for l in range(n):
                if k < l and q[k]>q[l]:
                    flg1 = False
                    break
                if l==n-1 and k==n-1 and flg1:
                    flg = True
        
if flg:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
n=int(input())
lx=[]
ly=[]
for i in range(n):
  x,y=map(int,input().split())
  lx.append(x+y)
  ly.append(x-y)
ax,bx,ay,by=max(lx),min(lx),max(ly),min(ly)
print(max(ax-bx,ay-by))


Measured memory_bytes: 96728