akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int ans = 700;
  rep(i, 0, s.size()) {
    if(s.at(i) == 'o')
      ans += 100;
  }
  
  cout << ans << "\n";
  
  //cout << fixed << setprecision(10) << n << "\n";

}


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

int main() {
  char c;
  cin >> c;
  // ここにプログラムを追記
  if((c == 'a')||(c=='i')||(c=='u')||(c=='e')||(c=='o')){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,a;
int main()
{
//	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>a;
	if(n%500<=a)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  
  int sum_vote = 0;
  vector<int> a(n);
  for (int i = 0; i < n; i ++)
  {
    cin >> a.at(i);
    sum_vote += a.at(i);
  }
  
  double vote_thres = (double)sum_vote / (4 * m);
  int num_popular = 0;
  for (int i = 0; i < n; i ++)
  {
    if (a.at(i) >= vote_thres) num_popular ++;
  }
  
  if (num_popular >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		List<Double> list = new ArrayList<Double>();
		for (int i = 0; i < N; i++) {
			list.add(Double.parseDouble(sc.next()));
		}

		double ans = list.stream().mapToDouble(s -> 1.0 / s).sum();

		ans = 1.0 / ans;
		
		PrintWriter out = new PrintWriter(System.out);
		out.println(ans);
		out.flush();
	}

}


Measured memory_bytes: 27472
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <queue>
#include <cstring>
#include <set>
#include <list>
#include <map>
#include <random>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vvi> vvvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;

#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define forn(i, a, b) for(int i = a; i < b; i++)

#define pb push_back
#define mp make_pair
vvpi nb;
vi par;
int cent = -1;
int n;
vi s;
ll ans = 0;
void dfs(int v, int p) {
    s[v] = 1;
    for(auto pu : nb[v]) {
        if(pu.first == p) continue;
        dfs(pu.first, v);
        s[v] += s[pu.first];
    }
    if(cent<0 && 2*s[v] >= n) cent = v;
}
void dfs2(int v, int p) {
    s[v] = 1;
    for(auto pu : nb[v]) {
        if(pu.first == p) continue;
        dfs2(pu.first, v);
        s[v] += s[pu.first];
        ans += 2ll*(ll)s[pu.first] * (ll)pu.second;
    }
    
}

int main()
{

    scanf("%d", &n);
    nb.resize(n);
    s.resize(n);
    forn(i,0,n-1) {
        int u,v,c;
        scanf("%d %d %d", &u, &v, &c);
        u--; v--;
        nb[u].pb(mp(v,c));
        nb[v].pb(mp(u,c));
    }
    dfs(0,-1);
    int root = cent;
    dfs2(root,-1);
    bool done = false;
    ll mn = 1e9;
    for(auto x : nb[root]) {
        mn = min(mn, (ll)x.second);
        if(s[x.first]*2 == n) {
            done = true;
            ans -= x.second;
        }
    }
    if(!done) ans-=mn;
    cout<<ans;
    
    
    
}



Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define LL long long
using namespace std;

const int N = 2e5;

int n;
LL a[N+10];

LL get_sum(int l,int r){
    return a[r]-a[l-1];
}

int findposition(int L,int R){
    int l = L,r = R-1,idx = -1;
    while (l<=r){
        int mid = (l+r)>>1;
        LL temp1 = get_sum(L,mid),temp2 = get_sum(mid+1,R);
        LL temp3 = get_sum(L,mid+1),temp4 = get_sum(mid+2,R);
        if (mid+2<=R && abs(temp1-temp2)<abs(temp3-temp4)){
            idx = mid;
            r = mid-1;
        }else{
            if (mid+2>R && idx==-1){
                idx = mid;
                r = mid - 1;
            }else
                l = mid + 1;
        }
    }
    return idx;
}

int main()
{
    //freopen("D:\\rush.txt","r",stdin);
    ios::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    rep1(i,1,n) cin>>a[i];
    rep1(i,1,n) a[i]+=a[i-1];
    LL temp = -1;
    rep1(i,2,n-2){
        int idx1 = findposition(1,i);
        int idx2 = findposition(i+1,n);
        LL temp1 = max(get_sum(1,idx1),get_sum(idx1+1,i));
        LL temp2 = max(get_sum(i+1,idx2),get_sum(idx2+1,n));
        temp1 = max(temp1,temp2);
        LL temp3 = min(get_sum(1,idx1),get_sum(idx1+1,i));
        LL temp4 = min(get_sum(i+1,idx2),get_sum(idx2+1,n));
        temp3 = min(temp3,temp4);
        if (temp==-1){
            temp = temp1-temp3;
        }else{
            temp = min(temp,temp1-temp3);
        }
    }
    cout<<temp<<endl;
    return 0;
}


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

int main() {
  string S; ll K;
  cin >> S >> K;

  char ans = '0';
  if (K < 100) {
    bool all_one = true;
    rep(i,0,K-1) {
      if (S[i] != '1') all_one = false;
    }
    if (all_one) ans = '1';
  }
  if (ans == '0') {
    for (char c : S) {
      if (c != '1') {
        ans = c;
        break;
      }
    }
  }

  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define MODULE 1000000007
#define MP make_pair

template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9
const int MAXN = 100001;

/*struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];*/


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

//-----Template---------
string s;
string s2="CODEFESTIVAL2016";
int counter;
int main(){
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);

    cin>>s;
    for (int i = 0; i < 16; ++i) {
        if(s[i]!=s2[i])
            counter++;
    }
    cout<<counter<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
#include <set> 
using namespace std;

typedef long long ll;
typedef pair<ll, int> P;
typedef pair<pair<int, int>, int> PP;

const ll INF = 1e15;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

const int MAX = 510000;
const int MOD = 1000000007;


int color_h[4000010], color_w[4000010];
int ch[2010][2010], cw[2010][2010];
string s[2010];

int main(void) {
	int H, W; cin >> H >> W;

	for (int i = 0; i < H; i++) cin >> s[i];

	int j = 0;
	int c = 0;

	for (int h = 0; h < H; h++) {
		for (int i = 0; i < W;) {
			if (s[h][i] == '#') { i++; continue; }
			j = i; c++;
			while (j < W && s[h][j] == '.') {
				cw[h][j] = c;
				color_w[c]++;
				j++;
			}
			i = j + 1;
		}
	}

	j = c = 0;

	for (int w = 0; w < W; w++) {
		for (int i = 0; i < H;) {
			if (s[i][w] == '#') { i++; continue; }
			j = i; c++;
			while (j < H && s[j][w] == '.') {
				ch[j][w] = c;
				color_h[c]++;
				j++;
			}
			i = j + 1;
		}
	}

	int ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == '.') {
				int colw = cw[i][j], colh = ch[i][j];
				int lamp = color_w[colw] + color_h[colh];
				if (color_w[colw] > 0 && color_h[colh] > 0) lamp--;
				ans = max(ans, lamp);
			}
		}
	}

	cout << ans << endl;
}


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

int main(){
  ll X,K,D,f,left;
  cin>>X>>K>>D;
  X=abs(X);
  if(K<=X/D){
    cout<<abs(X-K*D)<<endl;
  }
  else{
    f=floor(X/D);
    left=K-f;
    X-=D*f;
    cout<<(left%2==0?X:abs(X-D))<<endl;
  }
}

Measured memory_bytes: 3600
#include <stdio.h>
int main(void){
    char s[4];
    int a=0,b=0,r=1;
    scanf("%s",s);
    for(int i = 0; i < 4; i++) {
        a=s[i];
        if(a==b) {
            r=0;
        }
        b=a;
    }
    if(r) {
        puts("Good");
    } else {
        puts("Bad");
    }
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<cctype>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<bitset>
using namespace std;
typedef long long LL;

inline int read() {
	int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
}

const int N = 305, mod = 998244353;
bitset<N>a[N], b[N];

int ksm(int a,int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = 1ll * res * a % mod;
		a = 1ll * a * a % mod;
		b >>= 1;
	}
	return res;
}

int main() {
	int n = read(), m = read(), cnt = 0;
	for (int i = 1; i <= n; ++i) 
		for (int j = 1; j <= m; ++j) a[i][j] = read();
	for (int i = 1; i <= n; ++i) 
		for (int j = 1; j <= m; ++j) 
			if (a[i][j]) {
				if (!b[j][j]) {
					b[j] = a[i];
					cnt ++;
					break;
				}
				else {
					a[i] ^= b[j];
				}
			}
	cout << 1ll * (ksm(2, n) - ksm(2, n - cnt) + mod) % mod * ksm(2, m - 1) % mod;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
       Scanner scan = new Scanner(System.in);
       int x = scan.nextInt();
       int a = scan.nextInt();
       if(x<a){
           System.out.println(0);
       }
       else{
           System.out.println(10);
       }
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
char n[4];
int main()
{
	scanf("%s",n);
	int  l=strlen(n);
	if(n[0]==n[l-1])
	{
		printf("Yes\n");
	}else
	{
		printf("No\n");
	}
	return 0;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (int)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}


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

    vll c(n),t(n),tmp;
    rep(i,n){
        cin >> c[i] >> t[i];
        if(T >= t[i])tmp.push_back(c[i]);
    }

    if(SIZE(tmp) == 0)cout << "TLE" << endl;
    else{
        sort(all(tmp));
        cout << tmp[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main() {
  std::string S;
  std::cin >> S;

  S.pop_back();
  if (S.length() % 2 > 0) S.pop_back();
  size_t n = S.length() / 2;
  while (true) {
    if (S.substr(0, n) == S.substr(n)) break;
    S.pop_back();
    S.pop_back();
    --n;
  }
  std::cout << S.length() << std::endl;
}

Measured memory_bytes: 380
use std::io;

// I'm really really not sure if this is the right way
fn get_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf.to_string()
}

fn solve(input: String) -> u32 {
    input.chars().skip_while(|&c| c != 'A').fold((0,0), |(t,buf), c| {
        match c {
            'Z' => (1+t+buf,0),
            _ => (t,buf+1)
        }
    }).0
}

fn main() {
    let input = get_line();
    println!("{}", solve(input));
}


Measured memory_bytes: 764
A=list(input())
right_cnt=[0]
left_cnt=[0]
cnt=0
for i in range(len(A)):
   if A[i] == "<":
      right_cnt.append(right_cnt[-1]+1)
   else:
      right_cnt.append(0)
   if A[-i-1] == ">":
      left_cnt.append(left_cnt[-1]+1)
   else:
      left_cnt.append(0)
left_cnt=left_cnt[::-1]
for i in range(len(A)+1):
   cnt+=max(left_cnt[i],right_cnt[i])
print(cnt)

Measured memory_bytes: 35480
/*

	Raghul
	
*/	
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
	ll a,b,c;
	cin>>a>>b>>c;
	if(a+b+1<c)	c = a+b+1;
	cout<<c+b;
}
int main(){
	int T;
	T = 1;
	while(T--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {

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

		int n = stdIn.nextInt();

		Map<String,Integer> map1 = new HashMap<>();
		Map<String,Integer> map2 = new HashMap<>();





		for(int i = 0; i < n; i++) {
			String s = stdIn.next();

			if(map1.containsKey(s)) {
				map1.put(s,map1.get(s)+1);
			}else {
				map1.put(s,1);
			}
		}

		int m = stdIn.nextInt();
		for(int i = 0; i < m; i++) {
			String t = stdIn.next();

			if(map2.containsKey(t)) {
				map2.put(t,map2.get(t)+1);
			}else {
				map2.put(t,1);
			}
		}

		int ans = 0;

		for(String mp1: map1.keySet()) {
			boolean flag = false;
			int cnt = 0;
			for(String mp2: map2.keySet()) {

				if(mp1.equals(mp2)) {
					flag = true;
					cnt = map1.get(mp1) - map2.get(mp2);
				}


			}

			if(!flag) {
				ans = Math.max(map1.get(mp1), ans);
			}else {
				ans = Math.max(ans, cnt);
			}


		}

		System.out.println(ans);

	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define REP3(i,x,n) for(int i=x; i>(n); i--)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int L;
    scanf("%d",&L);
    printf("%.12f\n",(double)L*L*L/27);
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



n, x, d = LI()
if d == 0:
    if x == 0:
        print(1)
    else:
        print(n + 1)
    exit()

D = defaultdict(list)
for i in range(n + 1):
    a = i * x
    L = i * (i - 1) // 2
    R = (2 * n - i - 1) * i // 2
    D[a % d] += [(a // d + L, a // d + R)]


ans = 0
for L in D.values():
    L.sort()
    now = -INF
    for l, r in L:
        if r <= now:
            continue
        elif l > now:
            ans += r - l + 1
        else:
            ans += r - now
        now = r


print(ans)


Measured memory_bytes: 82136
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        
        if("aiueo".indexOf(s) >= 0){
            System.out.println("vowel");
        }else{
            System.out.println("consonant");
        }
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

struct Node{
    vector<ll> adjacency_list{};
    explicit Node(){}
};

int main() {
    ll N, M;
    cin  >> N >> M;
    vector<ll> as(M, 0), bs(M, 0);
    for (auto &&i: irange(0LL, M)){
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        as.at(i) = a;
        bs.at(i) = b;
    }
    vector<Node> nodes(N, Node());
    for (auto &&i: irange(0LL, M)){
        nodes.at(as.at(i)).adjacency_list.emplace_back(bs.at(i));
        nodes.at(bs.at(i)).adjacency_list.emplace_back(as.at(i));
    }
    for (auto &&i: irange(0LL, N)){
        cout << nodes.at(i).adjacency_list.size() << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> namespace mp = boost::multiprecision; //mp::cpp_intで宣言
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
//ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////

int main(){
     ios::sync_with_stdio(false);cin.tie(0);
    
    ll a,b;cin>>a>>b;
    cout<<a+b/2<<endl;
    
    return 0;
}
//ios::sync_with_stdio(false);cin.tie(0);



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

using namespace std;

int main() {
    string s = "";
    cin >>  s;
    
    if(s[1] == 'R'){
        s[1] = 'B';
    }else{
        s[1] = 'R';
    }

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

Measured memory_bytes: 3596
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <algorithm>

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
inline int gcd(int a,int b){return b?gcd(b,a%b):a;}
inline int lcm(int a,int b){return a*b/gcd(a,b);}
typedef long long ll;
typedef std::vector<int> VI;
typedef std::pair<int, int> PII;

using namespace std;

int main()
{
  int N, D;
  cin >> N >> D;
  int d = 1+D;
  int cnt = 1;
  while(d+D < N)
  {
    d += D*2+1;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#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, q;
    cin>>n>>q;
    vector<stack<int>> ss(n);
    rep(i, q) {
        int j, t, x;
        cin>>j;
        if (j == 0) {
            cin>>t>>x;
            ss[t].push(x);
        }
        else if (j == 1) {
            cin>>t;
            if (ss[t].empty()) continue;
            cout<<ss[t].top()<<endl;
        }
        else {
            cin>>t;
            if (ss[t].empty()) continue;
            ss[t].pop();
        }
    }
}


Measured memory_bytes: 4260
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,K;
LL A[200000],F[200000];
 
LL ans = 0;

void solve(){
	LL A_sum = 0;
	for(int i=0;i<N;i++) A_sum += A[i];
	if(A_sum<=K){
		ans = 0;
		return;
	}

	sort(A,A+N,greater<LL>());
	sort(F,F+N);
	vector<LL> AF(N,0);
	for(int i=0;i<N;i++) AF[i] = A[i]*F[i];

	//二部探索でチーム全体の成績を最大どこまで下げられるか見る
	//(今回に関しては低い方がいい)
	LL left = 0;//ギリギリいけるライン
	LL right = *max_element(AF.begin(),AF.end())+1;//ギリギリ無理なライン
	while(left+1<right){
		LL center = (left+right)/2;//このcenterが狙う最小値なのかどうかを調べる

		auto ok = [&](){
			LL sum = 0;//成績をcenterにするのに必要な修行の総量
			for(int i=0;i<N;i++){
				LL diff = AF[i]-center;
				if(diff>0) sum += (diff/F[i] + (diff%F[i]!=0));
			}
			return sum<=K;
		};

		if(ok()) right = center;//修行の総量がK以下だったならばもっとcenterを下げる
		else left = center;
	}

	ans = right;
}

int main(){
    cin >> N >> K;
    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=0;i<N;i++) cin >> F[i];
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4864
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

D = I()
c = [0] + LI()
s = [0] + [[0] + LI() for i in range(D)]

last = [[0]*27 for i in range(D+1)]

for i in range(1,D+1):
    r = 0
    manzokudo = 0
    for j in range(1,27):
        m = s[i][j]
        for k in range(1,27):
            if k != j:
                m -= c[k]*(i-last[i-1][k])
            else:
                continue
        if j == 1:
            r = 1
            manzokudo = m
        else:
            if manzokudo < m:
                manzokudo = m
                r = j
    print(r)
    for j in range(1,27):
        if j == r:
            last[i][j] = i
        else:
            last[i][j] = last[i-1][j]


Measured memory_bytes: 69208
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;
int deco[1000];

void Sequence() {
	int w, h, n;
	cin >> w >> h >> n;
	int x1 = 0, y1 = 0, x2 = w, y2 = h;

	for (size_t i = 0; i < n; i++)
	{
		int a, b, c;
		cin >> a >> b >> c;
		if (c == 1) {
			x1 = max(a,x1);
		}
		else if (c == 2) {
			x2 = min(a,x2);
		}
		else if (c == 3) {
			y1 = max(b,y1);
		}
		else if (c == 4) {
			y2 = min(b,y2);
		}
	}

	cout << max(0, max(0,x2 - x1) * max(0,y2 - y1)) << endl;
}
int main() {
	Sequence();
	return 0;
}



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

using namespace std;

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

    vector<vector<pair<long,long>>> G(n);

    for(int i=0; i<m; i++) {
        long l, r, c;
        cin >> l >> r >> c;
        l--, r--;
        G[l].push_back({r, c});
    }
    for(int i=0; i<n-1; i++)
        G[i+1].push_back({i, 0});

    priority_queue<pair<long,long>> q;
    q.push({0, 0});

    vector<long> dis(n, 1e15);
    while(!q.empty()) {
        auto t = q.top(); q.pop();
        long d = -t.first;
        long v = t.second;
        if(dis[v] <= d) continue;
        dis[v] = d;

        for(auto w: G[v]) {
            if(dis[w.first] <= d + w.second) continue;
            q.push({-(d + w.second), w.first});
        }
    }
    cout << (dis[n-1] == 1e15 ? -1 : dis[n-1]) << endl;
}


Measured memory_bytes: 9972
N,K = map(int,input().split())
p = list(map(int,input().split()))
an = 0
if K == 1:
  ans = (max(p)+1)/2
  print(ans)
else:
  ans = sum(p[0:K])
  an = ans
  for i in range(0,N-K):
    an = an +p[i+K] -p[i]
    ans = max(ans,an)
  num = ans/2 + K/2    
  print(num)

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

using namespace std;
using ll = long long;
using ld = long double;

void solve() {
  int n;
  string s;
  cin >> n >> s;
  if (n % 2 == 0 && s.substr(0, n / 2).compare(s.substr(n / 2)) == 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

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

  solve();
  return 0;
}


Measured memory_bytes: 512
import sys

sys.setrecursionlimit(10000)

n, q = map(int, input().split())

def root(x):
    if par[x] == x:
        return x
    else:
        par[x] = root(par[x])
        return par[x]

def unite(x, y):
    rx = root(x)
    ry = root(y)
    if rx != ry:
        par[rx] = ry

def same(x, y):
    return root(x) == root(y)

par = [i for i in range(n)]

for i in range(q):
    p, a, b = map(int, input().split())
    if p:
        print(1 if same(a, b) else 0)
    else:
        unite(a, b)


Measured memory_bytes: 13096
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

bool isp(string s){
	rep(i,sz(s)/2){
		if(s[i]!=s[sz(s)-i-1]){
			return 0;
		}
	}
	return 1;
}
int main(int argc,char** argv){
	string s;
	cin>>s;
	int n=sz(s);
	string t,u;
	rep(i,(n-1)/2){
		t+=s[i];
	}
	for(int i=(n+3)/2-1;i<n;i++){
		u+=s[i];
	}
	if(isp(t)&&isp(u)&&isp(s))cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
 
using namespace std;

ll n, m;
 
int main() {
  fast_io;

  cin >> n >> m;

  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
 
  return 0;
}

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

#define int long long

const int maxn = 1e5 + 5;
int a[maxn], fen[2 * maxn], ps[maxn];
map <int, int> M;
vector <int> compress;

void add(int id, int val) {
	for (; id < 2 * maxn; id += id & -id)
		fen[id] += val;
}

int get(int id) {
	int ans = 0;
	for (; id; id -= id & -id)
		ans += fen[id];
	return ans;
}

int bs(int n) {
	int l = 0, r = n + 1;
	while (r > l + 1) {
		int mid = (l + r) / 2;
		for (int i = 0; i < n; i++) {
			if (a[i] <= mid) {
				ps[i + 1] = ps[i] + 1;
			}
			else
				ps[i + 1] = ps[i] - 1;
		}
		int ans = 0;
		for (int i = 0; i <= n; i++) {
			ans += get(ps[i] + n);
			add(ps[i] + n + 1, +1);
		}
		if (ans > (n * (n + 1) / 2) / 2)
			r = mid;
		else
			l = mid;
		fill(fen, fen + 2 * maxn, 0);
	}
	return l;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		compress.push_back(a[i]);
	}
	sort(compress.begin(), compress.end());
	compress.resize(unique(compress.begin(), compress.end()) - compress.begin());
	int sz = compress.size();
	for (int i = 0; i < sz; i++)
		M[compress[i]] = i;
	for (int i = 0; i < n; i++)
		a[i] = M[a[i]] + 1;
	cout << compress[bs(n)];
}


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

int main() {

	int n; cin >> n;
	string s; cin >> s;
	int ans = -1000000;
	int point = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'I') point++;
		if (s[i] == 'D') point--;
		ans = max(ans, point);
	}

	cout << max(0, ans) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstdlib>
using namespace std;
 int main()
 {
 	long long int a,b,c,x,y,sum,xymin;
 	cin>>a>>b>>c>>x>>y;
	 	sum=0;
 		if(a+b<c*2)
 		{
 			sum=x*a+y*b;
		}
		else
		{
		  	if(x>y)
 		   {
 		   	xymin=y;
			if(a>(c*2))
 				sum+=(x-y)*c*2;
 				else
 					sum+=(x-y)*a;
		   }
		 	else if(x<y)
		 	{
		 		xymin=x;
				if(b>(c*2))
 				sum+=(y-x)*c*2;
 				else
 					sum+=(y-x)*b;
		 	}
		 	sum+=xymin*c*2;
		} 
		 cout<<sum<<'\n';
 	return 0;
  } 

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

#define VMAX 100000
#define WMAX 1000000000
vector<int> dp(VMAX+1, WMAX+1);

int main(){
	int N,W; cin>>N>>W;
	dp[0] = 0;
	for(int i=1; i<=N; i++){
		int w,v; cin>>w>>v;
		for(int j=VMAX; j>=v; j--) dp[j] = min(dp[j], dp[j-v] + w);
	}

	int a = 0;
	for(a=VMAX; a>=1; a--) if(dp[a]<=W) break;
	cout<< a <<endl;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;
#define int long long 


signed main(){
    int n, b, r;
    cin >> n >> b >> r;
    if(b == 0){
        cout << 0;
        return 0 ;
    }

    int n1 = n/(b+r) * b;
    int n2 = ( n%(b+r) > b) ? b :n%(b+r);

    cout << n1+n2;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int n,r=-1;
ll a[100005];
vector<int>g[100005];
ll dfs(int v,int p){
    if(g[v].size()==1)return a[v];
    ll s=0,m=0;
    for(int i=0;i<g[v].size();i++){
        int u=g[v][i];
        if(u!=p){
            ll x=dfs(u,v);
            if(x<0)return -1;
            m=max(x,m);
            s+=x;
        }
    }
    ll y;
    if(s>=s-m)y=m;
    else y=(s+1)/2;
    if(y<=a[v]&&a[v]<=s)return 2*a[v]-s;
    else return -1;
}
int main(void){
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%lld",a+i);
    if(n==2){
        if(a[0]==a[1])printf("YES\n");
        else printf("NO\n");
        return 0;
    }
    for(int i=0;i<n-1;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        g[--a].push_back(--b);
        g[b].push_back(a);
    }
    for(int i=0;i<n&&r<0;i++)if(g[i].size()>1)r=i;
    if(dfs(r,-1)==0)printf("YES\n");
    else printf("NO\n");
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

	int n;
	cin >> n;
	string s;
	cin >> s;

	char last = s[0];
	int res = 1;
	for(int i = 1; i < n; ++i){
		if(last == s[i]) continue;
		else{
			last = s[i];
			res++;
		}
	}

	cout << res;
    return 0;
}


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

int L[100005],R[100005],n,w[100005];
long long ans;
int main(){
	cin>>n;
	int x;
	for (int i=1;i<=n;i++){
		cin>>x;
		w[x]=i;
		L[i]=i-1;
		R[i]=i+1;
	}
	
	for (int i=1;i<=n;i++){
		int b=L[w[i]],a=L[b];
		int c=R[w[i]],d=R[c];
		if (b!=0) ans+=1ll*(b-a)*(c-w[i])*i;
		if (c!=n+1) ans+=1ll*(d-c)*(w[i]-b)*i;
		
		L[c]=b;
		R[b]=c;
	}
	
	cout<<ans;
	return 0;
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int t = ri();
	std::pair<int, int> a[n];
	for (auto &i : a) {
		i.first = ri() + 1;
		i.second = ri() + i.first;
	}
	std::sort(a, a + n, [] (auto i, auto j) {
		return (int64_t) i.first * j.second + i.second > (int64_t) j.first * i.second + j.second;
	});
	// one
	std::vector<int> adds;
	std::vector<std::pair<int, int > > all;
	for (auto i : a) {
		if (i.first == 1) adds.push_back(i.second);
		else all.push_back(i);
	}
	std::sort(adds.begin(), adds.end());
	std::vector<int64_t> res0(adds.size() + 1);
	for (int i = 0; i < (int) adds.size(); i++) res0[i + 1] = res0[i] + adds[i];
	static int dp[40];
	for (auto &i : dp) i = 2050000000;
	dp[0] = 0;
	for (auto i : all) {
		for (int j = 40; j--; ) {
			if (dp[j] == 2050000000) continue;
			dp[j + 1] = std::min<int>(dp[j + 1], std::min<int64_t>(2050000000, (int64_t) dp[j] * i.first + i.second));
		}
	}
	int res = 0;
	for (int i = 0; i <= (int) adds.size(); i++) for (int j = 0; j < 40; j++) if (dp[j] != 2050000000 && res0[i] + dp[j] <= t)
		res = std::max(res, i + j);
	printf("%d\n", res);
	return 0;
}



Measured memory_bytes: 4340
#include<iostream>
using namespace std;
 
int main(){
    int a,b,i=1;
    cin>>a>>b;
    while(a!=0||b!=0){
if (a>b) swap(a,b);
cout<<a<<" "<<b<<endl;
        i++;
cin>>a>>b;
    }
    return 0;
}


Measured memory_bytes: 3076
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        String S=sc.nextLine();
        String[] number=S.split("/",0);
        number[0]="2018";
        System.out.println(number[0]+"/"+number[1]+"/"+number[2]);


    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

string s;
vector<string> vs;

int main(){
	getline(cin, s);
	stringstream ss;
	string buf;
	string t;
	ss << s;
	while (ss >> buf){
		REP(i, buf.size()){
			if (buf[i] != ','&&buf[i] != '.'){
				t += buf[i];
			}
		}
		if (t.size() >= 3 && t.size() <= 6)vs.push_back(t);
		t.clear();
	}
	REP(i, vs.size()){
		if (i == vs.size() - 1)cout << vs[i] << endl;
		else cout << vs[i] << " ";
	}
}

Measured memory_bytes: 1204
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <sstream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define EPS 1e-12
#define pri_max 60000
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

/*
bool memo[pri_max] = {};
vector<int> pri;
void calc()
{
	for (int i = 2; i < pri_max; i++)
	{
		if (memo[i] == false)
		{
			pri.push_back(i);
			for (int l = i; l < pri_max; l += i)
			{
				memo[l] = true;
			}
		}
	}
}*/
double len(pdd a, pdd b)
{
	return sqrt((b.first - a.first)*(b.first - a.first) + (b.second - a.second)*(b.second - a.second));
}

int main()
{
	vector<pdd> v;
	pdd p;
	while (scanf("%lf,%lf", &p.first, &p.second) != EOF)v.push_back(p);
	double ans = 0;
	FORI(i, 1, v.size() - 1)
	{
		double a = len(v[0], v[i]);
		double b = len(v[0], v[i + 1]);
		double c = len(v[i], v[i + 1]);
		double z = (a + b + c) / 2;
		ans += sqrt(z*(z - a)*(z - b)*(z - c));
	}
	printf("%.7f\n", ans);
}

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

public class Main {
	public static int c = 0;
	static int n;
	static int m;
	static boolean[][] bool;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();
		bool = new boolean[n + 1][n + 1];
		for(int i = 0 ; i < n + 1 ; i++) {
		Arrays.fill(bool[i], false);
		}
		for(int i = 0 ; i < m ; i++) {
			bool[sc.nextInt()][sc.nextInt()] = true;
		}
		sc.close();
			n(1 + "", n);

		System.out.println(c);

	}
	public static void n(String s , int n) {
		if(s.length() == n) {
			c++;
			return;
		}
		for(int i = 1 ; i <= n ; i++) {
			int last = Integer.parseInt(s.charAt(s.length() - 1) + "");
			if(!s.contains(Integer.toString(i)) && (bool[last][i] || bool[i][last]))
					n(s + "" + i , n);
		}


	}
}



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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;

int N;
int D[55];

signed main() {
    cin >> N;
    rep(i, N) {
        cin >> D[i];
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            ans += D[i] * D[j];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int N=2e5+7;
int n,m,p=0,rs[N],rp=0;
std::priority_queue<int,std::vector<int>,std::greater<int> >q;
struct itv{
	int l,r;
	bool operator<(const itv&w)const{return l<w.l;}
	void cal(){
		q.push(r);
		if(q.size()>l)rs[rp++]=q.top(),q.pop();
	}
}is[N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i)scanf("%d%d",&is[i].l,&is[i].r);
	std::sort(is,is+n);
	for(int i=0;i<n;++i)is[i].cal();
	std::sort(rs,rs+rp);
	int ans=q.size(),p=ans+1;
	for(int i=0;i<rp;++i){
		int x=rs[i];
		if(p<x)p=x;
		if(p>m)break;
		++ans,++p;
	}
	printf("%d\n",n-ans);
	return 0;
}

Measured memory_bytes: 3192
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top = 0, S[1000];

void push(int x) {
  S[++top] = x;
}

int pop(void) {
  top--;
  return S[top+1];
}

int main(void) {
  int a, b;
  top = 0;
  char s[100];
  while(scanf("%s",s) != EOF) {
  	
    if(s[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    }
  	
  	else if(s[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    }
  	
  	else if(s[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } 
  	
  	else {
      push(atoi(s));
    }
  }
  printf("%d\n",pop());

  return 0;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define FILE
#define ll long long
#define cn continue
using namespace std;
const ll M = 1e3;
ll n  ,mx = -1e9 , m , a , cnt , ans;
string s , s1;
int main(){
    #ifdef FILEs
        freopen(".in" , "r" , stdin);
        freopen(".out" , "w" , stdout);
    #endif
    cin >> n;
    if( n >= 30 )
        cout << "Yes";
    else
        cout << "No";
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int tc; cin>>tc; while(tc--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    ll a, b, c, d;

    cin>> a>> b>> c>> d;

    cout << max ( a* c, max (a*d, max (b*c, b*d)));
    nl;


    return 0;
}




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

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

    int ans = 0;
    int minv = 2 * 1e5;
    for (int i = 0; i < N; i++) {
        int p;
        cin >> p;
        if (p <= minv) {
            minv = p;
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

template<class T>
inline bool chmax(T &a, const T b) { return a < b && (a = b, true); }

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, T;
	cin >> N >> T;

	vector<int> A(N), B(N);
	for (int i = 0; i < N; i++) cin >> A[i] >> B[i];

	auto dp_f = make_vec(N + 1, T, 0);
	auto dp_b = make_vec(N + 1, T, 0);

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < T; j++) {
			chmax(dp_f[i + 1][j], dp_f[i][j]);
			if (j > A[i]) chmax(dp_f[i + 1][j - A[i]], dp_f[i][j] + B[i]);
		}
	}
	DMP(dp_f);

	for (int i = N - 1; i >= 0; i--) {
		for (int j = 0; j < T; j++) {
			chmax(dp_b[i][j], dp_b[i + 1][j]);
			if (j > A[i]) chmax(dp_b[i][j - A[i]], dp_b[i + 1][j] + B[i]);
		}
	}
	DMP(dp_b);

	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < T; j++) {
			chmax(ans, dp_f[i][j] + dp_b[i + 1][T - 1 - j] + B[i]);
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 70912
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

//繰り返し二乗
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M) % M;
}

int main() {
    ll n,a,b; cin>>n>>a>>b;
    ll ans=RepeatSquaring(2,n,MOD)-1;ans%=MOD;
    if(b>n/2)b=n-b;
    if(a>n/2)a=n-a;
    ll B=1;
    rep(i,b){
        B*=(n-i)*RepeatSquaring(i+1,MOD-2,MOD)%MOD;
        B%=MOD;
        if (B==0)break;
    }
    ll A=1;
    rep(i,a){
        A*=(n-i)*RepeatSquaring(i+1,MOD-2,MOD)%MOD;
        A%=MOD;
    }
    cout<<((ans-A-B)%MOD+MOD)%MOD<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}

int main(void) {
    
    
    

    string s;
    cin>>s;
    cout<<stringcount(s,'1')<<endl;


    
}


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

std::vector<int> gph[100001];

int dp[100001];

int dfs(int u) {
    int mx1(0);
    for(int& v: gph[u]) {
        if (dp[v] != 0) {
            mx1 = max(mx1, dp[v]);
            continue;
        }
        dp[v] = dfs(v) + 1;
        mx1 = max(mx1, dp[v]);
    }
    return mx1;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m, x, y;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        gph[x].push_back(y);
    }
    int mx(0);
    for (int i = 1; i <= n; i++) {
        if (dp[i] != 0) {
            mx = max(dp[i], mx);
            continue;
        }
        mx = max(dfs(i), mx);
    }
    cout << mx << "\n";
    return 0;
}

Measured memory_bytes: 8192
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    h = list(map(int, input().split()))
    ans = h[0]

    for i in range(1, n):
        ans += max(0, h[i] - h[i - 1])

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
A=list(map(int,input().split()))
l=[0]*60
for i in A:
    s=str(bin(i))[2:]
    for j in range(len(s)):
        if s[-j-1]=="1":
            l[j]+=1
a=0
for i in range(60):
    a=(a+2**i*l[i]*(N-l[i]))%(10**9+7)
print(a)

Measured memory_bytes: 124568