akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));

ll a[200010];
ll s[200010];

struct BinaryIndexedTree{
	vector<ll> bit;
	
	BinaryIndexedTree(int n){
		bit.assign(++n, 0);
	}
	
	void add(int k, int x){
		for(k++;k<=bit.size();k+=k&-k) bit[k] += x;
	}
	
	int get(int k){
		int ret = 0;
		for(k++;k>0;k-=k&-k) ret += bit[k];
		return ret;
	}
};

int main(){
	ll n,k; cin >> n >> k;
	REP(i,0,n) cin >> a[i];
	
	ll sum = 0, pos = 0;
	REP(i,0,n){
		sum += a[i]; pos += k;
		s[i] = sum - pos;
	}
	
	vector<ll> vec;
	REP(i,0,n) vec.push_back(s[i]); sort(vec.begin(), vec.end());
	vec.erase(unique(vec.begin(), vec.end()), vec.end());
	
	sum = 0;
	BinaryIndexedTree bit(vec.size());
	RREP(i,n-1,0){
		if(s[i] < 0) sum--;
		int c = vec.size() - 1 - (lower_bound(vec.begin(), vec.end(), s[i]) - vec.begin());
		bit.add(c, 1);
		sum += bit.get(c);
	}
	
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 6640
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define double long double
#define int long long
#define pb push_back 
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef pair<pii,pii> ppp;
typedef vector< pii > vp;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }

void mina(int &a,int b)
{ a=(a<b?a:b); }

void maxa(int &a,int b)
{ a=(a>b?a:b); }

  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=1e18;
  const int N=2e5+25;
  const int M=31;

 
 void doit()
 { 
   int r; cin>>r;

   double d=2.0*r;
   d*=pi;

   cout<<d;  
 }

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

  
  
   int tc=1;                         
 //  cin>>tc;

  rep(i,1,tc+1)
  { // cout<<"Case #"<<i<<": ";
    
   doit();
   if(i<tc)
   cout<<nl;
  }
  

 return 0; 
}

Measured memory_bytes: 3804
#include <cstdio>

int const SH = 50 * 100 + 2;

long long dp[2 * SH];

int main() {
  int n, A;
  scanf("%d%d", &n, &A);
  dp[SH] = 1;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    x -= A;
    if (x == 0) {
      for (int j = 0; j < 2 * SH; j++) dp[j] *= 2;
    } else if (x < 0) {
      for (int j = 0; j < 2 * SH; j++) dp[j] += dp[j - x];
    } else {
      for (int j = 2 * SH - 1; j >= 0; j--) {
        dp[j] += dp[j - x];
      }
    }
  }
  printf("%lld\n", dp[SH] - 1);
}

Measured memory_bytes: 256
def getlist():
	return list(map(int, input().split()))

N = int(input())
L = []

for i in range(N):
	A = list(input().split())
	S = A[0]
	P = int(A[1])
	L.append([S, -P, i + 1])

L = sorted(L)

for i in range(N):
	print(L[i][2])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

//小数点以下を切り上げる割り算
int updivide(int a,int b){
    if(b==1) return a;
    else if(a%b==0) return a/b;
    else return (a/b)+1;
}

int main(){
    INT(a,b,x);
    int ans=0;
    if(a>=2*b){
        ans=b*updivide(x,500);
    }else if(a<=b){
        ans=a*updivide(x,1000);
    }else if(a<2*b&&a>b){
        ans=a*(x/1000);
        x%=1000;
        if(x>500)ans+=a;
        else if(x>0)ans+=b;
    }
    out(ans);
}



Measured memory_bytes: 3216
/*input
12
100
200
300
0
*/
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_.pop();
    return_
}

//Sieve of Eratosthenes
fn sieve_of_eratosthenes(n: usize) -> Vec<bool> {
    let mut vec: Vec<bool> = vec![true; n];
    vec[0] = false;
    vec[1] = false;
    let mut j: usize;
    for i in 2..n {
        if vec[i] {
            j = i * i;
            while j < n {
                vec[j] = false;
                j = j + i;
            }
        }
    }
    vec
    /*let mut vec2: Vec<usize> = vec![];
    for i in 0..vec.len() {
        if vec[i] {
            vec2.push(i);
        }
    }
    vec2*/
}

fn main() {
    let soe = sieve_of_eratosthenes(10001);
    let mut input: i32;
    let mut index: i32;
    let mut prime: [i32; 2];
    let mut prime_fill_1: bool;
    loop {
        input = read_line().parse().unwrap();
        //println!(">{:?}", input);
        if input == 0 {
            break;
        }
        index = input;
        prime = [0; 2];
        prime_fill_1 = true;
        loop {
            if soe[index as usize] {
                if prime_fill_1 {
                    prime[1] = prime[0];
                    prime[0] = index;
                    prime_fill_1 = false;
                } else {
                    prime[1] = prime[0];
                    prime[0] = index;
                    prime_fill_1 = true;
                }
            }
            //println!("{:?} -> {:?} {:?}", index, prime[1], prime[0]);
            if (prime[1] - prime[0]).abs() == 2 {
                println!("{} {}", prime[0], prime[1]);
                break;
            }
            index = index - 1;
        }
    }
}



Measured memory_bytes: 5044
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

ll a,b,c;

int main(){
  cin>>a>>b>>c;
  ll ans=inf;
  ans=min(ans,abs(a-b)+abs(b-c));
  ans=min(ans,abs(b-a)+abs(a-c));
  ans=min(ans,abs(a-c)+abs(c-b));
  ans=min(ans,abs(b-c)+abs(c-a));
  ans=min(ans,abs(c-a)+abs(a-b));
  ans=min(ans,abs(c-b)+abs(b-a));
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define rn return
#define fi first
#define se second
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;



vector<int> uf(101010,-1);

int root(int p){
    rn (uf[p]<0? p: uf[p] = root(uf[p]));
}
bool join(int v, int w){
    int p = root(v); int q = root(w);
    if (p==q){
        rn false;
    }
    else{
        uf[p] += uf[q];
        uf[q] = p;
        rn true;
    }
}

int main(){
    int N,M;cin >> N >> M;int X,Y,Z;
    rep(i,M){
        
        cin >> X >> Y >> Z;
        X--; Y --;
        join(X, Y);
    }
    int ans = 0;
    rep(i,N){
        if(uf[i]<0){
            ans ++;
        }
    }

    cout << abs(ans);
    rn 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#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};

int n,dist[101010];

int bfs(){
  deque<pint> dq;
  dq.push_back({1,1});
  dist[1]=1;
  while(dq.size()){
    pint p=dq.front();
    dq.pop_front();
    int now=p.first,d=p.second;
    int next=(now+1)%n;
    if(dist[next]>d+1){
      dist[next]=d+1;
      dq.push_back({next,d+1});
      }
    next=(now*10)%n;
    if(dist[next]>d){
      dist[next]=d;
      dq.push_front({next,d});
      }
    }
  return dist[0];
  }      

int main(){
  cin>>n;
  rep(i,n)dist[i]=inf;
  cout<<bfs()<<endl;
  return 0;
  }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
  ll x;
  cin >> x;
  ll ans=1;
  const double pi=acos(-1.0);
  const double rad=pi/180.0;
  double s=1,t=0;
  while(1){
    if(abs(s)<1e-9&&abs(t)<1e-9) break;
    s+=cos(x*ans*rad);
    t+=sin(x*ans*rad);
   ans++; 
  }
  cout << ans << endl;
  
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3980
import java.util.*;

public class Main {
  public static boolean isNum(String str) {
    try {
      Integer.parseInt(str);
      return true;
    } catch(NumberFormatException e) {
      return false;
    }
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Deque<Integer> deq = new ArrayDeque<>();
    String s = "";
    int a = 0;
    while(sc.hasNext()) {
      s = sc.next();
      if(isNum(s)) {
        deq.addFirst(Integer.parseInt(s));
      } else if(s.equals("+")) {
        a = deq.pollFirst() + deq.pollFirst();
        deq.addFirst(a);
      } else if(s.equals("-")) {
        a = (deq.pollFirst() - deq.pollFirst()) * (-1);
        deq.addFirst(a);
      } else {
        a = deq.pollFirst() * deq.pollFirst();
        deq.addFirst(a);
      }
    }
    sc.close();
    System.out.println(deq.getFirst());
  }
}



Measured memory_bytes: 26276
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    ll k;
    cin >> s >> k;
    ll cnt = 0;
    while (s[cnt] == '1')
    {
        cnt++;
    }
    // cout << cnt << endl;
    if (k - cnt <= 0)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << s[cnt] << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX_H 1111
int H,W,N;
int ro[MAX_H][MAX_H];
int cou[MAX_H][MAX_H];

int ro1[MAX_H][MAX_H];
int cou1[MAX_H][MAX_H];

int main()
{
	while(true){
	scanf("%d%d%d",&H,&W,&N);
	if(H==0)break;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			scanf("%d",&ro[i][j]);
			ro1[i][j]=ro[i][j];
			cou[i][j]=0;
		}
	}
	
	cou[0][0]=N-1;
	/*
	for(int j=0;j<W;j++){
		if(cou[0][j]&1){
			if(ro[0][j]==1){
				cou[0][j+1]=1+(cou[0][j]>>1);
				cou[1][j]=cou[0][j]-cou[0][j+1];
			}
			else{
				cou[1][j]=1+(cou[0][j]>>1);
				cou[0][j+1]=cou[0][j]-cou[1][j];
			}
		}
		else{
			cou[0][j+1]=(cou[0][j]>>1);
			cou[1][j]=(cou[0][j]>>1);
		}
	}
	for(int i=0;i<H;i++){
		if(cou[i][0]&1){
			if(ro[i][0]==1){
				cou[i][1]=1+(cou[0][j]>>1);
				cou[i+1][0]=cou[0][j]-cou[0][j+1];
			}
			else{
				cou[1][j]=1+(cou[0][j]>>1);
				cou[0][j+1]=cou[0][j]-cou[1][j];
			}
		}
		else{
			cou[0][j+1]=(cou[0][j]>>1);
			cou[1][j]=(cou[0][j]>>1);
		}
	}*/
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(cou[i][j]&1){
				if(ro[i][j]==1){
					cou[i][j+1]+=(1+(cou[i][j]>>1));
					cou[i+1][j]+=(cou[i][j]-(1+(cou[i][j]>>1)));
				}
				else{
					//printf("%d %d\n",i,j);
					cou[i+1][j]+=(1+(cou[i][j]>>1));
					cou[i][j+1]+=(cou[i][j]-(1+(cou[i][j]>>1)));
					
				}
			}
			else{
				cou[i][j+1]+=(cou[i][j]>>1);
				cou[i+1][j]+=(cou[i][j]>>1);
			}
			//printf("%d %d:cou[%d][%d]=%d\n",i,j,4,0,cou[4][0]);
		}
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			//printf("%d ",cou[i][j]);
			ro[i][j]=(ro[i][j]+cou[i][j])&1;
		}
		//printf("\n");
	}
	int ans1=0,ans2=0;
	while(ans1<H&&ans2<W){
		if(ro[ans1][ans2]==1){
			ans2++;
		}
		else{
			ans1++;
		}
	}
	printf("%d %d\n",ans1+1,ans2+1);
	/*
	for(int i=0;i<N;i++){
		int now1=0,now2=0;
		while(now1<H&&now2<W){
			if(now1+now2==1){
				printf("%d %d\n",now1,now2);
			}
			if(i!=N-1)cou1[now1][now2]++;
			if(ro1[now1][now2]==1){
				ro1[now1][now2]=0;
				now2++;
				
			}
			else{
				ro1[now1][now2]=1;
				now1++;
				
			}
		}
		
		if(i==N-1){
			printf("%d %d\n",now1+1,now2+1);
		}
	}
	for(int j=0;j<H;j++){
			for(int k=0;k<W;k++){
				printf("%d ",cou1[j][k]);
			}
			printf("\n");
		}
	}
	*/
	}
	return 0;
}

Measured memory_bytes: 16200
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
int main()
{ 
    cool;
    string s;
    cin>>s;
    int i,cnt=0;
    for(i=0;i<s.length();i++)
    {
    	if((i+1)%2==0)
    	{
    		
    		if(s[i]=='L'||s[i]=='U'||s[i]=='D')
    		cnt++;
		}
		else if((i+1)%2!=0)
		{
			if(s[i]=='R'||s[i]=='U'||s[i]=='D')
			cnt++;	
		} 
	}
	if(cnt==s.length())
	cout<<"Yes";
	else
	cout<<"No";
    return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node *Node;

void insert(int);
void Inorder(Node);
void Preorder(Node);
int find(int);

Node root;

int main(){
  char mozi[7];
  int kii, n, i;

  scanf("%d", &n);

  for(i=0;i<n;i++){
    if(i<n)break;
  }

  for(i = 0; i < n; i++){
    scanf("%s", mozi);

    if(mozi[0] == 'i'){
      scanf("%d", &kii);
      insert(kii);
    }
    else if(mozi[0] == 'f'){
      scanf("%d", &kii);
      printf(find(kii) == 1 ? "yes\n" : "no\n");
    }
    else{
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
  }
  
  return 0;
}

void insert(int p){
  Node z, x = root, y = NULL;

  z = malloc(sizeof(struct node));
  z->key = p;
  z->left = NULL;
  z->right = NULL;

  while(x != NULL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NULL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void Inorder(Node q){
  if(q == NULL) return;
  Inorder(q->left);
  printf(" %d", q->key);
  Inorder(q->right);
}

void Preorder(Node q){
  if(q == NULL) return;
  printf(" %d", q->key);
  Preorder(q->left);
  Preorder(q->right);
}

int find(int p){
  Node x = root;

  while(x != NULL){
    if(p == x->key)
      return 1;
    else if(p < x->key)
      x = x->left;
    else
      x = x->right;
  }
  return 0;
}



Measured memory_bytes: 20460
n = int(input())
A = [int(input()) for i in range(n)]

INF = int(1e15)
DP = [[INF] * (n+1) for i in range(5)]
for i in range(4):
    DP[i][0] = 0

for i in range(n):
    DP[0][i+1] = DP[0][i] + A[i]
    DP[1][i+1] = min(DP[j][i] for j in range(2)) + (A[i] % 2 if A[i] != 0 else 2)
    DP[2][i+1] = min(DP[j][i] for j in range(3)) + (A[i] + 1) % 2
    DP[3][i+1] = min(DP[j][i] for j in range(4)) + (A[i] % 2 if A[i] != 0 else 2)
    DP[4][i+1] = min(DP[j][i] for j in range(1, 5)) + A[i]

print(min(DP[i][n] for i in range(1, 5)))

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

int main() {
	int n; cin >> n;
	vector<string> s(n);
	int cnt = 1;
	for(int i = 0; i < n; i++){
		cin >> s.at(i);
	}
	sort(s.begin(), s.end());
	string tmp = s.at(0);
	for(int i = 0; i < n; i++){
		if(tmp != s.at(i)){
		tmp = s.at(i);
		cnt++;
		}
	}
	cout << cnt << endl;
} 

Measured memory_bytes: 9600
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#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(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

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

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

//library

class UFTree {
//private:
public:
	vector<int> par;
	vector<int> rank;
	vector<int> num;

//public:
	UFTree(int n)
	{
		par = vector<int>(n);
		rank = vector<int>(n);
		num = vector<int>(n);
		for(int i = 0; i < n; i++){
			par[i] = i;
			rank[i] = 0;
			num[i] = 1;
		}
	}

	int find(int x)
	{
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(rank[x] < rank[y]){
			par[x] = y;
			num[y] += num[x];
		}else{
			par[y] = x;
			num[x] += num[y];
			if(rank[x] == rank[y])	rank[x]++;
		}
	}

	int count(int x)
	{
		return num[find(x)];
	}

	bool same(int x, int y)
	{
		return find(x) == find(y);
	}
};
//library


int main()
{
	ios_init();
	
	int n, m;
	while(cin >> n >> m) {
		UFTree uft(n);
		REP(_, m) {
			int x, y, z;
			cin >> x >> y >> z;
			x--;
			y--;
			uft.unite(x, y);
		}
		set<int> s;
		REP(i, n) {
			s.insert(uft.find(i));
		}
		cout << SZ(s) << endl;
	}

	return 0;
}


Measured memory_bytes: 6144
#include<algorithm>
#include<cstdio>
#define LL long long
using namespace std;
int n,sl,fh;
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int calc(LL x) {int res=0; for(;x;res+=x%10,x/=10); return res;}
int main()
{
	n=rd();LL x=0,y=1;
	for(;n;--n)
	{
		x+=y;printf("%lld\n",x);
		if((x+y)*calc(x+10*y)>(x+10*y)*calc(x+y)) y*=10;
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>


template<typename Itr>
int to_int(Itr begin, Itr end) {
	return std::accumulate(begin, end, 0, [](int r, int p) {return r * 4 + p; });
}
int to_int(const std::vector<int>& prev3) {
	return to_int(prev3.begin(), prev3.end());
}
template<typename Itr>
bool is_agc(Itr begin, Itr end) {
	return std::distance(begin, end) == 3 && to_int(begin, end) == 6;
}
bool contains_agc(const std::vector<int>& vec) {
	for (auto i = 0; i + 2 < vec.size(); ++i) {
		if (is_agc(std::next(vec.begin(), i), std::next(vec.begin(), i + 3))) return true;
	}
	return false;
}
bool is_match(std::vector<int> seq) {
	if (contains_agc(seq)) return true;
	for (auto i = 0; i + 1 < seq.size(); ++i) {
		std::swap(seq[i], seq[i + 1]);
		if (contains_agc(seq)) return true;
		std::swap(seq[i], seq[i + 1]);
	}
	return false;

}
constexpr long long int MOD = 1000000007LL;
long long int pattern(int length, const std::vector<int>& prev3, std::vector<std::vector<long long int>>& memo) {
	if (length == 2) return is_match(prev3) ? 0 : 1;
	if (memo[length][to_int(prev3)] >= 0) return memo[length][to_int(prev3)];
	std::vector<int> last(4); std::copy(prev3.begin(), prev3.end(), std::next(last.begin()));
	std::vector<int> last3(3); std::copy(last.begin(), std::prev(last.end()), last3.begin());
	long long int result = 0;
	for (auto i = 0; i < 4; ++i) {
		last[0] = last3[0] = i;
		if (!is_match(last)) {
			result += pattern(length - 1, last3, memo);
		}
	}
	return memo[length][to_int(prev3)] = result % MOD;
}
int main() {
	int n; std::cin >> n;
	if (n == 3) {
		std::cout << 61 << std::endl;
		return 0;
	}
	std::vector<std::vector<long long int>> memo(n, std::vector<long long int>(256, -1));
	std::vector<int> last3(3);
	long long int result = 0;
	for (auto i = 0; i < 64; ++i) {
		auto p = i;
		for (auto j = 0; j < 3; ++j) {
			last3[j] = p % 4;
			p /= 4;
		}
		result += pattern(n - 1, last3, memo);
		result %= MOD;
	}
	std::cout << result << std::endl;
}


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

int pow(int n){

        int ans = 1;
        for(int i=0;i<n;i++){
            ans *= 10;
        }
    return ans;

}

int main()
{
    long long N,K;

    cin >> N >> K;

    double exp[N];
    double ans[N-K+1];
    double p,ans2=-1;

    rep(i,N){
        cin >> p;
        exp[i] = (p+1)/2;
    }

    rep(i,N-K+1){
        if(i==0){
            ans[i]=0;
            rep(j,K){
                ans[i] += exp[i+j];
            }
        }else{
            ans[i]=ans[i-1] - exp[i-1] + exp[i+K-1];
        }
        
        if(ans[i]>ans2) ans2 = ans[i];
    }

    printf("%.8f\n",ans2);

    return 0;

}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

ll a[200000] = {};
ll b[200000] = {};
int main() {
	ll n; cin >> n;
	rep(i, 0, n) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b, b + n);
	ll MAX1 = b[n-1];
	ll MAX2 = b[n-2];

	rep(i, 0, n) {
		cout << ((a[i] == MAX1) ? MAX2 : MAX1) << endl;
	}

	return 0;
}

Measured memory_bytes: 4736
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
const ll N=1e5+10;
ll w[N],ne[N],la[N],len[N],cst[N],t,n;
ll s[N],cur[N];
ll d[N],dep[N],ti,vis[N],S,T,d1[N],d2[N],p1,p2,p3,p4;
void alink(ll x,ll y,ll z,ll l){
	w[++t]=y;
	ne[t]=la[x];
	la[x]=t;
	len[t]=z;
	cst[t]=l;
}
void link(ll x,ll y,ll z,ll l){
	alink(x,y,z,l);
	alink(y,x,0,-l);
}
ll spfa(){
	for (ll i=1;i<=T;i++)s[i]=-1e18,vis[i]=0;
	s[S]=0;vis[S]=1;d[1]=S;
	ll l=0,r=1;
	while (l<r){
		ll x=d[++l];
		for (ll y=la[x];y;y=ne[y]){
			ll z=w[y];
			if (len[y]&&s[z]<s[x]+cst[y]){
				s[z]=s[x]+cst[y];
				if (!vis[z]){
					vis[z]=1;
					d[++r]=z;
				}
			}
		}
		vis[x]=0;
	}
	vis[S]=1;l=0,r=1;
	while (l<r){
		ll x=d[++l];
		cur[x]=la[x];
		for (ll y=la[x];y;y=ne[y]){
			ll z=w[y];
			if (len[y]&&s[z]==s[x]+cst[y]&&!vis[z]){
				vis[z]=1;
				d[++r]=z;
				dep[z]=dep[x]+1;
			}
		}
	}
	return vis[T];
}
ll ans;
ll flow(ll x,ll val){
	if (x==T)return val;
	ll v1=val;
	for (ll y=cur[x];y;y=ne[y]){
		cur[x]=y;
		ll z=w[y];
		if (dep[z]!=dep[x]+1||!len[y]||s[z]!=s[x]+cst[y])continue;
		ll use=flow(z,min(val,len[y]));
		ans+=(ll)cst[y]*use;
		val-=use;
		len[y]-=use;
		len[y^1]+=use;
		if (!val)return v1;
	}return v1-val;
}
int main(){
	cin>>n;
	for (ll i=1;i<=n;i++)d1[i]=++t,d2[i]=++t;
	p1=++t,p2=++t,p3=++t,p4=++t;
	S=++t;T=++t;t=1;
	for (ll i=1;i<=n;i++){
		ll x,y,z;
		scanf("%lld%lld%lld",&x,&y,&z);
		link(S,d1[i],z,0);
		link(d1[i],p1,z,x+y);
		link(d1[i],p2,z,x-y);
		link(d1[i],p3,z,y-x);
		link(d1[i],p4,z,-x-y);
	}
	for (ll i=1;i<=n;i++){
		ll x,y,z;
		scanf("%lld%lld%lld",&x,&y,&z);
		link(d2[i],T,z,0);
		link(p1,d2[i],z,-x-y);
		link(p2,d2[i],z,y-x);
		link(p3,d2[i],z,x-y);
		link(p4,d2[i],z,x+y);
	}
	while (spfa())flow(S,1<<30);
	cout<<ans<<endl;
}

Measured memory_bytes: 6528
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		int M = scanner.nextInt();

		long[] xi = new long[N];
		long[] yi = new long[N];
		long[] zi = new long[N];

		for (int i = 0; i < N; i++) {
			xi[i] = scanner.nextLong();
			yi[i] = scanner.nextLong();
			zi[i] = scanner.nextLong();
		}

		long[] total = new long[N];
		for(int i = 0; i< N;i++) {
			total[i]=xi[i]+yi[i]+zi[i];
		}



		long[] total000 = new long[N];
		long[] total001 = new long[N];
		long[] total010 = new long[N];
		long[] total011 = new long[N];
		long[] total100 = new long[N];
		long[] total101 = new long[N];
		long[] total110 = new long[N];
		long[] total111 = new long[N];


		for (int i = 0; i < total000.length; i++) {
			total000[i] = -xi[i]-yi[i]-zi[i];
		}
		for (int i = 0; i < total001.length; i++) {
			total001[i] = -xi[i]-yi[i]+zi[i];
		}
		for (int i = 0; i < total010.length; i++) {
			total010[i] = -xi[i]+yi[i]-zi[i];
		}
		for (int i = 0; i < total011.length; i++) {
			total011[i] = -xi[i]+yi[i]+zi[i];
		}
		for (int i = 0; i < total100.length; i++) {
			total100[i] = xi[i]-yi[i]-zi[i];
		}
		for (int i = 0; i < total101.length; i++) {
			total101[i] = xi[i]-yi[i]+zi[i];
		}
		for (int i = 0; i < total110.length; i++) {
			total110[i] = xi[i]+yi[i]-zi[i];
		}
		for (int i = 0; i < total111.length; i++) {
			total111[i] = xi[i]+yi[i]+zi[i];
		}



		Arrays.sort(total000);
		Arrays.sort(total001);
		Arrays.sort(total010);
		Arrays.sort(total011);
		Arrays.sort(total100);
		Arrays.sort(total101);
		Arrays.sort(total110);
		Arrays.sort(total111);

		long score000 = getTotal(total000,M);
		long score001 = getTotal(total001,M);
		long score010 = getTotal(total010,M);
		long score011 = getTotal(total011,M);
		long score100 = getTotal(total100,M);
		long score101 = getTotal(total101,M);
		long score110 = getTotal(total110,M);
		long score111 = getTotal(total111,M);

		long max = Long.MIN_VALUE;
		max = (max > score000)?max : score000;
		max = (max > score001)?max : score001;
		max = (max > score010)?max : score010;
		max = (max > score011)?max : score011;
		max = (max > score100)?max : score100;
		max = (max > score101)?max : score101;
		max = (max > score110)?max : score110;
		max = (max > score111)?max : score111;

		System.out.println(max);



	}

	public static long getTotal(long[] ar,int m) {
		long ans = 0;
		for (int i = 0; i < m; i++) {
			ans += ar[ar.length-i-1];
		}
		return ans;
	}

}


Measured memory_bytes: 28572
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N ;
    cin >> N ;
    N %= 10 ;

    if( N == 2 || N == 4 || N == 5 || N == 7 || N == 9 )
    {
        cout << "hon" << endl ;
    }
    else if( N == 0 || N == 1 || N == 6 || N == 8 )
    {
        cout << "pon" << endl ;
    }
    else
    {
        cout << "bon" << endl ;
    }

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define INF (1LL<<59)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	ll a,b,n;
	cin>>a>>b>>n;
	ll mx = (((a * n)/b) - a * (n/b));
	if(b-1 <= n)
	mx = max(mx, (a * (b-1))/b);
	cout<<mx<<"\n";	
	return;
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

Measured memory_bytes: 3564
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
using namespace std;
typedef long long LL;
const int Maxn = 1e5 + 5;
const int inf = 1 << 30;
const LL Inf = 1LL << 60;
int n,m;
char s[100];

int main ()
{
	scanf("%s",s);
	if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
		printf("Yes");
		else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int ka[214514],inv[214514];
void setkaijo(int n){
	ka[0]=1;
	for(int i=1;i<=n;i++){
		ka[i] = ka[i-1] * i;
		ka[i] %= inf;
	}
}
int modpow(int x,int k){
	// x ^ k mod inf
	int res = 1;
	while(k>0){
		if(k%2)res = (res*x)%inf;
		x = (x*x)%inf;
		k >>=1;
	}
	return res;
}
void setinv(int n){
	for(int i=0;i<=n;i++){
		inv[i] = modpow(ka[i],(ll)inf-2);
	}
}
int comb(int n,int k){
	if( k<0 || n<0 || k>n)return 0;
	if(k==0 || k==n)return 1;
	int res = (ka[n] * inv[k]) % inf;
	res = (res*inv[n-k]) % inf;
	return res;
}
signed main(){
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	setkaijo(210000);
	setinv(210000);
	int ans = 0;
	for(int i=0;i<=h-a-1;i++){
		int tmp = comb(i+b-1,b-1);
		tmp *= comb( h-1-i+w-b-1, w-b-1);
		tmp %= inf;
		ans += tmp;
		ans %= inf;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct Score{
	int team_num;
	int ac=0;
	int time=0;
	int miss_tmp[20]={0};
};

bool asc(const Score& left, const Score& right) {
	return left.ac == right.ac ? (left.time == right.time ?  left.team_num > right.team_num : left.time < right.time) :
		   left.ac > right.ac;
}

int main(){
	while(1){
		int M, T, P, R; cin>>M>>T>>P>>R;
		if(!M && !T && !P && !R) break;
		vector <Score> score(T);
		for(int i=0; i<T; i++) score[i].team_num = i;
		int m, t, p, j;
		for(int i=0; i<R; i++){
			cin>>m>>t>>p>>j;
			t=t-1;//0オリジン
			if(j == 0){
				score[t].ac++;
				score[t].time += m+(score[t].miss_tmp[p]*20);
			} else{
				score[t].miss_tmp[p]++;
			}
		}
		sort(score.begin(), score.end(), asc);
		for(int i=0; i<T; i++){
			cout << score[i].team_num+1;
			if(i!=T-1){
				if(score[i].ac == score[i+1].ac && score[i].time == score[i+1].time) cout << "=";
				else cout << ",";
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b,c,d,x = 0;
    cin >> a >> b;
    int A[1000] = {};
    int n;
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> c >> d;
        if(a > c && a < d){
          x += 1;
          break;
        }
        if(b > c && b < d){
          x += 1;
          break;
        }
        if(a == c && b == d){
          x += 1;
          break;
        }
        if(a < c && b > d){
          x += 1;
          break;
        }
    }
    cout << x << endl;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x) cout<<#x<<" = "<<(x)<<endl
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  string s[n]; REP(i,n) cin >> s[i];
  map<string, int> m; m[s[0]]++;

  int ok = true;
  for (int i = 1; i < n; i++) {
    if (s[i][0] != s[i-1].back()) ok = false;
    if (m[s[i]] > 0) ok = false;
    m[s[i]]++;
  }

  Yes(ok);
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int a, b;
char c[105][105];
int main() {
	int i, j;
	scanf("%d%d", &a, &b);
	for(i=0; i<100; i++) for(j=0; j<100; j++) c[i][j] = i<50 ? '.' : '#';
	for(i=0; i<b-1; i++) c[i/50*2][i%50*2] = '#';
	for(i=0; i<a-1; i++) c[i/50*2+60][i%50*2] = '.';
	puts("100 100");
	for(i=0; i<100; i++) puts(c[i]);
	return 0;
}

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

int main(){
	int n, x;
	cin >> n >>x;
	
	int L[n]={};
	for(int i=0; i<n; i++) cin >> L[i];
	
	int ans=0;
	int cnt=1;
	for(int i=0; i<n; i++){
		ans = ans+L[i];
		if(ans <=x) cnt++;
	}
	cout << cnt << endl;
}


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

typedef long long lli;

const int mod = 1e9 +7;
lli dp[100001], presum[100001], a[100002], n, k;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin >> n >> k;
    for(int i=1; i<=n; i++)cin>>a[i];
	for(int i=1; i<=k+1; i++)presum[i]=1;
    for(int i=1; i<=n; i++)
    {
    	for(lli j=0; j<=k; j++)
    		dp[j] = (presum[j+1] - presum[max(0LL, j-a[i])] + 2*mod)%mod;
    	for(int x=1; x<=k+1; x++)
    		presum[x] = (presum[x-1]+dp[x-1])%mod;
    }
    cout << dp[k];
}

Measured memory_bytes: 5188
#include<cstdio>
using namespace std;
#define N 5005
long long dp[N][N];
int n,a,b,p[N];
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)dp[i][j]=1e17;
	dp[0][0]=0;
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	for(int i=1;i<=n;i++)
	{
		long long mn=1e18;
		for(int j=0;j<=n;j++)
		{
			long long tp=mn;
			if(p[i]>j)tp+=a;
			if(p[i]<j)tp+=b;
			if(dp[i][j]>tp)dp[i][j]=tp;
			if(mn>dp[i-1][j])mn=dp[i-1][j];
			tp=mn;
			if(p[i]>j)tp+=a;else tp+=b;
			if(dp[i][j]>tp)dp[i][j]=tp;
		}
	}
	long long as=1e18;
	for(int i=0;i<=n;i++)if(as>dp[n][i])as=dp[n][i];
	printf("%lld\n",as);
}//

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

//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)

//typedef----------------------------------------------------------------------------------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
//const------------------------------------------------------------------------------------------------------------------------
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;

//global-----------------------------------------------------------------------------------------------------------------------
int a, b;
char c;
//function--------------------------------------------------------------------------------------------------------------------
int main() {
	while ( true ) {
		scanf( "%d %c %d", &a, &c, &b );
		if ( c == '?' ) {
			break;
		}
		if ( c == '/' ) {
			printf( "%d\n", a / b );
		}
		else if(c == '*'){
			printf( "%d\n", a * b );
		}
		else if( c == '+' ) {
			printf( "%d\n", a + b );
		}
		else {
			printf( "%d\n", a - b );
		}
	}
	return 0;
}

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

int main() {
  int n,
      x = 0,
      ans = 0;
  string s;
  cin >> n >> s;
  for(int i = 0; i < n; i++) {
    x = s[i] == 'I' ? ++x : --x;
    if(x > ans) ans = x;
  }

  cout << ans << 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 INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n;
	cin >> n;
	vector<pair<ll, pair<ll, ll>>> a(n);
	REP(i, n){
		cin >> (a[i].second).first >> (a[i].second).second;
		a[i].first = (a[i].second).first + (a[i].second).second;
	}

	sort(a.begin(), a.end(), greater<pair<ll, pair<ll, ll>>>());

	ll taka = 0, aoki = 0;

	REP(i, n){
		if (i % 2 == 0) taka += (a[i].second).first;
		else aoki += (a[i].second).second;
	}

	cout << taka - aoki << endl;
}


Measured memory_bytes: 2560
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 998244353
mans = inf ;ans = 0 ;count = 0 ;pro = 1
sys.setrecursionlimit(10**6)

n = int(input())
XD = [(-10**10,inf)]
for i in range(n):
  x,d = map(int,input().split())
  XD.append((x,d))
XD.sort()
visited = [0] * (n+1)
def dfs(node):
  visited[node] = 1
  res = 1
  i = node + 1
  while i < n+1:
    if XD[i][0] < XD[node][0] + XD[node][1]:
      if visited[i]:continue
      pro,i = dfs(i)
      res *= pro
      res %= mod
    else: break
  # print(node,res+1)
  return res + 1 , i
print((dfs(0)[0]-1)%mod)
# print(visited)
# print(XD)
# dfs(1)


Measured memory_bytes: 203860
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
using namespace std;
int main()
{
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	int num = min(X, Y);
	long sum = 0;
	if(C * 2 * num < num * (A + B))
		sum += C * 2 * num;
	else
		sum += num * (A + B);
	//cout << sum << endl;
	bool flag = false;
	if(X - num > Y - num)
	{
		num = X - num;
		flag = true;
	}
	else
		num = Y - num;
	if(flag)
	{
		if(C * 2 * num < A * num)
			sum += C * 2 * num;
		else
			sum += A * num;
	}
	else
	{
		if(C * 2 * num < B * num)
			sum += C * 2 * num;
		else
			sum += B * num;
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){ 
	int  n ; 
    cin >> n ; 
    int l=1,r=n,len=-1;
    while (l<=r){
    	int m = (l+r)>>1 ; 
    	int sum = m * (m+1) / 2 ; 
    	if (sum == n) { 
    		len = m ; 
    		break ; 
     	} 
     	if (sum > n) r = m-1 ; 
     	else l = m+1 ; 
    }

    if (len == -1) {
    	co("No") ; 
    	return ; 
    }
    co("Yes\n"<<len+1) ; 
    vector < vi > ans( len+1, vi(len, 0) ) ; 
    int cur = 1 ; 
    for (int i=0;i<=len;i++) { 
    	for (int j=0;j<len;j++) { 
    		if (j<i)  ans[i][j] = ans[j][i-1] ; 
    		else  ans[i][j] = cur++ ; 
    	}
    }
    for (int i=0;i<=len;i++){
    	cout << len ; 
    	for (int j=0;j<len;j++){
    		cout << " " << ans[i][j] ; 
    	}
    	cout << endl;
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 4788
program main
	implicit none
	integer    :: W, a, b
	read(*, *) W, a, b
	if(a <= b .AND. b <= a+W) then
		write(*, *) 0
	else if(a+W < b) then
		write(*, *) b-(a+W)
	else
		write(*, *) a-(b+W)
	end if
end program main

Measured memory_bytes: 640
n = int(input())
x = [list(map(int,input().split())) for i in range(n)]
a = x[0][0]
b = x[0][1]
x.pop(0)
for i in x:
  m = a//i[0]
  n = b//i[1]
  if a % i[0] != 0:
    m+=1
  if b % i[1] != 0:
    n+=1
  a = max(m,n) * i[0]
  b = max(m,n) * i[1]
print(a+b)

Measured memory_bytes: 3188
use std::collections::HashSet;

#[allow(unused_macros)]
macro_rules! invec {
    ( $t:ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s.trim().split_whitespace().map(|s| s.parse::<$t>().unwrap()).collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }}
}

#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($(
            {
                 splits.next().unwrap().parse::<$t>().unwrap()
            },
        )*)
    }}
}

fn divisors(n: u32) -> Vec<u32> {
    (1..(n + 1)).filter(|m| n % m == 0).collect()
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (a, b, k) = input!(u32, u32, usize);

    let avec: HashSet<u32> = divisors(a).into_iter().collect();
    let bvec: HashSet<u32> = divisors(b).into_iter().collect();
    let mut ab = avec.intersection(&bvec).collect::<Vec<&u32>>();
    ab.sort();
    ab.reverse();

    println!("{}", ab[k - 1]);
}

fn main() {
    solve();
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <map>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long x,y;
    cin >> x >> y;
    long long cnt=0;
    while(x<=y){
        x*=2;
        cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256