akhauriyash/Code-Regression huggingface dataset:
"""
セグメント木
"""

INF = 10 ** 20

def main():
  n, q = map(int, input().split())
  
  size = 1
  while size < n:
    size *= 2
  size = size * 2 - 1
  
  seg_tree = [(INF, 0) for _ in range(size)]
  
  def update(a, v):
    ind = (size - 1) // 2 + a
    prea, prev = seg_tree[ind]
    seg_tree[ind] = (a + 1, prev + v)

    while ind > 0:
      ind = (ind - 1) // 2
      ca1, cv1 = seg_tree[ind * 2 + 1]
      ca2, cv2 = seg_tree[ind * 2 + 2]
      if cv1 >= cv2:
        if seg_tree[ind] == (ca1, cv1): break
        seg_tree[ind] = (ca1, cv1)

      else:
        if seg_tree[ind] == (ca2, cv2): break
        seg_tree[ind] = (ca2, cv2)
        
  
  for i in range(q):
    a, v = map(int, input().split())
    update(a - 1, v)
    print(seg_tree[0][0], seg_tree[0][1])

main()


Measured memory_bytes: 158060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)

template<class T> using V = vector<T>;
template<class T> using V2 = V<V<T>>;

void solve(){
  int n, t; cin >> n >> t;
  V<int> a(n), b(n);V<pair<int,int>> ab(n);
  FOR(i,0,n) {cin >> a[i] >> b[i]; ab[i].first = a[i]; ab[i].second = b[i]; }
  sort(ab.begin(), ab.end());
  FOR(i,0,n) {a[i] = ab[i].first; b[i] = ab[i].second; }
  V2<int> dp(n+5, V<int>(6010,-(1<<30))); 
  dp[0][0] = 0;
  FOR(i,0,n){
    FOR(j,0,6005){
      dp[i+1][j] = dp[i][j];
    }
    FOR(j,0,t){
      if(j+a[i]<6005 && dp[i][j] > -(1<<29)) dp[i+1][j+a[i]] = max(dp[i+1][j+a[i]], dp[i][j]+b[i]);
    }
  }
  int ans = 0; int cnt = 0;
  FOR(i,0,6005){
    ans = max(ans, dp[n][i]);
  }
  cout << ans << endl;
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 70912
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<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()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let M: usize = read();
    let mut vec = vec![];
    for i in 1..M + 1 {
        let (p, y): (usize, usize) = (read(), read());
        vec.push((y, p, i));
    }
    vec.sort();
    let mut prefectures: Vec<Vec<usize>> = vec![vec![]; N];
    for (_year, pref, idx) in vec {
        prefectures[pref - 1].push(idx);
    }
    let mut ans: Vec<(usize, String)> = vec![];
    for (pid, p) in prefectures.into_iter().enumerate() {
        for (i, v) in p.into_iter().enumerate() {
            ans.push((v, format!("{:>06}{:>06}", pid + 1, i + 1)));
        }
    }
    ans.sort();
    for (_i, v) in ans {
        println!("{}", v);
    }
}


Measured memory_bytes: 17280
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>
#include <queue>

using namespace std;

const int MOD = 1e9 + 7;

bool used[100000];
int dist1[100000];

int main(){

    int N, K;
    cin >> N >> K;
    vector<vector<int>> E(N);

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

    for(int i = 0; i < N; i++){
        used[i] = false;
        dist1[i] = 0;
    }

    long long ans = 1;
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int temp = q.front();
        q.pop();
        used[temp] = true;

        int cnt = 0;

        for(int e: E[temp]){
            if(used[e]){
                cnt += dist1[e] + 1;
            }
            dist1[e]++;
        }

        int kind = K - cnt;
        if(kind <= 0){
            cout << 0 << endl;
            return 0;
        }

        ans = (ans * kind) % MOD;

        for(int e: E[temp]){
            if(!used[e]){
                q.push(e);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7032
n, k = map(int, input().split())
X, Y, C = [], [], []
for _ in range(n):
  x, y, c = input().split()
  X.append(int(x)%(2*k))
  Y.append(int(y)%(2*k))
  C.append(c=="B")
G = [[0]*k for _ in range(k)]
cnt = 0
for x, y, c in zip(X, Y, C):
  if (x >= k and y < k) or (x < k and y >= k):
    x += k
    c ^= 1
  x %= k
  y %= k
  G[x][y] += (-1)**c
  cnt += c
for i in range(k):
  for j in range(k-1):
    G[i][j+1] += G[i][j]
for j in range(k):
  for i in range(k-1):
    G[i+1][j] += G[i][j]
ans = 0
for i in range(k):
  for j in range(k):
    temp = G[k-1][k-1] - G[i][k-1] - G[k-1][j] + G[i][j]*2 + cnt
    ans = max(ans, temp, n-temp)
print(ans)

Measured memory_bytes: 45388
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
int main() {
    string S; cin >> S;
    int N = S.size();
    S = '0' + S;
    if(N == 1) {
        cout << 1 << endl;
    }
    else if(N == 2) {
        cout << (S[1] == S[2]? 1:2) << endl;
    }

    vector<vector<int>> dp(N+2,vector<int>(3, -1));
    dp[N][1] = 1;
    dp[N-1][2] = 1;
    for(int i=N-1; i>=1; i--) {
        if(i+1<=N && S[i]!=S[i+1]) chmax(dp[i][1], dp[i+1][1]+1);
            if(i+2<=N){
            chmax(dp[i][1], dp[i+1][2]+1);
            chmax(dp[i][2], dp[i+2][1]+1);

        }
      if(i+3<=N && S.substr(i,2)!=S.substr(i+2,2)) chmax(dp[i][2], dp[i+2][2]+1);

    
    }
cout << max(dp[1][1], dp[1][2]) << endl;
}

Measured memory_bytes: 11328
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val a, b, c = sc.nextInt()
    val max = Array(a, b, c).max
    val sum = Array(a, b, c).sum

    if ((max * 3 - sum) % 2 == 0) {
      println((max * 3 - sum) / 2)
    } else {
      println((max * 3 - sum) / 2 + 2)
    }
  }
}


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

int main() {
	// your code goes here
	ll n;
	cin>>n;
	ll z=n/500;
	ll r=n%500;
	ll t=r/5;
	ll ans=z*1000+t*5;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//------------------------------------------------------------------------------

ll dp[52][6000];
int main(int argc, char const *argv[]) {
    ll N,A;
    cin>>N>>A;
    vector<ll> x(N),y(N);
    REP(i,N) {
        cin>>x[i];
        y[i]=x[i]-A;
    }
    FOR(i,0,N) {
        dp[i][3000+y[i]]++;
        REP(j,5000) {
            dp[i+1][j]+=dp[i][j];
            if(0<=j+y[i+1] && j+y[i+1]<5000) dp[i+1][j+y[i+1]]+=dp[i][j];
        }
    }
    cout<<dp[N-1][3000]<<endl;
    return 0;
}


Measured memory_bytes: 2432
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
const int N = 2e5 + 5;
int main()
{
    int n,flag=0;
    double t,a,b,minn=N;
    double h[1005];
    scanf("%d%lf%lf",&n,&t,&a);
    for(int i=1;i<=n;i++){
        scanf("%lf",&b);
        h[i]=t-b*0.006;
        if(minn>abs(h[i]-a)){
            flag=i;
            minn=abs(h[i]-a);
        }
    }
    printf("%d",flag);
    return 0;
}


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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
#define sz(s) (int)s.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define for1(i,n) for(int i=1;i<=(int)n;i++)
#define ford(i, b, a) for (int i = (int)(b); i >= a; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
const ll N = (ll)5e2+77;
const ll inf = (ll) 1e16+7;
const ll mod = (ll) 1e8;
const ld pi = acos(-1);

int main() {
    fast;
    int t;
    cin >> t;
    t = 25 - t;
    cout << "Christmas ";
    forn(i, t) {
        cout << "Eve ";
    }
    return 0;
}

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

using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<pair<int,pii>,vector<pair<int,pii> >,greater<pair<int,pii> > >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl



int32_t main()
{
    fast;
    int n;cin>>n;
    set<int> s;
    for(int i=0;i<n;i++)
    {
        int x;cin>>x;
        s.insert(x);
    }
    if(s.size()==n)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}   

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

int main(){
    int a[100000];
    int n;
    cin >> n;
    rep(i,n) cin >> a[i];
    map<int,int> mp;
    rep(i,n) mp[a[i]]++;
    int ans = 0;
    for(auto p: mp){
        int x = p.first;
        int y = p.second;
        if(y < x) ans += y;
        else ans += y - x;
    }
    cout << ans << endl;
}

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

int main(){
    ll x,y;
    cin >> x >> y;
    int ans = 0;
    while(y >= x){
        x *= 2;
        ans += 1;
    }
    cout << ans << endl;
}

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

int main(void){
    int n,q,l,r;
    scanf("%d%d",&n,&q);
    char s[n+3];
    scanf("%s",s);
    int count[n];
    for (int i=0; i<n; i++){
        count[i]=0;
    }
    for (int i=1; i<strlen(s); i++){
        count[i]=count[i-1];
        if (s[i-1]=='A' && s[i]=='C'){
            count[i]++;
        }
    }
    for (int i=0; i<q; i++){
        scanf("%d%d",&l,&r);
        printf("%d\n",count[r-1]-count[l-1]);
    }
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<climits>
#include<stack>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<string>
#include<cstring>
#include<sstream>
using namespace std;
 
const int LOOP_TIMES = 1e5;
const double EPS = 1e-6;
int L, N;
 
double Evaluate(int *r){
    double val = r[0] + r[N-1];
    for(int i = 0; i < N - 1; i++){
        int a = abs( r[i] - r[i+1] ), c = r[i] + r[i+1];
        val += sqrt(c*c - a*a);
    }
    return val;
}
 
bool IsChange(int cnt){
    return cnt < rand()%LOOP_TIMES + 1;
}
 
double Solve(int *r){
    double score = Evaluate(r), mi = score;
    for(int cnt = 0; cnt < LOOP_TIMES; cnt++){
        int *a = r + rand()%N, *b = r + rand()%N;
        swap(*a, *b);
 
        double next_score = Evaluate(r);
        if( score >= next_score && !IsChange(cnt) ) swap(*a, *b);
        else score = next_score;
         
        mi = min(mi, score);
    }
    return mi;
}
 
int main(){
	srand(time(NULL));

    while(cin >> L){
        N = 0;
        int r[12];
        string S;
        getline(cin, S);
        stringstream SS(S);
        while( !SS.eof() ){
            SS >> r[N++];
        }
 
        double ans;
        if(N == 1) ans = r[0]*2;
        else ans = Solve(r);
 
        if(L - ans + EPS > 0) puts("OK");
        else puts("NA");
    }
    return 0;
}

Measured memory_bytes: 1212
# B
n = int(input())
s = input()

ans = [0]*n
for i in range(n):
    l = sorted(list(set(s[:i])))
    r = sorted(list(set(s[i:])))
    for j in range(len(l)):
        for k in range(len(r)):
            if l[j] == r[k]:
                ans[i] += 1
                
print(max(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define MOD 1000000007 
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN


ll po(ll x,ll n){
    if(n==0) return 1;
    else if(n%2 == 0) return po((x*x)%MOD,n/2);
    else return (x*po((x*x)%MOD,(n-1)/2))%MOD;
}



void init(){
    
}

void solve( ll  tst ){
    ld r;
    cin>>r;
    ld pi = 6.28318530717958623200;
    printf("%0.6Lf", pi*r);
    return;
}

int main(){
    FAST;
    init();
    //cout<<"init"<<endl;
    ll t = 1;
    //cin>>t;
    for (ll i=1;i<=t;i++ ) solve(i);
    return 0;
} 

Measured memory_bytes: 3812
import math
from functools import reduce

K = int(input())
def gcd(numbers):
        res = reduce(math.gcd, numbers)
        n = len(set(numbers))
        if n == 1:
            return res
        elif n == 2:
            return res * 3
        else:
            return res * 6

ans = 0
for a in range(1, K+1):
    for b in range(a, K+1):
        for c in range(b, K+1):
            ans += gcd([a, b, c])

print(ans)


Measured memory_bytes: 69696
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint ungigned
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator

#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define BG begin
#define ED end

#define For(i,j,k) for (int i=(j);i<=(int)k;i++)
#define Rep(i,j,k) for (int i=(j);i>=(int)k;i++)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));

#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
using namespace std;

#define int long long
inline int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int k=1,kk=0;if (c=='-')c=getchar(),k=-1;
	while (c>='0'&&c<='9')kk=kk*10+c-'0',c=getchar();return kk*k;
}using namespace std;
void write(int x){if (x<0)putchar('-'),x=-x;if (x/10)write(x/10);putchar(x%10+'0');}
void writeln(int x){write(x);puts("");}
int n,m,x,y,a[1010][1010],f[10010],ff[10010],z[10010],dd;
int fa(int x){return f[x]==x?x:f[x]=fa(f[x]);} 
bitset<10010>qaq;
signed main(){
	n=read();m=read();for (int i=1;i<=m;i++)x=read(),y=read(),a[x][y]=a[y][x]=1;
	for (int i=1;i<=n;i++)f[i]=i,f[i+n]=i+n;
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++)if (!a[i][j])f[fa(i)]=fa(j+n),f[fa(i+n)]=fa(j);
	for (int i=1;i<=n;i++)ff[fa(i)]++,ff[fa(i+n)]--;
	for (int i=1;i<=n;i++)if (f[fa(i)]==f[fa(i+n)])return puts("-1"),0;
	for (int i=1;i<=n;i++)if (fa(i)==i)z[++dd]=abs(ff[i]);
	qaq[n]=1;for (int i=1;i<=dd;i++)qaq=(qaq<<z[i])|(qaq>>z[i]);
	for (int i=0;i<=n;i++)if (qaq[i+n]){
		int xx=(n-i)/2,yy=xx+i;writeln(xx*(xx-1)/2+yy*(yy-1)/2);
		return 0;
	}puts("-1");
}

Measured memory_bytes: 6272
h,w=map(int,input().split())
if h%3==0 or w%3==0:
    print(0)
    exit()
def main(a,b):
    ans=99999999999
    for l in range(1,a+1):
        s1=l*b
        s2=(a-l)*(b//2)
        s3=a*b-s1-s2
        s4=((a-l)//2)*b
        s5=a*b-s1-s4
        list1=sorted([s1,s2,s3])
        list2=sorted([s1,s4,s5])
        s=min((list1[-1]-list1[0]),(list2[-1]-list2[0]))
        if ans>s:
            ans=s
    return ans
print(min(main(h,w),main(w,h)))


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define pii pair<int, int>
#define plli pair <lli, lli>
#define F(i,n) for(lli (i)=0;(i)<(n);(i)++)
#define FR(i,n) for(lli (i)=(n)-1;(i)>=0;(i)--)
#define FSG(i,a,b) for(lli (i)=(a);(i)<(b);(i)++)
#define FSGR(i,a,b) for(lli (i)=(b)-1;(i)>=(a);(i)--)
#define VAL(n) cout << n << endl;
#define VALD(n) cout << #n << ": " << n << endl;

int main(){
  string S;
  cin >> S;
  string s[S.length()];
  for(int i = 0; i < S.length(); i++){
    s[i] = S.substr(i, 1);
  }
  int cnt1 = 0;
  int cnt2 = 0;
  string c1 = " ";
  string c2 = " ";
  F(i, S.length()){
    string c = s[i];
    if(i == 0){
      c1 = c;
      cnt1++;
    }
    else{
      if(c1 == c){
        cnt1++;
      }
      else if (c2 != c && c2 == " "){
        c2 = c;
        cnt2++;
      }
      else if(c2 == c){
        cnt2++;
      }
    }
  }
  if(cnt1 == 2 && cnt2 == 2){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
using namespace std;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> vp;
typedef vector<tuple<ll, ll, ll>> vt;
//vector<vector<ll>> vv(n, vector<ll>(n));

int main()
{
	ll n,ans=0;
	cin >> n;
	REP(i,n)
	{
		ll a, b;
		cin >> a >> b;
		ans += b - a + 1;
	}
	cout << ans << endl;
}

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

typedef long long ll;
using namespace std;
int main()
{
  ll n;
  ll a[5000];
  cin>>n;
  rep(i,n)cin>>a[i];

  ll sum=0;
  rep(i,n){
    sum+=a[i]-1;
  }

  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 3628
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			if(n==0)break;
			int ice[]=new int[10];
			for(int i=0;i<n;i++){
				int s=sc.nextInt();
				if(s==0)ice[0]+=1;
				else if(s==1)ice[1]+=1;
				else if(s==2)ice[2]+=1;
				else if(s==3)ice[3]+=1;
				else if(s==4)ice[4]+=1;
				else if(s==5)ice[5]+=1;
				else if(s==6)ice[6]+=1;
				else if(s==7)ice[7]+=1;
				else if(s==8)ice[8]+=1;
				else if(s==9)ice[9]+=1;
			}
			for(int i=0;i<10;i++){
				for(int j=0;j<ice[i];j++){
					if(j==ice[i]-1)System.out.print('*'+"\n");
					else System.out.print('*');
				}
				if(ice[i]==0)System.out.println('-');
			}
		}
	}
}

Measured memory_bytes: 55992
#include <iostream>
#include <algorithm>
#include <cstring>

constexpr int MAX = 1010;

int levenshtein_distance(char* s, char* t,
                         int incost = 1, int rmcost = 1, int recost = 1)
{
    int N = strlen(s), M = strlen(t);
    int dp[N + 1][M + 1];

    for (int i = 0; i <= N; i++) {
        dp[i][0] = i * incost;
    }
    
    for (int i = 0; i <= M; i++) {
        dp[0][i] = i * rmcost;
    }
    
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            int rcost = (s[i - 1] == t[j - 1] ? 0 : recost);
            dp[i][j] = std::min(dp[i - 1][j] + incost,
                       std::min(dp[i][j - 1] + rmcost, dp[i - 1][j - 1] + rcost));
        }
    }
    return dp[N][M];
}

int main()
{
    char s[MAX], t[MAX];
    std::cin >> s >> t;
    std::cout << levenshtein_distance(s, t) << std::endl;
    return 0;
}

Measured memory_bytes: 7016
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  string s;
  cin>>s;
  cout<<(s=="ABC"?"ARC":"ABC")<<endl;

  return 0;
}




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

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

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

	vector<int> B(n - 1, 0);
	rep(i, n - 1)  cin >> B[i];
	int x = B[0];
	int y = B[n - 2];

	int sum = 0;
	for (int i = 0; i < n - 2; i++) {
		sum += min(B[i], B[i + 1]);
	}
	sum += x + y;
	cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <limits.h>

int cnt = 0;

void marge(int A[], int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;

	int L[n1 + 1], R[n2 + 1];
	for (int i = 0; i < n1; ++i) {
		L[i] = A[left + i];
	}
	for (int i = 0; i < n2; ++i) {
		R[i] = A[mid + i];
	}
	L[n1] = INT_MAX;
	R[n2] = INT_MAX;

	int i = 0;
	int j = 0;
	for (int k = left; k < right; ++k) {
		A[k] = (L[i] <= R[j]) ? L[i++] : R[j++];
		++cnt;
	}
}

void marge_sort(int A[], int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		marge_sort(A, left, mid);
		marge_sort(A, mid, right);
		marge(A, left, mid, right);
	}
}

int main() {
	int n;
	std::cin >> n;
	int A[n];
	for (int i = 0; i < n; ++i) {
		std::cin >> A[i];
	}
	marge_sort(A, 0, n);

	for (int i = 0; i < n; ++i) {
		std::cout << A[i] << (i < n - 1 ? ' ' : '\n');
	}
	std::cout << cnt << std::endl;

	return 0;
}

Measured memory_bytes: 5064
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for a,b in ab:
    ans = []
    for c,d in cd:
        ans.append(abs(a-c)+abs(b-d))
    print(ans.index(min(ans))+1)

Measured memory_bytes: 9140
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#include <boost/multiprecision/cpp_int.hpp> 
using boost::multiprecision::cpp_int; 
 
#define ff              first
#define ss              second
// #define ll 				long long int
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define modp            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define FIO           	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl 			'\n'
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
// void aks()
// {
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
// }
 
 
void solve()
{
	cpp_int a; double b;
	cin >> a >> b;
	b = ((b)*(1000.0000000000000000));
	cpp_int bb = (cpp_int)b;
	cpp_int aa = a;
	cpp_int aans = (aa*bb);
	cpp_int t = aans/1000;
	cout << t << endl;
 
}
 
int32_t main()
{
	FIO
    //aks();
    //w(t)
    {
    	solve();
    }
    return 0;
}

Measured memory_bytes: 3892
import java.util.*;

public class Main {

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

	class Edge{
		int to;
		int cost;
		Edge(int to, int cost){
			this.to=to;
			this.cost=cost;
		}
	}

	class P implements Comparable<P>{
		int v;
		long dist;
		P(int v, long dist){
			this.v=v;
			this.dist=dist;
		}
		@Override
		public int compareTo(P arg0) {
			return Long.compare(this.dist, arg0.dist);
		}
	}

	long d[];
	long INF = 1001001001001001L;
	ArrayList<ArrayList<Edge>> g = new ArrayList<>();
	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		d = new long[n];
		for(int i=0; i<n; i++) {
			g.add(new ArrayList<>());
		}
		for(int i=0; i<n-1; i++) {
			int a=sc.nextInt();
			int b=sc.nextInt();
			a--;b--;
			int c=sc.nextInt();
			g.get(a).add(new Edge(b,c));
			g.get(b).add(new Edge(a,c));
		}

		int q=sc.nextInt();
		int k=sc.nextInt();
		k--;

		PriorityQueue<P> pq = new PriorityQueue<>();
		for(int i=0; i<n; i++) {
			d[i]=INF;
		}
		d[k]=0;
		pq.add(new P(k,0));
		while(!pq.isEmpty()) {
			P p = pq.poll();
			if(d[p.v]<p.dist) continue;
			for(Edge e : g.get(p.v)) {
				if(d[e.to] > d[p.v] + e.cost) {
					d[e.to] = d[p.v] + e.cost;
					pq.add(new P(e.to, d[e.to]));
				}
			}
		}
		for(int i=0; i<q; i++) {
			int x=sc.nextInt();
			int y=sc.nextInt();
			x--; y--;
			System.out.println(d[x]+d[y]);
		}
		sc.close();
	}





}


Measured memory_bytes: 82676
#include<bits/stdc++.h>
using namespace std;
const int maxn=55;
typedef long long ll;
const int mod=1e9+7;
ll dp[maxn][maxn][maxn*maxn];
int main()
{
	int n,k;cin>>n>>k;
	dp[0][0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			for(int x=0;x<=n*n;x++)
			{
				if(x-2*j>=0)
				dp[i][j][x]+=(2*j+1)*dp[i-1][j][x-2*j];
				//包括了在这个地方 i和i配对了，然后前面没有
				//配对的j个兔子和j个乌龟与后面的配对，那么
				//在这个地方的贡献就是2*j
				//这个地方兔子i和乌龟i没有配对，那么兔子i和
				//前面某个乌龟z配对了，这样没配对的还是有j个兔子
				//j个乌龟，贡献还是2*j 
				if(j+1<=n && x-2*j>=0)
				dp[i][j][x]+=(j+1)*(j+1)*dp[i-1][j+1][x-2*j];
				//在这之前 有j+1个没有配对，然后在这个地方配对两个
				//兔子i可以在j+1个乌龟里面选，乌龟i可以在j+1个兔子里面选
				//选完之后，还有j个没有配对，那么他们贡献加上2*j
				 if(j-1>=0 && x-2*j>=0 )
				 dp[i][j][x]+=dp[i-1][j-1][x-2*j];
				 //都不配对 以前有j-1个 现在有j个 
				 dp[i][j][x]%=mod;
			}
		}
	}
	cout<<dp[n][0][k]<<endl;
 } 

Measured memory_bytes: 66560
a, b, c, x, y = gets.split(' ').map(&:to_i)
total = 0
if a + b > 2*c
  smaller = x < y ? x : y
  x -= smaller
  y -= smaller
  total += 2 * smaller * c
end

if a > 2 * c && x > 0
  total += 2 * x * c
   y-= x
  x = 0
end
if b > 2* c && y > 0
  total += 2 * y * c
   x-= y
  y = 0
  
end
total += x*a if x > 0
total += y*b if y > 0

print total


Measured memory_bytes: 3836
module ABC140

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: task_B

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_B

    ! variables for this <subroutine>
    integer(INT32) :: num_dishes
    integer(INT32) :: sum_satisfaction

    ! arrays for this <subroutine>
    integer(INT32), dimension(:), allocatable :: list_turn
    integer(INT32), dimension(:), allocatable :: list_satisfaction
    integer(INT32), dimension(:), allocatable :: list_satisfaction_additional

    ! support variables for this <subroutine>
    integer :: itr

    ! STEP.01
    ! read out the given data
    ! (the number of the dishes)
    read(unit=INPUT_UNIT, fmt=*) num_dishes

    ! STEP.02
    ! allocate the arrays to store the given data
    allocate( list_turn(1:num_dishes) )
    allocate( list_satisfaction(1:num_dishes) )
    allocate( list_satisfaction_additional(1:num_dishes - 1) )

    ! STEP.03
    ! read out the given data
    read(unit=INPUT_UNIT, fmt=*) list_turn(:)
    read(unit=INPUT_UNIT, fmt=*) list_satisfaction(:)
    read(unit=INPUT_UNIT, fmt=*) list_satisfaction_additional(:)

    ! STEP.04
    ! calculate the sum of the satisfaction
    sum_satisfaction = list_satisfaction( list_turn(1) )

    do itr = 2, num_dishes, 1

      sum_satisfaction = sum_satisfaction + list_satisfaction( list_turn(itr) )

      if ( list_turn(itr - 1) + 1_INT32 .eq. list_turn(itr) ) then
        sum_satisfaction = sum_satisfaction + list_satisfaction_additional( list_turn(itr - 1) )
      end if

    end do

    ! STEP.05
    ! output the answer of this task
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') sum_satisfaction

    ! STEP.06
    ! deallocate the arrays to store the given data
    deallocate( list_turn )
    deallocate( list_satisfaction )
    deallocate( list_satisfaction_additional )

    ! STEP.END
    return

  end subroutine task_B

end module ABC140


program main

  ! <module>s to import
  use, non_intrinsic :: ABC140

  ! require all variables to be explicitly declared
  implicit none

  call task_B

end program main

Measured memory_bytes: 768
<?php
fscanf(STDIN, "%d", $n);
$xList = explode(' ', trim(fgets(STDIN)));
$ave = round(array_sum($xList) / $n);

$totalHp = 0;
foreach($xList as $x) {
    $totalHp += pow(($x - $ave), 2);
}
echo $totalHp;

echo PHP_EOL;
?>


Measured memory_bytes: 4604
N = int(input())
a = [set() for _ in range(N)]

for i in range(N):
    id = int(input()) - 1
    a[id].add(i)

step = -1
#already = a[1]
now = a[1]
next = set()
for i in range(N-1):
    #already = already.union(now)
    if 0 in now:
        step = i+1
        break
    for j in now:
        next = next.union(a[j])
    now = next
    next = set()

print(step)

Measured memory_bytes: 97608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main(){
  int n,m;
  ll k;
  cin >> n >> m >> k;
  vector<ll> a(n+1), b(m+1);
  for(int i = 0; i < n; i++){
    cin >> a[i+1];
    a[i+1] += a[i];
  }
  for(int i = 0; i < m; i++){
    cin >> b[i+1];
    b[i+1] += b[i];
  }
  int ans = 0;
  int j = m;
  for(int i = 0; i <= n; i++){
    if(a[i] > k) break;
    while(a[i]+b[j] > k) j--;
    ans = max(ans,i+j);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6436
#include <stdio.h>
int main()
{
    long long n,w1,w2,j,h;
    int f;
    while(~scanf("%lld",&n))
    {
        f=0;
     for(h=1;h<=3500;h++)
       { for(j=1;j<=3500;j++)

       {

        w1=n*h*j;
        w2=4*h*j-n*h-n*j;
        if(w1>0&&w2>0&&w1%w2==0)
          {

           printf("%lld %lld %lld\n",h,j,w1/w2);
                f=1;}
       if(f)
                break;

    }
    if(f)
        break;
}
 }
return 0;
}


Measured memory_bytes: 128
program sample
    implicit none
  
    integer(8) :: i,j,m,n,a0,a1,b,c,d
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n
    if(n<3)then
        write(*,*)1
        stop
    end if
    allocate(x(n))
    read(*,*)x
    if (x(1)<x(2))then
        a0=1
    elseif (x(1)==x(2))then
        a0=0
    else
        a0=-1
    end if
    m=1
    b=0
    do i=2,n-1
        
        if (x(i)<x(i+1))then
            a1=1
        elseif (x(i)==x(i+1))then
           
            cycle
        else
            a1=-1
        end if
        if(b==0)then
            if(a0*a1<0)then
                m=m+1
                b=1
            end if
        else
            b=0
        end if
        a0=a1
        
        
    enddo
    write(*,*) m
  
    stop
end program sample
  



Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  string s;
  cin >> n >> s;
  map<char,ll> count;
  for(ll i=0;i<n;i++) {
    count[s[i]]++;
  }
  ll ans=1;
  for(auto p:count) {
    ans=ans*(p.second+1)%mod;
  }
  ans=(ans-1+mod)%mod;
  cout << ans << endl;
}

Measured memory_bytes: 512
ini_list = \
    [('M', 'A', 'R'), \
     ('M', 'A', 'C'), \
     ('M', 'A', 'H'), \
     ('M', 'R', 'C'), \
     ('M', 'R', 'H'), \
     ('M', 'C', 'H'), \
     ('A', 'R', 'C'), \
     ('A', 'R', 'H'), \
     ('A', 'C', 'H'), \
     ('R', 'C', 'H')]

N = int(input())
name_dict = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}

for i in range(N):
    name = input()
    if name[0] in name_dict:
        name_dict[name[0]] += 1

result = 0

for a, b, c in ini_list:
    result += name_dict[a] * name_dict[b] * name_dict[c]

print(result)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        long c = (long)(n * (n - 1) + m * (m - 1)) / 2;
        System.out.println(c);
    }
}


Measured memory_bytes: 23764
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define Abs(x) ((x) > 0 ? (x) : -(x))
#define REP(i, n) for(int i = 0; i < n; i++)
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9 + 7
typedef long long ll;

int sort(const void *a, const void *b){
  return *(int *)a - *(int *)b;
}

int
main(int argc, char *argv[])
{
  int n, a[100000];
  scanf("%d", &n);
  REP(i, n) scanf("%d", &a[i]);

  qsort(a, n, sizeof(int), sort);

  int max = a[n - 1];
  int k = 0;
  while(max / 2 > a[k] && k < n -2) k++;

  if(k > 0)
    printf("%d %d\n", max, (Abs(max/2 - a[k]) > Abs(max/2 - a[k - 1]) ? a[k - 1] : a[k]));

  else
    printf("%d %d\n", max, a[n - 2]);
    
  return 0;
}


Measured memory_bytes: 892
import sys
from itertools import permutations
 
def main():
	while True:
		line = raw_input()
		if line == "0 0": break
		n = int(line)
		k = input()
		nums = [raw_input().strip() for i in xrange(n)]
		result = set(["".join(p) for p in permutations(nums, k)])
		print (len(result))

if __name__ == '__main__':
	sys.exit(main())

Measured memory_bytes: 5016
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int digit;

        digit = n % 10;

        if (digit == 2 | digit == 4 | digit == 5 | digit == 7 | digit == 9){
            System.out.println("hon");;

        } else if (digit == 0 | digit == 1 | digit == 6 | digit == 8){
            System.out.println("pon");

        } else if (digit == 3){
            System.out.println("bon");

        }else{
            
        }
    }
}

Measured memory_bytes: 35620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int modpow(int x, int n, int m) {
    x %= m;
    int res = 1;
    while(n > 0) {
        if(n & 1)
            res = res * x % m;
        x = x * x % m;
        n >>= 1;
    }
    return res;
}

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::steady_clock::now().time_since_epoch().count());

    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = inf;
    for(int j = 1; j <= 100; j++) {
        int cur = 0;
        for(int i = 0; i < n; i++) {
            cur += (j - a[i]) * (j - a[i]);
        }
        ans = min(ans, cur);
    }
    cout << ans;

    return 0;
}

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

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

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

	int ans = 700;

	for (int i = 0;i < 3;i++){
		char c; cin >> c;
		if(c == 'o') ans += 100;
	}

	cout << ans << endl;

	return 0;

}


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


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N; cin >> N;
  int vmax = 0;
  int sum = 0;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
    vmax = max(vmax, p.at(i));
    sum += p.at(i);
  }
  sum -= vmax / 2;
  cout << sum << endl;

  return 0;
}



Measured memory_bytes: 256
import itertools

a,b,c = map(int,input().split())
k = int(input())

flag = False

for arr in list(itertools.product([0,1,2], repeat=k)):
    temp = [a,b,c]
    for i in range(k):
        temp[arr[i]] = temp[arr[i]]*2

        if temp[0] < temp[1] and temp[2] > temp[1]:
            flag = True

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9332
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  ll l,r,d;
  cin>>l>>r>>d;
  ll cnt=0;
  for(ll i=l;i<=r;i++)
  {
      if(i%d==0)
      cnt++;
  }
  cout<<cnt<<endl;
}



Measured memory_bytes: 3604
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define N 110
int n,m,ji[30],a4,a2,a1;
char s[N][N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s[i]+1);
		for(int j=1;j<=m;j++)
			ji[s[i][j]-'a']++;
	}
	for(int i=0;i<26;i++)
	{
		a4+=ji[i]/4;ji[i]%=4;
		a2+=ji[i]/2;ji[i]%=2;
		a1+=ji[i];
	}
	a4-=(n/2)*(m/2);
	if(a4<0){puts("No");return 0;}
	a2+=a4*2;
	a2-=(n/2)*(m&1)+(m/2)*(n&1);
	if(a2<0){puts("No");return 0;}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    if(str.length() % 2 != 0){
      System.out.println("No");
      System.exit(0);
    }
    while(true){
      String tmp = str.replace(String.valueOf(str.charAt(0)), "");
      if((str.length() - tmp.length()) % 2 != 0){
        System.out.println("No");
        System.exit(0);
      }else if(tmp.length() == 0){
        System.out.println("Yes");
        System.exit(0);
      }
      str = tmp;
    }
  }
}

Measured memory_bytes: 22868
// /*
// "Won't stop until I'm phenomenal."
// - Phenomenal, Eminem
//  */
// #include<bits/stdc++.h>
// using namespace std;
// typedef long long int ll;
// #define ff first
// #define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
// #define ss second
// #define all(c) c.begin(),c.end()
// #define endl "\n"
// #define test() int t; cin>>t; while(t--)
// #define fl(i,a,b) for(int i = a ; i <b ;i++)
// #define get(a) fl(i,0,a.size())  cin>>a[i];
// #define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
// #define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
// const ll INF = 2e18;
// const int inf = 2e9;
// const int mod1 = 1e9 + 7;



// int main(){
//     Shazam;
//     int n; cin>>n;
//     vector<ll> a(n);
//     for(ll &i : a)
//         cin>>i;
//     vector<vector<int>> table(63, vector<int> (n));
//     for(int bit = 0; bit < 63; bit++){
//         for(int i = 0 ; i < n; i++){
//             table[bit][i] = ((a[i]&(1LL<<bit)) > 0);
//         }
//     }
//     auto add = [&](ll &a, ll b){
//         a = (a + b)%mod1;
//     };
//     ll ans = 0;
//     for(int bit = 0; bit < 63; bit++){
//         ll x = count(table[bit].begin(), table[bit].end(),0);
//         ll y = n - x;
//         add(ans, (1LL<<bit)%mod1*y%mod1*x%mod1);
//     }
//     cout<<ans<<endl;
//     return 0;
// }
/*
"Won't stop until I'm phenomenal."
- Phenomenal, Eminem
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    int n; cin>>n;
    vector<ll> a(n);
    for(ll &i : a)
        cin>>i;
    vector<vector<int>> table(61, vector<int> (n));
    for(int bit = 0; bit < 61; bit++){
        for(int i = 0 ; i < n; i++){
            table[bit][i] = ((a[i]&(1LL<<bit)) > 0);
            if(i)
                table[bit][i]+=table[bit][i-1];
        }
    }
    auto add = [&](ll &a, ll b){
        a = (a + b)%mod1;
    };
    ll ans = 0;
    for(int bit = 0; bit < 61; bit++){
        for(int i = 0; i < n-1; i++){
            if(!(a[i]&(1LL<<bit)))
                add(ans, (table[bit][n-1]-table[bit][i-1])*((1LL<<bit)%mod1)%mod1);
            else
                add(ans, (n- i   - (table[bit][n-1]-table[bit][i-1]))*((1LL<<bit)%mod1)%mod1);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 78112
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;

//#define fi1 ifstream fin("input.txt")
//#define of1 ofstream fout("output.txt")
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

vector< pair<ll,ll> >points;
map< pair<ll,ll>,ll>dp;

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

	for(ll i=1;i<=n;i++)
	{
		ll x,y;
		cin>>x>>y;
		points.eb(x,y);
	}
	sort(points.begin(),points.end());
	for(ll i=0;i<n;i++)
	{
		for(ll j=i+1;j<n;j++)
		{
			ll tp=points[j].fi-points[i].fi;
			ll tq=points[j].se-points[i].se;
			dp[mp(tp,tq)]++;
		}
	}
	ll ans=n;
	for(auto &x:dp)
	{
		ans=min(ans,n-x.se);
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <map>

int main() {
  int N,M;
  std::cin >>N >> M;
  std::map<unsigned long long,
    unsigned long long> AB;
  for(int i=0; i<N;i++){
    unsigned long long a,b;
    std::cin >> a >> b;
    AB[a] += b;
  }
  unsigned long long sum=0;
  unsigned long long cnt = 0;
  for(auto &ab:AB){
    if(cnt + ab.second>=M){
      sum += ab.first*(M-cnt);
      std::cout << sum << std::endl;
      break;
    }
    cnt += ab.second;
    sum += ab.first*ab.second;
  }
  return 0;
}

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

int main(){
	/*
	int A[100];
	for (int i = 0; i <= 99; i++){
		A[i] = 99-i;
	}
	sort(A,A+100);
	for (int i = 0; i <= 99; i++){
		cout << A[i] << endl;
	}
	*/

	while(1){
		int n;
		cin >> n;
		if(n == 0){
			break;
		}
		int A[n];
		for (int i = 0; i <= n-1; i++){
			cin >> A[i];
		}
		sort(A,A+n);
		int sum = 0;
		for (int i = 1; i<= n-2; i++){
			sum += A[i];
		}
		cout << (int)(sum/(n-2)) << endl;
	}

}

Measured memory_bytes: 1176
n, k = map(int, input().split(' '))
s = input()
if k >= n:
  print(n)
  exit()
  
s10 = []
cnt = 0
s_prev = '1'
for si in s+'x':
  if si == s_prev:
    cnt += 1
  else:
    s10.append(cnt)
    cnt = 1
  s_prev = si
if s[-1] == '0':
  s10.append(0)
if len(s10) < 2*k + 1:
  print(n)
  exit()

sum_i = sum(s10[:2*k+1])
sum_max= sum_i

for i in range(len(s10)//2-k):
  sum_i += (s10[2*i + 2*k + 1] + s10[2*i + 2*k + 2] - s10[2*i] - s10[2*i+1])
  sum_max = max(sum_i, sum_max)
  
print(sum_max)

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

int main() {
  double a,b,c;
  cin>>a>>b>>c;
  double d=a/b;
  if(d<=c){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
          
  

Measured memory_bytes: 3720
hon = (2, 4, 5, 7, 9)
pon = (0, 1, 6, 8)
bon = (3, )

s = input().strip()

last = int(s[-1])

if last in hon:
    print("hon")
elif last in pon:
    print("pon")
else:
    print("bon")


Measured memory_bytes: 9196