akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
  	int N;
	cin >> N;
  	if (N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9) cout << "hon" << endl;
  	if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) cout << "pon" << endl;
  	if (N % 10 == 3) cout << "bon" << endl;
}

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

#define int long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define endl "\n"

int32_t main()
{
	IOS;
	int n, x;
	cin >> n;
	unordered_map<int, int>m;
	for (int i = 2; i <= n; i++)
	{
		cin >> x;
		m[x]++;
	}
	for (int i = 1; i <= n; i++)
		cout << m[i] << endl;
	//cout << endl;


	return 0;
}

Measured memory_bytes: 11428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }





void solve() {
    int a, p;
    cin >> a >> p;
    p += a * 3;
    cout << p / 2 << endl;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int h,w,n;
    cin >> h >> w >> n;
    int m = max(h,w);
    cout << (n - 1) / m + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>

using namespace std;

int n = 0;
int h[100000] = {};

int main() {

	int n = 0;
	int now = 1e9;

	cin >> n;

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

	for (int i = n - 1; i >= 0; i--) {

		if (now > h[i]) {
			now = h[i];
		}

		if (h[i] > now + 1) {
			cout << "No" << endl;
			return 0;
		}


	}
	cout << "Yes" << endl;
	return 0;

}

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

using namespace std;

int main(){
    string s, t, ans="No";
    int i;
    cin >> s >> t;

    vector<char> vs, vt;

    for (i=0; i<s.length(); i++) {
        vs.push_back(s[i]);
    }
    for (i=0; i<t.length(); i++) {
        vt.push_back(t[i]);
    }

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

    for (i=0; i<min(s.length(), t.length()); i++) {
        if (vs[i] < vt[i]) {
            ans = "Yes";
            break;
        }
    }

    if (s.length() < t.length()) {
        i=0;
        while (vs[i] == vt[i]) {
            i++;
        }
        if (i == s.length()) {
            ans = "Yes";
        }   
    }

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


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M,S=map(int,input().split())
    
    X=2500
    edge=[[] for _ in range(N*X)]
    for _ in range(M):
        U,V,A,B=map(int,input().split())
        U-=1
        V-=1
        for i in range(A,X):
            edge[U*X+i].append((B,V*X+i-A))
            edge[V*X+i].append((B,U*X+i-A))
    for i in range(N):
        C,D=map(int,input().split())
        for j in range(X-C):
            edge[i*X+j].append((D,i*X+j+C))

    from heapq import heappop,heappush
    def dijkstra(start,n,edges):
        d=[INF]*n
        used=[False]*n
        d[start]=0
        used[start]=True
        edgelist=[]
        for edge in edges[start]:
            heappush(edgelist,edge)
        while edgelist:
            minedge=heappop(edgelist)
            if used[minedge[1]]:
                continue
            v=minedge[1]
            d[v]=minedge[0]
            used[v]=True
            for edge in edges[v]:
                if not used[edge[1]]:
                    heappush(edgelist,(edge[0]+d[v],edge[1]))
        return d
    
    d=dijkstra(min(S,X-1),N*X,edge)
    for i in range(1,N):
        print(min(d[i*X:(i+1)*X]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 123896
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld",&n);
  rep(i,3*n){
    scanf("%d",&a[i]);
  }
  qsort(a,3*n,sizeof(int),downint);
  rep(i,n){
    result+=(ll)a[2*i+1];
  }
  printf("%lld", result);
  
  return 0;
}



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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using llu = long long unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int X;
    Scd(X);
    YesNo(X>=30);


    return 0;
}



Measured memory_bytes: 3760
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
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;}




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

  ll N, M ; cin >> N >> M ;
  ll t = 1900 * M + (N-M) * 100;
  
  cout << t*pow(2,M)  << endl;
  
  
    
  
  
    
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>                                                                    
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> count(N);
  for(int i=0; i<N; i++){
    for(int j=i+1; j>0; j/=2){
      if(j%2==0)
        count.at(i)++;
      else
        break;
    }
  }
  int max=-1;
  int max_point;
  for(int i=0; i<N; i++){
    if(max<count.at(i)){
      max=count.at(i);
      max_point=i+1;
    }
  }
  cout << max_point << endl;
}

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

using namespace std;

int main() {
    int n;
    cin>>n;
    int arr[n][2];
    
    for(int i=0; i<n; i++) 
        cin>>arr[i][0]>>arr[i][1];

    for(int i=0; i<n-2; i++) {
        if(arr[i][0] == arr[i][1] && arr[i+1][0] == arr[i+1][1] && arr[i+2][0] == arr[i+2][1]) {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3596
sa, sb, sc = [input().strip() for _ in range(3)]

t = 'a'
w = ''
while True:
    if t == 'a':
        if len(sa) == 0:
            w = 'A'
            break

        t = sa[0]
        sa = sa[1:]
    elif t == 'b':
        if len(sb) == 0:
            w = 'B'
            break

        t = sb[0]
        sb = sb[1:]
    else:
        if len(sc) == 0:
            w = 'C'
            break

        t = sc[0]
        sc = sc[1:]


print(w)

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
#define forn(i,a,b) for(int i=a; i<=b; i++)
#define ford(i,a,b) for(int i=a; i>=b; i--)
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	string x,y;
	cin>>x>>y;
	y.erase(y.length()-1,1);
	(x==y) ?  cout<<"Yes\n" : cout<<"No\n"; 
	return 0;
}

Measured memory_bytes: 3644
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


x = ni()
s= [[[] for j in range(26)] for i in range(26)]
sum=0
for i in range(x):
    si=ns()
    sn1=ord(si[0:1])-97
    if len(si)==1:
        sn2=0
    else:
        sn2 = ord(si[1:2]) - 97
    if si not in s[sn1][sn2]:
       s[sn1][sn2].append(si)
for s1 in s:
    for s2 in s1:
        sum+=len(s2)
print(sum)

Measured memory_bytes: 24088
H, W = map(int, input().split())
a = [input() for _ in range(H)]

kari = []
for i in a:
    if "#" not in i:
        H -= 1
        continue
    kari.append(i)

ans = ["" for _ in range(H)]
for i in range(W):
    for j in range(H):
        if kari[j][i] == "#":
            for k in range(H):
                ans[k] += kari[k][i]
            break

for i in ans:
    print(i)

Measured memory_bytes: 3064
#include "iostream"
#include "set"
#include<cstring>
using namespace std;
int main()
{
    int n;
    cin>>n;
    set<string> s;
    string c;
    for(int i=0;i<n;i++)
    {
        cin>>c;

        s.insert(c);
        
    }

    cout<<s.size()<<endl;
    

}


Measured memory_bytes: 19180
#include<bits/stdc++.h>
using namespace std;
int main(){
  string X;
  cin >> X;
  int ans = 0;
  int RS = 0;
  for(auto&& c:X){
    if(c == 'S'){
      ans += 1;
      RS += 1;
    }else{
      if(RS > 0){
        ans -= 1;
        RS -= 1;
      }else{
        ans += 1;
      }
    }
    // cerr << c << " " << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
N = int(input())
B = [int(s) for s in input().split()]

A = [0] * N

for i in range(1, N - 1):
    A[i] = min(B[i - 1], B[i])

A[0] = B[0]
A[N - 1] = B[N - 2]

print(sum(A))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair < int , int > pii;
#define mpr make_pair
#define FS first
#define SC second
#define PB push_back
template < typename T > T MAX(T a,T b){return (a>b)?a:b;}
template < typename T > T MIN(T a,T b){return (a<b)?a:b;}
template < typename T > void UMAX(T &a,T b){a=(a>b?a:b);}
template < typename T > void UMIN(T &a,T b){a=(a<b?a:b);}
LL readint(){
	char c=getchar();
	LL ret=0ll;
	while(!(c>='0' && c<='9')) c=getchar();
	while(c>='0' && c<='9'){
		ret=ret*10ll+(LL)(c-'0');
		c=getchar();
	}
	return ret;
}
void putint(LL v){
	if(!v){
		putchar('0');
		return;
	}
	if(v>=10ll) putint(v/10ll);
	putchar('0'+(v%10ll));
}
LL n,A,B,C,D;
map < LL , LL > res;
priority_queue < LL > pq;
void upd(LL d,LL v){
	if(!res.count(d) || res[d]>v){
		res[d]=v;
		pq.push(d);
	}
}
void solve(){
	int i,j,k;
	n=readint();A=readint();B=readint();C=readint();D=readint();
	res.clear();
	while(!pq.empty()) pq.pop();
	res[n]=0;
	pq.push(n);
	while(!pq.empty()){
		LL tv=pq.top(),tr=res[tv];
		pq.pop();
//		if(tv<10){
//			for(i=1;i<=tv;++i){
//				upd(tv-i,tr+D*i);
//			}
//		}
		if(log(tv)+log(D)<log(1e18)) upd(0,tr+tv*D);
		upd(tv/2,tr+A+(tv%2)*D);
		if(tv/2+1<tv) upd(tv/2+1,tr+A+((tv/2+1)*2-tv)*D);
		upd(tv/3,tr+B+(tv%3)*D);
		if(tv/3+1<tv) upd(tv/3+1,tr+B+((tv/3+1)*3-tv)*D);
		upd(tv/5,tr+C+(tv%5)*D);
		if(tv/5+1<tv) upd(tv/5+1,tr+C+((tv/5+1)*5-tv)*D);
	}
	printf("%lld\n",res[0]);
}
int main(){
	int t=readint();
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 5004
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, m, a, b, c, sesame, dp[5555];
    rep(i, 5555) dp[i] = INF;
    dp[0] = 0;
    cin>>n>>m;
    rep(i, m) {
        cin>>a>>b;
        sesame = 0;
        while(b--) {
            cin>>c;
            c--;
            sesame += (int)pow(2, c);
        }
        rep(i, (int)pow(2, n)) {
            chmin(dp[i | sesame], dp[i] + a);
        }
    }
    cout<<(dp[(int)pow(2, n) - 1] == INF ? -1 : dp[(int)pow(2, n) - 1])<<endl;
}


Measured memory_bytes: 384
#include <climits>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <sstream>
 #include <string>
using namespace std;

void swap(int &x, int &y) {
    int tmp = x;
    x = y;
    y = tmp;
}



int partition(vector<int> &A, int p, int r) {
    int x = A[r - 1]; //分割の基準となる値
    int i = p; //配列のインデックス(先頭)

    for (int j = p; j < r-1; ++j)
    {
        //基準値以下の値を配列の前の方に持っていく
        if(A[j] <= x) {
            swap(A[i], A[j]);
            i++;
        }

        // for (int k = 0; k < A.size(); ++k)
        // {
        //     printf("%2d ", A[k]);
        // }
        // cout << endl;

    }

    //基準値を、「基準値以下の値」と「基準値を超える値」の境目に挿入する
    swap(A[i], A[r - 1]);

    return i;
}


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

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


    int q = partition(A, 0, n);
    for (int i = 0; i < n; ++i)
    {
        int out = A[i];
        if(i == q) {
            cout << "[" << out << "]";
        } else {
            cout << out;
        }

        if(i < n - 1) {
            cout << " ";
        }
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 3116
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define EPS 1e-14
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define PI 2*acos(0.0)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cout<<#x <<": "<< x << "\n"
#define DEBUG_ARR(a) REP(i, size(a)){ cout << #a << "[" << i << "]: " << a[i] << "\n"; }

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

	int c1, c5, c10, c50, c100, c500;
	cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
	if (c500 * 500 + c100 * 100 + c50 * 50 + c10 * 10 + c5 * 5 + c1 >= 1000)
		cout << 1 << "\n";
	else
		cout << 0 << "\n";

	return 0;
}

Measured memory_bytes: 3216
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 300000

vector<int>e[N];
vector< vector<long long> >a;
int nx;


int dfs(int k){
int b;

vector<pair<int,int> >c;
int m;
long long ww,xx,yy,zz;

f(i,e[k].size()){
b=dfs(e[k][i]);
c.push_back(make_pair(a[b].size(),b));
}

if(c.size()>0){
sort(c.begin(),c.end(),greater<pair<int,int> >());
b=c[0].second;

if(c.size()>1){

f(i,c[1].first){
m=0;

f(j,c.size()){
if(c[j].first>i)m++;
else break;
}

xx=1;
zz=0;

f(j,m){
ww=a[c[j].second][c[j].first-i-1];
yy=(MOD+1-ww);
if(yy>=MOD)yy=yy%MOD;

zz=zz*yy;
zz=zz%MOD;

ww=ww*xx;
ww=ww%MOD;
zz+=ww;
zz=zz%MOD;

xx=xx*yy;
xx=xx%MOD;
}

a[b][c[0].first-i-1]=zz;

}

}
}
else{
vector<long long>d;
d.push_back(((MOD+1)/2));
a.push_back(d);
nx++;
return nx;
}
a[b].push_back(((MOD+1)/2));
return b;
}




int main(){
	int n, x;
	long long ans;
	ans = 0;
	scanf("%d", &n);
	f(i,n){
		scanf("%d", &x);
		e[x].push_back(i+1);
	}
nx=-1;
x=dfs(0);
f(i,a[x].size()){
ans+=a[x][i];
ans=ans%MOD;
}
f(i,n+1){
ans=ans*2;
ans=ans%MOD;
}
	printf("%lld\n", ans);


	return 0;
}


Measured memory_bytes: 50040
use std::io;
use std::str::FromStr;

fn main(){
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());
    let (mut l, mut r, mut d) = (it.next().unwrap(), it.next().unwrap(), it.next().unwrap());
    l -= 1;
    println!("{}", r / d - l / d);
}

Measured memory_bytes: 2112
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> p;
 
#define MOD 1000000007
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    ll mod = pow(10, 9) + 7LL;

    ll N, K;
    cin >> N >> K;

    vector<bool> b(N);
    vector<vector<int> > v(N);

    for(int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    ll ans = K;

    stack<int> s;

    b[0] = true;

    if(K - 1 < v[0].size()) {
        cout << 0 << endl;
        return 0;
    }

    for(int i = K - 1; i > K - 1 - v[0].size(); i--) {
        ans *= i;
        ans %= mod;
    }

    for(int i = 0; i < v[0].size(); i++) {
        b[v[0][i]] = true;
        s.push(v[0][i]);
    }

    while(!s.empty()) {
        int a = s.top();
        s.pop();

        if(K - 1 < v[a].size()) {
            cout << 0 << endl;
            return 0;
        }

        for(int i = K - 2; i > K - 1 - v[a].size(); i--) {
            ans *= i;
            ans %= mod;
        }

        for(int i = 0; i < v[a].size(); i++) {
            if(b[v[a][i]]) continue;
            b[v[a][i]] = true;
            s.push(v[a][i]);
        }
    }

    cout << ans << endl;
}

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

int main() {
char a[3],b[3];
  cin>>a>>b;
  
  if(a[0]==b[2] && a[1]==b[1] && a[2]==b[0]){cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
    // 入力を解釈
	// input = input.split("\n");
	tmp = input.split(" ");

    var A = tmp[0];
	var B = tmp[1];
	var T = parseInt(tmp[2]) + 0.5;

    var interval = Math.floor(T / A);
    
	
	// 文字を10進数に変換
	// var a = parseInt(input[0], 10);


	//出力
	console.log(interval * B);
}

var counter = function(str,seq){
    return str.split(seq).length - 1;
}

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

Measured memory_bytes: 11468
N = gets.to_i
array = gets.split.map(&:to_i)
count = 0

0.upto(N - 1) do |i|
  minj = i

  i.upto(N - 1) do |j|
    if array[j] < array[minj]
      minj = j
    end
  end

  unless i == minj
    array[i], array[minj] = array[minj], array[i]
    count += 1
  end
end

puts array.join(' ')
puts count

Measured memory_bytes: 8688
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, 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: usize,
        k: usize,
    }
    let mut ans = (n - k) / (k - 1) + 1;
    if (n - k) % (k - 1) != 0 {
        ans += 1;
    }
    println!("{}", ans);
}


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



int main(){
    string s; cin >>s;
    char a,b;
    int aa=0,bb=0;
    string ans="n";
    for(int i=0;i<4;i++){
        if(i==0){
            a=s[i]; aa++; continue;
        }
        if(s[i]!=a){
            if(bb==0){b=s[i]; bb++;}
            else if(b==s[i]){bb++;}
            else ans="No";
        }else{aa++;}
    }
    if(ans!="No"){
        if(aa==2&&bb==2){
            ans="Yes";
        }else{ans="No";}
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 256
// 要素の合計が最大となるような組み合わせを探す
#include<iostream>
#include<iomanip>

int findmaxcombination(int p[], int n, int k){
    int csum=0, max=0, startpointindex=0;
    if(n==k) return 0;
    else{
        for(int i=0; i<n; i++){
            if(i-k < 0) csum += p[i];
            else{
                csum = csum - p[i-k] + p[i];
                if(csum > max){
                    max = csum;
                    startpointindex = i - k +1;
                }
            }
        }
        return startpointindex;
    }

}

double getMean(int p){
    double sum=0, mean=0;
    for(int i=1; i<=p; i++){
        sum += i;
    }
    mean = sum / (double)p;
    //std::cout << "mean of " << p <<" = " << mean << std::endl;

    return mean;
}

double getMeanSum(int A[], int index, int k){
    double  meansum=0;
    for(int i=index; i < index + k; i++){
        meansum += getMean(A[i]);
    }
    return meansum;

}

int main(void){
    std::cout << std::fixed;
    int N, K;
    std::cin >> N >> K;
    int p[N];
    for(int i=0; i<N; i++){
        std::cin >> p[i];
    }
    int index = findmaxcombination(p, N, K);
    //std::cout << "index = " << index << std::endl;
    double ans = getMeanSum(p, index, K);

    std::cout << std::setprecision(12) << ans << std::endl;
    return 0;
}

Measured memory_bytes: 1024
def main():
    n, m = map(int, input().split())

    ab = sorted([list(map(int, input().split())) for _ in range(n)])
    ans = 0

    for i, j in ab:
        if m >= j:
            m -= j
            ans += i*j
        elif m < j:
            ans += i*m
            break

    print(ans)

main()

Measured memory_bytes: 28652
#include <stdio.h>

int main(void){
int a;
int b;
int goukei;

scanf("%d%d",&a,&b);

goukei = a+b;

if(a%3==0){
printf("Possible");
}else if(b%3==0){
printf("Possible");
}else if(goukei%3==0){
printf("Possible");
}else{
printf("Impossible");
}
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

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

    int ans = 0;
    for(int i=0; i<2; i++){
        if(a>=b){
            ans += a;
            a--;
        }else{
            ans += b;
            b--;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [ for i in 1..n do yield stream.ReadLine().Split() |> Array.map f ]
  member this.ScanCharMatrix n = [| for i in 1..n -> stream.ReadLine().ToCharArray() |]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let H, W = util.Scan2 int
let h, w = util.Scan2 int

H*W - (h*W + w*H - h*w)
|> printfn "%d" 



Measured memory_bytes: 14040
var lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');

var N = +lines[0];
var Ls = lines[1].split(' ').map(Number);

Ls = Ls.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);

var total = 0;
for (var i = 0; i < Ls.length; i += 2) {
    total += Ls[i];
}
console.log(total);


Measured memory_bytes: 14712
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	int res = a;
	if (a > b)res--;
	cout << res << endl;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <unordered_set>
#include <unordered_map>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define debug( fmt, ... ) \
        fprintf( stderr, \
                  fmt "\n", \
                  ##__VA_ARGS__ \
        )

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1 << 30;
const double EPS = 1e-10;

double zero(double d) {
    return abs(d) < EPS ? 0.0 : d;
}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, a.size()) os << (i ? " " : "") << a[i];
    return os << ']';
}

string toString(int i) {
    stringstream ss;
    ss << i;
    return ss.str();
}

const int MOD = 1000000007;
// a^k
ll fpow(ll a, ll k, int M) {
    ll res = 1ll;
    ll x = a;
    while (k != 0) {
        if ((k & 1) == 1)
            res = (res * x) % M;
        x = (x * x) % M;
        k >>= 1;
    }
    return res;
}

struct prepare {
	prepare() {
	    cout.setf(ios::fixed, ios::floatfield);
	    cout.precision(8);
	    ios_base::sync_with_stdio(false);
	}
} _prepare;

bool solve() {
int a,b,c;
    cin>>a>>b>>c;
    int u = a*100+b*10+c;
    if(u%4==0)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}

int main() {
    auto res = solve();	
	
    return 0;
}


Measured memory_bytes: 256
import sys
from itertools import accumulate
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))

    for _ in range(60 if k >= 60 else k):
        B = [0] * (n + 1)
        for i in range(n):
            left = max(0, i - A[i])
            right = min(n, i + A[i] + 1)
            B[left] += 1
            B[right] -= 1

        B = list(accumulate(B))
        A = B
    print(*B[:n])


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 233656
// mod 組み合わせ計算　縦列も
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

// 自動でmodを取ってくれる整数型
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const { //pow(a, b) aのb乗
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) { // コロン以下は初期化子リスト
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv(); // fact[i]の逆元
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
  int n,k;
  cin>>n>>k;
  mint ans=0;
  combination c(n);
  for(int i=0;i<=min(n-1,k);i++){
    ans+=c(n,i)*c(n-1,i); // nCi*(n-i)Hi nHr=(n+r-1)Cr
//    cout<<i<<endl;
  }
  cout<<ans.x<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) rep2(i,0,n-1)
int MOD=1000000000+7;
int INF=1e6;
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int a,b;
cin>>a>>b;
    if(b>=a) cout<<a;
    if(b<a) cout<<a-1;
    return 0;
}


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

#define f first
#define s second
#define ll long long
#define pb push_back
#define mp make_pair
#define inp(x) cin>>x
#define print(x) cout<<x
#define pii pair<int,int>
#define pll pair<ll,ll>
#define gcd(a,b) __gcd(a,b)
#define reset(d,val) memset(d,val,sizeof(d))
#define sort(v) sort(v.begin(),v.end())
#define sort_arr(arr,i,f) sort(arr+i,arr+f)
#define pq priority_queue<int,vector<int>,greater<int> >
#define pq1 priority_queue<pll,vector<pll>,greater<pll> >

const int mod = 1e9+7;



int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll d;
	cin>>d;
	//int cnt=0;
	int ans=0;
	for (ll i = 2; i*i <=d; ++i)
	{
		if(d%i==0){
			int prev_cnt=0;
			int cur_cur=0;
			while(d%i==0) {
				d/=i;
				cur_cur++;
				if(prev_cnt<cur_cur) {
					ans ++;
					prev_cnt = cur_cur;
					cur_cur=0;
				}
			}
		}
	}
	if(d>1) ans++;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3636
/**
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 2019-11-22:17:43:12
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

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

  int n, W; cin >> n >> W;
  vector<int64> w(n), v(n);
  for (int i = 0; i < n; ++i) cin >> w[i] >> v[i];

  vector<vector<int64>> dp(n + 5, vector<int64>(W + 5, 0LL));
  
  for (int i = 0; i < n; ++i) {
    for (int64 j = 0; j <= W; ++j) {
      if (j - w[i] >= 0LL){
        dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
      } else {
        dp[i + 1][j] = dp[i][j];
      }
    }
  }
  //debug(dp[n]);
  cout << dp[n][W] << endl;

  return 0;
}

Measured memory_bytes: 83328
#include<stdio.h>
#define min(a,b) (a)<(b)?(a):(b)
int main(void)
{
  int n,k,ans=0;
  char s[100010];
  scanf("%d%d%s",&n,&k,s);
  for(int i=0;i<n-1;i++){
    if(s[i]==s[i+1]){
      ans++;
    }
  }
  printf("%d",min(ans+2*k,n-1));
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
	
		Scanner in = new Scanner(System.in);

		double A = in.nextDouble();
		double B = in.nextDouble();
		
		double C = Math.abs((A+B)/2);
		if(C==(int)C) {
			System.out.println((int)C);
		}
		else {
			System.out.println("IMPOSSIBLE");
		}
	}

}


Measured memory_bytes: 37236
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
string s,t;
int main(){
	cin>>s>>t;
	int ans=0;
	for(int i=0;i<s.size();i++)ans+=(s[i]==t[i]);
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  rep(i, n) cin >> x.at(i);
  rep(i, n) cin >> y.at(i);
  double d1 = 0;
  rep(i, n) {
    d1 += abs(x.at(i) - y.at(i));
  }
  
  double d2 = 0;
  rep(i, n) {
    d2 += pow(abs(x.at(i) - y.at(i)), 2);
  }
  d2 = sqrt(d2);

  double d3 = 0;
  rep(i, n) {
    d3 += pow(abs(x.at(i) - y.at(i)), 3);
  }
  d3 = pow(d3, 1.0 / 3);
  
  double d4 = 0;
  rep(i, n) {
    d4 = max(d4, fabs(x.at(i) - y.at(i)));
  }
  cout << fixed << setprecision(10);
  cout << d1 << endl;
  cout << d2 << endl;
  cout << d3 << endl;
  cout << d4 << endl;
}


Measured memory_bytes: 3396
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    long long H,W;
    cin>>H>>W;
    long ans=1e18;
    for(int i=0;i<2;i++){
        for(int i=1;i<H;i++){
            long a=i*W;
            long b=(W/2)*(H-i);
            long c=((W+1)/2)*(H-i);
            ans=min(ans,max({a,b,c})-min({a,b,c}));
            b=((H-i)/2)*W;
            c=((H-i+1)/2)*W;
            ans=min(ans,max({a,b,c})-min({a,b,c}));
        }
        swap(H,W);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main() {
  int number_n, i, temp_a = 0, temp_b = 0, sum = 0, answer;
  scanf("%d", &number_n);
  int weight[number_n];
  for(i = 0; i < number_n; i++) {
    scanf("%d", &weight[i]);
    sum += weight[i];
  }
  for(i = 0; i < number_n; i++) {
    temp_a += weight[i];
    if(sum <= temp_a * 2) break;
    else temp_b = temp_a;
  }
  if(abs(sum - 2 * temp_a) < abs(sum - 2 * temp_b)) answer = 2 * temp_a - sum;
  else answer = sum - 2 * temp_b;
  printf("%d\n", answer);
  return 0;
}


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

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

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

	for (int j = 0; j < n; j++){
		if (j == n - 1) cout << a[n-j-1] << endl;
		else cout << a[n-j-1] << " ";
	}

	return 0;
}


Measured memory_bytes: 3088
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
using namespace std;
int main(){
	
	map<double,string> s;
	vector<double> t1(8);
	vector<double> t2(8);
	vector<double> t3(8);
	vector<double> t4;
	for(int i=0;i<8;i++){
		string a;
		cin>>a>>t1[i];
		s[t1[i]]=a;
	}
	for(int i=0;i<8;i++){
		string a;
		cin>>a>>t2[i];
		s[t2[i]]=a;
	}
	for(int i=0;i<8;i++){
		string a;
		cin>>a>>t3[i];
		s[t3[i]]=a;
	}
	
	
	sort(t1.begin(),t1.end());
	sort(t2.begin(),t2.end());
	sort(t3.begin(),t3.end());
	
	for(int i=2;i<8;i++){
		t4.push_back(t1[i]);
		t4.push_back(t2[i]);
		t4.push_back(t3[i]);
	}
	sort(t4.begin(),t4.end());
	
	
	cout<<s[t1[0]]<<" "<<t1[0]<<endl;
	cout<<s[t1[1]]<<" "<<t1[1]<<endl;
	cout<<s[t2[0]]<<" "<<t2[0]<<endl;
	cout<<s[t2[1]]<<" "<<t2[1]<<endl;
	cout<<s[t3[0]]<<" "<<t3[0]<<endl;
	cout<<s[t3[1]]<<" "<<t3[1]<<endl; 
	cout<<s[t4[0]]<<" "<<t4[0]<<endl;
	cout<<s[t4[1]]<<" "<<t4[1]<<endl;
	
	
	
	
}

Measured memory_bytes: 1324
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define ull unsigned long long
#define ff first
#define ss second
#define Mod 1000000007
//#define Mod 998244353
#define nl "\n" 
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define f(i, a, b) for (ll i = a; i < b; ++i)
#define rf(i, a, b) for (ll i = a; i >= b; --i)
#define vll vector<ll>
#define pll pair<ll, ll>
#define mem(a, b) memset(a, b, sizeof(a))
#define printv(v) for(int i=0;i<v.size();i++) { cout<<v[i]<<" "; } cout<<nl;
using namespace std;
inline bool kthbit(ll n, int k) { return (n >> k) & 1; }
ll pw(ll a, ll b){ll c = 1, m = a;while (b){if (b & 1) c = (c * m);m = (m * m);b /= 2;}return c;}
//------------------------------------------------------------------------------------------------

const int MAX = 500005; 
struct Query 
{ 
    int l, r, idx; 
}; 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit));  
    int ans[q]; 
    int query_counter = 0; 
    f(i,0,n) 
    {
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
    f(i,0,q) 
        cout<<ans[i]<<nl; 
} 
int main()
{
    fast;
    ll T=1;
    //cin>>T; //comment for single test

    while(T--)
    {
        //code...
        int n,q;
        cin>>n>>q;
        int a[n];
        Query queries[q]; 
        f(i,0,n)
        {
            cin>>a[i];
        }
        f(i,0,q)
        {
            int lo,rr;
            cin>>lo>>rr;
            lo--;
            rr--;
            queries[i].l = lo; 
            queries[i].r = rr; 
            queries[i].idx = i;
        }
        sort(queries, queries+q, cmp);
        answeringQueries(a, n, queries, q);
    }
    return 0;  
}

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

int a, b, n;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		if (a % 100 == 0 && b % 30 == 0) {
			cout << (b / 30) * 5 + (a / 100) << endl;
		}
		else if (b % 30 == 0) {
			a -= a % 100;
			cout << (b / 30) * 5 + (a / 100) << ' ';
			cout << (b / 30) * 5 + (a / 100) + 1 << endl;
		}
		else if (a % 100 == 0) {
			b -= b % 30;
			cout << (b / 30) * 5 + (a / 100) << ' ';
			cout << (b / 30) * 5 + (a / 100) + 5 << endl;
		}
		else {
			a -= a % 100; b -= b % 30;
			cout << (b / 30) * 5 + (a / 100) << ' ';
			cout << (b / 30) * 5 + (a / 100) + 1 << ' ';
			cout << (b / 30) * 5 + (a / 100) + 5 << ' ';
			cout << (b / 30) * 5 + (a / 100) + 6 << endl;
		}
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
 
int main() {
  string s, t;
  
  cin >> s;
  cin >> t; 
  
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
    
  if(s < t)
    cout << "Yes" << endl;  
  else
    cout << "No" << endl;  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=200010, LOG=20;

int n, k, u, v, x, y, t, a, b, comp;
int A[MAXN], B[MAXN], C[MAXN], X[MAXN];
//int adj[MAXN*2], head[MAXN*2], prv[MAXN*2], m;
int par[MAXN], topol[MAXN], ts;
pll dp[MAXN][3];
bool good[MAXN];
ll h[MAXN], ans;
int dsu[MAXN];
pll opt[MAXN];
int Q[MAXN], ql, qr;
vector<pii> G[MAXN];

int getpar(int x){ return (dsu[x]==x?x:dsu[x]=getpar(dsu[x]));}
void join(int x, int y, ll w){
	x=getpar(x);
	y=getpar(y);
	if (x==y) return ;
	dsu[x]=y;
	comp--;
	ans+=w;
}

void dfs(int node){
	for (pii p:G[node]) if (p.first!=par[node]){
		par[p.first]=node;
		h[p.first]=h[node]+p.second;
		dfs(p.first);
	}
}
inline void add(pll *A, pll x){
	if (A[1].first<=x.first) return ;
	A[2]=x;
	if (A[2]<A[1]) swap(A[2], A[1]);
	if (A[1]<A[0]) swap(A[1], A[0]);
	if (A[0].second==A[1].second) swap(A[1], A[2]);
}
void dfs2(int node){
	if (node>1){
		int v=par[node], w=h[node]-h[par[node]];
		add(dp[node], pll(dp[v][0].first+w, dp[v][0].second));
		add(dp[node], pll(dp[v][1].first+w, dp[v][1].second));
	}
	for (pii p:G[node]) if (p.first!=par[node]){
		int v=p.first, w=p.second;
		dfs2(v);
		add(dp[node], pll(dp[v][0].first+w, dp[v][0].second));
		add(dp[node], pll(dp[v][1].first+w, dp[v][1].second));
	}
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	for (int i=1; i<=n; i++) cin>>X[i], dsu[i]=i;
	for (int i=1; i<n; i++){
		cin>>A[i]>>B[i]>>C[i];
		/*
		adj[m]=i, prv[m]=head[A[i]], head[A[i]]=m++;
		adj[m]=i, prv[m]=head[B[i]], head[B[i]]=m++;
		*/
		G[A[i]].pb({B[i], C[i]});
		G[B[i]].pb({A[i], C[i]});
	}
	dfs(1);
	comp=n;
	while (comp>1){
		memset(opt, 63, sizeof(opt));
		for (int i=1; i<=n; i++) dp[i][0]={X[i], getpar(i)}, dp[i][1]={INF, -1};
		dfs2(1);
		dfs2(1);
		for (int i=1; i<=n; i++){
			pll p=dp[i][0];
			if (p.second==getpar(i)) p=dp[i][1];
			p.first+=X[i];
			opt[getpar(i)]=min(opt[getpar(i)], p);
		}
		for (int i=1; i<=n; i++) if (dsu[i]==i)
			join(opt[i].second, i, opt[i].first);
		
	}
	cout<<ans<<"\n";
	
	return 0;
}


Measured memory_bytes: 48960
#Trained?
import numpy as np
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
    
p=1
cnt=0
while 1:
    cnt+=1
    p = a[p-1]
    if(p==2):
        print(cnt)
        break
    if(cnt>N):
        print(-1)
        break

Measured memory_bytes: 18268