akhauriyash/Code-Regression huggingface dataset:
#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++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
#define PER(i,n) for(int i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }

int n;

int dfs(int v, const vii &g, vb &seen) {
  seen[v] = true;
  int res = 0;
  bool ok = true;
  rep(i,n) if(seen[i] == false) ok = false;
  if(ok) res++;
  for(int nv : g[v]) {
    if(seen[nv]) continue;
    res += dfs(nv, g, seen);
  }
  seen[v] = false;
  return res;
}

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

  int m;
  cin >> n >> m;
  vii g(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vb seen(n);
  int s = 0;
  int ans = dfs(s,g,seen);
  cout << ans << endl;
}

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

using ll = long long;

void solve(){
	int n;
	cin >> n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	string s;
	cin >> s;
	const ll B = 62;
	vector<ll> what(62);
	for(int i = n-1; i >= 0; i--){
		ll cur = a[i];
		for(int j = B-1; j >= 0; j--){
			if(what[j] && (cur & (1ll << j))){
				cur ^= what[j];
			}
		}
		if(s[i] == '0'){
			for(int j = B-1; j >= 0; j--){
				if((cur & (1ll << j))){
					what[j] = cur;
					break;
				}
			}
		} else if(s[i] == '1'){
			if(cur != 0){
				cout << "1" << '\n';
				return;
			}
		}
	}
	cout << "0" << '\n';
	return;
}

int main(){
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	int T;
	cin >> T;
	while(T--) solve();
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int n,m,C[110][110],K,mod,p[110][110],f[2][110][110];
void clean(int o){for(int i=0;i<=n;i++)for(int j=0;j<=m;j++)f[o][i][j]=0;}
int main()
{
	scanf("%d%d%d%d",&n,&m,&K,&mod);
	for(int i=0;i<=max(n,m);i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	}
	for(int i=1;i<=K;i++)
	{
		p[i][0]=1;
		for(int j=1;j<=max(n,m);j++)p[i][j]=1ll*p[i][j-1]*i%mod;
	}
	f[0][0][0]=1;int o=0;
	for(int k=1;k<=K;k++)
	{
		clean(o^1);
		for(int i=0;i<=n;i++)for(int j=0;j<=m;j++)
		{
			int x=f[o][i][j],y=1ll*p[K-k+1][j]*p[k][m-j]%mod;
			for(int a=0;i+a<=n;a++,x=1ll*x*y%mod)f[o^1][i+a][j]=(f[o^1][i+a][j]+1ll*C[n-i][a]*x)%mod;
		}
		o^=1; 
		clean(o^1);
		for(int i=0;i<=n;i++)for(int j=0;j<=m;j++)
		{
			int x=f[o][i][j],y=1ll*p[K-k+1][i]*p[k][n-i]%mod;
			for(int b=0;j+b<=m;b++,x=1ll*x*y%mod)f[o^1][i][j+b]=(f[o^1][i][j+b]+1ll*C[m-j][b]*x)%mod;
		}
		o^=1; 
		clean(o^1);
		for(int i=0;i<=n;i++)for(int j=0;j<=m;j++)
		{
			int x=f[o][i][j],y=1ll*-p[K-k][j]*p[k][m-j]%mod;
			for(int a=0;i+a<=n;a++,x=1ll*x*y%mod)f[o^1][i+a][j]=(f[o^1][i+a][j]+1ll*C[n-i][a]*x)%mod;
		}
		o^=1; 
		clean(o^1);
		for(int i=0;i<=n;i++)for(int j=0;j<=m;j++)
		{
			int x=f[o][i][j],y=1ll*-p[K-k][i]*p[k][n-i]%mod;
			for(int b=0;j+b<=m;b++,x=1ll*x*y%mod)f[o^1][i][j+b]=(f[o^1][i][j+b]+1ll*C[m-j][b]*x)%mod;
		}
		o^=1; 
	} 
	printf("%d",(f[o][n][m]+mod)%mod);
	return 0;
}

Measured memory_bytes: 3780
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
#include <functional>
#include <unordered_set>
#define rep(i, n) for(int i = 0; i < n; i++)
//#include <Windows.h>
//#include "Library.h"
//#include "Math.h"
using namespace std;
typedef long long int ll; typedef pair <int, int> P; typedef vector <int> vecint;
const int INF = 100000000000;
const double EPS = 10e-9;
int main()
{
	int x; cin >> x;
	int a[4]; 
	a[0] = x / 1000;
	x %= 1000;
	a[1] = x / 100;
	x %= 100;
	a[2] = x / 10;
	x %= 10;
	a[3] = x;
	int ans;
	rep(i, 1 << 3)
	{
		int res = a[0];
		rep(j, 3)
		{
			if (i >> j & 1)
			{
				res += a[j + 1];
			}
			else res -= a[j + 1];
		}
		if (res == 7)
		{
			ans = i; break;
		}
	}
	cout << a[0];
	if (ans >> 0 & 1) cout << '+';
	else cout << '-';
	cout << a[1];
	if (ans >> 1 & 1) cout << '+';
	else cout << '-';
	cout << a[2];
	if (ans >> 2 & 1) cout << '+';
	else cout << '-';
	cout << a[3];
	cout << "=" << 7 << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
 
N,M=map(int,input().split())
 
graph=[[]for _ in range(N+1)]
 
for _ in range(M):
    A,B=map(int,input().split())
    graph[A].append(B)
    graph[B].append(A)
 
dist=[-1]*(N+1)
dist[0]=0
dist[1]=0
 
D=deque()
D.append(1)
 
while D:
    V=D.popleft()
    for i in graph[V]:
        if dist[i]!=-1:
            continue
        dist[i]=V
        D.append(i)
 
print('Yes')
for j in dist[2:]:
    print(j)


Measured memory_bytes: 34868
#include <iostream>
#include <stdio.h> 

using namespace std;
int main(){
	double a, b;
	cin>>a;
	cin>>b;
	if(a>b){
		cout<<"GREATER"<<endl;
	}else if(a<b){
		cout<<"LESS"<<endl;
	}else if(a==b){
		cout<<"EQUAL"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
const int INF = (int)(1e18)+3ll;
signed main(){
    int n,k;cin >> n >> k;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    sort(a.begin(),a.end());
    vector<int> b = a;
    reverse(b.begin(),b.end());
    auto cnt = [&](int x,int y,vector<int> &v){
        //x*v[i] < yとなるiの個数
        int bot = -1,top = n;
        while(top - bot > 1){
            int mid = (top + bot )/2;
            if(v[mid]*x < y)bot = mid;
            else top = mid;
        }
        return top;
    };
    auto ok = [&](int x){
        //x未満がkこ未満か
        int ret = 0;
        rep(i,n){
            if(a[i] >= 0)ret += cnt(a[i],x,a);
            else ret += cnt(a[i],x,b);
            if(a[i]*a[i] < x)ret--;
        }
        ret /= 2;
        return ret < k;
    };
    int top = INF;
    int bot = -INF;
    while(top - bot>1){
        int mid = (top + bot)/2;
        if(ok(mid))bot = mid;
        else top = mid;
    }
    cout << bot << endl;
    return 0;
}

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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int X,N; cin >> X >> N;
  vector<int> p(N);
  for(int i = 0; i < N; i++){
    cin >> p[i];
  }
  sort(p.begin(), p.end());

  int min_val = 1000;
  int ans;
  for(int i = 200; i >= 0; i--){
    // 
    if(find(p.begin(), p.end(), i) == p.end()){
      int tmp = abs(X - i);
      if(tmp <= min_val){
        min_val = tmp;
        ans = i;
      } 
    }
  }
  cout << ans << endl;

}


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

int main(){
  Int a, b, t;
  cin >> a >> b >> t;
  
  Int cnt = 0;
  Int time = a;
  
  if(a>t){
    cout << 0 << endl;
    return 0;
  }
  while(time <= t){
    cnt += b;
    time += a;
  }
  cout << cnt << endl;
  return 0;
}

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

int main() {
  long long x,y;
  cin >> x >> y;
  if(y == 1 || x%y == 0) cout << -1 << endl;
  else{
    if(y == 1000000000) cout << x*(y-1) << endl;
    else cout << x*(y+1) << endl;
  }
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)

int main(){
    string s; cin >> s;
    int rel = 0;
    for(int i=2; i < s.size(); i += 2){
        if(s.substr(0, i/2) == s.substr(i/2, i/2)) rel = i;
    }
    cout << rel << endl;
    return 0;
}

Measured memory_bytes: 384
using System;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string[] w = new string[n];
        for (int i = 0; i < n; i++)
            w[i] = Console.ReadLine();
        bool flag = false;

        for (int i = 0; i < n - 1; i++)
        {
            if (w[i][w[i].Length - 1] != w[i + 1][0])
            {
                flag = true;
                break;
            }
        }

        for (int i = 0; i < n; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                if (w[i] == w[j])
                {
                    flag = true;
                    break;
                }
            }
            if (flag == true) break;
        }

        if (flag) Console.WriteLine("No");
        else Console.WriteLine("Yes");
    }
}

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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
    int N; cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];
    int max = 0;
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        if (H[i] >= max)
        {
            max = H[i];
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int fee_list[6] = {600, 800, 1000, 1200, 1400, 1600};

int checkSize(int x, int y, int h);
int checkWeight(int w);

int main()
{
    int n;
    while(1)
    {
        int ans = 0;
        cin >> n;
        if(n == 0)
        {
            break;
        }
        for(int i=0; i<n; i++)
        {
            int x;
            int y;
            int h;
            int w;
            int rank;
            cin >> x >> y >> h >> w;
            rank = std::max(checkSize(x, y, h),checkWeight(w));
            if(rank < 6)
            {
                ans += fee_list[rank];
            }
        }
        cout << ans << endl;
    }
    return 0;
}

int checkSize(int x, int y, int h)
{
    int total = x + y + h;
    int ret_value;

    if(total <= 60)
    {
        ret_value = 0;
    }
    else if(total <= 80)
    {
        ret_value = 1;
    }
    else if(total <= 100)
    {
        ret_value = 2;
    }
    else if(total <= 120)
    {
        ret_value = 3;
    }
    else if(total <= 140)
    {
        ret_value = 4;
    }
    else if(total <= 160)
    {
        ret_value = 5;
    }
    else
    {
        ret_value = 6;
    }
    return ret_value;
}

int checkWeight(int w)
{
    int ret_value;

    if(w <= 2)
    {
        ret_value = 0;
    }
    else if(w <= 5)
    {
        ret_value = 1;
    }
    else if(w <= 10)
    {
        ret_value = 2;
    }
    else if(w <= 15)
    {
        ret_value = 3;
    }
    else if(w <= 20)
    {
        ret_value = 4;
    }
    else if(w <= 25)
    {
        ret_value = 5;
    }
    else
    {
        ret_value = 6;
    }
    return ret_value;
}

Measured memory_bytes: 2984
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)
        self.weight = [0] * (n + 1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 重さの検索
    def weighting(self, x):
        self.find(x)
        return self.weight[x]

    # 併合
    def unite(self, x, y, w):
        px = self.find(x)
        py = self.find(y)
        if px != py:
            if self.rank[px] < self.rank[py]:
                self.par[px] = py
                self.weight[px] = w - self.weight[x] + self.weight[y]
            else:
                self.par[py] = px
                self.weight[py] = -w - self.weight[y] + self.weight[x]
                if self.rank[px] == self.rank[py]:
                    self.rank[px] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # 各頂点間の絶対距離
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]


N, M = map(int, input().split())
graph = WeightedUnionFind(N)

for i in range(M):
    l, r, d = map(int, input().split())
    if not graph.same(l-1, r-1):
        graph.unite(l-1, r-1, d)
    else:
        if graph.diff(l-1, r-1) != d:
            print('No')
            quit()

print('Yes')



Measured memory_bytes: 102560
N = int(input())
H = str(input())
heights = [int(h) for h in H.split(' ')]
obstacles = [0]
for idx in range(N - 1):
    h1 = heights[idx]
    h2 = heights[idx + 1]
    if h1 < h2:
        obstacles.append(idx + 1)

obstacles.append(N)
max_span = -1
for idx in range(len(obstacles) - 1):
    ob1 = obstacles[idx]
    ob2 = obstacles[idx + 1]
    span = ob2 - ob1 - 1
    if span > max_span:
        max_span = span
    
print("%d" % max_span)


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	int n;cin>>n;
    vector<int> h(n);
    int ans;
    rep(i,n){
        cin>>h[i];
        if(i==0)ans=h[0];
        if(i>0&&h[i]>h[i-1])ans+=h[i]-h[i-1];
    }
    cout<<ans<<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)


int main() {
  int ans = 0;
  rep(i,3){
    char a;
    cin >> a;
    if(a == '1') ans++;
  }
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <stdio.h>

int h=0,aa[2000000000];

void mh(int i){
  int l,r,big,t;

  l = i*2;
  r = i*2 + 1;

  if(l<=h && aa[l]>aa[i])big = l;
  else big = i;
  if(r<=h && aa[r] > aa[big])big = r;

  if(big!=i){
    t=aa[i];
    aa[i]=aa[big];
    aa[big]=t;
    mh(big);
  }
}

/*
void bmh(void){
  int i;
  for(i=h/2;1<=i;i--){
    mh(i);
  }
}
*/

void in(int key){
  int t,tt;
  h++;
  tt=h;
  aa[h] = key;
  while(1<tt && aa[tt/2]<aa[tt]){
    t=aa[tt];
    aa[tt] = aa[tt/2];
    aa[tt/2] = t;
    tt = tt/2;
  }   
}

void ex(void){
  printf("%d\n",aa[1]);
  aa[1] = aa[h];
  h--;
  mh(1);
}
  

int main(){
  int i,key;
  char com[10];

  while(1){
    scanf("%s",com);
    if(com[2]=='d')break;

    if(com[0]=='i'){
      scanf("%d",&key);
      in(key);
    }
    else if(com[0]=='e'){
      ex();
    }
  }

  return 0;
}



Measured memory_bytes: 5608
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];
        int[] count = new int[n + 1];
        var py = Enumerable.Repeat(0, m).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
        string[] res = new string[m];
        foreach (var (elem, ind) in py.Select((elem, ind) => (elem, ind)).OrderBy(x => x.elem[1]))
        {
            var p = elem[0];
            res[ind] = $"{p:000000}{++count[p]:000000}";
        }

        Console.WriteLine(string.Join("\n", res));
    }
}

Measured memory_bytes: 55268
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <ctime>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

typedef long long LL;
const int N = 200010;

int a[N];
LL p[N];

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	Rep(i, n) scanf("%d", &a[i]);
	a[0] = 1;
	LL sum = 0;
	for (int i = 2; i <= n; i ++) {
		int l = a[i - 1], r = a[i];
		if (r < l) r += m;
		sum += r - l;
		if (r - l > 1) {
			p[l + 2] ++;
			p[r + 1] -= r - l;
			p[r + 2] += r - l - 1;
		}
	}
	Rep(t, 2) Rep(i, m * 2) p[i] += p[i - 1];
	LL ans = 1e18;
	Rep(i, m) ans = min(ans, sum - p[i] - p[i + m]);
	
	printf("%lld\n", ans);
	
	return 0;
}


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

int main(void){
    string s,t;
    cin >> s >> t;
    for(int i = 0;i < s.size();i++){
        if(s.at(i) != t.at(i)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"

using namespace std;

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

bool isp[1000000]={};


void makeEra(){
    for(int i=2;i<=1000;i++){
        if( isp[i] ){
            for(int j=2;j<=1000000/i;j++){
                isp[i*j]=false;
            }
        }
    }
}


int main(){
    rep(i,1000000)isp[i]=true;
    isp[0]=isp[1]=false;
    makeEra();
    
    int n;
    while(cin>>n){
        int c = 0;
        rep(i,n+1){
            if(isp[i])c++;
        }
        cout<<c<<endl;
    }
}

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

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

long long read(){
	long long i;
	cin >> i;
	return i;
}

string Suffling(const string& text) {
	string deck(text);
	int m = read();
	REP(i, m) {
		int h = read();
		deck = deck.substr(h, deck.size() - h) + deck.substr(0, h);
	}
	return deck;
}

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

	string s;
	for (cin >> s; s != "-"; cin >> s) {
		cout << Suffling(s) << endl;
	}
	return 0;
}



Measured memory_bytes: 3184
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class B
{
	public static void Main()
	{
		string S = Console.ReadLine();
		int N = Int32.Parse(S);

		int SN = 0;
		int tmpN = N;
		for(int i = 0; i < S.Length; i++)
		{
			SN += (tmpN % 10);
			tmpN /= 10;
		}

		Console.WriteLine(((N % SN) == 0) ? "Yes" : "No");
	}	
}





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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string a;
  cin >> a;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
  	cnt += (int) (a[i] == 'R');
  }
  if (cnt > n - cnt) {
  	cout << "Yes" << '\n';
  } else {
  	cout << "No" << '\n';
  }
  return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N ;
  int Check = 0;
  for(int i = 0; i < N; i++){
  	cin >> S;
    if(S == "Y"){
    	Check = 1;
      	break;
    }
  }
  if( Check == 0){
  	cout << "Three" << endl;
  }else{
    cout << "Four" << endl;
  }
}


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

int main() {
  int n;
  cin>>n;
  int l[n];
  for (int i=0; i<n; i++) cin>>l[i];
  sort(l, l + n);
  long long ans = 0;
  for (int i=0; i<n; i++) {
    for (int j=i+1; j<n; j++) {
      int a = l[i];
      int b = l[j];
      auto it = lower_bound(l, l + n, a + b);
      --it;
      int r_idx = it - l;
      ans += r_idx - j;

    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int c[26];
int s[365][26];
int t[365];
int last[26];

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

	for (int i=0; i<26; i++) {
		cin >> c[i];
		last[i] = -1;
	}

	for (int d=0; d<D; d++) {
		for (int i=0; i<26; i++) {
			cin >> s[d][i];
		}
	}

	for (int d=0; d<D; d++) {
		cin >> t[d];
		t[d]--;
	}

	int score = 0;

	for (int d=0; d<D; d++) {
		for (int i=0; i<26; i++) {
			if (i == t[d]) {
				score += s[d][i];
				last[i] = d;
			} else {
				score -= c[i] * (d - last[i]);
			}
		}

		cout << score << endl;
	}

	return 0;
}

Measured memory_bytes: 3656
function Main(input){
    input=input.split("\n");  //ここまで必須
    var point=0;
    inputA=input[1].split(" ");
    for (i=inputA[1];i>parseInt(inputA[0])-1;i--){
        if (i%input[0]==0){point=point+1}
    }
    if (point>0){console.log("OK")} else {console.log("NG")}
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));


Measured memory_bytes: 29532
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,l;
	int i,j;
	int sum,x;
	int MIN;
	int point;
	cin>>n>>l;
	MIN=INT_MAX;
	point=n+1;
	x=0;
	for(i=1;i<=n;i++)	x+=l+i-1;
	for(i=1;i<=n;i++){
		sum=0;
		for(j=1;j<=n;j++){
			if(i!=j){
				sum+=l+j-1;
			}
		}
		//cout<<sum<<endl;
		if(MIN>abs(sum-x)){
			MIN=abs(sum-x);
			point=sum;
		}
	}
	cout<<point<<endl;
	return  0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
static const int MAX = 3E+5;

int main()
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    int x = 0;
    for (int i = 1; i < N; i++)
    {
        if (S[i] == 'E')
        {
            x++;
        }
    }

    int xtemp = x;
    for (int i = 1; i < N; i++)
    {
        if (S[i - 1] == 'W')
        {
            xtemp++;  
        }
        if (S[i] == 'E')
        {
            xtemp--;
        }
        if (xtemp < x)
        {
            x = xtemp;
        }
    }

    cout << x << endl;
    return 0;
}

Measured memory_bytes: 900
package main

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

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

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

func euc(a,b int) int {
	r := a%b
	x := b
	for ; r != 0; {
		x, r = r, x%r
	}
	return x
}

func main() {
	sc.Split(bufio.ScanWords)
	var a,b int64
	var c,d int

	fmt.Scan(&a,&b,&c,&d)

	lcm := c*d/euc(c,d)

	cnum := b/int64(c) - (a-1)/int64(c)
	dnum := b/int64(d) - (a-1)/int64(d)
	lcmnum := b/int64(lcm) - (a-1)/int64(lcm)

	fmt.Println(b-a+1-cnum-dnum+lcmnum)
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int p = 13331;
map<ll,int>has1;
long long hh[5005]={0};
long long aa[5005]={0};
char s[5005]={0};
ll gethashcode(int i,int j){
    if(i==0)
        return hh[j];
    else
    return hh[j]-hh[i-1]*aa[j-i+1];
}
int n;
bool check(int m){
        has1.clear();
        ll num;
        for(int i=1;i+m-1<=n;i++){
        num=gethashcode(i,i+m-1);
        if(has1[num]){
            if(has1[num]<=i-m)
                return 1;
            //cout << i << " " << has1[num] << endl;
        }
        else
            has1[num]=i;
    }
    return 0;
}
int main()
{
    cin >> n;
    cin >> s;
    ll num;
    aa[0]=0;
    for(int i=0;i<n;i++){
        hh[i+1]=hh[i]*p+s[i]-'a';
    }
    aa[0]=1;
    for(int i=1;i<=n;i++)
        aa[i]=aa[i-1]*p;
    int res=0;
    int l=0,r=n;
    int mid;
    int flag=0;
    //cout << check(5) << endl;
    while(l<r){
        mid=(l+r)/2;
        if(check(mid)){
            res=mid;
            l=mid+1;
        }
        else
            r=mid;
    }
    printf("%d\n",res);
    return 0;
}



Measured memory_bytes: 640
#a, b, c = map(int, input().split())
s = input()

len = len(s)

cnt = 0

for i in range(len//2):
  #print( s[len-1-i] )
  if( s[i] != s[len-1-i] ):
    cnt += 1
    #print("!")
  else:
    continue
    
print(cnt)

Measured memory_bytes: 38256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int caves[1005][1005];
int dy[] = {0,-1,0,1};
int dx[] = {1,0,-1,0};
int is_prime[1000005];
pi dp[1005][1005];

void init()
{
  memset(caves, -1, sizeof(caves));
  caves[502][502] = 1;
  caves[502][503] = 2;
  int x=503, y=502, d = 0;
  for(int i=3;i<=1000000;i++){
    int rd = (d+1)%4;
    int ry = y+dy[rd], rx = x+dx[rd];
    int ny = y+dy[d], nx = x+dx[d];
    //    cout << "rt " << d<< "  "<< ry << " " << rx << endl;
    if(caves[ry][rx] == -1){
      d = (d+1)%4;
      nx = x+dx[d], ny = y+dy[d];
    }
    //    cout << ny << " " << nx << endl;
    caves[ny][nx] = i;
    x = nx, y = ny;
  }

  is_prime[0] = is_prime[1] = 1;
  for(int i=2;i<=1000000;i++){
    if(is_prime[i]) continue;
    for(int j=i*2;j<=1000000;j+=i) is_prime[j] = 1;
  }

  /*  rep(i, 1000){
    if(!is_prime[i]) cout << i << endl;
  }
  */

}

pi dfs(int y, int x, int m)
{
  if(dp[y][x] != pi(-1, -1)) return dp[y][x];
  pi ret(0, 0);
  //  if(caves[y][x] == 947) cout << "ok\n";
  int ny=y+1;
  if(ny >= 1005) return ret;
  for(int nx=x-1;nx<=x+1;nx++){

    if(nx < 0 || nx >= 1005) continue;
    if(caves[ny][nx] == -1 || caves[ny][nx] > m) continue;
    //    if(caves[y][x] == 829) cout << caves[ny][nx] << endl;    
    ret = max(ret, dfs(ny, nx, m));
  }

  if(!is_prime[caves[y][x]]){
    if(ret == pi(0, 0)){
      ret = pi(1, caves[y][x]);
    }else{
      ret = pi(ret.first+1, ret.second);
    }
  }
  
  return dp[y][x] = ret;
}

pi solve(int m, int n)
{
  rep(i, 1005) rep(j, 1005){
    if(caves[i][j] == n)
      return dfs(i, j, m);
  }
  return pi(0, 0);
}

int main(){
  init();
  /*
  for(int i=482;i<518;i++){
    for(int j=484;j<516;j++) cout << caves[i][j]  << " ";
    cout << endl;
  }
  */
  int M, N;
  while(cin >> M >> N, M){
    rep(i, 1005) rep(j, 1005) dp[i][j] = pi(-1, -1);    
    pi res = solve(M, N);
    cout << res.first << " " << res.second << endl;
  }
  return 0;
}

Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    ll h;
    cin >> h;
    ll sum=0;
    ll now=1;
    while(h){
        if(h==1){
            sum+=now;
            h--;
        }
        else{
            sum+=now;
            now*=2;
            h/=2;
        }
    }
    cout << sum;


}

/*



 */



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

//  a^b % m
long long powmod(long long a, long long b, long long m)
{
    long long r = 1;
    for (; b>0; b>>=1, a=a*a%m)
        if (b&1)
            r = r*a%m;
    return r;
}

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

    long long MOD = 998244353;

    vector<long long> F(N);
    F[0] = 1;
    for (int i=1; i<N; i++)
        F[i] = F[i-1]*i%MOD;

    vector<long long> P(N);
    P[0] = 1;
    for (int i=1; i<N; i++)
        P[i] = P[i-1]*(M-1)%MOD;

    long long ans = 0;
    for (int k=0; k<=K; k++)
    {
        ans += M*P[N-k-1]%MOD*F[N-1]%MOD*powmod(F[N-1-k], MOD-2, MOD)%MOD*powmod(F[k], MOD-2, MOD)%MOD;
        ans %= MOD;
    }
    cout<<ans<<endl;
}


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

int main() {
	int a, n, j;
	cin >> n;
	for (int i = 0; i < n; i++) {
		vector<int> a(10);
		vector<int> b, c;
		for (j = 0; j < 10; ++j) cin >> a[j];
		for (j = 0; j < 11; j++) {
			if (j == 10) {
				break;
			}
			if (j == 0) {
				b.push_back(a[j]);
			}
			else if (a[j] < b[b.size() - 1] && c.size() == 0) {
				c.push_back(a[j]);
			}
			else if (a[j] > b[b.size() - 1]) {
				b.push_back(a[j]);
			}
			else if (a[j] > c[c.size() - 1]) {
				c.push_back(a[j]);
			}
			else {
				break;
			}
		}
		if (j == 10) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,i,j;
	cin>>n>>m;
	char a[n][m];
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			cin>>a[i][j];
		}
	}
	for(i=0;i<=m+1;i++) cout<<"#";
	cout<<endl;
	for(j=0;j<n;j++)
	{
		cout<<"#";
		for(i=0;i<m;i++) cout<<a[j][i];
		cout<<"#";
		cout<<endl;	
	}
	for(i=0;i<=m+1;i++) cout<<"#";
	cout<<endl;
 	return 0;
}


Measured memory_bytes: 256
import sys
import bisect
from itertools import product
def input(): return sys.stdin.readline().strip()
A,B,Q = map(int,input().split())
s = [int(input()) for i in range(A)]
t = [int(input()) for i in range(B)]
stlist = [s,t]
ab = [A,B]
for i in range(Q):
    x = int(input())
    cand = []
    for i in range(2):
        st = stlist[i]
        cand1 = set()
        l1 = bisect.bisect_left(st,x)
        r1 = bisect.bisect_right(st,x)
        if 0 <= l1 <= ab[i]-1:
            cand1.add(st[l1])
        if 0 <= l1-1 <= ab[i]-1:
            cand1.add(st[l1-1])  
        if 0 <= r1 <= ab[i]-1:
            cand1.add(st[r1])
        if 0 <= r1+1 <= ab[i]-1:
            cand1.add(st[r1+1])
        cand.append(cand1)
        
    ans = float('inf')
    for a,b in product(cand[0],cand[1]):
        c = min(abs(x-a)+abs(b-a),abs(x-b)+abs(b-a))
        ans = min(ans,c)
    print(ans)
        
        
    

Measured memory_bytes: 80092
// Marcin Knapik
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< int , null_type,less< int >, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ll>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<vll>             vvll;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vii>             vvii;
#define pll pair<long long, long long>
#define vpll vector<pll>
#define ull unsigned long long

#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second

template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}

template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<class T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return abs(a); }

const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll BIG_INF = 1e18 + 7;
const ll N = 1e6+7;
const ll T = 1<<20;
const ld inf = 1e18;

ll n, m, q, k;

vector<string> tab(N);

int zostalo(int x, int y){
	int ret = 0;
	FOR(i, n)
		FOR(j, m)
			if(((1 << i) & x) == 0 and ((1 << j) & y) == 0)
				ret += tab[i][j] == '#';
	return ret;
}

map<string, int> mapa;
void solve(){
	cin >> n >> m >> k;

	FOR(i, n)
		cin >> tab[i];

	int ans = 0;
	for(int i = 0; i < (1 << n); i++)
		for(int j = 0; j < (1 << m); j++)
			ans += zostalo(i, j) == k;
	cout << ans << '\n';
}


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

	q = 1;
	// cin >> q;

	while(q--)
		solve();
}	

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

int main() {
    int A, B;
    std::string S, T, U;

    std::cin >> S >> T;
    std::cin >> A >> B;
    std::cin >> U;

    if (S == U) {
        --A;
    } else {
        --B;
    }

    std::cout << A << " " << B << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int h, w, i, j;
	char c;
	cin >> h >> w;
	int arr[h][w], dp[h][w];
	fo(i, 0, h)
	{
		fo(j, 0, w)
		{
			cin >> c;
			arr[i][j] = (c == '.' ? 1 : 0);
		}
	}
	fo(i, 0, h)
	{
		fo(j, 0, w)
		dp[i][j] = 0;
	}
	dp[0][0] = 1;
	fo(i, 1, w)
	{
		if(arr[0][i] == 0)
		continue;
		dp[0][i] = dp[0][i - 1]; 
	}
	fo(i, 1, h)
	{
		fo(j, 0, w)
		{
			if(arr[i][j] == 0)
			continue;
			dp[i][j] = (dp[i - 1][j] + (j > 0 ? dp[i][j - 1] : 0)) % MOD;
		}
	}
	cout << dp[h - 1][w - 1];
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;
#define INF 1000000000000
#define NOD 1000000007
#define PI 3.141592653589793238462643

int main() {
    int n, s=0;
    cin >> n;
    s += (n)/100000;
    s += (n%100000)/10000;
    s += (n%10000)/1000;
    s += (n%1000)/100;
    s += (n%100)/10;
    s += (n%10);
    if(s != 1) cout << s << endl;
    else cout << 10 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    if(n>=30){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;


ll A, B,ans;

ll cul(ll N) {
	ll a = 1;
	if (((N+1) / 2) % 2 == 0)a = 0;
	if (N % 2 == 0)a = a ^ N;
	return a;
}


int main(void) {
	cin >> A >> B;
	ans = cul(A - 1) ^ cul(B);
	ct(ans);



	return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let k: usize = it.next().unwrap().parse().unwrap();
    let h: Vec<i32> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
    let mut dp = vec![std::i32::MAX; n];
    dp[0] = 0;
    for i in 1..n {
        for j in 1..(k + 1) {
            if j > i {
                break;
            }
            dp[i] = std::cmp::min(dp[i], dp[i - j] + (h[i] - h[i - j]).abs());
        }
    }
    println!("{}", dp[n - 1]);
}

fn main() {
    run();
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

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

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }
#define dump(...) cout<<#__VA_ARGS__<<": [L_"<<__LINE__<<"]"<<'\n'; print(__VA_ARGS__);cout<<'\n';

template<class T, class U>inline bool chmax(T &a, const U &b) { if(a<b){ a=b; return 1; } return 0; }
template<class T, class U>inline bool chmin(T &a, const U &b) { if(b<a){ a=b; return 1; } return 0; }


int main() {
  long long n, d, a; cin>>n>>d>>a;
  vector<pair<long long, long long>> xh(n);
  rep(i, n) cin>>xh[i].first>>xh[i].second;
  sort(xh.begin(), xh.end());
  
  long long ans = 0;
  long long acc = 0;
  queue<pair<long long, long long>> q;
  rep(i, n) {
    while (q.size() > 0 and q.front().first < xh[i].first) {
      acc -= q.front().second; q.pop();
    }
    if (acc >= xh[i].second) continue;
    else {
      long long t = ((xh[i].second - acc) % a == 0) ? (xh[i].second - acc) / a : (xh[i].second - acc) / a + 1;
      ans += t;
      acc += t * a;
      q.emplace(xh[i].first+2*d, t * a);
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <cstring>
#include <iomanip>
#include<queue>

using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1000000000
typedef long long  ll;

#define MOD 1000000007


int main()
{
    string s;
    cin >> s;
    int n;
    n = s.size();
    int K = 1;
    string ss = s.substr(0,1);
    int idx = 1;
    REP(i, 1, n)
    {
        if (ss != s.substr(idx, i - idx + 1))
        {
            ss = s.substr(idx, i - idx+1);
            K++;
            idx = i+1;
        }else{
            
        }
    }
    cout << K << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
main(){
    string S, T;
    int sum = 0;
    cin >> S >> T;
    if(S.at(0) == T.at(0)){
        sum++;
    }
    if(S.at(2) == T.at(2)){
        sum++;
    }
    if(S.at(1) == T.at(1)){
        sum++;
    }
    cout << sum <<endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	fmt.Scan(&N)
	m := make(map[int]int)
	for i := 0; i < int(N); i++ {
		var a int
		fmt.Scan(&a)
		m[a]++
	}
	fmt.Println(solve(m[1], m[2], m[3]))
}

var N float64
var memo [301][301][301]float64

func solve(i, j, k int) float64 {
	if i == 1 && j == 0 && k == 0 {
		return N
	}
	if i < 0 || j < 0 || k < 0 {
		return 0
	}
	if memo[i][j][k] > 0 {
		return memo[i][j][k]
	}
	ans := N
	ans += solve(i-1, j, k) * float64(i)
	ans += solve(i+1, j-1, k) * float64(j)
	ans += solve(i, j+1, k-1) * float64(k)
	ans /= float64(i + j + k)
	memo[i][j][k] = ans
	return ans
}


Measured memory_bytes: 109428
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,l;
    string s;
    ll c,d,cd;
    cin>>a>>b>>c>>d;
    ll divc,divd,divcd;
    divc=b/c;
    divc-=a/c;
    if(a%c==0) divc++;
    divd=b/d;
    divd-=a/d;
    if(a%d==0) divd++;
    cd=(c*d)/__gcd(c,d);
    divcd=b/cd;
    divcd-=a/cd;
    if(a%cd==0) divcd++;
    ll rem=divc+divd-divcd;
    ll ans=b-a+1;
    ans-=rem;
    cout<<ans;
    
}

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

int main(){
    int n, m; cin >> n >> m;
    ll ans = 0;
    priority_queue<int> q;
    vector<vector<int> > lis(n, vector<int>(2, 0));
    for(int i = 0; i < n; i++){
        cin >> lis[i][0] >> lis[i][1];
    }
    sort(lis.begin(), lis.end(), [](auto& x, auto& y){return x[0] < y[0];});
    int l = 0;
    for(int i = 1; i <= m; i++){
        for(;l < n && i >= lis[l][0]; l++){
            q.push(lis[l][1]);
        }
        if(q.empty()){continue;}
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 6396
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 taro = 0;
            var hanako = 0;

            for (var i = 0; i < n; i++)
            {
                var line = Console.ReadLine().Split();

                if (line[0] == line[1])
                {
                    taro++;
                    hanako++;
                    continue;
                }

                // 短いほうに合わせてループ
                var min = Math.Min(line[0].Length, line[1].Length);
                var isSame = true;

                for (var j = 0; j < min; j++)
                {

                    if (line[0][j] > line[1][j])
                    {
                        isSame = false;
                        taro += 3;
                        break;
                    }
                    else if (line[0][j] < line[1][j])
                    {
                        isSame = false;
                        hanako += 3;
                        break;
                    }
                }

                // 始まりが同じの場合は長いほうにポイントを与える
                if (isSame)
                {
                    if (min == line[0].Length)
                    {
                        hanako += 3;
                    }
                    else
                    {
                        taro += 3;
                    }
                }
            }

            Console.WriteLine($"{taro} {hanako}");
        }
    }
}


Measured memory_bytes: 15932