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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010, M = 35;

int n, m;
struct Pro
{
	int s, t, c;
	bool operator<(const Pro &e)const
	{
		if (t != e.t) return t < e.t;
		else return s < e.s;
	}
}a[N];
int cnt;
PII rec[M];

bool cmp(PII a, PII b)
{
	return a.F > b.F;
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i ++ )
	{
		int s, t, c;
		scanf("%d%d%d", &s, &t, &c);
		a[i] = {s, t, c};
	}
	sort(a, a + n);
	
	for (int i = 0; i < n; i ++ )
	{
		bool flag = false;
		int s = a[i].s, t = a[i].t, c = a[i].c;
		sort(rec, rec + cnt, cmp);
		
		for (int j = 0; j < cnt; j ++ )
			if (rec[j].F == s && rec[j].S == c)
			{
				rec[j].F = t;
				flag = true;
				break;
			}
			else if (rec[j].F + 1 <= s)
			{
				rec[j] = {t, c};
				flag = true;
				break;
			}
			
		if (!flag) rec[cnt ++ ] = {t, c};
	}
	
	printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>

using namespace std;
int num[51][26];
int main(){
  int n;
  cin>>n;
  //string s[51];
  
  for(int i = 0;i<n;i++){
    string s;
    cin>>s;
    for(int j = 0;j<s.length();j++){
      num[i][(int)s[j]-'a']++;
      //cout<<"a"<<endl;
    }
  }

 
  
  for(int i = 0;i<26;i++){
    int tmp = 1;
    bool zero = false;
    bool first = true;
    for(int j = 0;j<n;j++){
      if(num[j][i] != 0 && !first)
	tmp = min(tmp,num[j][i]);
      else if(first){
	tmp = num[j][i];
	first = false;
	
      }else
	zero = true;
    }
    //cout<<(char)('a' + i)<<"\t"<<tmp<<endl;
    if(!zero)
      for(int k = 0;k<tmp;k++)
	cout<<(char)('a' + i);
  }
  

  return 0;
}


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = SS()

    if N == N[::-1]:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()


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

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
 
int main(){
   int a; cin >> a;
   int a2 = a*a;
   int a3 = a*a*a;
   cout << a+a2+a3 <<endl;
}

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

int main(){
  string A;
  cin >> A;
  if(A.at(0)=='7'||A.at(1)=='7'||A.at(2)=='7'){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

long long gcd(long long a, long long b)
{
    return b ? gcd(b, a % b) : a;
}
int main()
{
    int n;
    int a[110000];
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int ans = a[0];
    for (int i = 1; i < n; i++)
    {
        ans = gcd(ans, a[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
from functools import lru_cache
import sys
sys.setrecursionlimit(10**6)

def main(N, M, a_list):
    div = 10**9 + 7
    a_set = set(a_list)
    @lru_cache(maxsize=None)
    def fib(n):
        if n in a_set:
            return 0
        else:
            if n == -1:
                return 0
            elif n == 0 or n == 1:
                return 1
            else:
                return fib(n-2) % div + fib(n-1)
    
    
    print(fib(N) % div )


if __name__ == "__main__":
    N, M = [int(x) for x in input().split()]
    a_list = []
    for _ in range(M):
        a_list.append(int(input()))

    main(N, M, a_list)


Measured memory_bytes: 155480
#include<iostream>
#include<cstdio>
#include<string>

using namespace std;

int main()
{
	string num;
	int k;
	while(cin>>num){
		k=9;
		while(k){
			for(int i=0;i<k;i++){
				num[i]=((int)num[i]+(int)num[i+1]-96)%10+48;
			}
			k--;
		}
		cout<<num[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1172
n,y = map(int,input().split())
y = y//1000
for a in range(min((y-n)//9+1,n+1)):
    #print(a)
    if (y-n-9*a)%4==0:
        b = (y-n-9*a)//4
        if a+b <= n:
            print(a,b,n-a-b)
            break
else:
    print(-1,-1,-1)

Measured memory_bytes: 3064
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

a,b,c,d=nii()

i=0
while a>0 and c>0:
  if i%2==0:
    c-=b
  else:
    a-=d
  i+=1

print('Yes' if a>0 else 'No')

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

int main() {
  int A, B, C, D, L , R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  
  if (L > R){
    cout << "Left" << endl;
  }
  else if (L<R){
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORALL(i, m) for( auto i = m.begin(); i != m.end() ; ++i )
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define TM_T template <class T>
#define MOD 1000000007
using namespace std;
typedef long long ll;
TM_T T inp(){T it;cin >> it;return it;}

ll N,K;
vector<ll> li;

int input(){
  cin >> N >> K;
  REP(i,N) li.push_back( inp<ll>() );
}

int main()
{
  input();
  
  ll da1=0;
  ll da0=0;
  ll df0=0; //full
  ll df1=0;
  
  ll k =K;
  ll keta = 0;
  REP(i,50){ if (k>0) k>>=1; else {keta=i; break;} }
  //cout << keta << "," << K ;
  
  REPR(i,45){
    ll x0 = 0,x1 = 0;
    REP(j,N) x0 += ((1l<<i)&li[j]);
    REP(j,N) x1 += ((1l<<i)&li[j])^(1l<<i);
    //cout << x0 << "," << x1 << endl;

    ll da0_,da1_=0,df1_,df0_;
    if ( ((K>>i)&1l)==0 ){
      da0_ = x0 + max(da0,da1);
      if (i<keta) da1_ = x1 + max(da0,da1);
      df1_ = 0;
      df0_ = x0 + max(df0,df1);
    }else{
      da0_ = x0 + max(da0,max(da1,max(df0,df1)));
      if (i<keta-1) da1_ = x1 + max(da0,da1);
      df1_ = x1 + max(df0,df1);
      df0_ = 0;
    }
    da0=da0_;da1=da1_;df0=df0_;df1=df1_;
    //cout << da0 << ","<< da1 << ","<< df0 << ","<< df1 << endl;
  }
  cout << max(da0,max(da1,max(df0,df1))) << endl;
  
 
}

Measured memory_bytes: 1400
s = input()
first = int(s[:2])
second =int(s[2:])

if (first > 0 and first < 13) and (second > 0 and second < 13):
    print("AMBIGUOUS")
elif (first > 0 and first < 13): 
    print("MMYY")
elif (second > 0 and second < 13):
    print('YYMM')
else:
    print('NA')



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

int main(void){
    ll N,K;
    cin >> N >> K;
    
    //vector<ll> A(N);
    int counter =0; 
    for (ll i = 0; i < N; i++) {
        int h;
    	cin >> h;
    	if (h>=K){
    	    counter++ ;
    	}		
  	}
    cout<< counter << endl;
}


Measured memory_bytes: 256
/*;

THE BEST IS YET TO COME
*/
#include <bits/stdc++.h>
using namespace std;
#define r(i, s, l) for (int i = s; i < l; i++)
#define rr(i,s,l) for(int i=s;i>=l;i--)
#define mod 1000000007
#define int long long
#define INT_BITS 32
#define ld long double
#define pp pair<int,int>
#define ss second
#define ff first
#define INF 1e18
#define N 2000005
#define all(a) a.begin(), a.end()
#define pb push_back
#define endl "\n"
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

signed main()
{


    int a,b,c,d;
    cin>>a>>b>>c>>d;

    int lcm = (c*d)/(__gcd(c,d));
    a--;
    int notb = b - (b/c) - (b/d) + (b/lcm);
    int nota = a - (a/c) - (a/d) + (a/lcm);

    cout<<notb - nota;




	return 0;
}



Measured memory_bytes: 256
N, Y = map(int, input().split())
a, b, c = -1, -1, -1
n, y = 0, 0

for i in range(min(N, Y//10000)+1):
  n = N-i
  y = Y-i*10000
  if 1000*n<=y<=5000*n and (5000*n-y)%4000 == 0:
    a, b, c = i, n-(5000*n-y)//4000, (5000*n-y)//4000
    break
  else:
    pass
print(a, b, c)

Measured memory_bytes: 9136
#include <iostream>
#include <fstream>
using namespace std;
string a;
long long ap[30];
long long ans,N;
int n,i,j,r,c;
int main()
{
    //freopen("data.in","r",stdin);
    cin>>a;n=a.size();N=a.size();
    for(i=0;i<n;i++)
        ap[a[i]-'a']++;
    ans=N*(N+1)/2+1;
    for(i=0;i<26;i++)
        ans-=1LL*ap[i]*(ap[i]+1)/2;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

ll Pot(ll p, ll w)
{
    if (w == 0)
        return 1;
    if (w % 2 == 0)
    {
        ll pol = Pot(p, w / 2);
        return pol * pol % MOD;
    }
    return Pot(p, w - 1) * p % MOD;
}

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> wyk(1000000, 0);
    for (int i = 0; i < n; ++i)
    {
        ll x;
        cin >> x;
        a[i] = x;
        for (ll d = 2; d * d <= a[i]; ++d)
        {
            ll il = 0;
            while (x % d == 0)
            {
                x /= d;
                ++il;
            }
            wyk[d] = max(wyk[d], il);
        }
        if (x != 1)
            wyk[x] = max(wyk[x], (ll) 1);
    }
    ll nww = 1;
    for (ll i = 1; i < 1000000; ++i)
        nww = nww * Pot(i, wyk[i]) % MOD;
    ll odp = 0;
    for (int i = 0; i < n; ++i)
        odp = (odp + nww * Pot(a[i], MOD - 2)) % MOD;
    cout << odp;
    return 0;
}


Measured memory_bytes: 8192
import Data.Maybe
import Data.List

main :: IO ()
main = do
  input <- getContents
  putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve s = show   $a + b + c - max a (max b c)
  where [a, b, c] = fmap read (words s) :: [Int]

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

Measured memory_bytes: 508
#include<iostream>
int main(void){
	int a, b, c;
	std::cin >> a >> b >> c;
	if (a < b&& b< c){
		std::cout << "Yes" << std::endl;
	}
	else{
		std::cout << "No" << std::endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>

int main(){
  int N; cin>>N;
  ll x[N],y[N];
  REP(i,N){
    cin >> x[i];
    y[i] = x[i];
  }
  sort(y,y+N);
  ll mid1 = y[N/2-1];
  ll mid2 = y[N/2];
  if(mid1==mid2){
    REP(i,N){
      cout << mid1 << "\n";
    }
  }else{
    REP(i,N){
      if(x[i]<mid2){
        cout << mid2 << "\n";
      }else{
        cout << mid1 << "\n";
      }
    }
  }
}

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

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

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

    int n, k, c;
    string s;
    cin>>n>>k>>c>>s;

    vector<int> ok;
    rep(i, n) if (s[i] == 'o') ok.push_back(i);
    int d = ok[0];
    int cnt = 0;
    vector<int> critical;
    while (cnt < k) {
        critical.push_back(d);
        d = *lower_bound(ok.begin(), ok.end(), d + c + 1);
        cnt++;
    }
    vector<int> ans;
    if (critical[k - 1] != ok[ok.size() - 1]) critical[k - 1] = ok[ok.size() - 1];
    else ans.push_back(critical[k - 1]);
    for (int i = k - 2; i >= 0; --i) {
        int n = *(lower_bound(ok.begin(), ok.end(), critical[i + 1] - c) - 1);
        if (n == critical[i]) ans.push_back(n);
        critical[i] = n;
    }
    reverse(ans.begin(), ans.end());
    rep(i, ans.size()) cout<<ans[i] + 1<<endl;
}

Measured memory_bytes: 4236
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	ll n, a,b;
	cin >> n >> a >> b;
	ll sum =0;
	if (a == 0) {
		cout << 0 << endl;
		return 0;
	}

	sum = ((n / (a + b)) * a);
	if (n % (a + b) >= a) {
		sum = sum +a;
	} else {
		sum = sum + (n % (a + b));
	}
	cout << sum << endl;
	return 0;

}


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

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int n;
int x[111],y[111],h[111];
int a,b,c;
int ansx=0,ansy=0,ansh=0;

signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>n;
    rep(i,0,n)cin>>x[i]>>y[i]>>h[i];
    rep(i,0,101){
        rep(j,0,101){
            int ok=true;
            int H=0;
            rep(k,0,n){
                if(h[k]!=0)H=h[k]+abs(x[k]-i)+abs(y[k]-j);
            }
            rep(k,0,n){
                if(max(H-abs(x[k]-i)-abs(y[k]-j),0LL)!=h[k])ok=false;
            }
            if(ok)cout<<i<<" "<<j<<" "<<H<<endl;
        }
    }
        
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = [0] * n
double_x = 0

for i, t in enumerate(a):
    double_x += (1 + -2 * (i % 2)) * t

ans[0] = double_x

for i in range(1, n):
    ans[i] = 2 * (a[i-1] - ans[i-1] // 2)

print(*ans)

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

using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int main(){
 string s;int sum=0;
 cin>>s;
 for(int i=0;i<s.length();i++){
     sum+=s[i]-'0';
 }
if(sum%9==0)
    cout<<"Yes\n";
else
    cout<<"No\n";
return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <climits>
using namespace std;
int n;
int arr[100005];
int dp[100005];

int fun(int ind)
{
    if (ind == n - 1)
    {
        return 0;
    }

    if (dp[ind] != -1)
        return dp[ind];
    int left = abs(arr[ind] - arr[ind + 1]) + fun(ind + 1);
    int right = INT_MAX;
    if (ind + 2 < n)
        right = abs(arr[ind] - arr[ind + 2]) + fun(ind + 2);

    return dp[ind] = min(left, right);
}

int main()
{

    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    memset(dp, -1, sizeof(dp));
    cout << fun(0) << "\n";
}

Measured memory_bytes: 4096
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define MAX 50
typedef long long ll;

bool visit[MAX];
bool adj[MAX][MAX];
int a[MAX]={},b[MAX]={};
int n,m;

void dfs(int v){
	visit[v] = 1;

	rep(i,n){
	if (!adj[v][i]) continue;
	if (visit[i]) continue;
	dfs(i);
	}
	
}

int main(){
	cin >> n>>m;
	int ans = 0;
	rep(i,m){
	cin >> a[i] >> b[i];
	a[i]--; b[i]--;
	adj[a[i]][b[i]] = adj[b[i]][a[i]] = 1;
	}

	rep(i,m){
	//各辺について削除してみて、連結かどうか調べる
	adj[a[i]][b[i]] = adj[b[i]][a[i]] = 0;

	//visitをclearする
	rep(j,n){
	visit[j] = 0;
	}

	dfs(a[i]);
/*
	rep(k,n){
	cout << visit[k] << " ";
	}

	cout << endl;
*/
	if (!visit[b[i]]) {ans++;}
	adj[a[i]][b[i]] = adj[b[i]][a[i]] = 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int IsPrime(int x);
int main(void){
    int i,n,count;
    
    for(;;){
        scanf("%d",&n);
        if(n==0) break;
        count=0;
        for(i=n+1;i<=2*n;i++){
            if(IsPrime(i)) count++;
        }
        printf("%d\n",count);
    }
    
}

int IsPrime(int x){
    int i;
    for(i=2;i*i<=x;i++){
        if(x%i==0) return 0;
    }
    return 1;
}


Measured memory_bytes: 2040
#include <stdio.h>

#define MAX 246912

int main(){
  int n, n2, flag[MAX], i, j, count;

  while(1){
    scanf("%d", &n);
    if(n == 0) break;

    n2 = 2*n;
    for(i = 0; i < n2 + 1; i++){
      flag[i] = 0;
    }
    count = 0;
    flag[0] -= 1;
    flag[1] -= 1;
 
    for(i = 2; i < n2 + 1; i++){
      if(flag[i] < 0) continue;
      if(n2 < i*i) break;
      for(j = i*i; j < n2 + 1; j += i){
        flag[j] -= 1;
      }

    }

    for(i = 0; i < n2 + 1; i++){
      if( (0 == flag[i])&&(n < i) ){
        count++;
      }
    }

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

  return 0;
}



Measured memory_bytes: 2724
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
  int n, k;
  cin >> n >> k;
  
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int h;
    cin >> h;
    if (h >= k) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ctoi(x) x-'0'
#define pshb(a) cin >> x;a.push_back(x)
#define fr(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false);
using namespace std;
bool a[3] ;
int main()
{

    ll x ;
    cin>>x ;
    a[x-1]=1 ;
    cin>>x ;
    a[x-1]=1 ;
    for (int i =0 ; i< 3 ; i++)
    {
        if (!a[i])
            return cout<<i+1 , 0 ;
    }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
// x^y≡x^(y%(p-1))mod p
// but there is a condition that x needs to be coprime to p
///assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set; */
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
#define  pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define tests() int test_cases ; cin >> test_cases ; while(test_cases--)
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define sp " "
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define debug(x) cerr << (#x) << " is " << (x) << endl;

#ifndef ONLINE_JUDGE
#define cerr if(true)cerr
#endif

template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
static_assert(D >= 1, "Vector dimension must be greater than zero!");
template<typename... Args>
	Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
	}
};
template<typename T>
struct Vec<1, T> : public vector<T> {
	Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {
	}
};

ll power(ll x, ll y,ll p)
{
    ll res = 1;     // Initialize result
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; // y = y/2
        x = (x*x) % p;  // Change x to x^2
    }
    return res;
}
int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);}

ll modinv(ll a,ll p){return power(a,p-2,p);}
vll adj[MAXN];
Vec<1,ll> dist(MAXN,-1);
void dfs(ll s,ll p){
    // debug(dist[s])
    dist[s] = 0;
    for(auto v: adj[s]){
        if (v==p)
        {
            if (adj[s].size()==1)
            {
                dist[s] = 0;
                // dist[v] = max(dist[v],0LL);
            }
            continue;
        }
        if (dist[v]==-1)
        {
            dfs(v,s);
        }
        // debug(dist[v])
        dist[s] = max(dist[s], dist[v]+1);
    }
    // debug(dist[s])
    return;
}
void solve(){
    ll n,m;
    cin>>n>>m;
    f(i,0,m){
        ll a,b;
        cin>>a>>b;
        adj[a].pb(b);
    }
    fo(i,1,n){
        dfs(i,-1);
    }
    ll mx = 0;
    fo(i,1,n){
        mx = max(mx, dist[i]);
    }
    cout<<mx<<endl;
    return ;
}
int main()

{
    IO;
    int T=1;
	// cin >> T;
	f(c,0,T){
		solve();
	}
    return 0;
}// make_pair make_tuple  tuple<int,int,int> continue resize insert count size else true isValid second first false erase


Measured memory_bytes: 9984
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll M, K;

int main()
{
  std::cin >> M >> K;

  if( K >= (1ll<<M) ) {
    puts("-1");

    return 0;
  }

  if( M == 1 ) {
    if( K == 1 ) {
      puts("-1");

      return 0;
    }

    puts("0 0 1 1");

    return 0;
  }

  std::vector<ll> vs;

  rep( i, 1<<M ) if( i != K )
    vs.emplace_back( i );
  
  vs.emplace_back( K );

  repd( i, (1<<M) ) if( i != K )
    vs.emplace_back( i );

  vs.emplace_back( K );

  rep( i, vs.size() )
    std::cout << vs[i] << (i==vs.size()-1?'\n':' ');

  return 0;
}

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

using namespace std;
int main(){
  long n;
   cin >> n;
  
  vector<long> a(n+1),b(n+1);
  for(long i=0;i<=n;i++) cin >> a[i];
  for(long i=0;i<n;i++) cin >> b[i];
  
  b[n]=0;
  
  
  long res=0,num=0;
  for(long i=0;i<=n;i++){
   res+=min(b[i]+num,a[i]);
  num=max(long(0),b[i]-max(long(0),a[i]-num));
 
  }
  
  cout << res << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << (H-h)*(W-w) << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <map>
#include <queue>
#include <algorithm>
#define ri register int 
#define ll long long
using namespace std;
const int maxn=200005;
const int inf=0x7fffffff;
template <class T>inline void read(T &x){
	x=0;int ne=0;char c;
	while(!isdigit(c=getchar()))ne=c=='-';
	x=c-48;
	while(isdigit(c=getchar()))x=(x<<3)+(x<<1)+c-48;
	x=ne?-x:x;
	return ;
}
int n;
ll a[maxn];
ll sum=0;
inline ll solve(int k){
	ll cnt=0;
	for(ri i=1;i<=n;i++)cnt+=abs(a[i]-k);
	return cnt;
}
int main(){
    read(n);
    for(ri i=1;i<=n;i++){
	   read(a[i]);
	   a[i]=a[i]-i;
    }
    ll ans,lmid,rmid;
    ll l=-1e9-5,r=1e9+5;
    while(l<r-1){
	    lmid=(l+r)>>1,rmid=(lmid+r)>>1;    
    	if(solve(lmid)>solve(rmid))l=lmid;
    	else r=rmid;
    }
    if(solve(l)<solve(r))ans=l;
    else ans=r;
	printf("%lld\n",solve(ans));
	return 0;
}

Measured memory_bytes: 1792
//Say hi to nerdy_geek2799
//work untill your role model does not become your opponent

#include<bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define MOD 1000000007
#define mp make_pair
#define pll pair<ll,ll>
#define pb push_back
#define all(v) (v.begin(),v.end())
#define Ryo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
#define ceil(a,b) a/b+((a%b ==0 )?0:1)
using namespace std;
int main()
{
    Ryo;
    
    ll s,w;
    cin>>s>>w;
    if(w>=s)
    {
        cout<<"unsafe";
    }
    else
        cout<<"safe";
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
vector<char> S(3);
vector<char> T(3);
int main() {
    int ans = 0;
    for(int i = 0; i < 3; ++i) {
        cin >> S.at(i);
    }
    for(int i = 0; i < 3; ++i) {
        cin >> T.at(i);
    }
    for(int i = 0; i < 3; ++i) {
        if(S.at(i) == T.at(i)) ans++;
    }
    cout << ans << endl;
}

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


using namespace std;

typedef pair<int,int> P;

const int INF=INT_MAX;
const int N=30;


char tiles[N][N];
int W,H;
int ans=0;


void solve(int i, int j){
  
  tiles[i][j]='x';
  ans++;

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

  for(int k=0;k<4;k++){
    int ni=i+di[k],nj=j+dj[k];
    if(0<=ni&&ni<H && 0<=nj&&nj<W)
      if(tiles[ni][nj]=='.'){
	solve(ni,nj);
      }
  }   
  
}



int main(){

  P start;

  
  while(1){

    cin>>W>>H;
    start = P(INF,INF);

    if(W==0 && H==0) break;
    ans=0;
    
    for(int i=0;i<H;i++){
      cin>>tiles[i];
      if(start.first==INF){
	for(int j=0;j<W;j++)
	  if(tiles[i][j]=='@') start=P(i,j);
      }
    }
    solve(start.first,start.second);
    cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 3032
def main():
    N = int(input())
    S = list()
    pow_m2, mod = 1, 2
    S.append(N % mod)
    N -= (N % mod) * pow_m2
    while N != 0:
        pow_m2 *= (- 2)
        mod *= 2
        s = 1 if N % mod > 0 else 0
        S.append(s)
        N -= s * pow_m2
    S.reverse()
    print(''.join(map(str, S)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
# encoding:utf-8

def main():
	n = int(input())
	s = list(input())
	d = {'W':0, 'E':1}
	nums = [d[x] for x in s]

	left = 0
	right = sum(nums[1:])
	min_cost = right

	for i in range(1, n):	
		left = left + (1 - nums[i-1])
		right = right - nums[i]
		min_cost = min(min_cost, left + right)

	print(min_cost)



if __name__ == '__main__':
	main()

Measured memory_bytes: 10496
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;
typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll

ll mycount[110000];


signed main(){
    int N;
    cin>>N;
    P a[110000];
    for(int i=0;i<N;i++){
        ll t;
        cin>>t;
        a[i].first=t;
        a[i].second=i+1;
    } 
    sort(a,a+N,greater<P>());
    int ans=N+1;
    ll now,count=0;
    a[N].first=0;
    for(int i=0;i<N;i++){
        now=a[i].first;
        while(a[i].first==now){
            ans=min(ans,a[i].second);
            i++;
            count++;
        }
        mycount[ans]+=count*(now-a[i].first);
        i--;
    }
    for(int i=1;i<=N;i++) cout<<mycount[i]<<endl;
}


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

int main() {
	string S,T ;
	cin >> S >> T;
	bool state=true;
	if (S.size()+1==T.size()) {
		for (int i=0;i<S.size();i++) {
			if (S.at(i)!=T.at(i)) {
				state=false;
				break;
			}
		}
	}
	if (state) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

  ll n;
  cin >> n;
  ll a, b;
  cin >> a >> b;
  vector<ll> p(n), cnt(3);
  REP(i, n) {
    cin >> p[i];
    if(p[i] <= a) cnt[0]++;
    else if(p[i] <= b) cnt[1]++;
    else cnt[2]++;
  }

  cout << min({cnt[0], cnt[1], cnt[2]}) << endl;

  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
n=int(input())
a=[int(input()) for i in range(n)]
b=defaultdict(list)
s=1
c=0
while True:
  c+=1
  b[s].append(a[s-1])
  if b[s]==[2]:print(c);exit()
  if len(b[s])>1:print(-1);exit()
  s=a[s-1]

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; ll m;
	cin>>n>>m;
	vector<ll> a(n);
	set<int> st;
	for(auto &x : a){
		cin>>x;
		int cnt = 0;
		while(x%2 == 0){
			x >>= 1;
			cnt++;
		}
		st.insert(cnt);
	}
	if(st.size() > 1){
		cout<<0<<endl;
		exit(0);
	}
	int pw = (*st.begin()); m /= (1<<(pw - 1));
	ll tmp = 1;
	for(auto x : a){
		tmp = tmp*(x/__gcd(x, tmp));
		if(tmp > m)break;
	}
	ll x = (m/tmp);
	x = (x + 1)/2;
	cout<<x<<'\n';

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>




double dis(int x1,int y1,int x2,int y2){
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int fact(int n){return n==0?1:n*fact(n-1);}
using namespace std;
int main(){
    int n;
    double ans=0.0;
    cin>>n;
    int x[n],y[n];
    vector<int>v(n);
    for(int i=0;i<n;i++)v[i]=i;
    for(int i=0;i<n;i++)cin>>x[i]>>y[i];
    do{
        //for(int i=0;i<n;i++)cout<<v[i];
        //cout<<endl;
        for(int i=0;i<n-1;i++){
            //cout<<x[i]<<y[i]<<x[i+1]<<y[i+1]<<endl;
            ans+=dis(x[v[i]],y[v[i]],x[v[i+1]],y[v[i+1]]);
        }
        //cout<<ans<<endl;
    }while(next_permutation(v.begin(),v.end()));

    cout<<setprecision(10)<<ans/fact(n)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll MOD=1e9+7 ;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const int n_max = 5010;
int dp[n_max][n_max];
string s;

int dfs(int x, int y)
{
    if (x == y) return -1;
    if (s[x] == s[y])
    {
        if (dp[x+1][y+1] != -1)
        {
            // dp[x][y] = dp[x+1][y+1]+1;
            dp[x][y] = min(y-x, dp[x+1][y+1]+1);
        }
        else
        {
            dp[x][y] = 1;
        }
        return dp[x][y];
    }
    else
    {
        return -1;
    }
    

    // if (dp[x+1][y+1] != -1)
    // {
    //     dp[x][y] = dp[x+1][y+1]+1;
    //     return dp[x][y];
    // }
    // else
    // {
    //     if (s[x] == s[y])
    //     {
    //         dp[x][y] = 1;
    //         return  dp[x][y];
    //     }
    // }
    
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    rep(i,n_max) rep(j, n_max) dp[i][j] = -1;
    int n;
    cin >> n >> s;

    // build();
    int ans = 0;
    for (int i=n-2;i>=0;i--)
    {
        for (int j=n-1;j>i;j--)
        {
            ans = max(ans, dfs(i,j));
            // cout << i << " " << j << " " << dp[i][j] << endl;
        }
    }
    // rep(i,n) rep(j,n)
    // {
    //     ans = max(ans, dp[i][j]);
    // }
    cout << ans << endl;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int N,K;
  cin>>N>>K;
  vector<double>p(N);
  for(int i=0;i<N;i++)cin>>p[i];
  for(int i=0;i<N;i++)p[i]=(1.*p[i]+1.0)/2;
  vector<double>sum(N+1);
  sum[0]=0;
  for(int i=1;i<=N;i++)sum[i]=sum[i-1]+p[i-1];
  double ans=0;
  for(int i=0;i+K<=N;i++)ans=max(sum[i+K]-sum[i],ans);
  cout<<fixed<<setprecision(20)<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3456
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    S = input()
    K = int(input())
    if len(S) > K and S[K-1] == '1':
        print('1')
        exit()
    for i in list(S):
        if i != '1':
            print(i)
            exit()
    print('1')

if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define allr(x) (x.rbegin()),(x.rend())
#define sz(x)  ((ll)x.size())
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif


void tokenize(string str,const char delim,vector<string> & res){
	stringstream p(str);
	string token;
	while(getline(p,token,delim)){
		res.push_back(token);
	}
	return;
}
// Your workSpace ...

const int inf = 1e9;
int n;

void test_case(){
    cin>>n;
    vector<int> v(n);
    for(auto & el : v)
        cin>>el;
    vector<long> dp(n+3,inf);
    dp[0] = 0;
    for(int i = 0;i<n;++i)
        for(int j = 1;j<=2;++j)
            dp[i+j] = min(dp[i+j],dp[i] + abs(v[i] - v[i+j]));
   // debug() << owo(dp);
    cout<<dp[n-1]<<endl;
    return;
}




int main(){
	FAST_IO;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
#endif
	int tt;
	tt = 1;
	for(int i = 0;i<tt;++i)
	    test_case();
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

Measured memory_bytes: 4464
N = int(input())
A = list(map(int,input().split()))
d = [0]*(10**6)
ans = 0
for i in range(N):
    m = i+1+A[i]
    if m < 10**6:
        d[i+1+A[i]] += 1
    
for i in range(1,N+1):
    f = A[-i]+N+1-i-(2*A[-i])
    if f >= 0 and f < 10**6:
        ans += d[f]
print(ans)
    

Measured memory_bytes: 32228
#include "bits/stdc++.h"
using namespace std;
int Array[100005];
pair<int,int> Increase[100005];

int main(){
    int N , M , i;
    scanf( "%d%d" , &N , &M );

    for( i = 1 ; i <= N ; ++i )
        scanf( "%d" , Array + i );

    sort( Array + 1 , Array + N + 1 );

    for( i = 1 ; i <= M ; ++i )
        scanf( "%d%d" , &Increase[i].second , &Increase[i].first );
        
    sort( Increase + 1 , Increase + M + 1 , greater<pair<int,int> >() );
    int Cur = 1 , Count;

    for( i = 1 ; i <= M ; ++i ){
        Count = 0;

        while( Cur <= N && Count < Increase[i].second ){
            if( Array[Cur] < Increase[i].first ){
                Array[Cur] = Increase[i].first;
                ++Count;
            }
            else break;

            ++Cur;
        }

        if( ( Cur <= N && Count < Increase[i].second ) || Cur == N + 1 ) break; 
    }

    long long Ans = 0;

    for( i = 1 ; i <= N ; ++i )
        Ans = Ans + Array[i];
    
    printf( "%lld\n" , Ans );
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
#define test ll t;cin>>t;while(t--)
#define f first
#define s second
#define pb push_back
#define pop pop_back
#define int long long int
#define mod 1000000007
#define inf 1LL<<60

vector<int> tree[100001];
int dp[100001][2];

int solve(int u,bool constraint ,int pr)
{
    if(dp[u][constraint]!=-1)
        return dp[u][constraint];
        
    int ans = 0;
    int w1 = 1;
    for(int child : tree[u])
    {
        if(child!=pr)
       w1 = (w1*solve(child,0,u))%mod;
    }
   ans=(ans+w1)%mod;
   
    if(!constraint)
    {
        int w2 = 1;
          for(int child : tree[u])
         {        
                if(child!=pr)
                 w2 = (w2*solve(child,1,u))%mod;
         }
      ans=(ans + w2)%mod;
    }

    return dp[u][constraint] = ans;
}

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

	memset(dp,-1,sizeof dp);

	for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        tree[u].pb(v);
        tree[v].pb(u);
    }

    cout<<solve(1,0,-1);

	return 0;
}



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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end() å
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

#define TENNINE 1000000005
#define TENFIVE 100005

string n;

signed main()
{
    cin >> n;

    if (n[0] == '7' || n[1] == '7' || n[2] == '7')
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3676
import numpy as np

D = int(input())
c = np.array(list(map(int, input().split())))
s = np.array([list(map(int, input().split())) for _ in range(D)])


def s11(c, s, last_date, di, i, mul):
    score = s[di - 1][i]
    score += 0.05 * mul * c[i] * (di - last_date[i])
    return score


def f12(D, c, s):
    last_date = np.zeros(26)

    t = []
    for di in range(1, D + 1):
        mul = np.mean(s[di - 1]) / np.mean(c)
        score_list = []
        for i in range(26):
            score_list.append(s11(c, s, last_date, di, i, mul))

        select_index = score_list.index(max(score_list))
        t.append(select_index)
        last_date[select_index] = di

    return t


for ti in f12(D, c, s):
    print(ti + 1)

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int gcd(int x, int y){
  if(y==0)return x;
  return gcd(y,x%y);
}

int cnter(int n){
  int cnt = 0;
  while(n&&n%2==0){
    cnt++;
    n/=2;
  }
  return cnt;
}

int f(int x){
  int y = 0;
  while(x){
    y += x%10;
    x /= 10;
  }
  return y;
}

bool Ok(int x){
  string s = to_string(x);
  for(int i = 0; i < 4-i; ++i){
    if(s[i] != s[4-i])return false;
  }
  return true;
}

int main(){
  int l,r; cin >> l >> r;
  int cnt = 0;
  for(int i = l; i <= r; ++i){
    cnt += Ok(i);
  }
  cout << cnt << endl;
} 



Measured memory_bytes: 3720
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,T;
	int t[200001];
	ll sum=0;
	scan(N);scan(T);
	rep(i,N){
		scan(t[i]);
		if(i!=0){
			sum+=min(t[i]-t[i-1],T);
		}
	}
	sum+=T;
	prin(sum);
	return 0;
}


Measured memory_bytes: 1024
#ifndef LOCAL
#define NDEBUG 1
#endif
#include<bits/stdc++.h>

int main(){
	std::ios::sync_with_stdio(0);std::cin.tie(0);
	int number, leftMoveCost, rightMoveCost; std::cin>>number>>rightMoveCost>>leftMoveCost;
	std::vector<int> data(number), pos(number);
	for(int index=0;index<number;++index) {
		auto& item=data[index];
		std::cin>>item;--item; 
		pos[item]=index;
	}

	std::vector<std::vector<int64_t>> f(number+1, std::vector<int64_t>(number+1, INT64_MAX));
	f[0][0]=0;

	// f[a][b]=minimum cost to move a smallest numbers to the left, and
	// b numbers at first indices(including those that may be moved to the left)
	// to an arbitrary position to the right)
	for(int a=0;a<number;++a) {
		std::vector<int> uncoveredSuffix(number+1);
		for(int cur=0,index=number; index--;){
			uncoveredSuffix[index]=cur+=(data[index]>=a);
		}


		for(int b=0;b<=number;++b) if(f[a][b]!=INT64_MAX) {
			auto const cur=f[a][b];
			f[a+1][b]=std::min(f[a+1][b], cur+leftMoveCost);
			auto const rightMoveCount=std::max(0,uncoveredSuffix[b]-uncoveredSuffix[pos[a]]);
			auto& next2=f[a+1][std::max(b, pos[a]+1)];
			next2=std::min(next2, cur+(int64_t)rightMoveCost*rightMoveCount);
		}
	}

	std::cout<<*std::min_element(begin(f[number]),end(f[number]))<<'\n';
}


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

int main(){
  
  int a,b,c;
  cin>>a>>b>>c;
  
  if((a==b&&a!=c) || (a==c&&a!=b) || (c==b&&a!=c)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void){
    int n[4];
    
    scanf("%d%d%d%d", &n[0], &n[1], &n[2], &n[3]);
    
    for(int j=0; j<3; j++){
        for(int i=3; i>j; i--){
            if(n[i-1] > n[i]){
                int temp = n[i];
                n[i] = n[i-1];
                n[i-1] = temp;
            }
        }
    }
    
    if(n[0]==1 && n[1] == 4 && n[2]==7 && n[3]==9){
        puts("YES");
    }else{
        puts("NO");
    }
    
    return 0;
}


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

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

Measured memory_bytes: 3644
#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include <queue>
#include<algorithm>
typedef long long int ll;
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,a) for (int i=1;i<=(a);i++)
const ll MOD = (10*10*10*10*10*10*10*10*10+7);
    int ans=0,id;
    int N,M;
    int a[52],b[520],c[52],d[52];
    string O,E;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>O>>E;
    REP(i,52){
        if(i==O.size()&&i==E.size()){
            break;
        }
        if(i<O.size())cout<<O[i];
        if(i<E.size())cout<<E[i];
    }
    //cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

const int M=998244353;
const int MX=200005;

int l[12],r[12];
int dp[MX],bit[MX];

void upd(int i,int n,int x)
{
    while(i<=n){
        bit[i]+=x;
        if(bit[i]>=M) bit[i]-=M;
        i+=i & -i;
    }
}

int qry(int i)
{
    int x=0;
    while(i>0){
        x+=bit[i];
        if(x>=M) x-=M;
        i-=i & -i;
    }
    return x;
}

int main()
{
    int n,k;
    cin>> n >> k;
    for(int i=0;i<k;i++){
        cin>> l[i] >> r[i];
    }
    dp[n]=1;
    upd(n,n,1);
    for(int i=n-1;i;i--){
        for(int j=0;j<k;j++){
            int p=i+l[j];
            if(p>n) continue;
            int q=min(n,i+r[j]);
            int x=qry(q)-qry(p-1);
            if(x<0) x+=M;
            dp[i]+=x;
            if(dp[i]>=M) dp[i]-=M;
        }
        upd(i,n,dp[i]);
        //cout<< i << " -- " << dp[i] <<endl;
    }
    cout<< dp[1] <<endl;
    return 0;
}

Measured memory_bytes: 5144
N = int(input())
X = list(map(int, input().split()))
XI = [[X[i], i] for i in range(N)]
XI.sort()
A = [0]*N
for k in range(N):
  x, i = XI[k]
  if k < N//2:
    A[i] = XI[N//2][0]
  else:
    A[i] = XI[N//2 - 1][0]
for a in A:
  print(a)

Measured memory_bytes: 42280