akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

constexpr ll MOD = 1e9 + 7;

ll calc_pow(ll x, ll pow) {
    if (pow == 0) return 1;
    ll a = calc_pow(x, pow / 2);
    a = a * a % MOD;
    if (pow % 2 == 1) a *= x;
    return a % MOD;
}

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

    ll ret = 2 * calc_pow(9, n) - calc_pow(8, n);
    ret = calc_pow(10, n) - ret;

    cout << (ret + MOD * 100000) % MOD << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
const int N = 1e2 + 10;
const int mod = 1e9 + 7;



int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    set < int > c;
    int a, b;
    c.insert(1);
    c.insert(2);
    c.insert(3);
    cin >> a >> b;
    c.erase(a);
    c.erase(b);
    cout << *c.begin();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

#define MAX_PRIME 1000000 
bool isprime[MAX_PRIME+1]; 
vector<int> primes; 
void init_prime(){
  fill(isprime, isprime+MAX_PRIME+1, true); 
  isprime[0] = isprime[1] = false; 
  for(int i = 2; i <= MAX_PRIME; i++) { 
    if (isprime[i]) { 
      primes.push_back(i); 
      for(int j = i*2; j <= MAX_PRIME; j += i) 
      isprime[j] = false; 
    } 
  } 
}

int memo[MAX_PRIME+1];
int dp[MAX_PRIME+1];

int main(){
  init_prime();
  REP(i,1,MAX_PRIME){
    if(i%2==0) continue;
    if(isprime[i] && isprime[(i+1)/2]) memo[i] = 1;
  }
  REP(i,1,MAX_PRIME){
    dp[i] = dp[i-1] + memo[i];
  }
  
  int Q;
  cin >> Q;

  rep(i,Q){
    int l, r;
    cin >> l >> r;

    cout << dp[r] - dp[l-1] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 9976
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}


int main(){
  
  string s;
  cin>>s;
  int n = s.size();
  bool flag = true;
  REP(i,n){
    if(i==0){
      if(s[i]=='0'){
        flag = false;
        break;
      }
    }else if(i==n-1){
      if(s[i]=='1'){
        flag = false;
        break;
      }
    }else{
      if(s[i] != s[n-2-i]){
        flag = false;
        break;
      }
    }
  }
  if(!flag){
    cout<<-1<<endl;
    return 0;
  }
  
  vector<int> nums;
  REP(i,n){
    if(s[i]=='1'){
      nums.push_back(i+1);
    }
  }
  vector<int> G[n];
  int nowv = 0;
  int sub_v;
  int nowc = 1;
  int r = nums.size();
  int temp_num;
  REP(i,r){
    temp_num = nums[i];
    sub_v = nowv + 1;
    while(nowc<temp_num){
      ++nowc;
      G[nowv].push_back(sub_v);
      G[sub_v].push_back(nowv);
      ++sub_v;
    }
    if(sub_v>=n)break;
    G[nowv].push_back(sub_v);
    G[sub_v].push_back(nowv);
    nowv = sub_v;
    nowc++;
  }
  
  REP(i,n){
    for(int j:G[i]){
      if(i<j){
        cout<<i+1<<' '<<j+1<<endl;
      }
    }  
  }
  
  return 0;
}


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

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

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

struct Sieve {
  vector<int> p;
  Sieve(int n) : p(n + 1, 1) {
    for (int i = 2; i <= n; ++i) {
      if (p[i] == 1) {
        p[i] = i;
        for (int j = 2 * i; j <= n; j += i) p[j] = i;
      }
    }
  }

  vector<P> fact(int x) {
    map<int, int> mp;
    while (x != 1) {
      ++mp[p[x]];
      x /= p[x];
    }
    vector<P> f;
    for (auto p : mp) f.emplace_back(p.first, p.second);
    return f;
  }
};

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

  Sieve s(n);
  ll ans = 0;
  for (int c = 1; c <= n; ++c) {
    int ab = n - c;
    if (ab == 0) continue;
    auto f = s.fact(ab);
    ll cnt = 1;
    for (auto p : f) {
      cnt *= (p.second + 1);
    }
    ans += cnt;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7160
#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>;

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main(){
    int n,m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        --a;--b;
        uf.unite(a,b); // a & b has connection
    }
    int ans = 0;
    set<int> check;
    for( int id : uf.d ){
        if( id < 0 ) ++ans;
    }
    cout << ans-1 << endl;
    return 0;
}

        


Measured memory_bytes: 3788
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    string s;
    cin>>s;
    ll a[1010]={};
    ll n=s.size();
    rep(i,n) a[s[i]-'a']++;
    rep(i,26){
        if(a[i]==0){
            cout<<(char)(i+'a')<<endl;
            return ;
        }
    }
    cout<<"None"<<endl;
    

}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    ll Q=1;
    // cin>>Q;
    rep(_,Q){

        solve();

    }
   


    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define RANGE(i,a,b) for(int i=(a);i<=(b);i++)
#define RANGER(i,a,b) for(int i=(b);i>=(a);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)
using ll=long long int;
using vi=vector<int>;
using vii=vector<vi>;
using pi=pair<int,int>;
constexpr int INF=1<<30;
constexpr ll INTL=1ll<<60;

int main(){
  ll x;
  int r,d;
  cin>>r>>d>>x;
  REP(i,10){
    x=x*r-d;
    cout<<x<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;
#define BUF (100005)

int n;
int A[BUF];
int B[BUF];
void input(void){
	cin >> n;
	for(int i=1;i<=n;i++) cin >> A[i] >> B[i];
}

int main(void){
	input();

	int max =0;
	int max_ind = 0;
	for(int i=1;i<=n;i++){
		if(A[i]>max){
			max = A[i];
			max_ind = i;
		}
	}

	cout << A[max_ind] + B[max_ind] <<endl ;
	return 0;
}


Measured memory_bytes: 1024
from collections import defaultdict as d
n = int(input())
a = list(map(int,input().split()))
m1 = d(int)
for i in a:
  m1[i]+=1

#print(m1)
flag=0
for i in m1.values():
  if i >1:
    print("NO")
    flag=1
    break

if flag==0:
  print("YES")



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

typedef long long ll;

const int maxn = 1e5 + 5;
const ll INF = 1e18;
int N, h[maxn], K;
ll dp[maxn];

ll solve(int n) {
    if (n == 0) {
        return 0;
    }
    if (dp[n] != -1) {
        return dp[n];
    }
    dp[n] = INF;
    for (int i = 1; i <= min(K, n); i++) {
        dp[n] = min(dp[n], abs(h[n] - h[n - i]) + solve(n - i));
    }
    return dp[n];
}

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

    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    memset(dp, -1, sizeof(dp));
    ll answer = solve(N - 1);
    cout << answer;

    return 0;
}

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

#define int long long

auto main() -> signed {
    string r, g, b;
    cin >> r >> g >> b;
    string s = r + g + b;
    int n = stoi(s);
    if(n%4==0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    string s; cin>>s;
    int n=s.size();
    auto sa=suffix_array(s);
    ll ans=(ll)n*(n+1)/2;
    auto lcp=lcp_array(s, sa);
    for(auto x:lcp) ans-=x;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 15688
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
#include <string>
using namespace std;
typedef long long int ll;

int main(){
	int n,a,b; cin >> n >> a >> b;
	cout << min(a,b) << " " << max(0,a+b-n) << endl;
}

Measured memory_bytes: 256
n = int(input())
t,a = map(int,input().split())
H = list(map(int,input().split()))
for i in range(n):
    H[i] = t-H[i]*0.006
minn = 10**5
for i in range(n):
    dif = abs(a-H[i])
    if dif == min(minn,dif):
        minn = dif
        p = i
print(p+1)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int cake = 4;
		int donut = 7;
		int ans = 0;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				ans = cake * i + donut * j;
				if (ans == n) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

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


Measured memory_bytes: 384
n = int(input())
a = list(map(int,input().split()))
list_S = [0]
ans = 0
for i in range(n):
    list_S.append(list_S[i] + a[i])

dict_S = {} # 辞書を用意して，数字の出現回数をカウント
for i in list_S: 
    if i in dict_S: # iが辞書にあるなら
        dict_S[i] += 1
    else: # ないなら
        dict_S[i] = 1

for v in dict_S.values(): # dict_S の全てのvalue(=出現回数)について
    ans += v * (v-1) // 2

print(ans)

Measured memory_bytes: 41196
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		String s = scn.next();
		boolean check = Character.isUpperCase(s.charAt(0));
		if (check) {
			System.out.println("A");
		} else {
			System.out.println("a");
		}
	}

}


Measured memory_bytes: 26936
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
const int mod=1e9+7;

int main(){
    ll x,y;
    cin >> x >> y;
    cout << (abs(x-y)>1?"Alice":"Brown") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define MP make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef long long LL;

static const int INF = INT_MAX;
static const int MIN = INT_MIN;
static const LL L_INF = LLONG_MAX;
static const int MOD = 1000000000 + 7;

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

    int n;
    cin >> n;
    int cnt[100005] = {};

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

    }

    int mx = 0;
    for( int i = 1; i < 100004; ++i ) {
        mx = max( cnt[i - 1] + cnt[i] + cnt[i + 1], mx );

    }

    cout << mx << endl;
    return 0;
}



Measured memory_bytes: 640
N=int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return len(divisors)
ans=0
for i in range(1,N+1):
        if i%2==0:
                continue
        else:
                u=make_divisors(i)
                if u==8:
                        ans+=1
print(ans)

Measured memory_bytes: 3060
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1e5+5;
struct eg{int v,nx;}e[N<<1];int head[N],tot;
inline void add(R int u,R int v){e[++tot]={v,head[u]},head[u]=tot;}
int d[N],st[N],top,n;
inline bool cmp(const int &x,const int &y){return d[x]>d[y];}
void dfs(int u){
	d[u]=0;
	go(u)dfs(v);
	top=0;go(u)st[++top]=v;
	sort(st+1,st+1+top,cmp);
	fp(i,1,top)cmax(d[u],d[st[i]]+i);
}
int main(){
	scanf("%d",&n);
	for(R int fa,i=2;i<=n;++i)scanf("%d",&fa),add(fa,i);
	dfs(1);
	printf("%d\n",d[1]);
	return 0;
}

Measured memory_bytes: 8064
# by the authority of GOD     author: manhar singh sachdev #

import os,sys
from io import BytesIO, IOBase

def main():
    n = int(input())
    ans = 0
    for i in range(1,n):
        ans += (n-1)//i
    print(ans)
    
#Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()

Measured memory_bytes: 63620
n, k = map(int,input().split())
ab_list = [list(map(int,input().split())) for _ in range(n)]
ab_dic= {}
ab_list.sort()
for i in range(n):
  if i<n-1 and ab_list[i][0] == ab_list[i+1][0]:
    ab_list[i+1][1] += ab_list[i][1]
  else:
    ab_dic[ab_list[i][0]]=ab_list[i][1]

ab_dic = sorted(ab_dic.items(),key=lambda x:x[0])
cnt = 0
for i in range(len(ab_dic)):
  cnt += ab_dic[i][1]
  if cnt >= k:
    print(ab_dic[i][0])
    break

Measured memory_bytes: 35476
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;


int main()
{
    int k;
    cin>>k;
    if(k%2==0||k%5==0)cout<<-1;
    else{
        int p=7%k;
        for(int i=1;i<1e7;i++){
            if(p==0){
                cout<<i;
                break;
            }
            p=(p*10+7)%k;
        }

    }

    return 0;
}


Measured memory_bytes: 3596
// abc142_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;


map<ll, int> factorize(ll n){
    ll tmp = n;
    map<ll, int> res;
    for (ll a = 2; a * a <= n; a++) { int cnt = 0; while (tmp % a == 0){ cnt++; tmp /= a; } if (cnt > 0) res[a] = cnt; }
    if (tmp > 1) res[tmp] = 1;
    return res;
}

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll A, B;
    cin >> A >> B;

    auto factA = factorize(A);
    auto factB = factorize(B);

    factA[1]++;
    factB[1]++;

//    print(factA);
//    print(factB);

    int ans = 0;
    for (auto p: factA){
        ll f = p.first;
        if (factB[f] > 0){
            ans++;
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc090/tasks/abc090_b

import itertools
import collections
import bisect

def main():
    A, B = map(int, input().split())
    ans = 0
    for i in range(A, B+1):
        j = int(str(i)[::-1])
        if i == j:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
#define MAX_N 100000000
using namespace std;
bool debug=false;

int main(){
  int h,m,s;
  cin>>s;
  h=s/3600;
  m=s%3600/60;
  s=s%3600%60;
  cout<<h<<":"<<m<<":"<<s<<endl;
  return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
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;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

int N;

ll dfs(ll x,ll sev,ll fiv,ll thr) {
  if(x > N) return 0;
  ll ret = 0;
  if(sev > 0 && fiv > 0 && thr > 0) ret++;
  ret += dfs(x * 10 + 7,sev+1,fiv,thr);
  ret += dfs(x * 10 + 5,sev,fiv+1,thr);
  ret += dfs(x * 10 + 3,sev,fiv,thr+1);
  return ret;
}
  
int main() {
  cin >> N;
  
  cout << dfs(0,0,0,0) << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())

arr = []

for i in range(N):
    s, p = input().split()
    p = int(p)
    arr.append([s, p, i + 1])

arr2 = sorted(arr, key=lambda x: x[1], reverse=True)
arr3 = sorted(arr2, key=lambda x: x[0], reverse=False)

for e in arr3:
    print(e[2])


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
 
using namespace std;
const int MAX = 100010;
long long n,m,dist[MAX],used[MAX],a[MAX],color[MAX];
struct edge{long long to,cost;};
pair<pair<int,int>,long long> E[MAX];
vector<edge> G[MAX];
 
void dfs(int s,int x,int y){
    a[s] = y; dist[s] = x;used[s] = true;
    for(int i=0;i<G[s].size();i++){
        if(!used[G[s][i].to]) dfs(G[s][i].to,x+1,G[s][i].cost-y);
    }
}
 
bool bip(int i, int col) {
    if (color[i] == col) return true;
    if (color[i] != 0) return false;
    bool ok = true;
    color[i] = col;
    for (int u = 0;u<G[i].size();u++)
        ok &= bip(G[i][u].to, 3 - col);
    return ok;
}
 
bool check(){
    for(int i=0;i<m;i++){
        if(a[E[i].first.first]+a[E[i].first.second]!=E[i].second){
            return false;
        }
    }
    return true;
}
 
vector<edge> c,d;
long long dep[MAX],ml=0,l;
void cycle(int s,int dist){
	dep[s] = dist;
	for(edge e : G[s]){
		if(dep[e.to]==-1) {
			c.push_back(e);
			cycle(e.to,dist+1);
		}else if(dep[e.to]<dep[s]-1 && !(ml & 1)){
			ml = dep[s]+1-dep[e.to];
			if(ml & 1){
				c.push_back(e);
				l = e.to;
				for(int j =0; j<c.size();j++){
					edge p = c[j];
					d.push_back(p);
				}
			}
		}
	}
	if(!(ml & 1)){
		c.pop_back();
	}
}
 
int main(){
    int i;
    cin >> n >> m;
    for(i=0;i<m;i++){
        long long u,v,s;
        cin >> u >> v >> s;
        u--; v--;
        edge e; e.to = v; e.cost = s;
        G[u].push_back(e);
        e.to = u; e.cost = s;
        G[v].push_back(e);
        pair<int,int> p = make_pair(u,v);
        E[i] = make_pair(p,s);
    }
    long long min1 = 1000000000,min2 = 10000000000;
    dfs(0,0,0);
    for(i=0;i<n;i++){
        if(dist[i]%2==1){
            min1 = min(min1,a[i]);
        }else{
            min2 = min(min2,a[i]);
        }
    }
    if(bip(0,1)){
        if(!check()){
            cout << 0 << endl;
            return 0;
        }
        if(min1<=0){
            cout << 0 << endl;
        }else if(min1>0 && min2>=0){
            cout << min1-1 << endl;
        }else if(min1>=0 && min2<0){
            if(min1+min2<=0){
                cout << 0 << endl;
            }else{
            	cout << min1+min2-1 << endl;
            }
        }
    }else{
		for(i=0;i<n;i++){
        	dep[i] = -1;
   			used[i] = false;
   		}
    	cycle(0,0);
    	int x = 1,k = d.size() - ml;
    	long long sum = 0;
    	for(i=d.size()-1;i>=k;i--){
    		sum += x*d[i].cost;
    		x *= -1;
    	}
    	if(sum%2==1){
    		cout << 0 << endl;
    		return 0;
    	}
    	dfs(l,0,sum/2);
    	for(i=0;i<n;i++){
    		min1 = min(min1,a[i]);
    	}
    	if(check() && min1>0){
        	cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
    }
}

Measured memory_bytes: 22900
// ConsoleApplication2.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

int main()
{
	int variant, amount,production;
	production = 0;
	int min = 0;
	std::cin >> variant >> amount;
	for (int i = 0; i < variant; i++)
	{
		int mi;
		std::cin >> mi;
		if (i == 0)
		{
			min = mi;
		}
		if (mi < min)
		{
			min = mi;
		}
		amount = amount - mi;
		production++;
	}
	production += amount / min;
	std::cout << production;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i,n) for(int i=0;i< (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };

int n, m;
vector<ll> d, t;

signed main() {

	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	ll tmp;

	cin >> n;
	REP(i, n) {
		cin >> tmp;
		d.push_back(tmp);
	}
	cin >> m;
	REP(i, m) {
		cin >> tmp;
		t.push_back(tmp);
	}

	VSORT(d);
	VSORT(t);

	ll nowNum=0;
	ll ok = 0;
	REP(i, m) {
		FOR(j, nowNum, n) {
			if (d[j] == t[i]) {
				nowNum = j+1;
				ok++;
				break;
			}
		}
	}

	if (ok == m) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;

	}

	return 0;

}

Measured memory_bytes: 4848
function Main(input) {
    var idata = input.split(/\s/);
    var a = parseInt(idata[0]);
    var b = parseInt(idata[1]);
    var c = parseInt(idata[2]);
    var nokori = Math.max(0, a - b);
    var ans = Math.max(0, c - nokori);
    console.log(ans);
}

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


Measured memory_bytes: 7372
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
    int Max,a,b;
    while(~scanf("%d%d",&a,&b))
    {
        Max=0;
        Max=max(a+b,a-b);
        Max=max(Max,a*b);
        printf("%d\n",Max);
    }
    return 0;
}

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

int main() {
  while (1) {
    int n;
    int m;
    int p;
    int sum = 0;
    int k;

    scanf("%d%d%d", &n, &m, &p);
    if (n == 0 && m == 0 && p == 0) return 0;

    for (int i=0; i<n; i++) {
      int x;

      scanf("%d", &x);
      if (i == m-1) k = x;
      sum += x;
    }

    if (k == 0) puts("0");
    else printf("%d\n", sum*(100-p)/k);
  }
}

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

int main() {
  int n; cin>>n;
  vector<int> a(n);
  rep(i, n) cin>>a[i];

  vector<P> p(n);
  rep(i, n) {
    p[i]=make_pair(a[i], i+1);
  }
  sort(p.begin(), p.end());
  rep(i, n) {
    printf("%d ", p[i].second);
  }
  printf("\n");
}


Measured memory_bytes: 2048
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	static int N,M,X;
	static int c[]=new int[100001];
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		N=sc.nextInt();
		M=sc.nextInt();
		X=sc.nextInt();

		
		int a[][]=new int[N][M];
		
		
		
		for(int i=0;i<N;i++) {
			c[i]=sc.nextInt();
			for(int i1=0;i1<M;i1++) {
				a[i][i1]=sc.nextInt();
			}
		}
	
		
			int v[]=new int[M];
			
			Queue<Integer> qq=new ArrayDeque<>(); //add,poll,peek
			qq.add(0);
			Queue<Integer> sum1=new ArrayDeque<>(); //add,poll,peek
			sum1.add(0);
			Queue<int[]> vv=new ArrayDeque<>(); //add,poll,peek
			vv.add(v);
			int ans=1000000009;
			while(qq.peek() != null) {
				
				int t=qq.poll();
				int s=sum1.poll();
				int bb[]=vv.poll();
				//for(int i:bb)System.out.print(i+" ");
				//System.out.println(t+" ");
				if(t==N) {
					boolean f=true;
				for(int i=0;i<M;i++) {
					if(bb[i]<X) {
						f=false;
						break;
					}
				}
				
				if(f)ans=Math.min(ans, s);
				continue;
				}
				
				
				qq.add(t+1);sum1.add(s);vv.add(bb.clone());
				
				qq.add(t+1);
				sum1.add(s+c[t]);
				for(int i=0;i<M;i++) {
					bb[i]+=a[t][i];
				}
				vv.add(bb.clone());
				
				
			}
			if(ans==1000000009)p(-1);
			else p(ans);
			
			
			
		}
		
		
	
	
	
	static int dfs(int i) {
		
		
		
		
		
		return 0;
	}
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 38136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

template< typename T >
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;
int negative[2510] = {};

template< typename T >
vector< T > bellman_ford(Edges< T > &edges, int V, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(V, INF);
  dist[s] = 0;
  for(int i = 0; i < V - 1; i++) {
    for(auto &e : edges) {
      if(dist[e.src] == INF) continue;
      dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
    }
  }
  bool flag = 0;
  for(int i = 0; i < 2*V; i++){
    for(auto &e : edges) {
        if(dist[e.src] == INF) continue;
        if(dist[e.src] + e.cost < dist[e.to])
        {
            dist[e.to] = dist[e.src] + e.cost;
            negative[e.to] = 1;
        }
    }
  }
  return dist;
}

void propagate(Edges<LL> &edges){
    for(auto &e : edges){
        if(negative[e.src] == 1) negative[e.to] = 1;
    }
}

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

    LL N,M,P; cin >>N>>M>>P;
    Edges<LL> es;
    REP(i,2510) negative[i] = 0;
    REP(i,M)
    {
        LL a,b,c; cin>>a>>b>>c;
        a--; b--;
        //c *= -1;
        c -= P;
        c *= -1;
        es.emplace_back(a,b,c);
    }
    auto dists = bellman_ford(es,N,0);
    propagate(es);

    if(negative[N-1] == 1)
    {
        cout << -1 << endl;
        return 0;
    }
    else
    {
        cout << max(dists[N-1] * -1,0LL) << endl;
    }

}


Measured memory_bytes: 512
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>



int main(void)
{
    ll x;
    cin>>x;

    for(int a = -200;a<200;a++)
    {
        for(int b=-200;b<200;b++)
        {
            ll now=pow(a,5)-pow(b,5);
            if(now==x)
            {
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }

}

Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
int main()
{
    //
    int n, x;
    scanf("%d %d", &n, &x);
    int cn = n;
    int A[n];
    for(int i = 0; i < n; i++){
        int m;
        scanf("%d", &m);
        A[i] = m;
        x -= m;
    }

    //this is where greedy comes in
    bool yes = true;
    sort(A, A+n);
    while(yes == true){
        if(x - A[0] >= 0){
            x -= A[0];
            cn++;
        }else{
            yes = false;
        }
    }
    printf("%d\n", cn);
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n];
		int[] q = new int[n];
		for (int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			q[i] = sc.nextInt();
		}

		List<Integer> pList = Arrays.stream(p).boxed().collect(Collectors.toList());
		List<Integer> qList = Arrays.stream(q).boxed().collect(Collectors.toList());
		int a = m(pList, Arrays.stream(p).sorted().boxed().collect(Collectors.toList()));
		int b = m(qList, Arrays.stream(p).sorted().boxed().collect(Collectors.toList()));
		System.out.println(Math.abs(a - b));
	}

	public static int m(List<Integer> l, List<Integer> n) {
		if (l.size() == 0) {
			return 1;
		}
		int i = l.get(0);
		int x = n.indexOf(i);
		l.remove(0);
		n.remove((Object) i);
		x = x * k(l.size());

		return x + m(l, n);
	}

	public static int k(int i) {
		if (i == 0) {
			return 1;
		}
		return i * k(i - 1);
	}
}


Measured memory_bytes: 28108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const string nl="\n";
const ll MOD=1000000007;

int main(){
    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    int a,b;
    cin>>a>>b;
    int x=max(a+b,a-b);
    cout<<max(x,a*b);
    return 0;
}

Measured memory_bytes: 256
def find_pledge(i, j):
    mylist = []
    for m in range(1, 101):
        if i % m == 0 and j % m == 0:
            mylist.append(m)
    return mylist

a, b, k = map(int, input().split())
mylist = find_pledge(a, b)
print("{}".format(mylist[len(mylist)-k]))

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

#define pb push_back
#define MAX 100005
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;

int n;
double p[3005], dp[3005][3005];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i =1; i<=n; ++i)
        cin>>p[i];
    dp[1][0] = 1-p[1];
    dp[1][1] = p[1];
    for(int i = 2; i<=n; ++i){
        dp[i][0] = dp[i-1][0]*(1-p[i]);
        for(int j = 1; j<=i; ++j){
            dp[i][j] = dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
        }
    }
    double ans = 0;
    for(int i = n; i>n-i; i--){
        ans+=dp[n][i];
    }
    cout<<fixed<<setprecision(12)<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 69120
#include <iostream>
#include<stdio.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b,x,y;
    cin>>a>>b;
    double z;
    x = a/b;
    y = a%b;
    z = 1.0 * a/b;
    cout<<x<<" "<<y<<" ";
    printf("%.6lf\n", z);
}



Measured memory_bytes: 3224
#include <cstdio>
char* r[] = { "AAA", "AA", "A", "B", "C", "D", "E", "NA" };
double a[] = { 35.5, 37.5, 40, 43, 50, 55, 70 };
double b[] = { 71, 77, 83, 89, 105, 116, 148 };
double x, y;
int main()
{
    while (scanf("%lf%lf", &x, &y) != EOF) {
        int i;
        for (i = 0; i < 7; ++i)
            if (x < a[i] && y < b[i]) { puts(r[i]); break; }
        if (i == 7) puts(r[i]);
    }
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

ll N;
vi A(5);

ll solve() {
    ll m = *min_element(ALL(A));
    ll ans = 4 + N/m;
    if (N%m) ans++;
    return ans;
}

int main() {
    cin >> N;
    REP (i, 5) cin >> A[i];
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////

int main(){
    int n;
    cin >> n;
    vector<int> ans(n);
    vector<int> c(n), s(n), f(n);
    for (int i = 0;i < n - 1;i++){
        cin >> c[i] >> s[i] >> f[i];
    }

    for (int i = 0;i < n;i++){
        int t = 0;
        for (int j = i;j < n - 1;j++){
            if (t < s[j]) t = s[j];
            else if (t % f[j] == 0);
            else t = t + f[j] - (t % f[j]);
            t += c[j];
        }
        cout << t << endl;
    }
}

Measured memory_bytes: 3604
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();

    let mut map: HashMap<String, i32> = HashMap::new();

    let mut ans_array: Vec<String> = vec![];

    for _ in 0..n {
        let command: String = read();
        let value: String = read();

        match command.as_ref() {
            "insert" => {
                map.insert(value, 1);
            }
            "find" => match map.get(&value) {
                Some(_v) => {
                    ans_array.push("yes".to_string());
                }
                None => {
                    ans_array.push("no".to_string());
                }
            },
            _ => {}
        }
    }

    for i in 0..ans_array.len() as usize {
        println!("{}", ans_array[i]);
    }
}



Measured memory_bytes: 52000
package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Scan()
	n, _ := strconv.Atoi(s.Text())

	dic := make(map[string]struct{})
	for i := 0; i < n; i++ {
		s.Scan()
		arr := strings.Split(s.Text(), " ")

		if arr[0] == "insert" {
			dic[arr[1]] = struct{}{}
		} else if arr[0] == "find" {
			if _, ok := dic[arr[1]]; ok {
				fmt.Println("yes")
			} else {
				fmt.Println("no")
			}
		}
	}
}




Measured memory_bytes: 37672
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let mut k: i64 = sc.cin();
    let a: i64 = sc.cin();
    let b: i64 = sc.cin();
    let mut ans = 1;
    {
        ans = max!(ans, 1 + k);
    }
    {
        k -= a - 1;
        ans = max!(
            ans,
            a + (b - a) * (k / 2) + (k % 2)
        );
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
/*zhen hao*/
#include <bits/stdc++.h>
using namespace std;

#define lson l, m, rt*2
#define rson m + 1, r, rt*2+1
#define xx first
#define yy second

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> pii;

const int N = 5e5 + 10;
int d[N], min_dist[N], dist[N];

int main() {
#ifdef JUDGE
    freopen("case.in", "r", stdin);
#endif
    int n, q;
    cin >> n >> dist[0];
    for (int i = 1; i <= n; i++) {
        scanf("%d", &d[i]);
        dist[i] = min(dist[i - 1], abs(d[i] - dist[i - 1]));
//        cout << dist[i] << endl;
    }
    min_dist[n + 1] = 1;
    for (int i = n; i >= 1; i--) {
        if (min_dist[i + 1] <= d[i] / 2) {
            min_dist[i] = min_dist[i + 1];
        }
        else {
            min_dist[i] = min_dist[i + 1] + d[i];
        }
//        cout << min_dist[i] << endl;
    }

    cin >> q;
    for (int i = 1; i <= q; i++) {
        int x;
        scanf("%d", &x);
        if (dist[x - 1] >= min_dist[x + 1]) puts("YES"); else puts("NO");
    }
    return 0;
}


Measured memory_bytes: 7808
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    ll n,m;
    cin >> n >> m;
    ll answer;
    if(n*2 <= m){
        answer = n;
        m-=(n*2);
        answer += (m/4);
    }
    else{
        answer = m/2;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;
const int INF = 1 << 30;

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

    int st = 0;
    for (int i = 1; i <= n; i++) {
        st += l + i - 1;
    }

    int m = INF;
    int ignore;

    for (int i = 1; i <= n; i++) {
        int s = 0;
        for (int j = 1; j <= n; j++) {
            if (j == i) continue;
            s += l + j - 1;
        }
        if (abs(s - st) < m) {
            m = abs(s - st);
            ignore = i;
        }
    }

    int res = 0;
    for (int i = 1; i <= n; i++) {
        if (i == ignore) continue;
        res += l + i - 1;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque

N, Q = map(int, input().split())
to = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    to[a - 1].append(b - 1)
    to[b - 1].append(a - 1)
P = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    P[p - 1] += x
cnt = [0] * N

q = deque()
q.append((0, 0, -1))
while len(q):
    p, x, prev = q.pop()
    x += P[p]
    cnt[p] = x
    for b in to[p]:
        if b != prev:
            q.append((b, x, p))
print(*cnt)


Measured memory_bytes: 65944
[<EntryPoint>]
let main argv =
    //printfn "Make it!"
    let n = System.Console.ReadLine() |> int
    let xs = System.Console.ReadLine().Split() |> Array.map float |> Array.toList
    let c = List.sumBy (fun x -> 1.0/x) xs
    let ans = 1.0 / c
    printfn "%f" ans
    0


Measured memory_bytes: 14044