akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
//#define debug
//#define TRACE(x)

using namespace std;

typedef long long llint;

const int MAXN = 105; 

struct rect {
  int r1, c1, r2, c2;
};

rect inter(rect a, rect b) {
  return {max(a.r1, b.r1), max(a.c1, b.c1), min(a.r2, b.r2), min(a.c2, b.c2)};
}

int h, w;
char a[MAXN][MAXN];
int p[MAXN][MAXN], er, ec;
int dp[2][MAXN][MAXN][MAXN];

int sum(rect r) {
  if (r.r1 > r.r2 || r.c1 > r.c2) return 0;
  int ret = 0;
  ret += p[r.r2][r.c2];
  if (r.r1 > 0) ret -= p[r.r1 - 1][r.c2];
  if (r.c1 > 0) ret -= p[r.r2][r.c1 - 1];
  if (r.r1 > 0 && r.c1 > 0) ret += p[r.r1 - 1][r.c1 - 1];
  return ret;
}

int get_col(int c, rect rt) {
  return sum(inter({0, c, h - 1, c}, rt));
}

int get_row(int r, rect rt) {
  return sum(inter({r, 0, r, w - 1}, rt));
}

int main(void) {
  scanf("%d %d",&h,&w);
  REP(i, h) scanf("%s",a[i]);

  REP(i, h) REP(j, w) {
    if (a[i][j] == 'E') {
      er = i;
      ec = j;
    }
  }

  REP(i, h) REP(j, w) {
    int ret = 0;
    if (a[i][j] == 'o') ++ret;
    if (i > 0) ret += p[i-1][j];
    if (j > 0) ret += p[i][j-1];
    if (i > 0 && j > 0) ret -= p[i-1][j-1];
    p[i][j] = ret;
  }

  for (int l = w - 1; l >= 0; --l)
    for (int r = w - 1; r >= 0; --r)
      for (int u = h - 1; u >= 0; --u)
	for (int d = h - 1; d >= 0; --d) {
	  rect save = inter({u, l, h - 1 - d, w - 1 - r},
			    {er - d, ec - r, er + u, ec + l});

	  if (save.r1 > save.r2 || save.c1 > save.c2) {
	    dp[l&1][r][u][d] = 0;
	    continue;
	  }

	  
	  int ret = sum(save);
	  ret = max(ret, dp[l&1][r+1][u][d] + get_col(w - 1 - r, save));
	  ret = max(ret, dp[(l+1)&1][r][u][d] + get_col(l, save));
	  ret = max(ret, dp[l&1][r][u+1][d] + get_row(u, save));
	  ret = max(ret, dp[l&1][r][u][d+1] + get_row(h - 1 - d, save));

	  dp[l&1][r][u][d] = ret;
	  // TRACE(l _ r _ u _ d _ ret);
	  // TRACE(save.r1 _ save.c1 _ save.r2 _ save.c2);
	}

  printf("%d\n",dp[0][0][0][0]);

  return 0;
}


Measured memory_bytes: 9216
A={-1:False}
n=int(input())
count=0
for i in range(n):
    num=int(input())
    try:
        
        if(A[num]==True):
            count-=1
            A[num]=False
        else:
            count+=1
            A[num]=True
    except:
        #print("exception",A,num)
        A[num]=True
        count+=1
print(count)


Measured memory_bytes: 53592
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-8;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    for(;;){
        int n;cin>>n;
        if(n==0)return 0;
        string s[n];
        rep(j,0,n)cin>>s[j];
        int cnt=1;
        map<string,int> mp;
        vector<int> w[n];
        rep(i,0,n){
            string now="";
            rep(j,0,s[i].size()){
                if(s[i][j]==':'||s[i][j]==','||s[i][j]=='.'){
                    if(mp[now]==0){
                        mp[now]=cnt;
                        cnt++;
                    }
                    w[i].push_back(mp[now]);
                    //cout<<mp[now]<<endl;
                    now="";
                }
                else now+=s[i][j];
            }
        }
        vector<int> v[cnt];
        rep(i,0,n){
            rep(j,1,w[i].size()){
                v[w[i][0]].push_back(w[i][j]);
            }
        }
        queue<int> q;
        bool used[cnt];
        fill(used,used+cnt,false);
        used[1]=true;
        int ans=0;
        q.push(1);
        while(q.size()>0){
            int now=q.front();
            q.pop();
            if(v[now].size()==0){
                ans++;
                continue;
            }
            rep(i,0,v[now].size()){
                int ne=v[now][i];
                if(used[ne])continue;
                used[ne]=true;
                q.push(ne);
            }
        }
        cout<<ans<<endl;
    }
}






Measured memory_bytes: 3344
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));

typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
int main(){
    int n;
    std::cin >> n;
    string s,t;
    std::cin >> s>>t;
    rep(i,n){
        bool han=1;
        rep(j,n-i){
            if(s[i+j]!=t[j])han=0;
        }
        if(han){
            std::cout << n+i << std::endl;
            exit(0);
        }
    }
    std::cout << 2*n << std::endl;
}

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

typedef long long ll;
typedef pair<ll,ll> edge;

ll n, k;
ll h[1000000];

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


    for( ll i=0; i<n; i++ ){
        if( h[i] >= k ){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


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

int n, m = 0, sum = 0;

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int l;
        cin >> l;
        m = max(l, m);
        sum += l;
    }
    if (sum - m > m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main() {
  int W,H,N;
  cin >> W >> H >> N;
  int bigx,smallx,bigy,smally;
  bigx = W;
  smallx = 0;
  bigy = H;
  smally = 0;
  int x,y,a;
  for (int i=0; i<N; i++) {
    cin >> x >> y >> a;
    if (a == 1) {
      smallx = max(smallx,x);
    }
    if (a == 2) {
      bigx = min(bigx,x);
    }
    if (a == 3) {
      smally = max(smally,y);
    }
    if (a == 4) {
      bigy = min(bigy,y);
    }
  }
  cout << max(0,bigx-smallx) * max(0,bigy-smally) << endl;
}

Measured memory_bytes: 256
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n+1):
        k = n-i-j
        s = i*10000 + j*5000 + k*1000
        if s == y and k >= 0:
            print(i,j,k)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 40300
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,t = li()
ct = []
for _ in range(n):
    ct.append(list(li()))
    
ans = 10**18
for ci, ti in ct:
    if ti <= t:
        ans = min(ans, ci)
        
if ans == 10**18:
    print("TLE")
else:
    print(ans)

Measured memory_bytes: 3064
S = input()
MOD = 10**9+7
A = 0
C = S.count('C')
Q = 0
QMAX = S.count('?')

ans = 0
# <ABCとして選んだ場所>* 3**(残された_の数)
b = 3 ** (QMAX-2) % MOD
q = 3 ** (QMAX-3) % MOD

for s in S:
    if s == 'A':
        A += 1
    elif s == 'C':
        C -= 1
    elif s == 'B':
        ans = (ans + (3*A+Q) * b * (3*C+QMAX-Q))%MOD
    else:
        ans = (ans + (3*A+Q) * q * (3*C+QMAX-Q-1))%MOD
        Q += 1

print(int(ans))

Measured memory_bytes: 3188
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        t: String,
    };
    let ans: String = t
        .chars()
        .map(|c| match c {
            'P' => 'P',
            'D' => 'D',
            '?' => 'D',
            _ => ' ',
        })
        .collect::<String>();

    println!("{}", ans);
}


Measured memory_bytes: 2676
#include "bits/stdc++.h"
using namespace std;

const int N = 505;

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

    for(int i = 1; i <= n; ++i) {
        int smy = 0;
        for(int j = i; j < n; ++j) {
            smy = max(smy, s[j]);
            smy = (smy + f[j] - 1) / f[j] * f[j];
            smy += c[j];
        }
        cout << smy << endl;
    }
}

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;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int N = 2e6 + 6;
int A[N];
int n;

void solve()
{
     cin >> n;

     int ans  = 0;
     map<int,int> m;

     loop(i,1,n+1)
     {
     	cin >> A[i];
     	m[A[i]+i]++;
     }

     loop(i,1,n+1)
     {
          ans += m[i-A[i]];
          if( i-A[i] == i + A[i] )ans--;
     }

     cout << ans << endl;


}
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);

ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	

 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

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

int main() {
  int a[5];
  for(int i=0;i<5;i++){
    cin >>a[i];
  }
  int k;
  cin >>k;
  if(a[4]-a[0]>k){
    cout <<":("<<endl;
  }
  else{
    cout <<"Yay!"<<endl;
  }
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int a, b;
  cin >> a >> b;
  if (a > 1)
    a -= 1;
  if (b > 1)
    b -= 1;
  pr(a * b);

  return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

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) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  ll x, y; std::cin >> x >> y;
  int ans = 1;
  while (x*2 <= y) x *= 2, ans++;
  std::cout << ans << "\n";
}


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

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

int main() {
    int n;
    cin >> n;
    vector<pair<ll, int>> a(n);
    rep(i, n) {
        int tmp_a;
        cin >> tmp_a;
        a[i] = make_pair(tmp_a, i);
    }
    sort(a.begin(), a.end());
    int ans = 0;
    rep(i, n) {
        if (a[i].second % 2 != i % 2) ++ ans; 
    }
    cout << ans/2 << endl;
    return 0;
}


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

int main(){
    string s,t,ans;
    cin >> s >> t;
    std::sort(s.begin(), s.end()); std::sort(t.begin(),t.end(), std::greater<>());
    if(s < t) ans = "Yes";
    else ans = "No";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  long long a,b,amari;
  long long x,y;
  cin>>a>>b;
  x=max(a,b);
  y=min(a,b);
  amari=x%y;
  while(amari!=0){
    x=y;
    y=amari;
    amari=x%y;
  }
  cout<<y<<endl;
}

Measured memory_bytes: 1156
package main

import (
	"fmt"
)

func main() {
	var R int
	var ans string
	fmt.Scan(&R)

	if R < 1200 {
		ans = "ABC"
	} else if R < 2800 {
		ans = "ARC"
	} else {
		ans = "AGC"
	}

	fmt.Println(ans)
}

Measured memory_bytes: 512
n,m=map(int,input().split())
edr=[]
for i in range(n):
  edr.append(list(map(int,input().split())))
edr.sort(key =lambda x:x[0])
cnt=0
ans=0
for i in range(n):
  cnt+=edr[i][1]
  ans+=edr[i][0]*edr[i][1]
  if cnt>=m:
    ans-=(cnt-m)*edr[i][0]
    break
print(ans)


Measured memory_bytes: 29024
// A - Kenken Race
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	a--, b--, c--, d--;
	string s;
	cin >> s;

	bool ans = true;
	if (c > d) {
		ans = false;
		for (int i = b - 1; i < d; i++)
			if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') ans = true;
		for (int i = a; i < c - 1; i++)
			if (s[i] == '#' && s[i + 1] == '#') ans = false;
	} else {
		for (int i = b; i < d - 1; i++)
			if (s[i] == '#' && s[i + 1] == '#') ans = false;
		for (int i = a; i < c - 1; i++)
			if (s[i] == '#' && s[i + 1] == '#') ans = false;
	}

	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int h, w, d;
    cin >> h >> w >> d;
    auto a = make_vec<int>(h, w);
    int n = h * w;
    vector<int> x(n+10), y(n+10);
    rep(i, h) rep(j, w) {
        cin >> a[i][j];
        a[i][j]--;
        y[a[i][j]] = i;
        x[a[i][j]] = j;
    }
    vector<int> v(n+10, 0);
    for (int i = 0; i < d; i++) {
        for (int j = 0; (j + 1) * d+i < n; j++) {
            int now = (j + 1) * d + i;
            int pre = j * d + i;
            v[now] += v[pre] + abs(y[now] - y[pre]) + abs(x[now] - x[pre]);
        }
    }
    // rep(i, n) cout << i + 1 << " " << v[i] << endl;
    int q;
    cin >> q;
    while (q--) {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        cout << v[r] - v[l] << endl;
    }
}


Measured memory_bytes: 2560
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
dic = defaultdict(int)
s,t = input().split()
a,b = readInts()
dic[s] = a
dic[t] = b
u = input()
dic[u] -= 1
print(dic[s], dic[t])


Measured memory_bytes: 10280
#include <iostream>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    
    int ans = 9999999;
   
    for (int i = 0; i < (1 << N); i++) {
        int a = 1;
        for (int j = 0; j < N; j++) {
            if ((i >> j) & 1) {
                a *= 2;
            } else {
                a += K;
            } 
        }
        ans = min(ans, a);
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int N;
 	cin >> N;
 	vector<int>a(N);
 	for (int i = 0; i < N; i++) {
 		cin >> a.at(i);
 	}
 	sort(a.begin(),a.end());
 	cout << a.at(N-1)-a.at(0) << endl;
 }

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

int main(){
  int n;
  cin >> n;
  int v[n],c[n];
  int sum = 0;
  rep(i,n) cin >> v[i];
  rep(i,n){
    cin >> c[i];
    if(v[i]-c[i]>0) sum += v[i] - c[i];
  }
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n, r, max, r_base;

	scanf("%d", &n);

	scanf("%d", &r_base);

	max = 1 - 1000000000;
	for (int i=0; i<n-1;i++) {
		scanf("%d", &r);
		if (max < r - r_base) {
			max = r - r_base;
		}
		if (r_base > r) {
			r_base = r;
		}
	}

	printf("%d\n", max);
}




Measured memory_bytes: 2744
#include <iostream>

using namespace std;

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

	int x = s / 100;
	int y = s % 100;

	int f1 = 1 <= x && x <= 12;
	int f2 = 1 <= y && y <= 12;

	if(f1) {
		cout << (f2? "AMBIGUOUS" : "MMYY") << endl;
	} else {
		cout << (f2? "YYMM" : "NA") << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N;
  string S;
  cin >> N >> S;
  int X, co;
  X = co = 0;
  rep(i, N) {
    if(S.at(i) == 'D') {
      X--;
    }
    else {
      X++;
    }
    co = max(X, co);
  }
  cout << co;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

vector<vector<int>> to, cost;
vi ans;
void dfs(int v, int c = 0) {
    ans[v] = c;
    rep(i, sz(to[v])) {
        if (ans[to[v][i]] != -1) continue;
        int nc = (cost[v][i]%2==0 ? c : 1-c);
        dfs(to[v][i], nc);
    }
}

int main(){
    int n;
    cin >> n;
    to = vector<vector<int>>(n);
    cost = vector<vector<int>>(n);
    rep(i, n-1) {
        int u, v, w;
        cin >> u >> v >> w;
        --u; --v;
        to[u].pb(v);
        cost[u].pb(w);
        to[v].pb(u);
        cost[v].pb(w);
    }
    ans = vi(n, -1);
    dfs(0);
    rep(i, n) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 16132
from collections import defaultdict
from collections import deque
from collections import OrderedDict
import itertools
from sys import stdin
input = stdin.readline


def main():
  N = int(input())
  P = list(map(int, input().split()))

  min_ = float('inf')
  cnt = 0
  for i in range(N):
    if P[i] < min_:
      cnt += 1
      min_ = P[i]

  print(cnt)


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 102944
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

ll mod,fact[3030],invfact[3030],p[3030],pp[3030],dp[3030][3030];

ll pow(ll n,ll k){
  ll ret=1;
  while(k>0){
    if(k&1)ret=ret*n %mod;
    n=n*n%mod;
    k/=2;
    }
  return ret;
  }

ll comb(int n,int k){
  ll ret=fact[n]*invfact[n-k]%mod;
  return ret*invfact[k] %mod;
  }

int main(){
  int n;cin>>n;
  cin>>mod;
  
  fact[0]=invfact[0]=1;
  pp[0]=2;
  rep(i,3000){
    fact[i+1]=(ll)(i+1)*fact[i] %mod;
    invfact[i+1]=pow(fact[i+1],mod-2);
    pp[i+1]=pp[i]*pp[i] %mod;
    }
  
  rep(i,n+1)dp[0][i]=0;
  dp[0][0]=1;
  REP(i,1,n+1)rep(j,n+1){
    if(j==0)dp[i][j]=1;
    else dp[i][j]=(dp[i-1][j-1]+dp[i-1][j]*(j+1))%mod;
    }
  ll ans=0;
  rep(i,n+1){
    ll ret=0;
    rep(j,n+1){
      ll res=pow(2,(ll)(n-i)*j)*pp[n-i]%mod;
      res=res*dp[i][j]%mod;
      ret=(ret+res)%mod;
      }
    ret=ret*comb(n,i)%mod;
    if(i&1)ans+=mod-ret;
    else ans+=ret;
    ans%=mod;
    }
  cout<<ans<<endl;
  return 0;
  }

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
#define INF 1000000000
#define pb push_back
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define tr(c, i) for (typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c), x) != c.end())

ll bigmod(ll a, ll b, ll m)
{

    if (b == 0)
        return 1;
    ll x = bigmod(a, b / 2, m);
    x = (x * x) % m;

    if (b % 2)
        x = (x * a) % m;
    return x;
}

ll bigsum(ll a, ll b, ll m)
{
    ll s;
    if (b == 0)
        return b;
    if (b == 1)
        return a + 1;
    if (b % 2)
    {
        b = b / 2;
        s = bigsum(a, b, m) % m;
        s = (s * bigmod(a, b + 1, m)) % m;
        return s;
    }
    else
    {
        s = bigsum(a, b - 1, m) % m;
        s = (a * s + 1) % m;
        return s;
    }
}


int main()
{
    ll s=0,n,i,ara[200005];
    cin>>n;
    for(i=0;i<n;i++){
        cin>>ara[i];
    }

    for(i=1;i<n;i++){
        if(ara[i]<ara[i-1]){
            s+= ara[i-1]-ara[i];
            ara[i] = ara[i-1];
        }
    }

    cout<<s<<endl;
    
    return 0;
}

Measured memory_bytes: 5172
package main

import (
	"fmt"
	"sort"
)

func main() {
	var p, q, r int
	fmt.Scan(&p, &q, &r)

	result := make([]int, 0)
	result = append(result, p + q)
	result = append(result, q + r)
	result = append(result, p + r)
	sort.Ints(result)

	fmt.Println(result[0])
}


Measured memory_bytes: 512
from collections import defaultdict
from heapq import heappop, heappush


class Graph(object):
    """
    隣接リストによる有向グラフ
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    """
    ダイクストラ法（二分ヒープ）による最短経路探索
    計算量: O((E+V)logV)
    """

    def __init__(self, graph, start,N):
        self.g = graph.graph
        self.N = N
        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        # 最短経路での1つ前のノード
        self.prev = defaultdict(lambda: None)

        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            # 優先度（距離）が最小であるキューを取り出す
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):
        """
        startノードからgoalノードまでの最短距離
        """
        return self.dist[goal]

    def shortest_path(self, goal):
        """
        startノードからgoalノードまでの最短経路
        """
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]
    
    def solve(self):
        res = []
        for i in range(1, self.N):
            res.append(self.prev[i]+1)
        return res

n,m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
G = Graph()
for a,b in ab:
    G.add_edge(a-1,b-1)
    G.add_edge(b-1,a-1)
d = Dijkstra(G,0,n)
ans = d.solve()
print("Yes")
for i in ans:
    print(i)

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

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

  vector<pair<long long int, int> > ab(n);

  for(int i = 0; i < n; i++){
    cin >> ab[i].first >> ab[i].second;
  }

  sort(ab.begin(), ab.end());

  long long int price = 0;

  for(int i = 0; i < n; i++){
    if(m > ab[i].second){
      price += ab[i].first * ab[i].second;
      m -= ab[i].second;
    }

    else{
      for(; m > 0; m--){
        price += ab[i].first;
      }

      break;

    }
  }

  cout << price << endl;

  return 0;

}


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

int main() {
    int n;
    cin >> n;
    ll sum = 0;
    map<int, int> mp;
    rep(i,n) {
      int a;
      cin >> a;
      sum += a;
      mp[a]++;
    }
    int q;
    cin >> q;
    rep(i,q) {
      int b, c;
      cin >> b >> c;
      sum += (c-b)*mp[b];
      mp[c] += mp[b];
      mp[b] = 0;
      cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 7944
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    ll n,ans=0,d[20001];
    cin>>n;
    rep(i,n) cin>>d[i];
    rep(i,n)for(int j=i+1;j<n;j++) ans+=d[i]*d[j];
    cout<<ans;
}

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

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

    if (a <= b) {
        for (int k = a; k <= b; k++) {
            if (k - a == b - k) {
                cout << k << endl;
                return 0;
            }
        }
    }
    else {
        for (int k = b; k <= a; k++) {
            if (k - b == a - k) {
                cout << k << endl;
                return 0;
            }
        }
    }

    cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
p = gets.chomp.split(" ").map(&:to_i)
ans = 0
for i in 1..n-2
  if ((p[i-1] < p[i]) && (p[i] < p[i+1])) || ((p[i-1] > p[i]) && (p[i] > p[i+1]))
    ans += 1
  end
end
puts ans

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI d(n);
	rep(i, n) cin >>d[i];
	ll ans = 0;
	rep(i, n) rep2(j,i+1, n) ans += d[i] * d[j];
	cout << ans <<"\n";
	return 0;
	
}


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

#define SIZE 200000
#define INFTY 1200000000
long long cnt = 0;  // number of inversion.

int upperbound(int x, int* R, int N)
{
    // R[0], R[1], ... , R[N].
    if(x < R[0]) return 0;
   
	int left, right, mid;
    left = 0;
    right = N;

    while(right - left > 1){
        mid = (left + right) / 2;
        if(R[mid] < x){
            left = mid;
        }else{
             right = mid;
        }
    };
    return right;
}

void Merge(int* A, int left, int mid, int right)
{
    int R[SIZE], L[SIZE];
    int i, j, k, n1, n2;
    n1 = mid - left;
    n2 = right - mid;
    for(i = 0; i < n1; i++) L[i] = A[i + left];
    for(j = 0; j < n2; j++) R[j] = A[j + mid];

    L[n1] = INFTY;
    R[n2] = INFTY;
    i = j = 0;

    // calculate inversion number.
    for(k = 0; k < n1; k++){
        cnt = cnt + upperbound(L[k], R, n2);
    }

    // Sorting.
    for(k = left; k < right; k++){

        if(L[i] <= R[j]){ A[k] = L[i]; i++; }

        else{ A[k] = R[j]; j++; }
    }
}

void MergeSort(int* A, int left, int right)
{
    int mid;
    if(left + 1 < right){
        mid = (left + right) / 2;
        MergeSort(A, left, mid);
        MergeSort(A, mid, right);
        Merge(A, left, mid, right);
    }
    return;
}

int main()
{
    int i, n, A[SIZE];
    cin >> n;
    for(i = 0; i < n; i++) cin >> A[i];

    MergeSort(A, 0, n);
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 2728
#include<bits/stdc++.h>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
#define pb push_back
#define IT iterator
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20,mod=998244353,inf=2e9;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

//math
ll mult(ll a,ll b,ll p) {
	a=(a%p+p)%p; b=(b%p+p)%p;
	ll c=(ld)a*b/p;
	return a*b-c*p;
}
ll gcd(ll a,ll b) {return !a?b:gcd(b%a,a);}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
ll power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=c*a%mod;
		b /= 2; a=a*a%mod;
	}
	return c;
}
ll Power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=mult(c,a,mod);
		b /= 2; a=mult(a,a,mod);
	}
	return c;
}

int main() {
	int a,b,c; qr(a); qr(b); qr(c);
	int n; qr(n);
	bool ans=1;
	while(n--) {
		if(b<=a) b*=2;
		else c*=2;
	}
	if(c>b&&b>a) puts("Yes");
	else puts("No");
	return 0;
}




Measured memory_bytes: 3616
# include <iostream>
# include <stdint.h>
# include <stdio.h>
# include <math.h>
# include <algorithm>
# include <string>
using namespace std;


int main(){
	double a,b,c,s,l,h;
    cin >>a>>b>>c;
    double pi = 3.141592653589793;
    c = c*pi/180;
    s =a*b*0.5* sin(c);
    l = pow(pow(a,2) + pow(b,2) - 2*a*b*cos(c),0.5) +a +b;
    h = b*sin(c);
    printf("%.7f\n",s);
    printf("%.7f\n",l);
    printf("%.7f\n",h);

	return 0;
}



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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,T,k,q;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const ll MAXN = 200001;

ll deg[MAXN] = {0};
bool mark[MAXN] = {0};

vector<vl> C(MAXN, vl());

vector<pii> ANS;

vector<pll> E;

set<ll> S;

ll dfs(ll i){
    mark[i] = 1;
    ll ans = deg[i];
    rep(c1,0,sz(C[i])){
        ll a = C[i][c1];
        if(!mark[a]){
            ll temp = dfs(a);
            ans += temp;
            if(temp%2 == 1){
                ANS.push_back({max(a,i), min(a,i)});
            }
            else{
                ANS.push_back({min(a,i), max(a,i)});
            }
            S.insert(ll(i)*MAXN + ll(a));
            S.insert(ll(a)*MAXN + ll(i));
        }
    }
    return ans;
}

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

    //freopen("input.txt","r",stdin);
   // freopen("autput.txt","w",stdout);
    ll a,b,c,d;
    cin >> n >> m;
    rep(c1,0,m){
        cin >> a >> b;
        a--;
        b--;
        C[a].push_back(b);
        C[b].push_back(a);
        deg[min(a,b)]++;
        E.push_back({min(a,b),max(a,b)});
    }
    if(m%2 == 1){
        cout << "-1\n";
        return 0;
    }
    dfs(0);
    rep(c1,0,m){
        ll h = E[c1].first*MAXN + E[c1].second;
        if(S.find(h) == S.end()){
            ANS.push_back(E[c1]);
        }
    }
    rep(c1,0,m){
        cout << ANS[c1].first+1 << " " << ANS[c1].second+1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 29680
import sys
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7

# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]

N, X = [int(x) for x in input().split()]
L = [int(x) for x in input().split()]

cnt = 0
d = 0
for i in range(N):
    if d <= X:
        cnt += 1
    d = d + L[i]

if d <= X:
    cnt += 1

print(cnt)


Measured memory_bytes: 3564
#include <bits/stdc++.h>
 
using namespace std;
 
 
 
//c++ templte for help...........................................................
 
#define deb(x) cout<<#x<<" "<<x<<endl;/* for debuging  printing variable with name*/
#define debb(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;										
#define debbb(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;			
 
typedef long long ll;
	
 
//for loop
//#define fo(i,n) for(int i=0;i<(ll)n;i++)
//#define Fo(i,k,n) for(int i=k;i<n;i++)
 
 
//to print vector element 
//template<typename T>
//void printV(T vec){
	//fo(i,vec.size()) cout<<vec[i]<<" "<<flush;
	//cout<<endl;
	//}
	
 
//#define modulo 998244353
//const int INF=1e9+5;
 
 
 
 
//c++ template for help........................................................

int main() {
	//stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	cout<<setprecision(16);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	
	 // TESTCASE KO DEKH KA BHAUT SARA CONDITION GENERATE MAT KRO 
	 // PAPER PD CONFIRM HO JAO THORA JADA TIME HI KYU NA LGA
	 // greedy ma jadatr exceptional case check kr ke dekh lo
	 
	 // WHILE DOING THE QUESTION OF DYNAMIC PROGRAMMING GREEDY KA TRAH SOCHNA BAND KRO
	 // DP M DATA KA BHI USE KRNA PDTA HA BE BHULO MT 
	 // DP BHI WO LEETCODE WALE MATRIX KA QUESTION KI TARAH HA
	 // CONSTRAIN WILL BE THE DIMENSION OF DP
	 // DP MA STATE PTA KRO AUR PHIR FUNCTION GENERATE KRO
	 // OBJECT KO CHOOSE KIA YA NAE KIA AGAR KIA TO KYA HOGA AUR NAE KIA TO KYA HOGA
	 // KYA KYA CHEJ IMPORTANT HA WO STATE BN JYAGA AUR HUM LOG STATE KO CHANGE KR SKTA HA JYSA KNPSACK 2 WALE PROBLEM MA KIA THA
	 
	 
	 ll n,m;
	 cin>>n>>m;
	 
	 vector<ll> vec(n);
	 ll sum=0;
	 for(ll i=0;i<n;i++){
		cin>>vec[i];
		sum+=vec[i];
	 }
	 
	 
	
	double g=(double)sum/(4*(double)m);
	ll count=0;
	for(ll x: vec){
		if(!(x<g)) count++;
	}
		
	
	if(count>=m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	

	 

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


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

    int top = n[0] - '0';
    bool complete = true;

    for (int i = 1; i < n.size(); i++) {
        if (n[i] != '9') {
            complete = false;
            break;
        }
    }
    
    if (!complete) {
        cout << (top - 1) + 9 * (n.size() - 1) << endl; 
    }
    else {
        cout << top + 9 * (n.size() - 1) << endl;
    }

    
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int N,p;
    cin>>N;
    int flag=0;

    for(int i=1;i<N;i++)
    {
        cin>>p;
        if(p!=i)
            flag++;
    }
    if(flag<=2)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int a[3 * MAXN];
int n;
struct bit
{
    int sz;
    bit()
    {
        sz = 0;
    }
    bit(int _sz)
    {
        sz = _sz;
    }
    long long v[3 * MAXN];
    void add(int pos, int val)
    {
        while(pos <= sz)
        {
            v[pos] += val;
            pos += pos & -pos;
        }
    }
    long long get(int pos)
    {
        long long ret = 0;
        while(pos)
        {
            ret += v[pos];
            pos -= pos & -pos;
        }
        return ret;
    }
};
struct magic
{
    bit val, ind;
    int sz;
    magic(int _sz)
    {
        sz = _sz;
        val = *new bit(sz);
        ind = *new bit(sz);
    }
    void add(int pos, int x)
    {
        //cout << "DODAJEM " << x << " " << pos << endl;
        val.add(pos, x);
        ind.add(pos, 1);
    }
    void del(int x, int pos)
    {
        //cout << "BRISEM " << x << " " << pos << endl;
         val.add(pos, -x);
         ind.add(pos, -1);
    }
    long long get(int k)
    {
        //cout << "UZIMAM " << k << endl;
        if(k == 0) return 0;
        int lo = 1;
        int hi = sz;
        while(lo <= hi)
        {
            int mid = (lo + hi)/2;
            int gmid = ind.get(mid);
            if(gmid == k)
                return val.get(mid);
            else if(gmid < k) lo = mid + 1;
            else hi = mid - 1;
        }
        //cout << " VRACAM " << val.get(ans) << endl;
    }
};
const long long INF = 999999999999999999ll;
long long b_left[3 * MAXN];
long long b_right[3 * MAXN];
int a_scaled[3 * MAXN];
int main()
{
    long long best = -INF;
    scanf("%d", &n);
    vector<pair<int, int> > a_values;
    for(int i = 1; i <= 3 * n; i++)
    {
        scanf("%d", &a[i]);
        a_values.push_back({a[i], i});
    }
    sort(a_values.begin(), a_values.end());
    for(int i = 0; i < 3 * n; i ++)
    {
        a_scaled[a_values[i].second] = i + 1;
    }
    magic my_magic_left = *new magic(3 * n), my_magic_right = *new magic(3 * n);
    long long sum_left = 0;
    for(int i = 1; i < n; i++)
    {
        sum_left += a[i];
        my_magic_left.add(a_scaled[i], a[i]);
    }
    for(int i = n; i < 2 * n + 1; i++)
    {
        sum_left += a[i];
        my_magic_left.add(a_scaled[i], a[i]);
        //printf("%d %lld %lld\n", i, sum_left, my_magic_left.get(i - n));
        b_left[i] = sum_left - my_magic_left.get(i - n);
    }
    for(int i = 3 * n; i > 2 * n + 1; i--)
    {
        my_magic_right.add(a_scaled[i], a[i]);
    }
    for(int i = 2 * n + 1; i > n; i--)
    {
        my_magic_right.add(a_scaled[i], a[i]);
        //printf("%d %lld\n", i, my_magic_right.get(n));
        b_right[i] = my_magic_right.get(n);
    }

    for(int i = n; i <= 2 * n; i++)
    {
        best = max(best, b_left[i] - b_right[i + 1]);
        //printf("%lld %lld\n", b_left[i], b_right[i + 1]);
    }
    cout << best << endl;
    return 0;
}


Measured memory_bytes: 29292
#include <bits//stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
    int n;cin >> n; vector<int> p(n+1), v(n+1); rep(i, n) cin >> p[i];
    rep(i, n) v[p[i]] = 1 + v[p[i] - 1];
    cout << n - *max_element(v.begin(),v.end()) << endl;
}

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

using namespace std;

int main()
{
    #ifndef ONLINE_JUDGE
        // freopen("input.txt", "r", stdin);
    #endif // ONLINE_JUDGE

    ios_base::sync_with_stdio(false); cin.tie(0);

    int n;
    cin >> n;
    int a;
    for(int i=0; i<n; i++)
    {
        cin >> a;
        if(a%2 == 0 && a%3 != 0 && a%5 != 0)
        {
            cout << "DENIED\n";
            return 0;
        }
    }
    cout << "APPROVED\n";

    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N = int(readline())
    if N%2 != 0:
        print(0)
        return
    k = 1
    cnt = 0
    while 1:
        p = pow(5, k)
        tmp = N//p
        if tmp == 0:
            break
        cnt += tmp//2
        k += 1
    print(cnt) 
if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N = int(input())
A = sorted(list(map(int,input().split())))

if N%2==0:
  B = [2*(n//2)+1 for n in range(N)]
else:
  B = [2*(n//2) for n in range(1,N+1)]

if A==B:
  print(pow(2,N//2,10**9+7))
else:
  print(0)

Measured memory_bytes: 14008
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
inline int read(){
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9'){ x = x * 10 + (ch ^ 48); ch = getchar(); }
	return x * f;
}
struct edge{
	int v, nxt;
}e[200010];
int head[200010], cnt, n, m, w[100010], x, y, ans;
inline void add(int u, int v){
	e[++cnt].v = v;
	e[cnt].nxt = head[u];
	head[u] = cnt;
}
int main(){
	n = read(); m = read();
	for(int i = 1; i <= n; ++i) w[i] = read();
	for(int i = 1; i <= m; ++i) x = read(), y = read(), add(x, y), add(y, x); 
	for(int u = 1; u <= n; ++u){
		bool flag = 1;
		for(int i = head[u]; i; i = e[i].nxt){
			int v = e[i].v; flag &= w[u] > w[v]; 
		}
		if(flag) ans++;
	}
	return printf("%d\n", ans) & 0;
}

Measured memory_bytes: 6060
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  lint x, a = 100, y = 0; cin >> x;
  while(a < x){
    a += a / 100;
    ++y;
  }
  cout << y << "\n";
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>

int main() {
  int af, h;
  std::cin >> af >> h;
  int c = 0;
  for(int i = 0; i < af; i++) {
    int j;
    std::cin >> j;
    if(j >= h) {
      ++c;
    }
  }
  
  std::cout << c;
  
  return 0;
}

Measured memory_bytes: 256