akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){

  int t,n,h[100],s,ue=0,sita=0,uemax,sitamax,i,j,k=0;
  scanf("%d",&t);
  while(1){
    if(k==t)break;
    k += 1;
    for(i=0;i<100;i++)h[i]=0;
    uemax=-1000;
    sitamax=-1000;
    j=1;
    scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%d",&s);
      h[i]=s;
    }
    for(i=0;i<n-1;i++){
	ue=h[j]-h[i];
	sita=h[i]-h[j];
	if(ue>uemax)uemax=ue;
	if(sita>sitamax)sitamax=sita;
	if(uemax<0)uemax=0;
	if(sitamax<0)sitamax=0;
	ue=0;
	sita=0;
	j += 1;
      }
    printf("%d %d\n",uemax,sitamax);
  }
  return 0;
}

Measured memory_bytes: 596
n = int(input())
days = []
for _ in range(n):
    day = list(map(int,input().split()))
    days.append(day)

dp = [[0 for i in range(0,3)] for j in range(n)]
dp[0][0] = days[0][0]
dp[0][1] = days[0][1]
dp[0][2] = days[0][2]

for i in range(1,n):
    dp[i][0] = days[i][0] + max(dp[i-1][1],dp[i-1][2])
    dp[i][1] = days[i][1] + max(dp[i-1][0],dp[i-1][2])
    dp[i][2] = days[i][2] + max(dp[i-1][1],dp[i-1][0])

print(max(dp[-1][0],dp[-1][1],dp[-1][2]))


Measured memory_bytes: 47368
#include<bits/stdc++.h>
#define PB push_back
#define MP make pair
#define FI first
#define SE second
using namespace std;
static const int INF = 1ll<<60;
typedef pair<int,int> pii;
 
int W,H,N;
int X1[1001],Y1[1001],X2[1001],Y2[1001];
bool fld[6005][6005];
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
int ans;
vector<int> xs;
 
int compress(int* x1,int* x2,int w){
    xs.clear();
    for(int i=0;i<N;++i){
        for(int d=-1;d<=1;++d){
            int tx1=x1[i]+d;
            int tx2=x2[i]+d;
            if(0<=tx1&&tx1<w)xs.PB(tx1);
            if(0<=tx2&&tx2<w)xs.PB(tx2);
        }
    }
    sort(xs.begin(),xs.end());
    xs.erase(unique(xs.begin(),xs.end()),xs.end());
    for(int i=0;i<N;++i){
        x1[i]=find(xs.begin(),xs.end(),x1[i])-xs.begin();
        x2[i]=find(xs.begin(),xs.end(),x2[i])-xs.begin();
    }
    return xs.size();
}
 
signed main(){
    while(1){
        cin>>W>>H;
        if(W==0&&H==0)break;
        cin>>N;
        for(int i=0;i<N;++i){
            cin>>X1[i]>>Y1[i]>>X2[i]>>Y2[i];
        }
        W=compress(X1,X2,W);
        H=compress(Y1,Y2,H);
        for(int i=0;i<N;++i){
            for(int y=Y1[i];y<Y2[i];++y){
                for(int x=X1[i];x<X2[i];++x){
                    fld[y][x]=1;
                }
            }
        }
        for(int y=0;y<H;++y){
            for(int x=0;x<W;++x){
                if(fld[y][x]==1)continue;
                queue<pii> que;
                que.push(pii(x,y));
                fld[y][x]=1;
                while(!que.empty()){
                    pii p=que.front();
                    que.pop();
                    int x=p.FI;
                    int y=p.SE;
                    for(int i=0;i<4;++i){
                        int nx = x+dx[i];
                        int ny = y+dy[i];
                        if(nx<0||nx>=W||ny<0||ny>=H)continue;
                        if(fld[ny][nx]==1)continue;
                        fld[ny][nx]=1;
                        que.push(pii(nx,ny));
                    }
                }
                ans++;
            }
        }
        cout<<ans<<endl;
        memset(fld,0,sizeof(fld));
        ans=0;
    }
}

Measured memory_bytes: 38348
//前置き
#pragma region

#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

typedef  long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

#define FOR(i, a, n) for(ll i = (ll)(a); i < (ll)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

#pragma endregion

//関数定義
#pragma region 
//偶数 ->　true :: 奇数　-> false
bool EVEN(ll a){
    return a%2-1;
}

//最大公約数
ll gcd(ll a, ll b) {  
    if (!b)  
        return a;  
    return gcd(b, a%b);  
}  

//最小公倍数
ll lcm(ll a, ll b) {  
    return a*b/gcd(a,b);  
} 

#pragma endregion

int main(){
    int a[4], b;
    cin >> b;
    REP(i , 4){
        a[3-i] = b % 10;
        b /= 10;
    }
    string op = "+-";

    int ans;
    REP(i, 8){
        ans = a[0];
        REP(j, 3){
            if(i & (1 << j)) ans -= a[j+1];
            else ans += a[j+1];
        }
        if(ans == 7){
            REP(j ,4){
                cout << a[j];
                if(j < 3){
                    if(i & (1 << j)) cout << "-";
                    else cout << "+";
                }
            }
            cout << "=7" << endl;
            return 0;
        }
    }
 }




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using ll =long long;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  int N;
  cin >>N;
  vector<int> h(N);
  vector<int> dp(N+10);
  for(int i =0; i<N ; i++){
    cin >> h[i];
  }
  dp.at(2) = ab(h[0],h[1]);
  for(int i=1; i<=N; i++){
    dp[i+2] =min(dp[i+1] + ab(h[i],h[i+1])   ,   dp[i]+ ab(h[i-1],h[i+1])   );
  }
  cout << dp[N]<<endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc;// = new Scanner(System.in);
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i=3; i<=n; i++){
            if(i%3==0 || i%10==3){
                System.out.print(" "+i);
                continue;
            }
            int x = i;
            while(x >= 10){
                x /= 10;
                if(x%10==3){
                    System.out.print(" "+i);
                    break;
                }
            }
        }
        System.out.println();

    }
}


Measured memory_bytes: 28800
s = list(input())
t = list(input())
s.sort()
t.sort()
t.reverse()
alphabet = list('@abcdefghijklmnopqrstuvwxyz')
#@ :空白を表す
judge = -1 #0:可,-1:不可

if(len(s)>len(t)):
 for i in range(len(s)-len(t)):
   t.append('@')
elif(len(s)<len(t)):
 for i in range(len(t)-len(s)):
   s.append('@')

len0 = len(s)
count = 0
while(len(s) > 0):
  a = alphabet.index(s[0])
  b = alphabet.index(t[0])
  if(a < b):
    judge = 0 #可:0
    break
  elif(a == b):
    count += 1
  else:
    judeg = -1
    break #不可:-1
  s.pop(0)
  t.pop(0)
  
if((judge == -1)or(count == len0)):
  print('No')
else:
  print('Yes')

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

class Program
{
    static void Main(string[] args)
    {
        int n = crI();
        if (n % 1000 == 0) Console.WriteLine(0);
        else
        {
            Console.WriteLine(1000 - n % 1000);
        }
    }

   
  



        //入力受け取り用
    static string crS() { return Console.ReadLine(); }
    static int crI() { return int.Parse(Console.ReadLine()); }
    static int[] arrInt(){return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();}
    static long[] arrLong(){ return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray(); }
    static string[] arrStr(){return Console.ReadLine().Split(' ').ToArray();}
    static List<int[]> mapInt(int h)
    {
        List<int[]> mapInt = new List<int[]>();
        for (int i = 0; i < h; i++)
        {
            mapInt.Add(arrInt());
        }
        return mapInt;
    }
}

Measured memory_bytes: 27512
#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 LOG=61;

ll A, B, u, v, x, y, t, a, b, ans, bit;

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>>A>>B;
	if (A==B) kill(1)
	for (int i=59; ~i; i--){
		bit=i;
		if ((A^B)&(1ll<<i)) break ;
		if (A&(1ll<<i)){
			A^=(1ll<<i);
			B^=(1ll<<i);
		}
	}
//	debug(bit)
	ans=(1ll<<bit)-A;
	ll tmp=(B^(1ll<<bit))+1;
	while (tmp&(tmp-1)) tmp+=(tmp&-tmp);
	if (tmp>=A) ans+=(1ll<<bit);
	else{
		ans+=tmp;
		ans+=(1ll<<bit)-A;
	}
	cout<<ans<<"\n";
	
	return 0;
}


Measured memory_bytes: 3628
def resolve():
    n=int(input())
    a=list(map(int,input().split()))
    a.sort()
    c=0
    for i in range(n-1):
        if a[i]==a[i+1]:
            c+=1
            break
    if c==0:
        print("YES")
    else:
        print("NO")
resolve()

Measured memory_bytes: 86868
def solve(string):
    n, k, *td = map(int, string.split())
    td = sorted([(t, d) for t, d in zip(td[::2], td[1::2])], key=lambda x: x[1], reverse=True)
    max_variety = len(set([c[0] for c in td]))
    choice = td[:k]
    r, v, b = [], set([]), 0
    for _c in choice:
        b += _c[1]
        if _c[0] in v:
            r.append(_c[1])
        else:
            v.add(_c[0])
    b += len(v)**2
    i = k
    ans = [b]
    while len(v) < min(max_variety, k):
        while td[i][0] in v:
            i += 1
        v.add(td[i][0])
        ans.append(ans[-1] - r.pop() + td[i][1] + 2 * len(v) - 1)
    return str(max(ans))


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 26876
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

template<class T> inline bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

int main(){

    int n;
    ll y;
    cin >> n >> y;

    for(int i = 0; i <= 2000; i++){
        for(int j = 0; j <= 2000; j++){
            ll tmp = y - i*10000 - j*5000;
            if(tmp < 0) continue;
            if(i + j + tmp/1000 == n){
                cout << i << " " << j << " " << tmp/1000 << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;

    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int main(){
	string a,b;
	cin>>a>>b;
	int la=a.size(),lb=b.size();
	if(la!=lb){
		puts(la>lb?"GREATER":"LESS");
	}
	else {
		for(int i=0;i<la;i++)
			if(a[i]!=b[i]){
				puts(a[i]>b[i]?"GREATER":"LESS");
				exit(0);
			}
		puts("EQUAL");
	}
	return 0;
}

Measured memory_bytes: 3616
import itertools

n, m = map(int, input().split())
lis = []
for i in range(m):
    a, b = map(int, input().split())
    lis.append((a, b))

LIS = [i for i in range(2, n + 1)]
big_lis = list(itertools.permutations(LIS))
L = len(big_lis)

ans2 = 0
for j in range(L):
    i = 1
    ans1 = 1
    for k in big_lis[j]:
        if((i, k) not in lis) & ((k, i) not in lis):
            ans1 = 0
        i = k
    ans2 += ans1
print(ans2)


Measured memory_bytes: 9236
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

int gcd(int a, int b) { return a ? gcd(b % a, a) : b; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
const int MOD = 1000000007;
int bin_pow_mod(int a, int b) {
  int ret = 1;
  while (b > 0) {
    if (b & 1) ret = (ret * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return ret;
}
signed main() {
  int N;
  cin >> N;
  vi A(N), B(N);
  rep(i, 0, N) cin >> A[i] >> B[i];
  map<pii, pii> cnt;
  int zero = 0;
  rep(i, 0, N) {
    int a = abs(A[i]), b = abs(B[i]);
    if (a == 0 && b == 0) {
      zero++;
    } else if (a == 0) {
      cnt[pii(0, INF)].first++;
    } else if (b == 0) {
      cnt[pii(0, INF)].second++;
    } else {
      int sign = (A[i] / abs(A[i])) * (B[i] / abs(B[i]));
      int g = gcd(a, b);
      a /= g;
      b /= g;
      (sign > 0 ? cnt[pii(a, b)].first : cnt[pii(b, a)].second)++;
    }
  }
  int ans = 0;
  ans += zero;
  int tmp = 1;
  for (auto &&p : cnt) {
    int x, y;
    tie(x, y) = p.second;
    tmp *= bin_pow_mod(2, x) + bin_pow_mod(2, y) + MOD - 1;
    tmp %= MOD;
  }
  tmp = tmp + MOD - 1;
  ans += tmp;
  ans %= MOD;
  cout << ans << endl;
  return (0 ^ _ ^ 0);
}



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

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

	int N;
	int i,j;
	int tmp;
	int answer;
	int counter=0;
	double ave;
	vector<int> given;
	string S;

	cin >> S;

	for(i=0;i<S.size();i++){
		cout << "x";
	}

	cout << endl;

	return 0;
}



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

LL const N=1009;
LL const MOD=1000000007;

int main(){
	LL n;
	LL fac[N]={0};
	cin>>n;
	for(LL i=2;i<=n;i++){
		LL k=i;
		for(LL j=2;j<=n;j++){
			if(k==1){
				break;
			}
			while(k%j==0){
				k/=j;
				fac[j]++;
				fac[j]%MOD;
			}
		}
	}
	LL sum=1;
	for(LL k=2;k<=n;k++){
		sum*=((fac[k])%MOD+1)%MOD;
		sum %= MOD;
	}
	cout<<sum%MOD<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#define N 100005
#define ll long long
using namespace std;
int n,x,y;ll ans=1e17,sum1,sum2,sum;
int fl[N],fil[N];
struct pl{int id,num;}s[2*N];
bool cmp(const pl &A,const pl &B){return A.num<B.num;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x,&y);
		sum1+=x;sum2+=y;s[2*i-1].num=x;s[2*i-1].id=i;
		s[2*i].num=y;s[2*i].id=i;
	}
	ans=min(sum1,sum2);
	sort(s+1,s+1+2*n,cmp);
	for(int i=1;i<=n;i++) fl[s[i].id]++,sum+=s[i].num;
	for(int i=n+1;i<=2*n;i++) fil[s[i].id]+=s[i].num;
	for(int i=1;i<=n;i++){
		if(fl[s[i].id]==2) ans=min(ans,sum);
		else{
			if(i!=n) ans=min(ans,sum+fil[s[i].id]-s[n].num);
			else ans=min(ans,sum+fil[s[i].id]-s[n-1].num);
		}
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 2560
S = input()
if S == "zyxwvutsrqponmlkjihgfedcba":
        print("-1")
        exit()
S = list(S)
S = [ord(e) for e in S]
ord_list = list(range(97,123))
# アルファベットが26個含まれているかチェック
for e in ord_list:
        if not e in S:
                S.append(e)
                S = [chr(e) for e in S]
                print("".join(S))
                exit()
#以下はアルファベット26個確定　後ろから最適になるように文字を置換していく
for i in range(len(S)-2,-1,-1):
        note = 123
        for j in range(i+1,len(S)):
                if S[i] < S[j] and S[j] < note:
                        note = S[j]
        if note < 123:
                S[i] = note
                del S[i+1:]
                S = [chr(e) for e in S]
                print("".join(S))
                break

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
const int INF = 1001001001;

int main() {
    int n;
    cin  >> n;
    vector<int> p(n+1);
    int temp;
    for(int i=0; i<n-1; i++) {
        cin >> p[i] >> temp;
    }
    cin >> p[n-1] >> p[n];
    
    vector<int> a(n);
    vector< vector<int> > A(n,a);
    for(int i=0; i<n; i++) A[i][i] = 0;

    for(int l=2; l<=n; l++) {
        for(int i=0; i<n-l+1; i++) {
            int j = i+l-1;
            A[i][j] = INF;
            for(int k=i; k<j; k++) {
                int q = A[i][k] + A[k+1][j] + p[i]*p[k+1]*p[j+1];
                if(q<A[i][j]) A[i][j] = q;
            }
        }
    }

    cout << A[0][n-1] << endl;
    return 0;
}


Measured memory_bytes: 3180
import sys
input = lambda: sys.stdin.readline().rstrip() 
import re

def resolve():
    S = input()
    acgt = ('A', 'C', 'G', 'T')
    ans = 0
    # l = 0
    # while (l < len(S)) and (len(S)-l > ans):
    #     r = l+1
    #     while (r < len(S)+1) and (S[r-1] in acgt):
    #         r += 1
    #     ans = max(r-1-l, ans)
    #     l += 1

    for l in range(len(S)):
        for r in range(l+1, len(S)+1):
            # print(l, r, S[l:r], re.fullmatch(r'[ACGT]*', S[l:r]))
            if re.fullmatch(r'[ACGT]*', S[l:r]):
                ans = max(r-l, ans)
            # if S[r-1] not in acgt:
            #     ans = max(r-1-l, ans)
            #     break
 
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
  int r,g;
  cin>>r>>g;
  cout << 2*g-r << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
  Scanner sc;

  class Rect {
    int w, d;

    Rect(int w, int d) {
      this.w = w;
      this.d = d;
    }

    ArrayList<Rect> cut(int s) {
      Rect[] res = new Rect[2];

      s %= w + d;
      if ( s < w ) {
        res[ 0 ] = new Rect( s, d );
        res[ 1 ] = new Rect( w - s, d );
      } else {
        s -= w;
        res[ 0 ] = new Rect( w, s );
        res[ 1 ] = new Rect( w, d - s );
      }

      if ( res[ 0 ].getV() > res[ 1 ].getV() ) {
        Rect tmp = res[ 0 ];
        res[ 0 ] = res[ 1 ];
        res[ 1 ] = tmp;
      }

      ArrayList<Rect> l = new ArrayList<Rect>( 2 );
      for ( Rect r : res ) {
        l.add( r );
      }
      return l;
    }

    int getV() {
      return w * d;
    }

    public String toString() {
      return "(" + w + ", " + d + ")";
    }
  }

  void run() {
    for ( ;; ) {
      int n, w, d;
      n = ni();
      w = ni();
      d = ni();
      if ( ( n | w | d ) == 0 ) {
        break;
      }

      Comparator<Rect> comp = new Comparator<Rect>() {
        public int compare(Rect o1, Rect o2) {
          return o1.getV() - o2.getV();
        }
      };

      ArrayList<Rect> list = new ArrayList<Rect>();
      list.add( new Rect( w, d ) );
      for ( int i = 0; i < n; ++i ) {
        int p = ni() - 1;
        int s = ni();

        list.addAll( list.get( p ).cut( s ) );
        list.remove( p );
      }
      Collections.sort( list, comp );

      for ( int i = 0; i < n + 1; ++i ) {
        if ( i > 0 ) {
          System.out.print( " " );
        }
        System.out.print( list.get( i ).getV() );
      }
      System.out.println();
    }
  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }

}

Measured memory_bytes: 53356
#include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>

using namespace std;

typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
void pkuassert(bool t){t=1/t;};

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

int n;

void solve(){
  set<int> app[n];
  rep(i,n){
    int t;
    cin >> t;
    rep(j,t){
      int m;
      cin >> m;
      app[i].insert(m);
    }
  }

  set<int> ro;
  int k;
  cin >> k;
  rep(i,k){
    int t;
    cin >> t;
    ro.insert(t);
  }
  
  int ans=-1;
  int cnt=0;
  rep(i,n){
    bool ok=true;
    FOR(it,ro)ok &= app[i].count(*it);
    if(ok){
      ++cnt;
      ans=i;
    }
  }
  if(cnt==1) cout << ans+1 << endl;
  else cout << -1 << endl;
}

int main(int argc, char *argv[])
{
  while(cin >>n && n) solve();
  return 0;
}

Measured memory_bytes: 1628
def wf(cost):
    l = 10
    for k in range(l):
        for i in range(l):
            for j in range(l):
                cost[i][j] =  min(cost[i][j],cost[i][k] + cost[k][j])

h,w = map(int,input().split())
c= []
for i in range(10):
    c.append(list(map(int,input().split())))
wf(c)
ans = 0
for i in range(h):
    for num in map(int,input().split()):
        if num==1 or num==-1:pass
        else:
            ans+=c[num][1]
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	ll N; cin >> N;
    ll ans = N*(N-1)/2;
    cout << ans << endl;
}
   


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

int a[20][7];
int d[11][5];

ll f(int m, int r=11) {
  int sum = 0;
  rep(i,r)rep(j,5) if (d[i][j] == m) sum++;
  return sum;
}

int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  rep(i,20)rep(j,7) a[i][j] = i*7+j+1;
  rep(i,11)rep(j,5) {
    rep(di,3)rep(dj,3) {
      d[i][j] += a[i+di][j+dj];
    }
    d[i][j] %= 11;
  }
  n -= 2;
  ll ans = f(m)*(n/11);
  ans += f(m,n%11);
  cout<<ans<<endl;
  return 0;
}































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

int main(){
  string S;
  cin >>S;
  
  int ans=0;
  repeat(i,4) S[i]=='+' ? ans++ : ans--;
 
  cout <<ans<< endl;
}

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s = input()
ans = 0
for i in range(1000):
    t1, t2, t3 = list("00" + str(i))[-3:]
    f1, f2, f3 = False, False, False
    for j in range(n):
        if not f1 and s[j] == t1:
            f1 = True
        elif f1 and not f2 and s[j] == t2:
            f2 = True
        elif f2 and not f3 and s[j] == t3:
            f3 = True

    if f3:
        ans += 1
print(ans)

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

int main(){
  int x,y,xx,yy;
  cin >> x >> y >> xx >> yy;
  int a=xx-x; int b=yy-y;
  cout << xx-b << " " << yy+a << " ";
  cout << x-b << " " << y+a << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		scanner.Scan()
		aa, _ := strconv.Atoi(scanner.Text())
		a[i] = aa
	}
	sort.Ints(a)

	var plus []int
	var minus []int
	for i := 0; i < n; i++ {
		if a[i] < 0 {
			minus = append(minus, a[i])
		} else {
			plus = append(plus, a[i])
		}
	}

	var ret int
	var ops [][]int
	if len(plus) == 0 {
		ret = minus[len(minus)-1]
		for i := len(minus) - 2; i >= 0; i-- {
			x := ret
			y := minus[i]
			ret = x - y
			ops = append(ops, []int{x, y})
		}
	} else {
		ret = plus[len(plus)-1]

		if len(plus) > 1 && len(minus) == 0 {
			z := plus[0]
			for i := 1; i < len(plus)-1; i++ {
				x := z
				y := plus[i]
				z = x - y
				ops = append(ops, []int{x, y})
			}
			x := ret
			y := z
			ret = x - y
			ops = append(ops, []int{x, y})
		} else if len(plus) > 1 {
			z := minus[0]
			for i := 0; i < len(plus)-1; i++ {
				x := z
				y := plus[i]
				z = x - y
				ops = append(ops, []int{x, y})
			}
			x := ret
			y := z
			ret = x - y
			ops = append(ops, []int{x, y})
			minus = minus[1:]
		}

		for i := 0; i < len(minus); i++ {
			x := ret
			y := minus[i]
			ret = x - y
			ops = append(ops, []int{x, y})
		}
	}

	fmt.Println(ret)
	for i := 0; i < n-1; i++ {
		fmt.Print(ops[i][0])
		fmt.Print(" ")
		fmt.Print(ops[i][1])
		fmt.Println("")
	}
}


Measured memory_bytes: 17280
from math import gcd
def prime_factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i,cnt])
    if temp != 1:
        arr.append([temp,1])
    if arr == []:
        arr.append([n,1])
    return arr
n,p = map(int,input().split())
l = prime_factorization(p)
ans = []
for i in l:
    if i[1] >= n:
        for j in range(i[1]//n):
            ans.append(i[0])
product = 1
for i in ans:
    product *= i
print(product) 

Measured memory_bytes: 63080
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    vector<ll>imos(100003, 0);
    REP(i, in()) {
        ll a = in(), b = in();
        ++imos[a];
        --imos[b + 1];
    }
    REP(i, imos.size() - 1)imos[i + 1] += imos[i];
    ll ans = 0;
    REP(i, 100002)if (imos[i] >= i - 1)ans = max(ans, i - 1);
    cout << ans << endl;
}


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

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

int main(){
  unsigned long long N, K;
  unsigned long long a = 0;
  cin >> N >> K;
  for(unsigned long long i=K; i<N+2;i++){
    unsigned long long A=i*(i+1)/2;
    unsigned long long B=(N+1)*(N+2)/2;
    unsigned long long C=(N+1-i)*(N+2-i)/2;
    unsigned long long D=B - A - C + 1;
    a = a+D;
  }
  cout << a%1000000007 << endl;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    int mmax = 0;
    int ans = 0;
    inc(i, 0, n){
        int h;cin >> h;
        if(h >= mmax){
            ans++;
        }
        mmax = max(mmax, h);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int a[1000050];
int main()
{
	int n,h;
	int ans=0;
	scanf("%d%d",&n,&h);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]>=h)
		ans++;
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        
        int h = scan.nextInt();
        int w = scan.nextInt();
        
        String[] pict = new String[h];
        for(int i=0;i<pict.length;i++)
        {
            pict[i] = scan.next();
        }
        
        for(int i=0;i<pict.length;i++)
        {
            System.out.println(pict[i]);
            System.out.println(pict[i]);
        }
    }
}


Measured memory_bytes: 24532
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
char s[100010];
int main() {
//    freopen("in.txt", "r", stdin);
    scanf("%s", s);
    int len = strlen(s);
    s[len-8] = '\0';
    printf("%s", s);
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    vector<int> num(101, 0);  //0から100の要素ででそれぞれ何個あるかを保持
    rep(i, n) {
        cin >> d.at(i);
        num.at(d.at(i))++;
    }

    int ans = 0;
    rep(i, 101){
        if(num.at(i) > 0) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys
INF = 11414191981036436433-4

n = int(input())
g = [[] for i in range(n)]
for v in range(n-1):
    a,b,c = map(int,input().split())
    g[a-1].append((b-1,c))
    g[b-1].append((a-1,c))
    
q,k = map(int,input().split())
k -= 1

r = [INF]*n
que = deque([k])
r[k] = 0
while que:
    v = que.popleft()
    rr = r[v]
    for w,x in g[v]:
        if r[w] == INF:
            r[w] = rr + x
            que.append(w)
            
for i in range(q):
    d,e = map(int,input().split())
    print(r[d-1] + r[e-1])

Measured memory_bytes: 83616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Linq;
using System.Collections.Generic;

namespace VirtualAtCorder
{
    class Program
    {

        static void Main(string[] args)
        {
            string[] inputs = Console.ReadLine().Split(' ');
            int a = int.Parse(inputs[0]);
            int b = int.Parse(inputs[1]);
            int c = int.Parse(inputs[2]);
            int x = int.Parse(inputs[3]);
            int y = int.Parse(inputs[4]);
            List<int> sum = new List<int>();
            int piza_AB_c = 0;

            while (x >= 0 || y >= 0)
            {
                sum.Add(Math.Max(0, a * x) + Math.Max(0, b * y) + c * piza_AB_c);
                x--;
                y--;
                piza_AB_c += 2;
            }

            Console.WriteLine(sum.Min());

            Console.ReadKey();
        }




    }
}


Measured memory_bytes: 13536
import sys
input = sys.stdin.readline
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
def print_ans(X):
    """Test Case
    >>> print_ans(20)
    23
    >>> print_ans(2)
    2
    >>> print_ans(99992)
    100003
    """
    ord = 10 ** 6
    prime_list = primes(ord)
    for i in prime_list:
        if i >= X:
            print(i)
            break
if __name__ == '__main__':
    # test
    X = int(input().rstrip())
    print_ans(X)

Measured memory_bytes: 14032
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int INF=1e9;
const int MOD=1e9+7;
const double pi=acos(-1);
 
int main(){
  int n;
  cin >>n;
  map<string,int>mp;
  string w;
  cin >> w;
  mp[w]++;
  
  bool ok=true;
  rep(i,n-1){
    string s;
    cin >> s;
    if(w[w.size()-1]!=s[0]){
      ok=false;
      break;
    }
    mp[s]++;
    w=s;
  }
  for(auto p:mp){
    if(p.second>=2)ok=false;
  }
  if(ok)cout<<"Yes"<<endl;
  else cout << "No"<<endl;
}

Measured memory_bytes: 256
from itertools import accumulate
n, m, *a = map(int, open(0).read().split())
a = [-x for x in a]
a.sort()
acc = list(accumulate(a))
l, r = 0, 2 * 10 ** 5 + 1
while r - l > 1:
	mid = (l + r) // 2
	border = n - 1
	cnt = 0
	for x in a:
		while x + a[border] > -mid:
			border -= 1
			if border < 0:
				break
		if border < 0:
			break
		cnt += border + 1
		if cnt >= m:
			break
	if cnt >= m:
		l = mid
	else:
		r = mid
ans = tot = 0
border = n - 1
for x in a:
	while x + a[border] > -l:
		border -= 1
		if border < 0:
			break
	if border < 0:
		break
	ans += acc[border] + x * (border + 1)
	tot += border + 1
ans += l * (tot - m)
print(-ans)

Measured memory_bytes: 14324
#include <bits/stdc++.h> // Integer Product, by Errichto
using namespace std;
int main() {
    int n;
    scanf("%d", &n);
    map<pair<int,int>, int> cnt;
    for(int rep = 0; rep < n; ++rep) {
        double x;
        scanf("%lf", &x);
        long long i = llround(x * 1e9);
        int two = 0, five = 0;
        while(i % 2 == 0) {
            two++;
            i /= 2;
        }
        while(i % 5 == 0) {
            five++;
            i /= 5;
        }
        ++cnt[{two,five}];
    }
    long long answer = 0;
    for(auto p1 : cnt) {
        for(auto p2 : cnt) {
            if(p1.first.first+p2.first.first >= 18 && p1.first.second+p2.first.second >= 18) {
                if(p1 < p2) {
                    answer += (long long) p1.second * p2.second;
                }
                else if(p1 == p2) {
                    answer += (long long) p1.second * (p1.second - 1) / 2;
                }
            }
        }
    }
    printf("%lld\n", answer);
}

Measured memory_bytes: 3828
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
using namespace std;
typedef long long ll;

int main(){
  string s;
  cin >> s;
  int zeroNum = 0;
  int oneNum = 0;

  for(int i=0;i<s.length();i++) {
    if(s.at(i) == '0') {
      zeroNum++;
    } else {
      oneNum++;
    }
  }

  cout << min(zeroNum, oneNum) * 2 << endl;
  return 0;
}


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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long ll;
typedef pair<int, int> pii;

bool good(int n){
    int ret = 0;
    while(n){
        n /= 10;
        ret++;
    }
    return (ret&1);
}

int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    cin >> n;
    int ans = 0;
    range(i,1,n)ans += good(i);
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

long long P = 1000000007;
long long n;
map<long long, long long> memo;

long long f(long long x) {
  if (memo.find(x) != memo.end())
    return memo[x];
  long long ret = 0;
  ret = (ret + f(x / 2)) % P;
  ret = (ret + f((x - 1) / 2)) % P;
  ret = (ret + f(x / 2 - 1)) % P;
  return memo[x] = ret;
}

int main() {
  memo[0] = 1;
  memo[1] = 2;
  cin >> n;
  cout << f(n) << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

if sum(A) < sum(B):
    print(-1)
    exit()

diff = [A[i] - B[i] for i in range(N)]
diff.sort()
r = sum(A) - sum(B)
ans = N
for i in range(N):
    if diff[i] < 0:
        continue
    if r < 1:
        break
    if diff[i] <= r:
        ans -= 1
        r -= diff[i]

print(ans)


Measured memory_bytes: 18292
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
bool second_greater(const pii& left, const pii& right) {
    return left.second > right.second;
}
#endif


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

    int hi = max(A, max(B, C));
    int sum = A + B + C;
    int x = hi;
    while(true){
        // ((X-A)+(X-B)+(X-C))%2 == 0
        if ((3 * x - sum) % 2 == 0) break;
        x++;
    }

    int ans = (3 * x - sum) / 2;
    cout << ans << endl;

    return 0;
}

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

#define ll long long int
#define str string

ll MOD = 1000000007,INFL = 1ll << 60,INF = 1 << 30;
ll A[10000000] = {}, X[1000000] = {};
ll aiti[10000];
int dy[]={0, 0, 1, -1},dx[]={1, -1, 0, 0};
vector <ll> v;
ll a = 0,b = 0,c = 0,n = 0,sum = 0, max = INF;
str S;
int ans = 0;

int findDigits(int n) {
        int i = 0;
        while (n > 0) {

                sum += n%10;
                n /= 10;
                i++;
        }
        return i;
}


int main(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        //Code Line
cin >> a >> b >> c;
cout << min(b / a, c) << endl;



  //Code Line
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    string s;
    cin >> s;
    string t = "";
    while (t.size() <= s.size()) {
        t += "hi";
        if (t == s) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

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

const int MAXN = 100010;
vector<pair<int,int>> adj[MAXN];
int sz[MAXN] = {0};
long long d[MAXN];
int n;
int cen = -1;
long long ans = 0;

int dfs(int x, int p) {
	sz[x] = 1;
	for(auto u : adj[x]) {
		if(u.first != p) {
			sz[x] += dfs(u.first, x);
			if(sz[x] >= (n+1)/2 and cen == -1) cen = x;
		}
	}
	return sz[x];
}

int ddfs(int x, int p, long long dth) {
	d[x] = dth;
	ans += 2*d[x];
	sz[x] = 1;
	for(auto u : adj[x]) {
		if(u.first != p) {
			sz[x] += ddfs(u.first, x, dth + u.second);
		}
	}
	return sz[x];
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int i = 0; i < n-1; ++i){
		int a,b,c;
		cin >> a >> b >> c;
		--a; --b;
		adj[a].push_back({b,c});
		adj[b].push_back({a,c});
	}
	dfs(0, 0);
	ddfs(cen, cen, 0);

	if(n&1) {
		long long mn = 1e9;
		for(auto u : adj[cen]) {
			mn = min(mn, d[u.first]);
		}
		cout <<  ans - mn << endl;
	}
	else {
		for(auto u : adj[cen]) {
			if(sz[u.first] == (n/2))
				return cout <<  ans - d[u.first] << endl, 0;
		}

		long long mn = 1e9;
		for(auto u : adj[cen]) {
			mn = min(mn, d[u.first]);
		}
		cout << ans - mn << endl;
	}
}


Measured memory_bytes: 10880
#include<stdio.h>
int main() {
	long long int a[1000005] = {};
	a[0] = 2;
  	a[1] = 1;
	int n;
	scanf("%d", &n);
	for (int i = 2; i <= n; i++) {
		a[i] = a[i - 1] + a[i - 2];
		
	}
	printf("%lld", a[n]);
}


Measured memory_bytes: 7936
#include <stdio.h>

int main(void)
{
	int x,y,a,b;
	while(1){
	scanf("%d %d",&x,&y);
	if(x==0 && y==0) break;
		if(x<=y){
			a=x; b=y;
		}else{
			b=x; a=y;
		}
		printf("%d %d\n",a,b);
	}
	return 0;
}

Measured memory_bytes: 596
fun main(args: Array<String>) {
  val (A, B, H, M) = readInts()
  val m = 60 * H + M
  val a = m.toDouble() / (12 * 60)
  val b = M.toDouble() / 60

  val d = Math.abs(a - b)
  val dMin = Math.min(d, 1 - d)
  val rad = (2 * Math.PI) * dMin

  val result2 = A * A + B * B - 2 * A * B * Math.cos(rad)
  val result = Math.sqrt(result2)
  println(result)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 36588
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}

int main(){
    ll A,B,M;
    cin>>A>>B>>M;
    vector <ll> a(A),b(B);
    ll minA=1001001001;
    ll minB=1001001001;
    rep(i,0,A){
        cin>>a[i];
        minA =min(a[i],minA);
    }
    rep(i,0,B){
        cin>>b[i];
        minB =min(b[i],minB);
    }
    ll mins=minA+minB;

    rep(i,0,M){
        ll x,y,c;
        cin>>x>>y>>c;
        ll sumc=a[x-1]+b[y-1]-c;
        mins =min(mins,sumc);
    }
    cout<<mins;
    
    
    return 0;
}

Measured memory_bytes: 1792