akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

const int inf = 1e9;

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

	vector<int> a(n, 0), b(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}

	vector<int> dp(h + 1, inf);
	dp[0] = 0;

	for (int i = 0; i < h; i++) {
		if (dp[i] == inf) {
			continue;
		}

		for (int j = 0; j < n; j++) {
			int to = min(h, i + a[j]);
			int val = dp[i] + b[j];

			dp[to] = min(dp[to], val);
		}
	}

	cout << dp[h] << endl;
	return 0;
}


Measured memory_bytes: 256
<?php
$inp = intval( trim( fgets( STDIN ) ) );
$i = 0;
$sum = 0;

while($inp >= $i) {
  if ($i % 5 === 0 && $i % 3 === 0) {
  } elseif ($i % 5 === 0) {
  } elseif ($i % 3 === 0) {
  } else {
    $sum += $i;
  }
  $i++;
}

echo $sum;
?>

Measured memory_bytes: 16108
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const ll INFS=1e18;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
 
int main() {
  int h,w;
  cin>>h>>w;
  vector<vector<char>> c(h,vector<char>(w));
  rep(i,h)rep(j,w) cin>>c[i][j];
  rep(i,h){
    rep(j,w){
      if(c[i][j]=='#'){
        bool ja=true;
        rep(k,4){
          if(i+di[k]<0||i+di[k]>=h||j+dj[k]<0||j+dj[k]>=w) continue;
          if(c[i+di[k]][j+dj[k]]=='#') ja=false;
        }
        if(ja){
          cout<<"No"<<endl;
          return 0;
        }
      }
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 3616
/**********************************************

1.red and black
2.炭田高輝
3.sumita.takaki@gmail.com

last updated: 2013-10-15@20:19

 **********************************************/
#include<iostream>
#include<algorithm>
#include<sstream>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;


void rec(int y, int x);
int dy[4] = {-1, 0, 1, 0};
int dx[4] = {0, 1, 0, -1};
bool visit[21][21];
string tiles[21];
int h=0, w=0;



int main(void){
        


        while(cin >> w >> h, h){
                
                
                for(int i=0; i<h; i++){

                        cin >> tiles[i];
                        
                        for(int j=0; j<w; j++)visit[i][j] = false;
                }


                for(int i=0; i<h; i++){

                        for(int j=0; j<w; j++){
                                
                                if(tiles[i][j] == '@')rec(i,j);

                        }
                }
                                
                int ans = 0;

                for(int i=0; i<h; i++){

                        for(int j=0; j<w; j++){
                                if(visit[i][j])ans++;
                        }

                }

                cout << ans << endl;

        }



}

void rec(int y, int x){

        
        if(visit[y][x])return;
        visit[y][x] = true;

        for(int i=0; i<4; i++){
                int ny = y + dy[i], nx = x + dx[i];

                if(ny<0 || nx<0 || ny>=h || nx>=w)continue;
                if(tiles[ny][nx] == '#')continue;
                rec(ny,nx);
        }



}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

string s;
string res;
map<string, int> word;
pair<string, int> mx;

int main()
{
  while(cin >> s){
    if(++word[s] > mx.second) mx.first = s, mx.second = word[s];
    if(s.size() > res.size()) res = s;
  }

  cout << mx.first << " " << res << endl;

  return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i = 0; i < c; i++)
const int inf = 1000000000;

int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  int l = x[0], r = x[0];
  rep(i, n){
    l = min(l, x[i]);
    r = max(r, x[i]);
  }
  int ans = inf;
  for(int i = l; i <= r; i++){
    int cost = 0;
    rep(j, n) cost += (x[j] - i) * (x[j] - i);
    ans = min(ans, cost);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 1; i < (n); ++i)



int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  ll ans = 0;
  
  for(ll i=0; i< N; i++){
    cin >> A[i];
  }
  
  rep(i, N){
    ll diff = A[i-1] - A[i];
    if (diff > 0) {
      ans += diff;
      A[i] = A[i-1];
    }

  }
  
  
  cout << ans << endl;

  return 0;
}


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

public class Main{
    public static void main(String[] args){
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    
    try{
        String str = br.readLine();
        StringTokenizer st = new StringTokenizer(str, " ");
        
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        int c = Integer.parseInt(st.nextToken());
        
        if (a<b){
            
            if(b<c){
            System.out.println("Yes");
            }
            
            else{
            System.out.println("No");
            }
        }
        
        else{
            System.out.println("No");
        }
        
        
        
        
        
    }catch(IOException e){}
    

    }
}

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

const int N = 1111111;

char s[N];

main(void) {
	scanf("%s" , s + 1);
	int len = strlen(s + 1);
	int now = 1;
	for(int i = 2;i <= len;++ i) if(s[i] != '9') now = 0;
	if(now) {
		cout << s[1] - '0' + (len - 1) * 9;
	}
	else cout << s[1] - '1' + (len - 1) * 9;
}

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

int main(){
    int n,m,c,t[100],s[100]={0};
    cin>>n>>m;
    for(int i=0;i<m;i++)cin>>t[i];
    for(int i=0;i<m;i++)
        for(int j=0;j<n;j++){
            cin>>c;
            if(c==t[i])s[j]++;
            else s[t[i]-1]++;
        }
    for(int i=0;i<n;i++)
        cout<<s[i]<<endl;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  vector<int> sum(1000);
  sum.at(0)=0;
  for(int i=1;i<=999;i++){
    sum.at(i)=sum.at(i-1)+i;
  }
  int diff=b-a;
  cout << sum.at(diff)-b << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main() {
	int a[200];
	int n, s = 0, kais = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	while (1) {
		for (int i = 0; i < n; i++) {
			s = i + 1;
			if (a[i] % 2 != 0)
				break;
		}
		if (s == n) {
			kais++;
			for (int i = 0; i < n; i++)
				a[i] = a[i] / 2;
		}
		else
			break;
	}


	cout<< kais <<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define P 1000000007
#define M 200005
int n,i,c[M],si;
long long dp[M],a[M];
int main() {
	scanf("%d",&n);
	for(i=1; i<=n; i++)scanf("%d",&c[i]);
	for(i=1; i<=n; i++)if(c[i]!=c[i-1])c[++si]=c[i];
	for(dp[0]=i=1; i<=si; i++)a[c[i]]=(dp[i-1]+a[c[i]])%P,dp[i]=a[c[i]];
	printf("%lld\n",dp[si]);
	return 0;
}

Measured memory_bytes: 4096
l = input()
ccount = 0
for i in range(len(l)):
    if i==0 and l[i]!="A":
        print("WA")
        break
    elif i>=2 and i<=len(l)-2:
        if ccount==0 and l[i]=="C":
            ccount = ccount + 1
        elif not(ord(l[i])>=ord("a") and ord(l[i])<=ord("z")):
            print("WA")
            break
        if ccount>=2:
            print("WA")
            break
    elif (i==1 or i==len(l)-1) and not(ord(l[i])>=ord("a") and ord(l[i])<=ord("z")):
            print("WA")
            break
        
    if i==len(l)-1 and ccount==1:
        print("AC")
    elif i==len(l)-1 and ccount!=1:
        print("WA")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc()) 
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 300010;
int n, l, x[N], t[N], tp[N], val[N], num[N];
ll ans;
int v1[N], v2[N];
int main() {
  read(n), read(l);
  ++ n;
  rep (i, 2, n) read(x[i]);
  rep (i, 2, n) read(t[i]);
  rep (i, 2, n) {
    ans += (t[i] / (2 * l)) * 2;
    t[i] %= 2 * l;
  }
  rep (i, 2, n) {
    int va, vb;
    if (t[i] == 0) va = 0, vb = 0, tp[i] = 0;
    else {
      va = (t[i] <= 2 * (l - x[i]));
      vb = (t[i] <= 2 * x[i]);
      if (va == 0 && vb == 0) {
  	tp[i] = 0, ans += 2;
      } else if (va == 0 && vb == 1) {
  	tp[i] = 1, ans ++;
      } else if (va == 1 && vb == 0) {
  	tp[i] = -1, ans ++;
      } else {
  	tp[i] = 2, ans ++;
      }
    }
  }
  tp[1] = 1;
  // read(n);
  // rep (i, 1, n) read(tp[i]);
  v1[0] = n;
  rep (i, 1, n) {
    val[i] = val[i-1];
    num[i] = num[i-1];
    if (tp[i] == 2) num[i] ++;
    else val[i] += tp[i];
    v1[i] = min(v1[i-1], num[i] + val[i] - (i != n));
  }
  v2[n+1] = n;
  rrp (i, n, 1) {
    int tmp = tp[i] == 2 ? -1 : tp[i];
    v2[i] = min(v2[i+1] + tmp, tmp - (i != n));
  }
  int mn = 10 * n;
  rep (i, 0, n) {
    int n1 = - min(v1[i], v2[i+1] + val[i] + num[i]);
    n1 = max(n1, 0);
    int n2 = n1 + val[n] + num[i] - (num[n] - num[i]);
    mn = min(mn, n1 + n2);
  }
  // cerr << mn << endl;
  ans += mn;
  ++ ans;
  ans = ans * l;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
stack <char> s;
int main(){
	ll n;
	cin >> n;
	
	ll sum = 0, fac = 26;
	int len = 1;
	while (sum + fac < n)
	{
		sum += fac;
		fac *= 26;
		len++;
	} 
	n -= sum + 1;
	for (int i = 1; i <= len; i++)
	{
		int now = n % 26;
		n /= 26;
		if (now == 0) s.push('a');
		else s.push(char(now + 'a'));
	} 
	
	while (!s.empty()) {
		putchar(s.top());
		s.pop();
	}
	puts("");
  return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<vector<int>> a(k, vector<int>(n, 0));
    vector<int> d(k);
    rep(i, k) {
        cin >> d[i];
        rep(j, d[i]) cin >> a[i][j];
    }

    vector<bool> s(n, false);
    rep(i, k) {
        rep(j, d[i]) {
            s[a[i][j] - 1] = true;
        }
    }

    int ans = 0;
    rep(i, n) {
        if (s[i] == false) ++ans;
    }

    cout << ans << endl;

    return 0;
}


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

const int mod = 1e9 + 7;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<vector<int>> dp(n + 1, vector<int>(n));
    dp[1][0] = 1;
    for (int i = 1; i < n; i++) {
        vector<int> sum(n + 1);
        for (int j = 0; j < n; j++) {
            sum[j + 1] = sum[j] + dp[i][j];
            sum[j + 1] %= mod;
        }
        for (int j = 0; j < i + 1; j++) {
            if (s[i - 1] == '<') {
                dp[i + 1][j] = sum[j];
            } else {
                dp[i + 1][j] = (sum[n] - sum[j] + mod) % mod;
            }
        }
    }
    int ans = 0;
    for (int j = 0; j < n; j++) {
        ans += dp[n][j];
        ans %= mod;
    }
    cout << ans << endl;
}


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

map<int,int> mp;

signed main(){

  int n; cin >> n;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    mp[a]++;
  }

  int ans = 0;
  for(auto p = mp.begin(); p != mp.end(); p++){
    if(p->first == p->second) continue;
    if(p->first < p->second){
      ans += p->second - p->first;
    }
    else {
      ans += p->second;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	int q[]={0,6000,4000,3000,2000};
	int a,b;
	while(cin>>a>>b)cout<<q[a]*b<<endl;
	
	
}

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();

        int a = 4;
        int b = 7;

        boolean isOk = false;
        for (int i = 0; i <= 100 / a; i++) {
            for (int j = 0; j <= 100 / b; j++) {
                if (i * a + j * 7 == n) {
                    isOk = true;
                    break;
                }
            }
        }

        if (isOk) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}


Measured memory_bytes: 21844
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> ipair;
typedef tuple<int, int, int> ituple;

// const int INF = INT_MAX;
// const ll INF = LLONG_MAX;
// const int MOD = ((int)1e9 + 7);
// const ld EPS = (1e-10);
#define PI acosl(-1)
#define MAX_N (100000 + 2)

void exec(){
  int h, w,n;
  cin >> n >> h >> w;

  cout << (n - h + 1) * (n - w + 1)  << endl;
}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();
	string s;
	cin >> s;
	for(auto to : s) 
	{
		if(to == 'B') cout << 'R'; 
		else if(to == 'R') cout << 'B';
		else cout << to;
	}
}      

Measured memory_bytes: 3640
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int H = Integer.parseInt(S[0]);
    int W = Integer.parseInt(S[1]);
    
    String ans = "snuke";
    for(int i = 0; i < H; i++){
      String[] T = sc.nextLine().split(" ");
      for(int j = 0; j < W; j++){
        if(T[j].equals(ans)){
          String s1 = String.valueOf((char)(j + 'A'));
          String s2 = (i+1) + "";
          System.out.println(s1 + s2);
          return;
        }
      }
    }
  }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}


int main()
{
  int n, k, q ;
  cin >> n >> k >> q ;
  
  vector<int> vec(n,k) ;
  
  REP(i,q){
    int a ;
    cin >> a ;
    vec.at(a-1)++ ;
  }
  
  REP(i,n){
    if(vec.at(i)>q){
      cout <<"Yes"<<endl ;
    }
    else{
      cout <<"No"<<endl ;
    }
  }


  return 0 ;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		for (int i = 0; i < n; i++) {
		    if ((i + n % 2) / 2 * 2 + (n + 1) % 2 != arr[i]) {
		        System.out.println(0);
		        return;
		    }
		}
		long ans = 1;
		for (int i = 0; i < n / 2; i++) {
		    ans *= 2;
		    ans %= MOD;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 49004
<?php
// Your code here!
$input = explode(' ',trim(fgets(STDIN)));
$n = $input[0];
$m = $input[1];
$k = [];
$a = [];
for ($i = 0; $i < $n; $i++) {
    $input2 = explode(' ',trim(fgets(STDIN)));
    $k[$i] = $input2[0];
    for ($j = 0; $j < (count($input2) - 1); $j++) {
        $a[$i][$j] = $input2[$j + 1];
    }
}

if ($n == 1) {
    $duplicate = $a[0];
} else {
    $duplicate = call_user_func_array('array_intersect', $a);
}

print(count($duplicate));
?>


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

using namespace std;

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

  int mi = n;
  for(int i = 1; i < n; i++) {
    int a = i;
    int b = n-i;
    int sum = 0;
    while(a > 0) {
      sum += a % 10;
      a /= 10;
    }
    while(b > 0) {
      sum += b % 10;
      b /= 10;
    }
    mi = min(mi, sum);
  }
  cout << mi << endl;
}


Measured memory_bytes: 3640
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    	Scanner scan=new Scanner(System.in);
    	String str=scan.next();
    	if(str.length()>=4) {
    		if(str.substring(0,4).equals("YAKI")) {
    			System.out.println("Yes");
    			return;
    		}
    	}
    	System.out.println("No");
    }
}

Measured memory_bytes: 23124
#include <stdio.h>

int selectionSort(int A[], int N){
    int i,j,t,sw=0,minj;
    for(i=0;i<N-1;i++){
        minj=i;
        for(j=i;j<N;j++){
            if(A[j]<A[minj])minj=j;
        }
        t=A[i];A[i]=A[minj];A[minj]=t;
        if(i!=minj)sw++;
    }
    return sw;
}

int main(void){
    int A[100],N,i,sw;
    
    scanf("%d",&N);
    for(i=0;i<N;i++)scanf("%d",&A[i]);
    
    sw = selectionSort(A,N);
    
    for(i=0;i<N;i++){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",sw);
    
    return 0;
}



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

int main(){
  int N;
  cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  int ans=0;
  for(int i=1;i<N;i++)if(v[i-1]==v[i]){v[i]=0;ans++;}
  cout<<ans<<endl;
}


Measured memory_bytes: 256
N = gets.chomp.to_i
S = Hash.new(0)
N.times do
  s = gets.chomp
  S[s] += 1
end

ans = nil
S.sort_by{|k,v| [-v, k]}.each do |k,v|
  ans = v if ans.nil?
  break if v < ans
  puts k
end


Measured memory_bytes: 49096
<?php

while (($line = trim(fgets(STDIN))) !== '') {
    $arr = explode(',', $line);
    $v2 = array_pop($arr);
    $v1 = array_pop($arr);
    $sp = $v1 + $v2;
    $distance = array_sum($arr);
    $n = $v1 * $distance / $sp;
    $sum = 0;

    for ($i = 0; $i < 10; $i++) {
        $sum += $arr[$i];
        if ($sum >= $n) {
            echo $i + 1, PHP_EOL;
            break;
        }
    }
}

Measured memory_bytes: 6608
N = int(input())
a = []
for i in range(5):
    a.append(int(input()))

num_ride = min(a)
num_arrive = 5-a.index(num_ride)
if num_ride < N:
    if 10 * N/num_ride % 10 == 0:
        
        print(5+int(N/num_ride)-1)
    else:
       print(5+int(N/num_ride))

else:
     print(5)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const int INF = 2e9;
string S;

bool check(int left, int right) {
  for (int i=left; i<=right; i++) {
    if (S[i]!=S[right-i]) {
      return false;
    }
  }
  return true;
}

string calc(int N) {
  if (!check(0, N-1)) return "No";
  if (!check(0, (N-1)/2-1)) return "No";
  if (!check((N+1)/2, N-1)) return "No";
  return "Yes";
}

int main() {
  INCANT;
  cin >> S;
  int N = S.size();
  cout << calc(N) << "\n";
  return 0;
}

Measured memory_bytes: 256
/*
 * Swapping Two Numbers.c
 *
 *  Created on: 2015/02/13
 */

int main(void){
	int x,y;

	while(1){
		scanf("%d %d",&x,&y);
		if(x==0 && y==0) break;

		if(x > y){
			printf("%d %d\n",y,x);
		}
		else{
			printf("%d %d\n",x,y);
		}

	}

	return 0;


}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N, K;
int A[110];
bool dp[100010];

int main(){

    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int k = 0; k <= K; k++){
        bool res = false;
        if(k != 0){
            for(int i = 0; i < N; i++)
                if(k - A[i] >= 0) res |= (!dp[k-A[i]]);
        }
        dp[k] = res;
    }

    if(dp[K]){
        cout << "First" << endl;
    }
    else{
        cout << "Second" << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  cpp_int h, w; cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1 << CRLF;
    return;
  }

  cpp_int ans{};
  ans += (h / 2) * (w / 2); // 偶数
  ans += ((h+1) / 2) * ((w+1) / 2); // 奇数
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const ll MOD=1e9+7;

int main(){
    int a, b; cin >> a >> b;
    string s, t;
    for(int i=0; i<b; i++){
        s+=a+'0';
    }
    for(int i=0; i<a; i++){
        t+=b+'0';
    }
    cout << (s<t ? s:t) << endl;
    return 0;
}

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

#define FasterIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main(){
    FasterIO;

    int n, m;

    while(cin>>n>>m){
        int data[m];

        for(int i=0; i<m; i++)
            cin>>data[i];

        sort(data, data+m);

        vector<int>v;

        long long ans = 0;

        for(int i=1; i<m; i++){
            v.push_back(data[i]-data[i-1]);
            ans+=1LL*(data[i]-data[i-1]);
        }

        sort(v.begin(), v.end(), greater<int>());

        for(int i=0; i<n-1 && i<m-1; i++){
            ans-=1LL*v[i];
        }

        cout<<max(0LL, ans)<<endl;
    }

    return 0;
}


Measured memory_bytes: 1276
using System;

class MyClass
{
    static void Main(string[] args)
    {
        string str = Console.ReadLine();
        foreach (var c in str)
        {
            Console.Write(Char.ConvertFromUtf32((c == 'A' || c == 'B' || c == 'C') ? c + 23 : c - 3));
        }
        Console.WriteLine();
    }
}


Measured memory_bytes: 5292
N = int(input())
As = []
Bs = []
for _ in range(N):
  A, B = map(int, input().split())
  As.append(A)
  Bs.append(B)

As.sort()
Bs.sort()

if N % 2 == 1:
  i = (N+1) // 2
  print(Bs[i-1] - As[i-1] + 1)
else:
  lower = N // 2
  upper = lower + 1
  
  lower_sum = As[lower-1] + As[upper-1]
  upper_sum = Bs[lower-1] + Bs[upper-1]
  
  print(upper_sum - lower_sum + 1)


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

int main() {
  string s;
  cin >> s;
  int ans = 0, now = 0;
  for(int i=0; i<s.size(); i++) {
    if(s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'G' || s.at(i) == 'T') {
      now++;
    } else {
      now = 0;
    }
    ans = max(ans, now);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define INF 1e15
#define MOD 1000000007
int n;
string s;
signed main() {
	cin >> n >> s;
	int a=0, b=0;
	rep(i, s.size()) {
		if (s[i] == 'R')a++;
		else b++;
	}
	if (a > b)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <sstream>
using namespace std;

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define FOR(i, l, r) for (int (i) = (l); (i) < (r); ++(i))
#define REP(i, n) FOR((i), 0, (n))

long long cnt[100];
int n;
string s;

int main() {
	cin >> n;
	cout << n / 3 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int A,B;
	cin>>A>>B;
	int ans=0;
	for (int i=1;i<=2;i++){
		if (A>=B){
			ans+=A;
			A--;
		}else{
			ans+=B;
			B--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pi 3.1415926535
#define endl '\n'
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll inf=1e19;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
void bfs(ll arr[],ll node,ll n,vector<ll>v[])
{
    queue<ll>q;
    ll vis[n+1]={0},dis[n+1]={0},a;
    q.push(node);
    dis[node]={0};
    vis[node]=1;
    while(!q.empty())
    {
        a=q.front();
        q.pop();
        if(a>node)
        arr[dis[a]]++;
        for(auto u:v[a])
        {
            if(!vis[u])
            {
                vis[u]=1;
                dis[u]=1+dis[a];
                q.push(u);
            }
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   ll n,x,y,i,a,b,c;
   cin>>n>>x>>y;
   vector<ll>v[n+1];
   v[x].pb(y);
   v[y].pb(x);
   for(i=1;i<=n-1;i++)
    v[i].pb(i+1),v[i+1].pb(i);
   ll arr[n+1]={0};
   for(i=1;i<=n;i++)
    bfs(arr,i,n,v);
   for(i=1;i<=n-1;i++)
    cout<<arr[i]<<endl;
}


Measured memory_bytes: 384
from collections import deque

H, W = map(int,input().split())
coords = []
blacks = deque([])
for i in range(H):
    rows = list(input())
    coords.append(rows)
    for j,row in enumerate(rows):
        if row == "#":
            blacks.append((i,j,0))

ans = 0
while len(blacks) > 0: 
    h,w,dist = blacks.popleft()
    ans = max(dist,ans)
    for di, dj in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
        ni = h + di
        nj = w + dj
        if 0 <= ni < H and 0 <= nj < W:
            if coords[ni][nj] == ".":
                blacks.append((ni,nj,dist+1))
                coords[ni][nj] = "#"

print(ans)

Measured memory_bytes: 153308
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pil pair<int,ll>
#define pii pair<int,int>
#define ull unsigned long long
#define base 1000000000000000000
#define fio ios::sync_with_stdio(false);cin.tie(0)

using namespace std;

const double g=10.0,eps=1e-12;
const int N=100000+10,maxn=100000+10,inf=0x3f3f3f3f,INF=0x3f3f3f3f3f3f3f3f;


int main()
{
    ll n,k,ans=0;
    scanf("%lld%lld",&n,&k);
    if(k==0)
    {
        printf("%lld\n",n*n);
        return 0;
    }
    for(int i=k;i<=n;i++)
    {
        ans+=n-i;
        for(int j=i;j<=n;j+=i)
        {
            if(j+i<=n)ans+=i-k;
            else ans+=max(n-j-k+1,0ll);
        }
    }
    printf("%lld\n",ans);
    return 0;
}
/********************

********************/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define ff first
#define ss second
#define nl '\n'
//////////////////////////////////////////////////

const int N = 100100, M = N + N;
const ll INF = (ll) 1e17, mod = 7+(ll)1e9;

int n, m, s, t;
ll dist[N], dps[N], dpt[N];
vector< pair<ll, ll> > g[N];
vector< int > dag[N], dagt[N];
int eu[M], ev[M]; ll ew[M];
priority_queue< pair<ll, ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>> > pq;

void dijkstra(int src) {
  fill(dist, dist+n+1, INF);
  dist[src] = 0;
  pq.emplace(dist[src], src);
  while( not pq.empty() ) {
    auto fr = pq.top(); pq.pop();
    ll u = fr.ss, del = fr.ff;
    if( del > dist[u] ) continue;
    for( const auto&e: g[u] ) {
      if( dist[e.ff] > del + e.ss ) {
	dist[e.ff] = e.ss + del;
	pq.emplace(dist[e.ff], e.ff);
      }
    }
  }
  for(int e=1;e<=m;e++) {
    int u = eu[e], v = ev[e]; ll w = ew[e];
    if( dist[u] > dist[v] ) swap(u, v);
    if( dist[u] + w == dist[v] ) {
      dag[u].emplace_back(v);
      dagt[v].emplace_back(u);
    }
  }
}

void dfs(int u, ll dp[], const int&sink, vector< int > dag[]) {
  if( dp[u] != -1 ) return;
  if( u == sink ) {
    dp[u] = 1;
    return;
  }
  dp[u] = 0;
  for(const int&v : dag[u]) {
    dfs(v, dp, sink, dag);
    dp[u] = (dp[u] + dp[v])%mod;
  }
}

inline bool intersect(ll a, ll b, ll c, ll d) {
  return not (b <= c or a >= d);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); srand(time(0));
  
  cin >> n >> m;
  cin >> s >> t;
  for(int e=1;e<=m;e++) {
    int u, v; ll w;
    cin >> u >> v >> w;
    eu[e] = u, ev[e] = v, ew[e] = w;
    g[u].emplace_back(v, w);
    g[v].emplace_back(u, w);
  }
  
  dijkstra(s);
  
  // for(int i=1;i<=n;i++) cout << ds[i] << ' '; cout << endl;
  // for(int i=1;i<=n;i++) cout << dt[i] << ' '; cout << endl;
  
  fill(dps, dps+n+1, -1);
  for(int i=1;i<=n;i++) if( dps[i] == -1 ) dfs(i, dps, t, dag);
  fill(dpt, dpt+n+1, -1);
  for(int i=1;i<=n;i++) if( dpt[i] == -1 ) dfs(i, dpt, s, dagt);
  
  // assert(dpt[t] == dps[s]);
  
  ll tot = ( dps[s] * dps[s] ) % mod; // all pairs
  
  ll foo = 0;
  for(int i=1;i<=n;i++) { // meet at node
    if( dist[i] == dist[t] - dist[i] ) {
      ll ways = ( dps[i] * dpt[i] ) % mod;
      ways = (ways * ways)%mod; // all pairs passing through i
      foo = (foo + ways)%mod;
    }
  }
  
  for(int e=1;e<=m;e++) {
    int x = eu[e], y = ev[e]; ll w = ew[e];
    if( dist[x] > dist[y] ) swap(x, y);
    if( dist[x] + w != dist[y] ) continue;

    ll sx = dist[x], sy = dist[y],
      tx = dist[t] - dist[x], ty = dist[t] - dist[y];
    
    if( tx > ty ) swap(tx, ty); // 
    if( intersect(sx, sy, tx, ty) ) {
      ll ways = ( dps[y] * dpt[x] )%mod;
      ways = (ways * ways)%mod;
      foo = (foo + ways)%mod;
    }
  }
  
  cout << (tot + mod - foo) % mod << endl;
  
  return 0;
}
/* -*- -*- */


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

#define rep( i, n ) for( int i = 0; i < ( n ); i++ )
#define PI 3.14159265
typedef long long ll;

int main( void ) {


    while( 1 ) {
        int n, sum;
        cin >> n >> sum;

        int cnt = 0;

        if( n == 0 && sum == 0 ) break;

        for( int i = 1; i <= n - 2; i++ ) {
            for( int j = i + 1; j <= n - 1; j++ ) {
                for( int k = j + 1; k <= n; k++ ) {
                    if( sum == i + j + k ) cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}



Measured memory_bytes: 3024
#include<stdio.h>
main(){
  double a,b,c,d,e,f,x,y;
  double ansx,tmp,ansy;
  double a1,a2,a3,a4,a5,a6,x1,y1;
  while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){

  tmp=a,a1=a,a2=b,a3=c,a4=d,a5=e,a6=f;
  a*=d,b*=d,c*=d;
  d*=tmp,e*=tmp,f*=tmp;
  x=b-e;
  y=c-f;

  ansx=y/x+0.000499999999;

  tmp=a2;
  a1*=a5,a2*=a5,a3*=a5;
  a4*=tmp,a5*=tmp,a6*=tmp;
  x1=a1-a4;
  y1=a3-a6;

  ansy=y1/x1+0.000499999999;

  printf("%.3f %.3f\n",ansy,ansx);
  }
  return 0;
}

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

    typedef long long int ll;
    #define pb         push_back
    #define mp         make_pair
    #define F          first
    #define S          second
    #define fl(i,a,b)  for(ll i=a;i<b;i++)
    #define pll        pair<ll,ll>
    #define pii        pair<int,int>
    #define all(v)     v.begin(),v.end()
    #define M 1000000007
    #define tr(v, it) for(auto it = v.begin(); it != v.end(); it++)
    using namespace std;


    int main()
    {

        ios_base::sync_with_stdio(false);
    	cin.tie(NULL);


       int n,k;
       cin>>n>>k;
       int arr[n];
       for(int i=0; i<n; i++)
        cin>>arr[i];
       sort(arr,arr+n);
       int dp[k+1];
       dp[0]=0;
       for(int i=1; i<=k; i++)
       {
           for(int j=0;j<n; j++)
           {
               if((i-arr[j])<0)
                dp[i]=0;
               else
               {
                   if(dp[i-arr[j]]==0)
                   {
                       dp[i]=1;
                       break;
                   }
                   else
                    dp[i]=0;
               }
           }
       }
        if(dp[k]==1)
            cout<<"First";
        else
            cout<<"Second";
       return 0;
    }


Measured memory_bytes: 4052
package main

import (
	"fmt"
)

func main() {

	for {

		var n [2]int
		//n := ScanedLinetoIntSlice()
		fmt.Scanln(&n[0], &n[1])

		if (n[0] == 0) && (n[1] == 0) {
			break
		}
		if n[0] > n[1] {
			n[0], n[1] = swap(n[0], n[1])
		}
		fmt.Println(n[0], n[1])
	}

}

func swap(a, b int) (int, int) {
	return b, a
}

/*
func ScanedLinetoIntSlice() []int {

	var sc = bufio.NewScanner(os.Stdin)
	sc.Scan()
	line := sc.Text()

	words := strings.Fields(line)

	var numbers []int

	for _, v := range words {
		number, _ := strconv.Atoi(v)
		numbers = append(numbers, number)
	}

	return numbers
}
*/



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

using namespace std;

string str;
int ct[26];

int main() {
	cin >> str;
	int n = str.size();
	string bef, af;
	int b = 0, a = n - 1;
	while (b < a) {
		for (; str[b] == 'x' && b < n - 1; b++);
		for (; str[a] == 'x' && a > 0; a--);
		bef += str[b], af += str[a];
		b++, a--;
		//cout << b << " " << a << endl;
	}
	if (bef != af) 
		cout << -1 << endl;
	else {
		int ans = 0;
		b = 0, a = n - 1;
		while (a > b) {
			if (str[a] == str[b]) {
				a--, b++;
				continue;
			}
			if (str[a] == 'x') {
				ans++, a--;
			}
			if (str[b] == 'x') {
				ans++, b++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;

int main()
{
	//ifstream cin("input.txt");
	ll n,m;
	cin>>n>>m;
	vi x(m);

	if(m == 1 || n >= m)
	{
		cout<<0;
		return 0;
	}
	rep(i,0,m-1)
		cin>>x[i];

	vi diff(m-1);

	sort(x.begin(), x.end());
	rep(i, 1, m-1)
		diff[i-1] = abs(x[i] - x[i - 1]);

	sort(diff.begin(), diff.end());
	int poss_distance = 0, j =0;
	rep(i, 1, m- n )
		poss_distance += diff[j++];
	
	cout<<poss_distance;
	
}


Measured memory_bytes: 4852
#ABC141_B
S = list(input())
flag1 = 1
flag2 = 1
for i in range(len(S)):
    if i % 2 == 1:
        if S[i] != "L"and S[i] != "U"and S[i] != "D":
            flag1 = 0
            break
    else:
        if S[i] != "R"and S[i] != "U"and S[i] != "D":
            flag2 = 0
            break

if flag1 == 1 and flag2 == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int ans=0;
  while(n--){
    int k;
    cin>>k;
    bool f=0;
    for(int i=2;i*i<=k;i++) f|=(k%i==0);
    if(!f) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
    int num = 0;
    string s;
    cin >> s;
    if(s[0] == '1') num++;
    if(s[1] == '1') num++;
    if(s[2] == '1') num++;
    cout << num << endl;
}



Measured memory_bytes: 256
flag =0
while flag==0:
    a,b,c=[ i for i in input().split()]
    if b=="?":
        flag=1
        break
    elif b=="+":
        n=int(a)+int(c)
    elif b=="-":
        n=int(a)-int(c)
    elif b=="*":
        n=int(a)*int(c)
    elif b=="/":
        n=int(a)/int(c)
    print(int(n))

Measured memory_bytes: 7768
N,M = map(int,input().split())
A = [tuple(map(int,input().split())) for i in range(N)]
C = [tuple(map(int,input().split())) for i in range(M)]
for ax,ay in A:
    min_d = 10**10
    min_i = -1
    for i,(cx,cy) in enumerate(C):
        d = abs(ax-cx) + abs(ay-cy)
        if d < min_d:
            min_d = d
            min_i = i
    print(min_i + 1)

Measured memory_bytes: 3064
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

a,b,x = map(int,input().split())

first = x*(a//x + bool(a%x))
end = x*(b//x)
if first==end:
    print(1)
elif first>end:
    print(0)
else:
    print((end-first)//x+1)


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

//#define DEBUG

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

int main() {
    int K; cin >> K;
    int right;
    long long j=0;
    vector<long long> l;
    for(int i=1; i<10; i++){
        l.push_back(i);
    }
    int count = 10;

    while(count <= K){
        right = l[j]%10;
        if(right != 0){
            l.push_back(l[j]*10+right-1);
            count ++;
        }
        l.push_back(l[j]*10+right);
        count ++;
        if(right != 9){
            l.push_back(l[j]*10+right+1);
            count ++;
        } 
        j++;
    }
    cout << l[K-1] << endl;
}


Measured memory_bytes: 1400
/*************************************************************************
  > File Name: c.cpp
  > Author: Samuel
  > Mail: enminghuang21119@gmail.com
  > Created Time: Tue Mar 17 19:08:52 2020
*************************************************************************/

#include <bits/stdc++.h>
using namespace std;

int in[200010];
long long ans;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> in[i];
    sort(in, in + n, [&](int a, int b) {
            return a > b;
            });
    for (int i = k; i < n; i++)
        ans += in[i];
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int N, C, K, a[100100];
int main(){
    int i, ans = 0, cnt = -1, dap = 0;
    cin>>N>>C>>K;
    for(i=0; i<N; i++) cin>>a[i];
    sort(a, a+N);
    for(i=0; i<N; i++){
        if(cnt < a[i]) {
            ans++;
            cnt = a[i] + K;
            dap = 0;
        }
        if(dap == C){
            cnt = a[i] + K;
            ans++;
            dap = 0;
        }
        if(cnt >= a[i] && cnt <= a[i] + K){
            dap++;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 640
/**
 * Contest : AtCoder Beginner Contest 159
 * Contest URL : https://atcoder.jp/contests/abc159/
 * Problem : F - Knapsack for All Segments
 * Problem URL : https://atcoder.jp/contests/abc159/tasks/abc159_f
 */

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair < int, int >;

// This section is for Policy Based Data Structure, more precisely Ordered Set.
// All Functions of set works here, in addition we have order_of_key() and find_by_order() function. find_by_order() returns iterator
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace __gnu_pbds;

// 1. Custom Set
template < class T, class COMP >
using custom_set = tree < T, null_type, COMP, rb_tree_tag, tree_order_statistics_node_update >;

// 2. Ordered Set
template < class T >
using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;

// 3. Ordered Multi Set
// For storing multiple occurance of same value we need to use pair. In pair first value is our key and second is useless count variable.
// order_of_key(make_pair(key, 0)) returns first occurance of a value, order_of_key(make_pair(key, INT_MAX)) returns last occurance.
template < class T >
using ordered_multiset = tree < pair < T, int >, null_type, less < pair < T, int > >, rb_tree_tag, tree_order_statistics_node_update >;

// 4. Ordered Map
template < class T, class U >
using ordered_map = tree < T, U, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
// Policy End

const int mod = 998244353;

void add_self (int & a, int b) {
	a += b;
	if (a >= mod) a -= mod;
}

int mul (int a, int b) {
	return (ll) a * b % mod;
}

int main() {
	ios_base::sync_with_stdio (false);
	cin.tie (0); cout.tie (0);
	int n, s;
	cin >> n >> s;
	vector < int > a (n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int answer = 0;
	vector < int > dp (s + 1);
	dp[0] = 1;
	for (int i = 0; i < n; i++) {
		if (a[i] < s) {
			add_self (answer, mul (n - i, dp[s - a[i]]));
		}
		for (int j = s - a[i]; j >= 1; j--) {
			add_self (dp[j + a[i]], dp[j]);
		}
		
		if (a[i] <= s) {
			add_self (dp[a[i]], i + 1);
		}
		if (a[i] == s) {
			add_self (answer, mul (i + 1, n - i));
		}
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

void Solve() {
	int x, y;
	cin >> x >> y;

	if (x % y == 0) {
		cout << -1 << "\n";
	} else {
		cout << x << "\n";
	}
}

int main() {
	int tests = 1;

	for (;tests; --tests) {
		Solve();
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>

//#define PI 3.141592653589

using namespace std;



int main()
{
	int sh, sm, ss, eh, em, es;
	int s_sum, e_sum;
	int time;
	int th, tm, ts;
	
	for (int i=0; i<3; i++)
	{
		cin >> sh >> sm >> ss >> eh >> em >> es;
		
		s_sum = 3600*sh + 60*sm + ss;
		e_sum = 3600*eh + 60*em + es;
		time = e_sum - s_sum;
		th = time / 3600;
		time %= 3600;
		tm = time / 60;
		time %= 60;
		ts = time;
		cout << th << " " << tm << " " << ts << endl;
	}
	
	return 0;
}

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

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    int N,i;

    cin>>N>>i;

    cout<<N-i+1<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define M 200
#define N 1000

void is_same(
    int m,int n,
    int mx[],int my[],
    int nx[],int ny[]){
  int i,j,k,l;
  int count;

  for(i=0;i<m;i++)
    for(j=0;j<n;j++){
      count=0;

      for(k=0;k<n;k++)
        for(l=0;l<m;l++)
          if( mx[l]+(nx[j]-mx[i])==nx[k] &&
              my[l]+(ny[j]-my[i])==ny[k] )
            count++;

      if(count==m){
        printf("%d %d\n",nx[j]-mx[i],ny[j]-my[i]);
        return ;
      }
    }
}

int main(void){
  int i;
  int m,n;
  int mx[M],my[M];
  int nx[N],ny[N];

  for(;;){
    scanf("%d",&m);
    if(m==0)
      break;
    for(i=0;i<m;i++)
      scanf("%d%d",&mx[i],&my[i]);

    scanf("%d",&n);
    for(i=0;i<n;i++)
      scanf("%d%d",&nx[i],&ny[i]);
    
    is_same(m,n,mx,my,nx,ny);
  }

  return 0;
}

Measured memory_bytes: 412