akhauriyash/Code-Regression huggingface dataset:
n = list(map(int, input()))
if len(n) == 6:
        print(90909)
elif len(n) == 5:
        num = n[0] * 10000 + n[1] * 1000 + n[2] * 100 + n[3] * 10 + n[4]
        print((num - 10000) + 1 + 900 + 9)
elif len(n) == 4:
        print(909)
elif len(n) == 3:
        num = n[0] * 100 + n[1] * 10 + n[2] * 1
        print((num - 100) + 1 + 9)
elif len(n) == 2:
        print(9)
else:
        num=n[0]*1
        print(num)

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

using namespace std;

int main(void) {
    string s;
    cin >> s;

    int n = s.size();

    long r = 0;
    long a = 0;
    int i=0;
    while(i+1 < n) {
        if(s[i] == 'A') a++, i++;
        else if(s[i] == 'B' && s[i+1] == 'C') r += a, i+=2;
        else a=0, i++;
    }
    cout << r << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int a, b, c, k;
      vector<int> v;
      cin >> a >> b >> c >> k;
      v = {a, b, c};
      sort(v.begin(), v.end());
      cout << v.at(0) + v.at(1) + v.at(2) * pow(2, k) << endl;
    }

Measured memory_bytes: 384
#pragma GCC optimize("O3")
                #pragma comment(linker, "/stack:200000000")
                #pragma GCC optimize("unroll-loops")
                 
                #include <algorithm>
                #include <bitset>
                #include <cassert>
                #include <chrono>
                #include <cmath>
                #include <complex>
                #include <cstdio>
                #include <cstdlib>
                #include <cstring>
                #include <ctime>
                #include <deque>
                #include <functional>
                #include <iomanip>
                #include <iostream>
                #include <iterator>
                #include <limits>
                #include <climits>
                #include <list>
                #include <map>
                #include <numeric>
                #include <queue>
                #include <random>
                #include <ratio>
                #include <set>
                #include <sstream>
                #include <stack>
                #include <string>
                #include <unordered_map>
                #include <unordered_set>
                #include <utility>
                #include <vector>
                using namespace std;
                 
                typedef long long ll;
                typedef long double LD;
                #define int ll
                #define double LD
                #define pb push_back
                #define mp make_pair
                #define REP(i,n) for (int i = 0; i < n; i++)
                #define loop(i,n) for (int i = 0; i < n; i++)
                #define FOR(i,a,b) for (int i = a; i < b; i++)
                #define REPD(i,n) for (int i = n-1; i >= 0; i--)
                #define FORD(i,a,b) for (int i = a; i >= b; i--)
                #define remax(a,b) a = max(a,b)
                #define remin(a,b) a = min(a,b)
                #define mem(a, b) memset(a, b, sizeof a)
                #define append push_back
                #define all(v) v.begin(),v.end()
                #define F first
                #define S second
                #define print(x) cout << (x) << endl
                #define PRECISION(x) cout << fixed << setprecision(x)
                #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
                 
                const double PI=acos(-1);
                const int MOD = 1000000007;
                const int FMOD = 998244353;
                const double eps = 1e-9;
                 
                mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
                int p[5000005];
                
             	signed main()
             	{
             		int n,x,y;
             		cin>>n>>x>>y;
             		int ans[n]{0};
             		FOR(i,1,n+1)
             		{
             			FOR(j,i+1,n+1)
             			{
             				ans[min(min(abs(i-j),abs(x-i)+abs(y-j)+1),abs(x-j)+abs(y-1)+1)]++;
						 }
					 }
					 FOR(i,1,n)
					 cout<<ans[i]<<endl;
				 }

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

string A, B, C;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> A >> B >> C;

  if (*(A.end() - 1) == *(B.begin()) && *(B.end() - 1) == *(C.begin())) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 888
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, a; cin >> n >> a;
  REP(i, a+1) {
    if ((n-i)%500 == 0) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
const int N=1000000007;

main() {
	int n, m;
	cin>>n>>m;
	int a[n];
	int b[m];
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	for(int i=0; i<m; i++){
		cin>>b[i];
	}
	int dp[n][m];
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			if(i==0 && j==0){
				if(a[0]==b[0]){
					dp[0][0]=2;
					continue;
				}
				else{
					dp[0][0]=1;
					continue;
				}
			}
			if(i==0){
				dp[i][j]=dp[i][j-1]+(a[0]==b[j]);
				dp[i][j]=dp[i][j]%N;
				continue;
			}
			if(j==0){
				dp[i][j]=dp[i-1][j]+(b[0]==a[i]);
				dp[i][j]=dp[i][j]%N;
				continue;
			}
			if(a[i]==b[j]){
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%N;
			}
			else{
				dp[i][j]=(dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+N)%N;
			}
		}
	}
	cout<<dp[n-1][m-1];
	return 0;
}

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

using namespace std;

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

lli dp[1020];

signed main(){

	lli d,g;
	cin>>d>>g;
	dp[0]=1;

	REP(i,0,d){
		lli p,c;
		cin>>p>>c;

		lli nextDp[1020];
		REP(i,0,1020)nextDp[i]=0;

		for(lli j=1;j<=p;j++){
			for(lli k=0;k<=1000;k++){
				lli score = j*(i+1)*100;
				if(j==p)score+=c;
				if(dp[k]){
					nextDp[k+j] = max(nextDp[k+j],dp[k]+score);
				}
			}
		}

		for(lli j=1;j<=1000;j++){
			dp[j] = max(dp[j],nextDp[j]);
			if(DEBUG && j<=20){
				cout<<"j="<<j<<" dp[j]="<<dp[j]<<endl;
			}
		}
	}

	REP(i,0,1010){
		if(DEBUG)cout<<"i="<<i<<" dp[i]="<<dp[i]<<endl;
		if(dp[i]>=g){
			if(DEBUG)cout<<"this?"<<endl;
			cout<<i<<endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [list(map(int,input().split())) for k in range(N)]

ans = 0
for k in range(N):
    A[N-1-k][0] += ans
    if A[N-1-k][0]%A[N-1-k][1]!=0:
        d = A[N-1-k][1]*(1+A[N-1-k][0]//A[N-1-k][1])-A[N-1-k][0]
        ans += d
        A[N-1-k][0] += d

print(ans)

Measured memory_bytes: 31476
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define PB push_back
#define PII pair<int,int>
#define ll long long
#define quick ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//set<int> :: iterator it(get with *it)
int N=INT_MAX;
ll INF1=1e9 + 5;
ll INF2=1e18L + 5;
map<int ,int>my;
int h[10005];

int main(){
	string s;
	cin>>s;
	ll k;
	cin>>k;
	int n1=s.length();
	ll x=0,t=0,num=0;
	for(int i=0;i<n1-1;i++){
		t=0;
		x=1;
		for(int j=i+1;j<n1;j++){
			if(s[i]==s[j]){
				x++;
				t++;
			}	
			else{break;}
		}
		i+=t;
		num+=x/2;
	}
	int d=1;
	for(int j=n1-2;j>=0;j--){
		if(s[n1-1]==s[j]){
			d++;
		}
		else{break;}
	}
	int z1=1;
	for(int i=1;i<n1;i++){
		if(s[0]==s[i]){
			z1++;
		}
		else{break;}
	}
	//cout<<z1<<endl;
	int d1=0;
	if((z1)%2!=0 && s[0]==s[n1-1] && d%2!=0){
		d1++;
	}
	if((z1+d)>=n1){
		cout<<(n1*k)/2;
		return 0;
	}
	//cout<<num<<endl;
	ll x1=num*k;
	if(d1!=0){
		x1+=k-1;
	}
	cout<<x1;
}


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

int main(void) {
    int k, a, b;
    scanf("%d", &k);
    scanf("%d%d", &a, &b);
    int largest = (b / k) * k;
    //cout<<largest<<endl;
    if (a <= largest) {
    puts("OK");
    } else {
    puts("NG");
    } 

   return 0;
}

Measured memory_bytes: 3776
/**
 * Created by hiramekun at 20:44 on 2019-12-08.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll h, w;
    cin >> h >> w;
    vvl a(h, vl(w)), b(h, vl(w));
    rep(i, h) rep(j, w) cin >> a[i][j];
    rep(i, h) rep(j, w) cin >> b[i][j];

    // a < b にする
    rep(i, h) {
        rep(j, w) {
            P p = minmax(a[i][j], b[i][j]);
            a[i][j] = p.first, b[i][j] = p.second;
        }
    }

    ll max_diff = 85 * (h + w);
    bool dp[h][w][max_diff];
    rep(i, h) rep(j, w) rep(l, max_diff) dp[i][j][l] = false;

    dp[0][0][b[0][0] - a[0][0]] = true;

    rep(i, h) {
        rep(j, w) {
            rep(l, max_diff) {
                if (dp[i][j][l]) {
                    if (i + 1 <= h - 1) {
                        vl candi{l + b[i + 1][j] - a[i + 1][j],
                                 l - b[i + 1][j] + a[i + 1][j],
                                 -l + b[i + 1][j] - a[i + 1][j],
                                 -l - b[i + 1][j] + a[i + 1][j]};

                        each(e, candi) if (e >= 0) dp[i + 1][j][e] = true;
                    }
                    if (j + 1 <= w - 1) {
                        vl candi{l + b[i][j + 1] - a[i][j + 1],
                                 l - b[i][j + 1] + a[i][j + 1],
                                 -l + b[i][j + 1] - a[i][j + 1],
                                 -l - b[i][j + 1] + a[i][j + 1]};

                        each(e, candi) if (e >= 0) dp[i][j + 1][e] = true;
                    }
                }
            }
        }
    }
    ll ans = ll_inf;
    rep(i, max_diff) {
        if (dp[h - 1][w - 1][i]) ans = min(ans, i);
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 85376
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    int n , k , x;
    cin >> n >> k;
    vi v;
    for(int i = 0 ;i < n ; i++){
        cin >> x;
        v.pb(x);
    }
    bool dp[k+1];
    memset(dp,false , sizeof(dp));
    for(int i = 1 ;i <= k ; i++){
        bool ans = false;
        for(auto it : v){
            if(it <= i)
                ans |= (!dp[i-it]);
        }
        dp[i] = ans;
    }
    if(dp[k])
        cout << "First" << endl;
    else
        cout << "Second" << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <boost/date_time/posix_time/posix_time.hpp>

using namespace std;
using namespace boost::gregorian;
using namespace boost::posix_time;

int main(void) {
    int y,m,d;
    char tmp;
    cin >> y;
    cin >> tmp;
    cin >> m;
    cin >> tmp;
    cin >> d;

    auto t1 = ptime(date(y,m,d));
    auto t2 = ptime(date(2019,4, 30));
    auto duration = t2 - t1;
    // cout << "[DEBUG] " << duration << endl;
    
    if (duration .ticks() >= 0) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<iterator>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int a,n;
  while(cin>>a>>n,a||n){
    map<int,vector<int> >in;
    rep(i,n){
      int b,c;
      cin>>b>>c;
      in[b].pb(c);
      in[c].pb(b);
    }
    set<int>out;
    rep(i,in[1].size()){
      int e=in[1][i];
      out.insert(e);
      rep(j,in[e].size())out.insert(in[e][j]);
    }
    int d=0;
    if(out.find(1)!=out.end())d=1;
    cout<<out.size()-d<<endl;
  }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define loop(i,m,n) for(lli i=m;i<=n;i++)
#define loopr(i,m,n) for(lli i=m;i>=n;i--)
#define pb push_back
#define vi vector<int>
#define ff first
#define ss second
#define pii pair<int,int>
#define vpii vector<ii>
#define INF 1000000000
#define mod 1000000007
#define siz 1000001
#define endl "\n"
const double PI=3.14159265358979323846264338327950288419716939937510;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;

int main()
{
	string s;
	char ch;
	cin>>s;
	if(s[s.size()-1]!='s')
	{
		ch='s';
		s=s+ch;
	}
	else
	{
		ch='e';
		s=s+ch;
		ch='s';
		s=s+ch;
	}
	cout<<s;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>

using namespace std;

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

Measured memory_bytes: 256
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int h=sc.nextInt();
        int w=sc.nextInt();
		int count=0;
  		String[][] s=new String[h+2][w+2];
        
		for(int c=1;c<h+1;c++){
    		String si=sc.next();
           for(int d=1;d<w+1;d++){
            s[c][d]=Character.toString(si.charAt(d-1));  
           }
    	}
  
  for(int a=0;a<w+2;a++){
         s[0][a]=".";
         s[h+1][a]=".";
        }
  	for(int a=0;a<h+2;a++){
         s[a][0]=".";
         s[a][w+1]=".";
        }
  	for(int d=1;d<h+1;d++){
        for(int e=1;e<w+1;e++){
         if(s[d][e].equals("#")&&s[d][e-1].equals(".")&&s[d][e+1].equals(".")&&s[d-1][e].equals(".")&&s[d+1][e].equals(".")){
         count++;
           break;
         }
        }
        }
    
 	if(count==0){
    		System.out.println("Yes");
    	}else{
     		System.out.println("No");
   	 }

    	
    }
}


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

#define MAX 100005

struct Item{
    int w;
    int v;
}item[105];

int N, W;
long long dp[105][MAX];
long long m;

int main(){
    cin>>N>>W;
    for(int i=0; i<N; i++)
        cin>>item[i].w>>item[i].v;
    for(int i=0; i<N; i++){
        for(int j=0; j<=W; j++){
            if(item[i].w+j<=W){
                dp[i+1][item[i].w+j] = max(dp[i+1][item[i].w+j], dp[i][j]+item[i].v);
                m = max(dp[i+1][item[i].w+j], m);
            }
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            m = max(dp[i+1][j], m);
        }
    }
    cout<<m<<"\n";
    return 0;
}


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

int main()
{
	ll n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;

	ll minv = min({ a,b,c,d,e });
	cout << (n + minv - 1) / minv + 4 << endl;
}


Measured memory_bytes: 256
from heapq import heappush as push, heappop as pop
N, M = [int(v) for v in raw_input().split()]
items = [- int(v) for v in raw_input().split()]
q = []
for i in items:
    push(q, i)
for ticket in range(M):
    price = -pop(q)
    push(q, -(price//2))
tot= -sum(q)
print(tot)

Measured memory_bytes: 12684
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N, M = get_ints
hash = Hash.new { |h, k| h[k] = { num: 0, ac: false } }
ac_count = 0
sum = 0

M.times do |i|
  p, s = gets.split
  p = p.to_i

  if !hash[p][:ac]
    if s == 'AC'
      hash[p][:ac] = true
      ac_count += 1
      sum += hash[p][:num]
    else
      hash[p][:num] += 1
    end
  end
end

puts "#{ac_count} #{sum}"


Measured memory_bytes: 39020
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <string>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    int count=0;
    for(int i=0;i<3;i++){
        if(s[i]==t[i]){
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int read()
{
	char c=getchar();
	int res=0;
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') res=(res<<1)+(res<<3)+(c^48),c=getchar();
	return res;
}
int tot=0;
struct Edge
{
	int x,y;
}e[200005];
int n;
int main()
{
	n=read();
	if(!(n&(n-1))) return puts("No"),0;
	puts("Yes");
	printf("%d %d\n",1,2);
	printf("%d %d\n",2,3);
	printf("%d %d\n",3,n+1);
	printf("%d %d\n",n+1,n+2);
	printf("%d %d\n",n+2,n+3);
	for(int i=4;i<n;i+=2)
	{
		int j=i^1;
		printf("%d %d\n",1,i);
		printf("%d %d\n",1,j);
		printf("%d %d\n",i,j+n);
		printf("%d %d\n",j,i+n);
	}
	if(!(n&1))
	{
		for(int i=4;i<=n;i++)
		{
			int j=n^i^1;
			if(j!=3&&j<n)
			{
				printf("%d %d\n",i,n);
				printf("%d %d\n",j,2*n);
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    ll a,b,c;
    cin>>n;
    vector<vector <pair<ll,ll> > > v(n);
    for(int i=0;i<n-1;i++){
        cin>>a>>b>>c;
        a--;
        b--;
        v[a].pb(make_pair(b,c));
        v[b].pb(make_pair(a,c));
    }
    ll q,k;
    cin>>q>>k;
    k--;
    queue<ll> que;
    que.push(k);
    ll dis[n];
    memset(dis,-1,sizeof(dis));
    dis[k]=0;
    ll maki;
    ll umi;
    while(!que.empty()){
        maki=que.front();
        que.pop();
        umi=v[maki].size();
        for(int i=0;i<umi;i++){
            if(dis[v[maki][i].first]==-1){
                dis[v[maki][i].first]=dis[maki]+v[maki][i].second;
                que.push(v[maki][i].first);
            }
        }
    }
    ll x,y;
    ll ans[q];
    for(int i=0;i<q;i++){
        cin>>x>>y;
        x--;
        y--;
        ans[i]=dis[x]+dis[y];
    }
    for(int i=0;i<q;i++){
        cout << ans[i]<<endl;
    }
    return 0;
}




Measured memory_bytes: 10752
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;

LL n,m;
int main(){
    cin>>n>>m;
    if(n<=m/2)cout<<(LL)((n+m/2)/2)<<endl;
    else cout<<(LL)(m/2)<<endl;	
	
	
    
    
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
a = [int(x) for x in readline().split()]
ans = float('inf')
for x in a:
    ans = min(ans, len(bin(x)) - bin(x).rfind('1') - 1)
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
   ll n,k;
   cin>>n>>k;
   
   ll a[n];
   
   for(ll i=0;i<n;i++)
   cin>>a[i];
   
   for(ll i=k;i<n;i++){
       if(a[i]>a[i-k])
       cout<<"Yes";
       else
       cout<<"No";
       
       cout<<endl;
   }
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 5216
#include <iostream>
#include <fstream>
#include <cstring>
#include <climits>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

#define ll long long

ll dpa[100000];
ll dpb[100000];
ll dpc[100000];

// int solve(int i, int* a, int* b, int* c, int n, bool aa, bool bb, bool cc) {
	
// 	if (n == 0)
// 		return 0;
	
// 	if (dpa[i] == -1)
// 		dpa[i] = a[i] + solve(i+1, a, b, c, n, false, true, true);

// 	if (dpb[i] == -1) 
// 		dpb[i] = b[i] + solve(i+1, a, b, c, n, true, false, true);
	
// 	if (dpc[i] == -1)
// 		dpc[i] = c[i] + solve(i+1, a, b, c, n, true, true, false);
	
// 	if (!aa)
// 		return max(dpb[i], dpc[i]);
// 	if (!bb)
// 		return max(dpa[i], dpc[i]);
// 	if (!cc)
// 		return max(dpa[i], dpb[i]);

// 	return max(max(dpa[i], dpb[i]), dpc[i]);
// }

// int solve(int i, char last) {

// 	if (i == n)
// 		return 0;

// 	if (a[i][last] != -1)
// 		return dp[i][last];

// 	if (last != 1)
// 		dp[i][last] = max(dp[i][last], solve(i+1, 1));
// 	if (last != 2)
// 		dp[i][last] = max(dp[i][last], solve(i+1, 2));
// 	if (last != 3) 
// 		dp[i][last] = max(dp[i][last], solve(i+1, 3));

// 	return dp[i][last];
// }

int solve_ite(int n, int* a, int* b, int* c) {

	dpa[0] = a[0];
	dpb[0] = b[0];
	dpc[0] = c[0];
	for (int i = 1; i < n; ++i) {
		dpa[i] = max(dpb[i-1], dpc[i-1]) + a[i];
		dpb[i] = max(dpc[i-1], dpa[i-1]) + b[i];
		dpc[i] = max(dpa[i-1], dpb[i-1]) + c[i]; 
	}

	return max(dpa[n-1], max(dpb[n-1], dpc[n-1]));
}

int main() {

	int n;
	cin >> n;
	int a[n], b[n], c[n];
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		cin >> b[i];
		cin >> c[i];
	}
	for (int i = 0; i < 100000; ++i) {
		dpa[i] = -1;
		dpb[i] = -1;
		dpc[i] = -1;
	}
	cout << solve_ite(n, a, b, c);


	return 0;
}

Measured memory_bytes: 3712
#include<cstdio>
#include<iostream>
#include<cstring>
#define f(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;i=-(~i))
#define travel(i,u,v,e,head) for(register int i=head[u],v=e[i].v;i;i=e[i].nex,v=e[i].v)
namespace IO
{
	const unsigned int bufsize=1<<15,outsize=1<<24;
	static char ch[bufsize],*S=ch,*T=ch;
	inline char getc()
	{return ((S==T)&&(T=(S=ch)+fread(ch,1,bufsize,stdin),S==T)?0:*S++);}
	static char Out[outsize],*nowp=Out;
	inline void flush(){fwrite(Out,1,nowp-Out,stdout);nowp=Out;}
	template<typename T>
		inline void read(T &x)
		{
			char c=getc();x=0;T p=1;
			if(c=='-')p=-1;
			for(;!isdigit(c);c=getc())if(c=='-')p=-1;
			for(;isdigit(c);x=(x<<1)+(x<<3)+(c^'0'),c=getc());
			x*=p;
		}
	template<typename T>
		inline void write(T x,char c='\n')
		{
			if(!x)*nowp++='0';
			if(x<0)*nowp++='-',x=-x;
			static unsigned int stk[50],tp=0;
			for(;x;x/=10)stk[++tp]=x%10;
			for(;tp;*nowp++=stk[tp--]^'0');*nowp++=c;
		}
	void rstring(char *str)
	{
		char c=getc();
		for(;c^'a'&&c^'b';c=getc());
		int len=0;
		for(;c=='a'||c=='b';c=getc())str[++len]=c;
	}
	void wstring(char *str)
	{
		int len=strlen(str)-1;
		f(i,0,len)*nowp++=str[i];*nowp++='\n';
	}
}
const int neko=100010;
struct edge
{int v,nex;}e[neko],E[neko<<1];
int n;
typedef int arr[neko];
arr head,Head,dgr,ans;
namespace Bi_Graph
{
	using IO::read;
	int t=0,T=0;
	void add(int x,int y)
	{e[++t].v=y,e[t].nex=head[x],head[x]=t;}
	void Add(int x,int y)
	{
		E[++T].v=y,E[T].nex=Head[x],Head[x]=T;	
		E[++T].v=x,E[T].nex=Head[y],Head[y]=T;	
	}
	int dfsinit(int u)
	{
		int now=0,las;
		travel(i,u,v,e,head)if(las=dfsinit(v))
		{
			if(now)Add(now,las),now=0;
			else now=las;
		}return now?now:u;
	}
	void dfs(int u,int fa)
	{
		travel(i,u,v,E,Head)if(ans[v]==-2)ans[v]=-ans[u],dfs(v,u);
	}
	void spangraph(int opt)
	{
		if(opt)memset(head,0,sizeof head),t=0;
		int root,x;
		f(i,1,n)
		{
			read(x),add(x,i);
			if(~x)dgr[x]^=1;
			else root=i;
		}dfsinit(root);
	}
}
int main()
{
	using namespace Bi_Graph;
	using namespace IO;
	char orz[20]="IMPOSSIBLE",qwq[20]="POSSIBLE";
	read(n);
	spangraph(0);
	f(i,1,n)if(!dgr[i])ans[i]=-2;//儿子数量为偶数的点才要填；能填的话第二棵树奇偶性是一样的
	spangraph(1);
	f(i,1,n)if(dgr[i])return wstring(orz),flush(),0;
	wstring(qwq);
	f(i,1,n)if(ans[i]==-2)ans[i]=1,dfs(i,0);
	f(i,1,n)write(ans[i],i^n?' ':'\n');
	return flush(),0;
}

Measured memory_bytes: 9088
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
typedef pair<int, string> P;
int H, W;
bool used[20][20];
void rec(int x, int y, int dx, int dy, string s, map<string, int>& count, vector<string>& grid){
  count[s] += 1;
  used[y][x] = true;
  int nx = (x + dx + W) % W;
  int ny = (y + dy + H) % H;
  if(used[ny][nx]) return;
  rec(nx, ny, dx, dy, s + grid[ny][nx], count, grid);
}

int main(){
  int dx[8] = {1,1,1,0,-1,-1,-1,0};
  int dy[8] = {-1,0,1,1,1,0,-1,-1};
  while(cin>>H>>W && H){
    vector<string> grid(H);
    REP(y, H) cin>>grid[y];
    map<string, int> count;
    REP(y, H)REP(x, W)REP(r, 8){
      memset(used, 0, sizeof(used));
      rec(x, y, dx[r], dy[r], string() + grid[y][x], count, grid);
    }
    vector<P> v;
    FORIT(it, count)if((it->first).size() >= 2 && it->second >= 2) v.push_back(P(-1*(it->first).size(), it->first));
    string ans;
    if(v.empty()) ans = "0";
    else ans = (*min_element(v.begin(), v.end())).second;
    cout<<ans<<endl;
  }
  return 0;
}

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

int main(){
	string s;
  int n;
  cin>>n;
  cin>>s;
  int c=0;
  for(int i=0;i+2<n;i++){
  	if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
      	c++;
  }
  cout<<c;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
  ll N;
  cin >> N;
  vector<string> S(N);
  rep(i, N){
    cin >> S.at(i);
  }
  ll a = 0;
  ll w = 0;
  ll t = 0;
  ll r = 0;
  rep(i, N){
    if(S.at(i) == "AC"){
      a++;
    }
    if(S.at(i) == "WA"){
      w++;
    }
    if(S.at(i) == "TLE"){
      t++;
    }
    if(S.at(i) == "RE"){
      r++;
    }
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << w << endl;
  cout << "TLE x " << t << endl;
  cout << "RE x " << r << endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s;
    if(s.size()%2==1)
    {
        cout<<"No";
        return 0;
    }
    for(int i=0;i+1<s.size();i+=2)
        if(s[i]!='h'||s[i+1]!='i')
    {
        cout<<"No";
        return 0;
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 3532
class Heap():
    def __init__(self, H):
        self.n = len(H)
        self.nodes = {}
        for i, key in enumerate(H):
            self.add_node(i+1, key)
        self.connect()

    def add_node(self, index, key):
        if index not in self.nodes:
            self.nodes[index] = Node(index, key)

    def connect(self):
        for i in range(1, self.n+1):
            if i//2 != 0:
                self.nodes[i].parent = self.nodes[i//2]
            if i*2 <= self.n:
                self.nodes[i].left = self.nodes[i*2]
            if i*2+1 <= self.n:
                self.nodes[i].right = self.nodes[i*2 + 1]


class Node():
    def __init__(self, index, key):
        self.index = index
        self.key = key
        self.parent = None
        self.left = None
        self.right = None

    def __str__(self):
        out = 'node {}: key = {}, '.format(self.index, self.key)
        if self.parent:
            out += 'parent key = {}, '.format(self.parent.key)
        if self.left:
            out += 'left key = {}, '.format(self.left.key)
        if self.right:
            out += 'right key = {}, '.format(self.right.key)
        return out


n = int(input())
H = list(map(int, input().split()))
heap = Heap(H)
for i in range(1, n+1):
    print(heap.nodes[i])



Measured memory_bytes: 5696
def main():
    N = int(input())
    AB = [tuple(map(int, input().split())) for _ in range(N)]
    t = 0
    for a, b in sorted(AB, key=lambda x: x[1]):
        t += a
        if t > b:
            print('No')
            exit()
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 107916
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: chars,
        k: usize
    }
    println!("{}", solve(&n, k));
}

fn solve(n: &Vec<char>, k: usize) -> usize {
    let l = n.len();
    if l == 0 || l < k {
        return 0;
    }
    let n0 = (n[0] as u8 - '0' as u8) as usize;
    let mut z = 0;
    for i in 1..l {
        if n[i] == '0' {
            z += 1;
        } else {
            break;
        }
    }
    let next = n[1 + z..l].to_vec();
    if k == 1 {
        n0 + 9 * (l - 1)
    } else if k == 2 {
        (l - 1) * (l - 2) / 2 * 9 * 9 + (n0 - 1) * (l - 1) * 9 + solve(&next, 1)
    } else {
        (l - 1) * (l - 2) * (l - 3) / 6 * 9 * 9 * 9 + (n0 - 1) * (l - 1) * (l - 2) / 2 * 9 * 9 + solve(&next, 2)
    }
}


Measured memory_bytes: 4352
#include<stdio.h>

#define N 10000

int main(){

  int input_m[N], serch_m[500], m, n, i, j, c=0;

  scanf("%d", &n);

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

  scanf("%d",&m);

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

  for( j = 0; j < m; j ++){
    for( i = 0; i < n; i++){
      if(input_m[i] == serch_m[j]){
	c++;
	break;
      }
    }
}

    printf("%d\n", c);

    return 0;
  }

Measured memory_bytes: 640
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,Y = map(int,input().split())

for m1000 in range(0,N+1):
    for m5000 in range(0,N+1-m1000):
        m10000 = N - m1000 - m5000
        if m10000<0:
            continue
        if Y == m10000*10000 + m5000*5000 + m1000*1000:
            print(m10000,m5000,m1000)
            exit()
print(-1,-1,-1)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <typeinfo>
#include <cmath>
#include <sstream>

using namespace std;

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

	string a, b, res;
	int temp, size, hoge, as, bs;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		hoge = 0;
		res = "";

		as = a.size();
		bs = b.size();
		size = as > bs ? as : bs;
		while (a.size() < size) { a = "0" + a; }
		while (b.size() < size) { b = "0" + b; }

		for (int i = 0; i < size; i++) {
			temp = a[size-i-1]+b[size-i-1]-'0'-'0'+hoge;

			stringstream ss;
			ss << temp % 10;
			if (temp > 9) {
				res = ss.str() + res;
				hoge = temp / 10;
			}
			else {
				res = ss.str() + res;
				hoge = 0;
			}
		}

		stringstream ss;
		ss << hoge;
		if (hoge > 0) {
			res = ss.str() + res;
		}
		
		if (res.size() > 80) {
			cout << "overflow";
		}
		else {
			cout << res;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  
 /* ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  */
  ll s,w;
  
  cin>>s>>w;
  
  if(w>=s)
    cout<<"unsafe";
  
  else
    cout<<"safe";
  
  return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

typedef long long ll;
const ll maxn=2e3+10;
ll n,a[maxn],x,cost[maxn][maxn],ans=1e18;

int main(){
	ios::sync_with_stdio(false);
	cin>>n>>x;
	for(ll i=1;i<=n;++i)
		cin>>a[i];
	for(ll i=1;i<=n;++i){
		cost[i][0]=a[i];
		for(ll k=1;k<n;++k)
			cost[i][k]=min(cost[i][k-1],a[(i+n-k-1)%n+1]);
	}
	for(ll i=0;i<n;++i){
		ll tot=0;
		for(ll j=1;j<=n;++j)
			tot+=cost[j][i];
		ans=min(ans,tot+i*x);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 31744
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    cin >> n;
    int ans = INT_MAX;
    for(int i = 1;i < n;i++)
    {
        int x = i;
        int y = n - i;
        int temp = 0;
        while(x > 0)
        {
            temp += x % 10;
            x /= 10;
        }
        while(y > 0)
        {
            temp += y % 10;
            y /= 10;
        }
        if(temp < ans)
        {
            ans = temp;
        }
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
const int INF = 1000100100;

int main(){
    ll k;
    cin>>k;
    rep(i,k){
        cout<<"ACL";
    }
    cout<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

int main()
{
  unsigned N, C, K;
  std::cin >> N >> C >> K;

  std::vector<unsigned> T(N);
  N_TIMES(n, N) std::cin >> T[n];
  std::sort(T.begin(), T.end());

  unsigned max = T[0] + K, count = 0, bus = 0;
  N_TIMES(n, N) {
    if (T[n] <= max) {
      ++count;
    } else {
      ++bus;

      max = T[n] + K;
      count = 1;
    }

    if (count == C) {
      ++bus;

      max = T[n + 1] + K;
      count = 0;
    }
  }

  if (count > 0) ++bus;

  std::cout << bus << std::endl;

  return 0;
}

Measured memory_bytes: 640
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

n,m = map(int,input().split())
x = sorted(list(map(int,input().split())))
diff = []
visit = [False]*m
visit[0] = True
if m == 1 or n>=m:
    print(0)
    sys.exit()
for i in range(m-1):
    d = x[i+1] - x[i]
    diff.append(d)
diff.sort(reverse= True)
for i in range(n-1):
    diff[i] = 0
print(sum(diff))

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n);
	rep(i, n) cin >>a[i];
	ll ans[2] = {};
	
	rep(g, 2){
		ll cur =0;
		rep(i, n){
			cur += a[i];
			dbg(g,i,  cur,ans[g]);
			if(cur >=0 && (g+i)%2){
				ll s = -1 - cur; cur=-1;
				ans[g] += abs(s);
			}else if(cur <=0 && (g+i)%2==0){
				ll s = 1 -cur;  cur=1;
				ans[g] +=abs(s);
			}
		}
	}
	dbg(ans[0], ans[1]);
	cout << min(ans[0], ans[1]) <<"\n";
	return 0;
}

Measured memory_bytes: 640
N,M = map(int,input().split())
sutdent = []
point = []
INF = float("inf")
anss = []
for i in range(N):
    a,b = map(int,input().split())
    sutdent.append((a,b))
for i in range(M):
    c,d = map(int,input().split())
    point.append((c,d))
for a,b in sutdent:
    ans = INF
    index = 0
    for num,(c,d) in enumerate(point):
        count = abs(a-c)+abs(b-d)
        if count<ans:
            ans=count
            index = num+1
    anss.append(index)
for a in anss:
    print(a)

Measured memory_bytes: 3064
{
	const process = (a: string[][]): string => {
		const aa = a.map((e) => e.map((ee) => parseInt(ee)))
		const n = aa[0][0]
		const m = aa[0][1]
		const x = aa[0][2]
		const y = aa[0][3]
		const xx = aa[1]
		const yy = aa[2]

		if (y - x <= 0) {
			return "War"
		}
		const xxMax = Math.max(...xx)
		const yyMin = Math.min(...yy)

		if (yyMin - xxMax <= 0) {
			return "War"
		}

		if (yyMin > x && xxMax < y) {
			return "No War"
		}
		return "War"
	}

	const Main = (input: string): void => {
		//const n: number = parseInt(input)
		//const a: string[]  = input.split(" ")
		const aa: string[][]  = input.split("\n").map((e) => e.split(" "))
		console.log(process(aa))
	}

	Main(require("fs").readFileSync("/dev/stdin", "utf8"))
}


Measured memory_bytes: 11596
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 *
 * AND WATCH OUT FOR OFF BY ONE!!!
 */

#include <bits/stdc++.h>
const bool unsyncedio=std::ios::sync_with_stdio(false);
using namespace std;
typedef unsigned int uint;
typedef long long ll;

#define fori(n) for(ll i=0; i<(n); i++)
#define forn(i, n) for(ll (i)=0; (i)<(n); (i)++)

int main() {
ll a, b, t;
    cin>>a>>b>>t;

    ll ans=b*(t/a);
    cout<<ans<<endl;

}



Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define pb push_back
     
    using namespace std;
    using ll = long long int;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;


int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<string>> s(h, vector<string>(w));
    rep(i, h)rep(j, w){
        cin >> s[i][j];
        if(s[i][j] == "snuke"){
            cout << (char)('A' + j) << i + 1 << endl;
        }
    }
    
}



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

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	ll x; cin>>x;
	for(ll a = 1; ; a++){
		ll b5 = a*a*a*a*a - x;
		if(b5 < 0){
			ll tmp = pow(-b5, 0.2) - 1;
			while(tmp*tmp*tmp*tmp*tmp < -b5)tmp++;
			if(tmp*tmp*tmp*tmp*tmp == -b5){
				cout<<a<<" "<<-tmp<<endl;
				exit(0);
			}
		}else{
			ll tmp = pow(b5, 0.2) - 1;
			while(tmp*tmp*tmp*tmp*tmp < b5)tmp++;
			if(tmp*tmp*tmp*tmp*tmp == b5){
				cout<<a<<" "<<tmp<<endl;
				exit(0);
			}
		}
	}

	return 0;
}

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

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

  vector<int> S(M), C(M);
  for (int i = 0; i < M; i++) cin >> S.at(i) >> C.at(i);
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < i; j++) {
      if (S.at(i) == S.at(j)) if (C.at(i) != C.at(j)) return cout << -1 << "\n", 0;
    }
  }

  for (int i = 0; i < 1000; i++) {
    string tmp = to_string(i);
    if (tmp.size() != N) continue;
    for (int i = 0; i < M; i++) {
      if (tmp.at(S.at(i) - 1) - '0' != C.at(i)) goto NG;
    }
    return cout << i << "\n", 0;
    NG: ;
  }
  cout << -1 << "\n";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int h,w,n;
    cin>>h>>w>>n;
    int p=max(h,w);
    int i=1;
    for(i;p<n;i++){
        p+=max(h,w);
    }
    cout<<i;

    return 0;
}


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

int main(){
  int N, M;
  cin >> N;
  map<string, int> m;
  for(int i=0; i<N; ++i){
    string s;
    cin >> s;
    if(m.find(s)==m.end()) m[s] = 1;
    else m[s]++;
  }
  cin >> M;
  for(int i=0; i<M; ++i){
    string s;
    cin >> s;
    if(m.find(s)==m.end()) m[s] = -1;
    else m[s]--;
  }

  int ans = 0;
  for(auto x: m){
    ans = max(ans, x.second);
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	int n; cin >> n;
	map<int,int> dic;
	int a;
	ll s = 0;
	Rep(n){
		cin >> a;
		s += (ll)a;
		dic[a]++;
	}
	int b,c;
	int q; cin >> q;
	Rep(q){
		cin >> b >> c;
		s += (ll)(c-b) * dic[b];
		dic[c] += dic[b];
		dic[b] = 0;
		cout << s << endl;
	}
}

Measured memory_bytes: 8060