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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n, m;
  cin >> n >> m;
  if (n == m) yes(); no();
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,p[1000][3],flg[1000];
	int i,j,cnt;
	scanf("%d",&n);
	for(i=0;i<n;i++)	{
		scanf("%d %d %d",&p[i][0],&p[i][1],&p[i][2]);
		sort(p[i],p[i]+3);
	}
//	for(i=0;i<n;i++)	{
//		for(j=0;j<3;j++)	printf("%d ",p[i][j]);
//		printf("\n");
//	}
	for(i=0;i<n;i++)	flg[i]=0;
	cnt=0;
	for(i=0;i<n-1;i++)	{
		for(j=i+1;j<n;j++)	{
			if(flg[i]==0 && p[i][0]==p[j][0] && p[i][1]==p[j][1] && p[i][2]==p[j][2])	{
				cnt++;
				flg[j]=1;
			}
		}
	}
	printf("%d\n",cnt);
	return 0;
}


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

int main() {
    char C;
    cin >> C;
    string str = "abcdefghijklmnopqrstuvwxyz";

    rep(i,27){
      if(C == str.at(i)){
        C = str.at(i+1);
        break;
      }
    }

    cout << C << endl; 

}


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

template <typename T>
T pow_mod(T a, T n, T mod)
{
	T r = 1;
	for (; n; n >>= 1)
	{
		if (n & 1)
		{
			(r *= a) %= mod;
		}
		(a *= a) %= mod;
	}
	return r;
}

int main()
{
	int64_t n, m, mod = 1000000007;
	cin >> n >> m;
	map<int64_t, int64_t> mp;
	for (int64_t i = 2; m != 1; i++)
	{
		while (m % i == 0)
		{
			mp[i]++;
			m /= i;
		}
	}
	vector<int64_t> fact(200001), fact_rev(200001);
	fact[0] = 1;
	for (int i = 0; i < 200000; i++)
	{
		fact[i + 1] = fact[i] * (i + 1) % mod;
	}
	fact_rev[200000] = pow_mod(fact[200000], mod - 2, mod);
	for (int i = 200000; i; i--)
	{
		fact_rev[i - 1] = fact_rev[i] * i % mod;
	}
	int64_t ans = 1;
	for (auto p : mp)
	{
		(ans *= fact[p.second + n - 1] * fact_rev[p.second] % mod * fact_rev[n - 1] % mod) %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

vector<pint> A;

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int N;
	cin >> N;
	A.resize(N);

	for (size_t i = 0; i < N; i++) {
		cin >> A[i].first;
		A[i].second = i;
	}

	auto A_sorted = A;
	sort(A_sorted.begin(), A_sorted.end(), greater<pint>());

	int max_v = A_sorted[0].first;
	int max_i = A_sorted[0].second;
	int max_v2 = A_sorted[1].first;
	int max_i2 = A_sorted[1].second;

	for (int i = 0; i < N; i++) {
		if (i == max_i) {
			cout << max_v2 << endl;
		} else {
			cout << max_v << endl;
		}
	}

	return 0;
}


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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e - a <= k){
    cout << "Yay!" << endl;
  }
  else{
    cout << ":(" << endl;
  }
}


Measured memory_bytes: 256
io = STDIN
n,m=io.gets.split.map(&:to_i)
connected_sw=m.times.map do 
  ar=io.gets.split.map(&:to_i)
  ar[1..-1]
end
on_cond=io.gets.split.map(&:to_i)
cnt=(1<<n).times.map do |mask|  #on/off全組み合わせ
  ar=m.times.map do |light_no|
    sws=connected_sw[light_no].map do |sw_no|
      mask & 1<<(sw_no-1) > 0
    end
    sws.count(true)%2==on_cond[light_no]
  end
  ar.all?
end
p cnt.count(true)


Measured memory_bytes: 2172
N=int(input())
A=list(map(int,input().split()))
before=0
state='minus'
ans=0

for i in range(N):
  if A[i]==before:
    continue
  elif A[i]-before>0:
    if state=='minus':
      ans+=1
      state='None'
    elif state=='None':
      state='plus'
  else:
    if state=='plus':
      state='None'
      ans+=1
    elif state=='None':
      state='minus'
  before=A[i]
print(ans)

Measured memory_bytes: 14224
n = int(input())
a = list(map(int,input().split()))
ans = 1
mark = False
if 0 in a:
    print(0)
    mark = True
if mark==False:
    for i in range(n):
        ans *= a[i]
        if ans > 1000000000000000000:
            mark = True
            print(-1)
            break
if not mark: print(ans)


Measured memory_bytes: 21688
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

al = [0, 5] + [0] * 49
bl = [0, 3] + [0] * 49


def solve2(ans, x, idx, cnt):
    if idx == 1:
        if x >= 5:
            return ans + 3
        return ans + (0, 0, 1, 2, 3, 3)[x]
    if x >= al[idx - 1] + 1:
        ans += bl[idx - 1]
        x -= al[idx - 1] + 1
        if x >= 1:
            ans += 1
            x -= 1
    else:
        x -= 1
        if x <= 0:
            return ans
    return solve2(ans, x, idx - 1, cnt)


def solve(n, x):
    for i in range(2, n + 1):
        al[i] = al[i - 1] * 2 + 3
        bl[i] = bl[i - 1] * 2 + 1
    ans = solve2(0, x, n, 0)
    print(ans)


if __name__ == "__main__":
    n, x = map(int, input().split())
    solve(n, x)


Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <tuple>
#include <climits>

using namespace std;


int main() {
    int n;
    cin>>n;
    long long a0 = 2, a1 = 1, a2;
    if (n == 1) a2 = 1;
    else {
        for (int i=1; i<n; i++) {
            a2 = a1 + a0;
            a0 = a1, a1 = a2;
        }
    }
    cout<<a2<<endl;
}

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


void solve(long long x){
    cout << !x << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long x;
    scanf("%lld",&x);
    solve(x);
    return 0;
}


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

int dp[11][1010][2];

int main(){
	int D,G;
    cin >> D >> G;
    G = G/100;
    VI p(D+1), c(D+1);
    p[0] = 0; c[0] = 0;
    rep2(i,1,D+1){
        int _c;
        cin >> p[i] >> _c;
        c[i] = _c / 100;
    }

    // init
    rep(n,1010){
        dp[0][n][0] = 0;
    }
    rep(d,11){
        dp[d][0][0] = 0;
        dp[d][0][1] = 0;
    }

    rep2(d,1,D+1){
        rep2(n,1,1010){
            int A = dp[d-1][n][0];
            int B=0, C=0;
            if(dp[d][n-1][1] < p[d]){
                B = dp[d][n-1][0] + d;
            }
            if(n >= p[d]){
                C = d*p[d] + c[d] + dp[d-1][n-p[d]][0];
            }

            if(C >=A && C >= B){
                dp[d][n][0] = C;
                dp[d][n][1] = p[d];
            }else if(B >= A){
                dp[d][n][0] = B;
                dp[d][n][1] = dp[d][n-1][1] + 1;
            }else{
                dp[d][n][0] = A;
                dp[d][n][1] = 0;
            }
        }
    }

    // rep(i,11){
    //     rep(j,15){
    //         cout << dp[i][j][0] << " ";
    //     }
    //     cout << endl;
    // }

    // cout << " --- "<< endl;

    // rep(i,11){
    //     rep(j,15){
    //         cout << dp[i][j][1] << " ";
    //     }
    //     cout << endl;
    // }

    int ans;
    rep(n,1010){
        if(dp[D][n][0] >= G){
            ans = n;
            break;
        }
    }

    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
def main():
    A, B, C = map(int, input().split())
    K = int(input())

    for k in range(K):
        if B <= A:
            B *= 2
        elif C <= B:
            C *= 2
    
    if A < B and B < C:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 61904
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-03-29 14:12:17
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#include<vector>
//                    123456789
const int N=2010,inf=1000000000;
int n,w[N],Min[N],Max[N],ans;
std::vector<int> e[N];
char s[N];
void solve(int u,int f)
{
	w[u]=s[u]; Max[u]=0;
	for(auto v:e[u]) if(v!=f) solve(v,u);
	for(auto v:e[u]) if(v!=f){ w[u]+=w[v]; Max[u]+=Max[v]+w[v]; }
	Min[u]=Max[u]&1;
	for(auto v:e[u]) if(v!=f) Min[u]=std::max(Min[u],Min[v]+w[v]-(Max[u]-Max[v]-w[v]));
}
int main()
{
	n=read(); scanf("%s",s+1);
	fr(i,1,n) s[i]-=48;
	fr(i,1,n-1)
	{
		int u=read(),v=read();
		e[u].push_back(v); e[v].push_back(u);
	}
	ans=inf;
	fr(i,1,n)
	{
		solve(i,0);
		if(Min[i]==0) ans=std::min(ans,Max[i]/2);
	}
	printf("%d\n",ans==inf?-1:ans);
	return 0;
}

Measured memory_bytes: 512
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k;cin>>n>>k;
  int cnt=0;
  rep(i,n){
    int x;cin>>x;
    if(x>=k)cnt++;
  }
  cout <<cnt<<endl;
}



Measured memory_bytes: 256
#include  <iostream>
#include <cstring>
#include <cstdlib>

using namespace std;

int main(){
  int N;
  cin >> N;
  int H[N];
  int life = 1;
  for(int i=0;i<N;i++){
    cin >> H[i];
  }
  for(int i=1;i<N;i++){
    int dh = H[i] - H[i-1];
    if(dh > 0){
      life = 1;
      continue;
    }else if(dh == 0){
       continue;
    }else if( dh == -1 && life == 0){
      cout << "No" << endl;
      return 0;
    }else if(dh == -1){
      life = 0;
      H[i-1] -= 1;
    }else if(dh < -1){
      cout << "No" <<endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#define LL long long
#define N 200005
using namespace std;
LL L,n,ans,a[N],b[N],Sa[N],Sb[N];
inline void Max(LL& a,LL b){ if(a<b) a=b; }
inline LL Qa(int l,int r){ return Sa[r]-Sa[l-1]; }
inline LL Qb(int l,int r){ return Sb[r]-Sb[l-1]; }
inline void Solve(){
	for(int i=n;i;--i){
		int B_L=(n-i)/2,A_L=n-i-B_L;
		Max(ans,((n-i)&1?b[n-B_L]:a[n-A_L])+(Qb(n-B_L+1,n)+Qa(i,i+A_L-1))*2);
	}
}
int main(){
	scanf("%lld%lld",&L,&n);
	for(int i=1;i<=n;++i) scanf("%lld",&a[i]);
	for(int i=1;i<=n;++i) b[i]=L-a[i],Sa[i]=Sa[i-1]+a[i],Sb[i]=Sb[i-1]+b[i];
	Solve(); for(int i=1;i<=n;++i) a[i]=b[n-i+1];
	for(int i=1;i<=n;++i) b[i]=L-a[i],Sa[i]=Sa[i-1]+a[i],Sb[i]=Sb[i-1]+b[i];
	Solve(); printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6400
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    ll n=in();
    ll ans=inf;
    for(ll i=1;;++i){
        if(i>n/i)break;
        if(n%i==0){
            ll j=n/i;
            ans=min(ans,i-1+j-1);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
import math
a, b = map(int, input().split())

p = math.ceil(a/0.08)

if math.floor(p/10) == b:
    print(p)
else:
    while 1:
        p += 1
        if math.floor(p*0.08) == a:
            if math.floor(p*0.1) == b:
                print(p)
                break
        else:
            print("-1")
            break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int lo;
lo w,h;

int main(){
    cin >> w >> h;
    if(w == 1 or h == 1) cout << 1;
    else cout << (lo)ceil(((long double)(w*h))/2);
}   


//g++ code.cpp -o code.exe
// code.exe

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int H = 1, W = 1, i, j;

	while(1)
	{
		scanf("%d %d", &H, &W);
		if(H == 0 && W == 0)break;
	
		for(i=0; i<H; i++)
		{
			for(j=0; j<W; j++)
			{
				printf("#");
			}
		
			printf("\n");
		}
		printf("\n");
		
	}

	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef vector <ll> vi;                 // Vector of long long
typedef vector <vi> vvi;                // Vector of vi
typedef vector <pair<ll,ll>> ii;        // Vector of pairs
#define ff first                        // For pairs
#define ss second                       // For pairs
#define sz(a) int((a).size())           // Function to determine size of any container
#define pb push_back                    // Pushback to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >

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

    ll n;
    cin >> n;
    ll arr[n][3];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < 3; j++)
            cin >> arr[i][j];

    ll dp[n][3];

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

    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
            dp[i][j] = max(dp[i - 1][(((j - 1) % 3) + 3) % 3], dp[i - 1][(j + 1) % 3]) + arr[i][j];
    }

    ll ans = 0;
    for (int i = 0; i < 3; i++)
        ans = max(ans, dp[n - 1][i]);
    
    cout << ans << "\n";
}


Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String input = br.readLine();
		String[] splitByApple = input.split("apple",-1);
		
		for(int i = 0; i < splitByApple.length ; i++){
			splitByApple[i] = splitByApple[i].replaceAll("peach", "apple");
		}
		
		for(int i = 0; i < splitByApple.length ; i++){
			if(i != 0){
				System.out.print("peach");
			}
			System.out.print(splitByApple[i]);
		}
		
		System.out.println();
	}

}

Measured memory_bytes: 24364
N = int(input())
M = {}
S = set()
for i in range(N):
	s, p = input().split()
	if s in M:
		t = M[s]
		t.append((int(p), i + 1))
	else:
		t = []
		t.append((int(p), i + 1))
		M[s] = t		
	S.add(s)

for s in sorted(S):
	for t2 in (sorted(M[s], reverse = True)):
		print(t2[1])
	


Measured memory_bytes: 9172
from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys
import random
import itertools
import math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt


def LI(): return list(map(int, input().split()))


def LF(): return list(map(float, input().split()))


def LI_(): return list(map(lambda x: int(x)-1, input().split()))


def II(): return int(input())


def IF(): return float(input())


def LS(): return list(map(list, input().split()))


def S(): return list(input().rstrip())


def IR(n): return [II() for _ in range(n)]


def LIR(n): return [LI() for _ in range(n)]


def FR(n): return [IF() for _ in range(n)]


def LFR(n): return [LI() for _ in range(n)]


def LIR_(n): return [LI_() for _ in range(n)]


def SR(n): return [S() for _ in range(n)]


def LSR(n): return [LS() for _ in range(n)]


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


def gcdx(x, y):
    g = 0
    if (x % y != 0):
        g = x % y
        gcdx(y, g)
    return g


mod = 1000000007
inf = float('INF')


def A():
    a = II()
    b = a//2
    p = b/a
    if a % 2:
        print(1-p)
    else:
        print(p)

    return

# B


def B():
    N, K = map(int, input().split())
    h = LI()
    count = 0

    for i in h:
        if i >= K:
            count += 1
        else:
            continue
    print(count)
    return

# C


def C():
    N = II()
    A = LI()
    J = [0] * N
    for i, n in enumerate(A):
        J[n-1] = i+1
    for s in J:
        print(s, end=" ")

    return

# D


def D():
    A, B = map(int, input().split())
    g = gcd(A, B)
    #go = g
    #myset = set([1])
    sq = int(sqrt(g)) + 2
    ans = 1

    for i in range(2, sq):
        if g % i == 0:
            ans += 1
        while g % i == 0:
            g /= i

            # myset.add(i)
        if g == 1:
            break
        if i == sq - 1:
            # myset.add(go)
            ans += 1

    print(ans)

    return

# E


def E():
    N, M = LI()

    price = [-1] * N
    ans = [0]*N

    for i in range(M):
        a, b = LI()
        c = LI()
        for k in c:
            if price[k-1] > a/b or price[k-1] == -1:
                price[k-1] = a/b
                ans[i] = a

    if -1 in price:
        print(-1)
    else:
        print(sum(price))

    return

# F


def F():
    return


# Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 40432
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Scanner;

public class Main{
	static Scanner sc;

	public static void main(String[] args) throws Exception {
		//InputStream in = new FileInputStream("src/input.txt");
		InputStream in = System.in;
		//PrintStream out = new PrintStream("src/output.txt");

		//System.setOut(out);

		sc = new Scanner(in);

		String answer = "YES";

		int N = sc.nextInt();
		//long[] D = new long[N];
		HashMap<Long, Integer> D = new HashMap<>();
		for(int i = 0; i < N; i++){
			long d = sc.nextLong();
			if(D.get(d) == null){
				D.put(d, 1);
			}else{
				D.put(d, D.get(d) + 1);
			}
		}

		int M = sc.nextInt();
		//long[] T = new long[N];

		//ArrayList<Long> T = new ArrayList<Long>();
		for(int i = 0; i < M; i++){
			//T.add(sc.nextLong());
			long t = sc.nextLong();
			if(D.get(t) == null || D.get(t) == 0){
				answer = "NO";
				break;
			}else{
				D.put(t, D.get(t) - 1);
			}
		}

		System.out.println(answer);

		//out.close();
	}
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  int count = 0;
  for (int i = A; i <= B; i++) {
    if (i / 10000 == i % 10 && (i / 10) % 10 == (i / 1000) % 10) {
      count ++;
    }
  }
  
  cout << count << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long int

int main()
{
	int n, ans = 0;
	ll x, y, d;
	ll tmp;
	cin >> n >> d;
	tmp = (ll)d*d;
	rep(i, n) {
		//cin >> x[i] >> y[i];
		cin >> x >> y;
		if ((x*x + y*y) <= (d*d)) ans++;
	}

	//auto sqroot = [](int x, int y) {return x*x + y*y;};
	//rep(i, n) {
	//	ans_value = sqroot(x[i], y[i]);
	//	if (sqroot(x[i], y[i]) <= d*d) ans++;
	//}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#define ll long long
using namespace std;

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


}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x, a, b;
    cin >> x >> a >> b;
    int aa = abs(x - a);
    int bb = abs(x - b);
    //cout << aa << endl;
   // cout << bb << endl;
    if(aa < bb){
        cout << 'A' << endl;
    }
    else{
        cout << 'B' << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N, money = gets.chomp.split(' ').map(&:to_i)
money /= 1000

ans_x = -1; ans_y = -1; ans_z = -1
(0..N).each do |x|
  (0..N-x).each do |y|
    z = N - x - y
    sum = 10 * x + 5 * y + z
    if sum == money
      ans_x = x
      ans_y = y
      ans_z = z
    end
  end
end

puts "%d %d %d" % [ans_x, ans_y, ans_z]


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
const int Maxn=300005;
int a[Maxn],sum[Maxn][2];
int main(){
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        memcpy(sum[i],sum[i-1],sizeof(sum[i]));
        sum[i][i&1]+=a[i];
    }
    if(n%2==0){
        cout<<max(sum[n][0],sum[n][1])<<" "<<min(sum[n][0],sum[n][1])<<"\n";
        return 0;
    }
    int l=-3e8,r=3e8;
    while(l<=r){
        int mid=(l+r)/2,p=0;
        for(int i=2;i<=n;i+=2)
            if(mid+p<=sum[i-1][1]-sum[i-2][0])
                p=min(p,sum[i-1][1]-sum[i][0]);
        if(mid+p<=sum[n][1]-sum[n][0])l=mid+1;
        else r=mid-1;
    }
    cout<<r+sum[n][0]<<" "<<sum[n][1]-r<<"\n";
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0, left, right;
    vector<int> V(3);
    char tmp, tmp2;
    string S, S2;
    bool flag=true;
    
    cin >> A >> B >>C;
    // ans = 24 + (24-A);
    ans = (A-B)%C;
  
    cout << ans << endl;

    // if(left <right )
    // 	cout << "Right" <<endl;
    // else if(left > right)
    // 	cout << "Left" <<endl;
    // else
    // 	cout << "Balanced" <<endl;


    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(A+B==C || B+C==A || C+A==B)
    // 	puts("Yes");
    // else
    // 	puts("No");
}


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

using namespace std;

typedef long long LL;
int n;
int a[110000],b[110000],c[110000];
LL f[110000];
LL ans;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	for (int i=1;i<=n;i++)
		scanf("%d",&c[i]);
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	sort(c+1,c+1+n);
	int head=1;
	for (int i=1;i<=n;i++)
	{
		while (head<=n&&c[head]<=b[i]) head++;
		f[i]=(LL)(n-head+1)+f[i-1];
	}
	//cout<<f[1]<<" "<<f[2]<<endl;
	head=1;
	for (int i=1;i<=n;i++)
	{
		while (head<=n&&b[head]<=a[i]) head++;
		ans+=f[n]-f[head-1];
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll H, W;
  cin >> H >> W;
  ll N;
  cin >> N;
  vll a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  ll color = 0;
  ll counter = a.at(color);
  vvll ans(H, vll(W, -1));
  for(int i = 0; i < H; i++){
    if(i%2==0){
      for(int j = 0; j < W; j++){
        ans.at(i).at(j) = color + 1;
        counter--;
        if(counter == 0){
          color++;
          counter = a[color];
        }
      }
    }
    else{
      for(int j = W-1; j >= 0; j--){
        ans.at(i).at(j) = color + 1;
        counter--;
        if(counter == 0){
          color++;
          counter = a[color];
        }
      }
    }
  }
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cout << ans.at(i).at(j);
      if(j != W-1) cout << ' ';
      else cout << endl;
    }
  }
}

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

int main() {
	string s;
	cin>>s;
	string ans="";
	rep(i,s.size()){
		if(s[i]=='B'){
			if(ans.size())
			ans=ans.substr(0,ans.size()-1);
		}
		else ans+=s[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
S = input()

if len(S)==2 and S[0]==S[1]:
    print(1,2)
    exit()
for i in range(2,len(S)):
    if S[i] == S[i-2]:
        print(i-1,i+1)
        exit()
    elif S[i] == S[i-1]:
        print(i,i+1)
        exit()
print(-1,-1)



Measured memory_bytes: 3188
#include<cstdio>

int main(void){
    int n;
    int l[101];
    int x;

    scanf("%d %d\n", &n, &x);
    for(int i = 1; i <= n; i++){
        scanf("%d", &l[i]);
    }

    int count;
    int d = 0;
    for(count = 1; d <= x && count <= n + 1; count++){
        d = d + l[count];
    }

    printf("%d\n", count - 1);

    return 0;
}

Measured memory_bytes: 128
n=int(input())
p=input().split()
k=[]
for i in p:k.append(int(i))
c=1
for i in range(1,n):
    if i == 1:
        if k[1] >= k[0]:
            c+=1
        continue
    m=max(k[0:i])
    w=k[i]
    if m <= w:c+=1
print(c)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using LL=int64_t;
const int INF=0x3f3f3f3f;
const int maxn=1e6+5;
struct Node {
    int t,x,y;
};
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,flag=0;
    cin>>n;
    Node now,next;
    now.x=now.y=now.t=0;
    for(int i=0;i<n;i++) {
        cin>>next.t>>next.x>>next.y;
        int temp=abs(now.x-next.x)+abs(now.y-next.y);
        if(temp>next.t-now.t) flag=1;
        else if((abs(temp+now.t-next.t))%2) flag=1;
        now=next;
    }
    if(flag) cout<<"No\n";
    else cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int main(void) {
    int i, n;
    cin >> n;
    set<int> st;
    REP (i,n) {
        int d;
        cin >> d;
        st.insert(d);
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  ll n, m;
  cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  int arr[n], pos[n];
  fi(0, n) {
    arr[i] = 1;
    pos[i] = 0;
  }
  pos[0] = 1;
  int a, b;
  fi(0, m) {
    cin >> a >> b;
    a--, b--;
    arr[a]--;
    arr[b]++;
    if(pos[a])
      pos[b] = 1;
    if(arr[a] == 0)
      pos[a] = 0;
  }
  fi(0, n)
    if(arr[i] && pos[i])
      ans++;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    ll a, b;
    cin >> n >> a >> b;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    int l = -1;
    int r = 1e9;
    int m;
    while(r - l > 1) {
        m = (l + r) / 2;
        ll cnt = 0;
        rep(i, n) {
            if (h[i] > b * m) {
                cnt += (h[i] - b * m - 1) / (a - b) + 1;
            }
        }
        if (cnt > m) {
            l = m;
        }
        else {
            r = m;
        }
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 4052
def f h,n
h[n]=0
q=[n]
yield n
(a=q.shift
[a.index(0),a.rindex(0)].map{|j|[6,-6,1,-1].map{|i|a[k=i+j]>0&&(b=a.dup
b[j],b[k]=b[k],b[j]
h[b]||=(q<<b;h[a]+1)
yield b)}})while q[0]&&h[q[0]]<10
end
o=[-1]
d=o*2
f(g={},d+[0]+o*4+[*1..3]+d+[*4..8]+d+[*9..11]+o*4+[0]+o*6){}
puts f(h={},d+[$_.to_i]+o*3+[1,0,1,2].flat_map{|i|o*i+gets.split.map(&:to_i)+o*i+o}+o*3){|a|g[a]&&(break h[a]+g[a])}||:NA while gets>?0

Measured memory_bytes: 25176
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<unordered_set>
#include<map>
#include<cstring>
#include<utility>
#include<string>
#include<iomanip>
#include<unordered_map>
using namespace std;
#define int long long
#define pb push_back
#define ppb pop_back
#define fr(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define LM LONG_MAX
#define LS LONG_MIN
#define cfM 998244353
#define ccM 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define inf 10000000000000000
#define sp setprecision(9)
float pi=3.14159265;
int max(int b,int a)
{if(b>a)return b;else return a;}
int min(int b,int a)
{if(b<a)return b;else return a;}
int ab(int b)
{if(b<0) return (-1*b);else return(b);}
void print(vector<int>&v)
{
	fr(i,v.size())
	cout<<v[i]<<" ";
	cout<<endl;
}
void print(int arr[],int n)
{
	for(int i=0;i<n;i++)
		cout<<arr[i]<<" ";}
int32_t main()
{
	string arr[3]={"Sunny","Cloudy","Rainy"};
	string s;
	cin>>s;
	int fl=0;
	for(int i=0;s[i];i++)
	{
		if((i+1)&1)
		{
			if(s[i]=='R' || s[i]=='U' || s[i]=='D')
				continue;
			else
				fl=1;
		}
		else
		{
			if(s[i]=='L' || s[i]=='U' || s[i]=='D')
				continue;
			else
				fl=1;
		}
	}
	if(fl)
		cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define has_str(s, c)	((s).find(c) != string::npos)
typedef long long ll;

int main() {
#ifdef LOCAL
    //freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n, w;
    cin >> n >> w;
    ll ans = 0, vt = 0;
    vector<pair<ll,ll>> val;
    for(int i = 0; i < n; ++i) {
        ll weight, value;
        cin >> weight >> value;
        vt += value;
        val.push_back({weight, value});
    }
    vector<ll> dp(vt+1, 1e9+9);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = vt - val[i].second; j >= 0; --j) {
            dp[j + val[i].second] = min(dp[j + val[i].second], dp[j] + val[i].first);
        }
    }
    for(int i = 1; i <= vt; ++i) {
        if(dp[i] <= w)
            ans = max(ans, 1ll*i);
    }
    cout << ans << endl;
    return 0;
}

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

int gcd(int a, int b){return b?gcd(b, a%b):a;}

int main(){
  int K;
  int sum=0;
  cin >> K;
  
  for(int i=1;i<=K;i++){
    for(int j=1; j<=K; j++){
      for(int k=1; k<=K; k++){
        sum += gcd(i,gcd(j,k));
      }
    }
  }
  
  cout << sum << endl;
  return 0;
}

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

int n, m, q;
vector<int> a, b, c, d;
int ans;
vector<vector<int>> V;

void dfs(vector<int> A) {
  if (A.size() == n) {
    V.push_back(A);
    return;
  }
  int last = A.back();
  for(int i = last;i<=m;i++){
      A.push_back(i);
      dfs(A);
      A.pop_back();
  }
}

int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i,q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;b[i]--;
  }
  dfs(vector<int>(1,1));
  for(auto v:V){
    int now = 0;
    rep(i,q) {
      if (v[b[i]] - v[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans, now);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

const ll L = 1e2+5;

vector <ll> s(L);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll N;
    cin >> N;

    ll sum = 0;
    ll flag = 0;

    for(ll i=0; i<N; i++)
    {
        cin >> s[i];
        sum+=s[i];
        
        if(s[i]%10!=0)
        {
            flag=1;
        }
    }

    if(flag)
    {
        if(sum%10!=0)
        {
            cout << sum << endl;
        }       

        else
        {
            ll ans = 0;
            for(ll i=0; i<N; i++)
            {
                if(s[i]%10!=0)
                {
                    ans = max(ans, sum-s[i]);
                }
            }

            cout << ans << endl;
        }
    }

    else
    {
        cout << 0 << 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;
using ll = long long;
int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int tmp = i+1;
        if(tmp%2==1&&a[i]%2==1) ans++;

    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3624
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int N = (int)1e5 + 228;

using namespace std;

int n, m, a[N], b[N];
bool used[N], was[N];
vector < pair < int, int > > g[N];

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	
	scanf("%d%d", &n, &m);
	forn(i, m)
	{
		scanf("%d%d", &a[i], &b[i]);
		g[a[i]].pb({b[i], i});
		g[b[i]].pb({a[i], i});
	}
	used[1] = true;
	int v = a[1], u = b[1];
	was[v] = was[u] = true;
	deque < int > dq;
	dq.pb(v);
	dq.pb(u);
	while(true)
	{
		int vv = v, uu = u;
		for (auto e : g[v])
		{
			int to = e.first, id = e.second;
			if (!used[id])
			{	
				if (!was[to])
				{
					was[to] = true;
					v = to;
					used[id] = true;
				    dq.push_front(to);
					break;	
				}					
			}
		}
		for (auto e : g[u])
		{	
			int to = e.first, id = e.second;
			if (!used[id])
			{
				if (!was[to])
				{
					was[to] = true;
					u = to;
					used[id] = true;
					dq.pb(to);
					break;
				}
			}
		}
		if (vv == v && uu == u)
			break;
	}
	printf("%d\n", (int)dq.size());
	for (auto it : dq)
		printf("%d ", it);

	return 0;
}



Measured memory_bytes: 7680
#include <stdio.h>
int main (void)
{
	int kansya[4][3][10];
	int kazu,tou,kai,ban,hito;
	int a,b,c,d;

	for(a=0;a<4;a++)//?????????
	{
		for(b=0;b<3;b++)
		{
			for(c=0;c<10;c++)
			{
				kansya[a][b][c]=0;
			}
		}
	}


	scanf("%d",&kazu);

	for(a=0;a<kazu;a++)//??\???
	{
		scanf("%d %d %d %d",&tou,&kai,&ban,&hito);
		kansya[tou-1][kai-1][ban-1]=hito + kansya[tou-1][kai-1][ban-1];
		
	}

	
	for(a=0;a<4;a++)//??????
	{
		for(b=0;b<3;b++)
		{
	
			for(c=0;c<10;c++)
			{
				printf(" %d",kansya[a][b][c]);
			}
	
			
			printf("\n");

		}
		if(a<3)
		{
			
			printf("####################\n");
			
		}
	}
	


	return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

bool isCuboid(vector<pair<int, int> > &d)
{
  for (int i = 0; i < 6; i++) {
    if (d[i].first > d[i].second) {
      swap(d[i].first, d[i].second);
    }
  }
  sort(d.begin(), d.end());
  for (int i = 0; i < 6; i += 2) {
    if (d[i] != d[i + 1]) return false;
  }
  if (d[0].first == d[2].first && d[2].second == d[4].second
      && d[4].first == d[0].second) {
    return true;
  } else {
    return false;
  }
}

int main()
{
  vector<pair<int, int> > hw(6);
  for (int i = 0; i < 6; i++) {
    cin >> hw[i].first >> hw[i].second;
  }

  if (isCuboid(hw)) {
    cout << "yes" << endl;
  } else {
    cout << "no" << endl;
  }
}
    
  




Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,i,k;
    cin>>n>>k;
    ll arr[n+1]={0};
    for(i=1;i<=n;i++)
        cin>>arr[i];
    ll dp[n+1];
    fill(dp,dp+n+1,1000000000000000000);
    dp[1]=0;
    if(n>1)
        dp[2]=abs(arr[2]-arr[1]);
    for(i=3;i<=n;i++)
    {
        for(ll j=max(i-k,(ll)1);j<i;j++)
            dp[i]=min(dp[i],dp[j]+abs(arr[i]-arr[j]));

    }
  cout<<dp[n]<<endl;
}


Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		int id[]=new int[10000];
		int sc[]=new int[10000];
		int i=0;
		int j=0;
		
		while(true)
		{
			String str[]=in.next().split(",");
			if(str[0].equals("0")&&str[1].equals("0"))
				break;
			id[i++]=Integer.valueOf(str[0]);
			sc[j++]=Integer.valueOf(str[1]);
		}
		while(in.hasNext())
		{
			int n=in.nextInt();
			int se=0;
			for(int m=0;m<i;m++)
			{
				if(n==id[m])
				{
					se=m;
					break;
				}
			}
			boolean b[] =new boolean[31];
			Arrays.fill(b, true);
			int ans=1;
			for(int l=0;l<i;l++)
			{
				if(sc[se]<sc[l]&&b[sc[l]])
				{
					ans++;
					b[sc[l]]=false;
				}
			}
			System.out.println(ans);
		}
	}
}

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

int N,H,W;
int A[1010];
int B[1010];


int main(){
    cin >> N >> H >> W;
    for (int i=0;i<N;i++) cin >> A[i] >> B[i];
    int count = 0;
    for (int i=0;i<N;i++){
        if ((A[i] >= H) && (B[i] >= W)){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main (){
int a,b,c,d,e,k;
scanf ("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);
  k=k+1;
if (abs(a-b) < k && abs(a-c) < k && abs(a-d) < k  && abs(a-e) < k && abs(b-c) < k && abs(b-d) < k && abs(b-e) < k && abs(c-d) < k && abs(c-e) < k && abs(d-e) < k){
printf ("Yay!");
}
else{
printf (":(");
}
return 0;
}

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

int main()
{
	long long N, A, B;
	cin >> N >> A >> B;

	N -= 2;
	long long Max, Min;
	Max = A + B + N*B;
	Min = A + B + N*A;

	cout << max((long long)0,Max - Min + 1) << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long int mod = (1e9 + 7);
int main(){
    int n,m;
    cin>>n>>m;
    vector<int>S(n+1,0);
    while(m--){
	int x;
	cin>>x;
	S[x]=1;
    }

    vector<long long int>d(n+1,0);
    d[0]=1;
    if(S[1]==0)
	d[1]=1;
    for(int i=2;i<=n;i++){
	if(S[i]==0){
	    d[i]=(d[i-1]+d[i-2])%mod;
	}
    }
  // for(int x:d)
  //      cout<<x<<" ";
  //  cout<<endl;
    cout<<d[n]<<endl;
}


Measured memory_bytes: 1408
#include <stdio.h>

long long  a[2000000], b[2000000], c[10001];

void csort(long long *a, long long *b, long long k, long long n){
  long long i, j;
  for(j = 0; j < n; ++j) c[a[j]]++;
  for(i = 1; i <= k; ++i) c[i] += c[i - 1];
  for(j = n - 1; j >= 0; --j){
    b[c[a[j]] - 1] = a[j];
    c[a[j]]--;
  }
}

int main(){
  long long n, i, max  = 0;

  scanf("%lld", &n);
  for(i = 0; i < n; ++i){
    scanf("%lld", a + i);
    if(max < a[i]) max = a[i];
  }
  csort(a, b, max, n);

  for(i = 0; i < n; ++i) printf(i != 0 ? " %lld" : "%lld" , b[i]);
  puts("");
  return 0;
}


Measured memory_bytes: 33064
#      
import collections, atexit, math, sys, bisect 

sys.setrecursionlimit(1000000)
def getIntList():
    return list(map(int, input().split()))    

try :
    #raise ModuleNotFoundError
    import numpy
    def dprint(*args, **kwargs):
        #print(*args, **kwargs, file=sys.stderr)
        # in python 3.4 **kwargs is invalid???
        print(*args,  file=sys.stderr)
    dprint('debug mode')
except Exception:
    def dprint(*args, **kwargs):
        pass



inId = 0
outId = 0
if inId>0:
    dprint('use input', inId)
    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #标准输出重定向至文件
if outId>0:
    dprint('use output', outId)
    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #标准输出重定向至文件
    atexit.register(lambda :sys.stdout.close())     #idle 中不会执行 atexit


if True:
    N, = getIntList()
    #print(N)
    za = getIntList()
else:
    N = 100
    import random
    za = [random.randint(1, 1000000000) for i in range(N) ]

dprint('begin')

zleft = [0 for i in range(N+1)]
zright = [0 for i in range(N+1)]


def getwork(zr, za):
    zr[0] = 0
    st = []
    for i in range(N):
        if i%10000  ==0:
            dprint('---', i)
        nt = [[za[i],0], [za[i],0], 1]
        st.append(nt)
        nr = zr[i]
        #dprint(st)
        while len(st)>1:
            b_2 = st[-2][1][1]
            b_1 = st[-1][0][1]
            bb = min(b_1,b_2)
            b_1 -=bb
            b_2 -=bb
            b_1p = 4 ** b_1
            b_2p = 4 ** b_2
            t2 = st[-2][1][0] * b_2p
            t1 = st[-1][0][0] * b_1p
            if  t2 < t1:
                nr+= 2* st[-2][2]
                st[-2][0][1] +=1
                st[-2][1][1] +=1
            elif t2 < t1 * 4:
                ttt = [ st[-2][0], st[-1][1], st[-2][2] + st[-1][2] ]  
                st[-2] = ttt
                st.pop()
            else:
                break
        #dprint(st)
        zr[i+1] = nr
        #dprint(nr)
        #dprint(st)
        assert nr < 1000000000000000
    dprint(st)
getwork(zleft, za)
dprint('!!!!')
getwork(zright, za[::-1])
 
#dprint(zleft)
#dprint(zright)

r =  zright[N]
for i in range(N+1):
    tr =  i + zleft[i] + zright[N-i]
    r = min(r,tr)

print(r)

dprint('end')




Measured memory_bytes: 101532
#include <iostream>
using namespace std;
long long z[100];
long long  digui(int a) {
	z[0] = 2, z[1] = 1;
	if (a == 1 || a == 0)  return  z[a];
	else {
		for (int i = 2; i <= a; i++) {
			z[i] = z[i - 1] + z[i - 2];
		}
	}
	return 	 z[a];
}
int main()
{
	int n;
	while (cin >> n) {
		cout << digui(n) << endl;
	}
}

Measured memory_bytes: 256