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

int main() {
  int a, b, c, n, min, mid, max;
  min = 0;
  mid = 0;
  max = 0;
  
  cin >> a >> b >> c;
  if (a < b) {
    if (a > c) {
      min = c;
      mid = a;
      max = b;
    }
    else {
      min = a;
      if (b < c){
        mid = b;
        max = c;
      }
      else {
        mid = c;
        max = b;
      }
    }
  }
  else if (b < c){
    min = b;
    if (a < c) {
      mid = a;
      max = c;
    }
    else {
      mid = c;
      max = a;
    }
  }
  else {
    min = c;
    mid = b;
    max = a;
  }

  cout << min << " " << mid << " " << max << endl;

}


Measured memory_bytes: 3104
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define N 2000005
#define ll long long
#define db double
#define dbg1(x) cout<<#x<<"="<<x<<" "
#define dbg2(x) cout<<#x<<"="<<x<<"\n"
int n,A[N],id[N],ans[N];
bool cmp(int t1,int t2) {return A[t1]<A[t2];}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&A[i]),id[i]=i;
	sort(id+1,id+1+n,cmp);
	for(int i=1;i<=n;i++)
	{
		if(i<=n/2) ans[id[i]]=A[id[n/2+1]];
		else ans[id[i]]=A[id[n/2]];
	}
	for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
}

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

int main(){
	int n; cin >> n;
	deque<long long> a(n), b(n);
	deque<pair<long long, int>> c(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		c[i] = {a[i] + b[i], a[i]};
	}
	sort(c.rbegin(), c.rend());
	bool turn = true;
	long long ans1 = 0;
	long long ans2 = 0;
	while (!c.empty()) {
		long long t;
		if (turn) {
			t = c.front().second;
			ans1 += t;
			c.pop_front();
		} else {
			t = c.front().first - c.front().second;
			c.pop_front();
			ans2 += t;
		}
		turn = !turn;
	}
	cout << ans1 - ans2 << endl;
	return 0;
}


Measured memory_bytes: 3584
#include <iostream>
using namespace std;
int main(void){

	int sum = 0;
	int coin; //[0] = 1, [1] = 5, [2] = 10, [3] = 50, [4] = 100, [5] = 500 (???)
	int mag[6] = { 1, 5, 10, 50, 100, 500 };

	for (int i = 0; i < 6; i++){

		cin >> coin;
		sum += coin * mag[i];
	}

	if (sum >= 1000) cout << '1' << endl;
	else cout << '0' << endl;
}

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

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

    int n;
    cin >> n;
    vector<int> X(n), Y(n);
    REP(i, n){
        cin >> X[i];
        Y[i] = X[i];
    }
    sort(Y.begin(), Y.end());
    
    REP(i, n){
        int idx = lower_bound(Y.begin(), Y.end(), X[i]) - Y.begin();
        if(idx < n / 2) cout << Y[n / 2] << endl;
        else cout << Y[n / 2 - 1] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

int dp[500][500];

void warshall_floyd(int n) { // nは頂点数
  for (int i = 0; i < n; i++)      // 経由する頂点
    for (int j = 0; j < n; j++)    // 開始頂点
      for (int k = 0; k < n; k++)  // 終端
        dp[j][k] = min(dp[j][k], dp[j][i] + dp[i][k]);
}


int main(){

  int H, W;
  char s[30][30];
  int dp_h;
  int ans = 0;

  //入力
  cin >> H >> W;
  REP(i, H){
    REP(j, W){
      cin >> s[i][j];
    }
  }

  //初期化
  REP(i, H*W){
    REP(j, H*W){
      dp[i][j] = MAX;
    }
  }


  REP(i, H){
    dp_h = W * i;
    REP(j, W){
      if( s[i][j+1] == '.' && s[i][j] == '.' ){
        dp[dp_h + j][dp_h + j+1] = dp[dp_h + j+1][dp_h + j] = 1;
      }
      if( s[i][j] == '.' && s[i+1][j] == '.' ){
        dp[dp_h + j][dp_h + j + W] = dp[dp_h + j + W][dp_h + j] = 1;
      }
    }
  }

  //REP(i, H*W){
  //  REP(j, H*W){
  //    cout << dp[i][j] << " ";
  //  }
  //  cout << endl;
  //}


  warshall_floyd(H*W);
  
  for (int i = 0; i < H*W; i++) {
    for (int j = 0; j < H*W; j++) {
      if (i != j && dp[i][j] != MAX)
        ans = max(ans, dp[i][j]);
    }
  }

  cout << ans << endl;

  return 0;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  int N; cin >> N;
  int C[N-1], S[N-1], F[N-1];
  rep(i,N-1) cin >> C[i] >> S[i] >> F[i];

  rep(i,N){
    int now = 0;
    for (int j = i;j<N-1;j++){
      if (now<=S[j]) now = S[j];
      else if (now%F[j]!=0) now += F[j]-(now%F[j]);
      
      now += C[j];
    }
    cout << now << endl;
  }

  return 0;
}


Measured memory_bytes: 256
sd = input()
t = input()
oks = []
for i in range(len(sd)-len(t)+1):
    sdd = sd[i:i+len(t)]
    f = True
    for j,sddj in enumerate(sdd):
        if sddj == "?":
            continue
        elif sddj != t[j]:
            f = False
            break
    if f:
        oks.append(i)
if oks:
    k = oks[-1]
    print((sd[:k]+t+sd[k+len(t):]).replace("?","a"))
else:
    print("UNRESTORABLE")

Measured memory_bytes: 9064
use List::Util qw/reduce/;
sub sum (@) {return reduce { $a+$b } @_}
my $input = <stdin>; chomp($input);
my ($n, $k) = split(' ', $input);
$input = <stdin>; chomp($input);
my @l = split(' ', $input);

print sum((sort {$b <=> $a} @l)[0..($k-1)]);

Measured memory_bytes: 640
s = list(input())
N = len(s)

#(方針)パーが使えるようになった瞬間パー使用 → gpgpgpgp...
win = 0
lose = 0
for i in range(N):
  if(i%2 == 0): #奇数回目 g
    my_hand = 'g'
    if(my_hand != s[i]): lose += 1 #負け
  else: #偶数回目 p
    my_hand = 'p'
    if(my_hand != s[i]): win += 1 #負け
  
ans = win-lose
print(ans)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
 
int main() {
    int n, t;
    cin >> t >> n;
    for (int ctr1 = n - t + 1; ctr1 < n + t; ++ctr1)
        cout << ctr1 << " ";
    return 0;
}

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

int main()
{
	int s=0,n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<k;i++)
		s+=a[i];
	cout<<s;
	return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
typedef vector<int> vi;
//const int MAX=;

int main(){
	double T,X;
	cin>>T>>X;
	cout<<T/X;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int H, W, i, j;

	while (1) {
		scanf("%d %d", &H, &W);

		if (H == 0 && W == 0) break;

		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


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


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


# @mt
def slv(N):
    return (N**2 - N)//2


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6212
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,gram;
    cin>>n>>gram;
    int weight[100009];
    for(int i=0;i<n;i++)
    {
        cin>>weight[i];
    }
    sort(weight,weight+n);
    int totalwight=0,Count=0;
    for(int i=0;i<n;i++)
    {
        totalwight+=weight[i];
        if(totalwight<gram)
        {
            Count++;
        }
        else
        {
            totalwight-=weight[i];
                break;
        }

    }
    //cout<<Count<<"*"<<endl;
    int m;
    if(totalwight<gram)
    {
         m=(gram-totalwight)/weight[0];
         Count=Count+m;
    }

    cout<<Count<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<ctime>
#include<ctime>
#include<map>
using namespace std;

#define INF (1 << 30)

struct treap_n{
  int value, pri, minimum, count;
  treap_n* right, *left;
  treap_n(int v){
    value = v;
    pri = rand() % INF;
    count = 1;
    minimum = v;
    right = left = 0;
  }
};

int node_count(const treap_n* r){
  if(r == 0)return 0;
  return r -> count;
}


int node_min(const treap_n* r){
  if(r == 0)return INF;
  return r -> minimum;
}

treap_n* update(treap_n* r){
  r -> count = node_count(r -> left) + node_count(r -> right) + 1;
  r -> minimum = min(node_min(r -> left), node_min(r -> right));
  r -> minimum = min(r -> minimum, r -> value);
  return r;
}

treap_n* merge(treap_n* a, treap_n *b){
  if(a == 0)return update(b);
  if(b == 0)return update(a);
  if(a -> pri > b -> pri){
    treap_n* tmp = a -> right;
    a -> right = merge(tmp, b);
    return update(a);
  }
  else{
    treap_n* tmp = b -> left;
    b -> left = merge(a, tmp);
    return update(b);
  }
}

pair<treap_n*, treap_n*> split(treap_n* r,int pos){
  if(r == 0) return make_pair((treap_n*)0, (treap_n*)0);
  int left_count = node_count(r -> left);
  if(pos > left_count){
    pair<treap_n*, treap_n*> tmp;
    tmp = split(r -> right, pos - left_count - 1);
    r -> right = tmp.first;
    return make_pair(update(r), tmp.second);
  }
  else{
    pair<treap_n*, treap_n*> tmp;
    tmp = split(r -> left, pos);
    r -> left = tmp.second;
    return make_pair(tmp.first, update(r));
  }
}

treap_n* insert(treap_n* r, int pos, treap_n* n){
  pair<treap_n*, treap_n*>tmp;
  tmp = split(r, pos - 1);
  r = merge(tmp.first, n);
  r = merge(r, tmp.second);
  return r;
}

treap_n* remove(treap_n* r,int pos){
  pair<treap_n*, treap_n*>tmp;
  tmp = split(r, pos - 1);
  r = merge(tmp.first, split(tmp.second, 1).second);
  return r;
} 

treap_n* node(treap_n* r, int pos){
  int left_count = node_count(r -> left);
  if(pos == left_count + 1){
    return r;
  }
  if(pos > left_count){
    return node(r -> right, pos - left_count - 1);
  }
  else{
    return node(r -> left, pos);
  }
}

treap_n* shift(treap_n* r, int left, int right){
  treap_n* tmp = node(r, right);
  r = remove(r, right);
  r = insert(r, left, tmp);
  return r;
}

int minimum(treap_n* r, int left, int right){
  pair<treap_n*, treap_n*> tmp1, tmp2 ;
  int res;
  tmp1 = split(r, left - 1);
  tmp2 = split(tmp1.second , right - left + 1);
  res = node_min(tmp2.first);
  r = merge(tmp1.first, merge(tmp2.first, tmp2.second));
  return res;
}

treap_n* change(treap_n* r, int pos, int val){
  r = remove(r, pos);
  r = insert(r, pos, new treap_n(val));
  return r;
}



int main(){
  int tmp, n, q, x, y, z;
  srand((unsigned int)time(0));
  cin >> n >> q;
  cin >> tmp;
  treap_n root(tmp);
  treap_n* r = &root;
  for(int i = 2;i <= n;i++){
    cin >> tmp;
    r = insert(r, i, new treap_n(tmp));
  }
  for(int i = 0;i < q;i++){
    cin >> x >> y >> z;
    if(x == 0){
      r = shift(r, y + 1, z + 1);
    }
    if(x == 1){
      cout << minimum(r, y + 1, z + 1) << endl;
    }
    if(x == 2){
      r = change(r, y + 1, z);
    }
  }
  return 0;
}

Measured memory_bytes: 13704
#include<stdio.h>
int main()
{
	int h,w,i,j,r,t;
	char c[128][128];
	scanf("%d %d",&h,&w);
	for(i=0;i<h;i++){
		scanf("%s",c[i]);
	}
	for(i=0;i<h;i++){
		if(c[i][0]=='c'){
			r=0;
			t=1;
		}else{
			r=-1;
			t=0;
		}
		printf("%d",r);
		for(j=1;j<w;j++){
			printf(" ");
			if(c[i][j]=='c'){
				r=0;
				t=1;
			}else{
				if(t==0){
					r=-1;
				}else{
					r++;
				}
			}
			printf("%d",r);
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2724
import math

A,B,H,M = map(int, input().split())

angleL = 2 * math.pi * (H*60+M) / (12*60)
angleS = 2 * math.pi * M / 60
angle = max(angleL, angleS) - min(angleL, angleS)


ans = math.sqrt(A*A + B*B - 2*A*B*math.cos(angle))
print(ans)


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

void solve()
{
	int b;
	while(cin >> b, b != 1)
	{
		vector<bool> flag(b + 1);
		int i = 1;
		cout << b << ":";
		while(true)
		{
			int x = 7 * i - 1;
			if(x > b)
			{
				break;
			}
			if(!flag[x] && b % x == 0)
			{
				cout << " " << x;
				for(int j = x; j <= b; j += x)
				{
					flag[j] = true;
				}
			}
			int y = 7 * i + 1;
			if(y > b)
			{
				break;
			}
			if(!flag[y] && b % y == 0)
			{
				cout << " " << y;
				for(int j = y; j <= b; j += y)
				{
					flag[j] = true;
				}
			}
			++i;
		}
		cout << endl;
	}
}

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

Measured memory_bytes: 1236
def main():
    s = [input() for l in range(2)]
    N, A = int(s[0]), [int(x) for x in s[1].split()]
    """
    results = []

    for i in range(0, (N), 1):
        flag = 0
        for j in range(0, (N), 1):
            if i == j:
                pass
            else:
                if A[i] % A[j] == 0:
                    flag = 1
                    break
                else:
                    pass
        if flag == 1:
            results.append(0)
        else:
            results.append(1)
    cnt = 0
    for x in results:
        if x == 1:
            cnt += 1
    print(cnt)
    """
    # 最大値
    maxA = max(A)
    # 要素の個数を管理
    C = {a: 0 for a in A}
    # 同じ要素が複数ある時点で必ず割り切れる
    # c[a] > 1なら無視できるよ
    for a in A:
        C[a] += 1
    # D
    D = {a: 0 for a in A}
    for a in A:
        if C[a] > 0:
            t = 2
            while a * t <= maxA:
                D[a*t] = 1
                t+= 1

    ans = 0
    for a in A:
        # 重複なし&約数なし
        if C[a] == 1 and D[a] == 0:
            ans += 1
    print(ans)



if __name__ == '__main__':
    main()

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

for i in range(k):
    if a >= b:
        b = b * 2
    else:
        if b >= c:
            c = c * 2
        else:
            break
if a < b < c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n,m;
  cin >> n >> m;

  if(n == m) cout << "Yes";
  else cout << "No";


  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int n;
    int i, x;//処理用
    
    //入力
    scanf("%d", &n);
    
    //処理と出力
    for (i=1; i<=n; i++) {
        x = i; //避難
        
        if (x%3 == 0) {
            printf(" %d", x);
        }else{
            while (x) {
                if (x%10 == 3) {
                    printf(" %d", i); //xではなくiじゃないといっぱい出てくる
                    break;
                }
                x = x / 10;
            }
        }
    }
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 2044
s = input()
l = len(s)
counter = 0
if s[0] == '1':
    for i in range(1, l):
        if i % 2 == 1 and s[i] == '1':
            counter += 1
        elif i % 2 == 0 and s[i] == '0':
            counter += 1
else:
    for i in range(1, l):
        if i % 2 == 1 and s[i] == '0':
            counter += 1
        elif i % 2 == 0 and s[i] == '1':
            counter += 1
print(counter)

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define mod 1000000007
using namespace std;
int main(){
    vector<int> num(3);
    rep(i,3) cin>>num[i];
    sort(num.begin(),num.end());
    cout<<num[0]<<" "<<num[1]<<" "<<num[2]<<endl;
}


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

int main(){
  int a,b;
  char op;
  while(cin >> a >> op >> b){
    if(op == '?'){
      break;
    }
    switch(op){
      case '+': cout << a+b << endl; break;
      case '-': cout << a-b << endl; break;
      case '*': cout << a*b << endl; break;
      case '/': cout << a/b << endl; break;
    }
  }
  return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<algorithm>
#include<math.h>
#include<complex>
#include<iomanip>
using namespace std;
int main(){
	int d,e;
	while(true){
	cin>>d>>e;
	if(d==0&&e==0)break;
	double ans=1000000;
	for(int i=0;i<=d/2;i++){
		double cnt=(double)sqrt((double)i*i*2+d*d-2*i*d+0.0);
		if(abs(e-cnt)<abs(e-ans))ans=cnt;
	}
	cout<<fixed<<setprecision(10)<<abs(e-ans)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1236
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        int param = scan.nextInt();

        int from = scan.nextInt();
        int to = scan.nextInt();

        boolean is = false;

        for (int i = from; i <= to; i++) {
            if (i % param == 0) {
                is = true;
            }
        }

        if (is) {
            System.out.println("OK");
        } else {
            System.out.println("NG");
        }
    }
}


Measured memory_bytes: 35692
from sys import stdin
 
inf = 10**9 + 1

def solve():
    n = int(stdin.readline())
    max_d = -inf
    min_v = inf * 2

    for i in range(n):
        r = int(stdin.readline())

        max_d = max(max_d, r - min_v)
        min_v = min(min_v, r)

    print(max_d)


def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None
 
if __name__ == '__main__':
    solve()

Measured memory_bytes: 7760
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main(){
    int d,g;
    cin >> d >> g;
    vector<int> p(d),c(d);
    for(int i = 0; i < d; i++)
        cin >> p[i] >> c[i];
        
    int loop = pow(2,d);
    int min = 10000;
    for(int i = 0; i <= loop-1; i++){
        int t = i,tg = g;
        vector<int> check(d,0);
        int j=0,count=0;
        while(t != 0){
            if(t%2 == 1){
                tg -= p[j]*(j+1)*100+c[j];
                count += p[j];
                check[j] = 1;
            }
            t /= 2;
            j++;
        }
        for(j = d-1; j >= 0; j--){
            if(tg <= 0)
                break;
            if(check[j] == 0){
                for(int k = 0; k < p[j]-1 && tg > 0; k++){
                    tg -= (j+1)*100;
                    count++;
                }
            }
        }
        //cout << count << endl;
        if(count < min && tg <= 0)
            min = count;
    }
    cout << min;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;

int main()
{
	int s,m,h;	
	cin >> s;
	h = s / 3600; s -= h*3600;
	m = s / 60; s -= m*60;
	cout << h << ":" << m << ":" << s << endl;;
}

Measured memory_bytes: 1168
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

n = int(input())
s = input()
#文字列だと一部分変更できないので配列に修正
ls = list(s)

for i in range(len(s)):
    idx = alpha.find(s[i])
    idx += n
    if idx >= 26:
        idx -= 26
    ls[i] = alpha[idx]

#配列から文字列生成
print("".join(ls))

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"sort"
	"strconv"
)

func main() {
	n := readInt()
	a, b := make([]int, n), make([]int, n)
	for i := range a {
		a[i] = readInt()
		b[i] = readInt()
	}
	sort.Ints(a)
	sort.Ints(b)

	if n%2 != 0 {
		fmt.Println(b[n/2] - a[n/2] + 1)
	} else {
		x := a[n/2-1] + a[n/2]
		y := b[n/2-1] + b[n/2]
		fmt.Println(y - x + 1)
	}
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 8352
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <complex>
#include <bitset>
#include <numeric>
using namespace std;

typedef long long LL; typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define OUT(a) cout<<(a)<<endl;
#define MOD 1000000007



long long modpow(long long a, long long n){
    if(n==0) return 1;
    long long re=modpow((a*a)%MOD,n/2)%MOD;
    if(n%2==1) re= (re*a)%MOD;
    return re;
}
class Modint{
    public:
    long long Mod = MOD;
    long long v;
    Modint():v(0){}
    template<typename T> Modint(T x){
        x %= Mod;
        long long y = (long long)x;
        if(y<0) y+=Mod;
        v=y;
    }
    Modint &operator+=(Modint a){
        v=(v+a.v)%Mod;
        return *this;
    }
    Modint &operator-=(Modint a){
        v=(v-a.v)%Mod;
        return *this;
    }
    Modint &operator*=(Modint a){
        v=(v*a.v)%Mod;
        return *this;
    }
    Modint &operator/=(Modint a){
        v=(v*modpow(a.v,Mod-2))%Mod;
        return *this;
    }
    Modint operator+(Modint a){
        long long t= (v)+(a.v);
        return Modint(t);
    }
    Modint operator-(Modint a){
        long long t= (v)-(a.v);
        return Modint(t);
    }
    Modint operator*(Modint a){
        long long t= (v)*(a.v);
        return Modint(t);
    }
    Modint operator/(Modint a){
        long long t=(v)*modpow(a.v,Mod-2);
        return Modint(t);
    }
};
ostream& operator<< (ostream& os, const Modint m) {
    return os << m.v;
}
Modint dp[404][404],po[404][404];
long long n,c,a[404],b[404];

void solve(int n, int c){
    REPN(i,1,n){
        REPN(j,0,c+1){
            FOR(k,0,j+1){
                dp[i][j]+=dp[i-1][j-k]*(po[b[i]][k]-po[a[i]-1][k]);

            }
            //OUT(dp[i][j])
        }
    }

}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> c;
    dp[0][0]=1;

    REP(i,n){
        cin >> a[i+1];
    }
    REP(i,n){
        cin >> b[i+1];
    }
    REPN(i,1,401){
        REPN(j,0,401){
            po[i][j]=po[i-1][j]+modpow(i,j);
            //OUT(po[i][j])
        }
    }
    solve(n,c);
    cout << dp[n][c] <<endl;



    return 0;
}



Measured memory_bytes: 5504
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;

typedef pair <int, int> pii;

int main()
{

	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n;
	ll x[100005] = {};
	ll y[100005] = {};
	ll t[100005] = {};
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> t[i];
		cin >> x[i];
		cin >> y[i];
	}
	for (int i = 1; i <= n; i++)
	{
		if (abs(t[i] - t[i - 1]) >= abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])
			&& (abs(t[i] - t[i - 1]))%2==((abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]))%2))
		{

		}
		else
		{
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
	
	
	//cout << ans << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main() {
  int H,W;
  cin >> H >> W;
  cout << string(W+2,'#') << endl;
  string S;
  while(cin >> S) {
    cout << '#' << S << '#' << endl;
  }
  cout << string(W+2,'#') << endl;
  return 0;
}


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

using namespace std;

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "yes"
#define FALSE__ "no"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

int main()
{
	string s;
	cin >> s;
	int l = s.length();
	UNIQUE(s);
	int l2 = s.length();
	PRINT(l==l2);
}


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

#ifdef LOCAL
        #include "debug.h"
        #define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        #else
        #define debug(...) 4
        #define input ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#endif

using ll = long long;
const int N = 2e5 + 5;
const int mod = 998244353;

int main() {
    input;
    ll n;
    cin >> n;
    int ans = 0;
    // vector<int> prime(1000001, 1);
    // for(int i = 2; i <= 1000000; i++) {
    //     for(int j = 2 * i; j <= 1000000; j += i)
    //         prime[j] = false;
    // }
    ll temp = n;
    for(int i = 2; i <= sqrt(n); i++) {
        int cnt = 0;
        while(temp % i == 0) {
            temp = temp / i;
            cnt++;
        }
        debug(cnt);
        int l = 0, h = 1e6;
        while(l + 1 < h) {
            int m = (l + h) / 2;
            if((1LL * m * (m + 1)) / 2 > cnt)
                h = m;
            else
                l = m;
        }
        debug(l);
        ans += l;

    }
    if(temp != 1)
        ans++;
    cout << ans;

}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

int N;

int main() {
	cin >> N;
	int ans = 0;
	for (int n = 1; n <= N; n++) {
		int counter = 0;
		int copy = n;
		while (copy > 0) {
			copy /= 10;
			counter++;
		}
		if (counter%2==1)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
#input=sys.stdin.readline
from collections import deque

r=False
d=deque(list(input()))
for i in range(int(input())):
  Q=input().split()
  if Q[0]=='1':
    r=not r
  else:
    if (Q[1]=='1' and not r) or (Q[1]=='2' and r):
      d.appendleft(Q[2])
    else:
      d.append(Q[2])

if r:
  d.reverse()

print("".join(list(d)))


Measured memory_bytes: 8420
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
const int N=1505;
vector<int> C[N],D[N];
int val[N][N],b[N][N],S[N],n,u[N][N],l[N],r[N];
char A[N][N];
bool flag[N][N];
int main(){
	scanf("%d",&n);
	for (register int i=1;i<=n;++i)scanf("%s",A[i]+1);
	for (register int i=1;i<=n;++i)
		for (register int j=1;j<=n;++j)flag[i][j]=A[i][j]>='0'&&A[i][j]<='9',b[i][j]=A[i][j]-'0';
	for (register int i=1;i<=n;++i)
		for (register int j=n;j;--j)
			if (flag[i][j])C[i].push_back(j);
			else D[i].push_back(j);
	for (register int i=0;i<=n;++i)
		for (register int j=0;j<=n;++j)u[i][j]=flag[i][j]?min(i,min(u[i-1][j],u[i][j-1])):1<<30;
	long long ans=0;
	for (register int x=1;x<=n;++x){
		for (register int j=1;j<=n;++j)S[j]=S[j-1]+(u[x][j]<=x?b[x][j]:0);
		for (register int j=n+1;j;--j){
			if (flag[x][j]){
				l[j]=j-1;
				r[j]=max(r[j+1],j);
				val[x][j]+=(S[r[j]]-S[l[j]]-b[x][j]);
			}
			else l[j]=n+1,r[j]=0;
		}
		for (register int i=x-1;i;--i){
			for (register int j=1;j<=n;++j)S[j]=S[j-1]+(u[x][j]<=i?b[x][j]:0);
			for (int j:D[i])l[j]=n+1,r[j]=0;
			for (int j:C[i]){
				val[i][j]+=S[r[j]=max(r[j+1],r[j])];
				val[i][j]-=S[l[j]=min(l[j+1],l[j])];
			}
		}
	}
	for (register int i=1;i<=n;++i)
		for (register int j=1;j<=n;++j)ans+=val[i][j]*b[i][j];
	printf("%lld\n",ans);
}


Measured memory_bytes: 18944
#include <stdio.h>
#define N 100000

int main(){
int i,s,n1,t,n2,teto[N],teto2[N],count=0;
int lef,mid,ri;
scanf("%d",&n1);
for(i=0;i<n1;i++){
scanf("%d",&teto[i]);
}
scanf("%d",&n2);
for(i=0;i<n2;i++){
scanf("%d",&teto2[i]);
}
for(i=0;i<n2;i++){
ri=n1-1;
lef=0;
while(lef<ri){
mid=(lef+ri)/2;
if(teto[mid]==teto2[i]||teto[lef]==teto2[i]||teto[ri]==teto2[i]){
count++;
break;
}
else if(teto[mid]<teto2[i]){
lef=mid+1;
}
else{
ri=mid;
}
}
}



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


return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,q; cin>>n>>q;vector<ll> h(n+1,n),w(n+1,n);ll a=(n-2)*(n-2),H=n,W=n;
    while(q--){ll t,x; cin>>t>>x;if(t&1){if(x<W){for(ll i=x;i<W;i++)w[i]=H;W=x;}a-=w[x]-2;}else{if(x<H){for(ll i=x;i<H;i++)h[i]=W;H=x;}a-=h[x]-2;}}
    cout<<a;
}

Measured memory_bytes: 6356
s = input()
a = [0]*len(s)
b = [0]*len(s)
t = s[::-1]
for i in range(len(s)):
    if s[i] == "R":
        a[i] =+ a[i-1] + 1
        a[i-1] = 0
    if t[i] == "L":
        b[i] =+ b[i-1] + 1
        b[i-1] = 0
c = [0]*len(s)
d = [0]*len(s)
import math
for i in range(len(s)-1):
    if a[i] != 0:
        c[i] = math.ceil(a[i]/2)
        c[i+1] = a[i] - c[i]
    if b[i] != 0:
        d[i] = math.ceil(b[i]/2)
        d[i+1] = b[i] - d[i]
d = d[::-1]
u = [x+y for (x, y) in zip(c, d)]
ans = ' '.join([str(n) for n in u])
print(ans)

Measured memory_bytes: 16772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  vector<vector<int>> dp(n+1,vector<int>(n+1,0));
  rep(i,n)for(int j=i;j<n;j++){
    if(s[i]==s[j]) dp[i+1][j+1] = dp[i][j] +1;
    else dp[i+1][j+1] = 0;
  }
  int ans = 0;
  rep(i,n+1){
    for(int j=i;j<n+1;j++){
      ans = max(ans,min(dp[i][j],j-i));
      //cout << min(dp[i][j],j-i) <<" ";
    }
    //cout << endl;
  }  
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 98176
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

ll ans=-1;

void check(ll a){
	string s=to_string(a);
	bool ok=true;
	rep(i,s.size()-1){
		ok&=(s[i]+1==s[i+1]+0);
	}
	if(ok)chmax(ans,a);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vl v(n);
	rep(i,n)cin>>v[i];
	rep(i,n){
		rep(j,i){
			check(v[i]*v[j]);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3284
use proconio::input;

fn main() {
    input! {
        a: u64,
        b: String,
    }
    let b = b
        .split('.')
        .collect::<Vec<_>>()
        .concat()
        .parse::<u64>()
        .unwrap();
    println!("{}", a * b / 100);
}


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

int main(){
	int s; cin >> s;
	set<int> se;
	se.insert(s);
	int term = s;
	for(int i = 2; ;++i){
		if( term % 2 == 0 ){
			term /= 2;
			if(se.count(term) == 1){
				cout << i << endl;
				break;
			}
			else se.insert(term);
		}
		else {
			term = 3 * term + 1;
			if(se.count(term) == 1){
				cout << i << endl;
				break;
			}
			else se.insert(term);
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
double a[110];

bool cmp(int a,int b)
{
	return a>b;
}

int main(void)
{
	double sum=0;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	sort(a,a+n,cmp);
	double c=sum/(4*m);
	if(a[m-1]<c)
		printf("No");
	else
		printf("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double

using namespace std;
ll n, t, sum, mx, mn, m, k;

void solve(){
	cin >> n >> m;
	if(m > n) swap(m, n);
	for(int i = 0; i < n; i++)
	cout << m;
}

int main()
{
	t = 1;
//	cin >> t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 256
INF = 10 ** 20
n, m = map(int, input().split())
dist = [int(input()) for _ in range(n)]
weth = [int(input()) for _ in range(m)]
dp = [INF] * (n + 1)
dp[0] = 0
for i in range(m):
  for j in range(n, 0, -1):
    dp[j] = min(dp[j], dp[j - 1] + dist[j - 1] * weth[i])
print(dp[n])


Measured memory_bytes: 5624
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  vector<pair<int,int>> C;
  for(int i = 0; i < N/4; ++i){
    C.emplace_back(i+1,N/4*2-i);
  }
  for(int i = 0; i < N/2-N/4; ++i){
    C.emplace_back(N/4*2+1+i,N-(1-N%2)-i);
  }
  for(int i = 0; i < M; ++i)
    cout << C[i].first << " " << C[i].second << endl;
}


Measured memory_bytes: 4260
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> p, q;
    rep(i, M)
    {
        int pp, qq;
        cin >> pp >> qq;
        if (pp == 1 || qq == N)
        {
            p.push_back(pp);
            q.push_back(qq);
        }
    }

    map<int, int> mp;

    rep(i, p.size())
    {
        if (p[i] == 1)
        {
            if (!mp.count(q[i]))
            {
                mp[q[i]] = 1;
            }
        }
    }
    rep(i, p.size())
    {
        if (q[i] == N)
        {
            if (mp.count(p[i]))
            {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 6508
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;

int k, d[111111];
priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;

int main() {
    scanf("%d", &k);
    que.push({ 1,1 });
    fill(d, d+110000, 1e9);
    d[1] = 1;
    while (!que.empty()) {
        auto now = que.top();
        que.pop();

        if (d[now.first] != now.second) {
            continue;
        }

        int nxt = (now.first*10)%k;
        if (d[nxt] > now.second) {
            d[nxt] = now.second;
            que.push({ nxt,now.second });
        }
        nxt = (now.first+1)%k;
        if (d[nxt] > now.second+1) {
            d[nxt] = now.second+1;
            que.push({ nxt,now.second+1 });
        }
    }

    printf("%d\n", d[0]);

    return 0;
}

Measured memory_bytes: 2804
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, a, b;
    cin >> n >> a >> b;

    if (a + b > n + 1 || a * 1LL * b < n) {
        cout << -1 << '\n';
        return 0;
    }

    vector<int> res;

    for (int i = 0, x = 1; i < a; ++i) {
        int cnt = min(b, (n - x + 1) - (a - i - 1));
        assert(cnt > 0);
        int sz = res.size();
        for (int j = 0; j < cnt; ++j) {
            res.push_back(x++);
        }
        reverse(res.begin() + sz, res.begin() + sz + cnt);
    }


    assert(res.size() == n);
    for (int i = 0; i < n; ++i) {
        cout << res[i] << (i == n - 1 ? '\n' : ' ');
    }

    return 0;
}

Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
int calDigits(long long n)
{
	if(n==0)
		return 0;
	else
		return 1+calDigits(n/10);
}
int main() {
	long long n;
	cin >> n;
	int i;
	for(i=sqrt(n);i>1&&n%i!=0;i--);
	cout << max(calDigits(i),calDigits(n/i));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

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

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  int x = 0;
  vector<int> vec(35);
  rep(i, n) {
    int a; cin >> a;
    x ^= a;
    int cnt = 0;
    while (a%2 == 0) {
      cnt++;
      a /= 2;
    }
    vec[cnt]++;
  }

  int ans = 0;
  for(int j=30; j>=0; j--) {
    int s = 1<<j;
    if (x&s) {
      //debugln(s);
      if (vec[j]) {
        ans++;
        x ^= (s-1);
      } else {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;

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

    int ans=0;
    for(int k=1;k<=360;k++)
    {
        if((k*x)%360==0)
        {
            ans=k;
            break;
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3540
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

  int c[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>c[i][j];
    }
  }
  int ans;
  ans=0;

  for(int k=0;k<2;k++){
    int j=0;
      if(c[k][j]-c[k+1][j]!=c[k][j+1]-c[k+1][j+1]){ans=1;}
      if(c[k][j]-c[k+1][j]!=c[k][j+2]-c[k+1][j+2]){ans=1;}
  }

  for(int j=0;j<2;j++){
    int k=0;
      if(c[j][k]-c[j+1][k]!=c[j][k+1]-c[j+1][k+1]){ans=1;}
      if(c[j][k]-c[j+1][k]!=c[j][k+2]-c[j+1][k+2]){ans=1;}
  }

  if(ans==0){cout<<"Yes";}
  else{cout<<"No";}

  return 0;
  

}

Measured memory_bytes: 256
#include <stdio.h>

int max(int a,int b){return a>b?a:b;}

int n;
int a[200050];

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);

    int left[200050];
    int right[200050];
    
    for(int i=1;i<n;i++)
    {
        left[i]=max(left[i-1],a[i-1]);
    }
    for(int i=n-2;i>=0;i--)
    {
        right[i]=max(right[i+1],a[i+1]);
    }

    for(int i=0;i<n;i++)
    {
        printf("%d\n",max(left[i],right[i]));
    }
}

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

using lint = long long;
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  lint a[3];
  for (int i = 0; i < 3; i++) {
    cin >> a[i];
  }
  sort(a, a + 3);

  cout << (a[1] - a[0]) + (a[2] - a[1]) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9 + 7;
const int INT_MOD=1e9+7;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 0; i <= n; i++)
#define rrep(i,n) for(int i=n;i>0;i--)
#define RREP(i,n) for(int i=n;i>=0;i--)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
int n;
//sushiのある皿がそれぞれi,j,k枚だった時の期待値
double sushi[310][310][310];
double dp(int i,int j,int k){
    if(sushi[i][j][k]){
        //一回訪れているとき，もう期待値が変わることはない
        if(sushi[i][j][k]>=0) return sushi[i][j][k];
        //もうsushiが無い
        if(i==0 and j==0 and k==0) return 0.0;
        double res=0;
        if(i>0) res+=dp(i-1,j,k)*i;
        if(j>0) res+=dp(i+1,j-1,k)*j;
        if(k>0) res+=dp(i,j+1,k-1)*k;
        //期待値の計算(余分な皿に行くことこあるためnを足す)
        res=(res+n)/(i+j+k);
        return sushi[i][j][k]=res;
    }
}
signed main(){
    cin>>n;
    int one=0,two=0,three=0;
    rep(i,n){
        int x;
        cin>>x;
        if(x==1) one++;
        else if(x==2) two++;
        else three++;
    }
    memset(sushi,-1,sizeof(sushi));
    printf("%.16f\n",dp(one,two,three));
    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int array[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> array[i];
	}

	int answerArray[n] = {0};
	int startIndex = 0, endIndex = n - 1;
	for (int i = 0; i < n; ++i)
	{
		if (i%2 == 0) 
		{
			answerArray[startIndex++] = array[n - 1 - i];
		}
		else
		{
			answerArray[endIndex--] = array[n - 1 - i];
		}
	}

	for (int i = 0; i < n; ++i)
	{
		cout << answerArray[i] << " ";
	}

	return 0;
}

//	2,1,3	3,1,2,4		4,2,1,3,5	5,3,1,2,4	6,4,2,1,3,5

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
pair<int,int> a[N];
int n;
int main()
{
	scanf("%d",&n);
	for (int i=1,x,y;i<=n;i++) scanf("%d%d",&x,&y), a[i]=make_pair(x+y,x-y);
	sort(a+1,a+1+n);
	int cur=-1e9,ans=0;
	for (int i=1;i<=n;i++)
		if (cur<=a[i].second) ans++, cur=a[i].first;
	printf("%d\n",ans);
}


Measured memory_bytes: 1024