akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int K = scanner.nextInt();
    List<Integer> digits = new ArrayList<>();
    for (int i = 0; i < 10; i++) digits.add(i);
    for (int i = 0; i < K; i++) {
      int D = scanner.nextInt();
      if (digits.contains(D)) digits.remove(Integer.valueOf(D));
    }
    for (int i = 1; i <= 5; i++) {
      List<Integer> numbers = rec(i, new ArrayList<>(digits), digits);
      Collections.sort(numbers);
      for (int n : numbers) {
        if (n >= N) {
          System.out.println(n);
          return;
        }
      }
    }
  }

  private static List<Integer> rec(int remain, List<Integer> numbers, List<Integer> digits) {
    if (remain == 1) return numbers;
    List<Integer> list = new ArrayList<>();
    for (int n : numbers) {
      for (int d : digits) {
        list.add(n * 10 + d);
      }
    }
    return rec(remain - 1, list, digits);
  }
}


Measured memory_bytes: 21076
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define N 100010
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define mod 1000000007
#define pii pair <int, int>
#define all(x) x.begin(), x.end()
#define FOR(i, x, y) for (int i = x; i <= y; i++)

using namespace std;

int n, m, a, b;
int v[N], ans;

bool vis[N];

vector <int> E[N], tp;

void dfs(int node) {
	vis[node] = 1;
	tp.pb(node);
	for (auto i: E[node])
		if(!vis[i])
			dfs(i);
}

int main()
{
	scanf("%d%d", &n, &m);
	FOR (i,1,n)
		scanf("%d", &v[i]);
	
	FOR (i,1,m) {
		scanf("%d%d", &a, &b);
		E[a].pb(b);
		E[b].pb(a);
	}
	
	FOR (i,1,n) {
		if (!vis[i]) {
			dfs(i);
			
			set <int> S;
			for (auto j: tp) {
				S.insert(j);
			}
			
			for (auto j: tp) {
				if (S.find(v[j]) != S.end())
					ans++;
			}
			
			tp.clear();
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 14328
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

using namespace std;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

//const int maxn=

inline void cal(int a,int b,int c,int k)
{
	
	if(a<b && b<c)
	{
		cout<<"Yes"<<endl;
		return ;
	}
	
	while(b<=a)
	{
		if(k)
		{
			b<<=1;
			k--;
		}
		else
		{
			cout<<"No"<<endl;
			return ;
		}
	}
	
	while(c<=b)
	{
		if(k)
		{
			c<<=1;
			k--;
		}
		else
		{
			cout<<"No"<<endl;
			return ;
		}
	}
	
	cout<<"Yes"<<endl;
	return ;
	
}

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	int a,b,c,k;
	
	while(cin>>a>>b>>c>>k)
	{
		cal(a,b,c,k);
	}
	
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <list>
#include <deque>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#define ll long long
#define INF 0x3f3f3f3f
#define SIS std::ios::sync_with_stdio(false)
using namespace std;
ll fast_pow(ll a,ll b,ll mod)
{
    ll c=1;
    while(b>=2)
    {
        if(b%2==0)
            a*=a,b/=2;
        else
            c*=a,a*=a,b--,b/=2;
        a%=mod,c%=mod;
    }
    return (a*c)%mod;
}

int main()
{
    double n;
    while(cin>>n)
    {
        double ans;
        n/=3;
        ans=n*n*n;
        printf("%.12f\n",ans);
    }
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

vector<vector<ll>> A;
vector<vector<pair<ll, ll>>> path;
ll N;

ll dfs(ll x, ll y) {
    if(x >= N || y >= 2) return 0;
    if(get<0>(path[y][x]) == -1) get<0>(path[y][x]) = dfs(x + 1, y);
    if(get<1>(path[y][x]) == -1) get<1>(path[y][x]) = dfs(x, y + 1);
    return A[y][x] + max(get<0>(path[y][x]), get<1>(path[y][x]));
}

int main(void) {
    cin >> N;
    A.resize(2, vector<ll>(N));
    path.resize(2, vector<pair<ll, ll>>(N, pair<ll, ll>{-1, -1}));
    for(ll i = 0;i < N;i++) cin >> A[0][i];
    for(ll i = 0;i < N;i++) cin >> A[1][i];
    cout << dfs(0, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

  int N,sum;
  int cnt;

  while(1){
    cin >>N;
    if(N == 0)break;
    
    cnt=0;
    
    for(int i=1 ; i <= N/2 ; i++){
      sum=0;
      int j=0;
      while(1){
	sum+=i+j;
	if(sum == N){
	  cnt++;
	  break;
	}else if(sum > N){
	  break;
	}	
	j++;
      }
    }
    
    cout <<cnt<<endl;
    
  }
  return 0;
}

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


int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll target=max(max(a,b),c);
    ll else1, else2;
    if(target == a){
        else1 = c; else2 = b;
    }
    if(target == b){
        else1 = a; else2 = c;
    }
    if(target == c){
        else1 = a; else2 = b;
    }

    rep(i,k){
        target *= 2;
    }
    cout << target + else1 + else2 << endl;
    return 0;


}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int m = ( N / 1000) ;
  int k = ( N - m * 1000 ) /100 ;
  int l = ( N - ( m * 1000 + k * 100 ) ) / 10 ;
  int p =  N - ( m * 1000 + k * 100 + l * 10 ) ;
  if ( m == k && k == l ) {
    cout << "Yes" << endl;
  } else if ( k == l && l == p ) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  //cout << m << endl << k << endl << l << endl << p << endl;
}


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

int main(){
    long long n;
    cin >> n;
    vector<long long> a(n);

    for(long long i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<long long> a_sum(n+1, 0);

    for(long long i = 0; i < n; i++){
        a_sum[i+1] = a[i] + a_sum[i];
    }

    map<long long, long long> T;
    for(long long i = 0; i <= n; i++){
        if(T.find(a_sum[i]) == T.end()){
            T[a_sum[i]] = 1;
        }
        else{
            T[a_sum[i]]++;
        }
    }

    map<long long, long long>::iterator it;
    long long count = 0;
    for(it = T.begin(); it != T.end(); it++){
        if(it->second >= 2){
            count += it->second*(it->second-1)/2;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 18780
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
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; }
using namespace std;
typedef long long ll;

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

    auto check = [&](ll x){
        if(x == 0)return false;
        return N / x == N % x;
    };

    ll ans = 0;
    for(ll i = 1; i * i <= N; i++){
        if(N % i == 0){
            if(check(i - 1))ans += i - 1;
            if(check(N / i - 1))ans += N / i - 1;
        }
    } 
    
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
while True :
    x=int(input())
    if x==0:
        break
    else:
        a=(1000-x)//500
        b=(1000-x-500*a)//100
        c=(1000-x-500*a-100*b)//50
        d=(1000-x-500*a-100*b-50*c)//10
        e=(1000-x-500*a-100*b-50*c-10*d)//5
        f=1000-x-500*a-100*b-50*c-10*d-5*e
        print(a+b+c+d+e+f)


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

int main() {

  string s;
  cin >> s;
  
  int ans = 700;
  
  for (int i = 0; i < 3; i++){
    if (s[i] == 'o') ans +=100;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        
        while(true) {
            int a = scan.nextInt();
            String op = scan.next();
            int b = scan.nextInt();
            
            if(op.equals("+")) 
                  System.out.println(a+b);
            else if (op.equals("-"))
                  System.out.println(a-b);
            else if (op.equals("*"))
                  System.out.println(a*b);
            else if (op.equals("/"))
                  System.out.println(a/b);
            else break;
        }
     }
}

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

int main(){
    
    vector<int> a(3); cin>>a[0]>>a[1]>>a[2];

    sort(a.begin(),a.end());

    cout<< abs(a[2] - a[1]) + abs(a[0] - a[1])<<endl;

    return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
ll n,m,ans;
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    if(m/2 >= n)
        cout<<n+(m-n*2)/4<<endl;
    else
        cout<<m/2<<endl;
    return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

signed main(){

	lli n;
	cin>>n;

	lli sum = 0;
	for(lli i=1;i<=n;i++){
		if(i%2==1)sum++;
	}

	double ans = sum/(double)n;

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int n,p;
char a[N];
LL vis[N];
LL f[N][10];
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>p>>a+1;
  if(p>=10){
    int pre=0;
    LL ans=0;vis[0]=1;
    LL c=1;
    for(int i=n;i>=1;i--,c=c*10%p){
      pre=(pre+(a[i]-'0')*c)%p;
      ans+=vis[pre];
      vis[pre]++;
    }
    cout<<ans<<'\n';
  }else{
    LL ans=0;
    for(int i=1;i<=n;i++){
      for(int j=0;j<p;j++){
        f[i][(j*10+a[i]-'0')%p]+=f[i-1][j];
      }
      f[i][(a[i]-'0')%p]++;
      ans+=f[i][0];
    }
    cout<<ans<<'\n';
  }

  return 0;
}

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

using namespace std;

int main()
{
    while(1){
        int n,m;
        cin >> n >> m;
        if(n == 0){
            break;
        }
        vector<int> a(n);
        rep(i,n){
            cin >> a[i];
        }
        int mx = 0;
        rep(i,n-1){
            for(int j= i+1;j<n;j++){
                if(a[i]+a[j] <= m){
                    mx = max(mx,a[i]+a[j]);
                }
            }
        }
        if(mx == 0){
            cout << "NONE\n";
        }else{
            cout << mx << "\n";
        }
    }
}



Measured memory_bytes: 3092
#include <iostream>

using namespace std;

int main(void) {
    int K = 0;

    scanf("%d", &K);

    int num[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    cout << num[K-1];

    return 0;
}


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

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

    sort(A.begin(), A.end());
    int res = A[N - 1] - A[0];
    for (int i = 1; i < N - 1; i++) {
        res += abs(A[i]);
    }
    cout << res << endl;

    for (int i = N - 2; i > 0 && A[i] >= 0; i--) {
        cout << A[0] << " " << A[i] << endl;
        A[0] -= A[i];
    }
    for (int i = 1; i < N - 1 && A[i] < 0; i++) {
        cout << A[N - 1] << " " << A[i] << endl;
        A[N - 1] -= A[i];
    }

    cout << A[N - 1] << " " << A[0] << endl;
    return 0;
}

Measured memory_bytes: 2304
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<map>
#include<set> 
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<math.h>
using namespace std;
const int maxn = 1e3 + 5;
const int p = 233;
typedef unsigned long long ull;
ull hash1[maxn],hash2[maxn],P[maxn]; 
char a[maxn],b[maxn];
const int mod=1e9+7;
ull quhash(int l,int r)
{
	return hash1[r]-hash1[l-1]*P[r-l+1];
}
int main()
{
	int n;
	P[0]=1;
	for(int i=1;i<=maxn;i++)
		P[i]=P[i-1]*p;
	cin>>n;
	scanf("%s",a+1);
	b[1]='A',b[2]='B',b[3]='C';
	int len1=strlen(a+1);
	int len2=strlen(b+1);
	hash1[0]=0,hash2[0]=0;
	for(int i=1;i<=len1;i++)	
		hash1[i]=hash1[i-1]*p+a[i];
	for(int i=1;i<=len2;i++)	
		hash2[i]=hash2[i-1]*p+b[i];	
	int l=1,ans=0;
	for(;l<=len1-len2+1;)
	{
		int r=l+len2-1;
		if(quhash(l,r)==hash2[len2])
		{
			ans++;
			l=r+1;	
		}	
		else
			l++;  
	}
	cout<<ans<<endl;	
}

Measured memory_bytes: 3768
import java.lang.Math

fun main(args: Array<String>)
{
    val (a, b) = readInts()

    var cnt = 1
    var ans = 0
    while (cnt < b) {
        cnt += a - 1
        ans += 1
    }

    println(ans)
}

fun readInts(): List<Int> = readLine()!!.split(" ").map(String::toInt)
fun readLongs(): List<Long> = readLine()!!.split(" ").map(String::toLong)

fun readIntArr(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray()
fun readLongArr(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray()

fun readIntArrS(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray().sortedArray()
fun readLongArrS(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray().sortedArray()

fun readIntArrSD(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray().sortedArrayDescending()
fun readLongArrSD(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray().sortedArrayDescending()

fun readString() = readLine()!!


Measured memory_bytes: 37904
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF INT32_MAX / 2
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

#include <atcoder/dsu>

signed main() {
    int n, q, t, u, v;
    cin >> n >> q;
    atcoder::dsu d(n);
    while (q--) {
        cin >> t >> u >> v;
        if (!t) {
            d.merge(u, v);
        }
        else
            cout << d.same(u, v) << endl;
    }
}

Measured memory_bytes: 3960
N,Y=map(int,input().split())
for x in range(N+1):
  for y in range(N+1):
    z=N-x-y
    if z<0:
      continue
    else:
      if 10000*x+5000*y+1000*z==Y:
        print(x,y,z)
        exit()
print("-1 -1 -1")


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

#define mp make_pair

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef pair<i64,int> pli;
typedef pair<int,i64> pil;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<i64> vl;

template <typename T>
T id(T b) {return b;};
template <class It>
bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It>
bool any(It f,It l){return std::any_of(f,l,id<bool>);}

const int MAX_N = 200000;
int n;
int a[MAX_N];

bool f(int k)
{
  map<int,int> m;
  for (int i = 1; i < n; i++) {
    if (a[i] <= a[i-1]) {
      while (!m.empty() && m.rbegin()->first > a[i]) {
        m.erase(m.rbegin()->first);
      }

      m[a[i]]++;
      int j = a[i];
      while (j > 1 && m[j] == k) {
        m.erase(j);
        m[--j]++;
      }
      if (j == 1 && m[1] == k)
        return false;
    }
  }
  return true;
}

int main()
{
  bool inc = true;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i > 0) inc &= a[i] > a[i-1];
  }

  if (inc) {
    cout << 1 << endl;
    return 0;
  }

  int l = 1, r = n+1;
  while (r - l > 1) {
    int m = (l + r) / 2;
    if (f(m))
      r = m;
    else
      l = m;
  }

  cout << r << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			int[] a = new int[n+1];
			for(int i=1;i<=n;i++) {
				a[i] = sc.nextInt();
			}
			for(int i=1;i<=n;i++) {
				a[i] += a[i-1];
			}
			int max = Integer.MIN_VALUE;
			for(int i=1;i<=n;i++) {
				for(int j=i;j<=n;j++) {
					max = Math.max(max,a[j]-a[i-1]);
				}
			}
			System.out.println(max);
		}
	}

}

Measured memory_bytes: 26532
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace AtCoder
{
    class ABC168C
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = new int[n];
            string[] str = Console.ReadLine().Split(' ');
            for(int i = 0; i < n; i++)
            {
                a[i] = int.Parse(str[i]);
            }
            long count = 0;
            for(int i = 1; i < n; i++)
            {
                if(a[i]<a[i-1])
                {
                    count += a[i-1]-a[i];
                    a[i] = a[i-1];
                }
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 46004
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<string> W(N);
	int rec = 0;
	for (int i = 0; i < N; i++) {
		cin >> W[i];
	}
	for (int i = 1; i < N; i++) {
		if (W[i - 1][W[i - 1].length() - 1] != W[i][0]) {
			rec++;
		}
	}
	sort(W.begin(), W.end());
	for (int i = 0; i < N - 1; i++) {
		if (W[i] == W[i + 1]) {
			rec++;
		}
	}
	if (rec == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main(){
  int n,m;
  string a[100],b[100];
  cin>>n>>m;
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<m;i++) cin>>b[i];
  int cnt=0;
  for(int x=0;x<n;x++){
    for(int y=0;y<n;y++){

     for(int i=0;i<m;i++){
       for(int j=0;j<m;j++){
         if(a[x+i][y+j]==b[i][j]) cnt++;
         else cnt=0;
         if(cnt==m*m){ cout<<"Yes"; return 0; }
       }
     }

    }
  }
  cout<<"No";
}


Measured memory_bytes: 256
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

res = 1e10
for i in range(1 << d):
    total = 0
    num = 0
    rest_max = -1
    for j in range(d):
        if (i >> j) & 1 == 1:
            total += (j+1)*100*pc[j][0] + pc[j][1]
            num += pc[j][0]
        else:
            rest_max = j
    if total < g:
        rest = (g - total + (rest_max+1)*100 - 1) // ((rest_max+1)*100)
        if pc[rest_max][0] < rest:
            continue
        num += rest
    res = min(res, num)
print(res)

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int n,m,a[10009];

int main()
{
	cin >> n >> m;
	for(int i = 0;i<m;i++)cin >> a[i];
	for(int i = 0;i<m;i++)n -= a[i];
	cout << (n>=0?n:-1);
	return 0;
}

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

ans=0
for i in range(N):
    p=min(A[i]+A[i+1],B[i])
    ans=ans+p
    if A[i]<=B[i]:
        A[i+1]=max(0,A[i+1]-B[i]+A[i])
print(ans)

Measured memory_bytes: 19116
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int N, K, X, Y, ans;
	cin >> N >> K >> X >> Y;
	
	if (N > K) ans = (K * X) + ((N - K) * Y);
	else ans = (N * X);
	
	std::cout << ans << std::endl;
	
	return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c)cout << "Yes" << endl;
	else cout << "No" << endl;

}


Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
m = 114514
ans = 1919
for i in range(n):
    if abs(t - 0.006 * h[i] - a) < m:
        m = abs(t - 0.006 * h[i] - a)
        ans = i + 1
print(ans)

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"math"
)

func main() {
	X, A, B := scanInt(), scanInt(), scanInt()
	X -= A
	for X >= B {
		X -= B
	}
	fmt.Println(X)
}

/*
	Snippets
*/
func scanInt() (n int) {
	fmt.Scan(&n)
	return
}
func scanInts(n int) []int {
	N := make([]int, n)
	for i := 0; i < n; i++ {
		N[i] = scanInt()
	}
	return N
}
func scanInts2(n int) ([]int, []int) {
	N1, N2 := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		N1[i] = scanInt()
		N2[i] = scanInt()
	}
	return N1, N2
}
func scanInts3(n int) ([]int, []int, []int) {
	N1, N2, N3 := make([]int, n), make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		N1[i] = scanInt()
		N2[i] = scanInt()
		N3[i] = scanInt()
	}
	return N1, N2, N3
}
func scanMatrix(n, m int) [][]int {
	M := make([][]int, n)
	for i := 0; i < n; i++ {
		M[i] = scanInts(m)
	}
	return M
}
func scanStr() (s string) {
	fmt.Scan(&s)
	return
}
func scanStrs(n int) []string {
	S := make([]string, n)
	for i := 0; i < n; i++ {
		S[i] = scanStr()
	}
	return S
}
func getAbs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func getPow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}
func getMin(nums ...int) (int, int) {
	if len(nums) == 0 {
		panic("funciton getMin() requires at least one argument.")
	}
	min := nums[0]
	pos := 0
	for i := 1; i < len(nums); i++ {
		if min > nums[i] {
			min = nums[i]
			pos = i
		}
	}
	return min, pos
}
func getMax(nums ...int) (int, int) {
	if len(nums) == 0 {
		panic("funciton getMax() requires at least one argument.")
	}
	max := nums[0]
	pos := 0
	for i := 1; i < len(nums); i++ {
		if max < nums[i] {
			max = nums[i]
			pos = i
		}
	}
	return max, pos
}
func getGcd(a, b int) int {
	if b == 0 {
		return a
	}
	return getGcd(b, a%b)
}
func getLcm(a, b int) int {
	return a * b / getGcd(a, b)
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int n,k,t[100005],ans;
int main(void){
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)scanf("%d",t+i);
    ans=t[n-1]-t[0]+1;
    for(int i=0;i<n-1;i++)t[i]=t[i+1]-t[i]-1;
    sort(t,t+n-1);
    for(int i=n-2;i>n-1-k;i--)ans-=t[i];
    printf("%d\n",ans);
}



Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <bitset>
using namespace std;

const long int INF = 1000000007;

bool isInclude(vector<vector<char>> a, vector<vector<char>> b, int M, int x, int y)
{
    for (int i = 0; i < M; i++)
    {
        for (int j = 0; j < M; j++)
        {
            if (b[i][j] != a[y+i][x+j])
            {
                return false;
            }
            
        }
        
    }

    return true;
}

int main(void)
{
    int N, M;
    cin >> N >> M;
    vector<vector<char>> a(N, vector<char>(N)), b(M, vector<char>(M));
    for (int  i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cin >> a[i][j];
        }
        
    }

    for (int  i = 0; i < M; i++)
    {
        for (int j = 0; j < M; j++)
        {
            cin >> b[i][j];
        }
    }
    
    // 左上のマス
    for (int y = 0; y <= N-M; y++)
    {
        for (int x = 0; x <= N-M; x++)
        {
            // 含まれているか
            if (isInclude(a, b, M, x, y))
            {
                cout << "Yes" << endl;
                return 0;
            }
                        
        }
        
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main ()
{
    int n,m,sum = 0,a;
    cin >> n >>m;
    for (int i = 0 ; i<m;i++)
    {
        cin>>a;
        sum = sum +a;
    }
    if (sum >n)
        cout << "-1"<<endl;
    else{
    n = n - sum;
    cout << n<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;
public class Main{
public static void main(String[]args){
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
int b=scan.nextInt();
int c[][]=new int[a][b];
int d[]=new int[b];
int e[]=new int[a];
for(int i=0;i!=a;i++) {
	for(int j=0;j!=b;j++) {
		c[i][j]=scan.nextInt();
	}
}
for(int i=0;i!=b;i++) {
	d[i]=scan.nextInt();
}
int k=0;
for(int i=0;i!=a;i++) {
	k=0;
for(int j=0;j!=b;j++) {
	k+=c[i][j]*d[j];
}
e[i]=k;
}
for(int i=0;i!=a;i++){
	System.out.println(e[i]);
}
}
}



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

using namespace std;

#define ll long long 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SIZE 100005

int main()
{
	
	int t,coun = 1;
	string ch;
	cin >> t >> ch;
	for(int i=1; i < t; i++)
	{
		if(ch[i]!=ch[i-1]) coun++;
	}
	cout << coun << endl;
	return 0;
}


Measured memory_bytes: 512
<?php
list($n, $a, $b) = ints();
$x = ints();
$ans = 0;
for ($i = 1; $i < $n; ++$i) $ans += min(($x[$i] - $x[$i - 1]) * $a, $b);
echo $ans;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16884
#include <stdio.h>

int main(void)
{
	int x, n, a, b;
	
	for(x = 0; x < 3000; x++){
		scanf("%d%d", &a, &b);
		if((a == 0) && (b == 0)) break;
		if(a < b){
			printf("%d %d\n", a, b);
		} else{
			printf("%d %d\n", b, a);
		}
	}
	
	return(0);
}



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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int N;
    cin >> N;
    vector<lint> A(N, 0);
    rep(i, N) cin >> A[i];
    sort(all(A));
    vector<lint> L(N + 1, 0);
    rep(i, N) L[i + 1] = L[i] + A[i];
    vector<bool> canBeet(N, false);
    canBeet[N - 1] = true;
    rep(i, N - 1) {
        lint power = L[i + 1];
        canBeet[i] = (2 * power >= A[i + 1] ? true : false);
    }
    dump(A);
    dump(L);
    dump(canBeet);
    int ans = 1;
    for (int i = N - 2; 0 <= i; i--) {
        if (canBeet[i])
            ans++;
        else
            break;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n, W; cin >> n >> W;
  vll w(n), v(n); rep(i, n) cin >> w[i] >> v[i];
  vvll dp(n+10, vll(W+10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= W; j++) {
      if (j + w[i] <= W)
        dp[i+1][j + w[i]] = max(dp[i+1][j + w[i]], dp[i][j] + v[i]);
      dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
    }
  }
  cout << dp[n][W] << endl;
  return 0;
}

Measured memory_bytes: 87296
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>

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

int main() {
    int n;
    ll ans = 0;
    ll a[200000];
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        if (i != 0) {
            if (a[i - 1] > a[i]) {
                ans = ans +  a[i - 1] - a[i];
                a[i] = a[i - 1];
            }
        }
       
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4748
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e6+5;
const int MOD=1e9+7;

int n, sum=0;
int a[N], pref[N];
int fact[N], invfact[N];

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int modinv(int k)
{
	return pow(k, MOD-2, MOD);
}

void precompute()
{
	fact[0]=fact[1]=1;
	for(int i=2;i<N;i++)
	{
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
	}
	invfact[N-1]=modinv(fact[N-1]);
	for(int i=N-2;i>=0;i--)
	{
		invfact[i]=invfact[i+1]*(i+1);
		invfact[i]%=MOD;
	}
}

int nCr(int x, int y)
{
	if(y>x)
		return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=MOD;
	num*=invfact[x-y];
	num%=MOD;
	return num;
}

int32_t main()
{
	IOS;
	precompute();
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=a[i];
		pref[i]+=pref[i-1];
		pref[i]+=a[i];
		pref[i]%=MOD;
	}
	int ans=0;
	for(int x=0;x<=n-1;x++)
	{
		int num=fact[n];
		num*=modinv(x+1);
		num%=MOD;
		num*=(pref[n-x]);
		num%=MOD;
		ans+=num;
		ans%=MOD;
	}	
	reverse(a+1, a+n+1);
	for(int i=1;i<=n;i++)
	{
		sum+=a[i];
		pref[i]=pref[i-1]+a[i];
		pref[i]%=MOD;
	}
	for(int x=1;x<=n-1;x++)
	{
		int num=fact[n];
		num*=modinv(x+1);
		num%=MOD;
		num*=(pref[n-x]);
		num%=MOD;
		ans+=num;
		ans%=MOD;
	}	
	cout<<ans;
	return 0;
}

Measured memory_bytes: 20736
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll x[50] = {};
ll y[50] = {};
ll X[50] = {};
ll Y[50] = {};

int main() {
	ll n, k; cin >> n >> k;
	rep(i, 0, n) {
		cin >> x[i] >> y[i];
		X[i] = x[i];
		Y[i] = y[i];
	}

	sort(X, X + n);
	sort(Y, Y + n);

	ll minV = MAX_L;
	rep(x1, 0, n)rep(x2, x1 + 1, n) {
		if (X[x2] < X[x1]) {
			ll t = X[x2];
			X[x2] = X[x1];
			X[x1] = t;
		}
		rep(y1, 0, n)rep(y2, y1 + 1, n) {
			if (Y[y2] < Y[y1]) {
				ll t = Y[y2];
				Y[y2] = Y[y1];
				Y[y1] = t;
			}

			ll cnt = 0;
			rep(p, 0, n) {
				if (x[x1] == 1 && x[x2] == 8 && y[y1] == 1 && y[y2] == 4) {
					cout << endl;
				}
				if (X[x1] <= x[p] && x[p] <= X[x2] && Y[y1] <= y[p] && y[p] <= Y[y2]) {
					cnt++;
				}
			}
			if (cnt >= k) {
				minV = min(abs((X[x2] - X[x1])*(Y[y1] - Y[y2])), minV);
			}
		}
	}
	cout << minV << endl;

	return 0;
}

Measured memory_bytes: 256
// D - Simple Knapsack

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

ll w[101];
ll v[101];
map<ll, ll> dp[101]; // dp[i] map(tw, tv): i個目までの物で重さの合計がtwの時の価値の総和の最大値tv

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

	for (int i=1; i<=N; i++) {
		cin >> w[i] >> v[i];
	}

	dp[0][0] = 0;

	for (int i=0; i<N; i++) {
		//cout << "i=" << i << endl; // **** debug ****
		for (auto& itr : dp[i]) {
			ll tw = itr.first;
			ll tv = itr.second;
			//cout << "tw=" << tw << " tv=" << tv << endl; // **** debug ****

			// i個目を使わない遷移
			dp[i+1][tw] = max(dp[i+1][tw], dp[i][tw]);

			// i個目を使う遷移
			if (tw + w[i+1] <= W) {
				dp[i+1][tw + w[i+1]] = max(dp[i+1][tw + w[i+1]], dp[i][tw] + v[i+1]);
			}
		}
	}

	ll ans = 0;
	for (auto& itr : dp[N]) {
		ans = max(ans, itr.second);
	}

	cout << ans << endl;

	return 0;
}

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

void solve() {
    int n;
    cin >> n;
    map<string, int> a;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        a[s]++;
    }
    int mx = 0;
    for (auto it : a) {
        mx = max(mx, it.second);
    }
    vector<string> b;
    for (auto it : a) {
        if (it.second == mx) {
            b.push_back(it.first);
        }
    }
    sort(b.begin(), b.end());
    for (auto it : b) {
        cout << it << "\n";
    }
    cout << "\n";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 25584
#include<iostream>

using namespace std;

int main(){
    int A,B;
    cin>>A>>B;
    if(A==B)
    {
        cout<<"Draw"<<endl;
    }

    else if(A==1||B==1)
    {
    if(A==1){
        cout<<"Alice"<<endl;
    }
    else if(B==1){
        cout<<"Bob"<<endl;
     }
    }

     else
        {
     if(A>B){
        cout<<"Alice"<<endl;
    }
     else if(B>A){
        cout<<"Bob"<<endl;
     }
     }

  return 0;
}


Measured memory_bytes: 256
using System;

public class AtCoder
{
    public static void Main()
    {
        int n;
        n = int.Parse(Console.ReadLine().Trim());
        string[] s;
        s = Console.ReadLine().Trim().Split(' ');
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = int.Parse(s[i]);
        }
        Array.Sort(a);
        int[] b = new int[n];
        int x = 1;
        int ans = 0;
        bool fsuc = true;
        int y = (int)Math.Pow(2, 30);
        BinarySearch f = new BinarySearch(a);
        for(int i = n - 1; i > -1; i--)
        {
            if (b[i] == 1) continue;
            while (y/2 > a[i])
            {
                y /= 2;
            }           
            x = y - a[i];
            for(int j = f.UpperBound(x,i)-1; j > -1; j--)
            {                
                if (a[j] == x)
                {
                    if(b[j] == 0)
                    {
                        if (i != j)
                        {
                            b[i] = 1;
                            b[j] = 1;
                            ans++;
                            while (fsuc)
                            {
                                if (i > 0 && j > 0)
                                {
                                    if ((a[i - 1] == a[i]) && (a[j - 1] == x)
                                        &&(b[i-1] == 0) && (b[j-1] == 0))
                                    {                                        
                                        i--;
                                        j--;
                                        b[i] = 1;
                                        b[j] = 1;
                                        ans++;
                                    }
                                    else fsuc = false;
                                }
                                else fsuc = false;
                            }
                            fsuc = true;
                            break;
                        }                       
                    }
                }
                if (a[j] < x) j = -1;
            }           
        }
        Console.WriteLine(ans);
    }
}

public class BinarySearch
{

    int[] a;
    public BinarySearch(int[] arr)
    {
        a = arr;
    }

    public int LowerBound(int x, int i)
    {
        int l = -1;
        int r = i;
        while (r - l > 1)
        {
            int m = l + (r - l) / 2;
            if (a[m] >= x) r = m;
            else l = m;
        }
        return r;
    }

    public int UpperBound(int x, int i)
    {
        int l = -1;
        int r = i;
        while (r - l > 1)
        {
            int m = l + (r - l) / 2;
            if (a[m] > x) r = m;
            else l = m;
        }
        return r;
    }
}


Measured memory_bytes: 28256
//43
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

int w,h;
int n;

int cmp(int *a,int *b,int l){
  int *p[2]={a,b};
  vector<int> v;
  for(int j=0;j<2;j++){
    for(int i=0;i<n;i++){
      for(int d=-1;d<=1;d++){
	int cp=p[j][i]+d;
	if(0<=cp&&cp<l){
	  v.push_back(cp);
	}
      }
    }
  }
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      p[i][j]=find(v.begin(),v.end(),p[i][j])-v.begin();
    }
  }
  return v.size();
}

int main(){
  while(cin>>w>>h,w|h){
    cin>>n;
    int l[1000],r[1000],t[1000],b[1000];
    for(int i=0;i<n;i++){
      cin>>l[i]>>t[i]>>r[i]>>b[i];
    }
    int ch,cw;
    cw=cmp(l,r,w);
    ch=cmp(t,b,h);
    static bool g[6000][6000];
    fill(g[0],g[6000],false);
    for(int i=0;i<n;i++){
      for(int j=t[i];j<b[i];j++){
	for(int k=l[i];k<r[i];k++){
	  g[j][k]=true;
	}
      }
    }
    int c=0;
    for(int i=0;i<ch;i++){
      for(int j=0;j<cw;j++){
	if(!g[i][j]){
	  c++;
	  typedef pair<int,int> pii;
	  queue<pii> que;
	  que.push(pii(i,j));
	  while(!que.empty()){
	    int y=que.front().first;
	    int x=que.front().second;
	    que.pop();
	    if(x<0||cw<=x||y<0||ch<=y||g[y][x])continue;
	    g[y][x]=true;
	    for(int i=0;i<4;i++){
	      int d[]={0,1,0,-1,0};
	      que.push(pii(y+d[i],x+d[i+1]));
	    }
	  }
	}
      }
    }
    cout<<c<<endl;
  }
  return 0;
}

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

int main() {
  int n,m,c;
  cin >>n >>m >>c;
  
  vector<int>b(m);
  for(int i=0; i<m;i++){
    cin >>b[i];
  }
  
  vector<vector<int>>vec(n,vector<int>(m,0));
  
  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      cin >>vec.at(i).at(j);
    }
  }
  
  int count=0,sum=0;
  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      sum+=vec.at(i).at(j)*b.at(j);
    }
    if(sum+c >0){
      count++;
    }
  sum = 0;
  }
  cout <<count <<endl;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

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

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    ll a,b,x;
    cin >>a>>b>>x;

    ll bx = b/x;
    ll ax;
    if(a==0)ax=-1;
    else ax = (a-1LL)/x;

    //cout <<fixed<<setprecision(16)<< << endl;
    cout<<bx-ax<<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

int main()
{
  int N,L;scanf("%d %d",&N,&L);
  string S[N];
  for(int i=0;i<N;i++)cin>>S[i];
  sort(S,S+N);
  string ans;
  for(int i=0;i<N;i++)ans+=S[i];
  cout<<ans;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define reps(i, s, n) for(int i = (s); i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, s, n) for(int i = (n) - 1; i >= (s); i--)
#define INF ~(1 << 31)
#define INFL ~(1LL << 63)

int main()
{
    int N, M;
    cin >> N >> M;
    dsu d(N);
    rep(i, M){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        d.merge(a, b);
    }

    int ans = -1;
    vector<bool> f(N);
    rep(i, N){
        int leader = d.leader(i);
        if(!f[leader]){
            ans++;
            f[leader] = true;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define rep(i , x , y) for(register int i = (x) , _## i = ((y) + 1) ; i < _## i ; i ++)
#define Rep(i , x , y) for(register int i = (x) , _## i = ((y) - 1) ; i > _## i ; i --)
using namespace std ;
#define int long long
using ll = long long ;
using pii = pair < int , int > ;
const static int _ = 1 << 20 ;
char fin[_] , * p1 = fin , * p2 = fin ;
inline char gc() { return (p1 == p2) && (p2 = (p1 = fin) + fread(fin , 1 , _ , stdin) , p1 == p2) ? EOF : * p1 ++ ; }
inline int read() {
	bool sign = 1 ; char c = 0 ; while(c < 48) ((c = gc()) == 45) && (sign = 0) ;
	int x = (c & 15) ; while((c = gc()) > 47) x = (x << 1) + (x << 3) + (c & 15) ;
	return sign ? x : -x ;
}
template < class T > void print(T x , char c = '\n') {
	(x == 0) && (putchar(48)) , (x < 0) && (putchar(45) , x = -x) ;
	static char _st[100] ; int _stp = 0 ;
	while(x) _st[++ _stp] = x % 10 ^ 48 , x /= 10 ;
	while(_stp) putchar(_st[_stp --]) ; putchar(c) ;
}
template < class T > void cmax(T & x , T y) { (x < y) && (x = y) ; }
template < class T > void cmin(T & x , T y) { (x > y) && (x = y) ; }
signed main() {
#ifdef _WIN64
	freopen("testdata.in" , "r" , stdin) ;
#endif
	print(read() ^ read()) ;
	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 P = pair<int, int>;
typedef long long ll;

int main() {
  ll n, k;
  cin >> n >> k;
  if(k == 0){
    cout << n * n << endl;
    return 0;
  }
  ll ans = n * n;
  for (int b = 1; b <= n; b++){
    if(b <= k){
      ans -= n;
    }else {
      int a = n / b;
      ans -= k * a;
      ans -= min(n % b, k - 1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#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 yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {


	int n;
	int yn=1;
	int t=0;
	string s1[101];
	cin>>n;


	cin>>s1[0];


	rep(i,n-1){
		cin>>s1[i+1];

		t=s1[i].size()-1;
		if(s1[i][t]!=s1[i+1][0]){
			yn=0;

		}
		rep(j,i+1){
			if(s1[i+1]==s1[j]){
				yn=0;
			}
		}
	}



	if(yn==1){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}




	return 0;
}


Measured memory_bytes: 256
q = int(input())
A = []
for _ in range(q):
    tmp = [int(i) for i in input().split()]
    if tmp[0] == 0:
        A.append(tmp[1])
    if tmp[0] == 1:
        print(A[tmp[1]])
    if tmp[0] == 2:
        A.pop()


Measured memory_bytes: 13360
import static java.util.Arrays.deepToString;

import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int n = sc.nextInt();
			if (n == 0) break;
			Set<Integer> S = new HashSet<Integer>();
			for (int i = 1; i < n; i++) {
				int x = (i * i) % n;
				S.add(x);
			}
			int H = (n-1)/2;
			Integer[] L = S.toArray(new Integer[0]);
			int[] count = new int[H + 1];
			for (int a : L) {
				for (int b : L) {
					if (a != b) {
						int d = a - b;
						if (d < 0) d += n;
						if (d > H) d = n - d;
						count[d]++;
					}
				}
			}
			for (int i = 1; i <= H; i++) System.out.println(count[i]);
		}
	}
}

Measured memory_bytes: 26928
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[10005],b[10005],mod=1e9+7,sum=1,ans=0;;
vector<ll> p[10005];
map<ll,ll> m;
ll qpow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1) res=res*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return res%mod;
}
int main(){
	ll n;cin>>n;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
		ll x=a[i];
		for(ll j=2;j*j<=x;j++){
			if(x%j==0){
				p[i].push_back(j);
				while(x%j==0) x/=j;
			}
		}
		if(x>1) p[i].push_back(x);
	}
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<p[i].size();j++){
			ll t=0,x=a[i];
			while(x%p[i][j]==0) t++,x/=p[i][j];
			m[p[i][j]]=max(m[p[i][j]],t);
		}
	}
	for(auto x:m){
		sum=(sum%mod*qpow(x.first,x.second)%mod)%mod;
	}
	for(ll i=1;i<=n;i++){
		b[i]=(sum%mod*qpow(a[i],mod-2)%mod)%mod;
	}
	for(ll i=1;i<=n;i++){
		ans=(ans%mod+b[i]%mod)%mod;
	}
	cout<<ans<<endl;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;

int main()
{
   string s,ans;
   ans= "CODEFESTIVAL2016";
   cin >>s;ll a=0;
   rep(i,s.size()){
    if(s[i]!=ans[i])a++;
   }
   cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int arr[30];
void dfs(int m,int n,int atnum){
    bool flag=false;

    for(int i=n;i>0;i--){
        if(i>m)continue;

        arr[atnum]=i;
        dfs(i,n-i,atnum+1);
        arr[atnum]=-1;
        flag=true;
    }
    if(!flag){
        cout<<arr[0];
        for(int i=1;i<30;i++){
            if(arr[i]==-1)break;
            cout<<" "<<arr[i];
        }
        cout<<endl;
    }
}
int main(){
    while(true){
        int n;
        cin>>n;
        if(n==0)break;
        for(int i=0;i<30;i++)arr[i]=-1;

        dfs(n,n,0);
    }
    return 0;
}

Measured memory_bytes: 1160
s = input()
t = input()
s0 = {}
t0 = {}
for i in range(len(s)):
    s0.setdefault(s[i], [])
    s0[s[i]].append(i)
for i in range(len(t)):
    t0.setdefault(t[i], [])
    t0[t[i]].append(i)
s0 = list(s0.values())
t0 = list(t0.values())
s0.sort()
t0.sort()
if s0 == t0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 20656