akhauriyash/Code-Regression huggingface dataset:
/*

Author : @karngyan
Team : BlundersPride
Date : 23-03-2019
Time : 18:04:56

*/


#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
using namespace std;

using ll = long long;
using ld = long double;
using vll = std::vector< ll >;
using pll = std::pair< ll, ll >;
using vvll = std::vector<vll>;
using vpll = std::vector< pll >;


#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i, begin, end) for(__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define cntll(a) __builtin_popcountll((a))
#define ff first
#define ss second
#define mk make_pair
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it){}
template<typename T , typename... Args>
void err(istream_iterator<string> it , T a , Args... args)
{
	cerr << *it << " = " << a << endl;
	err(++it , args ... );
}

ll sum(){ return 0; }
template<typename T, typename... Args>
auto sum(T a, Args... args){ return a + sum(args...);}
const ll MOD = 1e9+7;
////////////////////////////////////////////////////////////////////////////////////////////////////////

const ll N = 110;
ll a[N][N];

void make_even(ll n)
{
	rep(i,1,n+1)
	{
		rep(j,1,n+1)
		{
			a[i][j] = 1;
		}
	}

	rep(i,1,n+1)
	{
		a[i][i] = 0;
	}

	for(ll i = n , j = 1; i> 0 ; --i , ++j)
	{
		a[i][j] = 0;
	}
}
void make_odd(ll n)
{
	make_even(n-1);
	for(ll i = 1 ; i<n ; ++i)
	{
		a[i][n] = 1;
		a[n][i] = 1;
	}
	a[n][n] = 0;


}
void print(ll n)
{
	set<pll> s;
	rep(i,1,n+1)
	{
		rep(j,1,n+1)
		{
			if(a[i][j] == 1)
			{
				pll x = {i,j};
				if(x.ff > x.ss)
					swap(x.ff,x.ss);
				s.insert(x);
			}
		}	
	}
	cout<<s.size()<<endl;
	for(auto it: s)
	{
		cout<<it.ff<<" "<<it.ss<<endl;
	}
}
signed main()
{

	fast;
////////////////////////////////////////////////////////////////////////////////////////////

	ll n;
	cin >> n;
	if(n&1)
	{

		make_odd(n);
		print(n);


	}
	else
	{
		make_even(n);
		print(n);

	}


////////////////////////////////////////////////////////////////////////////////////////////


	return 0;
}




Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define ARRAY_MAX 100005
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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




/******************************************************************************************/


ll dp[100005][15];

int main() {

	
	string s;
	cin >> s;

	dp[0][0] = 1LL;

	for (int i = 0; i < s.size(); i++)
	{
		int num = -1;
		if (s[i] == '?') {
			num = -1;
		}
		else
		{
			num = s[i] - '0';
		}

		for (int j = 0; j < 10; j++)
		{
			//余り
			if (num != -1 && num != j)continue; //numが-1なら全部試す、-1でないならnum==jとなるjのみを試す

			for (int k = 0; k < 13; k++)
			{
				dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
			}
		}

		for (int j = 0; j < 13; j++)
		{
			dp[i + 1][j] %= MOD;
		}
	}

	cout << dp[s.size()][5] << endl;

	return 0;
}


Measured memory_bytes: 12160
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; i++)
struct NODE{
	int to , dist , cost;
	NODE(int a,int b,int c){
		to = a , dist = b , cost = c;
	}
};
bool operator < (const NODE &a,const NODE &b){
	return a.dist != b.dist ? a.dist > b.dist : a.cost > b.cost;
}
int main(){
	int n,m;
	while(cin >> n >> m && (n||m) ){
		vector< vector<NODE> > g(n);
		bool done[10000] = {0};
		int ans = 0;
		rep(i,m){
			int a,b,c,d;
			cin >> a >> b >> c >> d;
			a--,b--;
			g[a].push_back(NODE(b,c,d));
			g[b].push_back(NODE(a,c,d));
		}
		priority_queue <NODE> Q;
		Q.push(NODE(0,0,0));
		while(Q.size()){
			NODE q = Q.top(); Q.pop();
			if(done[q.to])continue;
			else done[q.to] = true , ans += q.cost;
			rep(i,g[q.to].size()) Q.push(NODE(g[q.to][i].to,q.dist+g[q.to][i].dist,g[q.to][i].cost));
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 2720
s = ""
n = int(input())
while True:
    if n % 3 == 0:s = "0" + s
    elif n % 3 == 1:s = "+" + s
    else:
        s = "-" + s
        n += 1
    n = n // 3
    if n == 0:break
print(s)


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  ll ans=0;
  rep(i,n){
    ans+=a[i]/2;
    if(i+1<=n-1 && a[i+1]>=1 && a[i]%2==1){
      ans++;
      a[i+1]--;
    }
  }
  cout<<ans<<endl;
}

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

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(){
   int i,j,k,n,l[2000];
   long a;
 
   scanf("%d",&n);
   for (i=0;i<n;i++) scanf("%d",&l[i]);
   qsort(l,n,sizeof(int),asc);
   a=0;
   for (i=0;i<n;i++)
      for (j=i+1;j<n;j++)
         for (k=j+1;k<n;k++)
            if (l[i]+l[j]>l[k]) a++;
   printf("%ld\n",a);
   return 0;
}

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

void print_array(int a[],int n){
    for(int i=0;i<n;i++){
        if(i != 0) cout<<' ';
        cout<<a[i];
    }
    cout<<'\n';
}

void selection_sort(int a[],int n){
    int count = 0;
    for(int i=0;i<n;i++){
        int min_key = i;
        for(int j=i;j<n;j++){
            if(a[j]<a[min_key]) {min_key = j;}
        }
        swap(a[i],a[min_key]);
        if(i != min_key) count++;
    }
    print_array(a,n);
    cout<<count<<'\n';
}

int main(){
    int A[100],N;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    selection_sort(A,N);
    return 0;
}


Measured memory_bytes: 3120
package main

import "fmt"

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	a := make([]string, h)
	for i := range a {
		fmt.Scan(&a[i])
	}

	la := make([]bool, h)
	ca := make([]bool, w)
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if a[i][j] == '#' {
				la[i] = true
				ca[j] = true
			}
		}
	}

	for i := range a {
		if la[i] {
			for j := range a[i] {
				if ca[j] {
					fmt.Print(string(a[i][j]))
				}
			}
			fmt.Println()
		}
	}
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
ll INF = 15000000;
int main(){
    int n;
    cin >> n;
    vector<int> num(n);
    rep(i,n) cin >> num[i];
    sort(num.begin(),num.end());
    int res = INF;
    for(int i = 0;i <= 100;i++){
        int sum = 0;
        rep(x,n){
            sum += (i - num[x]) * (i - num[x]);
        }
        chmin(res,sum);
    }
    cout << res << endl;
}


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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    int X,Y;
    cin >> X >> Y;
    auto ty = Y - 2*X ;
    if(ty%2 == 1) {
        cout << "No" << endl;
        return;
    }
    auto y = ty/2;
    auto x = X - y;
    if ((x < 0) || (y < 0)  || ((2*x+4*y) != Y)) {

        cout << "No" << endl;
        return;
    }
    cout << "Yes" << endl;

}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3600
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		sc.close();
		int flag = -1;
		int t = ((n - 1) * (n - 2)) / 2;
		if (k > t)
			System.out.println(flag);
		else {
			int m = n - 1 + t - k;
			System.out.println(m);
			for(int i = 2; i <= n; ++i) {
				System.out.println(1 + " " + i);
			}
			int root = 2;
			int next = 3;
			for(int i = 0; i < t - k; ++i) {
				if(next > n) {
					root++;
					next = root + 1;
				}
				System.out.println(root + " " + next);
				next++;
			}
		}
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int main() {
  int h, w, k, black = 0;
  cin >> h >> w >> k;
  vector<string> v(h);
  rep(i,h)
  {
    cin >> v[i];
    rep(j,w)
    {
      if (v[i][j] == '#') {
        black++;
      }
    }
  }
  int cnt = 0;
  rep(i,pow(2,h))
    rep(j,pow(2,w))
    {
      int c = 0;
      bitset<8> bh(i);
      bitset<8> bw(j);
      rep(k,h)
      {
        if (bh.test(k)) {
          rep(l,w)
          {
            if (v[k][l] == '#') {
              c++;
            }
          }
        }
      }
      rep(k,w)
      {
        if (bw.test(k)) {
          rep(l,h)
          {
            if ((!bh.test(l)) && v[l][k] == '#') {
              c++;
            }
          }
        }
      }
      if (black - k == c) {
        cnt++;
      }
    }
  cout << cnt;
  return 0;
}


Measured memory_bytes: 4064
import math
import random
import sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from functools import lru_cache, reduce
from heapq import heapify, heappop, heappush
from itertools import (chain, combinations, combinations_with_replacement,
                       permutations)

MAX_INT = 2**62-1
sys.setrecursionlimit(10**7)

input = sys.stdin.readline


def read_n_int():
    return map(int, input().split())


def main():
    a, b = read_n_int()
    a1, a2 = a/0.08, (a+1)/0.08
    b1, b2 = b/0.1, (b+1)/0.1

    for i in range(int(a1), int(a2)+1):
        if b1 <= i < b2 and a1 <= i < a2:
            print(i)
            break
    else:
        print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 4448
#include<stdio.h>

int main() {
	int S = 0;
	scanf("%d", &S);

	int s = S % 60;
	int h = S / 3600;
	int m = (S % 3600 - s) / 60;
	printf("%d:%d:%d\n", h, m, s);
        return 0;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;

int main() {

	long H, W, D; cin >> H >> W >> D;
	vector<vector<long>> A(H, vector<long>(W));

	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> A[i][j];

	map<long, pair<long, long>> Mp;//数 -> 座標
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) Mp.emplace(A[i][j], make_pair(i, j));

	vector<long> cost(H * W);//+Dするためのコスト

	for (int i = 1; i + D <= H * W; i++) {
		auto from = Mp.at(i);
		auto to = Mp.at(i + D);

		cost[i] = abs(from.first - to.first) + abs(from.second - to.second);
	}

	vector<long> acmcost(H * W + 1 , 0);//+Dごとに累積する
	for (int i = 1 + D; i <= H * W; i++) {
		acmcost[i] = acmcost[i - D] + cost[i - D];
	}

	long Q; cin >> Q;
	for (int i = 0; i < Q; i++) {
		long L, R; cin >> L >> R;
		cout << acmcost[R] - acmcost[L] << endl;
	}

}

Measured memory_bytes: 10496
pn = [2]
A = 100007

for i in range(3, A):
    chk = True
    for num in pn:
        if i % num == 0:
            chk = False
            break
    if chk:
        pn.append(i)

X = int(input())

while True:
    if X in pn:
        print(X)
        break
    else:
        X += 1


Measured memory_bytes: 71832
#include<bits/stdc++.h>
#define ll long long
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
#define dbg3(x) cerr<<#x<<"\n"
using namespace std;
#define reg register
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
const int MN=2005,inf=1e9+5;
int N,K,Q;
int id[MN],a[MN];
bool cmp(int x,int y){return a[x]<a[y];}
int bel[MN],len[MN],cnt,bl;bool in[MN];
int solve(int pos)
{
	memset(in,0,sizeof in);
	cnt=bl=0;reg int i,j,k;
	for(i=1;i<=N;++i)
	{
		for(;i<=N&&a[i]<a[pos];++i);
		for(j=i;j<=N&&a[j]>=a[pos];++j);--j;
		for(len[++bl]=j-i+1,k=i;k<=j;++k)
			bel[k]=bl,in[k]=true;
		i=j;
	}
	for(i=1;i<=N;++i)if(in[id[i]]&&len[bel[id[i]]]>=K)
	{
		--len[bel[id[i]]];
		if(++cnt==Q)return a[id[i]]-a[pos];
	}
	return inf;
}
int main()
{
	N=read();K=read();Q=read();
	reg int i;
	for(i=1;i<=N;++i)a[id[i]=i]=read();
	sort(id+1,id+N+1,cmp);
	int ans=inf;
	for(i=1;i<=N;++i) ans=min(ans,solve(i));
	return 0*printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n,a,b;cin>>n>>a>>b;
    int res=0;
    for(int i=1;i<=n;i++) {
        int x = i, sum=0;
        while(x) {
            sum += (x%10);
            x/=10;
        }
        if(sum >= a && sum <= b)
            res += i;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
N, H = map(int, input().split())
ABs = []
for i in range(N):
  a, b = map(int, input().split())
  ABs.append((a, b))
A = max(map(lambda AB: AB[0], ABs))
Bs = sorted(filter(lambda b: b>A, map(lambda AB: AB[1], ABs)), reverse=True)
#print(A, Bs)
r = 0
c = 0
for b in Bs:
  r += 1
  c += b
  if c >= H:
    print(r)
    exit()
r += (H-c +A-1)//A
print(r)


Measured memory_bytes: 17708
#include<bits/stdc++.h>
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;}
const double EPS=1E-8;
////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    
    string s,t;cin>>s>>t;
    int a[26];rep(i,0,25)a[i]=-1;
    rep(i,0,s.size()-1){
        int x=s[i]-'a';
        int y=t[i]-'a';
        if(a[x]==-1){
            a[x]=y;
        }else if(a[x]!=y){
            cout<<"No"<<endl;return 0;
        }
    }
    vector<int>v;
    rep(i,0,25){
        if(a[i]!=-1)v.pb(a[i]);
    }
    sort(v.begin(),v.end());
    int n=v.size();
    if(n>=2)rep(i,0,n-2){
        if(v[i]==v[i+1]){
            cout<<"No"<<endl;return 0;
        }
    }
    cout<<"Yes"<<endl;
    
    return 0;
}

Measured memory_bytes: 916
# coding: utf-8
"""this is python work script"""

def solver(price, counts):
    """solve this problem"""
    answer = ['-1', '-1', '-1']
    for z in range(counts+1):
        sum_z = z * 1000
        if sum_z > price:
            continue
        for y in range(counts + 1 - z):
            x = counts - y - z
            sum_y = y * 5000
            sum_x = x * 10000
            sum_all = sum_x + sum_y + sum_z
            if sum_all > price:
                continue
            if sum_all == price:
                return list(map(str, [x, y, z]))
    return answer

def main():
    """main function"""
    N, Y = list(map(int, input().split()))
    answer = solver(Y, N)
    print(" ".join(answer))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 0;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int a, b;
signed main() {
	cin >> a >> b;
	int ans = 0;
	for (int i = 0; i < 40; i++) {
		int t = 1ll << i;
		if (t > b) {
			break;
		}
		int sum = 0;
		//a以前で最も大きいtより下のBitが0の数
		int l = (a / t)*t;
		if ((a / t) % 2 == 0) {
			l = ((a / t) + 1)*t;
		}
		else {
			l += t;
			sum += l - a;
			l += t;
		}
		int r = (b / t)*t;
		if ((b / t) % 2 == 0) {
			r += t;
		}
		else {
			sum += b - r + 1;
		}
		sum += max_0(ceil((r - l) / 2.0));
		if (sum % 2 == 1) {
			ans |= t;
		}
	}
	cout << ans << endl;
}

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

signed main() {
	ll x, y;
	cin >> x >> y;
	bool ans = false;
	for(ll i = 0; i < x + 1; i++){
		ll hon = i * 2 + (x - i) * 4;
		if(hon == y) ans = true;
	}
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        final int mod = ((int)1e9)+7;
        
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        
        for(int i=0; i<n; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        
        //N!
        long k = 1;
        for(int i=1; i<=n; i++){
            k *= i;
            k %= mod;
        }
        
        //累積和
        long[] r = new long[n+1];
        for(int i=1; i<=n; i++){
            r[i] = (r[i-1] + mod_pow(i,mod-2, mod)) % mod;
        }
        
        //
        long res = 0L;
        for(int i=0; i<n; i++){
            //左側+右側-重複分
            res += (r[i+1] + r[n-i] - r[1]) * a[i];
            res %= mod;
        }
        
        //
        System.out.println(res * k % mod);
    }
    
    public static long mod_pow(long x, long p, long m){
        long a = 1;
        while(p>0){
            if(p%2==1){
                a = a*x%m;
            }
            x = x*x%m;
            p /= 2;
        }
        return a;
    }
}

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

int main () {
    int n, k; cin >> n >> k;
    string s; cin >> s;

    if (s.at(k - 1) == 'A') s.at(k - 1) = 'a';
    if (s.at(k - 1) == 'B') s.at(k - 1) = 'b';
    if (s.at(k - 1) == 'C') s.at(k - 1) = 'c';
    cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000

ll N,M,K,Q;
ll A[200010],B,C,D,X;
ll ans=INF;
ll F[200010];
string S,T,U;
int main(){
    cin>>N>>K;
    REP(i,N){
        cin>>A[i];
    }
    ll pos=0;
    REP(i,200010)F[i]=-1;
    F[0]=0;
    bool f=false;
    REP(i,N+1){

        if(F[A[pos]-1]==-1){
            F[A[pos]-1]=i+1;
            pos=A[pos]-1;
            if(i+1==K){f=true;break;}
        }
        else{
            B=F[A[pos]-1];
            C=i+1;
            if(K<i+1){f=true;}
            DEB(i)DEB(B)DEB(C)END;
            break;
        }
        DEB(pos)END;
    }
    if(f){
        cout<<pos+1<<endl;
    }else{
        ans=A[pos]-1;DEB(ans)END;
        REP(i,(K-B)%(C-B)){
            ans=A[ans]-1;
        }
        cout<<ans+1<<endl;
    }

}

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

int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
  	int A = X;
  	int B = Y;
  	int C = Z;
  	A = Y;
  	B = X;
  	A = Z;
  	C = Y;
  	cout << A << " " << B << " " << C << endl;
}


Measured memory_bytes: 256
#Bad_Beast
n=int(input())
if n>=100 and n<=111:
    print(111)
if n>111 and n<=222:
    print(222)
elif n>222 and n<=333:
    print(333)
elif n>333 and n<=444:
    print(444)
elif n>444 and n<=555:
    print(555)
elif n>555 and n<=666:
    print(666)
elif n>666 and n<=777:
    print(777)
elif n>777 and n<=888:
    print(888)
elif n>888 and n<=999:
    print(999)
#print(res)    
        
    

Measured memory_bytes: 3064
using ll=long long;using ull=unsigned long long;
#include<limits>
namespace pcl{template<typename T>constexpr T TNF=std::numeric_limits<T>::max()/2;constexpr int INF=TNF<int>;constexpr ll LNF=TNF<ll>;constexpr double DNF=TNF<double>;constexpr double EPS=1e-8;constexpr int P7=1'000'000'007;constexpr int DX[]={1,0,-1,0,1,1,-1,-1};constexpr int DY[]={0,1,0,-1,-1,1,1,-1};}
#include<algorithm>
#include<cmath>
#include<iostream>
namespace pcl{template<typename T>void updmax(T&a,T const&b){a=std::max(a,b);}template<typename T>void updmin(T&a,T const&b){a=std::min(a,b);}template<typename T,typename U,typename V>bool in_range(T const&begin,U const&mid,V const&end){return begin<=mid&&mid<end;}template<typename T,typename U,typename V>bool in_range(T const&begin,std::initializer_list<U>list,V const&end){auto p=std::minmax_element(list.begin(),list.end());return begin<=*p.first&&*p.second<end;}template<typename T,typename U,typename V>bool in_range_strict(T const&begin,std::initializer_list<U>list,V const&end){if(!std::is_sorted(list.begin(),list.end()))return false;return in_range(begin,list,end);}template<typename T>inline T cget(){T x;std::cin>>x;return x;}}
#include<iostream>
#include<vector>
namespace pcl{template<typename T>std::ostream&operator<<(std::ostream&os,std::vector<T>const&v){os<<'[';for(size_t i=0;i<v.size();i++){if(i!=0)os<<",";os<<v[i];}os<<']';return os;}template<typename T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(size_t i=0;i<v.size();i++)is>>v[i];return is;}}
#include<bits/stdc++.h>
using namespace std;using namespace pcl;int main(){int N;cin>>N;vector<pair<ll,ll>>solvable;ll lmax=0;ll rmin=LNF;ll max_range=0;solvable.reserve(N);for(int i=0;i<N;i++){ll L,R;cin>>L>>R;R++;updmax(lmax,L);updmin(rmin,R);updmax(max_range,R-L);solvable.push_back(make_pair(L,R));}ll ans1=max(0ll,rmin-lmax)+max_range;vector<pair<ll,ll>>ab(N);for(int i=0;i<N;i++){ab[i].first=max(0ll,solvable[i].second-lmax);ab[i].second=max(0ll,rmin-solvable[i].first);}sort(ab.begin(),ab.end());ll ans2=0;ll bmin=LNF;for(int i=1;i<N;i++){updmin(bmin,ab[i-1].second);updmax(ans2,ab[i].first+bmin);}cout<<max(ans1,ans2)<<endl;}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

long long calc(long long a,long long b){
	if(a%b==0)return a;
	return b*(a/b+1);
}

int main(){
	int n;
	long long t,a;
	long long x,y;
	x=1;
	y=1;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> t >> a;
		x = calc(x,t);
		if(x/t*a<y){
			y = calc(y,a);
			x = y/a*t;
		}else{
			y = x/t*a; 
		}
	}
	cout << x+y <<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
	int pm,pj,pe,n,i;
	while(cin >> n&&n){
		for(i=0;i<n;i++){
			cin >> pm >> pe >> pj;
			double ave = (pm+pe+pj)/3;
			if(pm == 100 || pe == 100 || pj == 100) cout << 'A' << endl;
			else if((pm+pe)/2 >= 90 || ave >= 80) cout << 'A' << endl;
			else if(ave >= 70) cout << 'B' << endl;
			else if(ave >= 50 && pe >= 80) cout << 'B' << endl;
			else if(ave >= 50 && pm >= 80) cout << 'B' << endl;
			else cout << 'C' << endl;
		}
	}
	return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	
	int n, h, w;
	cin >> h >> w >> n;
	cout << (h < w ? (n + w - 1) / w : (n + h - 1) / h) << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	string s, t;
	cin >> s >> t;
	string ans = "UNRESTORABLE";
	rep(i, 0, s.size()) {
		string a = "";
		int x = 0;
		rep(j, 0, i) {
			if (s[x] == '?') a += "a";
			else a += s[x];
			x++;
		}
		bool can = true;
		rep(j, 0, t.size()) {
			if (s[x] == '?' || s[x] == t[j]) {
				a += t[j];
				x++;
			}
			else {
				can = false;
				break;
			}
		}
		if (!can) continue;
		while (x < s.size()) {
			if (s[x] == '?') a += "a";
			else a += s[x];
			x++;
		}
		if (ans == "UNRESTORABLE") ans = a;
		else ans = min(ans, a);
	}
	cout << ans << endl;
}

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

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    
    for (int i = a; i <= b; i++) {
        if (
            (i < (a + k)) ||
            (i > (b - k))
        ) {
            cout << i << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int L,R,d,M,c=0,i=2;
    scanf("%d %d %d",&L,&R,&d);
    M=d;
    while(M<=R)
    {
        if((M>=L)&&(M<=R))
            c++;
        M=d*i;
        i++;
    }
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 1728
n,k = map(int,input().split())
pk = [1]
pz = [1]
for i in range(n):
  pk.append(pk[-1]*2+1)
  pz.append(pz[-1]*2+3)
ans = 0
for i in range(n,-1,-1):
  z = pz.pop()
  ka = pk.pop()
  if k>= z//2:
    ans += ka//2
    k-=z//2
    if k:
      ans+=1
  if k:
    k-=1
print(ans)

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

//create arrays outside of main()
int N = 10;
int a[100000] = {};
int b[100000] = {};

stack<char> s;


int main() {

    int n;
    cin >> n;

    for(int i=0; i<n-1; i++){
        cin >> a[i];
    }

    for(int i=0; i<n; i++){
        if(i==0){
            b[i] = a[i];
        }

        if(a[i]>=a[i+1]){
            b[i+1] = a[i+1];
        } else {
            b[i+1] = a[i];
        }

        if(i==n-2){
            b[i+1] = a[i];
        }
    }

    int sum=0;

    for(int i=0; i<n; i++){
        sum += b[i];
    }

    cout << sum;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    cout<<(n+110)/111*111<<endl;
    return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include<tuple>
#include<stack>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tpl;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 1500

const int INF = 1 << 30;
const int MOD = 1e9 + 7;



//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

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

/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);
	return (x/tmp) * y;
}

int main() {

	ll n;
	cin >> n;
	vector<ll> t(n);
	ll maxi = 0;
	for (ll i = 0; i < n; i++)
	{
		cin >> t[i];
		maxi = max(maxi, t[i]);
	}

	for (int i = 0; i < n; i++)
	{
		maxi = lcm(maxi, t[i]);
	}
	cout << maxi << endl;



	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define For(i, a, b)    for(int i = (a); (i) < (b) ; ++(i))
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

bool isPrime(int n){
    if(n < 2) return false; else if(n == 2) return true; else if(n%2 == 0) return false;
    double sqrtNum = sqrt(n); for(int i = 3;i <= sqrtNum; i += 2) if(n%i == 0) return false;
    return true;
    }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int a, b; cin >> a >> b;
    if(a <= b){
        rep(i, b) cout << a;
        cout << endl;
        return 0;
    }

    else if(a > b){
        rep(i, a) cout << b;
        cout << endl;
        return 0;
    }

return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
const int MAX_N=1<<20;
int N,dat[2*MAX_N-1];
void init(int n_){
    N=1;
    while(N<n_) N*=2;
    rep(i,2*N-1) dat[i]=INT_MAX;
}
void update(int k,int a){
    k+=N-1;
    dat[k]=a;
    while(k>0){
        k=(k-1)/2;
        dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
}
int query(int a,int b,int k=0,int l=0,int r=N){
    if(r<=a||b<=l) return INT_MAX;
    if(a<=l&&r<=b) return dat[k];
    else{
        int vl=query(a,b,k*2+1,l,(l+r)/2);
        int vr=query(a,b,k*2+2,(l+r)/2,r);
        return min(vl,vr);
    }
}
int main(){
    ll n,x,d;
    vector<P> A;
    cin>>n;
    rep(i,n) cin>>x>>d,A.push_back(P(x,d));
    sort(all(A));
    ll dp[200001]={0},mod=998244353;
    dp[n]=1;
    vec B;
    init(n);
    for(int i=n-1;i>=0;i--){
        update(n-i-1,-A[i].first-A[i].second);
        int l=upper_bound(all(B),-A[i].first-A[i].second)-B.begin();
        int ans=query(l,n-i);
        (dp[i]=dp[i+1]+dp[n-(upper_bound(all(B),ans)-B.begin())])%=mod;
        B.push_back(-A[i].first);
        update(n-i-1,ans);
    }
    cout<<dp[0]<<"\n";
}


Measured memory_bytes: 13292
n = int(input())
a = list(map(int,input().split()))
a.sort()
M = max(a)
m = M/2
tmp = 1e9
for i in range(n-1):
    if tmp > abs(a[i]-m):
        tmp = abs(a[i]-m)
        ans = i

print(M,a[ans])

Measured memory_bytes: 14428
struct Read<R: std::io::BufRead> {
    stdin: R,
    v: Vec<String>,
    i: usize,
}
impl<R:std::io::BufRead> Read<R> {
    pub fn new(stdin: R) -> Self {
        Read{
            stdin,
            v: Vec::new(),
            i: 0,
        }
    }
    pub fn read_until<T: std::str::FromStr>(&mut self) -> T {
        if self.i == self.v.len() {
            self.read_line();
        }
        let elem = &self.v[self.i];
        self.i += 1;
        elem.parse().unwrap_or_else(|_| panic!())
    }
    #[allow(dead_code)]
    pub fn read_i32(&mut self) -> i32 {
        if self.i == self.v.len() {
            self.read_line();
        }
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }
    pub fn read_string(&mut self) -> String {
        if self.i == self.v.len() {
            
            self.read_line();
        }
        let elem = &self.v[self.i];
        self.i += 1;
        elem.to_owned()
    }
    pub fn read_line(&mut self) {
        self.i = 0; self.v = Vec::new();
        let mut buf = String::new();
        self.stdin.read_line(&mut buf).unwrap();
        let buf = buf.trim().to_owned();
        let mut ws = buf.split_whitespace();
        loop {
            let x = ws.next();
            if x.is_none() {
                break;
            }
            let x = x.unwrap().to_owned();
            self.v.push(x);
        }
    }
}
fn main() {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let mut read = Read::new(stdin);
    let mut n:usize = read.read_until();
    let mut s:Vec<String> = Vec::new();
    for _i in 0..n {
        s.push(read.read_string());
    }
    s.sort();
    let mut ans = 1;
    for i in 0..n-1 {
        if s[i] != s[i+1] {
            ans+=1;
        }
    }
    println!("{}",ans);
}

Measured memory_bytes: 14840
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n;
    int all = 0;
    vector<int> a(n);
    vector<int> dif(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    dif.at(0) = abs(a.at(0));
    dif.at(n) = abs(a.at(n - 1));
    for (int i = 1; i < n; i++) {
        dif.at(i) = abs(a.at(i) - a.at(i - 1));
    }
    for (int i = 0; i < n + 1; i++) {
        all += dif.at(i);
    }
    int first = all;
    first -= (dif.at(0) + dif.at(1));
    first += abs(a.at(1));
    cout << first << endl;
    for (int i = 1; i < n - 1; i++) {
        int ans = all;
        ans -= (dif.at(i) + dif.at(i + 1));
        ans += abs(a.at(i + 1) - a.at(i - 1));
        cout << ans << endl;
    }
    int last = all;
    last -= (dif.at(n) + dif.at(n - 1));
    last += abs(a.at(n - 2));
    cout << last << endl;
}

Measured memory_bytes: 2048
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
void mincat(ll &a,ll b){if(a > b)a=b;}
ll func(ll x[]){
  ll minimum = INFLONG;
  mincat(minimum,x[0] - min(x[1],x[3]));
  mincat(minimum,max(x[2],x[4]) - x[0]);
  mincat(minimum,2 * (x[0]-x[1]) + x[4]-x[0]);
  mincat(minimum,2 * (x[0]-x[3]) + x[2]-x[0]);
  mincat(minimum,2 * (x[4]-x[0]) + x[0]-x[1]);
  mincat(minimum,2 * (x[2]-x[0]) + x[0]-x[3]);
  return minimum;
}
int main(){
  int a,b,q;
  cin >> a >> b >> q;
  vector<pair<ll,ll>> vec;
  ll s[a],t[b],x[q],ans[q];
  vector<pair<ll,ll>> num(q);
  for(int i=0;i<a;i++){
    cin >> s[i];
    vec.push_back(make_pair(s[i],0));
  }
  for(int i=0;i<b;i++){
    cin >> t[i];
    vec.push_back(make_pair(t[i],1));
  }
  for(int i=0;i<q;i++){
    cin >> x[i];
    num[i].first = x[i];
    num[i].second = i;
    vec.push_back(make_pair(x[i],2));
  }
  ll res[q][5];//center,s min ,s max ,t min, t max
  sort(vec.begin(),vec.end());
  sort(num.begin(),num.end());
  ll min1 = -INFLONG/3,min2 = -INFLONG/3;
  ll count=0;
  for(int i=0;i<a+b+q;i++){
    if(vec[i].second == 2){
      res[count][0] = vec[i].first;
      res[count][1] = min1;
      res[count][3] = min2;
      count++;
    }else if(vec[i].second == 1){
      min1 = vec[i].first;
    }else{
      min2 = vec[i].first;
    }
  }
  count--;
  ll max1 = INFLONG/3,max2 = INFLONG/3;
  for(int i=a+b+q-1;i>=0;i--){
    if(vec[i].second == 2){
      res[count][0] = vec[i].first;
      res[count][2] = max1;
      res[count][4] = max2;
      count--;
    }else if(vec[i].second == 1){
      max1 = vec[i].first;
    }else{
      max2 = vec[i].first;
    }
  }
  for(int i=0;i<q;i++){
    // for(int j=0;j<5;j++){
    //   cout << res[i][j] << " ";
    // }
    // cout << endl;
    ans[num[i].second] = func(res[i]);
  }
  for(int i=0;i<q;i++){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 15848
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define repr(i, n) for(int i=(n-1); 0<=i; i--)
#define repr2(i, from, to) for(int i=(from-1); (int)(to)<=i; i--)
#define ALL(obj) (obj).begin(), (obj).end()
typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int to, cost; };
struct gNode { int from, to, cost; };
struct tNode { int value; int parent; vector<int> child; };


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

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

int main(void){
	int n; cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	
	int count=0, ans = 0;
	repr(i, n){
		if(i==0) continue;
		if(h[i-1] >= h[i]) count++;
		else count = 0;
		ans = max(ans, count);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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; }


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

    set<string> used;
    bool fg = false;

    for(char c = 'a'; c <= 'z'; c++){
        if(fg) break;
        vector<string> substrings;
        rep(i, s.size()){
            if(s[i] == c){
                substrings.push_back(s.substr(i));
            }
        }
        sort(all(substrings));
        for(string t: substrings){
            if(fg) break;
            rep(i, t.size()){
                string u = t.substr(0, i+1);
                used.insert(u);
                if(used.size() == k){
                    cout << u << ln;
                    fg = true;
                    break;
                }
            }
        }
    }
} 


Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int64_t MOD=1000000007;

int main() {
  int N;
  cin>>N;
  vector<int64_t> count(N,0);
  vector<char> S(N);
  for(int i=0;i<N;i++) {
    cin>>S.at(i);
    if(i>0){
      if(S.at(i)=='E') count.at(0)++;
    }
  }
  for(int i=1;i<N;i++){
    int temp=0;
    if(S.at(i)=='E') temp--;
    if(S.at(i-1)=='W') temp++;
    count.at(i)=count.at(i-1)+temp;
  }
  sort(count.begin(),count.end());
  cout<<count.at(0)<<endl;
    
  

}


Measured memory_bytes: 2944
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Elastotenes's sieve -- START --
def elastotenesSieve(n):
  l1=list(range(2,n+1))
  l2=[]
  
  while True:
    if len(l1)==0:
      return l2
  
    n=l1[0]
    l2.append(n)
    for y in l1:
      if y%n==0:
        l1.remove(y)
# Elastotenes's sieve --- END ---

def main():
  n=I()
  l=elastotenesSieve(55555)

  ans=[]
  cnt=0
  for x in l:
    if x%5==1:
      ans.append(x)   
      cnt+=1

    if cnt==n:
      break

  return ' '.join([str(x) for x in ans])

# main()
print(main())


Measured memory_bytes: 67304
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;

#ifdef LOCAL
    #define debug(v) cerr<<v<<"\n"
#else
    #define debug(...) 42
#endif
#define out(v) cout<<v<<"\n"
#define _overload3(_1,_2,_3,name,...) name
#define _all1(a) (a).begin(),(a).end()
#define _all2(a,n) (a),(a)+n
#define all(...) _overload3(__VA_ARGS__,42,_all2,_all1,)(__VA_ARGS__)
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const int INF = 1e9;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

template<typename T>T gcd(T a, T b){return b?gcd(b,a%b):a;}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  ll A, B;
  cin >> A >> B;

  cout << A * B / gcd(A, B) << "\n";

  return 0;
}


Measured memory_bytes: 256
import collections
N , C = map(int, input().split())
ds =[list(map(int, input().split())) for i in range(C)]
cs =[list(map(int, input().split())) for i in range(N)]
c0 = collections.defaultdict(int)
c1 = collections.defaultdict(int)
c2 = collections.defaultdict(int)
for i in range(N):
    for j in range(N):
        if (i+j) % 3 == 0:
            c0[cs[i][j]] += 1
        elif (i+j) % 3 == 1:
            c1[cs[i][j]] += 1
        else:
            c2[cs[i][j]] += 1
            
d = 10**9
for i in range(C):
    for j in range(C):
        if i == j:
            continue
        for k in range(C):
            if i == k or j == k:
                continue
            d0 = 0
            for l in c0:
                d0 += c0[l] * ds[l-1][i]
            for l in c1:
                d0 += c1[l] * ds[l-1][j]
            for l in c2:
                d0 += c2[l] * ds[l-1][k]
            if d > d0:
                d = d0
            
print(d)

Measured memory_bytes: 5876
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int n;
vector <int> node[100005];
int solve(int indeks)
{
	if(node[indeks].size()==0)	//leaf
		return 0;
	int ret=0;
	vector <int> daftar;
	for(int i=0;i<node[indeks].size();i++)
		daftar.push_back(solve(node[indeks][i]));
	sort(daftar.begin(),daftar.end());
	for(int i=0;i<daftar.size();i++)
	{
		ret=max(ret,daftar[i]);
		ret++;
	}
	return ret;
}
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
	{
		int par;
		scanf("%d",&par);
		node[par].push_back(i);
	}
	cout<<solve(1)<<endl;
}

Measured memory_bytes: 13568