akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

//Zeller's conguence

int main()
{
    int h, y, m, d;
    h = 20;
    y = 4;
    while (true)
    {
        cin >> m >> d;
        if (m == 0 && d == 0)
            break;
        if (m == 1 || m == 2)
        {
            m += 12;
            y--;
        }
        int r = 5 * h + h / 4;
        int w = {d + ((13 * (m + 1)) / 5) +
                 y + y / 4 + r + 5};

        int ans = w % 7 + 1;
        switch (ans)
        {
        case 7:
            cout << "Sunday" << endl;
            break;
        case 1:
            cout << "Monday" << endl;
            break;
        case 2:
            cout << "Tuesday" << endl;
            break;
        case 3:
            cout << "Wednesday" << endl;
            break;
        case 4:
            cout << "Thursday" << endl;
            break;
        case 5:
            cout << "Friday" << endl;
            break;
        case 6:
            cout << "Saturday" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3016
#include <iostream>
#include <vector>
#include <string>

using namespace std;

bool D[20];

bool check(int n)
{
	vector<int> tmp;
	while(n) {
		tmp.push_back(n % 10);
		n /= 10;
	}
	for(int i = 0; i < tmp.size(); i++) {
		//cout << tmp[i] << ' ' << D[tmp[i]] << endl;
		if(D[tmp[i]] == true) return false;
	}

	return true;
}

int main()
{
	int N, K;

	cin >> N >> K;
	for(int i = 0; i < K; i++) {
		int d;
		cin >> d;
		D[d] = true;
	}

	while(! check(N)) N++;
	cout << N << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,even=0,odd=0;
  int num;
  cin >> N;
  string ans = "YES";
  REP(i,N){
    cin >> num;
    num%2 == 0 ? even++ : odd++;
  }
  
  while(1){
    if(odd == 1 && even == 1){
      ans = "NO";
      break;
    }
    if(odd ==0 && even == 1) break;
    if(odd < 0 || even < 0) break;
    if(odd >= even){
      odd-=2;
      even++;
    }
    else{
      even--;
    }
  }
  cout << ans << endl;
}

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

int main(void){
    int n,u,k,i,j,x;
    bool path[110][110];
    memset(path,0,sizeof(path));
    cin>>n;
    for(i=0;i<n;i++){
        cin>>u>>k;
        u--;
        for(j=0;j<k;j++){
            cin>>x;
            x--;
            path[u][x]=true;
        }
    }
    
    for(i=0;i<n;i++){
        for(j=0;j<n-1;j++){
            cout<<path[i][j]<<" ";
        }
        cout<<path[i][n-1]<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        try (Scanner scanner = new Scanner(System.in)) {
            int n = Integer.parseInt(scanner.nextLine());
//            int[] s = new int[n];
//
//            for (int i = 0, p = 0; i < n; i++) {
//
//            }

            String[] s = scanner.nextLine().split(" ");

            int q = Integer.parseInt(scanner.nextLine());
            String[] t = scanner.nextLine().split(" ");

            int count = 0;

            for (String ts : t) {
                int i = Integer.parseInt(ts);
                if (search(s, i, 0, n)) {
                    count++;
                }
            }

            System.out.println(count);
        }
    }

    private static boolean search(String[] s, int i, int left, int right) {
        int half = (left + right) / 2;
        //System.out.printf("%d %d %d %d %s%n", i, left, right, half, s[half]);
        if (half == left || half == right) {
            return false;
        }
        if (i < Integer.parseInt(s[half])) {
            // if (left >= half) {
            //     return false;
            // }
            return search(s, i, left, half);
        } else if (i > Integer.parseInt(s[half])) {
            // if (right <= half) {
            //     return false;
            // }
            return search(s, i, half, right);
        }
        // 一致
        return true;
    }
}



Measured memory_bytes: 75276
n, h = [int(x) for x in input().split()]
sl = 0
b = []
for i in range(n):
  b += [0]
  a, b[-1] = [int(x) for x in input().split()]
  sl = max(sl, a)
b.sort(reverse=True)

res = 0
for th in b:
  if th <= sl:
    break
  h -= th
  res += 1
  if h <= 0:
    break
if h > 0:
  if h % sl == 0:
    res += h // sl
  else:
    res += h // sl + 1
print(res)


Measured memory_bytes: 7392
X = int(input())
dp = [0] * (X+1000)
for i in range(6):
    dp[100+i] = 1
for i in range(X+10):
    for k in range(6):
        if i - 100 - k > 0:
            dp[i] = dp[i] | dp[i-100-k]
print(dp[X])


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

int main(){
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll a,b,c;
  cin >> a >> b >> c;
  if(b-a == c-b) cout <<"YES\n";
  else cout <<"NO\n";
}


Measured memory_bytes: 256
N = int(input())
count = [10*[0]for _ in range(10)]
ans = 0
for i in range(1,N+1):
  s = str(i)
  if s[0] == '0' or s[-1] == '0':
    pass
  else:
    count[int(s[0])][int(s[-1])] += 1
for j in range(1,10):
  for k in range(1,10):
    ans += count[j][k]*count[k][j]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <sstream>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    int n;
    cin>>n;
    for(int i=0;i<11;i++){
        if(1000 * i >= n){
            cout<<1000*i - n<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3636
#include <cstdio>
typedef long long ll;
const int Maxn=1000000;
int n;
int a[Maxn+5];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j+=i){
			a[j]++;
		}
	}
	ll ans=0;
	for(int i=1;i<n;i++){
		ans+=a[i];
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 5636
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    sort(rall(a));
    ll alice = 0;
    ll bob = 0;
    rep(i,n){
        if(i%2==0) alice += a[i];
        else bob += a[i];
    }
    cout << alice-bob << endl;
}

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

int main() {
  int A, B, C, x; cin >> A >> B >> C >> x;
  int ans = 0;
  for(int a = 0; a <= A; ++a){
    for(int b = 0; b <= B; ++b){
      for(int c = 0; c <= C; ++c){
        int total = 500*a + 100*b + 50*c;
        if(total == x) ++ans;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

const MOD: usize = 1_000_000_007;

pub fn prime_factorize<T: PrimInt + NumAssign>(mut n: T) -> Vec<(T, T)> {
    let mut res: Vec<(T, T)> = Vec::new();
    let mut i: T = one::<T>().signed_shl(1);
    while i * i <= n {
        if n % i == zero() {
            let mut ex = zero::<T>();
            while n % i == zero() {
                ex += one();
                n = n / i;
            }
            res.push((i, ex));
        }
        i += one();
    }
    if n != one() {
        res.push((n, one()))
    }
    res
}

#[fastout]
fn solve() {
    input!{
        n: usize,
    }

    let mut ans = 1;

    for i in (1..=n).rev() {
        let primes = prime_factorize(i);
        if primes.iter().map(|x| x.1).any(|x| x == 1) { continue; }
        if primes.iter().map(|x| x.1).all_equal() {
            ans = i;
            break;
        }
    }

    println!("{}", ans);
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


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

int main()
{
    LL n,i,j,k;
    cin>>n;
    LL a[n+1],b[n+1],c[n+1];
    LL dp[n+1][3];
    LL cost[n+1][3];
    for(i=1;i<=n;i++)
    {
        cin>>cost[i][0]>>cost[i][1]>>cost[i][2];
    }

    dp[1][0]=cost[1][0];
    dp[1][1]=cost[1][1];
    dp[1][2]=cost[1][2];

    for(i=2;i<=n;i++)
    {
        for(k=0;k<=2;k++)
        dp[i][k]=cost[i][k]+max(dp[i-1][(k+1)%3],dp[i-1][(k+2)%3]);
    }

    LL maxima=-1;
    for(i=0;i<3;i++)
    {
        maxima=max(maxima,dp[n][i]);
    }
    cout<<maxima<<endl;

}

Measured memory_bytes: 4864
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;

#define REP(i,a,n) for(i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)


int speed[33][33], dist[33][33];
bool used[33][33][33];
double dp[33][33][33]; // [ツ個サツ催敖づ個都ツ市][ツ前ツづ個都ツ市][ツ堕ャツ度]
const double inf = 999999999.0;

struct state{
  int no, pr, sp;
  double t;
  
  state(int n, int p, int s, double _t)
       :no(n), pr(p), sp(s), t(_t){}
  bool operator<(const state& a)const{
    return t > a.t;
  }
};

int main(){
  int i,j,k,n,u, m,s,g;
  while( cin >> n >> m, n|m ){

    // init
    rep(i,33) rep(j,33) rep(k,33) dp[i][j][k] = inf;
    memset(speed, -1, sizeof(speed));
    memset(dist, -1, sizeof(dist));
    memset(used, false, sizeof(used));

    // input
    cin >> s >> g;
    rep(i,m){
      int x,y,d,c; cin >> x >> y >> d >> c;
      dist[x][y] = dist[y][x] = d;
      speed[x][y] = speed[y][x] = c;
    }

    priority_queue<state> q;
    // start
    
    REP(i,1,n+1) if( dist[s][i] != -1 ) {
      dp[i][s][1] = (double)dist[s][i];
      q.push(state(i,s,1,(double)dist[s][i]));
    }
      
    while( !q.empty() ){
      int now = q.top().no;
      int prev = q.top().pr;
      int sp = q.top().sp;
      double t = dp[now][prev][sp];

      //printf("dp[%d][%d][%d] = %lf\n",now,prev,sp,t);
      q.pop();

      if( now == g && sp == 1 ) break;
      if( used[now][prev][sp] ) continue;
      used[now][prev][sp] = true;

      REP(i,1,n+1) if( dist[now][i] != -1 && prev != i ) { // ツ篠淞づ可行ツつォツつスツつ「ツ都ツ市
        for(int v=sp-1; v<=sp+1; v++){
          if( v <= 0 || v > speed[now][i] ) continue;

          if( dp[i][now][v] > t + (double)dist[now][i]/(double)v ){
            double cost = t + (double)dist[now][i]/(double)v;
            dp[i][now][v] = cost;
            q.push(state(i,now,v,cost));
          }
        }
      }
    }

    double res = inf;
    REP(i,1,n+1) if( dp[g][i][1] != inf ) res = min(res, dp[g][i][1]);
    if( res == inf ){
      puts("unreachable");
    }
    else{
      printf("%lf\n",res);
    }
  }
  
  return 0;
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;

int n,q;
string s;
int main(){
  cin >> n >> q;
  cin >> s;
  vector<ll>cumsum(n+1);
  cumsum[0] = 0;
  cumsum[1] = 0;
  for(int i = 1; i < n; i++){
    if(s[i-1]=='A' && s[i] == 'C')cumsum[i+1] = cumsum[i] + 1;
    else cumsum[i+1] = cumsum[i];
  }
  for(int i = 0; i < q; i++){
    int l, r;
    cin >> l >> r;
    cout << (cumsum[r] - cumsum[l]) << endl;
  }
}


Measured memory_bytes: 1792
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(a%b,b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}

bool is_prime[ 100000 + 1 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }    
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

int main(){
    init();
	ll N,K;cin>>N>>K;
	ll R,S,P;cin>>R>>S>>P;
	string s;
	cin>>s;
	string t;
	for(int i=0;i<s.size();i++){
		if(s[i]=='r')t.push_back('p');
		if(s[i]=='s')t.push_back('r');
		if(s[i]=='p')t.push_back('s');
	}
	ll ans=0;
	for(int i=0;i<N;i++){
		if(i<K){
			//普通に
			if(s[i]=='r')ans+=P;
			if(s[i]=='s')ans+=R;
			if(s[i]=='p')ans+=S;

		}else{
			if(t[i]==t[i-K]){

				t[i]='.';
				continue;
			}
			if(s[i]=='r')ans+=P;
			if(s[i]=='s')ans+=R;
			if(s[i]=='p')ans+=S;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DEBUG 0
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;

//?????§??¬?´???°
int gcd(int x, int y) { return y ? gcd(y, x%y) : x; }

signed main() {
	int n; cin >> n;
	int g;
	if (n == 2) {
		int a, b; cin >> a >> b;
		g = gcd(a, b);
	}
	else {
		int a, b, c; cin >> a >> b >> c;
		g = gcd(c, gcd(a, b));
	}
	rep(i, 1, g + 1) {
		if (g%i == 0)cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 

// using namespace __gnu_pbds; 
using namespace std;

//macros
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define watch(x) cout << "debug : " << #x << " -> " << x << endl; 

//globals
ll const mod = 1e9+7;
ll const size_1d = 1e6 + 7;
ll const size_2d = 1e3 + 7;

//functions
ll power(ll x, ll y, ll mod = 2e18){ ll ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
ll modInverse(ll a, ll m){ll m0 = m;ll y = 0, x = 1;if (m == 1) return 0;while (a > 1){ ll q = a / m;ll t = m;m = a % m,a = t;t = y;y = x - q * y;x = t;}if(x < 0) x += m0;return x;} 
ll gcdext(ll a,ll b,ll *x = 0, ll *y = 0){if(a == 0){*x = 0;*y = 1;return b;}ll x1,y1;ll gcd1 = gcdext(b%a,a,&x1,&y1);*x = y1 - (b/a)*x1;*y = x1;return gcd1;}
int randomize(){return (rand()%10000);} 

// CODE STARTS HERE   
int dp[size_1d];

int main() {
  IOS;

  int n,k;cin >> n >> k;
  std::vector<int> v(n);
  for (int i = 0; i < n; ++i)
  {
    cin >> v[i];
  }
  int flag = 1;
  // dp[0] = 1;
  for (int i = 1; i <= k; ++i)
  {
    bool check = false;
    for (int j = 0; j < n; ++j)
    {
      if(i - v[j] >= 0)
      {
        if(!dp[i-v[j]]){
          dp[i] = true;
          break;
        }
      }
      else{
        dp[i] = false;
      }
    }
  }

  cout << (dp[k]?"First":"Second") << endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;
#define INF 1e+9;

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;
}

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i,n){
		cin >> h[i];
	}
	
	vector<int> cost(n);
	rep(i,n){
		cost[i] = INF;
	}
	cost[0] = 0;
	
	rep(i,n-1){
		for (int j = 1; j <= k ; ++j) {
			if (i-j+1 >= 0){
				chmin(cost[i+1], cost[i+1-j] + abs(h[i+1] - h[i+1-j]));
			}
		}
	}
	
	cout << cost[n-1] << endl;
    return 0;
}


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

#ifdef WIN32
    #define lld "%I64d"
#else
    #define lld "%lld"
#endif

#define mp make_pair
#define pb push_back
#define put(x) { cout << #x << " = "; cout << (x) << endl; }

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef double db;

const int M = 1e6 + 15;
const int Q = 1e9 + 7;

int t[M];

int main() {
    srand(time(NULL));
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(0);

	int n, c, k;
	cin >> n >> c >> k;
	for (int i = 0; i < n; i++) cin >> t[i];
	sort(t, t + n);
	int pos = 0;
	int ans = 0;
	while (pos < n) {
		int j = pos;
		while (j < n && j - pos < c && t[j] - t[pos] <= k) j++;
		ans++;
		pos = j;
	}
	cout << ans << endl;


    return 0;
}   

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

// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000000000000ll
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
//#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a, b, x;
  cin >> a >> b >> x;
  cout << b / x - a / x + (a % x == 0 ? 1 : 0) << endl;
  return 0;
}


Measured memory_bytes: 3604
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        System.out.println(a<=c&&b>=c?"Yes":"No");
    }
     
}

Measured memory_bytes: 25044
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int n;
  cin >> n;
  vector<bool> dp(n + 1);
  dp[0] = true;
  for (int i = 100; i <= 105; ++i) {
    for (int j = 0; j + i <= n; ++j) {
      dp[j + i] = dp[j + i] | dp[j];
    }
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 256
INF = 1e10

N, M, X = map(int, input().split())
C, A = [], []
for i in range(N):
    c, *a = map(int, input().split())
    C.append(c)
    A.append(a)

ans = INF

for s in range(1<<N):
    cost = 0
    d = [0]*M
    for i in range(N):
        if s>>i&1:
            cost += C[i]
            for j in range(M): d[j] += A[i][j]

    ok = True
    for j in range(M):
        if d[j] < X: ok = False
    if ok: ans = min(ans, cost)

if ans==INF: print(-1)
else: print(ans)


Measured memory_bytes: 9192
//
//  abc168_b.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll INF = 1000000007;
#define PI 3.14159265

const int MAX = 110000;

ll fac[MAX], finv[MAX], inv[MAX];

std::vector<int> permutations;

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

int main() {
  ll k;
  std::cin >> k;
  std::string s;
  std::cin >> s;

  int size = s.size();

  if (size <= k) {
    std::cout << s << std::endl;
    return 0;
  }

  for (int i = 0; i < k; i++) {
    std::cout << s[i];
  }
  std::cout << "..." << std::endl;

  return 0;
}



Measured memory_bytes: 3628
#include <cstdio>
#include <string>
using namespace std;

int n, a, b;
char t[100001];
string s;
int c, d;

int main(){
	scanf("%d %d %d %s", &n, &a, &b, t);
	s = t;

	for(int i=0; i<n; i++){
		if(s[i] == 'c'){
			printf("No\n");
		}else if(s[i] == 'a'){
			if(c + d < a + b){
				printf("Yes\n");
				c++;
			}else{
				printf("No\n");
			}
		}else{
			if(c + d < a + b && d < b){
				printf("Yes\n");
				d++;
			}else{
				printf("No\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 768
//AnkitCode99 here....
#include<bits/stdc++.h>
#define endl "\n"
typedef long long int ll;
#define MOD 1000000007
#define mp make_pair
#define pll pair<ll,ll>
#define pb push_back
//max xor btw range of two numbers..
#define max_XOR(a,b) (1 << int(log2(a ^ b) + 1)) - 1
#define vl vector<ll>
#define inf ll(1e18)
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
#define ceil(a,b) a/b+((a%b ==0 )?0:1)
using namespace std;

const ll sz=100005;
const ll szz=1000006;

int main()
{
	fast;
    ll n;
    cin>>n;
    bool flag=true;
    rep(i,0,n)
    {
    	ll ele;
    	cin>>ele;
    	if(!(ele&1))
    	{
    		if(ele%3!=0 and ele%5!=0)
    			flag=false;
    	}
    }

    if(flag)
    	cout<<"APPROVED";
    else
    	cout<<"DENIED";
}
//Goodbye...

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

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int n,ans=0;
    cin>>n;
    n*=2;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
	sort(a,a+n,greater<int>());
	for(int i=0;i<n;i++)
	{
	    if(i%2!=0)
	    ans+=a[i];
	}
	cout<<ans;
	return 0; 
} 


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <queue>
#include <vector>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)

const int nmax = 100005;
int warp[nmax];
int memo[nmax];
int p[nmax];
bool visited[nmax];
const int inf = 10000000;

int dfs(int now) {
    if (visited[now]) {
        return warp[now];
    }
    visited[now] = true;
    if (p[now] == 0) {
        warp[now] = now;
    } else {
        warp[now] = -1;
        warp[now] = dfs(now + p[now]);
    }
    return warp[now];
}

int main() {
    std::ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n) {
        cin >> p[i];
        warp[i] = inf;
    }
    rep(i,n) {
        dfs(i);
    }

    rep(i,n) {
        visited[i] = false;
    }
 
    priority_queue<pair<int,int> > q;
    q.push(make_pair(0,0));
    
    while(!q.empty()) {
        int depth = -q.top().first;
        int now = q.top().second;
        q.pop();
        if (visited[now])continue;
        visited[now] = true;
        if (now == n-1) {
            cout << depth << endl;
            return 0;
        }
        for (int i = 1; i <= 6; i++) {
            if (now + i >= n)break;
            if (warp[now+i] == -1)continue;
            q.push(make_pair(-(depth+1), warp[now+i]));
        }
    }
    
    return 0;
}

Measured memory_bytes: 3384
#include <bits/stdc++.h>
 
using namespace std;
 
#define int 		long long
#define endl		"\n"
#define mod			1000000007
#define IOS			ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
int32_t main(){
 
	IOS;
	
	int n, k, mn;
	cin >> n >> k;
	vector<int> h(n), dp(n);

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

	dp[0] = 0;

	for(int i = 1; i < n; i++) {
		mn = 1e18;
		for(int j = max(0ll, i - k); j < i; j++) {
			mn = min(mn, labs(h[i] - h[j]) + dp[j]);
		}
		dp[i] = mn;
	}
 	 
 	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    cout << max(0,in() - in()) << "\n";
}

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

using namespace std;

typedef long long ll;

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

    ll dp[3], happy[3], ans;
    int n;
    dp[0] = dp[1] = dp[2] = 0;

    cin >> n;
    while(n--){
        cin >> happy[0] >> happy[1] >> happy[2];
        happy[0] += max(dp[1], dp[2]);
        happy[1] += max(dp[0], dp[2]);
        happy[2] += max(dp[1], dp[0]);
        swap(dp,happy);
    }

    ans = max(dp[0], max(dp[1], dp[2]));
    cout << ans << '\n';

    return 0;
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    bool sym = true;
    for (int i=0; i<n/2; i++) 
        if (s[i] != s[n-2-i]) {
            sym = false;
            break;
        }
    if (s[0] == '0' || s[n-1] == '1' || !sym) {
        cout << -1 << '\n';
        return 0;
    }
    int now = 1;
    for (int i=2; i<=n; i++) {
        cout << now << ' ' << i << '\n';
        if (i - 2 < n / 2 && s[i-2] == '1') now = i;
    }
    return 0;
}

Measured memory_bytes: 1664
# coding: utf-8

a = int(input())+1
b = int(input())+1
c = int(input())+1
x = int(input())

count = 0
for i in range(a):
    if 500*i > x:
        break
    for j in range(b):
        if 500*i+100*j > x:
            break
        for k in range(c):
            if 500*i+100*j+50*k == x:
                count += 1
            elif 500*i+100*j+50*k > x:
                break

print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<set>
#include<algorithm>

using namespace std;

int main(){
  int N, M, X, Y;
  set<int> x, y;
  
  cin >> N >> M >> X >> Y;
  for(int i = 0;i < N;i++){
    int a;
    cin >> a;
    x.insert(a);
  }
  for(int i = 0;i < M;i++){
    int a;
    cin >> a;
    y.insert(a);
  }
  
  if(max(X, *prev(x.end(), 1)) < min(Y, *y.begin())) cout << "No ";
  cout << "War" << endl;
  
  return 0;
}

Measured memory_bytes: 380
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#define PI 3.141592
using namespace std;

int main(void){

    double x=0,y=0;
    int a,b;
    int q=90;
    char z;
    for(;;){
    scanf("%d%c%d",&a,&z,&b);
        if(a==0&&b==0)break;
        y += a*sin(((double)q/180)*3.141592);
        x += a*cos(((double)q/180)*3.141592);
        q -= b;
    }
    cout<<(int)x<<endl;
    cout<<(int)y<<endl;
    return 0;
}

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

const int N = 1e2 + 10;

int n, a[N], cnt[N];

inline void go_die() {
	puts("Impossible");
	exit(0);
}

int main() {
	scanf("%d", &n);
	int max_a = INT_MIN, min_a = INT_MAX;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		++cnt[a[i]];
		max_a = max(max_a, a[i]);
		min_a = min(min_a, a[i]);
	}
	if (min_a < (max_a + 1) / 2 || cnt[max_a] < 2) go_die();
	if ((max_a & 1) && cnt[min_a] != 2) go_die();
	if (!(max_a & 1) && cnt[min_a] != 1) go_die();
	for (int i = min_a + 1; i < max_a; ++i)
		if (cnt[i] < 2) go_die();
	puts("Possible");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t N, count = 0;
    cin >> N;
    vector<int64_t> A(N), B(N);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
        cin >> B.at(i);
    }
    reverse(ALL(A));
    reverse(ALL(B));
    for (int i = 0; i < N; i++) {
        A.at(i) += count;
        int64_t T = A.at(i) % B.at(i);
        if (T != 0) {
            T = B.at(i) - T;
        }
        count += T;
    }
    cout << count << endl;


}


Measured memory_bytes: 1792
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <limits>//setprecision
#include <iomanip>
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#include <numeric> //accumulate,,,
//#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M,long long MOD) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2,MOD);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a; else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    string S;cin >> S;
    string T;cin >> T;
    vector<int> alphaS(26,-1);
    for(int i = 0;i<S.size();i++){
        int now = S.at(i)-'a';
        if(alphaS.at(now) == -1){
            alphaS.at(now) = T.at(i)-'a';
        }
        else if(alphaS.at(now) != -1 && alphaS.at(now) != T.at(i)-'a'){
            cout << "No" << endl;
            return 0;
        }
    }
    vector<int> alphaT(26,-1);
    for(int i = 0;i<T.size();i++){
        int now = T.at(i)-'a';
        if(alphaT.at(now) == -1){
            alphaT.at(now) = S.at(i)-'a';
        }
        else if(alphaT.at(now) != -1 && alphaT.at(now) != S.at(i)-'a'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define MP make_pair
#define FI first
#define SE second
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;

const double EPS = 1e-9;
const double PI = acos(-1);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

ll addMod(ll a, ll b){
	return (a+b) % MOD;
}

ll mulMod(ll a, ll b){
	return (a*b) % MOD;
}

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

const int N = 100;

int w,h,n;
int x[N + 5], y[N + 5], a[N + 5];

int solve(){
	int mxx = 0, mxy = 0, mnx = w, mny = h;
	FOR(i,n){
		if(a[i] == 1){
			mxx = max(mxx, x[i]);
		}
		else if(a[i] == 2){
			mnx = min(mnx, x[i]);
		}
		else if(a[i] == 3){
			mxy = max(mxy, y[i]);
		}
		else{
			mny = min(mny, y[i]);
		}
	}
	if(mnx < mxx) mnx = mxx;
	if(mny < mxy) mny = mxy;
	return (mnx - mxx) * (mny - mxy);
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> w >> h >> n;
	FOR(i,n) cin >> x[i] >> y[i] >> a[i];
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 256
// ABC042C - こだわり者いろはちゃん

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

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

	vector<int> D(K);
	for (int i = 0; i < K; i++) {
		cin >> D.at(i);
	}

	int temp, number;
	bool isOccur;
	while (1) {
		temp = N;
		isOccur = false;
		while (temp > 0) {
			number = temp % 10;
			temp /= 10;
			for (int i = 0; i < K; i++) {
				if (number == D.at(i)) {
					isOccur = true;
					break;
				}
			}
			if (isOccur == true) {
				break;
			}
		}
		if (isOccur == false) {
			break;
		}
		N++;
	}

	cout << N << endl;

	return 0;
}


Measured memory_bytes: 256
#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>

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;

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

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 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; }

void solve(void)
{
  int64_t a, b; cin >> a >> b;
  auto c = boost::integer::gcd(a, b);
  ull ans{1};
  if(c % 2 == 0){
    ++ans;
    while (c % 2 == 0){
      c /= 2;
    }
  }
  int64_t i = 3;
  while (i * i <= c){
    if(c % i != 0){
      i += 2;
      continue;
    }
    ++ans;
    while (c % i == 0){
      c /= i;
    }
    i += 2;
  }
  if(c != 1){
    ++ans;
  }
  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
//Patwari26
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n;
    cin>>n;
    vi a(n),b(n);
    rep(i,0,n-1) cin>>a[i];
    rep(i,0,n-1) cin>>b[i];
    vi temp(n);
    rep(i,0,n-1) temp[i]=i+1;
    ll fk=1;
    ll y=0,z=0;
    do{
        if((temp)==(a)) y=fk;
        if((temp)==(b)) z=fk;
        fk++;
    }while(next_permutation(all(temp)));
    cout<<abs(z-y)<<endl;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int n;
int ans1,ans2;
string s;
int main()
{
    cin>>s;
    n=s.size();
    for(int i=0;i<n;i++)
    {
        if(i%2==0)
        {
            if(s[i]=='1')
                ans1++;
        }
        else
        {
            if(s[i]=='0')
                ans1++;
        }
    }

    for(int i=0;i<n;i++)
    {
        if(i%2==1)
        {
            if(s[i]=='1')
                ans2++;
        }
        else
        {
            if(s[i]=='0')
                ans2++;
        }
    }
    cout<<min(ans1,ans2);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n;

int main(){
	cin >> n;
	
	REP(i,1,10000){
		if(n<i*(i+1)/2){
			int pos=i*(i+1)/2-n;
			REP(j,0,i) if(j+1!=pos) cout << j+1 << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int a, b;
    string s;
    cin >> a >> b;
    cin >> s;
    int f = 1;
    imfor(i, s.size()) {
        if (i < a) {
            if (s[i] < '0' || '9' < s[i]) {
                f = 0;
            }
        }
        else if (i == a) {
            if (s[i] != '-') {
                f = 0;
            }
        }
        else {
            if (s[i] < '0' || '9' < s[i]) {
                f = 0;
            }
        }
    }
    if (f == 1) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import sys,math,collections,itertools
input = sys.stdin.readline
m=10**9+7
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

def factorization(n):
    arr = []
    temp = n
    i=2
    if temp%i==0:
        cnt=0
        while temp%i==0:
            cnt+=1
            temp //= i
        arr.append([i, cnt])
            
    for i in range(3, int(-(-n**0.5//1))+1,2):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])    

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N=int(input())
A=list(map(int,input().split()))
d = collections.defaultdict(int)
for a in A:
    arr = factorization(a)
    for ar in arr:
        if d[ar[0]]<ar[1]:
            d[ar[0]]=ar[1]

gcd = 1
for key,val in d.items():
    gcd = gcd*pow(key,val)

ans = 0
for a in A:
    ans = ans+gcd//a
print(ans%m)


Measured memory_bytes: 10612
x = gets.to_i

puts (1..10 ** 16).bsearch{|n| 
if n % 2 == 1  then 
    a = 6 * ((n/2)+1) + 5 * (n/2)
else n % 2 == 0 
     a = 6 * (n/2) + 5 * (n/2) 
    end
a >= x}


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();
        String[] ar = name.split("");
        for (int i = 0; i < 3; i++) {
            System.out.print(ar[i]);
        }
    }
}

Measured memory_bytes: 35684
#include<iostream>
#include<map>

int main(void){
    int n;
    std::cin >> n;
    // std::vector<int> a(n), b(n);
    std::multimap<int, int> mp;
    int a, b;
    for(int i = 0; i < n; i++){
        std::cin >> a >> b;
        mp.insert(std::make_pair(b, a));
    }
    int cur = 0;
    for(auto i = mp.begin(); i != mp.end(); i++){
        cur += i->second;
        if(cur > i->first){
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    std::cout << "Yes" << std::endl;
    return 0;
}

Measured memory_bytes: 12944
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    const int a = 100001;
    int s[a] = {};
    for(int i = 0;i < n;i++)
    {
        int x;
        cin >> x;
        s[x]++;
    }
    int max = 0;
    for(int i = 0;i < a - 2;i++)
    {
        if(s[i] + s[i + 1] + s[i + 2] > max)
        {
            max = s[i] + s[i + 1] + s[i + 2];
        }
    }
    cout << max;

    return 0;
}

Measured memory_bytes: 640
class Segtree:
    def __init__(self, original, func, element):
        self.n = len(original)
        self.element = element
        self.func = func
        self.N0 = 1 << (n-1).bit_length()
        self.seg = [element]*(self.N0 << 1)
        for i, j in enumerate(original, self.N0):
            self.seg[i] = j
        for i in range(self.N0-1, 0, -1):
            self.seg[i] = func(self.seg[2*i], self.seg[2*i+1])

    def get(self, i):
        return self.seg[i+self.N0]
        
    def update(self, i, x):
        i += self.N0
        self.seg[i] = x
        while i > 1:
            y = self.seg[i ^ 1]
            i >>= 1
            x = self.func(x, y)
            self.seg[i] = x
                
    def query(self, l, r):
        res = self.element
        l += self.N0
        r += self.N0
        while l < r:
            if r & 1:
                res = self.func(res, self.seg[r-1])
            if l & 1:
                res = self.func(res, self.seg[l])
                l += 1
            l >>= 1
            r >>= 1
     
        return res

    
import sys
input = sys.stdin.readline
from fractions import gcd
n = int(input())
A = list(map(int, input().split()))
seg = Segtree(A, gcd, 0)
ans = 0
for i in range(n):
  left = seg.query(0, i)
  right = seg.query(i+1, n)
  temp = gcd(left, right)
  ans = max(ans, temp)
print(ans)

Measured memory_bytes: 87272
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int INF = 2e9;
const ll INFLL = 4e18;
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int main() {
//	freopen(".in","r",stdin);freopen(".out","w",stdout);
	int n;
	ll ans=0;
	sd(n);
	for(int i = 1; i <= n; i++){
		ll calc=i;calc*=i+1;calc>>=1;
		ans+=calc;
	}
	int a,b;
	for(int i = 1; i < n; i++){
		sd(a);sd(b);
		if(a>b) swap(a,b);
		ll calc=a;calc*=n+1-b;
		ans-=calc;
	}
	plld(ans);
	return 0;
}

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

int main()
{
	long get ;
	
	while( cin >> get )
	{
		if( get == 0 ) break ;

		int sum = 0 ;
		for( int i = 5 ; i <= get ; i *= 5 )
		{
			sum += (get/i) ;
		}
		cout << sum << endl ;
	}

	return 0 ;
}

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

int main() {
  int N;
  cin >> N;
  map<string, ll> cnt;
  for (int i = 0; i < N; ++i) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    cnt[s]++;
  }
  ll ans = 0;
  for (pair<string, ll> p : cnt) {
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;

int main(){
	string s; cin >> s;
	rep(i, s.size()) if ((i + 1) % 2) cout << s[i];
	return 0;
}

Measured memory_bytes: 512
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(m)]
f=set([ft[1] for ft in ab if ft[0]==1])
t=set([ft[0] for ft in ab if ft[1]==n])
if f&t: print("POSSIBLE")
else: print("IMPOSSIBLE")

Measured memory_bytes: 60288
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using ll=long long;
using namespace std;

template<typename T>
class BIT{
private:
    int n;
    vector<T> d;
public:
    BIT(int m){
        n=m;
        for(int i=0;i<n;i++){
            d.push_back(0);
        }
    }
    void add(int i,T x){
        for(i++;i<=n;i+=i&-i){
            d[i]+=x;
        }
    }
    T sum(int i) {
        T x = 0;
        for (i++; i; i -= i&-i) {
            x += d[i];
        }
        return x;
    }
    T sum(int l, int r) {
        return sum(r-1) - sum(l-1);
    }
};

int main(){
    int N,Q;
    cin>>N>>Q;
    vector<queue<int>> place(N+1);
    vector<int> c(N);
    for(int i=0;i<N;i++){
        cin>>c[i];
        c[i]--;
        place[c[i]].push(i);
    }

    vector<vector<pair<int,int>>> q(N);
    int a,b;
    for(int i=0;i<Q;i++){
        cin>>a>>b;
        a--;b--;
        q[a].push_back({b,i});
    }

    vector<int> ans(Q);
    BIT<int> bit(N+1);
    for(int i=0;i<N;i++){
        if(!place[i].empty()){
            bit.add(place[i].front(),1);
            place[i].pop();
        }
    }

    for(int i=0;i<N;i++){
        for(auto p:q[i]){
            ans[p.second]=bit.sum(i,p.first+1);
        }

        if(!place[c[i]].empty()){
            bit.add(place[c[i]].front(),1);
            place[c[i]].pop();
        }
    }

    for(auto p:ans){
        cout<<p<<endl;
    }

    return 0;
}

Measured memory_bytes: 368840