akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF 2e9
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

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

	long long int ans=0;
	rep(i, 1, n + 1)
	{
		if (i % 3 == 0 || i % 5 == 0)continue;
		ans += i;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  int H, W;
  cin >> H >> W;
  bool S[H][W];
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      char in;
      cin >> in;
      if(in == '#')
        S[i][j] = true;
      else
        S[i][j] = false;
    }
  }
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(S[i][j]){
        bool ok = false;
        if(i > 0)
          if(S[i-1][j])
            ok = true;
        if(i < H-1)
          if(S[i+1][j])
            ok = true;
        if(j > 0)
          if(S[i][j-1])
            ok = true;
        if(j < W-1)
          if(S[i][j+1])
            ok = true;
        if(!ok){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
  public class Main {
     
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}

  public static void main(String args[]) throws  IOException {
        assign();
        int t=1;//int_v(read());
        while(t--!=0){
            int[] n1=int_arr();
            int n=n1[0],k=n1[1];
            long[] pre=new long[n+1];
            long s=0,mod=(long)1e9+7,res=0;
            for(int i=1;i<=n;i++){s+=i;pre[i]=pre[i-1]+i;}
            for(int i=k;i<=n;i++){
                long min=pre[i-1],max=s-pre[n-i];
                res+=max-min+1;
            }
            out.write(((res+1)%mod)+"\n"); //0 1 2 3 ,5+4

        }
             out.flush();
    }
           
}


Measured memory_bytes: 37916
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int X,Y;
  cin >> X >> Y;
  if(Y&1) {
    cout << "No" << endl;
    return 0;
  }
  if(Y-2*X<0) {
    cout << "No" << endl;
    return 0;
  }
  if(X-(Y-2*X)/2<0) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // cout << fixed << setprecision(20);
    int n;cin >> n;
    vector<ll> a(n);REP(i,n)cin >> a[i];

    ll nin = LONG_MAX;
    for(int p = 0;p <= 100;p++){
         ll sum = 0;
         REP(i,n){
              sum += (a[i] - p)*(a[i] - p);
         }
         nin = min(nin,sum);
    }
    cout << nin << '\n';

    return 0;
}


Measured memory_bytes: 256
class UnionFind:
	def __init__(self, n):
		self.par = [i for i in range(n)]  # 親
		self.rank = [1] * n  # 深さ
		self.size = [1] * n  # size[i]はiを根とするグループのサイズ

	def find(self, x):  # xの親を返す
		if self.par[x] == x:
			return x
		else:
			return self.find(self.par[x])

	def unite(self, x, y):  # x,yの属する集合をマージする
		x = self.find(x)
		y = self.find(y)
		if x != y:
			if self.rank[x] < self.rank[y]:
				self.par[x] = y
				self.size[y] += self.size[x]
			else:
				self.par[y] = x
				self.size[x] += self.size[y]
				if self.rank[x] == self.rank[y]:
					self.rank[x] += 1

N, M = map(int, input().split())
X, Y, Z = [0] * M, [0] * M, [0] * M
for i in range(M):
	X[i], Y[i], Z[i] = map(int, input().split())

uf = UnionFind(N)

for j in range(M):
	uf.unite(X[j] - 1, Y[j] - 1)

roots = set([])
for k in range(N):
	roots.add(uf.find(k))
print(len(roots))


Measured memory_bytes: 26208
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <queue>

using namespace std;
typedef long long ll;
#define MOD 1000000007

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

Measured memory_bytes: 256
s=input()
t=input()


ans='Yes'
st=[0]*26
ts=[0]*26
for i in range(len(s)):
    sind = ord(s[i])-ord('a')
    tind = ord(t[i])-ord('a')
    
    if st[sind] == 0:
        st[sind] = t[i]
    if ts[tind] == 0:
        ts[tind] = s[i]
    
    if st[sind] == t[i] and ts[tind] == s[i]:
        continue
    else:
        ans='No'
        break
    
print(ans)

Measured memory_bytes: 3648
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]

dp=[[0,0,0] for n in range(n + 1)]
# dp = [[0] * 3] * (n + 1)

for i in range(n):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i +1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k])
                
res = 0
for j in range(3):
    res = max(res, dp[n][j])
print(res)

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

using namespace std;

typedef long long ll;

const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T>
inline void chkmin(T&a, T b) { a = a < b ? a : b; }

const int MAXN = 300000;

int p[MAXN];
int vis[MAXN];
int ans[MAXN];
int cnt[MAXN];
int pos[MAXN];

int main() {
	int n = ri;
	for(int i = 1; i <= n; i++) {
		int x = p[i] = ri;
		if(vis[x]) {
			puts("No");
			return 0;
		}
		cnt[x] = i;
		vis[x] = 1;
		ans[x] = i;
		pos[x] = i;
	}
	int N = n * n;
	for(int i = 1; i <= N; i++) cnt[i] += cnt[i - 1];
	for(int i = 1; i <= N; i++)
		if(cnt[i] > i) { puts("No"); return 0; }
	int p = 1;
	for(int i = 1; i <= N; i++) {
		if(ans[i]) {
			int c = ans[i] - 1;
			while(c--) {
				while(ans[p]) ++p;
				if(p > i) {
					puts("No");
					return 0;
				} ans[p] = ans[i];
			}
		}
	} p = N;
	for(int i = N; i >= 1; i--) {
		if(pos[i]) {
			int c = n - pos[i];
			while(c--) {
				while(ans[p]) --p;
				if(p < i) {
					puts("No");
					return 0;
				} ans[p] = ans[i];
			}
		}
	}
	puts("Yes");
	for(int i = 1; i <= N; i++) printf("%d ", ans[i]);
	return puts(""), 0;
}

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

long read_long() {
	long ret=0,t=1;char c=getchar();
	while(c<'0' ||c>'9') {
		if(c=='-') t=-1;
		c=getchar();
	}	while(c>='0' && c<='9') {
		ret=ret*10+c-'0';
		c=getchar();
	}		return ret*t;
}

int main() {
	long k,x;
	cin>>k>>x;
	if(k*500>=x) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;

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

    int n;
    cin >> n;

    vector<long long> A(n + 1, 0);
    int t = n;
    for(int i = t; i >= 2; i--){
        int h = i;
        for(int j = 2; j <= sqrt(i); j++){
            while(h % j == 0){
                A[j]++;
                h /= j;
                if(h == 1) break;
            }
            if(h == 1) break;
        }
        if(h != 1) A[h]++;
    } 

    long long ans = 1;
    for(int i = 2; i <= n; i++){
        if(A[i] > 0){
            ans = ((ans % MOD) * ((A[i] + 1) % MOD)) % MOD;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/// In the name of God
#include <bits/stdc++.h>
//#define int long long
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

#define y1 def1
#define X first
#define Y second
#define endl '\n'
#define all(o) o.begin(), o.end()
#define IOS ios::sync_with_stdio(0), cin.tie(0)
const int maxn = 1e5 + 10;
bool dead[maxn];
set<int> adj[maxn], q;
void doo(int v){
    dead[v] = 1;
    for(auto u : adj[v]){
        adj[u].erase(v);
        if(!dead[u] && adj[u].size() == 1) q.insert(u);
    }
}
int main(){
    IOS;
    int n;
    cin >> n;
    for(int i=1; i<n; i++){
        int u, v;
        cin >> u >> v;
        u--, v--;
        adj[u].insert(v);
        adj[v].insert(u);
    }
    for(int i=0; i<n; i++)
        if(adj[i].size() == 1)
            q.insert(i);
    while(q.size()){
        int v = *q.begin();
        q.erase(v);
        if(dead[v]) continue;
        if(adj[v].size() != 1) continue;
        int u = *adj[v].begin();
        doo(u);
        doo(v);
    }
    for(int i=0; i<n; i++){
        if(!dead[i]){
            cout << "First" << endl;
            return 0;
        }
    }
    cout << "Second" << endl;
}


Measured memory_bytes: 16768
from fractions import gcd
A,B,C,D = map(int,input().split())
l = B-A+1
lcm = C//gcd(C,D)*D
b = B//C - A//C
d = B//D - A//D
lc = B//lcm - A//lcm
a1 = l-l//C-l//D+l//lcm
a2 = l-b-d+lc
print(min(a1,a2))

Measured memory_bytes: 5048
#include<iostream>

#include<iostream>

#include<cstdio>

#include<cmath>

using namespace std;

int main()

{

	int n;	cin>>n;

	int cnt=0;

	int m=n;

	while(m>0)

	{

		m/=10;

		cnt++;

	}

	if(cnt==1){

		cout<<n;

	}

	if(cnt==2){

		cout<<"9";

	}

	if(cnt==3){

		int d=9+n-100+1;

		cout<<d;

	}

	if(cnt==4){

		cout<<"909";

	}

	if(cnt==5){

		int d=909+n-10000+1;

		cout<<d;

	}

	if(n==100000){

		cout<<"90909";

	}

	return 0;

}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define mod 1000000007


struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }
    
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
    
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};



int gcd(int a, int b){
    while(b){
        int t = a;
        a = b;
        b = t%b;
    }
    return a;
}

int lcm(int a, int b){
    return a*b/gcd(a, b);
}



int main() {
    int N, K; cin >> N >> K;
    vector<int> H(N);
    for(int &h:H)
        cin >> h;
    
    sort(H.begin(), H.end());
    
    int ans = INF;
    for(int i=0; i<N-K+1; i++){
        
        ans = min(ans, H[i+K-1] - H[i]);
    }
    
    cout << ans << endl;
    
    return 0;
}


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

namespace ConsoleApp2
{
    public class Program
    {
        private static string[] enki = new string[2] { "AT", "GC" };
        public static void Main(string[] args)
        {
            string c = Console.ReadLine();

            foreach (string item in enki)
            {
                if (item.Contains(c))
                {
                    Console.WriteLine(item.Replace(c,""));
                }
            }


        }



        private static long[] Read(string input)
        {
            string[] inputs = input.Split(' ');
            long num = inputs.Length;
            long[] longs = new long[num];
            for (long i = 0; i < num; i++)
            {
                longs[i] = long.Parse(inputs[i]);
            }
            
            return longs;
        }


    }
}


Measured memory_bytes: 13140
#include <stdio.h>

#define N 101

int color[N];
int n, G[N][N],f[N],d[N],time;

void visit(int);

int main(){
  int i,j,v,vnext,k;
 
  scanf("%d",&n);

  for(i=0;i<n;i++){
    color[i] = 0;
    for(j=0;j<n;j++) {
      G[i][j] = 0;
    }
  }

  for(i=0; i<n; i++){
    scanf("%d %d",&v,&k);
    for(j=0; j<k; j++){
      scanf("%d",&vnext);
      G[v-1][vnext-1] = 1; 
    }
  }

  for(i=0; i<n; i++){
    if(color[i]==0) visit(i);
  }

  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  return 0;
}

void visit(int u){

  int i; 
  color[u]=1;
  d[u]= ++time;
  for(i=0; i<n; i++){
    if(G[u][i] == 1){
      if(color[i] == 0)visit(i);
    }
  }

  color[u]= 2;
  f[u]=++time;
}

Measured memory_bytes: 1064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    int count[n+1][2];
    count[0][0] = 0; count[0][1] = 0;
    for(int i=0;i<n;++i) {
        if(s[i] == '#') {
            count[i+1][1] = count[i][1] + 1;
            count[i+1][0] = count[i][0];
        } else {
            count[i+1][0] = count[i][0] + 1;
            count[i+1][1] = count[i][1];
        }
    }

    int ans = (1<<30);
    for(int i=0;i<=n;++i) {
        ans = min({ans, count[i][1]+count[n][0]-count[i][0]});
    }

    cout << ans << endl;
}


Measured memory_bytes: 2196
#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <stack>
#include <limits>
#include <climits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>
#include <set>
#include <array>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf 0x3f3f3f3f
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second
#define SETUP cin.tie(0), ios::sync_with_stdio(false), cout << setprecision(15)

namespace {
	struct input_returnner {
		int N; input_returnner(int N_ = 0) :N(N_) {}
		template<typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); }
		template<typename T> operator T() const { T res; cin >> res; return res; }
		template<typename T> T operator - (T right) { return T(input_returnner()) - right; }
		template<typename T> T operator + (T right) { return T(input_returnner()) + right; }
		template<typename T> T operator * (T right) { return T(input_returnner()) * right; }
		template<typename T> T operator / (T right) { return T(input_returnner()) / right; }
		template<typename T> T operator << (T right) { return T(input_returnner()) << right; }
		template<typename T> T operator >> (T right) { return T(input_returnner()) >> right; }
	};
	template<typename T> input_returnner in() { return in<T>(); }
	input_returnner in() { return input_returnner(); }
	input_returnner in(int N) { return std::move(input_returnner(N)); }
}

void solve();
/// ---template---
signed main(void) {
	SETUP;
	solve();
	return 0;
}

void solve() {
	string str = in();
	bool f[2] = {};
	for (char c : str) {
		if (c == 'C') f[0] = true;
		else if (f[0] and c == 'F') f[1] = true;
	}
	cout << (f[0] and f[1] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.array, std.string, std.container, std.algorithm, std.traits, std.range;

struct Point {
  ulong y;
  ulong x;
  this( ulong y, ulong x ) {
	this.y = y;
	this.x = x;
  }
}

immutable Point NONE = Point( -1, -1 );

immutable int EMPTY = 0;
immutable int BLOCK = 1;
immutable int START = 2;
immutable int GOAL = 3;
immutable int WALL = 4;

struct State {
  Point s;
  Point[ 10 ] remove;
  ulong noPoint;
  int turn;
  
  this( Point s ){
	this.s = s;
	foreach ( i; 0 .. 10 ) {
	  remove[ i ] = NONE;
	}
	noPoint = 0;
	turn = 0;
  }
  void apply( int[][] table, Point origStart ) {
	table[ origStart.y ][ origStart.x ] = EMPTY;
	foreach ( i; 0 .. noPoint ) {
	  table[ remove[ i ].y ][ remove[ i ].x ] = EMPTY;
	}
	table[ s.y ][ s.x ] = START;
  }

  void put( Point p ) {
	remove[ noPoint++ ] = p;
  }
}

Point findStart( int[][] table ) {
  foreach ( i, ary; table ) {
	foreach ( j, v; ary ) {
	  if ( v == START ) {
		return Point( i, j );
	  }
	}
  }
  return NONE;
}

Point findGoal( int[][] table ) {
  foreach ( i, ary; table ) {
	foreach ( j, v; ary ) {
	  if ( v == GOAL ) {
		return Point( i, j );
	  }
	}
  }
  return NONE;
}

void main()
{
  while ( true ) {
	auto token = split( strip( readln ) );
	int width = to!int( token[ 0 ] );
	int height = to!int( token[ 1 ] );
	if ( width == 0 && height == 0 ) break;

	int[][] table = new int[][]( height + 2, width + 2 );
	foreach ( ary; table ) {
	  ary[] = WALL;
	}
	foreach ( i; 1 .. height + 1 ) {
	  auto line = split( strip( readln ) );
	  foreach ( j; 1 .. width + 1 ) {
		table[ i ][ j ] = to!int( line[ j - 1 ] );
	  }
	}
	writeln( solve( table ) );
  }
}

void printMap( int[][] table ) {
  auto states = [ '.', '#', 'S', 'G', 'W' ];
  foreach ( ary; table ) {
	foreach ( v; ary ) {
	  stderr.write( states[ v ] );
	}
	stderr.writeln();
  }
  stderr.writeln();
}

int solve ( int[][] table ) {
  immutable Point start = findStart( table );
  immutable Point goal = findGoal( table );
  
  auto queue = DList!State( State( start ) );

  long[ 4 ] dx = [ -1, 0, 1, 0 ];
  long[ 4 ] dy = [ 0, 1, 0, -1 ];

  immutable ulong height = table.length;
  immutable ulong width = table[ 0 ].length;
  int[][] table2 = new int[][]( height, width );

  while ( !queue.empty ) {
	auto s = queue.front;
	queue.removeFront;

	if ( s.s == goal ) {
	  return s.turn;
	} else if ( s.turn < 10 ) {
	  foreach ( i; 0 .. height ) {
		table2[ i ][] = table[ i ][];
	  }
	  s.apply( table2, start );
	  
	  foreach ( i; 0 .. 4 ) {
		auto nx = s.s.x + dx[ i ];
		auto ny = s.s.y + dy[ i ];
		while ( table2[ ny ][ nx ] != GOAL && table2[ ny ][ nx ] != WALL && table2[ ny ][ nx ] != BLOCK ) {
		  ny += dy[ i ];
		  nx += dx[ i ];
		}
		if ( table2[ ny ][ nx ] == GOAL ) {
		  return s.turn + 1;
		}
		if ( s.s.y + dy[ i ] != ny || s.s.x + dx[ i ] != nx ) {
		  auto ns = s;
		  ns.turn++;
		  ns.s = Point( ny - dy[ i ], nx - dx[ i ] );
		  if ( table2[ ny ][ nx ] == BLOCK ) {
			ns.put( Point( ny, nx ) );
			queue.insertBack( ns );
		  }
		}
	  }
	}
  }
  return -1;
}

Measured memory_bytes: 31636
s_prime=list(input())
t=list(input())
ls=len(s_prime)
lt=len(t)
s_prime.reverse()
t.reverse()


if lt>ls:
    print('UNRESTORABLE')
else:
    def check(t,s):
        l=len(t)
        c=0
        for i in range(l):
            if s[i]!='?' and s[i]!=t[i]:
                c=1
        return True if c==0 else False
    c=0            
    for i in range(ls-lt+1):
        print()
        if check(t,s_prime[i:i+lt])==1:
            t_in=s_prime[:i]+t+s_prime[i+lt:] 
            for k in range(ls):
                if t_in[k]=='?':
                    t_in[k]='a'
            t_in.reverse()   
            print(''.join(t_in))
            c=1
            break
    print('UNRESTORABLE') if c==0 else exit()

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int A, P;
    cin >> A >> P;
    P += A*3;
    cout << P/2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n,t;

int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      char c;
      cin>>c;
      if(c>=65&&c<=95)cout<<'A';
      else cout<<'a';
      
}

Measured memory_bytes: 3660
/*
 ID: bradyawn
 PROG: contest
 LANG: C++11
 */

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#include <algorithm>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <random>
#include <cstring>

using ll = long long;

using namespace std;

typedef long long ll;
typedef pair<int,int> i2;
typedef pair<ll,ll> ll2;

int main()
{
    
    //ifstream inf("");
    //ofstream outf("");
    //cout << setprecision(10);
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    ll x, y;
    cin >> x >> y;
    
    ll cnt = 1;
    
    ll num = x;
    
    while (num <= y)
    {
        if (y/2 < num) break; //overflow
        num *= 2;
        cnt++;
    }
    
    cout << cnt << endl;
    
    return 0;
    
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n,y,a,b;
	int check = 0;
	scanf("%d %d",&n,&y);
	y = y / 1000 - n;
	for(int i = 0;i <= n && check == 0;i++){
		for(int j = 0;j <= n && check == 0;j++){
			if(9 * i + 4 * j == y && n - i - j >= 0) {
				check = 1;
				a = i;
				b = j;
				}
			}
		}
	if(check == 1)
	printf("%d %d %d\n",a,b,n - a - b);
	else printf("-1 -1 -1\n");
	return 0;
	}

Measured memory_bytes: 128
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N=ri()
ans = 0
for i in range(1,int(N**(1/2))+1):
    if (N-i)%i==0:
        temp = (N-i)//i
        if temp > i:
            ans += temp
print(ans)

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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int a, b, c;
  cin >> a >> b >> c;

  if (b / a >= c) {
    cout << c << endl;
  } else {
    cout << b / a << endl;
  }

  return 0;
}


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

ll f(ll n) { return n*(n+1)/2;}

int main() {
  char a;
  cin >> a;
  if (a >= 'A' && a <= 'Z') {
    cout << 'A' << endl;
  } else if (a >= 'a' && a <= 'z') {
    cout << 'a' << endl;
  }
  return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  int n,k;
  string s;
  cin >> n >> k;
  cin >> s;
  int kk = k-1;
  s[kk] = tolower(s[kk]);
  cout << s << "\n";
}


Measured memory_bytes: 384
require 'ripper'

def calc(se)
	#p se
	case se[0]
	when :paren
		return nil if se[1][0][0] == :paren
		return nil if !se[1][0].flatten.include?(:binary)
		return calc(se[1][0])
	when :binary
		l, op, r = se[1..-1]
		return nil unless x = calc(l)
		return nil unless y = calc(r)
		result = x.send(op, y)
		return nil unless (0..1023) === result
		result
	when :@int
		r = se[1].to_i
		return (0..1023) === r ? r : nil
	when :unary
		if se[1] == :-@
			r = calc(se[2])
			return nil if !r
			return r == 0 ? 0 : nil
		elsif se[1] == :+@
			r = calc(se[2])
			return calc(se[2])
		else
			puts "unimplemented"
			return -1
		end
	else
		puts "unimplemented"
		return -1
	end
end

s = gets.chomp
k = s.count(?.)

if k == 0
	s.gsub!(/\d+/){|b| b.to_i(2)}
	if s =~ /[-+*]{2,}/
		p -1
	else
		begin
			eval s
			r = calc(Ripper.sexp(s)[1][0])
			p (0..1023) === r ? r : -1
		rescue Exception
			p -1
		end
	end
else
	p %w[ ( ) 0 1 + - * ].repeated_permutation(k).map {|perm|
		e = s.gsub(?.){ perm.pop }
		e.gsub!(/\d+/){|b| b.to_i(2)}
		next -1 if e =~ /[-+*]{2,}/
		begin
			eval e
		rescue Exception
			next -1
		end
		r = calc(Ripper.sexp(e)[1][0]) || -1
		#p [e, r] if r >= 0
		r
	}.max
end

Measured memory_bytes: 11644
#include <bits/stdc++.h>
#define fastio  ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0)
using namespace std;
#define ll long long
const int mod = 1'000'000'007;
int main()
{
	fastio;
	int N;
	cin>>N;
	int ans=0;
	for (int i = 1; i <= N; i++)
	{
		ans+=(N-1)/i;
	}
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;

//Mirror Illusion
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int[][][] g = {
				{{0, 0},{0, 800}},
				{{0, 0},{800, 0}},
				{{0, 800},{800, 800}},
				{{800, 0},{800, 800}}
		};
		for(;;){
			int n = sc.nextInt();
			if(n<0)break;
			int px = 75, py = 25, dx = 1, dy = 1;
			int[][][] wall = new int[n+1][2][2];
			wall[0][0][0] = wall[0][1][0] = 75; wall[0][0][1] = wall[0][1][1] = 25;
			for(int i=1;i<=n;i++){
				char ch = sc.next().charAt(0);
				int a = sc.nextInt()*100, b = sc.nextInt()*100;
				if(ch=='x'){
					wall[i][0][0] = a; wall[i][0][1] = b;
					wall[i][1][0] = a+100; wall[i][1][1] = b;
				}
				else{
					wall[i][0][0] = a; wall[i][0][1] = b;
					wall[i][1][0] = a; wall[i][1][1] = b+100;
				}
			}
			for(;;){
				int id = -1, min = 1000;
				for(int i=0;i<=n;i++){
					int x1 = wall[i][0][0], x2 = wall[i][1][0], y1 = wall[i][0][1], y2 = wall[i][1][1];
					if(x1==x2){
						int t = (x1-px)/dx;
						if(t<=0||min<=t)continue;
						int y = py+t*dy;
						if(y1<=y&&y<=y2){
							id = i;
							min = t;
						}
					}
					else{
						int t = (y1-py)/dy;
						if(t<=0||min<=t)continue;
						int x = px+t*dx;
						if(x1<=x&&x<=x2){
							id = i;
							min = t;
						}
					}
				}
				if(id==-1){
					min = 1000;
					for(int i=0;i<4;i++){
						int x1 = g[i][0][0], x2 = g[i][1][0], y1 = g[i][0][1], y2 = g[i][1][1];
						if(x1==x2){
							int t = (x1-px)/dx;
							if(t<=0||min<=t)continue;
							int y = py+t*dy;
							if(y1<=y&&y<=y2)min = t;
						}
						else{
							int t = (y1-py)/dy;
							if(t<=0||min<=t)continue;
							int x = px+t*dx;
							if(x1<=x&&x<=x2)min = t;
						}
					}
					System.out.println((px+min*dx)+" "+(py+min*dy));
					break;
				}
				if(id==0){
					System.out.println("75 25");
					break;
				}
				px+=min*dx; py+=min*dy;
				if(wall[id][0][0]==wall[id][1][0])dx*=-1;
				else dy*=-1;
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#include <iostream>


using namespace std;
int main(){

    int n,r,m;
    cin>>n>>r>>m;
  

    if((n+r)<=(n+m) && (n+r)<=(r+m)){
        cout<<n+r;

    }
   else if((n+m)<=(n+r) && (n+m)<=(r+m)){
        cout<<n+m;

    }
       else if((m+r)<=(n+m) && (m+r)<=(n+r)){
        cout<<m+r;

    }


    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>


using namespace std;
typedef long long int ll;


int main() {
    string ans;
    cin >> ans;
    ans[3] = '8';
    cout << ans << endl;
    return 0;
}

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

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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


/////////////////////////////////////////////////////////////////////////////////////////

int main(){
    int n,k;
    cin >> n >> k;
    ll a = n / k,b = 2*n / k;
    if (k & 2 != 0){
        cout << a * a * a << endl;
    }
    else {
        cout << a*a*a + (b-a)*(b-a)*(b-a) << endl;
    }   
}

Measured memory_bytes: 256
n = int(input())
w = list(map(int, input().split()))

s_1 = 0
s_2 = sum(w)
ans = abs(s_1 - s_2)
for i in range(0, n):
  s_1 += w[i]
  s_2 -= w[i]
  tmp = abs(s_1 - s_2)
  if tmp < ans:
    ans = tmp

print(ans)

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

int main() {
  int n, k;
  cin>>n>>k;
  set<int> s;
  for (int i=0; i<k; i++) {
    int d;
    cin>>d;
    for (int j=0; j<d; j++) {
      int ai;
      cin>>ai;
      s.insert(ai);
    }
  }
  cout<< n - s.size()<<endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const long long inf=0x3f3f3f3f3f3f3f3f;
long long n,x,a[2005],dp[2005][2005],sum,ans=inf;
int main(){
	scanf("%lld%lld",&n,&x);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++){
	    dp[i][0]=a[i];
	    for(int j=1;j<n;j++){
	    	int k=i-j;
	    	if(k<=0) k+=n;
	        dp[i][j]=min(dp[i][j-1],a[k]);
	    }
	}
	for(int i=0;i<n;i++){
	    sum=x*i;
	    for(int j=1;j<=n;j++)
	        sum+=dp[j][i];
	    ans=min(ans,sum);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int) n;i++)
#define rep1(i,m,n) for(int i=(int) m;i<(int) n;i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
    if(x>=0) return ;
    else x=-x; return;
}

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

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

const ll INF = 1LL << 60;

int N;

//DPテーブル
vector<ll> dp(100010);

int main() {
    cin >> N;
    if(N<=999) cout << "ABC" << endl;
    else cout << "ABD" << endl;
}

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

int main(){
  string s;
  int k;
  cin >> s >> k;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'a') continue;
    if (k - 26 + (s[i] - 'a') >= 0) {
      k -= 26 - (s[i] - 'a');
      s[i] = 'a';
    }
  }
  s[s.size() - 1] += k % 26;
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

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

  int even = K / 2;
  int odd = K - K / 2;

  cout << even * odd << endl;
}

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

int M, W;
int bm[12], bw[12];
int dp[15][(1<<12)];

int calcPower(int a, int b)
{
	int num = ((a - b) >= 0)? (a - b): (b - a);
	return num * (num - 30) * (num - 30);
}

int main()
{
	while(cin >> M >> W, M, W) {
		// input
		for(int i = 0; i < M; i++) {
			cin >> bm[i];
		}
		for(int i = 0; i < W; i++) {
			cin >> bw[i];
		}
		
		if(M > W) {
			swap(M, W);
			swap(bm, bw);
		}
		
		// initialize
		for(int i = 0; i < M; i++) {
			for(int j = 0; j < (1<<W); j++) {
				dp[i][j] = -1;
			}
		}
		for(int i = 0; i < W; i++) {
			dp[0][(1<<i)] = calcPower(bm[0], bw[i]);
		}
		
		// solve
		for(int i = 0; i < M-1; i++) {
			for(int j = 1; j < (1<<W); j++) {
				if(dp[i][j] == -1) {
					continue;
				}
				
				for(int k = 0; k < W; k++) {
					if((j & (1<<k))) {
						continue;
					}
					
					int next = ((j | (1<<k)));
					int cost = dp[i][j] + calcPower(bm[i+1], bw[k]);
					dp[i+1][next] = max(dp[i+1][next], cost);
				}
			}
		}
		
		int ans = -1;
		for(int i = 0; i < (1<<W); i++) {
			ans = max(ans, dp[M-1][i]);
		}
		cout << ans << endl;
	}
	
	return 0;
}

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

const int mx = 200005;
int memo[26][mx], sz, c[26], pr[mx], bit[mx*2];
long long ans;
bool safe = true;
string s;

int main(){
  cin >> s; sz = s.size();
  for(int i = 0; i < sz; i++){
    int t = s[i]-'a';
    memo[t][c[t]++] = i;
  }
  for(int i = 0; i < 26; i++){
    if(c[i]&1){
      if(safe) safe = false;
      else return puts("-1")*0;
    }
    for(int j = 0; j < c[i]; j++) pr[memo[i][j]] = memo[i][c[i]-1-j];
  }
  for(int i = 0; i < sz; i++){
    for(int j = pr[i]+1; j > 0; j -= j&-j) ans += bit[j];
    for(int j = pr[i]+1; j < mx*2; j += j&-j) bit[j]++;
  }
  printf("%lld\n", ans/2);
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

i64 sigma(int n) { return n * (1 + n) / 2; }

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

  int a, b;
  cin >> a >> b;
  cout << sigma(b - a) - b << "\n";

  return 0;
}

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

using namespace std;

const int N = 2e2 + 5;
const int INF = 0x3f3f3f3f;
int _w;

int n , G[N][N] , col[N];
char str[N];

void dfs( int u ) {
  if( !~col[u] ) col[u] = 0;
  for( int i = 1 ; i <= n ; ++i )
    if( G[u][i] ) {
      if( col[i] == col[u] ) {
        puts("-1");
        exit( 0 );
      }
      if( col[i] == -1 ) {
        col[i] = col[u] ^ 1;
        dfs( i );
      }
    }
}

int main( void ) {
  memset( col , -1 , sizeof col );
  _w = scanf("%d",&n);
  for( int i = 1 ; i <= n ; ++i ) {
    _w = scanf("%s",str+1);
    for( int j = 1 ; j <= n ; ++j )
      if( str[j] == '1' )
        G[i][j] = 1;
  }
  dfs( 1 );
  for( int i = 1 ; i <= n ; ++i )
    for( int j = 1 ; j <= n ; ++j )
      if( !G[i][j] ) G[i][j] = INF;
  for( int k = 1 ; k <= n ; ++k )
    for( int i = 1 ; i <= n ; ++i )
      for( int j = 1 ; j <= n ; ++j )
        G[i][j] = min( G[i][j] , G[i][k] + G[k][j] );
  int ans = 0;
  for( int i = 1 ; i <= n ; ++i )
    for( int j = i + 1 ; j <= n ; ++j )
      ans = max( ans , G[i][j] );
  cout << ans + 1;
  return 0;
}


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

int main()
{
  ll a, b, x;
  cin >> a >> b >> x;
  ll c = (a - 1) / x + 1;
  if(a == 0) c = 0;
  ll d = b / x + 1;
  cout << d - c << endl;

  return 0;
}


Measured memory_bytes: 3596
import fractions
import itertools

# nの約数をすべて求める
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

A,B = map(int,input().split())

# 最大公約数gcd
gcd = fractions.gcd(A,B)
# 公約数=最大公倍数gcdの約数
cd = make_divisors(gcd)
cd = sorted(cd)

# 小さいものから1つずつ
ans = set()
for x in cd:    
    if len(ans) == 0:
        # 集合が空なら
        ans.add(x)
    else:
        # 集合のどの要素ともxが互いに素なら，追加
        if all([fractions.gcd(x,y)==1 for y in ans]):
            ans.add(x)

#print(ans)
print(len(ans))

Measured memory_bytes: 5340
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	bool ans = true;
	for (int i = 0; i < n; i++)
	{
		if (i % 2 == 0)
		{
			if (s[i] == 'L') ans = false;
		}
		else
		{
			if (s[i] == 'R') ans = false;
		}
	}

	if (ans) cout << "Yes" << "\n";
	else cout << "No" << "\n";
	return 0;
}

Measured memory_bytes: 3616
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<ll>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }

    int ma = -1;
    int jj = -1;
    bool plus = true;
    rep(i, n) {
        if(ma < abs(a[i])) {
            ma = abs(a[i]);
            jj = i;
            if(a[i] < 0) {
                plus = false;
            } else {
                plus = true;
            }
        }
    }

    vector<P> ans;
    if(plus) {
        rep(i, n-1) {
            if(a[i] <= a[i+1]) continue;
            if(a[i] > 0 and a[i+1] >= 0) {
                a[i+1] += a[i];
                ans.emplace_back(i+1, i);
            } else if(a[i] > 0) {
                a[i+1] += ma;
                ans.emplace_back(i+1, jj);
                if(a[i] > a[i+1]) {
                    a[i+1] += a[i];
                    ans.emplace_back(i+1, i);
                }
            } else {
                a[i+1] += ma;
                ans.emplace_back(i+1, jj);
            }
            if(a[i+1] > ma) {
                ma = a[i+1];
                jj = i+1;
            }
        }
    } else {
        for(int i = n-2; i>= 0; --i) {
            if(a[i] <= a[i+1]) continue;
            if(a[i] <= 0 and a[i+1] < 0) {
                a[i] += a[i+1];
                ans.emplace_back(i, i+1);
            } else if(a[i+1] < 0) {
                a[i] -= ma;
                ans.emplace_back(i, jj);
                if(a[i] > a[i+1]) {
                    a[i] += a[i+1];
                    ans.emplace_back(i, i+1);
                }
            } else {
                a[i] -= ma;
                ans.emplace_back(i, jj);
            }
            if(-a[i] > ma) {
                ma = -a[i];
                jj = i;
            }
        }
    }

    int y = ans.size();
    cout << y << endl;
    rep(i, y) {
        cout << ans[i].second+1 << ' ' << ans[i].first+1 << endl;
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
const ll MD = 1000000007;
const int INF = 10000;
int n, m;
int edge[50][2];
int d[100];
struct sedge {
	int to;
	int cost;
};

bool warshall_floyd(int tempm) {
	int d[100][100];
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			d[i][j] = INF;
		}
	}

	for (int i = 0; i < m; i++) {
		if (i != tempm) {
			d[edge[i][0]][edge[i][1]] = 1;
			d[edge[i][1]][edge[i][0]] = 1;
		}
	}

	for (int k = 1; k <= n; k++) {
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= n; j++) {
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
	}
	bool ret = false;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (d[i][j] == INF) {
				ret = true;
				break;
			}
		}
		if (ret)break;
	}
	return ret;
}

bool dijkstra(int s, int tempm) {
	int v = -1;
	vector<sedge> G[100];
	for (int i = 0; i < m; i++) {
		sedge t;
		if (tempm != i) {
			t.cost = 1;
			t.to = edge[i][1];
			G[edge[i][0]].push_back(t);
		}
	}

	priority_queue<P, vector<P>> que;
	fill(d+1, d + n+1, INF);
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (int i = 0; i < G[v].size(); i++) {
			sedge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}

	}
	bool ret = false;
	for (int i = 1; i <= n; i++) {
		if (d[i] == INF) {
			ret = true;
			break;
		}
	}
	return ret;

}


int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> edge[i][0] >> edge[i][1];
	}

	int answer = 0;

	for (int i = 0; i < m; i++) {
		if (warshall_floyd(i)) {
			answer++;
		}
	}

	cout << answer;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
int N, M; cin >> N >> M; int A[M], B[M]; vector<vector<int>> tugi(N);
REP(i, M){ 
  cin >> A[i] >> B[i]; A[i]--; B[i]--;
  tugi[A[i]].push_back(B[i]); tugi[B[i]].push_back(A[i]);
}
bool table[N]={}; vector<int> V={0}; int ans[N]={}; table[0]=true;
for(int i=0; i<V.size(); i++){
  int v=V[i], n=tugi[v].size();
  REP(j, n){ 
    int w=tugi[v][j];
    if(!table[w]){ V.push_back(w); ans[w]=v+1; table[w]=true; }
  }
}
cout << "Yes\n";
for(int i=1; i<N; i++){ cout << ans[i] << "\n"; }
}

Measured memory_bytes: 12216
#include <stdio.h>

int power(int n, int a) {
    int tmp = 1;

    if (a != 0) {
        for (int i = 0; i < a; i++) {
            tmp *= n;
        }
    }
    return tmp;
}

int main(void) {
    int d, n;

    scanf("%d %d", &d, &n);
    if (n != 100) {
        printf("%d\n", n * power(100, d));
    } else {
        printf("%d\n", (n + 1) * power(100, d));
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
	int n;
	cin >> n;
	if(n<1200)
	{
		cout<<"ABC"<<endl;
	}
	else
	{
		cout<<"ARC"<<endl;
	}
	
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> w(n);
  for(int i=0;i<n;i++){
    cin >> w.at(i);}
  int sum = 0;
  for(int i=0;i<n;i++){
    sum += w.at(i);}
  int a = 0;
  int b = 0;
  b = sum;
  for(int i=0;i<n;i++){
    a += w.at(i);
    b = min(b,abs(2*a-sum));}
  cout << b << endl;
  return 0;
}
            
    
    
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, k, q; cin >> n >> k >> q;
  vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  vector<bool> b(n, true);
  vector<P> s(n);
  for (int i = 0; i < n; i++) {
    s[i].first = a[i];
    s[i].second = i;
  }
  sort(s.begin(), s.end());
  int res = 2e9;
  for (int i = 0; i < n - k + 1; i++) {
    vector<int> c;
    int l = 0, r = 1;
    while (r <= n) {
      while (r < n and b[r]) r++;
      vector<int> tmp;
      tmp.assign(a.begin() + l, a.begin() + r);
      sort(tmp.begin(), tmp.end());
      for (int j = 0; j < r - l - k + 1; j++) {
        c.push_back(tmp[j]);
      }
      if (r == n) break;
      l = r;
      while (l < n and not b[l]) l++;
      r = l + 1;
    }
    if (c.size() < q) continue;
    sort(c.begin(), c.end());
    res = min(res, c[q - 1] - c[0]);
    b[s[i].second] = false;
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 384