akhauriyash/Code-Regression huggingface dataset:
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
/**************************************************************************/
const int N = 1e5+5;
int mod = 1e9+7;
int mul(int a,int b)
{
    return ((a%mod)*(b%mod))%mod;
}
int add(int a,int b)
{
    return ((a%mod)+(b%mod))%mod;
}
int sub(int a,int b)
{
    return ((a%mod)-(b%mod)+mod)%mod;
}
int power(int a,int b)
{
    int res = 1;
    while(b>0)
    {
        if(b&1)
            res = mul(res,a);
        b = b/2;
        a = mul(a,a);
    }
    return res;
}
signed  main()
{
    fast;
    int n;
    cin>>n;
    int a[n+1],b[n+1],c[n];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        cin>>b[i];
    for(int i=1;i<=n-1;i++)
        cin>>c[i];
    int ans = b[a[1]];
    if(a[2]-a[1]==1)
        ans+=c[a[1]];
    //cout<<ans<<endl;
    for(int i=2;i<=n;i++)
    {
        ans+=b[a[i]];
        if(i+1<=n && a[i+1]-a[i]==1)
        {
            ans+=c[a[i]];
        }
    }
    cout<<ans;
}   

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

signed main() {
  string S;
  cin >> S;
  for(int i=1; i<S.size(); i+=2) if(S[i]=='R') {puts("No"); return 0;}
  for(int i=0; i<S.size(); i+=2) if(S[i]=='L') {puts("No"); return 0;}
  puts("Yes");
}


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const A = arg[1].split(" ").map(n=>parseInt(n)).sort((a,b)=>b-a);
    
    let answer = 0;
    
    answer += A[0];
    let cnt = 1;

    
    for(let i=1; i<N-1; i++) {
        
        answer += A[i];
        cnt++;
        if(cnt >= N-1) break;
        
        answer += A[i];
        cnt++;
        if(cnt >= N-1) break;
        
        // console.log("cnt:" + cnt);
        // console.log("A[i]:" + A[i]);
        // console.log("answer:" + answer);
        // console.log("----")
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 53060
X, N = map(int, input().split())
if X <= 50:
  l = X
  d = 0
else:
  l = 101 - X
  d = 101

if N == 0:
  print(X)
  exit()
elif N == 100:
  print(d)
  exit()
else:
  p = set(map(int, input().split()))

for i in range(100):
  if i+1 not in p:
    li = abs(X-i-1)
    if li < l:
      l = li
      d = i+1
    elif li == l:
      if i+1 < d:
        d = i+1
    elif li > l:
      break
print(d)

Measured memory_bytes: 9164
#include <cstdio>
#include <vector>
using namespace std;

int main()
{
  int N, Y;
  scanf("%d %d", &N, &Y);
  bool ok = false;
  int x, y, z;
  for (x = 0; x <= N; x++)
  {
    for (y = 0; x+y <= N; y++)
    {
      z = N - x -y;
      if(x*10000+y*5000+z*1000==Y){
        ok=true;
        break;
      }
    }
    if(ok)break;
  }

  if (ok)
  {
    printf("%d %d %d\n", x, y, z);
  }
  else
  {
    printf("-1 -1 -1\n");
  }
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }


// global
int N, K;
vector<vector<int>> G;
vector<int> visited;
vector<int> one, two;
int ans;

int calc_two(int v, int parent, vector<int>& visited) {
	int ret = 0;
	ret++;
	for (int t : G[parent]) {
		if (visited[t] != 0) ret++;
	}
	return ret-1;	// 自身を除く
}

void bfs(vector<int>& visited) {
	queue<int> q;
	q.push(0);
	visited[0] = 1;

	while (!q.empty()) {
		int p = q.front(); q.pop();

		int c = 0;
		for (int v : G[p]) {
			if (visited[v] == 0) {
				q.push(v);
				visited[v] = 1;

				// vから距離2以内ですでに訪れた頂点数
				int cnt;
				if (p == 0) {
					cnt = c + 1;
				}else
					cnt = c+2;// calc_two(v, p, visited);
//				cerr << v << " " << cnt << endl;
				ans *= K - cnt;
				ans %= mod;

				c++;

			}
		}
	}
}


signed main() {

	cin >> N >> K;
	visited.assign(N, 0);
	G.assign(N, vector<int>());
	one.assign(N, 0);
	two.assign(N, 0);

	rep(i, N - 1) {
		int a, b;
		cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	ans = K;	// 頂点0
	bfs(visited);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 9716
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

import static java.util.Comparator.reverseOrder;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> aList = new ArrayList();
        for (int i = 1; i <= n; i++) {
            aList.add(sc.nextInt());
        }
        List<Integer> sortedList = aList.stream().sorted(reverseOrder()).collect(Collectors.toList());
        int max = sortedList.get(0);

        for (int i = 0; i < n; i++) {
            int tempA = aList.get(i);
            if (tempA == max) {
                System.out.println(sortedList.get(1));
            } else {
                System.out.println(max);
            }
        }
    }
}

Measured memory_bytes: 68844
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		long sum = 0;
		for(int i = 1; i < a+1; i++) {
			if(i % 3 == 0 || i % 5 == 0) {}
			else sum += i;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 35756
#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--)
using namespace std;
typedef long long ll;
const ll INF = 1e15;
int main() {
  ll n;
  cin >> n;
  ll mx, sum = 0;
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  FOR(i, 1, n) {
    sum += i;
    if (sum < n && n <= sum + i + 1) {
      mx = i + 1;
      sum += mx;
      break;
    }
  }
  ll diff = sum - n;
  FOR(i, 1, mx + 1) {
    if (i == diff) continue;
    cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 256
D = 1_000_000_000
H, W, N = gets.split.map(&:to_i)

h = Hash.new(0)
N.times do
  a, b = gets.split.map(&:to_i)
  ((a - 1)..(a + 1)).each do |i|
    ((b - 1)..(b + 1)).each do |j|
      next if i <= 1 || i >= H || j <= 1 || j >= W
      h[D * i + j] += 1 
    end
  end
end

c = h.values.inject(Array.new(10, 0)) {|a, v| a[v] += 1; a}
c[0] = (H - 2) * (W - 2) - c.inject(:+)
puts c

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

int main() {

  int H,W,K;

  cin >>H>>W>>K;
  char c[H][W];
  

  for (int i = 0; i < H; i++) {
    for(int j=0;j<W;j++){
      cin>>c[i][j];
      
    }
  }
  int ans=0;
  int n=H+W;
  int count;
  for (int bit = 0; bit < (1<<n); bit++) {
    count=0;
   for(int i=0;i<H;i++){
     int a= bit & (1<<i);
     int b=(1<<i);
     if(a==b){
       for(int j=0;j<W;j++){
         int x=bit & (1<<H+j);
         int y=(1<<H+j);
         if(x==y){
          if(c[i][j]=='#'){
 
            count=count+1;
          }
         }
       }//forj

     }//if
   }//for i
   
    
    if(count == K){
      ans=ans+1;
  }
   }//bitfor
   cout<<ans<<endl;
 return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int A,B,K;
  cin>>A>>B>>K;
  //AもBも割り切る正整数を小さい順に求めていく
  int count=0;
  for(int i=min(A,B);i>=1;i--){
    if(A%i==0&&B%i==0) count++;
    if(count==K) {
      cout<<i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int H,W;
int A[511][511];
bool used[511][511];
typedef pair<LL,LL>P;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
bool check(int x,int y){
	if(x<0)return false;
	if(x>=H)return false;
	if(y<0)return false;
	if(y>=W)return false;
	return true;
}

P dfs(int x,int y){
	if(used[x][y]==true)return P(0,0);
	used[x][y]=true;
	P p=P(0,0);
	if(A[x][y]==0){
		p.first++;
	}else{
		p.second++;
	}
	REP(i,4){
		int xx=x+dx[i];
		int yy=y+dy[i];
		if(check(xx,yy)){
			if(A[x][y]!=A[xx][yy]){
				P pp=dfs(xx,yy);
				p.first+=pp.first;
				p.second+=pp.second;
			}
		}
	}
	return p;
}

int main(){
	cin>>H>>W;
	REP(i,H){
		REP(j,W){
			used[i][j]=false;
		}
	}
	REP(i,H){
		string S;
		cin>>S;
		REP(j,W){
			if(S[j]=='.'){
				A[i][j]=0;
			}else{
				A[i][j]=1;
			}
		}
	}
	LL ans=0;
	REP(i,H){
		REP(j,W){
			if(used[i][j]==false){
				P p=dfs(i,j);
				//cout<<i<<j<<p.first<<p.second<<endl;
				ans+=p.first*p.second;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 13696
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION cout<<fixed; cout<<setprecision(20);
  
using namespace std;
 
const ll inf = 1e17;
const ll N = 3500;
const ll bits = 30;
const ll mod = 1e9+7;

ld dp[N][N];



int main(){
    FASTIO;
    PRECISION;
    
    ll n;
    cin>>n;
    vector<ld>arr(n+1);

    for(ll i=1;i<=n;i++){
        cin>>arr[i];
    }

    dp[0][0] = 1;

    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=i;j++){
            dp[i][j] += arr[i] * dp[i-1][j-1];
        }

        for(ll j=0;j<=i;j++){
            dp[i][j] += (1-arr[i]) * dp[i-1][j];
        }
    }

    ld sum = 0;

    // for(ll i=0;i<=n;i++){
    //     for(ll j=0;j<=i;j++){
    //         cout<<dp[i][j]<<" ";
    //     }

    //     cout<<"\n";
    // }

    for(ll i=(n+1)/2;i<=n;i++){
        sum+=dp[n][i];
    }

    cout<<sum<<"\n";

    


}

Measured memory_bytes: 164352
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 100000 + 50;
const ll INF = (1ll<<60);
struct nod{
    int to, cost;
    nod(int a=0,int b=0){to = a; cost = b;}
};
int dep[maxn], se[maxn*2], no[maxn*2], fir[maxn], st[maxn*2][20], lo[200005];
int pre[maxn], size[maxn];
vector<nod> g[maxn];
int n, m;
int cnt, sum;

void Init(){
    for(int i = 0; i <= n; i++)
        {
            g[i].clear();
            dep[i] = 0;
        }
    sum = cnt = 0;
}
void mkst(){
    for(int i = 0; i <= cnt; i++) st[i][0] = se[i];
    for(int j = 1; (1<<j) <= cnt; j++)
        for(int i = 1; i <= cnt-(1<<j)+1; i++)
            st[i][j] = min(st[i][j-1], st[i+(1<<(j-1))][j-1]);
}

void dfs(int u, int f, int di){
	pre[u] = f;
    dep[u] = di;
    no[++sum] = u;
    int t = sum;
    se[++cnt] = t;
    fir[u] = cnt;//
   /* for(auto p : g[u])
    {
        if(p.to == f) continue;
        dfs(p.to, u, di+p.cost);
        se[++cnt] = t;
    }*/
    for(int i = 0; i < g[u].size(); i++)
    {
        if(g[u][i].to == f) continue;
        dfs(g[u][i].to, u, di+g[u][i].cost);
        se[++cnt] = t;
 
    }

}
int find(int p, int q){
    if(p > q) swap(p, q);
    int j = lo[q-p+1];
    return min(st[p][j],st[q-(1<<j)+1][j]);
}
int cal(int x, int y){
    int now = no[find(fir[x], fir[y])];
    return dep[x] + dep[y] -2*dep[now];
}
int cnt1 = 1;
void dfs1(int p, int f){
	for(int i = 0; i < g[p].size(); i++)
    {
        if(g[p][i].to == f) continue;
        dfs1(g[p][i].to, p);
        cnt1++;
 
    }
}
int main(){
//freopen("input.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
 	lo[1] = 0;
    for(int i = 2; i <= 200000; i++) lo[i] = lo[i>>1]+1; 
    while(scanf("%d", &n) != EOF){
    	cnt1 = 1;
        Init();
        for(int i = 1; i <= n - 1; i++)
        {
            int  x, y;
            scanf("%d%d", &x, &y);
            g[x].push_back({y, 1});
            g[y].push_back({x, 1});
        }
        dfs(1,0,0); mkst();
        int len = cal(1,n);
        if(len % 2 != 0) len/=2;
        else len = (len - 1) / 2;
        int s = n;
        while(len--) s = pre[s];
        dfs1(s,pre[s]);
        if(cnt1 >= n-cnt1){
        	cout << "Snuke" <<endl; 
        }
        else cout << "Fennec" << endl;
	}
    return 0;
}

Measured memory_bytes: 32896
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

// template from zscoder

int d[10];

bool br(int x)
{
    int y = x%10;
    if(d[y]==1)return false;
    x/=10;
    //cout << x << " " << y << endl;
    if(x>0)br(x);
    else return true;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    ll n,k;
    cin >> n >> k;
    int p;
    for(int i = 0; i < k; i++)
    {
        cin >> p;
        d[p]++;
    }
    bool f = false;
    while(!f)
    {
        //cout << n << endl;
        if(br(n))
        {
            f = true;
            cout << n << endl;
        }
        else n++;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
	int n;
	int aji[200];
	int l;
	int ans = 0;
	int aans = 0;
	cin >> n >> l;
	LOOP(i,n){
		aji[i] = l+i;
		if((aji[ans]>0 ? aji[ans] : -aji[ans]) > (aji[i]>0 ? aji[i] : -aji[i])){
			ans = i;
		}
		aans += aji[i];
	}
	// cerr << aans << " " << aji[ans] << endl;
	cout << aans - aji[ans]	;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define MOD (long int)10e9 + 7

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

    cout << (ceil(c/b) <= ceil(a/d) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int x, y;
    cin >> x >> y;

    int b = 0;
    for (int i = 0; i <= x; i++) {
        if (i * 2 + (x - i) * 4 == y) b = 1;
    }

    cout << (b ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3632
#! env python
# -*- coding: utf-8 -*-

import os
import sys


# ac_py.main
# Date: 2020/06/14
# Filename: main 
# Author: acto_mini

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

    print((b // x) - ((a - 1) // x))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n,d;
    cin>>n;
    d=n;
   ll c=n%10;
     c=(c*10+c)*10+c;
     //cerr<<"c "<<c<<endl;
    // cout<<700%10<<" "<<700%100<<" "<<700%1000<<endl;
     while(d%10!=(d/10)%10   ||  d%10!=(d/100)%10 ||(d/10)%10!=(d/100)%10)
     {
      d++;
      //cerr<<c<<endl;
     }
     cout<<d<<endl;
    
    
}
return 0;
}


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

int main(){
  int N; cin >>N;
  vector<int> a(N);
  rep(i,0,N) cin >>a[i];
  sort(a.begin(),a.end());
  cout <<a.back()-a.front() <<endl;
  return 0;
}


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

int main(){
	int input = -1;
	int i = 0;

	while (true){
		cin >> input;
		i++;
		if(input == 0){
			break;
		}else if(1 <= input && input <= 10000){
			cout << "Case" << " " << i << ":" << " " << input << endl;
		}else{
			cout << "error" << endl;
			break;
		}
	}
	return 0;

}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
long long n,ans=0;
int main(){
	scanf("%lld",&n);
	long long sn=sqrt(n);
	for(int i=1;i<=sn;i++){
		if(n%i==0){
			long long a=i,b=n/i;
			if(b>2&&b-1>a) ans+=b-1ll;
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long INT;
double PI = 3.14159265;
using namespace std;
using Graph = vector<vector<int>>;
using Field = vector<string>;
using DGraph = vector<vector<pair<int, int>>>;

const long long INF = 1LL << 60;
//---//

int main() {
	bool j=0;
	int k, a, b;
	cin >> k >> a >> b;

	for (int i = a; i <= b; i++)if (i%k==0)j = 1;
	if (j==1)cout << "OK" << endl;
	else cout << "NG" << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    vll h(n);
    for (ll i = 0; i < n; i++) cin >> h[i];
    sort(ALL(h));
    ll ans = HIGHINF;
    for (ll i = k - 1; i < n; i++) chmin(ans, h[i] - h[i - k + 1]);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main(void){
  int a, b;
  cin >> a >> b;
  if(a%2==0 || b%2==0){cout << "Even"  << endl;}
  else cout << "Odd" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int a, b, c;    

    std::cin >> a;
    std::cin >> b;
    std::cin >> c;

    for (int i = 0; i < 101*50; i++) {
        if ( (i * b + c) % a == 0 ) {
            std::cout << "YES" << std::endl;
            return 0;
        }
    }

    std::cout << "NO" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#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(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	set<int> st;
	rep(i, 0, N) {
		int a; cin >> a;
		if (st.count(a))
			st.erase(a);
		else
			st.emplace(a);
	}
	cout << st.size() << endl;
	return 0;
}

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

#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {0, -1, 0, 1, 1, 1, -1, -1};
int dy[] = {-1, 0, 1, 0, 1, -1, 1, -1};

struct Edge {
  int to;
  i64 cost;
  Edge(int to, int cost) : to(to), cost(cost) {}
};

vvt<Edge> edge(1500);
vt<i64> dist(1500, LINF);
vt<bool> neg(1500, false);

void bellman_ford(int n, int s) {
  dist[s] = 0;

  rep(i, 0, n) {
    rep(v, 0, n) {
      for(auto nxt : edge[v]) {
        Edge e = nxt;
        if(dist[v] == LINF) continue;

        if(dist[e.to] > dist[v] + e.cost) {
          neg[e.to] = true;
          dist[e.to] = dist[v] + e.cost;
        }

        if(neg[v]) neg[e.to] = true;
      }
    }
  }
}

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

  int n, m;
  cin >> n >> m;
  rep(i, 0, m) {
    int a, b;
    i64 c;
    cin >> a >> b >> c;
    a--; b--;
    edge[a].push_back(Edge(b, -c));
  }

  bellman_ford(n, 0);
  i64 ans = -dist[n - 1];

  rep(i, 0, n) neg[i] = false;
  bellman_ford(n, 0);

  if(neg[n - 1]) cout << "inf\n";
  else cout << ans << endl;
}


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

int main(){
	int N;
    cin >> N;
    string s = "";
    cin >> s;
    int numR = 0;
    int numB = 0;
    for(int i=0;i<N;i++){
        if(s[i]=='R'){
            numR++;
        }
        else{
            numB++;
        }
    }
    if(numR > numB){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mii;
#define pb push_back

/*int pare(int en,int start,int par[])
{
	if(par[en]==start)
	{
		return en;
	}
	pare(par[en],start,par);
}*/

int main()
{
    int tst=1;
    //scanf("%d",&tst);
    while(tst--)
    {
        int n,m,i,j,c=0;
        cin >> n >> m;
        vector<int>g[n+1],v;
        for(i=0; i<m; i++)
        {
            int n1,n2;
            cin >> n1 >> n2;
            g[n1].pb(n2);
            g[n2].pb(n1);
        }

        bool vis[n+1];
        int par[n+1];
        memset(vis,false,sizeof(vis));
        queue<int>q;
        q.push(1);
        vis[1]=true;
        while(!q.empty())
        {
            int top=q.front();
            q.pop();
            for(j=0; j<(int)g[top].size(); j++)
            {
                int tt=g[top][j];
                if(vis[tt]==false)
                {
                    vis[tt]=true;
                    par[tt]=top;
                    q.push(tt);
                }
            }
        }
        for(i=1; i<=n; i++)
        {
            if(vis[i]==false)
            {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        for(i=2; i<=n; i++)
        {
            cout << par[i] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 10512
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
using std::min; using std::max;
using std::swap; using std::sort;
using std::set;
typedef long long ll;
typedef std::pair<int, int> pii;

template<typename T>
void read(T &x) {
	int flag = 1; x = 0; char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') flag = -flag; ch = getchar(); }
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= flag;
}

const int _ = 1e5 + 10;
const int dx[30] = {0,
					-2, -1, 0, 1, 2,
					-2, -1, 0, 1, 2,
					-2, -1, 0, 1, 2,
					-2, -1, 0, 1, 2,
					-2, -1, 0, 1, 2};
const int dy[30] = {0,
					2, 2, 2, 2, 2,
					1, 1, 1, 1, 1,
					0, 0, 0, 0, 0,
					-1, -1, -1, -1, -1,
					-2, -2, -2, -2, -2};
ll h, w, n; int now; int v[30];
struct node { int x, y; } p[_];
ll r[10];
set<pii> S;

bool f(int dx, int dy) {
	int x = p[now].x + dx, y = p[now].y + dy;
	return S.find((pii){x, y}) != S.end();
}

bool chk(int x, int y) {
	return x >= 1 && y >= 1 && x <= h && y <= w;
}

int main () {
	read(h), read(w), read(n);
	for(int i = 1; i <= n; ++i) {
		read(p[i].x), read(p[i].y);
		S.insert((pii){p[i].x, p[i].y});
	}
	for(int i = 1; i <= n; ++i) {
		now = i;
		for(int j = 1; j <= 25; ++j) v[j] = f(dx[j], dy[j]);
		if(chk(p[now].x - 2, p[now].y + 2) && chk(p[now].x, p[now].y))
		++r[v[1] + v[2] + v[3] + v[6] + v[7] + v[8] + v[11] + v[12] + v[13]];
		
		if(chk(p[now].x - 1, p[now].y + 2) && chk(p[now].x + 1, p[now].y))
		++r[v[2] + v[3] + v[4] + v[7] + v[8] + v[9] + v[12] + v[13] + v[14]];
		
		if(chk(p[now].x, p[now].y + 2) && chk(p[now].x + 2, p[now].y))
		++r[v[3] + v[4] + v[5] + v[8] + v[9] + v[10] + v[13] + v[14] + v[15]];
		
		if(chk(p[now].x - 2, p[now].y + 1) && chk(p[now].x, p[now].y - 1))
		++r[v[6] + v[7] + v[8] + v[11] + v[12] + v[13] + v[16] + v[17] + v[18]];
		
		if(chk(p[now].x - 1, p[now].y + 1) && chk(p[now].x + 1, p[now].y - 1))
		++r[v[7] + v[8] + v[9] + v[12] + v[13] + v[14] + v[17] + v[18] + v[19]];
		
		if(chk(p[now].x, p[now].y + 1) && chk(p[now].x + 2, p[now].y - 1))
		++r[v[8] + v[9] + v[10] + v[13] + v[14] + v[15] + v[18] + v[19] + v[20]];
		
		if(chk(p[now].x - 2, p[now].y) && chk(p[now].x, p[now].y - 2))
		++r[v[11] + v[12] + v[13] + v[16] + v[17] + v[18] + v[21] + v[22] + v[23]];
		
		if(chk(p[now].x - 1, p[now].y) && chk(p[now].x + 1, p[now].y - 2))
		++r[v[12] + v[13] + v[14] + v[17] + v[18] + v[19] + v[22] + v[23] + v[24]];
		
		if(chk(p[now].x, p[now].y) && chk(p[now].x + 2, p[now].y - 2))
		++r[v[13] + v[14] + v[15] + v[18] + v[19] + v[20] + v[23] + v[24] + v[25]];
	}
	r[0] = (h - 2) * (w - 2);
	for(int i = 1; i <= 9; ++i) r[i] /= i, r[0] -= r[i];
	for(int i = 0; i <= 9; ++i) printf("%lld\n", r[i]);
	return 0;
} 


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

int main() {
	// your code goes here
	int a[100];
	int N;
	int cnt=0;
	cin >> N;
	
	for(int i=0;i<N;i++){
		cin >> a[i] ;
	}
	
	for(int i=0;i<N;i++){
		for(int j=N-1;j>=i+1;j--){
			if(a[j]<a[j-1]){
				swap(a[j],a[j-1]);
				cnt++;
			}
		}
	}
	for(int i=0;i<N-1;i++){
		cout << a[i] << " " ;
	}
	cout << a[N-1];
	cout << endl << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 3108
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;

int main(int argc, char* argv[]){
  long long int a,b,c;
  long long int ans = 0;
  cin >> a >> b >> c;
  if(a+b >= c)ans = b + c;
  else ans = min(a+2*b+1,b+c);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll dp[51][2501][51];
ll  n,a;
int main(){
	cin >> n >> a;

	REP(i,2501) {
		REP(j,n+1)
		dp[0][i][j] = 0;
	}
	dp[0][0][0] = 1;

	REP(i,n) {
		ll x;
		cin >> x;
		REP(j,2501) {
			REP(k,n + 1) {
				dp[i + 1][j][k] += dp[i][j][k];
				if(j + x < 2501 && k < n)
					dp[i + 1][j + x][k + 1] += dp[i][j][k];
			}
		}
	}

	ll ans = 0;
	REP(j,2501) {
		REP(k,n + 1) {
			if(k > 0 && j % k == 0 && j / k == a)
				ans += dp[n][j][k];
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 51072
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
signed main() {
	int n;
	while (cin >> n, n) {
		int ans1, ans2;
		for (int i = 1; i * (i + 1) / 2 <= n; i++) {
			if ((n - i * (i + 1) / 2) % i == 0) {
				ans1 = (n - i * (i + 1) / 2) / i + 1;
				ans2 = i;
			}
		}
		cout << ans1 << ' ' << ans2 << endl;
	}
}


Measured memory_bytes: 3084
@w,@h,@n = gets.chomp.split.map(&:to_i)
arr = Array.new(@w * @h) { 0 }
@n.times { |n|
  x, y, a = gets.chomp.split.map(&:to_i)
  case a
  when 1
    0.upto(@h - 1) { |h|
      0.upto(x - 1) { |xi|
        arr[h * @w + xi] = 1; 
      }
    }
  when 2
    0.upto(@h - 1) { |h|
      x.upto(@w - 1) { |xi|
        arr[h * @w + xi] = 1; 
      }
    }
  when 3
    0.upto(y * @w -1) { |i|
      arr[i] = 1;
    }
    
  when 4
    (y * @w).upto(@w * @h - 1) { |i|
      arr[i] = 1
    }
  end
}
puts arr.count(0)

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

ll n;
struct node{
	ll sum,value;
}first[100010],second[100010];

inline ll read(){
    ll x=0,tmp=1;
    char ch=getchar();
    while(!isdigit(ch)){
        if(ch=='-') tmp=-1;
        ch=getchar();
    }
    while(isdigit(ch)){
        x=(x<<3)+(x<<1)+ch-48;
        ch=getchar();
    }
    return tmp*x;
}

inline bool cmp(node a,node &b){
    return a.sum>b.sum;
}
 
int main(){
	n=read();
	for(ll i=1; i<=n; i++){
        ll x=read();
		if(i&1){
            first[x].sum++;
            first[x].value=x;
        }
		else{
            second[x].sum++;
            second[x].value=x;
        }
	}
	
	sort(first+1,first+100001,cmp);
	sort(second+1,second+100001,cmp);
	if(first[1].value!=second[1].value) printf("%lld\n",n-first[1].sum-second[1].sum); 
	else printf("%lld\n", n-max(first[1].sum+second[2].sum,first[2].sum+second[1].sum));
	
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main(void) {
	int n, ans = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	// your code goes here
	int a,b,n;
	cin >> a >> b >> n;
	for(int i=0; i!=n; i++){
		if(i % 2 == 0){
			if(a % 2 == 0){
				a = a / 2;
				b = b + a;
			}else{
				a = a - 1;
				a = a / 2;
				b = b + a;
			}
		}else{
			if(b % 2 == 0){
				b = b / 2;
				a = a + b;
			}else{
				b = b - 1;
				b = b / 2;
				a = a + b;
			}
		}
	}
	
	cout << a << ' ' << b << '\n';
	
	return 0;
}

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

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

	for(i=1;i<=n;i++){
		if(i % 3 == 0){
			cout << " " << i;
		} else {
			x = i;
			while( x != 0){
				if(x % 10 == 3){
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}

	cout << endl;

	return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var S = Console.ReadLine();

        for (int i = 0; i < S.Length; i++)
        {
            if (i % 2 == 0)
            {
                if (S[i] == 'L')
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            else
            {
                if (S[i] == 'R')
                {
                    Console.WriteLine("No");
                    return;
                }
            }
        }

        Console.WriteLine("Yes");
    }
}


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

#define ln '\n'
#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 FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

const int MOD = (int)1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    VI dp(n + 1, 0);
    REP(i, m) {
        int a;
        cin >> a;
        dp[a] = -1;
    }

    dp[0] = 1;
    dp[1] = dp[1] == -1 ? -1 : 1;
    FOR(i, 2, n) {
        if (dp[i] == -1) continue;
        if (dp[i - 1] != -1) dp[i] = (dp[i - 1] + dp[i]) % MOD;
        if (dp[i - 2] != -1) dp[i] = (dp[i - 2] + dp[i]) % MOD;
    }
    
    cout << dp[n] << ln;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define PI acos(-1)
#define int long long int
#define MOD (ll) (1e9+7)
#define in_arr(ar) for(int i=0;i<sizeof(ar)/sizeof(ar[0]);i++)cin>>ar[i];
#define val(x) cout<<"Value of "<<(#x)<<" is "<<x<<endl;




//ll bigmod(ll a, ll e)
//{
//    ll ret = 1LL;
//    while (e>0)
//    {
//        if (e%2==1) ret = ret * a % MOD;
//        a = a*a % MOD;
//        e/=2;
//    }
//    return ret;
//}

int vis[1000000];

int solve()
{
    char ch;
    cin>>ch;
    if('a'<=ch&&ch<='z')
    {
        cout<<'a'<<endl;
    }
    else
    {
        cout<<"A"<<endl;
    }

    return 0;
}


main()
{
    int t=1;
//    cin>>t;
    while(t--)
    {
        int x = solve();
    }
//    return 0;
}


Measured memory_bytes: 3624
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

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

Measured memory_bytes: 3188
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=2005;
map<int,vector<int> >adj;
int n,k,q;
int vis[M];
int a[M];
set<int>s[M];
int home[M];
 main()

{
    fast
    cin>>n>>k>>q;
    f(i,1,n)
    {
        cin>>a[i];
        adj[a[i]].pb(i);
    }
    int ses=inf;
    vis[n+1]=1;
    adj[0].pb(0);
    for(auto tmp:adj)
    {
        vector<int>idx=tmp.si;
        int x=tmp.fi;
        for(auto id:idx)
        {
            vis[id]=1;
        }
        int cur=0;
        s[cur].clear();
        priority_queue< pi , vector<pi> , greater<pi> > pq;
        f(i,1,n+1)
        {
            if(vis[i])
            {
                if(s[cur].size()!=0)
                {
                    cur++;
                    s[cur].clear();
                }
            }
            else
            {
                s[cur].insert(i);
                home[i]=cur;
                pq.push(mp(a[i],i));
            }
        }
        int tq=q;
        int last=-1;
        int fst;
        while(!pq.empty())
        {
            int z=pq.top().fi;
            int ii=pq.top().si;
            //cout<<z<<" "<<ii<<endl;
            ii=home[ii];
            pq.pop();
            if(s[ii].size()<k)continue;
            s[ii].erase(s[ii].begin());
            tq--;
            if(last==-1)fst=z;
            last=z;
            if(tq==0)break;
        }
       // cout<<fst<<" # "<<last<<endl;
        if(tq==0)
        {
            ses=min(ses,last-fst);
        }
    }
    cout<<ses<<endl;
    return 0;
}



































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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

signed main() {
    int N;
    cin>>N;
    int ans=0;
    for(int i=1;i<=N;i++){
        int k=0,a=i;
        while(a>0)a/=10,k++;
        if(k%2==1)ans++;
    }
    cout<<ans<<endl;
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    map<int, bool> dic;
    int N;
    cin >> N;
    REP(i, N) {
        int a;
        cin >> a;
        if(dic[a]) {
            cout << "NO" << endl;
            return 0;
        }
        dic[a] = true;
    }
    cout << "YES" << endl;
    return 0;
}



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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)9e18);
const int ninf=((int)-9e18);
const int mod=1000000007;

using namespace std;

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","w",stdout);
    //FILE *fptr2=freopen("out.txt","w",stdout);


    int c,a,b;
    cin>>c>>a>>b;
    
    loop(i,a,b+1)
    {
        if(i%c==0)
        {
            cout<< "OK";
            return 0;
        }
    }
    
    cout<< "NG";



    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x, k, d; cin >> x >> k >> d;
  ll cnt = abs(x)/d;
  if(k <= cnt || (k-cnt)%2==0) {
    cout << abs(x)-d*min(cnt, k) << endk;
  } else {
    cout << abs(abs(x)-d*(cnt+1)) << endk;
  }
  return 0;
}


Measured memory_bytes: 3648
def main():
    s_i = input()
    n_i = int(input())
    ans = ""
    while True:
        if len(s_i) < n_i:
            if s_i != "":
               ans += s_i[0]
               break
            else:
                break
        else:
            ans += s_i[:n_i][0]
            s_i = s_i[n_i:]
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vll a(1LL << n);
    REP(i, 1LL << n) cin >> a[i];

    V< P<ll, ll> > dp(1LL << n);
    REP(i, 1LL << n) dp[i] = make_pair(a[i], 0);

    REP(j, n) {
        REP(i, 1LL << n) {
            if (i & (1LL << j)) {
                P<ll, ll> a = dp[i], b = dp[i & ~(1LL << j)];
                if (a.first > b.first) dp[i] = make_pair(a.first, max(a.second, b.first));
                else dp[i] = make_pair(b.first, max(b.second, a.first));
            }
        }
    }

    ll ans = 0;
    rep(i, 1, 1LL << n) {
        chmax(ans, dp[i].first + dp[i].second);
        cout << ans << '\n';
    }
    return 0;
}



Measured memory_bytes: 9216
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<int, int> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll N_MAX=1010;
  ll M_MAX=2010;
  ll N,M;

  cin >> N >> M;
  ll a[M_MAX],b[M_MAX],c[M_MAX];
  for(int i=0;i<M;i++){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    c[i]=-c[i];
  }
  ll dist[N_MAX];
  const ll INFA =1LL<<50;
  for(int i=0;i<N_MAX;i++){
    dist[i]=INFA;
  }
  dist[0]=0;

  for(int i=0;i<N-1;i++){
    for(int j=0;j<M;j++){
      if(dist[a[j]]==INFA)continue;
      if(dist[b[j]]>dist[a[j]]+c[j]){
        dist[b[j]]=dist[a[j]]+c[j];
      }
    }
  }

  ll ans=dist[N-1];

  for(int i=0;i<N-1;i++){
    for(int j=0;j<M;j++){
      if(dist[a[j]]==INFA)continue;
      if(dist[b[j]]>dist[a[j]]+c[j]){
        dist[b[j]]=dist[a[j]]+c[j];
      }
    }
  }
  if(ans!=dist[N-1]){
    cout << "inf" << endl;
  }else{
    cout << -ans << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
using namespace std;

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

	string ns = to_string(n);
	long a,b;
	long ma = pow(10, ((ns.length()%2 == 1)? ns.length()/2+1: ns.length()/2));
	for(int i=1; i<ma; i++){
		if(n%i == 0){
			a = i;
			b = n/i;
		}
	}

	string as,bs;
	as = to_string(a);
	bs = to_string(b);
	cout << max(as.length(), bs.length()) << endl;
}



Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N;

int main(){
	ll A,B,C;
	cin>>A>>B>>C;
	cout<<B+min(C,A+B+1)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[0].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    string S; cin >> S;
    int N = S.size();
    int ans = INF;

    int p[3] = {100, 10, 1};

    REP(i, N - 2){
        int tmp = 0;
        REP(j, 3) tmp += p[j] * (S[i + j] - '0');
        ans = min(ans, llabs(tmp - 753));
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 256