akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const ll INF = 1e18;

struct ST {
  ll a, b;
};
bool operator==(const ST& x, const ST& y){
  return (x.a == y.a && x.b == y.b);
}

int N, M;
vector<pair<ll,ll>> G[100005];
vector<ST> states[100005];


int main(){
  cin >> N >> M;
  rep(i,M){
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    G[a].emplace_back(b,c);
    G[b].emplace_back(a,c);
  }

  queue<pair<int,ST>> que;
  que.push(make_pair(0,(ST){1,0}));
  while(!que.empty()){
    pair<int,ST> p = que.front(); que.pop();

    bool flg = false;
    rep(i,states[p.first].size()){
      if(states[p.first][i] == p.second) flg = true;
    }
    if(flg) continue;
    states[p.first].push_back(p.second);

    if(states[p.first].size() > 2){
      cout << 0 << endl;
      return 0;
    }

    rep(i,G[p.first].size()){
      pair<ll,ll> j = G[p.first][i];
      que.push(make_pair(j.first,(ST){-p.second.a,j.second-(p.second.b)}));
    }
  }

  ll lb = 0, ub = INF;
  rep(i,N){
    if(states[i].size() == 1){
      if(states[i][0].a > 0){
        //x+b>0
        lb = max(lb, -states[i][0].b);
      }else{
        //-x+b>0
        ub = min(ub, states[i][0].b);
      }
    }else{
      if(states[i][0].a > 0 && states[i][1].a < 0){
        lb = max(lb, -states[i][0].b);
        ub = min(ub, states[i][1].b);

        //x+a == -x+b <=> x = (b-a)/2 > 0
        if(llabs(states[i][1].b - states[i][0].b)%2 == 0){
          ll x = (states[i][1].b - states[i][0].b) / 2;
          lb = max(lb, x-1);
          ub = min(ub, x+1);
        }else{
          cout << 0 << endl;
          return 0;
        }
      }
      else if(states[i][0].a < 0 && states[i][1].a > 0){
        ub = min(ub, states[i][0].b);
        lb = max(lb, -states[i][1].b);

        //-x+a == x+b <=> x = (a-b)/2 > 0
        if(llabs(states[i][0].b - states[i][1].b)%2 == 0){
          ll x = (states[i][0].b - states[i][1].b) / 2;
          lb = max(lb, x-1);
          ub = min(ub, x+1);
        }else{
          cout << 0 << endl;
          return 0;
        }
      }
      else{
        cout << 0 << endl;
        return 0;
      }
    }
  }

  lb++;
  if(ub-lb <= 0) cout << 0 << endl;
  else cout << ub - lb << endl;

  return 0;
}


Measured memory_bytes: 18192
from math import *

def func(x):
  ret_val=0
  while 0<x:
    x//=10
    ret_val+=1
  return ret_val

N=int(input())
ans=func(N)
for A in range(1,int(sqrt(N))+1):
  if N%A==0:
    B=N//A
    temp=max(func(A),func(B));
    ans=min(ans,temp)
print(ans)


Measured memory_bytes: 9112
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;

struct Node{
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x){
	while (x->left != NIL) x = x->left;
	return x;
}

Node * find(Node *u, int k){
	while (u != NIL && k != u->key){
		if (k < u->key) u = u->left;
		else u = u->right;
	}
	return u;
}

Node * treeSuccessor(Node *x){
	if (x->right != NIL) return treeMinimum(x->right);
	Node *y = x->parent;
	while (y != NIL && x == y->right){
		x = y;
		y = y->parent;
	}
	return y;
}

void treeDelete(Node *z){
	Node *y;
	Node *x;

	if (z->left == NIL || z->right == NIL) y = z;
	else y = treeSuccessor(z);

	if (y->left != NIL){
		x = y->left;
	}
	else {
		x = y->right;
	}

	if (x != NIL){
		x->parent = y->parent;
	}

	if (y->parent == NIL){
		root = x;
	}
	else {
		if (y == y->parent->left){
			y->parent->left = x;
		}
		else {
			y->parent->right = x;
		}
	}

	if (y != z){
		z->key = y->key;
	}

	free(y);
}

void insert(int k){
	Node *y = NIL;
	Node *x = root;
	Node *z;

	z = new Node;
	z->key = k;
	z->left = NIL;
	z->right = NIL;

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

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

void inorder(Node *u){
	if (u == NIL) return;
	inorder(u->left);
	cout << " " << u->key;
	inorder(u->right);
}

void preorder(Node *u){
	if (u == NIL) return;
	cout << " " << u->key;
	preorder(u->left);
	preorder(u->right);
}

int main(){
	int n, i, x;
	string com;

	cin >> n;

	for (i = 0; i < n; i++){
		cin >> com;
		if (com[0] == 'f'){
			cin >> x;
			Node *t = find(root, x);
			if (t != NIL) cout << "yes" << endl;
			else cout << "no" << endl;
		}
		else if (com == "insert"){
			cin >> x;
			insert(x);
		}
		else if (com == "print"){
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
		else if (com == "delete"){
			cin >> x;
			treeDelete(find(root, x));
		}
	}
	
	return 0;
}

Measured memory_bytes: 19960
import sys
from operator import itemgetter


fin = sys.stdin.readline
N = int(fin())
ab_list = [[int(elem) for elem in fin().split()] for _ in range(N)]

ab_list = sorted(ab_list, key=itemgetter(1, 0))

current_time = 0
result = True
for ab in ab_list:
    a, b = ab
    current_time += a
    if current_time > b:
        result = False
        break
if result:
    print('Yes')
else:
    print('No')


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

int main()
{ 
  int a, b;
  cin >> a >> b ;
  int judge = b - a ;
  int length = 0 ;

  for(int i = 1 ; i <= judge ; i++)
  {
    length += i ;
  }

  cout << length - b << endl ;
}


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

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == 0) {
			cout << "0" << "\n";
			return 0;
		}
	}
    
    ll prod = 1;

    for (int i = 0; i < n; i++) {
    	if (a[i] <= INF / prod) {
    		prod *= a[i];
    	}
    	else {
    		cout << "-1" << "\n";
    		return 0;
    	}
    }
    cout << prod << "\n";

	return 0;
}


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

int n,a,b;
long long ans=0;

bool check(int x) {
	int sum=0;
	while(x) {
		sum+=x%10; x/=10;
	}
	if(sum>=a && sum<=b) return true;
	return false;
}

int main() {
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++) {
		if(check(i)) {
			ans+=i;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    int N, X;
    cin >> N >> X;
    int ans = 1;
    int now = 0;
    rep(i, N) {
        int tmp;
        cin >> tmp;
        now += tmp;
        if (now > X) break;
        ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
A, B, C, D, E  = [int(input()) for i in range(5)]
S = [A, B, C, D, E]
s = []

for i in S:
    s.append(i%10)

for i in range(5):
    if s[i]==0:
        s[i]=9

for i in range(5):
    if s[i]==min(s):
        tmp = S[i]
        S.pop(i)
        break

sum = 0
for i in S:
    if i%10!=0:
        sum += (i//10+1)*10
    elif i%10==0:
        sum += i

print(sum+tmp)

Measured memory_bytes: 3064
n,m=map(int,input().split())
def divisors(n):
  div=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      div.append(i)
      if not i==n//i:
        div.append(n//i)
  div=sorted(div)[::-1]
  return div
ans=1
for i in divisors(m):
  if m-i*(n-1)>0:
    ans=i
    break
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    char c;
    cin>>c;
    puts(c<'a'?"A":"a");
}

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

int main() {

    int a, b,c,tmp;
    cin >> a >> b >> c  ;

    if(a>b)
    {
        tmp = a;
        a = b;
        b = tmp;

    }
    if(b>c)
    {
         tmp = b;
        b = c;
        c = tmp;
    }

    if(a>b)
    {
         tmp = a;
        a = b;
        b = tmp;
    }
    cout << a << " " << b << " " << c <<endl;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define all(n)      (n).begin(), (n).end()
#define ll long long
#define ull unsigned long long int
void solve() {
    ll n; cin >> n;

    string s,a = ""; cin >> s;
    int rcnt = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'R'){
            rcnt++;
        }
    }
    int wcnt = s.size() - rcnt;
    while(rcnt--){
        a += 'R';
    }
    int ans = 0;
    for(int i = 0;i < a.size(); i++){
        if(s[i] != a[i]){
            ans++;
        }
    }
    cout << ans << endl;
}
int main(){

        solve();
    return 0;
            
}

Measured memory_bytes: 3924
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int k, q;
	vector<int> d;
	
	cin>>k>>q;
	
	d.resize(k);	


	for(int i = 0; i < k; i++){
		cin>>d[i];
	}
	
	for(int i = 0; i < q; i++){
		int n, x, m, ans = 0, sum = 0;
		
		cin>>n>>x>>m;
		
		sum = x;
		
		for(int i = 0; i < k; i++){
			if(d[i] % m == 0) {
				ans += (n - 1 - i + k - 1) / k;
			}
			sum += (d[i] % m) * ((n - 1 - i + k - 1) / k);
		}
		
		
		ans += sum / m - x / m;
		
		ans = n - 1 - ans;
		
		cout<<ans<<endl;
	}
	
	return 0;
}

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

typedef long long ll;
const int MaxN = 3001;
const ll mod = 1000000007;
ll dp[MaxN][MaxN];

class Solver {
	int n; ll *a;
	ll* pre;
public :
    Solver() {
		solve();
	}
	void solve();
};

void Solver::solve() {
	//cout << "hello\n";
	cin >> n;

	a = new ll[n];
	for (int i = 0; i < n; i++) cin >> a[i];

	pre = new ll[n + 1];
	pre[0] = 0;
	for(int i = 1; i <= n; i++) {
		pre[i] = pre[i - 1] + a[i - 1];
	}

	for (int i = 1; i <= n; i++) {
		dp[i][i] = pre[i] - pre[i - 1];
	}

	for (int len = 2; len <= n; len++) {
		for (int i = 1; i <= n; i++) {
			int j = i + len - 1;
			if (j > n) break;
			ll sum = pre[j] - pre[i - 1];
			dp[i][j] = max(sum - dp[i][j - 1], sum - dp[i + 1][j]);
		}
	}
	
	cout << 2*dp[1][n] - pre[n] << "\n";
}

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

    ll t=1;
    //cin >> t;
    while(t--) {
		Solver s;
	}
}


Measured memory_bytes: 49808
n=int(input());
A=[int(input().replace(' ',''),2)for _ in[0]*n]
p=[0]*2**n
p[0]=1
for I in range(2**n-1):
 a=A[bin(I).count('1')]&~I
 for j in range(n):
  if a&1<<j:p[I|1<<j]+=p[I];p[I|1<<j]%=10**9+7
print(p[-1])

Measured memory_bytes: 58844
/**
*    author:  boutarou
*    created: 21.06.2020 21:03:04
**/

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

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

const double PI = 3.1415926535897932;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    lint n;
    cin >> n;
    n--;
    string ans;
    while (n >= 0) {
        ans += 'a' + n % 26;
        n /= 26;
        n--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1,
    x=-x;
  }
  while(x){
    f[s++]=x%10,
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N, Y;
int main(){
  int i, j, k;
  rd(N);
  rd(Y);
  Y /= 1000;
  for(i=Y%5;i<=N;i+=5){
    for(j=0;j<N+1-i;j++){
      k = N - i - j;
      if(i+5*j+10*k==Y){
        wt_L(k);
        putchar_unlocked(' ');
        wt_L(j);
        putchar_unlocked(' ');
        wt_L(i);
        putchar_unlocked('\n');
        return 0;
      }
    }
  }
  wt_L(-1);
  putchar_unlocked(' ');
  wt_L(-1);
  putchar_unlocked(' ');
  wt_L(-1);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20180107-1

// --- original code ---
// int N, Y;
// {
//   int i, j, k;
//   
//   rd(N,Y);
//   Y /= 1000;
// 
//   for(i=Y%5;i<=N;i+=5) rep(j,N+1-i){
//     k = N - i - j;
//     if(i+5j+10k==Y){
//       wt(k,j,i);
//       return 0;
//     }
//   }
//   wt(-1,-1,-1);
// }


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 13 22:46:19 2019

"""


N,K,Q=( int(x) for x in input().split())


s=[input() for i in range(Q)]

Point=[0]*N


for i in s:
    Point[int(i)-1]=Point[int(i)-1]+1


for i in Point:
    if i >(Q-K) :
        print('Yes')
    else :
        print('No')
        

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

#include <iostream>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> ln(n);
  for (auto& li : ln) {
    cin >> li;
  }
  sort(ln.begin(), ln.end(), std::greater<int>());
  int total = 0;
  for (int i = 0; i < k; ++i) {
    total += ln[i];
  }
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 256
a,b,c,x,y=gets.split.map(&:to_i)
if a+b<=2*c
  p a*x+b*y
elsif x>y
  if a>c*2
    p x*2*c
  else
    p y*2*c+(x-y)*a
  end
else
  if b>c*2
    p y*2*c
  else
    p x*2*c+(y-x)*b
  end
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    
    int a,b,x; cin >> a >> b >> x;
    if(x-a <= b && x >= a) YES;
    else NO;

    return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n , k  ;
  cin >> n >> k ;
  
  vector<int> v(n) ;
  rep(i,k){
    int c ;
    cin >> c ;
    rep(j,c){
      int a ;
      cin >> a ;
      a-- ;
      v.at(a) ++;
    }
  }
  
  int ans = 0 ;
  rep(i,n){
    if(v.at(i) == 0 )
      ans ++ ;
  }

  
  cout << ans ;
  
  
}


Measured memory_bytes: 3632
import sys

def read_inputs():
    inputs = []
    for i in range(9):
        try:
            inputs.append(raw_input())
        except EOFError:
            sys.exit()
    return inputs

def create_routes(inputs):
    for y, line in enumerate(inputs):
        for x, c in enumerate(list(line)):
            if c == '1':
                if y % 2 == 0:
                    dots[y/2][x]["R"] = 1
                    dots[y/2][x+1]["L"] = 1
                else:
                    dots[y/2][x]["D"] = 1
                    dots[y/2+1][x]["U"] = 1

def move_person(dots):
    ret, current = "", "R"
    x, y = 0, 0

    def find(indexs):
        dic = ("R", "D", "L", "U",)
        for i in indexs:
            if dots[y][x][dic[i]]:
                return dic[i]
        return ""

    while True:
        ret += current
        if current == "R":
            x += 1
            current = find([3, 0, 1, 2])
        elif current == "D":
            y += 1
            current = find([0, 1, 2, 3])
        elif current == "L":
            x -= 1
            current = find([1, 2, 3, 0])
        elif current == "U":
            y -= 1
            current = find([2, 3, 0, 1])
        else:
            print "wrong data"
        if x == 0 and y == 0:
            break
    return ret

dots = [[{'U': 0, 'D': 0, 'L': 0, 'R': 0} for i in range(5)] for j in range(5)]

inputs = read_inputs()

create_routes(inputs)

print move_person(dots)

Measured memory_bytes: 4312
/*input
atcoder
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-6;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll sub(ll a,ll b){
    ll x=a-b;
    while(x<0) x+=MOD;
    while(x>MOD) x-=MOD;
    return x;
}
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
const ll maxn=1e5+5;
const ll maxlg=__lg(maxn)+2; 
bool ispal(string s){
	REP(i,sz(s)){
		if(s[i]!=s[sz(s)-i-1]){
			return false;
		}
	}
	return true;
}
int main(){
	string s;
	cin>>s;
	int n=sz(s);
	if(ispal(s) and ispal(s.substr(0,(n-1)/2)) and ispal(s.substr((n+3)/2-1))){
		cout<<"Yes";
	}
	else cout<<"No";
}


Measured memory_bytes: 256
n,i,a[100009];main(){
	scanf("%d",&n);for(i=0;i<n;i++)scanf("%d",&a[i]);
	for(i=n-1;i>=1;i--){
    	if(a[i]<a[i-1])a[i-1]--;
    	if(a[i]<a[i-1]){printf("No");return 0;}
	}
	printf("Yes");
}

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

const long long maxn = 2e5 + 10;
const long long inf = 1e9 + 7;

long long n, h, a[maxn], b[maxn];
int dp[maxn];
long long ans;

void in();
void solve();
void out();

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> h >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
}

void solve(){
    for(int i = 1; i <= h; i++){
        dp[i] = inf;
        for(int j = 0; j < n; j++){
            int chiz;
            if(i - a[j] <= 0)
                chiz = b[j];
            else
                chiz = b[j] + dp[i - a[j]];
            dp[i] = min(dp[i], chiz);
        }
    }
    ans = dp[h];
}

void out(){
    cout << ans;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
  char w[11], t[1001];
  int count = 0;
  int len;
  int i;

  scanf("%s", w);

  while (1) {
    scanf("%s", t);
    len = strlen(t);

    if (strcmp("END_OF_TEXT", t) == 0) {
      break;
    } else {
      for (i = 0; i < len; i++) {
        t[i] = tolower(t[i]);
      }
      if (strcmp(t, w) == 0)
        ++count;
    }
  }

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

  return 0;
}



Measured memory_bytes: 2124
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,m,c;
  cin>>n>>m>>c;
  vector<int> b(m);
  for(int i=0; i<m; i++){
    cin>>b.at(i);
  }
  vector<vector<int>> a(n,vector<int>(m));
  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      cin>>a.at(i).at(j);
    }
  }

  long long int ans=0;
  for(int i=0; i<n; i++){
    long long int pre=0;
    for(int j=0; j<m; j++){
      pre+=b.at(j)*a.at(i).at(j);
    }
    pre+=c;
    if(pre>0){
      ans++;
    }
  }
  cout<<ans<<endl;
}

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


using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(n) n.begin(),n.end()
#define eb emplace_back
#define endl "\n"

const ll maxn=5e5;

const ll maxx=1e13;
const ll mod=1000000007;
const ll mod1=998244353;

vector<ll> adj[maxn];
ll h[maxn];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("test.txt","r",stdin);
    //   freopen("GREEDY.INP", "r", stdin);
    //  freopen("GREEDY.OUT", "w", stdout);
    ll x;
    cin>>x;
     for (ll i=-1234;i<=1234;i++)
     {
         ll t= i*i*i*i*i+x;
        // if (t==34) cout <<i;
         ll l=-1234,h=1234;
         while (l<=h)
         {
             ll m=(l+h)/2;
             if (m*m*m*m*m>t) h=m-1;
             else l=m+1;
         }
       // if (t==34) cout <<l ;
         if (h*h*h*h*h==t)
         {
             cout <<h<<" "<<i;
             return 0;
         }
     }


}


Measured memory_bytes: 15376
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define PI 3.14159265359
using namespace std;
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> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
vector<int> Eratosthenes(const int N)
{
    vector<bool> is_prime(N+1, true);
    vector<int> P;
    for(int i=2; i<=N; i++) {
        if (is_prime[i]) {
            for(int j=2*i; j<=N; j+=i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}

int main() {
    int n;
    cin >> n;
    vector<int> V(n);
    vector<int> C(n);
    rep(i,n) {
        cin >> V[i];
    }
    rep(i,n) {
        cin >> C[i];
    }
    vector<int> dp(n+1);
    dp[0] = 0;
     rep(i,n) {
         dp[i] = max(dp[i-1], dp[i-1]+V[i]-C[i]);
     }
     cout << dp[n-1] << "\n";

}


Measured memory_bytes: 256
import Data.List
import Control.Applicative

solver :: Int->[Int]->Int
solver k list = sum $ take k $ reverse $ sort list

main :: IO ()
main = do
    -- スペース区切り整数の入力
    [n, k] <- map read . words <$> getLine
    list <- map read . words <$> getLine
    -- 出力
    putStrLn $ show $ solver k list



Measured memory_bytes: 764
import java.util.Scanner;

public class Main {

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

        int k = scanner.nextInt();
      String s = scanner.next();

      if( s.length() <= k ) {
          System.out.println( s );
      }else if( s.length() > k ) {
          String sk = s.substring( 0 , k );
          System.out.println( sk + "...");
      }


      scanner.close();
    }

}

Measured memory_bytes: 38588
#include <stdio.h>

int main (){
int A,B,C,D,E,F;

scanf("%d",&A);
scanf ("%d",&B);

C=A+B;
D=A-B;
E=A*B;

if (C<D){
F=C;
C=D;
}
if (C<E){
C=E;
}
printf("%d",C);
return 0;
}

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

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

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

    bool flag[30] = {};
    string S; cin >> S;

    for (int i = 0;i < S.size();i++){
        if(flag[S[i]-'a']){
            cout << "no" << endl;
            return 0;
        }
        flag[S[i]-'a'] = true;
    }

    cout << "yes" << endl;

    return 0;

}

Measured memory_bytes: 256
def test():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    dp = [float('inf')]*N
    dp[0] = 0
 
    for i in range(1, N):
        dp[i] = min(dp[j] + abs(H[i] - H[j]) for j in range(max(i-K, 0), i))
 
    print(dp[-1])
 
if __name__ == '__main__':
    test()

Measured memory_bytes: 13928
#include <stdio.h>
#include <math.h>
#define N 1000001
#define M 1000000007
typedef long long LL;

int mp[N], pc[N];
int a[10001], m = 0;

LL qpow(LL x, int y)
{
	if(!y) return 1;
	LL t = qpow(x, y >> 1);
	t = t * t % M;
	if(y & 1) t = t * x % M;
	return t;
}

int main()
{		
	int n, i, j, x, k, p[22], c, y, tc;
	LL e = 1, s = 0;
	
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &x);
		if(x > m) m = x;
		a[i] = x;
	}
	for(i = 0; i <= m; i++) mp[i] = pc[i] = 0;
	for(i = 2, k = sqrt(m); i <= k; i++){
		if(mp[i]) continue;
		for(j = i * i; j <= m; j += i){
			if(!mp[j]) mp[j] = i;
		}
	}
	for(i = 1; i <= m; i++){
		if(!mp[i]) mp[i] = i;
	}
	for(i = 0; i < n; i++){
		x = a[i];
		if(x == 1) continue;
		c = 0;
		while(x > 1){
			p[c++] = mp[x];
			x /= mp[x];
		}
		for(j = 0; j < c; j = k){
			for(y = p[j], k = j + 1; k < c && p[k] == y; k++);
			tc = k - j;
			if(pc[y] < tc) pc[y] = tc;
		}
	}
	for(i = 2; i <= m; i++){
		if(pc[i]) e = e * qpow((LL)i, pc[i]) % M;
	}
	for(i = 0; i < n; i++){
		s += e * qpow((LL)a[i], M - 2) % M;
	}
	printf("%lld\n", s %= M);
			
	return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e9;

struct Vertex {
    vector<pll> node;
};

Vertex V[100005];
pll D[100005];
ll T[100005];
ll C[200005];
ll S[100005];

int main() {
    ll N, M;
    cin >> N >> M;
    REP(i, N) {
        cin >> D[i].first;
        D[i].second = i;
        T[i] = D[i].first;
    }
    sort(D, D + N, [](pll a, pll b) { return a.first < b.first; });
    REP(i, M) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        V[a].node.push_back(pll(b, i));
        V[b].node.push_back(pll(a, i));
    }

    if (D[0].first != D[1].first) {
        cout << -1 << endl;
        return 0;
    }

    memset(C, 0, sizeof(C));
    memset(S, -1, sizeof(S));
    REP(i, N) {
        ll c = D[i].first;
        ll v = D[i].second;

        if (S[v] >= 0)
            continue;

        bool exist = false;
        REP(j, V[v].node.size()) {
            //! すでに色付けされている or 同じ最小コストで色付けされていないものを見つける
            ll n = V[v].node[j].first;
            if (S[n] >= 0) {
                exist = true;
                C[V[v].node[j].second] = c;
                S[v] = (S[n] + 1) % 2;
                break;
            }

            if (S[n] == -1 && T[n] == c) {
                exist = true;
                C[V[v].node[j].second] = c;
                S[v] = 0;
                S[n] = 1;
                break;
            }
        }

        if (!exist) {
            cout << -1 << endl;
            return 0;
        }
    }

    REP(i, M) {
        if (C[i] == 0)
            C[i] = INF;
    }

    REP(i, N) {
        if (S[i] == 0)
            cout << "B";
        else
            cout << "W";
    }
    cout << endl;
    REP(i, M) {
        cout << C[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 19072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

int main() {
    ll n, k;
    cin >> n >> k;
    if (n == k) {
        cout << 0 << endl;
        return 0;
    }
    if (n > k) n -= (n / k) * k;
    ll ans = min(abs(n - k), n);
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = Counter(a)

e = []
for k, v in c.items():
    if v > 3:
        e.append(k)
        e.append(k)
    elif v > 1:
        e.append(k)
e.sort(reverse=True)

if len(e)<2:
    print(0)
else:
    print(e[0]*e[1])

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  string s; cin >> s;
  ll n = s.size();
  vector<ll> vec(26, 0);
  for(auto c : s) ++vec[c-'a'];
  ll ans = 1+n*(n-1)/2;
  rep(i, 26) ans -= vec[i]*(vec[i]-1)/2;
  cout << ans << endl;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

const int mod = 1e9 + 7;
int f[410][410];
int dp[410][410];

long long mod_pow(long long x,long long n){
    if(n == 0) return 1;
    long long res = mod_pow(x*x % mod, n / 2);
    if(n & 1) res = res*x % mod;
    return res;
}

signed main(){
    int n, c;
    cin >> n >> c;
    vector<int> a(n), b(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    

    rep(i, 0, 401){
        rep(j, 0, 401){
            (f[j + 1][i] = f[j][i] + mod_pow(j, i)) %= mod;
        }
    }

    dp[0][0] = 1;
    rep(i, 0, n){
        rep(j, 0, c + 1){
            for(int k = 0; j + k <= c; k++){
                int p = (f[b[i] + 1][k] - f[a[i]][k] + mod) % mod;  
                (dp[i + 1][j + k] += dp[i][j] * p) %= mod;
            }
        }
    }
    cout << dp[n][c] << endl;
}

Measured memory_bytes: 2816
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <queue>
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(){
    ll n,k;
    cin>>n>>k;
    cout<<n%k<<endl;
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t X;
  cin >> X;
  // const int64_t L = static_cast<int64_t>(T.length());
  if (X <= 599) {
    cout << 8 << endl;
  } else if (X <= 799) {
    cout << 7 << endl;
  } else if (X <= 999) {
    cout << 6 << endl;
  } else if (X <= 1199) {
    cout << 5 << endl;
  } else if (X <= 1399) {
    cout << 4 << endl;
  } else if (X <= 1599) {
    cout << 3 << endl;
  } else if (X <= 1799) {
    cout << 2 << endl;
  } else {
    cout << 1 << endl;
  }
  return 0;
}


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

using namespace std;

string s;
int N, x, sol;
stack < int > st;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> s;
    string sol = "";
    
    for (int i = 0; i < s.size(); ++i) {
        if (i % 2 == 0) {
            sol += s[i];
        }
    }
    
    cout << sol << '\n';
    return 0;
}

Measured memory_bytes: 592
from itertools import combinations_with_replacement
n, m, q = map(int, input().split())
s_l = []
for i in range(q):
    s = list(map(int, input().split()))
    s_l.append(s)

ans = 0
for v in combinations_with_replacement(range(1, m+1), n):
    cnt = 0
    for i in range(q):
        if v[s_l[i][1] - 1] - v[s_l[i][0] - 1] == s_l[i][2]:
            cnt += s_l[i][3]
    ans = max(ans, cnt)

print(ans)

Measured memory_bytes: 9136
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;

class Program
{
  static int n, m;
  public static int Main()
  {
    Scanner cin = new Scanner();
    while (true)
    {
      n = cin.nextInt();
      m = cin.nextInt();
      if (n == 0 && m == 0)
      {
        break;
      }
      int[,] a = new int[n, m];
      for (int i = 0; i < n; i++)
      {
        for (int j = 0; j < m; j++)
        {
          a[i, j] = cin.nextInt();
        }
      }
      Console.WriteLine(dfs(a, 0));
    }
    return 0;
  }

  static int dfs(int[,] a, int now)
  {
    int res = 0;
    
    for (int i = 0; i < m; i++)
    {
      int cnt = 0;
      for (int j = 0; j < n; j++)
      {
        cnt += a[j, i];
      }
      res += Math.Max(cnt, n - cnt);
    }
    if (now == n)
    {
      return res;
    }
    res = Math.Max(res, dfs(a, now + 1));
    for (int j = 0; j < m; j++)
    {
      a[now, j] = 1 - a[now, j];
    }
    res = Math.Max(res, dfs(a, now + 1));
    return res;
  }
}

class Scanner {
  string[] s;
  int i;

  char[] cs = new char[] { ' ' };

  public Scanner() {
    s = new string[0];
    i = 0;
  }

  public string next() {
    if (i < s.Length) return s[i++];
    do {
      s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
    } while ((s.Length == 1 && s[0] == "") || s.Length == 0);
    i = 0;
    return s[i++];
  }

  public int nextInt() {
    return int.Parse(next());
  }

  public long nextLong() {
    return long.Parse(next());
  }

  public double nextDouble() {
    return double.Parse(next());
  }

}

Measured memory_bytes: 11856
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

from math import ceil
N, K = mapint()
S = list(str(input()))

old = S[0]
lis = []
cnt = 1
for i in range(1, N):
    s = S[i]
    if s!=old:
        lis.append(cnt)
        old = s
        cnt = 1
    else:
        cnt += 1
lis.append(cnt)
for l in range(K):
    if len(lis)>=3:
        l1 = lis.pop()
        l2 = lis.pop()
        lis[-1] += (l1+l2)
    elif len(lis)>=2:
        l1 = lis.pop()
        lis[-1] += l1
        break
    else:
        break

ans = sum([i-1 for i in lis])
print(ans)

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

const int INF = 1e9;

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

  int cnt=1;
  for(char c: s){
    int d = c-'0';
    if (d>1){
      cout<<d<<endl;
      return 0;
    }
    if(to_string(cnt)==k){
      cout<<d<<endl;
      return 0;
    }
    ++cnt;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
// #include <iomanip>
// std::cout << std::fixed << std::setprecision(5);

int main()
{
    std::pair<std::string, int> p[2];
    std::string u;
    std::cin >> p[0].first >> p[1].first >> p[0].second >> p[1].second >> u;
    if(u==p[0].first) std::cout << p[0].second - 1 << " " << p[1].second << std::endl;
    else std::cout << p[0].second << " " << p[1].second - 1 << std::endl;
    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
$h = explode(" ",fgets(STDIN));
$h = array_map("intval", $h);
$move = 0;
$moveMax = 0;

for($i=0; $i<$n-1; $i++) {
    if($h[$i] >= $h[$i+1]) {
        $move++;
    } else {
        $moveMax = max($move, $moveMax);
        $move = 0;
    }
}
echo max($move, $moveMax);

Measured memory_bytes: 16884
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
const int MaxN = 1e5;
using namespace std;

struct NODE{
	int w , v;
}a[MaxN + 5];
int n ;
long long k;
bool cmp(NODE x , NODE y){
	return x.w < y.w;
}
int main()
{
	while(~scanf("%d%lld" , &n , &k)){
		for(int i = 1;i <= n;i++){
			scanf("%d%d" , &a[i].w , &a[i].v);
		}
		sort(a + 1 , a + n + 1 , cmp);
		long long  f = 1 , e = a[1].v;
		for(int i = 2;i <= n + 1;i++){
			if(k >= f && k <= e) {
				printf("%d\n" , a[i - 1].w);
				break;
			}
			else f = e + 1 , e = e + a[i].v;
		}
	}
}

Measured memory_bytes: 896
a = input()
b = a.split(" ")
if int(b[0]) <= int(b[1]) <= int(b[2]):
    print(b[0], b[1], b[2])
elif int(b[0]) <= int(b[2]) <= int(b[1]):
    print(b[0], b[2], b[1])
elif int(b[1]) <= int(b[0]) <= int(b[2]):
    print(b[1], b[0], b[2])
elif int(b[1]) <= int(b[2]) <= int(b[0]):
    print(b[1], b[2], b[0])
elif int(b[2]) <= int(b[1]) <= int(b[0]):
    print(b[2], b[1], b[0])
elif int(b[2]) <= int(b[0]) <= int(b[1]):
    print(b[2], b[0], b[1])
    


Measured memory_bytes: 5600
#include <bits/stdc++.h> 
 
using namespace std;
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const long INF=LONG_MAX;


int main(){
    long N,x;
    cin>>N>>x;
    vector<long>a(N),b(N);
    REP(i,N){
        cin>>a[i];
        b[i]=a[i];
    }
    LL res=INF;

    REP(k,N){
        LL sum=k*x;
        REP(i,N){
            b[i]=min(b[i],a[(i-k+N)%N]);
            sum+=b[i];
        }
        res=min(res,sum);
    }
    cout<<res<<endl;
    return 0;
}
//b[i]=min(a[i],a[i-1],a[i-2],...,a[i-k])

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

using namespace std;
using   ll=long long;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353 

ll mod_pow(ll a,ll b,ll m) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2 , mod);
}
 
void solve()
{
	int a , b , c;
	
	cin >> a >> b >> c;
	
	cout << floor((c + 0.5)/a)*b;
}

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


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


int main(){
    int64_t a,b,k;
    cin >> a >> b >>k;
    if (k-a > 0){
        if (b-(k-a) >0){
            cout << 0 << ' ' << b-(k-a) << endl;
        }
        else{
            cout << 0 << ' ' << 0 << endl;
        }
    }
    else{
        cout << a-k << ' ' << b << endl;
    }
} 



Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

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

    while(n != 0) {
        vector<double> vec(n);
        for(int i=0; i<n; ++i) cin >> vec[i];

        double sum = 0.0;
        for(int i=0; i<vec.size(); ++i) {
            sum += vec[i];
        }
        double ave = sum / ((double)vec.size());


        sum = 0.0;
        for(int i=0; i<vec.size(); ++i) {
            double diff = vec[i] - ave;
            sum += (diff * diff);
        }

        double dispersion = sum / ((double)n);
        double standard_deviation = sqrt(dispersion);

        printf("%.12f\n", standard_deviation);

        cin >> n;
    }

    return 0;
}


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

int main(){
    int d,g;
    cin >> d >> g;
    vector<int> p(d);vector<int> c(d);
    for(int i = 0; i<d; i++){
        cin >> p.at(i) >> c.at(i);
    }
    int min = 1000;
    for(int i = 1; i <= pow(2,d); i++){
        int point = 0;int num = 0;int n = 0;
        for(int j = 0;j < d; j++){
            if(i >> j & 1 == 1){
                point += p.at(j)*(j+1)*100+c.at(j);
                num += p.at(j);
            }else{
                n = j;
            }
          	
        }
      	
        int ty = p.at(n);
        while(point < g and ty > 0){
            point += (n+1)*100;
            num += 1;
            ty -= 1;
        }

        if(num < min and point >= g){
            min = num;
        }
    }
    cout << min << endl;
}

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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
int x[100005],y[100005];
int memo[100005];
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,t,m,a[2],len=2;
    cin >> n >> t >> m;
    rep(i,0,n){
        cin >> x[i] >> y[i];
    }
    rep(i,0,100005){memo[i]=0;}
    rep(j,0,n){
        if(y[j]==2){
            memo[j]=x[j]-t;
        }
        if(y[j]==1){
            memo[j]=x[j]+t;
            for(;j<n;j++){
                memo[j]=x[j]+t;
                if(y[j]==2){
                int wa;
                int butu=(x[j-1]+x[j])/2;
                //cout << butu <<" " << j << "ss";
                //1?????????
                for(int p=j-1;p>=0;p--){
                    if(y[p]==2)break;
                    if((x[p]+t)>=butu){
                        memo[p]=butu;
                    }else{
                        break;
                    }
                }
                int mae = j-1;
                for(;j<n;j++){
                if(y[j]==1){j--;break;}
                if((x[j]-t)<=butu){
                  //  cout << j << endl;
                    memo[j]=butu;
                }else{
                    memo[j]=x[j]-t;
                }
                }
                }
            }
        }
    }
    rep(i,0,m){
        int u;cin >> u;
        cout << memo[u-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 5448
n, m = map(int, input().split())
ab = []

for i in range(n):
    ab.append(list(map(int, input().split())))

shop = sorted(ab)

#print(shop)
count = 0
rest = m
price = 0

for i in range(n):
    # print('# i: ' + str(i))
    # print('rest: ' + str(rest))
    if rest == 0:
        break

    num = shop[i][1]
#    print('num: ' + str(num))
    if num < rest:
        price += shop[i][0] * shop[i][1]
        rest = rest - shop[i][1]
#        print(price)
    else:
        price += shop[i][0] * rest
        break

print(price)


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

using namespace std;

const int MAX_N = 101;
int n;
int a[MAX_N];


int main()
{
    int n;

    scanf("%d", &n);
    int aa = 2 * n, bb = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        bb += 2 * a[i];
    }

    if (bb % aa == 0) {
        int y = 0;
        for (int i = 0; i < n; ++i)
            y += (a[i] - bb / aa) * (a[i] - bb / aa);
        printf("%d\n", y);
    }
    else {
        int x1 = floor((double)bb / aa), y1 = 0;
        int x2 = ceil((double)bb / aa), y2 = 0;
        for (int i = 0; i < n; ++i) {
            y1 += (x1 - a[i]) * (x1 - a[i]);
            y2 += (x2 - a[i]) * (x2 - a[i]);
        }

        printf("%d\n", min(y1, y2));
    }

    return 0;
}


Measured memory_bytes: 256