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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

#define MAX_N 110

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, M;
    cin >> N >> M;

    vector<ll> a(M), b(M), c(M);
    rep (i, M) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
    }

    ll d[MAX_N][MAX_N];
    rep (i, N) {
        rep (j, N) {
            if (i == j) {
                d[i][j] = 0;
            } else {
                d[i][j] = INF;
            }
        }
    }

    rep (i, M) {
        d[a[i]][b[i]] = min(d[a[i]][b[i]], c[i]);
        d[b[i]][a[i]] = min(d[b[i]][a[i]], c[i]);
    }

    rep (k, N) {
        rep (i, N) {
            rep (j, N) {
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }

    ll ans = M;
    rep (i, M) {
        bool flag = false;
        rep (j, N) {
            if (d[j][a[i]]+c[i] == d[j][b[i]]) {
                flag = true;
            }
        }
        if (flag) {
            ans--;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,mn=1000,p=0,dif=0;
    string a;
    cin>>a;
    for(i=0; i+2<a.size(); i++)
    {
        p=0;
        dif=0;
        p=p*10+(a[i]-'0');
        p=p*10+(a[i+1]-'0');
        p=p*10+(a[i+2]-'0');
        dif=abs(p-753);
        mn=min(mn,dif);
    }
        cout<<mn<<endl;




}


Measured memory_bytes: 3572
import queue
H,W = map(int, input().split())

s = list([list(input()) for i in range(H)])
dist = list([[-1 for j in range(W)] for i in range(H)])

q = queue.Queue()
q.put([0,0])
dist[0][0] = 0
s[0][0] = '0'

while q.empty() != True:
  x, y = map(int, q.get())
  for i in range(-1,2):
    for j in range(-1,2):
      if (i == 0 and (j == 1 or j == -1)) or (j == 0 and (i == 1 or i == -1)):
        nx = x + i
        ny = y + j
        if 0 <= nx < H and 0 <= ny < W and s[nx][ny] == '.' and dist[nx][ny] == -1:
          dist[nx][ny] = dist[x][y] + 1
          s[nx][ny] = str(dist[x][y] + 1)
          q.put([nx,ny])

dCount = set()
wallCount = 0
notShortest = 0
goal = dist[H-1][W-1]
for i in s:
  for j in range(len(i)):
    if i[j] =='#':
      wallCount += 1
    elif i[j] == '.':
      pass
    elif goal < int(i[j]):
      pass
    else:
      dCount.add(i[j])

if dist[H-1][W-1] != -1:
  print( H*W - wallCount - goal - 1)
else:
  print(-1)
# for i in s:
  # print("".join(i))


Measured memory_bytes: 4080
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


const int mod=1000000007;
//const int mod=998244353;
vvll dp;
vll v;
ll recur(int i, int j ,ll a){
    if(dp[i][j]==-1){
        if(i==j){
            return dp[i][i]=v[i];
        }
        else{
            return dp[i][j]=max(a-recur(i+1,j,a-v[i]),a-recur(i,j-1,a-v[j]));
        }
    }
    return dp[i][j];
}

int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r;
    cin >> n;
    dp.resize(n,vll(n,-1));
    v.resize(n);
    a=0;
    for(int i=0; i<n; i++){
        cin >> v[i];
        a+=v[i];
    }
    cout << 2*recur(0,(int)n-1,a) - a<< el;
    return 0;
}


Measured memory_bytes: 70912
#include<stdlib.h>
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
int rabbit[51][51];
int bad[51];
int main(){
	int n,k,a,b,m,r;
	cin>>n>>k;
	for(int i=0;i<k;i++){
		cin>>m;
		for(int j=1;j<=m;j++){
			cin>>a;
			rabbit[i][a]=1;
		}
	}
	cin>>r;
	for(int i=0;i<r;i++){
		cin>>a>>b;
		if(bad[a]==1&&bad[b]==1)continue;
		for(int j=0;j<k;j++){
			if(rabbit[j][a]==1){
				if(rabbit[j][b]==1){
					bad[a]=1;
					bad[b]=1;
					break;
				}
			}
		}
	}
	int c=0;
	for(int i=0;i<=n;i++){
		if(bad[i]==1)c++;
	}
	cout<<c<<endl;
	return 0;
}	

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define dec(i, l, r) for (int i = l; i>=r;i--)
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define pb(c) push_back(c)
#define vii vector<pair<int,int>>
#define ii pair<int,int>
#define mp(i, j) make_pair(i,j)
#define ull unsigned long long int
#define ll  long long int
#define pie 3.141592653589793238
#define inf ((ll)1e18)
#define eps 1e-7
#define mod ((int)1e9+7)
#define maxlg 18
const int maxn = ((int) 4e5) +5;
#define left(i) ((i)<<1)
#define right(i) (((i)<<1)+1)

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifndef ONLINE_JUDGE
 #endif
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if (!(k&1))
    cout<<a-b;
    else
        cout<<b-a;
    return 0;
}//cout<<"Case #"<<++T<<": ";

Measured memory_bytes: 768
// Gaurav Nuti
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define ar array
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define INF 1e9 

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

ll power_without_mod(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x); 
        y = y>>1;
        x = (x*x); 
    } 
    return res; 
}

bool comparep(pair<ll, ll> i1, pair<ll, ll> i2){
	return (i1.S < i2.S);
} 

ll modInverse(ll a)
{
    return power(a , mod - 2);
}

vector<vector<ll>> graph;
vector<bool> visited;
vector<ll> dist;
map<ll,ll> mymap;
ll max_dist = 1;

void bfs(int u1){
    visited[u1] = 1;
    dist[u1] = 1;
    mymap[1] = u1;
    queue<ll> q;
    q.push({u1});
    while(!q.empty()){
        ll u = q.front();
        q.pop();
        for(auto i=graph[u].begin();i!=graph[u].end();i++){
            if(!visited[*i]){
                dist[*i] = dist[u] + 1;
                visited[*i] = 1;
                max_dist = max(dist[*i],max_dist);
                mymap[dist[*i]] = *i;
                q.push({*i});
            }
        }
    }
}

// int next_lunlun(ll n){
//     vector<int> digits;
//     while(n){
//         digits.pb(n%10);
//         n /= 10;
//     }
//     // reverse(digits.begin(),digits.end());
//     ll num_digits = digits.size(); 
//     int count_9 = 0;
//     for(int i: digits)
//         if(i == 9)
//             count_9++;
//     if(count_9 == num_digits)
//         return ;
//     for(int i=0;i<(num_digits-1);i++){
//         if(digits)
//     }
// }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif  
	
    ll t;
    // cin>>t;
    t = 1;
    for(ll z=0;z<t;z++){
        ll n;
        cin>>n;
        ll h[n];
        inp_arr(h,n);
        ll dp[n] = {0};
        for(ll i=1;i<n;i++){
            dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]),dp[max(i-2,(ll)0)] + abs(h[i] - h[max(i-2,(ll)0)]));
        }
        cout<<dp[n-1];
    }
}

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

using namespace std;

const int N = 1e5 + 6;

char s[N];

int main() {
  scanf("%s", s);
  int n = strlen(s);
  int ans = 0;
  int now = 0;
  for (int i = 0; i < n; i++) {
    if (now) {
      if (s[i] == 'g')
        ans++;
      now--;
    }
    else {
      if (s[i] == 'p')
        ans--;
      now++;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 512
<?php
$length =trim(fgets(STDIN));
list($forwardStr,$backStr)=explode(" ",trim(fgets(STDIN)));
$combinedStr="";

for($i=0;$i<$length;$i++){
$combinedStr.=$forwardStr[$i].$backStr[$i];
}

echo $combinedStr;    
?>

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

int main(){
    int n,k;cin>>n>>k;
    double P=0;
    for(int i=1;i<=n;i++){
        long long score=i;
        double p=(double)1/(double)n;
        while(1<=score&&score<=k-1){
            p*=0.5;
            score*=2;
        }

        P+=p;
    }

    printf("%.14f\n",P);
}    

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

using namespace std;

#define rep(i,a,b) for(int i=a;i<b;i++)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";

int main(){
	int i,j,n,m,K;
	scanf("%d%d",&n,&m);
	char s[120];
	int v[26]={0};
	rep(i,0,n){
		scanf("%s",s);
		rep(j,0,m){
			v[s[j]-'a']++;
		}
	}
	int g[4]={0};
	rep(i,0,26)if(v[i])g[v[i]%4]++;
	if(n%2==0&&m%2==0){
		if(g[1]||g[2]||g[3])puts("No");
		else puts("Yes");
	}
	else if(n%2==0||m%2==0){
		if(g[1]+g[3])puts("No");
		else{
			if(m&1)swap(n,m);
			int k=m/2;
			//DBG(g[2])
			if(g[2]>k)puts("No");
			else puts("Yes");
		}
	}
	else{
		if(g[1]){
			if(g[1]>1)puts("No");
			else{
				if(g[3])puts("No");
				else{
					n/=2,m/=2;
					if(g[2]>n+m)puts("No");
					else puts("Yes");
				}
			}
		}
		else{
			if(!g[3]||g[3]>1)puts("No");
			else{
				n/=2,m/=2;
				if(g[2]>n+m-1)puts("No");
				else puts("Yes");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	string s;
	cin >> s;
	int l = s.size();
	int ptr = l - 3;

	if (l<5) {
		cout << "NO" << endl;
		return 0;
	}
	else {
		while(ptr>=0) {
			if (s[ptr]=='e') {
				string str = s.substr(ptr-2,5);
				if (str == "dream") {
					ptr -= 5;
				}
				else {
					cout << "NO" << endl;
					return 0;
				}
			}
			else if (s[ptr]=='m') {
				string str = s.substr(ptr-4,7);
				if (str == "dreamer") {
						ptr -= 7;
				}
				else {
					cout << "NO" << endl;
					return 0;
				}
			}
			else if (s[ptr]=='a') {
				string str = s.substr(ptr-2,5);
				if (str == "erase") {
					ptr -= 5;
				}
				else {
					cout << "NO" << endl;
					return 0;
				}
			}
			else if (s[ptr]=='s') {
				string str = s.substr(ptr-3,6);
				if (str == "eraser") {
					ptr -= 6;
				}
				else {
					cout << "NO" << endl;
					return 0;
				}
			}
			else {
				cout << "NO" << endl;
				return 0;
			}
		}
	}

	if (ptr==-3) cout << "YES"<< endl;
	else cout << "NO" << endl;

	return 0;
}

			


			


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  double n,t,a;
  std::cin >> n >> t >> a;

  vt<int> H(n);
  rep(i,n)
    std::cin >> H[i];

  double tmp = 0.0, mini = 100000.0;
  int num;
  rep(i,n) {
    tmp = t - H[i]*0.006;
    if(std::max(a,tmp) - std::min(a,tmp) < std::max(a,mini) - std::min(a,mini)) {
      mini = tmp;
      num = i+1;
    }
  }

  std::cout << num << '\n';
  return 0;
}


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

int main() {
  
  int X, N, ans; cin >> X >> N; int minDif = 102;
  
  if (X == 0) { cout << X << endl; return 0; }
  
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) cin >> vec[i];
  
  for (int i = 0; i < 102; i++) {
    
    int tmp = i; bool flag = false;
    
    for (int p : vec) if (tmp == p) flag = true;
    
    if (flag) continue;
    
    int tmpDif = abs(X - tmp);
    
    if (tmpDif < minDif) {
      ans = tmp;
      minDif = tmpDif;
    }
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <unordered_set>
#include <algorithm>

using namespace std;

template <int base>
int digit_sum(int n)
{
	int sum = 0;
	while (n > 0) {
		sum += n % base;
		n /= base;
	}
	return sum;
}

using ivec = vector<int>;

ivec read_int_args()
{
	int N;
	cin >> N;
	ivec v(N);
	for (auto& e : v) {
		cin >> e;
	}
	return v;
}

int main()
{
	int N;
	cin >> N;
	ivec A(N);
	ivec B(N);
	ivec C(N - 1);
	for (auto& e : A) {
		cin >> e;
	}
	for (auto& e : B) {
		cin >> e;
	}
	for (auto& e : C) {
		cin >> e;
	}
	
	int cnt = 0;
	int last = -10;
	for (auto& a : A) {
		cnt += B[a - 1];
		if (a == last + 1) {
			cnt += C[last - 1];
		}
		last = a;
	}
	cout << cnt << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<ctime>

#define int long long
#define R register
#define IL inline
#define Rf(a,b,c) for(R int (a)=(b);(a)<=(c);++(a))
#define Tf(a,b,c) for(R int (a)=(b);(a)>=(c);--(a))
#define MP make_pair
#define PA pair<int,int>
#define MES(a,b) memset((a),(b),sizeof((a)))
#define MEC(a,b) memcpy((a),(b),sizeof((b)))
#define D double

using namespace std;

const int N=1e5+5,mod=1e9+7;

int n,k,head[N],tot,dep[N],s[N],fac[N],fa[N],vis[N],vis2[N],ans,son[N];
struct Edge {
	int to,next;
}e[N<<1];

struct node {
	int num,dep;
}tmp;
queue <int> q;
queue <node> q2;

IL int read() {
    int x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x*=10;x+=(ch-'0');ch=getchar();}
    return x*f;
}
IL void write(int x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
IL void add(int u,int v) {
	e[++tot].next=head[u];
	e[tot].to=v;head[u]=tot;
}
/*IL int qpow(int x,int y) {
	R int S=1;
	while(y) {
		if(y&1) S=S*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return S;
}
IL int C(int a,int b) {//a>b;
	R int inv1=qpow(fac[b],mod-2),inv2=qpow(fac[a-b],mod-2);
	return fac[a]*inv1%mod*inv2%mod;
}*/
void dfs(int x) {
	for(R int i=head[x];i;i=e[i].next) {
		R int v=e[i].to;
		if(v==fa[x]) continue;
		son[v]--;
		fa[v]=x;dep[v]=dep[x]+1;
		dfs(v);
		s[x]+=son[v]+1;
	}
}
IL int bfs(int now) {
	MES(vis2,0);R int cnt=0;
	tmp.num=now,tmp.dep=0;
	q2.push(tmp);vis2[now]=1;
	while(!q2.empty()) {
		tmp=q2.front();q2.pop();
		R int x=tmp.num,de=tmp.dep;
		for(R int i=head[x];i;i=e[i].next) {
			R int v=e[i].to;
			if(vis[v]&&de<2&&!vis2[v]) {
				cnt++;vis2[v]=1;
				tmp.num=v;tmp.dep=de+1;
				q2.push(tmp);
			}
		}
	}
	return cnt;
}

signed main()
{
	n=read(),k=read();
	Rf(i,2,n) {
		R int u=read(),v=read();
		add(u,v);add(v,u);
	}
	q.push(1);ans=1;
	while(!q.empty()) {
		R int x=q.front();q.pop();vis[x]=1;son[fa[x]]++;
		R int sum=0;
		if(fa[fa[x]]) sum++;
		if(fa[x]) sum+=son[fa[x]];
		ans=ans*(k-sum)%mod;
		for(R int i=head[x];i;i=e[i].next) {
			R int v=e[i].to;
			if(!vis[v]) {
				fa[v]=x;
				q.push(v);
			}
		}
	}
	write(ans);
	
    return 0;
}


Measured memory_bytes: 10276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define US unordered_set
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;

ll ma(vi v) {
  ll ret=0;
  for(auto i:v) ret=max(ret,i);
  return ret;
}

ll mi(vi v) {
  ll ret=INF;
  for(auto i:v) ret=min(ret,i);
  return ret;
}



int main(){
  string S; cin>>S;
  UM<char,ll> cnt;
  for(auto c:S) cnt[c]++;
  vi v;
  for(auto p:cnt) v.PB(p.second);
  while(v.size()!=3) {
    v.PB(0);
  }
  if(ma(v)-mi(v)<=1) {
    cout<<"YES"<<endl;
    return 0;
  }
  cout<<"NO"<<endl;
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

const int Mod(const int n, const int mod)
{
    if (n > 0) return n % mod;
    else return Mod(n + mod, mod);
}

const bool IsOK(
    const int N, const vector<vector<char>> &grids,
    const int A, const int B)
{
    for (int x1 = 0; x1 < N; ++x1)
    {
        for (int y1 = 0; y1 < N; ++y1)
        {
            int x2 = Mod(y1 + B - A, N);
            int y2 = Mod(x1 + A - B, N);
            if (grids[x1][y1] != grids[x2][y2]) return false;
        }
    }
    return true;
}

int main()
{
    int N; cin >> N;
    vector<vector<char>> grids(N, vector<char>(N));
    for (int i = 0; i < N; ++i)
    {
        string S; cin >> S;
        for (int j = 0; j < N; ++j)
        {
            grids[i][j] = S[j];
        }
    }
    int ans = 0;
    int A = 0;
    for (int B = 0; B < N; ++B)
    {
        if (IsOK(N, grids, A, B)) ++ans;
    }
    cout << ans * N << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#define MAX 100000

int A[MAX],n;

int partition(int p,int r){
  int x,i,j,t;
  x = A[r];
  i = p - 1;
  for(j = p;j < r;j++){
    if (A[j] <= x){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i +1];
  A[i +1] = A[r];
  A[r] = t;

  return i + 1;
}

int main(){
  int i,q;

  scanf("%d",&n);
  for(i = 0;i < n;i++)
    scanf("%d",&A[i]);

  q = partition(0,n - 1);

  for(i = 0;i < n;i++){
    if(i)
      printf(" ");
    if( i == q)
      printf("[");
    printf("%d",A[i]);
    if(i == q)
      printf("]");
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  double a, b;
  cin >> a >> b;
  cout << a - b + 1 << "\n";
}


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

int main() {
  
  int n,a;
  cin >> n;
  
  for ( int i = 0; i < 2; i++){
    a = n % 10;
    if( a == 9 ){
      cout << "Yes" << endl;
      return 0;
    }
    n /= 10;
  }
  
  cout << "No" << endl;
  
  
  
  
}



Measured memory_bytes: 256
N, W = map(int,raw_input().split())

score = [0] * (W+1)

for n in range(N) :
  w, v = map(int,raw_input().split())
  for i in range(w, W+1) :
    score[i-w] = max(score[i-w], score[i] + v)

print score[0]

Measured memory_bytes: 31596
#include <stdio.h>
#include <map>
using namespace std;

typedef long long ll;

map<ll, ll> M;

int main(void)
{
	ll n, tmp, i, p, ans = 0, left = 0;

	scanf("%lld" ,&n);
	tmp = n;

	for (i = 2; i * i <= n; i++)
		while (tmp % i == 0)
		{
			tmp /= i;
			M[i]++;
		}

	if (tmp != 1)
	{
		left = tmp;
		M[left]++;
	}

	for (p = 2; p * p <= n; p++)
	{
		if (!M[p])
			continue;

		ll exp = M[p];

		i = 1;
		while (M[p] >= i)
		{
			M[p] -= i;
			i++;
		}

		ans += i - 1;
	}

	p = left;

	ll exp = M[p];
	i = 1;
	while (M[p] >= i)
	{
		M[p] -= i;
		i++;
	}
	ans += i - 1;

	printf("%lld" ,ans);
	return 0;
}

Measured memory_bytes: 65796
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


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


int gcd3(int a,int b,int c){
   return gcd(a, gcd(b,c));
}



int main(){
   int k;
   cin >> k;
   
   int ans=0;
   
   for(int a=1; a<=k; a++){
      for(int b=1; b<=k; b++){
         for(int c=1; c<=k; c++){
            ans += gcd3(a,b,c);
         }
      }
   }
   
   cout <<ans<<endl;
   
   return 0;
}

Measured memory_bytes: 3652
#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 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(){
    string s; cin >> s;
    ll n = s.size();
    ll dp[n+1][2] = {};
    dp[0][0] = 1;
    dp[0][1] = 0;
    rep(i,n){
        dp[i+1][1] = dp[i][1] * 3;
        if(s[i] == '0'){
            dp[i+1][0] += dp[i][0];
        }else{
            dp[i+1][1] += dp[i][0];
            dp[i+1][0] += dp[i][0] * 2;
        }
        dp[i+1][0] %= MOD;
        dp[i+1][1] %= MOD;
    }
    cout << (dp[n][0] + dp[n][1]) % MOD << endl;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
 /* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)*/
template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////




int main() {
	int A,B,ans; cin >> A >>B;
	ans = 0;
	if(A>=13){ans = B;}
	else if(A>=6){ans = B/2;}
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		//private const int mod = 1000000007;  // 10^9+7

		static public void Solve(string[] args)
		{
			string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int mod = 2019;

			Dictionary<int, int> pairs = new Dictionary<int, int>();
			int tmp = 0, d = 1;
			for (int i = 0; i <= s.Length; i++) {
				if (i > 0) {
					tmp = (tmp + int.Parse(s.Substring(s.Length - i, 1)) * d) % mod;
				}
				//System.Diagnostics.Debug.WriteLine($"T{i,2} {s.Substring(s.Length - i),13} mod {mod} = {tmp,4}");
				if (pairs.ContainsKey(tmp)) {
					pairs[tmp]++;
				} else {
					pairs.Add(tmp, 1);
				}
				d = d * 10 % mod;
			}

			long ans = 0;
			foreach (var item in pairs) {
				//System.Diagnostics.Debug.WriteLine($"{item.Key,4},{item.Value}:{item.Value * (item.Value - 1) / 2}");
				ans += item.Value * (item.Value - 1) / 2;
			}
			Console.WriteLine(ans);

		}
	}
}


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

#define pb push_back
#define mp make_pair
#define fs first
#define se second

const int limit = 100010;

typedef long long LL;

int n ;
vector < pair<int , int > > tree[limit];
LL d[limit];

void dfs(int v, int p, LL k) {
    d[v] = k;
    for (int i = 0 ; i < tree[v].size() ; i++) {
        if ( tree[v][i].first == p ) continue;
        dfs( tree[v][i].first, v, k + tree[v][i].second);
    }
}

int main() {
  //  freopen("test.txt","r",stdin);
    cin >> n ;
    for (int i =0 ; i < n -1 ; i++) {
        int x,y,z;
        cin >> x >> y >> z;
        x-- , y-- ;
        tree[x].pb(mp(y,z));
        tree[y].pb(mp(x,z));
    }

    int q,k;
    cin >> q >> k;
    k--;

    dfs(k,-1,0);

    for (int i = 0 ; i < q ; i++) {
        int x,y;
        cin >> x >> y;
        x--,y--;
        cout << d[x] + d[y] << endl;
    }
}


Measured memory_bytes: 14336
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif
#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;
const int MOD=1e9+7;
const int INF=1<<29;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
const int N=1e5+11;
using ii=pair<int,int>;
vector<ii> g[N];
int dp[N];
void dfs(int curr,int par,int sum){
  dp[curr]=sum;
  for(auto it:g[curr]){
	   if(it.f==par)continue;
	   dfs(it.f,curr,sum+1ll*it.s); 
	 }
}
void solve(){
	int n,q,k;
	cin>>n;
	for(int i=0;i<n-1;i++){
	   int a,b,c;
	   cin>>a>>b>>c;
	   g[a].push_back({b,c});
	   g[b].push_back({a,c});	
	}
	cin>>q>>k;
	dfs(k,-1,0ll);
	for(int i=0;i<q;i++){
	  int x,y;
	  cin>>x>>y;
	  cout<<dp[x]+dp[y]<<endl;
	}
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
    IOS;
    solve();
    #ifdef LOCAL_DEFINE
    cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
    #endif
}


Measured memory_bytes: 14336
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <queue>
#include <cmath>
#define ll long long 
#define ri register int 
#define ull unsigned loong long 
const int maxn=200015;
const int inf=0x7fffffff;
template <class T>inline void read(T &x){
	x=0;int ne=0;char c;
	while(!isdigit(c=getchar()))ne=c=='-';
	x=c-48;
	while(isdigit(c=getchar()))x=(x<<3)+(x<<1)+c-48;
	x=ne?-x:x;return;
}
int r;
int main(){
	read(r);
	if(r<1200)puts("ABC");
	else if(r<2800)puts("ARC");
	else puts("AGC");
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define fr(i,x,n) for(int i=x;i<=n;i++)
#define rf(i,n,x) for(int i=n;i>=x;i--)
#define mst(x,i) memset(x,i,sizeof(x))
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define PB push_back
#define X first
#define Y second
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int maxn=1E5+5;
const int maxm=1E5+5;
const int inf=0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3f;
const LL mod=1E9+7;
const double eps=1E-6;
const double PI=acos(-1.0);
template<class T>
bool scan(T &ret){
    char c;int sgn;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    ret*=sgn;
    return 1;
}
template<class T>
T gcd(T a,T b){
    return b==0?a:gcd(b,a%b);
}
template<class T>
T qpow(T a,T b,T mod){
    T ret=1;
    a%=mod;
    while(b){
        if(b&1) ret=(a*ret)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return ret%mod;
}
struct node{
    LL cost,amount;
    bool operator < (const node &rhs) const{
        return cost<rhs.cost;
    }
}store[maxn];
void solve(){
    int n,m;
    cin>>n>>m;
    LL ans=0;
    rep(i,n) cin>>store[i].cost>>store[i].amount;
    sort(store,store+n);
    rep(i,n){
        if(store[i].amount>=m){
            ans+=store[i].cost*m;
            break;
        }else{
            ans+=store[i].amount*store[i].cost;
            m-=store[i].amount;
        }
    }
    cout<<ans<<endl;
}
int main(){
#ifdef LOCAL
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif
    IOS;
    int T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
// #pragma comment(linker, "/stack:200000000"]
 
#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>
#include <fstream>
#include <sstream>
 
#define fr first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map 
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forln(i, l, n) for (int i = l; i < n; ++i)

#define int ll

using namespace std;

#ifdef __LOCAL
	#define dbg(x) cerr << #x << " : " << x << '\n'
	const int maxn = 20;
#else 
	#define dbg(x)
	const int maxn = 2e5 + 20;
#endif

//tg: @galebickosikasa
 
const ll inf = (ll) 2e9;
const ld pi = 3.14159265358979323846264;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

random_device rd;
mt19937 SuperRandom(rd());

int check (string& s, string& t, int i) {
	int j = 0;
	while (i < sz (s) && j < sz (t)) {
		if (s[i] == '?' || t[j] == '?') {++i, ++j; continue;}
		if (s[i] != t[j]) {
			// dbg (t[j]);
			return 0;
		}
		++i, ++j;
	}
	return i >= sz (s) || j >= sz (t);
}

signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	string a, b, c;
	cin >> a >> b >> c;
	int ans = inf;
	int ab[4001], ac[4001], ba[4001], bc[4001], ca[4001], cb[4001];
	for (int i = 0; i < 4001; ++i) ab[i] = check (a, b, i);
	for (int i = 0; i < 4001; ++i) ac[i] = check (a, c, i);
	for (int i = 0; i < 4001; ++i) ba[i] = check (b, a, i);
	for (int i = 0; i < 4001; ++i) bc[i] = check (b, c, i);
	for (int i = 0; i < 4001; ++i) ca[i] = check (c, a, i);
	for (int i = 0; i < 4001; ++i) cb[i] = check (c, b, i);
	for (int i = 0; i < 2001; ++i) 
		for (int j = 0; j < 2001; ++j) 
			if (ab[i] && bc[j] && ac[i + j])
				ans = min (ans, max (sz (c) + j + i, max (sz (b) + i, sz (a))));
	for (int i = 0; i < 2001; ++i) 
		for (int j = 0; j < 2001; ++j) 
			if (ac[i] && cb[j] && ab[i + j])
				ans = min (ans, max (sz (b) + j + i, max (sz (c) + i, sz (a))));
	for (int i = 0; i < 2001; ++i) 
		for (int j = 0; j < 2001; ++j) 
			if (ba[i] && ac[j] && bc[i + j])
				ans = min (ans, max (sz (c) + j + i, max (sz(a) + i, sz (b))));
	for (int i = 0; i < 2001; ++i) 
		for (int j = 0; j < 2001; ++j) 
			if (bc[i] && ca[j] && ba[i + j])
				ans = min (ans, max (sz (a) + j + i, max (sz (c) + i, sz (b))));
	for (int i = 0; i < 2001; ++i) 
		for (int j = 0; j < 2001; ++j) 
			if (ca[i] && ab[j] && cb[i + j])
				ans = min (ans, max (sz (b) + j + i, max (sz (a) + i, sz (c))));
	for (int i = 0; i < 2001; ++i) 
		for (int j = 0; j < 2001; ++j) 
			if (cb[i] && ba[j] && ca[i + j])
				ans = min (ans, max (sz (a) + j + i, max (sz (b) + i, sz (c))));

	cout << ans;









}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
typedef long long ll;

ll	digit_sum(ll n)
{
	ll sum = 0;
	while (1)
	{
		sum += n % 10;
		if (n < 10)
			break;
		n /= 10;
	}
	return sum;
}

ll digit_n(ll n)
{
	long cnt = 1;
	while (n > 9)
	{
		n /= 10;
		cnt++;
	}
	return cnt;
}

int main(void)
{
	ll n;
	scanf("%lld", &n);
	ll j = n;
	ll cnt = 0;
	// printf("%lld\n", digit_n(n));
	ll k = digit_n(n);
	ll d = pow(10, k - 1);
	ll c = n / d;
	ll i = 0;

	while (i < k - 1)
	{
		if (j % 10 == 9)
			cnt++;
		j /= 10;
		i++;
	}
	if (cnt == k - 1)
		printf("%lld\n", c + (9 * (k - 1)));
	else if (n % 10 != 9)
		printf("%lld\n", ((c-1) + (9 * (k - 1) )));
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
using ll=int64_t;
#define int ll
 
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))
 
using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;
 
template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}
 
template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}
 
ll read(){
	ll i;
	scanf("%" SCNd64,&i);
	return i;
}
 
void printSpace(){
	printf(" ");
}
 
void printEoln(){
	printf("\n");
}
 
void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}
 
string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}
 
char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}
 
template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}
 
template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}
 
template<class T>
T Sq(const T& t){
	return t*t;
}
 
#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}
 
const ll infLL=LLONG_MAX/3;
 
#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif
 
const int Nmax=100010;
vi g[Nmax];
int p[Nmax];
int buf[Nmax];
int Coincide(vi a,vi b){
	for(auto x:a)
		buf[x]=1;
	int res=0;
	for(auto x:b)
		res+=buf[x];
	for(auto x:a)
		buf[x]=0;
	return res;
}
bool vis[Nmax];
void dfs(int v,vi&a,vi&b){
	if(vis[v])return;
	vis[v]=true;
	a.PB(v);
	b.PB(p[v]);
	for(auto to:g[v])
		dfs(to,a,b);
}
 
signed main(){
	int n=read(),m=read();
	REP(i,n)p[i]=read()-1;
	REP(_,m){
		int x=read()-1,y=read()-1;
		g[x].PB(y);
		g[y].PB(x);
	}
	int ans=0;
	REP(i,n)if(!vis[i]){
		vi a,b;
		dfs(i,a,b);
		ans+=Coincide(a,b);
	}
	print(ans);
}

Measured memory_bytes: 17512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>

typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 2e3+1;
const ll mod = 1e9+7;


int main(){

    FASTIO;
    PRECISION; 

    ll ans = 0;

    int n,k;
    cin>>n>>k;

    vector<ll>arr(n);
    for(ll &x: arr){
        cin>>x;
    }

    for(int take = 0; take<=min(n,k); take++){
        for(int left=0;left<=take;left++){
            int right = take-left;
            
            vector<ll>store;
            for(int i=0;i<left;i++){
                store.push_back(arr[i]);
            }
            for(int j=0;j<right;j++){
                store.push_back(arr[n-1-j]);
            }

            int drop = k-take;
            sort(store.begin(),store.end(),greater<ll>());

            while(store.size() && store.back()<0 && drop){
                drop--;
                store.pop_back();
            }

            ll sum = 0;
            for(ll x: store){
                sum+=x;
            }

            ans = max(ans,sum);
            
        }

    }

    cout<<ans<<"\n";
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int, A: "List[int]"):
    s = sum(A)
    t = s / 4 / M
    v = [1 if a >= t else 0 for a in A]
    print(YES if sum(v) >= M else NO)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> d1(n),d2(n);
    rep(i,n) cin >> d1[i] >> d2[i];
    int cnt=0;
    rep(i,n){
        if(d1[i]==d2[i]) ++cnt;
        else cnt=0;
        if(cnt==3){
            cout << "Yes" << "\n";
            return 0;
        }
    }
    cout << "No" << "\n";
    return 0;
}   

Measured memory_bytes: 3648
#!/usr/bin/env python3
import sys
x = [int(input()) for _ in range(4)]
ans = 0
for i in range(x[0]+1):   # 500の個数
    for j in range(x[1]+1): # 100の個数
        if x[3]-i*500-j*100 >=  0 and x[3]-i*500-j*100 <= x[2]*50:
            ans += 1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<map>
#include<cmath>
#include<algorithm>
using namespace std;
typedef pair < int , int > Pt;
bool dp[1 << 24];
Pt pts[24];
int n, r[24], c[24];
int hoge[24];
const int INF = 1 << 28;
bool intersect( Pt a, Pt b, int r1, int r2){
  return pow( a.first - b.first, 2) + pow( a.second - b.second, 2) < pow( r1 + r2, 2);
}

int isnocover( const int& bit, const int& idx ){
  for(int i = 0 ; i < idx ; i++ ){
    if( (bit >> i) & 1 && (hoge[idx] >> i) & 1) return false;
  }
  return true;
}

int rec( int bit){
  if(dp[bit]++) return -INF;
  int ret = 0;
  for(int i = 0 ; i < n ; i++ ){
    if((bit >> i) & 1){
      for(int j = i + 1 ; j < n ; j++ ){
        if( (bit >> j) & 1 && c[i] == c[j] && isnocover( bit, i) && isnocover( bit, j)){
          ret = max( ret, rec( bit & ~(1 << i) & ~(1 << j)) + 2);
        }
      }
    }
  }
  return ret;
}
int main()
{
  while(cin >> n, n){
    fill_n( dp, 1 << 24 , false);
    fill_n( hoge, 24 , 0);

    for(int i = 0 ; i < n ; i++ ){
      cin >> pts[i].first >> pts[i].second >> r[i] >> c[i];
      for(int j = 0 ; j < i ; j++ ){
        if(intersect(pts[i],pts[j],r[i],r[j])) hoge[i] |= 1 << j;
      }
    }
    cout << rec((1 << n) - 1) << endl;
  }
}

Measured memory_bytes: 17544
(N, M), *ABs = readlines.map{|l| l.split.map(&:to_i)}

m, x = 0, 0
ABs.sort_by{|a, b| a}.each do |a, b|
  if m + b >= M
    x += a*(M - m)
    break
  else
    m += b
    x += a*b
  end
end
puts x

Measured memory_bytes: 20600
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const ceil=(a)=>{return Math.ceil(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const gcd=(x,y)=>{while(y){[x,y]=[y,x%y]}return x};const sum=(arr)=>{return arr.reduce((a,b)=>a+b);};const isPrime=(n:number):boolean=>{if(n<2)return false;const suq=Math.sqrt(n);for(let i=2;i<=suq;i++){if(n%i==0){return false;}}return true;};
const permutation = ({ result = [], pre = [], post, n = post.length }) => {
  if (n > 0) {
    post.forEach((_, i) => {
      const rest = [...post];
      const elem = rest.splice(i, 1);
      permutation({ result, pre: [...pre, ...elem], post: rest, n: n - 1});
    });
  } else {
    result.push(pre);
  }
  return result;
};
const main=()=>{
  let n=tn(),[a,b]=[tnn(n),tnn(n)]
  let x=[...a]
  let c=permutation({post: x.sort()})
  let aa=a.join('')
  let bb=b.join('')
  let aaa,bbb
  for(let i=0;i<c.length;i++){
    if(c[i].join('')==aa)aaa=i
    if(c[i].join('')==bb)bbb=i
  }
  to(abs(aaa-bbb))
}
main()


Measured memory_bytes: 27784
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int ans = 0;
int main(){
    cin >> N;
    int X[N], Y[N];
    rep(i, N){
        cin >> X[i];
        Y[i] = X[i];
    }
    sort(Y, Y + N);
    rep(i, N){
        if(X[i] >= Y[N/2]){
            cout << Y[N/2 - 1] << endl;
        }else{
            cout << Y[N/2] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3712
#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 s,w;
    cin>>s>>w;
    if(w>=s)
      cout<<"unsafe"<<endl;
    else
      cout<<"safe"<<endl;
}
return 0;
}

Measured memory_bytes: 3648
from math import floor


def main():
    A, B, K = map(int, input().split())
    # 1 is always divisor for integer
    divisors = [1]
    for d in range(2, min(A, B)+1):
        if (B % d == 0 and A % d == 0):
            divisors.append(d)
    print(divisors[-K])


main()


Measured memory_bytes: 3064
N,K = map(int,input().split())
H = []
for i in range(N):
    h = int(input())
    H.append(h)
H.sort()
ans = 1000000000
for i in range(N-K+1):
    tmp = H[K-1+i] - H[i]
    if tmp < ans:
        ans = tmp
print(ans)

Measured memory_bytes: 7384
def query(seat,m_max,m_min,seat_0):
    print(seat)
    s=input()

    if (seat%2==0 and s==seat_0) or (seat%2==1 and s!=seat_0):
        m_min=seat
        seat=int(0.5*(m_max+seat))
            
    else :
        m_max=seat
        seat=int(0.5*(m_min+seat))

    query(seat,m_max,m_min,seat_0)

n=int(input())
print(0)
query(int(0.5*n), n, 0, input())

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  vi v(n);
  rep(i, n) cin >> v[i];
  dump(v);
  map<int, int> mp[2];
  rep(i, n) {
    mp[i % 2][v[i]]++;
  }
  dumpv(mp, 2);
  P e0(-1, 0), e1(-1, 0);
  P o0(-1, 0), o1(-1, 0);
  for (auto m : mp[0]) {
    if (e0.second < m.second) {
      e1 = e0;
      e0 = m;
    } else if (e1.second < m.second) {
      e1 = m;
    }
  }
  for (auto m : mp[1]) {
    if (o0.second < m.second) {
      o1 = o0;
      o0 = m;
    } else if (o1.second < m.second) {
      o1 = m;
    }
  }
  dump(e0, e1, o0, o1);
  ll cnt = 0;
  if (e0.first != o0.first) {
    cnt += (n / 2) - e0.second;
    cnt += (n / 2) - o0.second;
  } else {
    ll c0 = 0, c1 = 0;
    c0 += (n / 2) - e1.second;
    c0 += (n / 2) - o0.second;
    c1 += (n / 2) - e0.second;
    c1 += (n / 2) - o1.second;
    cnt = min(c0, c1);
  }
  cout << cnt << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main()
{   
      ios::sync_with_stdio(0);
      cin.tie(0);
      long long int a,b,i,n,p,c1=0;
      cin>>n;
      cin>>a>>b;
      i=0;
      while(1)
      {
      	i++;
      	p=n*i;
      	if(p>=a&&p<=b)
      	{
      		c1++;
      		break;
		  }
		  else 
		  {
		  	if(p>b)
		  	{
		  		break;
			  }
		  }
		  
	  }
	  
	  if(c1!=0)
	  {
	  	cout<<"OK"<<"\n";
	  }
	  else
	  {
	  	cout<<"NG"<<"\n";
	  }
	  return 0;
	
}

Measured memory_bytes: 3612