akhauriyash/Code-Regression huggingface dataset:
//---------- Begin IO utilities ----------
#[macro_use]
#[allow(dead_code, unused_macros)]
mod io {
    // Thanks to https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
    macro_rules! input {
        ($($r:tt)*) => {
            let s = {
                use std::io::Read;
                let mut s = String::new();
                std::io::stdin().read_to_string(&mut s).unwrap();
                s
            };
            let mut iter = s.split_whitespace();
            input_inner!{iter, $($r)*}
        };
    }
    macro_rules! input_inner {
        ($iter:expr) => {};
        ($iter:expr, ) => {};
        ($iter:expr, $var:tt : $t:tt $($r:tt)*) => {
            let $var = read_value!($iter, $t);
            input_inner!{$iter $($r)*}
        };
    }
    macro_rules! read_value {
        ($iter:expr, ( $($t:tt),* )) => {
            ( $(read_value!($iter, $t)),* )
        };
        ($iter:expr, [ $t:tt ; $len:expr ]) => {
            (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        };
        ($iter:expr, chars) => {
            read_value!($iter, String).chars().collect::<Vec<char>>()
        };
        ($iter:expr, usize1) => {
            read_value!($iter, usize) - 1
        };
        ($iter:expr, $t:ty) => {
            $iter.next().unwrap().parse::<$t>().expect("Parse error")
        };
    }

    macro_rules! p {
        ($v:expr) => {
            println!("{}", $v);
        };
        ($v:expr, $($t:expr),*) => {
            print!("{}", $v);
            ($(print!(" {}", $t)),*);
            println!();
        }
    }

    macro_rules! ps {
        ($v:expr) => {
            println!("{}", $v.iter().collect::<String>());
        };
        ($v:expr, $($t:expr),*) => {
            print!("{}", $v.iter().collect::<String>());
            ($(print!(" {}", $t.iter().collect::<String>())),*);
            println!();
        }
    }

    pub fn pv<T: std::string::ToString>(v: &[T], sep: &str) {
        let s = v.iter().map(|e| e.to_string()).collect::<Vec<String>>().join(sep);
        println!("{}", s);
    }

    pub fn pvs(v: &[Vec<char>], sep:&str) {
        let s = v.iter().map(|e| e.iter().collect::<String>()).collect::<Vec<String>>().join(sep);
        println!("{}", s);
    }
}
//---------- End IO utilities ----------

//---------- Start solve ----------
#[allow(unused_imports)]
use io::*;
fn main() {
    input!{
        a: usize,
        b: usize,
        n: usize
    }
    let bb = std::cmp::min(b-1, n);
    p!(a * bb / b - a * (bb / b));
}


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

struct segtree {
    int n = 1;
    vector<bitset<26>> t;
    segtree(int k,string s){
        while(n < k) n*=2;
        t.resize(2*n-1);
        rep(i,s.size()) {
            int now = s[i]-'a';
            t[i+n-1].set(now);
        }
        for(int i = n-2; i >= 0; i--) {
            t[i] = t[i*2+1]|t[i*2+2];
        }
    }
    void query1(int i,char no) {
        int now = no-'a';
        i += n-1;
        t[i] = bitset<26>(0);
        t[i].set(now);
        while(i > 0) {
            i = (i-1)/2;
            t[i] = t[i*2+1]|t[i*2+2];
        }
    }
    auto preque(int a,int b,int k,int l,int r) {
        if(r <= a || b <= l) return bitset<26>(0);
        else if(a <= l && r <= b) return t[k];
        else {
            auto vl = preque(a,b,k*2+1,l,(l+r)/2);
            auto vr = preque(a,b,k*2+2,(l+r)/2,r);
            return vl|vr;
        }
    }
    int query2(int l,int r) {
        auto a = preque(l,r+1,0,0,n);
        return a.count();
    }
};

int main() {
    int n,q;
    string s;
    cin >> n >> s >> q;
    segtree seg(n,s);
    vector<int> ans;
    rep(j,q) {
        int i;
        cin >> i;
        if(i == 1) {
            int a;
            char b;
            cin >> a >> b;
            a--;
            seg.query1(a,b);
        } else {
            int a,b;
            cin >> a >> b;
            a--; b--;
            ans.push_back(seg.query2(a,b));
        }
    }
    for(int i : ans) {
        cout << i << endl;
    }
}

Measured memory_bytes: 9604
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll t;
    ll a,b;
    scanf("%lld",&t);
    ll ans1=1,ans2=1;
    ll m,n;
    while(t--){
        m = 1;
        n = 1;
        scanf("%lld %lld",&a,&b);
        if(a<ans1){
            m = ans1/a;
            if(ans1%a!=0){
                m++;
            }
        }
        if(b<ans2){
            n = ans2/b;
            if(ans2%b!=0){
                n++;
            }
        }
        m = max(m,n);
        ans1 = m*a;
        ans2 = m*b;
    }
    ll ans=ans1+ans2;
    cout<<ans<<endl;
    return 0;
}






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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  char str[3][101];

  scanf("%s %s %s",str[0],str[1],str[2]);

  //現在のターン
  int i=0;

  //各プレイヤーの捨てカードの数

  int cnt[3]={ };
  
  while(1){

  
    if(strlen(str[i])==cnt[i]){
      break;
    }else{

      int tmp=i;
      
      i=int((str[i][cnt[i]]-'a'));

      
      cnt[tmp]++;
      
    }
  }

  printf("%c\n",(i+'A'));
  
  return 0;

}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = [0]*n
ans[0] = a[0]*2
for i in range(1,n):
    ans[i] = (a[i]-ans[i-1]//2)*2
d = ans[0]//2+ans[n-1]//2-a[0]
ngo = 1
for i in range(n):
    ans[i] += -ngo*d
    ngo *= -1
s = ''
for i in range(n):
    s += str(ans[(n-1+i)%n])+' '
print(s[:-1])

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

const int N = 109;
int a[N], ans, n;
unordered_map<int, int> mp;
int main() {
	//freopen("input.txt", "r", stdin);
	cin >> n;
	mp.clear();
	set<int> s;
	for (int i = 0; i < n; i++) { 
		int x;
		cin >> a[i];
		//mp[a[i]]++;
		//s.insert(x);
	}

	/*int nn = 0;
	for (auto it = s.begin(); it!=s.end(); it++) {
		a[nn] = *it;
		++nn;
	}*/



	

	//sort(a, a+n);
	/*cout << '\n';

	for (int i = 1; i < n; i++) { 
		cout << a[i] << " ";
	}
	cout << endl;*/
	ans = 0;
	
	sort(a, a+n);
	//n = nn;
	int i = 0, j, k;
	for (int i =0;i<n;i++) {
		j = i + 1;
		while(a[j] == a[i])
			++j;
		for( ;j<n;j++) {
			k = j + 1;
			while(a[j] == a[k])
				++k;
			for (;k<n;k++) {
				if(a[i] + a[j] > a[k])
					++ans;
			}
		}
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int max(int a, int b);
int lcs( char *, char *, int, int);
 
int main(){
  char x[1001], y[1001];
  int m, n, t, k, i;
 
  scanf("%d", &k);
  for(i = 0;i < k;i++){
    scanf("%s %s", x, y);
    m = strlen(x);
    n = strlen(y);
    t = lcs( x, y, m, n );
    printf("%d\n", t);
  }
 
  return 0;
}

int lcs( char *x, char *y, int m, int n ){
   int l[m+1][n+1];
   int i, j;
 
   for (i=0; i<=m; i++)
   {
     for (j=0; j<=n; j++)
     {
       if (i == 0 || j == 0)
         l[i][j] = 0;
 
       else if (x[i-1] == y[j-1])
         l[i][j] = l[i-1][j-1] + 1;
 
       else
         l[i][j] = max(l[i-1][j], l[i][j-1]);
     }
   }
 
   return l[m][n];
}
 
int max(int a, int b){
    return (a > b)? a : b;
}

Measured memory_bytes: 4512
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

i64 count(i64 N) {
  i64 ans = 0;
  while(N != 0) {
    ans += N / 5;
    N /= 5;
  }
  return ans;
}

int main(int argc, char *argv[]) {
  i64 N;
  cin >>  N;

  if(N % 2 == 0) {
    cout << count(N / 2) << endl;
  }
  else {
    cout << 0 << endl;
  } 
  
  return 0;
}


Measured memory_bytes: 256
INF = 10**30

class Rmax():
	def __init__(self, size):
		#the number of nodes is 2n-1
		self.n = 1
		while self.n < size:
			self.n *= 2
		self.node = [-INF] * (2*self.n-1)

	def Access(self, x):
		return self.node[x+self.n-1]

	def Update(self, x, val):
		x += self.n-1
		self.node[x] = val
		while x > 0:
			x = (x-1)//2
			self.node[x] = max(self.node[2*x+1], self.node[2*x+2])
		return

	#[l, r)
	def Get(self, l, r):
		L, R = l+self.n, r+self.n
		s = -INF
		while L<R:
			if R & 1:
				R -= 1
				s = max(s, self.node[R-1])
			if L & 1:
				s = max(s, self.node[L-1])
				L += 1
			L >>= 1
			R >>= 1
		return s

class Rmin():
	def __init__(self, size):
		#the number of nodes is 2n-1
		self.n = 1
		while self.n < size:
			self.n *= 2
		self.node = [INF] * (2*self.n-1)

	def Access(self, x):
		return self.node[x+self.n-1]

	def Update(self, x, val):
		x += self.n-1
		self.node[x] = val
		while x > 0:
			x = (x-1)//2
			self.node[x] = min(self.node[2*x+1], self.node[2*x+2])
		return

	#[l, r)
	def Get(self, l, r):
		L, R = l+self.n, r+self.n
		s = INF
		while L<R:
			if R & 1:
				R -= 1
				s = min(s, self.node[R-1])
			if L & 1:
				s = min(s, self.node[L-1])
				L += 1
			L >>= 1
			R >>= 1
		return s

n, k = map(int, input().split())
p = list(map(int, input().split()))
ma, mi = Rmax(n), Rmin(n)
for i in range(n):
	ma.Update(i, p[i])
	mi.Update(i, p[i])
ans = n-k+1
same = set()
tmp = 0
for i in range(1, n):
	if p[i-1] < p[i]:
		tmp += 1
	else:
		tmp = 0
	if tmp >= k-1:
		same.add(i-k+1)
ans -= max(0, len(same)-1)
for i in range(k, n):
	if p[i-k] < mi.Get(i-k+1, i) and ma.Get(i-k+1, i) < p[i]:
		if not i-k in same and not i-k+1 in same:
			ans -= 1
print(ans)

Measured memory_bytes: 111608
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        int count = 0;
        Arrays.sort(array);
        int a = array[n / 2 - 1];
        int b = array[n / 2];
        
        if (a == b) {
            System.out.println(0);
        } else {
            System.out.println(b - a);
        }
    }
}


Measured memory_bytes: 52716
#include <bits/stdc++.h>
using namespace std;
#define MAXH 102
#define MAXW 102
#define MAXN 10005
int h, w, n, a[MAXN], m[MAXH][MAXW];
int main() {
    cin >> h >> w >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    int k = 1;
    for(int i = 0; i < h; ++i) {
        //cout << i << endl;
        if(i%2) {
            //cout<<"impar\n";
            for(int j = w - 1; j >= 0; --j) {
                if(a[k] == 0) {
                    k++;
                }
                m[i][j] = k;
                a[k]--;
            }
        } else {
            for(int j = 0; j < w; ++j) {
                if(a[k] == 0) {
                    k++;
                }
                m[i][j] = k;
                a[k]--;
            }
        }
    }
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            cout << m[i][j] << ' ';
        }
        cout << "\n";
    }
}

Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
 int n;
 cin>>n;
 if(n>63)cout<<64<<endl;
 else if(n>31)cout<<32<<endl;
 else if(n>15)cout<<16<<endl;
 else if(n>7)cout<<8<<endl;
 else if(n>3)cout<<4<<endl;
 else if(n>1)cout<<2<<endl;
 else if(n==1)cout<<1<<endl;
}

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

int main(void){
    int n;cin>>n;
    int sum=0;
    int x[n]={0};
    for(int i=0;i<n;i++){
        cin>>x[i];
        sum+=x[i];
    }
    int p=round(double(sum)/n);
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=((x[i]-p)*(x[i]-p));
    }
    cout<<ans<<endl;
}


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

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

Measured memory_bytes: 384
/*
           Nothing is absolute.
     This is the only absolute truth.
*/

#include<bits/stdc++.h>

using namespace std;

using ull = unsigned long long;
using ll = long long;

#define READ freopen("in.txt", "r", stdin)
#define ROUT freopen("out.txt", "w", stdout)
#define pb push_back
#define endl '\n'

void fasterIO()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

void fileIO()
{
    READ;
    //ROUT;
}

bool check_one(string s) {
    string ss = s;
    reverse(begin(ss), end(ss));
    return (s==ss)?true:false;
}

bool check_two(string s) {
    int n = s.size();
    string ss, st;
    for(int i = 0; i<(n-1)/2; i++) {
        ss+=s[i];
        st+=s[i];
    }
    reverse(begin(ss), end(ss));
    return (st==ss)?true:false;
}

bool check_three(string s) {
    int n = s.size();
    string ss, st;
    for(int i = ((n+3)/2) - 1; i<n; i++) {
        ss+=s[i];
        st+=s[i];
    }
    reverse(begin(ss), end(ss));
    return (st==ss)?true:false;
}

int main()
{
    //fileIO();
    fasterIO();
    //Siv();

    string st;
    cin>>st;

    if(check_one(st) && check_two(st) && check_three(st)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    exit(0);
}


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

long long A[] = { 0, 2, 3, 5, 8, 13, 21, 34 };
long long DP[ 10 ];
long long tmp[ 10 ];
const int MOD = 1000000007;

int main()
{
int i;
int j;
int H;
int W;
int K;
long long a;
long long b;

	cin >> H;
	cin >> W;
	cin >> K;

	DP[ 1 ] = 1;
	for( i = 0; i < H; i++ )
	{
		for( j = 1; j <= W; j++ )
		{
			a = 1;
			b = 1;
			if( j > 2 ) a = A[ j - 2 ];
			if( W - j > 1 ) b = A[ W - j - 1 ];

			tmp[ j ] = DP[ j ] * a * b;
			tmp[ j ] %= MOD;

			if( j > 1 )
			{
				a = 1;
				b = 1;
				if( j > 3 ) a = A[ j - 3 ];
				if( W - j > 1 ) b = A[ W - j - 1 ];

				tmp[ j ] += DP[ j - 1 ] * a * b;
				tmp[ j ] %= MOD;
			}

			if( j < W )
			{
				a = 1;
				b = 1;
				if( j > 2 ) a = A[ j - 2 ];
				if( W - j > 2 ) b = A[ W - j - 2 ];

				tmp[ j ] += DP[ j + 1 ] * a * b;
				tmp[ j ] %= MOD;
			}
		}

		for( j = 1; j <= W; j++ )
		{
			DP[ j ] = tmp[ j ];
			tmp[ j ] = 0;
		}
	}

	cout << DP[ K ] << endl;

	return 0;
}






Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

class WF{
	public:
	ll N;
	ll makeFlg;
	vector<vector<ll> >cost;
	WF(ll _N, ll INF = 1145141919){
		N = _N + 1;
		cost = vector<vector<ll> >(N, vector<ll>(N, INF));
		makeFlg = 0;
	}
	void add(ll a, ll b, ll c){
		cost[a][b] = min(cost[a][b], c);
		makeFlg = 0;
	}
	void make(){
		if(makeFlg)return;
		makeFlg = 1;
		for(ll i = 0; i < N; i++){
			for(ll j = 0; j < N; j++){
				for(ll k = 0; k < N; k++){
					cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);
				}
			}
		}
	}
	ll get(ll a, ll b){
		if(makeFlg == 0)make();
		return cost[a][b];
	}
};

int main(){

	ll H, W;
	cin >> H >> W;
	WF wf(10);
	ll ans = 0;
	for(ll i = 0; i < 10; i++){
		for(ll j = 0; j < 10; j++){
			ll c;
			cin >> c;
			wf.add(i, j, c);
		}
	}
	for(ll i = 0; i < H; i++){
		for(ll j = 0; j < W; j++){
			ll a = 0;
			cin >> a;
			if(a < 0)continue;
			ans += wf.get(a, 1);
		}
	}	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
 /*   double t,x;
    cin>>t>>x;
    t=t/x;
    cout<<t*1.0<<'\n';*/
  
   /* int a,b,c;
    cin>>a>>b>>c;
    cout<<(a*b)/2<<'\n';*/

   /* int d;
    cin>>d;
    if(d==22){
        cout<<"Christmas Eve Eve Eve"<<'\n';
    }else if(d==23){
        cout<<"Christmas Eve Eve"<<'\n';
    }else if(d==24){
        cout<<"Christmas Eve"<<'\n';
    }else if(d==25){
        cout<<"Christmas"<<'\n';
    }*/

   /* int x,y;
    cin>>x>>y;
    y=y/2;
    cout<<x+y<<'\n';*/

   /* int n,a,b;
    cin>>n;
    if(n==1){
        cout<<"Hello World"<<'\n';
    }else{
        cin>>a>>b;
        cout<<a+b<<'\n';
    }*/

   /* int n;
    cin>>n;
    if(n==111){
        cout<<999<<'\n';
    }else if(n==119){
        cout<<991<<'\n';
    }else if(n==199){
        cout<<911<<'\n';
    }else if(n==191){
        cout<<919<<'\n';
    }else if(n==999){
        cout<<111<<'\n';
    }else if(n==911){
        cout<<199<<'\n';
    }else if(n==919){
        cout<<191<<'\n';
    }else if(n==991){
        cout<<119<<'\n';
    }*/

    int a[5];
    for(int i=0; i<3; i++){
        cin>>a[i];
    }
    sort(a,a+3,greater<int>());
    a[0]=a[0]*10;
    a[0]=a[0]+a[1]+a[2];
    cout<<a[0]<<'\n';
}

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

int main(){
  int q;
  deque<int>Q;
  cin>>q;
  while(q--){
    int a,b,c;
    cin>>a>>b;
    if(!a){
      cin>>c;
      if(b)Q.push_back(c);
      else Q.push_front(c);
    }
    else if(a==1)cout<<Q[b]<<endl;
    else{
      if(b)Q.pop_back();
      else Q.pop_front();
    }
  }
}



Measured memory_bytes: 4528
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};
 
struct edge { int to, cost; };
vector<edge> G[101010];
int N, M;
int x[101010];
set<int> se;
 
bool dfs(int i)
{
  // if (x[i] != LLONG_MIN) return true;
  // cout << "dfs " << i << endl;
  for (edge e : G[i]) {
    // cout << "edge.to " << e.to << endl;
    // cout << "edge.c " << e.cost << endl;
    if (x[e.to] != LLONG_MIN && x[e.to] != x[i] + e.cost) {
      // cout << "in" << endl;
      return false;
    } else if (x[e.to] != LLONG_MIN && x[e.to] == x[i] + e.cost) {
      continue;
    } else {
      x[e.to] = x[i] + e.cost;
      // cout << "x[" << e.to << "] = " << x[e.to] << endl;
      if (!dfs(e.to)) return false;
    }
  }
  return true;
}
 
signed main()
{
  cin >> N >> M;
  REP(i,M) {
    int L, R, D;
    cin >> L >> R >> D;
    G[L].push_back((edge){R, D});
    G[R].push_back((edge){L, -D});
    se.insert(L);
    se.insert(R);
  }
 
  fill(x, x + 101010, LLONG_MIN);
 
  for (auto it=se.begin(); it!=se.end(); it++) {
    if (x[*it] == LLONG_MIN) {
      // cout << "enter " << *it << endl;
      x[*it] = 0;
      if (!dfs(*it)) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
 
  // REP(i,10) cout << x[i] << " ";
}

Measured memory_bytes: 21376
#include<bits/stdc++.h>
using namespace std;
int n,a[100003],t,minn=2147483647,ans,maxn;
int main(){
	cin>>n>>t;
	for(int i=0;i<n;i++)cin>>a[i];
	minn=a[0];
	for(int i=1;i<n;i++){
		minn=min(a[i],minn);
		if(maxn==a[i]-minn)
			ans++;
		if(maxn<a[i]-minn)
			maxn=a[i]-minn,
			ans=1;
	}
	cout<<ans;
}

Measured memory_bytes: 640
#include <stdio.h>
 
int main(){
	int i, N;
	double sum = 0, sa, T;
	double t[200001];
 
	scanf("%d %lf", &N, &T);
 
	for(i = 1; i <= N; i++) {
		scanf("%lf", &t[i]);
	}
 
	for(i = 1; i < N; i++) {
		sa = t[i + 1] - t[i];
		if(sa >= T) {
			sum += T;
		}
		if(sa < T) {
			sum += sa;
		}
	}
        sum += T;
	printf("%d", (int)sum);
 
}

Measured memory_bytes: 1664
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
const int MAX_N = 100;
bool matrix[MAX_N][MAX_N];

class DirectedGraph {
    struct edge {
        int to;
        int cost;
    };

public:
    int V;
    vector<vector<edge>> G;
    vector<int> before;

    DirectedGraph(int v) : G(v), V(v), before(v, -1) {
    }

    void add_edge(int u, int v, int cost) {
        G[u].push_back({v, cost});
    }

    void clear() {
        for (int i = 0; i < V; i++) before[i] = -1;
    }

    void history(int goal) {
        int bf = before[goal];
        int af = goal;
        while (bf != -1) {
            matrix[bf][af] = false;
            matrix[af][bf] = false;

            af = bf;
            bf = before[bf];
        }
    }

    // O(E * logV)
    vector<int> dijkstra(int s) {
        vector<int> d(V, INF);
        d[s] = 0;

        priority_queue<P, vector<P>, greater<>> que;
        que.push({0, s});

        while (!que.empty()) {
            P  p = que.top(); que.pop();
            int v = p.second;
            if (d[v] < p.first) continue;

            for (edge e : G[v]) {
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    before[e.to] = v;
                    que.push({d[e.to], e.to});
                }
            }
        }

        return move(d);
    }
};


signed main() {
    int N, M;
    cin >> N >> M;

    DirectedGraph dg = DirectedGraph(N);

    for (int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        dg.add_edge(a, b, c);
        dg.add_edge(b, a, c);
        matrix[a][b] = true;
        matrix[b][a] = true;
    }

    for (int i = 0; i < N; i++) {
        dg.dijkstra(i);
        for (int j = 0; j < N; j++) {
            if (i == j) continue;
            dg.history(j);
        }
        dg.clear();
    }

    int ret = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i; j < N; j++) {
            if (matrix[i][j]) ret++;
        }
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 384
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  int n; cin>>n;
  int ans;
  if(n<=111)ans=111;
  else if(n<=222)ans=222;
  else if(n<=333)ans=333;
  else if(n<=444)ans=444;
  else if(n<=555)ans=555;
  else if(n<=666)ans=666;
  else if(n<=777)ans=777;
  else if(n<=888)ans=888;
  else if(n<=999)ans=999;
  else ans=1111;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
using namespace std;
#define Rep(i,n) for(int i = 0; i < n; ++i)
#define For(i, s, e) for(int i = s; i <= e; ++i)
typedef long long ll;
long K, N;
long A[100001];

int main()
{
	scanf("%ld %ld", &N, &K);
	int a = (N - 1) / (K - 1);
	if (0 != (N - 1) % (K - 1))
		++a;
	printf("%d\n", a);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define all(c) (c).begin(), (c).end()
#define cpresent(c,x) ((c).find(x) != (c).end()) 
#define vpresent(c,x) (find(all(c),x) != (c).end())
#define endl '\n'
#ifdef LOCAL
#include "/home/iggaboi/Desktop/CP/debug.h"
#else
#define debug(x...)
#endif
using namespace std;

int n, q;

void solve(){
    cin >> n;
    int sum = 0;
    vector<int> freq(100069, 0); 
    for(int i = 0, inp; i < n; ++i){
        cin >> inp;
        freq[inp]++;
        sum += inp;
    }
    cin >> q;
    while(q--){
        int b, c;
        cin >> b >> c;
        sum -= freq[b]*b;
        sum += freq[b]*c;
        freq[c] += freq[b];
        freq[b] = 0;
        cout << sum << endl;
    }
}

int32_t main(){
	ios_base::sync_with_stdio(false),cin.tie(nullptr);
	// int t; cin >> t;
	// while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 3872
def main():
    n, m = map(int, input().split())
    a = []
    c = []
    dp = [10 ** 7 for j in range(2 ** n)]
    dp[0] = 0
    for _ in range(m):
        a, b = map(int, input().split())
        sc = list(map(int, input().split()))
        c = 0
        for j in sc:
            c += 2 ** (j - 1)
        for j in range(2 ** n):
            dp[j | c] = min(dp[j | c], dp[j] + a)

    if dp[2 ** n - 1] == 10 ** 7:
        print(-1)
    else:
        print(dp[2 ** n - 1])


main()


Measured memory_bytes: 3188
from sys import stdin
r, g, b, n = [int(x) for x in stdin.readline().rstrip().split()]

ans=0
for i in range(int(n/r)+1):
  for j in range(int(n/g)+1):
    if( n < (r*i)+(g*j) ):
      continue
    if( 0 == ((n-((r*i)+(g*j)))%b) ):
      #print(i,j,r*i,g*j)
      ans +=1

print(ans)


Measured memory_bytes: 41068
#!python3

LI = lambda: list(map(int, input().split()))

# input
X, N = LI()
P = LI()


def main():
    s = set(P)
    for i in range(1000):
        if X - i not in s:
            print(X - i)
            return
        if X + i not in s:
            print(X + i)
            return


if __name__ == "__main__":
    main()


Measured memory_bytes: 9180
/**
*    author:  boutarou
*    created: 02.08.2020 21:14:06
**/

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int>w(n + 1), r(n + 1);
    w[0] = 0;
    rep(i, s.size()) {
        if (s[i] == 'W') w[i + 1] = w[i] + 1;
        else w[i + 1] = w[i];
    }
    r[0] = 0;
    rep(i, s.size()) {
        if (s[i] == 'R') r[i + 1] = r[i] + 1;
        else r[i + 1] = r[i];
    }
    int ans = n;
    for (int i = -1; i < n; i++) {
        int lw = w[i + 1], lr = r[i + 1];
        int rw = w[n] - w[i + 1], rr = r[n] - r[i + 1];
        int res;
        res = max(lw, rr);
        ans = min(ans, res);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5228
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  ll n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  rep(i, m) {
    int na, nb;
    cin >> na >> nb;
    na--, nb--;
    a[i] = na;
    b[i] = nb;
  }
  vector<vector<int>> V(n);
  rep(i, n) V[i].push_back(i);
  vector<int> idx(n);
  rep(i, n) idx[i] = i;

  ll cnt = n * (n - 1) / 2;
  vector<ll> ans;
  ans.push_back(cnt);

  reverse(all(a));
  reverse(all(b));

  rep(i, m - 1) {
    if(idx[a[i]] == idx[b[i]]) {
      ans.push_back(cnt);
      continue;
    }

    ll sza = (ll)V[idx[a[i]]].size();
    ll szb = (ll)V[idx[b[i]]].size();
    cnt -= sza * szb;
    ans.push_back(cnt);

    int addto, removefrom;
    if(sza <= szb) {
      addto = idx[b[i]];
      removefrom = idx[a[i]];
    } else {
      addto = idx[a[i]];
      removefrom = idx[b[i]];
    }
    for(auto x : V[idx[removefrom]]) {
      V[idx[addto]].push_back(x);
      idx[x] = idx[addto];
    }
    V[removefrom].clear();
  }

  reverse(all(ans));
  rep(i, m) printf("%lld\n", ans[i]);
  return 0;
}


Measured memory_bytes: 12916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int A, B;
	cin >> A >> B;
	
	if (A == 1) A = 14;
	if (B == 1) B = 14;

	if (A > B) co("Alice");
	else if (A < B) co("Bob");
	else co("Draw");

	Would you please return 0;
}

Measured memory_bytes: 256
N = int(input())
a = [int(input())-1 for i in range(N)]
visited = [False]*N
now = 0
ans = 0
while now != 1:
    if visited[now]:
        ans = -1
        break
    visited[now] = True
    now = a[now]
    ans += 1
print(ans)


Measured memory_bytes: 7888
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
bool pri[2222222];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll k;
  vi prime;
  prime.pb(2);
  pri[2]=true;
  for(int i=3;i<=1299709;i++){
    bool hoge=true;
    for(int j=2;j<=sqrt(i);j++)if(i%j==0){hoge=false;break;}
    if(hoge){pri[i]=true;prime.pb(i);}
  }
  while(cin>>k,k){
    if(pri[k])cout<<0<<endl;
    else{
      auto lb=lower_bound(ALL(prime),k);
      cout<<(*lb-*(lb-1))<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 4872
a, b, c = map(int, input().split())

if a == b and a == 5:
    if c == 7:
        print("YES")
    else:
        print("NO")
elif b == c and b == 5:
    if a == 7:
        print("YES")
    else:
        print("NO")
elif a == c and c == 5:
    if b == 7:
        print("YES")
    else:
        print("NO")
else:
    print("NO")


Measured memory_bytes: 3060
input()
ai = [int(i) for i in input().split(" ")]
ai.sort()
ai = tuple((j ,a) for j,a in enumerate(reversed(ai)))
alice=sum([ a for j,a in list(filter(lambda x: x[0]%2 == 0, ai))])
bob=sum([ a for j,a in list(filter(lambda x: x[0]%2 == 1, ai))])
print (alice - bob)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#define rep(i,n) for(long long i=1;i<n+1;i++)

using namespace std;
using ll = long long;

int main(void)
{
    ll n,k,ans;
    cin>>n>>k;
    if(k%2==1)
    {
        ll s  = 0;
        rep(i,n)
        {
            if(i%k==0) s++;
        }
        ans=s*s*s;
    }else{
        ll t,l=0;
        rep(i,n)
        {
            if(i%k==k/2) t++;
        }

    
        rep(i,n)
        {
            if(i%k==0) l++;
        }
        ans=t*t*t+l*l*l;
    }

    cout<<ans<<endl;


    
    return 0;
}


Measured memory_bytes: 256
integer(16) X,Y,Z,K,t
integer(16),allocatable,dimension(:)::xi,yi,zi
integer(16),allocatable,dimension(:)::xy,xyk
integer(16),allocatable,dimension(:)::xyz
read*,X,Y,Z,K
allocate(xi(x),yi(y),zi(z))
read*,xi
read*,yi
read*,zi
allocate(xy(x*y))
allocate(xyk(k))
do i=1,x
  do j=1,y
    xy(x*(j-1)+i)=xi(i)+yi(j)
  end do
end do

call heapsort(x*y,xy)

if(x*y>K)then
  do i=1,K
    xyk(i)=xy(x*y-i+1)
  end do
  t=k*z
  allocate(xyz(t))
  do i=1,K
    do j=1,z
      xyz((j-1)*k+i)=xyk(i)+zi(j)
    end do
  end do
  
  call heapsort(k*z,xyz)
  do i=1,k
    print"(i0)",xyz(k*z-i+1)
  end do
else
  t=x*y*z
  allocate(xyz(t))
  do i=1,x*y
    do j=1,z
      xyz((j-1)*x*y+i)=xy(i)+zi(j)
    end do
  end do
  
  call heapsort(x*y*z,xyz)
  
  do i=1,k
  print"(i0)",xyz(x*y*z-i+1)
  end do
endif

contains

subroutine heapsort(n,array)
  implicit none
  integer(16),intent(in) :: n
  integer(16),intent(inout) :: array(1:n)
  
  integer(16)::i,k,j,l
  integer(16):: t

  if(n.eq.1)return

  l=n/2+1
  k=n
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k.eq.1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j.le.k)
        if(j.lt.k)then
           if(array(j).lt.array(j+1))j=j+1
        endif
        if (t.lt.array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo
  return
end subroutine heapsort
end

Measured memory_bytes: 62976
#include <iostream>

using namespace std;

int main()
{
  int a,b,c,d = 0; 
  cin >> a >> b >> c >> d;
  
  if ((a + b) > (c + d)){
    cout << "Left" << endl;
  }
  else if ((a + b) < (c + d)){
  	cout << "Right" << endl;  
  }
  else{
    cout << "Balanced" << endl;
  }
}

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

void push(int);
int pop(void);
int S[1000];

int top;

int main()
{
  char c[1000];
  int a,x,y,top,ans;

  top=0;

  while(scanf("%s",c)!=EOF)
    {
      if(c[0] == '+')
	{
	  x=pop();
	  y=pop();
	  push(x+y);
	}
      else if(c[0] == '-')
	{
	  x=pop();
	  y=pop();
	  push(y-x);
	}
      else if(c[0] == '*')
	{
	  x=pop();
	  y=pop();
	  push(x*y);
	}
      else
	{
	  a=atoi(c);
	  push(a);
	}
    }

  printf("%d\n",pop());

  return 0;
}

void push(int x)
{
  if(top >= 1000-1)
    {
      printf("error(over flow)\n");
    }
  top++;
  S[top]=x;
}

int pop(void)
{
  if(top == 0)
    {
      printf("error(over flow)\n");
    }
  top--;
  
  return S[top+1];
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  auto $ = [](unsigned i, unsigned ci, unsigned j, unsigned cj) {
    return i * 3000 * 18 * 3000 + ci * 18 * 3000 + j * 3000 + cj;
  };
  map<unsigned, long long> mp;
  auto dfs = [&](auto&& self, int i, int ci, int j, int cj) -> long long {
    if (j - i == 1) {
      return ci * a[i] + cj * a[j];
    }
    auto key = $(i, ci, j, cj);
    if (mp.count(key)) {
      return mp[key];
    }
    long long res = 1e18;
    for (int k = i + 1; k < j; ++k) {
      auto cur = self(self, i, ci, k, ci + cj);
      cur -= (ci + cj) * a[k];
      cur += self(self, k, ci + cj, j, cj);
      res = min(res, cur);
    }
    return mp[key] = res;
  };
  cout << dfs(dfs, 0, 1, n - 1, 1) << '\n';
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

int main() {
	IN(LL, n, m, v, p);
	vector<LL> a(n), s(n + 1);
	cin >> a;
	sort(ALL(a));
	inc(i, n) { s[i + 1] = s[i] + a[i]; }
	
	LL ans = p;
	inc(i, n - p) {
		if(a[i] + m < a[n - p]) { continue; }
		
		if(v <= p + i) { ans++; continue; }
		
		if(s[n - p + 1] - s[i] - a[i] * (n - p + 1 - i) <= m * (n - v)) { ans++; }
	}
	OUT(ans);
}


Measured memory_bytes: 1792
N, T = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

c = Float::INFINITY
af = A.inject([]){|ar, x| c = c < x ? c : x; ar << c}
ab = A.reverse.inject([]){|ar, x| c = c > x ? c : x; ar << c}.reverse
mx = ab.zip(af).uniq.map{|i, j| i - j}
puts mx.count(mx.max)

Measured memory_bytes: 19700
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#include <list>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;

int main(void){
    int n,k;
    cin>>n>>k;
    int d;
    bool ok[10];
    for(int i=0;i<10;i++)ok[i]=true;
    for(int i=0;i<k;i++){
        cin>>d;
        ok[d]=false;
    }
    while(1){
        int tmp=n;
        bool judge=true;
        while(tmp){
            int a=tmp%10;
            tmp/=10;
            if(ok[a]==false){
                judge=false;
                break;}
        }
        if(judge==true)break;
        n++;
    }
    cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
rev = {}
ind_dic = {}
for i in range(1, N+1):
    k, v = input().split()
    
    if k in rev:
        rev[k].append(v)
    else:
        rev[k] = [v]
    ind_dic[v] = i

for v in rev.values():
    for i in range(len(v)):
        v[i] = int(v[i])
    v.sort(reverse=True)

key_lst = []
for k in rev.keys():
    key_lst.append(k)
key_lst.sort()

new_dic = {}
for k in key_lst:
    new_dic[k] = rev[k]

for k in new_dic.keys():
    for i in range(len(new_dic[k])):
        print(ind_dic[str(new_dic[k][i])])

Measured memory_bytes: 62796
#include<iostream>
#include<string>
#include<stack>
using namespace std;
int main(){
	for(;;){
		string word;
		stack<int> log;
		getline(cin,word);
		if(word == "."){break;}
		for(int i=0; i<word.size(); i++){
			if(word[i] == '('){log.push(1);}
			if(word[i] == '['){log.push(2);}
			if(word[i] == ')'){
				if(log.empty()){cout<<"no"<<endl;goto jump;}
				else if(log.top() == 1){log.pop();}
				else if(log.top() != 1){cout<<"no"<<endl;goto jump;}
			}
			if(word[i] == ']'){
				if(log.empty()){cout<<"no"<<endl;goto jump;}
				else if(log.top() == 2){log.pop();}
				else if(log.top() != 2){cout<<"no"<<endl;goto jump;}
			}
		}
		if(log.empty()){cout <<"yes"<<endl;}
		else{cout <<"no"<<endl;}
		jump:;
	}
}

Measured memory_bytes: 900
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        l: u32
    }

    let mut r = 0;
    while 2u32.pow(r+1) <= l { r += 1 };

    let mut ans = vec![];

    for i in 0..r {
        ans.push((i+1, i+2, 0));
        ans.push((i+1, i+2, 2u32.pow(i)));
    }

    let mut t = l;
    for i in (0..r).rev() {
        if t - 2u32.pow(r) >= 2u32.pow(i) {
            t -= 2u32.pow(i);
            ans.push( (i+1, r+1, t) ) ;
        }
    }

    println!("{} {}", r+1, ans.len());
    for &(i, j, c) in ans.iter() {
        println!("{} {} {}", i, j, c);
    }
}

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

using namespace std;

const int N=1e5+10;

int n,a[N];

void Init()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
}

void Solve()
{
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	for (int i=1;i<=n;++i)
		if (a[i+1]<i+1)
		{
			int ret=1;
			for (int j=i+1;j<=n && a[j]==i;++j) ret=ret^1;
			ret&=(a[i]-(i-1))&1;
			if (ret) printf("Second\n");
			else printf("First\n");
			break; 
		}
}

int main()
{
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 640
"""
"""

from math import factorial


def int_as_array(num): return list(map(int, [y for y in str(num)]))


def array_as_int(arr): return int(''.join(map(str, arr)))


def read_int(): return int(input())


def read_array(): return list(map(int, input().split(' ')))


def array_to_string(arr, sep=' '): return sep.join(map(str, arr))


def matrix_to_string(arr, sep=' '): return '[\n' + '\n'.join(
    [sep.join(map(str, row)) for row in arr]) + '\n]'


def combine(n, r):
    try:
        return (factorial(n) / factorial(n - r)) * (1 / r)
    except:
        return 0


def solve(N, M):
    choose_evens = combine(N, 2)
    choose_odds = combine(M, 2)
    return int(choose_evens + choose_odds)


N, M = read_array()
print(solve(N, M))


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		prtln(A * B);
	}

	public static <T> void prtln(T t) { System.out.println(t); }
}

Measured memory_bytes: 27088
'''
ITP-1_4-A
 ?????????
???????????´??° a ??¨ b ?????????????????§?????\?????????????¨??????????????????°?????????????????????????????????
a ?? b ??? d (??´??°)
a ?? b ????????? ??? r (??´??°)
a ?? b ??? f (???????°???°?????°)
???Input
1?????????????????´??° a, b ????????????????????????
???Output
d, r, f ????????????????????§????????£????????????????????????????????????f??????????????????0.00001??\????????????????????£????????????????????¨????????????
'''
# import

# ?????°??????????????????
inputData01, inputData02 = map(int,input().split())

# ??????????????´??°???????±???????
d = inputData01 // inputData02
# print( d )

# ??????????????????????±???????
r = inputData01 % inputData02
# print( r )

# ??????????????´??°???????±???????
f = inputData01 / inputData02
print( d, r, "{0:f}".format( f ))

Measured memory_bytes: 7620
#include<stdio.h>
int main()
{
  int a,b,d,i,sum=0;
  int c[100];
  scanf("%d %d",&a,&b);
  
  for(i=0;i<a;i++){
    scanf("%d",&c[i]);
    sum += c[i];
    if(c[i] <= d) d=c[i];	
  }	
  printf("%d",(b-sum)/d+i);
  return 0;
}

Measured memory_bytes: 128
#define TEST_MODE false

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= b; --i)
#define range(i, a, b, c) for (int i = a;             \
                               c > 0 ? i < b : i > b; \
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long

#ifdef LOCAL_ENV

#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << endl
#else
const bool test = false;
#define dump(x) 
#endif

#else
const bool test = false;
#define dump(x) 
#endif

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while (getline(ss, buffer, sep))
    {
        v.push_back(buffer);
    }
    return v;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
    return accumulate(begin, end, 0ll);
}

void solve();

class Solver {
public:
    int N;
    string s;

    void solve() {
        cin >> s;
        N = s.size();
        int g_cnt = 0;
        int p_cnt = 0;
        int res = 0;
        rep(i, N) {
            if (p_cnt + 1 <= g_cnt) {
                if (s[i] == 'g') res++;
                p_cnt++;
            }
            else {
                if (s[i] == 'p') res--;
                g_cnt++;
            }
        }
        cout << res << endl;
    }
};

signed main()
{
    cout << fixed << setprecision(20);
    auto ptr = new Solver();
    ptr->solve();
    delete ptr;
    // while (true) {    
    //     auto ptr = new Solver();
    //     ptr->solve();
    //     delete ptr;
    // }
    return 0;
}

// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'




Measured memory_bytes: 512
import java.util.*;
public class Main {
    public void solve() {
        Scanner scan = new Scanner(System.in);
        int X = scan.nextInt();
        int Y = scan.nextInt();
        for (int i = 0; i <= X; i++) {
            for (int j = X; j >= 0; j--) {
                if (i + j == X && 2 * i + 4 * j == Y) {
                    System.out.println("Yes");
                    return;}}}
                System.out.println("No");

    }





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

Measured memory_bytes: 35624