akhauriyash/Code-Regression huggingface dataset:
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;


public class Main {
	
	public static void main(String[] args) throws IOException {
		new Main().exec();
	}
	
	public void exec() throws IOException {
		InputUtil in = new InputUtil();
		PrintWriter out = new PrintWriter(System.out);
		int N = in.nextInt();
		HashSet<Integer> A = new HashSet<>();
		for(int i=0; i<N; i++) {
			Integer a = Integer.valueOf(in.nextInt());
			if(A.contains(a)){
				A.remove(a);
			}else{
				A.add(a);
			}
		}
		out.println(A.size());
		out.flush();
	}
}


class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}

Measured memory_bytes: 26964
#include <iostream>


using namespace std;


int main()
{
  int n;
  long long sumv=0, l, r;

  cin >> n;
  for (int i=0; i<n; i++){
    cin >> l >> r;
    sumv += r-l+1;
  }
  cout << sumv << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=210;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,m;
char s[N][N],t[N][N];
signed main()
{
    n=read(), m=read();
    for(ri int i=1;i<=n;i++) scanf("%s",s[i]+1);
    for(ri int i=1;i<=m;i++) scanf("%s",t[i]+1);

    for(ri int i=1;i<=n;i++)
    for(ri int j=1;j<=n;j++)
    {
        if(s[i][j]==t[1][1])
        {
            int qwq=1;
            for(ri int x=1;x<=m;x++)
            for(ri int y=1;y<=m;y++)
            if(s[i+x-1][j+y-1]!=t[x][y]) qwq=0;
            if(qwq) { puts("Yes"); return 0; }
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 3780
#include <stdio.h>

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

	int max = 0, sum = 0;
	while (n--) {
		int x;
		scanf("%d", &x);
		if (x >= max) sum++;
		if (x > max) max = x;
	}
	printf("%d\n", sum);
}


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

using namespace std;

typedef long long int ll;
#define MAXSIZE 10000000;

const int MAX = 510000;
const int MOD = 1000000007;
const long long INF = 1LL << 60;

ll dp[10001][1001] = {0};

int main()
{
    int N;
    int ansNum = 0;
    cin >> N;
    for (int i = 0; i <= N; i++)
    {
        if (i % 2 == 1)
        {
            int yakuSuNum = 0;
            for (int j = 1; j <= N; j++)
            {
                if (i % j == 0)
                {
                    yakuSuNum++;
                }
            }
            if (yakuSuNum == 8)
                ansNum++;
        }
    }

    cout << ansNum << endl;
    return 0;
}

/*Syakutori
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;

      for(ll s = 1;s < 50000000;s++){

        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;

bool comp(const pair<int,int> a, const pair<int,int> b) {
    return a.second < b.second;
}

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


*/


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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

vector<char> boin = {'a','i','u','e','o'};
vector<char> alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main(){
    int H,W;
    cin >> H >> W;
    char maze[H][W];
    Rep(i,H){
        Rep(j,W){
            cin >> maze[i][j];
        }
    }
    int dis[H][W][H][W];
    queue<pair<int,int>> que; 
    Rep(i,H){
        Rep(j,W){
            Rep(k,H){
                Rep(l,W){
                    if(i == k && j == l)dis[i][j][k][l] = 0;
                    else dis[i][j][k][l] = -1;
                }
            }
        }
    }
    Rep(i,H){
        Rep(j,W){
            if(maze[i][j] == '.')que.emplace(i,j);
            else continue;
            while(!que.empty()){
                int x = que.front().first;
                int y = que.front().second;
                que.pop();
                Rep(d,4){
                    if(x + dx[d] < 0 || x + dx[d] >= H || y + dy[d] < 0 || y + dy[d] >= W);
                    else if(maze[x + dx[d]][y + dy[d]] != '#' && dis[i][j][x+dx[d]][y+dy[d]] == -1){
                        que.emplace(x + dx[d],y + dy[d]);
                        dis[i][j][x + dx[d]][y + dy[d]] = dis[i][j][x][y] + 1;
                    }
                }
            }
        }
    }
    int ans = 0;
    Rep(i,H){
        Rep(j,W){
            Rep(k,H){
                Rep(l,W){
                    if(maze[i][j] == '.' && maze[k][l] == '.')ans = max(ans,dis[i][j][k][l]);
                }
            }
        }
    }
    cout << ans << endl;
    //cin >> H;
}

Measured memory_bytes: 896
#include<stdio.h>

int main()
{
    int a,b,c,t;
    scanf("%d%d%d",&a,&b,&c);
    if(a>b) {t=a;a=b;b=t;}
    if(a>c) {t=a;a=c;c=t;}
    if(b>c) {t=b;b=c;c=t;}
    printf("%d %d %d\n",a,b,c);
    return 0;
}



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

int main() {
    int N; cin >> N;
    vector<long long> A(N), B(N);
    for(int i = 0; i < N; i++) cin >> A[i], B[i] = A[i] - i;
    
    //メディアンを
    sort(B.begin(),B.end());
    long long x = B[N/2];
    
    //答えを求める
    long long res = 0;
    for(int i = 0; i < N; i++){
        res += max(x - B[i], -x + B[i]);
    }
    cout << res << endl;
} 
 

Measured memory_bytes: 6428
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;
typedef vector<pii> vp;

#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))
const ll MOD = 1000000007ll;

int main() {
	string s, cf = "CF";
	cin >> s;
	
	int ans = 0;
	REP(i, s.size()) {
		if (ans < 2 && cf[ans] == s[i]) ans++;
	}
	puts(ans == 2 ? "Yes" : "No");
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int dp[202][202];
unsigned long long int ans = 0;

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    if (dp[a][b] != -1)
        return dp[a][b];
    dp[a][b] = gcd(b, a % b);
    return dp[a][b];
}

void solve(int c)
{
    for (int i = 1; i <= c; i++)
    {
        for (int j = 1; j <= c; j++)
        {
            for (int k = 1; k <= c; k++)
            {
                ans += gcd(gcd(i, j), k);
            }
        }
    }
}

int main()
{
    for (int i = 0; i < 202; i++)
    {
        for (int j = 0; j < 202; j++)
        {
            dp[i][j] = -1;
        }
    }
    int k;
    cin >> k;
    solve(k);
    cout << ans;
    return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 
 
#define PI 3.14159265
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
const ll limit = 2e9;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};
 
//const int mod = 998244353;
 
struct dsu{
	int parent[N];
	int cont;
	void make_set(int n){
		for(int i = 1; i <= n; i++)
			parent[i] = i;
		cont = n;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a); 
		b = find_set(b);	
		if(a != b){
			parent[b] = a;
			cont--;
		}
	}	
};


//~ map<int,int> h;
//~ int dp[2007];
//~ vector <int> arraySort(vector <int> v) {
	//~ vector<int> ans;
	//~ for(int i = 1; i <= (int)v.size(); i++){
		//~ dp[i] = 1;
	//~ }
	
	//~ for(int i = 1; i <= (int)v.size(); i++){
		//~ for(int j = 1; j < i; j++){
			//~ if(v[j-1] <= v[i-1]){ 
				//~ if(dp[i] < dp[j] + 1){
					//~ dp[i] = dp[j] + 1;
					//~ h[i] = j;
				//~ }
				//~ else if(dp[i] == dp[j] + 1){					
					//~ int index = h[i];
					//~ int val = v[index-1];
					//~ if(v[j-1] < val){
						//~ h[i] = j;
					//~ }
				//~ }
			//~ }
		//~ }
	//~ }
	//~ int index, maxi = 0, minval = inf;
	//~ for(int i = 1; i <= (int)v.size(); i++){
		//~ if(maxi <= dp[i] ){
			//~ maxi = dp[i];
		//~ }
	//~ } 
	
	//~ for(int i = 1; i<= (int)v.size(); i++){
		//~ if(maxi == dp[i]){
			//~ if(minval > v[i-1]){
				//~ minval = v[i-1];
				//~ index = i;
			//~ }
		//~ }
	//~ }
	
	//~ cout<<minval<<" "<<index<<endl;
	
	//~ int next = index;
	
	//~ while(next){
		//~ cout<<next<<" ";
		//~ next = h[next];
	//~ }
	//~ return ans;
//~ }

int v[4];
int main(){
	int a, b; cin>> a >> b;
	int x = -1;
	for(int i = 0; i <= 10000; i++)
		if(floor(i * 0.08) == a && floor(i*0.1) == b){
			x = i; break;
		}
	cout<<x <<endl;
	return 0;
}













Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int c[500][1000];
bool seq[1000];

int main() {
  int n, k;
  cin >> n >> k;
  REP(i,k) {
    REP(j,n/2) {
      int a; cin >> a; --a;
      c[i][a] = 1;
    }
  }
  
  while(1) {
    REP(i,n) seq[i] = rand()%2;
    bool f = 1;
    REP(i,k) {
      int cnt = 0;
      REP(j,n) if (seq[j] && c[i][j]) cnt++;
      if (cnt < n/8 || cnt > 3*n/8) {
        f = 0;
        break;
      }
    }
    if (f) {
      REP(i,n)cout << seq[i];
      cout << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define x first
#define y second
#pragma GCC optimize(2)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("sse3","sse2","sse")
#pragma GCC target("avx","sse4","sse4.1","sse4.2","ssse3")
#pragma GCC target("f16c")
#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
#pragma GCC diagnostic error "-std=c++14"
#define IOS ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef long long LL;
const int N=1e5+10;
const int M=150;
const int INF=0x3f3f3f3f;
const int MOD=998244353;
int main(){
    IOS;
    int k;
    string s;
    while(cin>>k>>s){
        int n=s.size();
        if(n<k) k=n;
        for(int i=0;i<k;i++) cout<<s[i];
        if(n!=k) cout<<"..."<<endl;
    }
    return 0;
}


Measured memory_bytes: 3676
A, B, C = input().split(" ")
A = int(A)
B = int(B)
C = int(C)

K = int(input())

if A>B and A>C:
    A = A * (2**K)
elif B>A and B>C:
    B = B * (2**K)
else:
    C = C * (2**K)

print(A+B+C)

Measured memory_bytes: 3060
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let m: usize = sc.read();

    if n == m {
        println!("Yes");
    } else {
        println!("No");
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

string s ;
char ans[200] ;

int main(){
	
	char t ;
	
	while( cin >> s >> t ){
		if( t == 'X' ) break ;
		
		int p = 1 ;
		
		if( s[0] <= 90 && t != 'U' ) ans[0] = s[0] +32 ;
		else if( s[0] >= 97 && t == 'U' ) ans[0] = s[0] -32 ;
		else ans[0] = s[0] ;
		for( int i=1 ; i<s.size() ; i++ ){
			if( s[i] == '_' && t != 'D' ){
				ans[p] = s[i+1] -32 ;
				i++ ;
			}
			else if( s[i] <= 90 && t == 'D' ){
				ans[p] = '_' ;
				ans[p+1] = s[i] +32 ;
				p++ ;
			} else ans[p] = s[i] ;
			
			p++ ;
		}
		
		for( int i=0 ; i<p ; i++ ){
			cout << ans[i] ;
		}cout << endl ;
	}
	
return 0 ;
}

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

using namespace std;
using ll = long long;

int main() {
    int N = 0, D, X;
    cin >> N >> D >> X;
    vector<int> A(N,0);
    int ans = 0;
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
        ans++;
        ans += (D - 1)/A.at(i);
    }
    cout << ans + X << endl;

    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    int cnt = 0;
    int ans = 0;
    rep(i,n) {
        int p;
        cin >> p;
        if(p == i+1) cnt++;
        else {
            ans += (cnt+1)/2;
            cnt = 0;
        }
    }
    ans += (cnt+1)/2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
        int n, i;

        scanf("%d", &n);

        int p[n],sum=0,max;
        for(i=0; i<n; i++){
                scanf("%d", &p[i]);
                if(p[i]%2!=0) return 1;
        }

        max=p[0];
        for(i=1; i<n; i++){
                if(p[i]>max){
                        max=p[i];
                }
        }

        int flag=0;

        for(i=0; i<n; i++){
                if(flag != 1 && max==p[i]){
                        p[i]=0;
                        flag = 1;
                }
                sum  += p[i];
        }

        sum += max/2;

        printf("%d\n",sum);

        return  0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N,M; cin >> N >> M;
  vector<int> elev(N+1); FOR(i,1,N+1) cin >> elev.at(i);
  vector<vector<int>> road(N+1); 
  int tmp1,tmp2;
  int ans = 0;
  bool goodflag;
    
  REP(i,M){
    cin >> tmp1 >> tmp2;
    road.at(tmp1).push_back(tmp2);
    road.at(tmp2).push_back(tmp1);
  }
  FOR(i,1,N+1) road.at(i).push_back(-1);
  
  FOR(i,1,N+1){
    goodflag = true;
    for(int j = 0; road.at(i).at(j) != -1; j++){
      if(elev.at(i) <= elev.at(road.at(i).at(j))){
        goodflag = false;
        break;
      }
    }
    if(goodflag)
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 9420
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int color[300];
vvint to(300);

bool dfs(int x,int c){
  color[x] = c;
  for(auto p:to[x]){
    if(color[p] == c) return false;
    if(color[p] == 0 && !dfs(p,-c)) return false;
  }
  return true;  
}

signed main(){
  int n;
  cin >> n;
  vstring mass(n);
  rep(i,0,n) cin >> mass[i];
  vvint dist(n,vint(n));
  rep(i,0,n){
    rep(j,0,n){
      if(i != j) dist[i][j] = INF; 
      if(mass[i][j] == '1'){
        to[i].push_back(j);
        dist[i][j] = 1;
      }
    }
  }
  if(!dfs(0,1)){
    cout << -1 << endl;
    return 0;
  }
  rep(i,0,n){
    rep(j,0,n){
      rep(s,0,n){
        dist[j][s] = min(dist[j][s],dist[j][i] + dist[i][s]);
      }
    }
  }
  int ans = 0;
  rep(i,0,n) rep(j,0,n) ans = max(ans,dist[i][j]);
  cout << ans+1 << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
int n, m, k;
int main(){
    scanf("%d%d%d", &n, &m, &k);
    int ok = 0;
    for (int i = 0; i <= n; ++i){
        int ans = i * m;
        if (ans == k){
            ok = 1;
            break;
        }
        for (int j = 0; j <= m; ++j){
            ans += (n-i) - i;
            if (ans == k){
                ok = 1;
                j = m + 1, i = n + 1;
            }
        }
    }
    printf("%s\n", ok ? "Yes" : "No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,H,W;
  cin >> N >> H >> W;
  cout << (N-H+1)*(N-W+1) << endl;
  return 0;
}


Measured memory_bytes: 3560
def main1
  n,k = gets.chomp.split(/ /).map {|i| i.to_i}
  as = gets.chomp.split(/ /).map {|i| i.to_i}
  as.unshift(0)

  pos = 1

  vs = []
  vs[pos] = 0

  ps = []
  ps << pos

  n = 1
  while true
    pos = as[pos]
    ps << pos
    if vs[pos]
      loop_start_idx = vs[pos]
      break
    end
    vs[pos] = n
    n = n+1
  end

  if k <= loop_start_idx
    #puts "k #{k}"
    #p ps
    x = ps[k]
    puts x
  else
    loopl = n - loop_start_idx
    #p vs
    #puts "loops #{loop_start_idx}"
    #puts "loop #{loopl}"
    #p ps

    n = (k - loop_start_idx) % loopl
    #puts n
    x = ps[loop_start_idx+n]
    puts x
  end
end

def main2
  n,k = gets.chomp.split(/ /).map {|i| i.to_i}
  as = gets.chomp.split(/ /).map {|i| i.to_i}
  as.unshift(0)

  pos = 1
  (1..k).each {|i|
    pos = as[pos]
  }
  puts pos
end

main1


Measured memory_bytes: 32452
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<utility>
#define neko 200005
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~(i)))
#define rf(i,a,b) for(register int i=(a);i>=(b);i=~(-(i)))
namespace IO
{
	const unsigned int bufsize=1<<16,outsize=1<<24;
	static char ch[bufsize],*S=ch,*T=ch;
	inline char getc()
	{return ((S==T)&&(T=(S=ch)+fread(ch,1,bufsize,stdin),S==T)?0:*S++);}
	static char Out[outsize],*nowp=Out;
	inline void flush(){fwrite(Out,1,nowp-Out,stdout);nowp=Out;}
	template<typename T>
		void read(T &x)
		{
			char c=getc();x=0;
			for(;!isdigit(c);c=getc());
			for(;isdigit(c);x=(x<<1)+(x<<3)+(c^'0'),c=getc());
		}
	template<typename T>
		void write(T x,char c='\n')
		{
			if(!x)*nowp++='0';
			static unsigned int stk[50],tp=0;
			for(;x;x/=10)stk[++tp]=x%10;
			for(;tp;*nowp++=stk[tp--]^'0');*nowp++=c;
		}
}
int n,a[neko],stk[neko],pre[neko],tp;
typedef long long ll;
ll ans;
int main()
{
	using namespace IO;
	read(n);
	f(i,1,n)
	{
		read(a[i]);
		while(tp&&a[stk[tp]]>a[i])--tp;
		pre[i]=stk[tp],stk[++tp]=i;
	}tp=0;
	rf(i,n,1)
	{
		while(tp&&a[stk[tp]]>a[i])--tp;
		ans+=(ll)(i-pre[i])*((tp?stk[tp]:n+1)-i)*a[i];
		stk[++tp]=i;
	}
	return write(ans),flush(),0;
}

Measured memory_bytes: 4352
#include <iostream>
#include<string.h>

using namespace std;

int main()
{
    char a[10];
    char b[10];

    cin>>a>>b;

    if(a[0]==b[2] && a[1]==b[1] && a[2]==b[0])
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
using namespace std;

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

	int c = 0;
	for (int i = 0;i < n;i++) {
		int a, b;
		cin >> a >> b;
		if (a == b) {
			c++;
		}
		else {
			c = 0;
		}

		if (c == 3) {
			cout << "Yes\n";
			return 0;
		}
		
	}
	
	cout << "No\n";

	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
 using namespace std;
 int main()
 {
     int N,T,A;
     cin>>N>>T>>A;
     vector<int> H;
     double ans = 1e16;
     int ansj = 0;
     for(int i=1;i<=N;++i)
     {
         int x;
         cin>>x;
         if(abs(T-0.006*x-A)<ans)
         {
             ans = abs(T-0.006*x-A);
             ansj = i;
         }
     }
    cout<<ansj<<endl;
 }

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main() {
    int N,D,X,Y,A=0; cin>>N>>D;
    for (int i=0; i<N; i++) {
        cin>>X>>Y;
        if (sqrt(pow(X,2)+pow(Y,2)) <= D) {
            A++;
        }
    }
    cout<<A<<endl;
    return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int cnt[200010];
bool cmp(int x,int y)
{
    return x>y;
}
int main()
{
    int n,k;
    cin>>n>>k;
    int x;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&x);
        cnt[x]++;
    }
    sort(cnt,cnt+n,cmp);
    int ans=0;
    for(int i=k;i<=n;i++)
        ans+=cnt[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
N, K = map(int, input().split())
# print(N,K)
p = list(map(int, input().split()))
# print(p)
# 1 から P までの P 種類の目が等確率で出るサイコロの出目の期待値は (1 + P)/2 です。
p_exp = [(1+i)/2 for i in p]
# print('期待値が入ったリストp')
# print('p='+ str(p_exp))
# 期待値が入ったリストpができた
# 新たに累積和リストSを作成する
S =[0] * N
S[0] = p_exp[0]
for i in range(len(p_exp) - 1):
    S[i + 1] = S[i] + p_exp[i + 1]
# print('累積和が入ったリスト')
# print('S=' + str(S))
S.insert(0, 0)
# print('累積和が入ったリストに先頭0挿入したリスト')
# print('S=' + str(S))
max =0
exp_sum = 0
for j in range(N - K + 1):
    exp_sum = S[j + K] - S[j]
    if max < exp_sum:
        max = exp_sum
# print('求める最大値maxは')
# print('max=' + str(max))
print(max)

Measured memory_bytes: 25928
import java.util.Arrays;
import java.util.Scanner;

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

		int[] nn = new int[200];
		int[] d = new int[200];

		int[][] field = new int[420][420];

		int w;
		int h;
		int blockNum;

		while (true) {
			int n = scan.nextInt();

			if (n == 0)
				break;

			w = 1;
			h = 1;

			int minW = 500;
			int maxW = 0;
			int minH = 500;
			int maxH = 0;

			for (int i = 0; i < 420; i++) {
				Arrays.fill(field[i], -1);
			}

			blockNum = 0;

			field[210][210] = blockNum;

			for (int i = 0; i < n - 1; i++) {
				nn[i] = scan.nextInt();
				d[i] = scan.nextInt();
			}

			for (int i = 0; i < n - 1; i++) {
				for (int j = 0; j < 420; j++) {
					for (int k = 0; k < 420; k++) {
						if (field[j][k] == nn[i]) {
							if (d[i] == 0) {
								field[j][k - 1] = blockNum + 1;
							}
							if (d[i] == 1) {
								field[j + 1][k] = blockNum + 1;
							}
							if (d[i] == 2) {
								field[j][k + 1] = blockNum + 1;
							}
							if (d[i] == 3) {
								field[j - 1][k] = blockNum + 1;
							}
							blockNum++;
						}
					}
				}
			}

			for (int i = 0; i < 420; i++) {
				for (int j = 0; j < 420; j++) {
					if (field[i][j] != -1 && minW > j) {
						minW = j;
						break;
					}
				}
			}

			for (int i = 0; i < 420; i++) {
				for (int j = 419; j >= 0; j--) {
					if (field[i][j] != -1 && maxW < j) {
						maxW = j;
						break;
					}
				}
			}
			for (int i = 0; i < 420; i++) {
				for (int j = 0; j < 420; j++) {
					if (field[j][i] != -1 && minH > j) {
						minH = j;
						break;
					}
				}
			}
			for (int i = 0; i < 420; i++) {
				for (int j = 419; j >= 0; j--) {
					if (field[j][i] != -1 && maxH < j) {
						maxH = j;
						break;
					}
				}
			}

			w = maxW - minW + 1;
			h = maxH - minH + 1;
			System.out.println(w + " " + h);
		}

		scan.close();
	}
}

Measured memory_bytes: 38660
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<vector<int>> sum;
  int N,M,Q,L,R,p,q;
  cin>>N>>M>>Q;
  sum=vector<vector<int>>(N+1,vector<int>(N+1,0));
  for(int i=0;i<M;i++){cin>>L>>R; sum[L][R]++;}
  for(int i=1;i<=N;i++)for(int j=1;j<=N;j++)
    sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
  for(int i=0;i<Q;i++){
    cin>>p>>q;
    cout<<sum[q][q]-sum[q][p-1]-sum[p-1][q]+sum[p-1][p-1]<<endl;
  }
}


Measured memory_bytes: 1920
s=input()
t=int(s[0]+s[1])
u=int(s[2]+s[3])
if 0<t<=12 and 0<u<=12:
  print('AMBIGUOUS')
elif (t>=13 or t==0) and (u>=13 or u==0):
  print('NA')
elif 0<u<=12:
  print('YYMM')
elif 0<t<=12: 
  print('MMYY')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int a[5][5000],b,c,n;
int main(){
    cin>>n;
    for(int i=0;i<2;i++){
        for(int u=0;u<n;u++){
            cin>>a[i][u];
        }
    }

    for(int i=n-1;i>0;i--){
        a[1][i-1]=a[1][i]+a[1][i-1];
    }


    for(int i=n-1;i>-1;i--){
        a[0][i]=a[0][i]+max(a[1][i],a[0][i+1]);
    }



    cout<<a[0][0]<<endl;
}


Measured memory_bytes: 256
d = {1:0,2:0,3:0,4:0}
for i in range(3):
    j,k = map(int,input().split())
    d[j] += 1
    d[k] += 1
if d[1]==3 or d[2]==3 or d[3]==3 or d[4]==3:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int	main(void)
{
  	char	s[99];
  	int		num;
  	int		len;
  	int		i;
  	int     first;
  	int     second;
  	int     flag;
  
  	num = scanf("%s", s);
  	if (num != 1)
      	return (0);
  
  	len = strlen(s);
  
  	first = (len - 1) / 2;
  	second = (len + 3) / 2;
  	
  	flag = 0;
  	for(i=0; i<len; i++)
  	{
  	    if (s[i] == s[len - i - 1])
  	        flag = 1;
  	    else
  	    {
  	        flag = 0;
            printf("No");
            return (0);
  	    }
  	}
  	
  	for(i=0; i<first; i++)
    {
  	    if (s[i] == s[first - i - 1])
  	    {
  	        flag = 1;
  	    }
  	    else
  	    {
  	        flag = 0;
            printf("No");
            return (0);
  	    }
  	}

  	for(i=second; i<len; i++)
    {
  	    if (s[i] == s[len - i - 1])
  	        flag = 1;
  	    else
  	    {
  	        flag = 0;
            printf("No");
            return (0);
  	    }
  	}
  	
  	if (flag == 1)
        printf("Yes");
    else
        printf("No");
    return (0);
}

Measured memory_bytes: 256
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, M, P = list(map(int, sys.stdin.readline().split()))
ABC = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]

graph = [[] for _ in range(N)]
for a, b, c in ABC:
    graph[a - 1].append((b - 1, P - c))


def can_go_from_0():
    # 1 からのパスがある
    ret = [False] * N

    stack = [0]
    while stack:
        v = stack.pop()
        ret[v] = True
        for u, _ in graph[v]:
            if not ret[u]:
                ret[u] = True
                stack.append(u)
    return ret


def can_go_to_n():
    revs = [[] for _ in range(N)]
    for a, b, c in ABC:
        revs[b - 1].append(a - 1)

    # n へのパスがある
    ret = [False] * N
    stack = [N - 1]
    while stack:
        v = stack.pop()
        ret[v] = True
        for u in revs[v]:
            if not ret[u]:
                ret[u] = True
                stack.append(u)
    return ret


vertices = []
for i, (v1, v2) in enumerate(zip(can_go_from_0(), can_go_to_n())):
    if v1 & v2:
        vertices.append(i)

# bellman-ford
dist = [INF] * N
dist[0] = 0
for i in range(N):
    for v in vertices:
        for u, d in graph[v]:
            dist[u] = min(dist[v] + d, dist[u])

# 使う頂点がまだアップデートされたらダメ
prev = dist[:]
for v in vertices:
    for u, d in graph[v]:
        dist[u] = min(dist[v] + d, dist[u])
updated = False
for v in vertices:
    updated |= prev[v] != dist[v]

if updated or dist[N - 1] == INF:
    print(-1)
else:
    print(max(-dist[N - 1], 0))


Measured memory_bytes: 56284
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;


#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod

int main(){
    ll N; cin>>N;
    vec ans(N+1,0);
    REP(i,1,100) {
        if(i*i>N) break;
        REP(j,1,100) {
            if(i*i+j*j+i+j>N) break;
            REP(k,1,100){
                if(i*i+j*j+k*k+i*j+j*k+k*i>N) break;
               // cout<<i<<' '<<j<<' '<<k<<' '<<i*i+j*j+k*k+i*j+j*k+k*i<<endl;
                ans[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
        }
    }
    REP(i,1,N+1) cout<<ans[i]<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define s second
#define f first
long long const mod = 1000000007;
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

ll power(ll x,ll y,ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;
    return (y%2 == 0)? p : (x * p) % m;
}

ll modInv(ll x)
{
    return power(x,mod-2,mod)%mod;
}



int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ld a,b,c;
    
    cin>>a>>b>>c;
    
    ll l=4*a*b;
    ll r=c-a-b;
    if(r>=0 && r*r>l)
        cout<<"Yes\n";
    else
    {
        cout<<"No\n";
    }
    
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
      	int k = in.nextInt();
      	int nam = 1;
      
      for(int i =0;i < n ;i++){
        nam = Math.min(nam*2,nam+k);
      }
      System.out.print(nam);
	}
}

Measured memory_bytes: 22612
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) prllf("%d",n)
#define pl(n) prllf("%d",n)
using namespace std;

ll solve(ll n){
  ll ans = 0;
  while(n){
    ans+=n%10;
    n/=10;
  }
  return ans;
}

int main(){
  ll n;
  cin >> n;
  if(n%solve(n)==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
N = int(input())
x = []
for _ in range(N):
    s = input()
    x.append(s)
print('AC'+ ' '+ 'x'+ ' '+str(x.count('AC')))
print('WA'+ ' '+ 'x'+ ' '+str(x.count('WA')))
print('TLE'+ ' '+ 'x'+ ' '+str(x.count('TLE')))
print('RE'+ ' '+ 'x'+ ' '+str(x.count('RE')))

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int MOD;
std::vector<std::vector<int> > hen;
std::vector<std::pair<int, int> > subtree;
std::vector<std::pair<int, int> > res;
void dfs1(int i, int prev) {
	// first : sum(first) + sum(second)
	// second : prod(second + 1)
	subtree[i].first = 0;
	subtree[i].second = 1;
	for (auto j : hen[i]) {
		if (j != prev) {
			dfs1(j, i);
			subtree[i].first += subtree[j].first;
			if (subtree[i].first >= MOD) subtree[i].first -= MOD;
			subtree[i].first += subtree[j].second;
			if (subtree[i].first >= MOD) subtree[i].first -= MOD;
			subtree[i].second = (int64_t) subtree[i].second * (subtree[j].second + 1) % MOD;
		}
	}
}
void dfs2(int i, int prev, std::pair<int, int> parent) {
	res[i].first = 0;
	res[i].second = 1;
	std::vector<std::pair<int, int> > childs;
	for (auto j : hen[i]) {
		std::pair<int, int> cur;
		if (j == prev) cur = parent;
		else cur = subtree[j];
		res[i].first += cur.first;
		if (res[i].first >= MOD) res[i].first -= MOD;
		res[i].first += cur.second;
		if (res[i].first >= MOD) res[i].first -= MOD;
		res[i].second = (int64_t) res[i].second * (cur.second + 1) % MOD;
		
		if (j != prev) childs.push_back(subtree[j]);
	}
	
	int m = childs.size();
	std::vector<int> prod_left(m + 1), prod_right(m + 1);
	prod_left[0] = 1;
	for (int i = 0; i < m; i++) prod_left[i + 1] = (int64_t) prod_left[i] * (childs[i].second + 1) % MOD;
	prod_right[m] = 1;
	for (int i = m; i; i--) prod_right[i - 1] = (int64_t) prod_right[i] * (childs[i - 1].second + 1) % MOD;
	
	int cnt = 0;
	for (auto j : hen[i]) {
		if (j != prev) {
			int first = res[i].first;
			first -= subtree[j].first;
			if (first < 0) first += MOD;
			first -= subtree[j].second;
			if (first < 0) first += MOD;
			int second = (int64_t) prod_left[cnt] * prod_right[cnt + 1] % MOD;
			if (prev != -1) second = (int64_t) second * (parent.second + 1) % MOD;
			dfs2(j, i, {first, second});
			cnt++;
		}
	}
	
}
int main() {
	int n = ri();
	MOD = ri();
	hen.resize(n);
	for (int i = 0; i + 1 < n; i++) {
		int a = ri() - 1, b = ri() - 1;
		hen[a].push_back(b);
		hen[b].push_back(a);
	}
	subtree.resize(n);
	dfs1(0, -1);
	res.resize(n);
	dfs2(0, -1, {0, 0});
	for (int i = 0; i < n; i++) std::cout << res[i].second << std::endl;
	
	return 0;
}


Measured memory_bytes: 24064
#include <cstdint>
#include <cstdlib>
#include <iostream>


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

  std::int64_t a, b, x;
  std::cin >> a >> b >> x;
  std::cout << (b / x + 1 - (a == 0 ? 0 : ((a - 1) / x + 1))) << std::endl;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 3000

const int INF = 1e9+7;


int main(){

    int w,h;
    while(cin >> w >> h,w|h){

        vector<pll> g[ARRAY_MAX];
        ll gy,gx,n = 0;
        for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                string s;
                cin >> s;
                if(s == "."){
                    continue;
                }
                if(s == "S"){
                    g[0].push_back({i,j});
                }else if(s == "G"){
                    gy = i;
                    gx = j;
                }else{
                    ll num = (ll)stoi(s);
                    g[num].push_back({i,j});
                    n = max(n,num);//最大の数字
                }
            }
        }
        n++;
        g[n].push_back({gy,gx});
        vector<vector<ll> > dp(n+1);
        for(int i = 0;i < n+1;i++){
            dp[i].resize(g[i].size(),INF);
        }
        dp[0][0] = 0;

        for(int i = 1;i <= n;i++){
            for(int j = 0;j < g[i-1].size();j++){
                for(int k = 0;k < g[i].size();k++){
                    ll len = abs(g[i-1][j].first-g[i][k].first) + abs(g[i-1][j].second-g[i][k].second);
                    dp[i][k] = min(dp[i][k],dp[i-1][j] + len);
                }
            }
        }
        cout << dp[n][0] << endl;
    }

    return 0;
}


Measured memory_bytes: 3436
n, m = STDIN.gets.split(' ').map(&:to_i)

requests = m.times.map do
  STDIN.gets.split(' ').map(&:to_i)
end

requests.sort_by! {|r| [r[1], -r[0]]}

split = 0

target = requests.shift
while (target)
  requests.select! {|r| r[0] >= target[1]}
  target = requests.shift
  split += 1
end

puts split

Measured memory_bytes: 15352
N, K = (int(x) for x in input().split())
S = input()

happiness = N
if S[0] == "L":
  happiness -= 1
if S[-1] == "R":
  happiness -= 1
for i in range(N-1):
  if S[i:i+2] == "RL":
    happiness -= 2

happiness += 2*K

print(min(N-1, happiness))

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    int N, K;
    vector<int> A;

    cin >> N >> K;
    A.resize(N);
    REP(i, N) {
        cin >> A[i];
    }

    int cur = 1;
    REP(i, K) {
        cur *= A[i];
    }

    for(int i = K; i < N; ++i) {
        int next_cur = cur / A[i - K] * A[i];
        if(A[i - K] < A[i]) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
        cur = next_cur;
    }

    return 0;
}


Measured memory_bytes: 4780
N = int(input())
T = [int(input()) for i in range(N)]
def gcd(x,y):
    if x<y:x,y = y,x
    if y==0:return x
    return gcd(y,x%y)
S = T[0]
for i in range(1,N):
    S = S*T[i]//gcd(S,T[i])
print(S)

Measured memory_bytes: 3060
#include <stdio.h>

#define N 100
#define inf 1000000000
#define L 1000


int Q[L],head, tail;
int n, mary[N][N], dary[N];

void enqueue(int value){
  Q[tail]=value;
  tail=(tail+1)%L;  
}

void dequeue(){
   head=(head+1)%L; 
}

void bfs(int s){
  int i,u,v;

  enqueue(s);
  for(i=0;i<n;i++)dary[i]=inf;
  dary[s] = 0;
  while(head!=tail){
    u=Q[head];
    dequeue();
    for(v=0;v<n;v++){
      if(mary[u][v]==0)continue;
      if(dary[v]!=inf)continue;
      dary[v]=dary[u]+1;
      enqueue(v);
    }
  }
  for(i=0;i<n;i++){
    printf("%d",i+1);
    if(dary[i]==inf){
      printf(" %d\n",-1);
    }
    else{
      printf(" %d\n",dary[i]);
    }
  }
}
int main(){
  int i,j,u,k,v;

  scanf("%d",&n);

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



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

using namespace std;
#define ll long long

ll INF = 1e9 + 7;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    vector<int> arr(n);

    for(int i=0;i<n;i++)
        cin>>arr[i];

    int ans = 0;

    for(int i =1; i<=n; i++)
        if((i%2 == 1) && (arr[i-1]%2 == 1))
            ans++;
    
    cout<<ans<<endl;

    return 0;
}


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

#define FasterIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(), v.end()
const int MOD = 1e9+7;

int main(){
    FasterIO;

    int r, d, x;

    while(cin>>r>>d>>x){
        for(int i=0; i<10; i++){
            x = r*x-d;
            cout<<x<<endl;
        }
    }

    return 0;
}



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

const int len = 50;
int cnt[len];
char str[len];

int main(){
    scanf("%s", &str);
    int n = strlen(str), m = -1;
    char let;

    for (int i = 0; i <= n; i++){
        int mn = str[i]-'a'+1;
        if (i == n) mn = 0;

        while (mn < 26 && cnt[mn])
            mn++;

        if (mn < 26)
            m = i, let = mn+'a';

        if (i < n)
            cnt[str[i]-'a']++;
    }

    if (m == -1) printf("-1\n");
    else{
        for (int i = 0; i < m; i++)
            printf("%c", str[i]);
        printf("%c\n", let);
    }
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  //入力終わり

  //各色のi番目までの登場回数
  //0で初期化
  int rn[N], gn[N], bn[N];
  rep(i, N){
    rn[i] = 0; gn[i] = 0; bn[i] = 0;
  }

  //各色のi番目までの登場回数を計算
  for(int i=0; i<N-1; i++){
    if(S[i] == 'R')
      rn[i]++;
    else if(S[i] == 'G')
      gn[i]++;
    else
      bn[i]++;
    rn[i+1] = rn[i];
    gn[i+1] = gn[i];
    bn[i+1] = bn[i];
  }
  //N番目は別で見る
  if(S[N-1] == 'R')
    rn[N-1]++;
  else if(S[N-1] == 'G')
    gn[N-1]++;
  else if(S[N-1] == 'B')
    bn[N-1]++;

  /*rep(i, N)
    cout << rn[i] ;
  cout << endl;

  rep(i, N)
    cout << gn[i] ;
  cout << endl;

  rep(i, N)
    cout << bn[i] ;
    cout << endl;*/

  map<char, int> m;
  m['R'] = 0; m['G'] = 1; m['B'] = 2;
  
  long long ans = 0;
  for(int i=0; i<N-2; i++){
    for(int j=i+1; j<N-1; j++){
      if(S[i] == S[j])
	continue;
      int k = j+(j-i);
      //i番目のとj番目でRとGを選んだとき
      if(m[S[i] ] + m[S[j] ] == 1){
	//j+1番目以降のBの数を加算
	ans = ans + bn[N-1] - bn[j];
	//条件の2つ目の処理
	if(k<N && S[k] == 'B')
	  ans--;
      }
      //GB
      else if(m[S[i] ] + m[S[j] ] == 3){
	ans = ans + rn[N-1] - rn[j];
	if(k<N && S[k] == 'R')
	  ans--;
      }
      //BR
      else if(m[S[i] ] + m[S[j] ] == 2){
	ans = ans + gn[N-1] - gn[j];
	if(k<N && S[k] == 'G')
	  ans--;
      }
    }
  }

  //解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <string>
#include <stack>
#include <iostream>
using namespace std;

string S;
int ans = -1, s = 0, e = -1;

int main()
{
    cin>>S;
    if( S[0] == S[S.size()-1] ) ans = S.size()-3;
    else ans = S.size()-2;
    if( ans%2 ) cout<<"First";
    else cout<<"Second";
}


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

using namespace std;

typedef long long int lli;

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

    int n, x[50], y[50];
    map<pair<int, int>, int> mp;

    cin >> n;
    for (int i=0; i<n; i++) cin >> x[i] >> y[i];

    int cont = 0;
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            if (i == j) continue;
            mp[make_pair(x[i]-x[j], y[i]-y[j])]++;
            cont = max(cont, mp[make_pair(x[i]-x[j], y[i]-y[j])]);
        }
    }

    cout << n-cont << endl;

    return 0;
}


Measured memory_bytes: 384