akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

ll n, m;
ll a[100], b[100];
bool g[100][100];
bool visited[100];

void dfs(ll v) {
    visited[v] = true;
    rep(u, n) {
        if (g[v][u] == false || visited[u] == true) continue;
        dfs(u);
    }
}

int main() {
    cin >> n >> m;
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        g[a[i]][b[i]] = g[b[i]][a[i]] = true;
    }

    ll ans = 0;
    rep(i, m) {
        g[a[i]][b[i]] = g[b[i]][a[i]] = false;
        rep(j, n) visited[j] = false;

        dfs(0);
        
        bool bridge = false;
        rep(j, n) if (visited[j] == false) bridge = true;
        if (bridge) ans += 1;

        g[a[i]][b[i]] = g[b[i]][a[i]] = true;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	int n;
	cin >> n;
	vector<int> l(n);

	for (int i = 0; i < n; i++) cin >> l[i];
	int ans = 0;
	for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			for (int k = j + 1; k < n; k++) {
				if (l[k] < l[i] + l[j] && l[i] < l[j] + l[k] && l[j] < l[k] + l[i]
					&& l[i]!=l[j]&&l[j]!=l[k]&&l[k]!=l[i]) ans++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
	int n, m;
	cin >> n >> m;
	int a, b;
	if (n == 1 && m == 0) {
		cout << 0 << endl;
		return 0;
	}
	vector<int> ans(n, -1);
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		a--;
		if (n != 1 && a == 0 && b == 0) {
			cout << "-1" << endl;
			return 0;
		}
		if (ans[a] == -1)	ans[a] = b;
		else if (ans[a] == b)	continue;
		else {
			cout << "-1" << endl;
			return 0;
		}
	}

	if (ans[0] == -1)	ans[0] = 1;
	for (int i = 1; i < n; i++) {
		if (ans[i] == -1) ans[i] = 0;
	}

	if (ans[0] == -1)	cout << "-1" << endl;
	else {
		for (int i = 0; i < n; i++) {
			cout << ans[i];
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

int c_sum_tate[300][301];
int c_sum_yoko[300][301];
int c_sum_2[300][300][301];

int main() {
    int n;
    cin >> n;
    vector<vector<int>> p(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> p[i][j];
        }
    }

    // c_sum_tate[x] = 左からx列目の累積和
    for (int i = 0; i < 300; i++)
        for (int j = 0; j <= 300; j++)c_sum_tate[i][j] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            c_sum_tate[i][j + 1] = c_sum_tate[i][j] + p[j][i];
        }
    }
    // c_sum_yoko[x] = 上からx行目の累積和
    for (int i = 0; i < 300; i++)
        for (int j = 0; j <= 300; j++)c_sum_yoko[i][j] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            c_sum_yoko[i][j + 1] = c_sum_yoko[i][j] + p[i][j];
        }
    }

    // コ形 の累積和を持つ
    // c_sum2[x][y][z]=上からx行目(0-indexed)と上からy行目(0-indexed)のz番目(1-indexed)までカウント
    for (int i = 0; i < 300; i++)
        for (int j = 0; j < 300; j++)
            for (int k = 0; k <= 300; k++)c_sum_2[i][j][k] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            for (int k = 1; k <= n; k++) {
                c_sum_2[i][j][k] = c_sum_yoko[i][k - 1];
                if (j != i)c_sum_2[i][j][k] += c_sum_yoko[j][k - 1];

                c_sum_2[i][j][k] += c_sum_tate[k - 1][j + 1] - c_sum_tate[k - 1][i];
            }

            // c_sum_2の累積Maxを右から取る
            for (int k = n - 1; k >= 0; k--) c_sum_2[i][j][k] = max(c_sum_2[i][j][k], c_sum_2[i][j][k + 1]);
        }
    }

    int ret = -1145141919;
    for (int sx = 0; sx < n; sx++) {
        for (int sy = 0; sy < n; sy++) {
            int lside = 0;
            for (int ex = sx; ex < n; ex++) {
                lside += p[ex][sy];
                ret = max(ret, lside);
                if (sy < n - 1) {
                    int box = lside + c_sum_2[sx][ex][sy + 2] - c_sum_yoko[sx][sy + 1];
                    if (ex != sx)box -= c_sum_yoko[ex][sy + 1];

                    ret = max(ret, box);
                }
            }
        }
    }

    cout << ret << endl;
    return 0;
}


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

import sys
import os
import math


def min_break_floor(v):
    t = v / 9.8
    y = 4.9 * t * t
    N = (5 + y) / 5
    return math.ceil(N)

for s in sys.stdin:
    break_v = float(s)
    break_floor = min_break_floor(break_v)
    print(break_floor)

    

Measured memory_bytes: 7464
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
long long fac[700100], finv[700100], inv[700100]; 
long long MOD = 1000000007; 
int MAX = 700100; 
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;
}
int main(){
	int X, Y; cin >> X >> Y; 
	if((X + Y) % 3 != 0){
		cout << 0 << endl; return 0; 
	}
	if(X > 2 * Y || Y > 2 * X){
		cout << 0 << endl; return 0; 
	}
	COMinit();
	int total = (X + Y) / 3; 
	int choose = X - total; 
	cout << COM(total, choose) << endl; 
}

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

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

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

int main()
{
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<vector<ll>> vvll(3);
    REP(i, a)
    {
        int z;
        cin >> z;
        vvll[0].push_back(z);
    }
    REP(i, b)
    {
        int z;
        cin >> z;
        vvll[1].push_back(z);
    }
    REP(i, c)
    {
        int z;
        cin >> z;
        vvll[2].push_back(z);
    }
    sort(vvll[0].begin(), vvll[0].end());
    sort(vvll[1].begin(), vvll[1].end());
    sort(vvll[2].begin(), vvll[2].end());

    ll ans = 0;
    REP(i, x)
    ans += vvll[0][vvll[0].size() - 1 - i];
    REP(i, y)
    ans += vvll[1][vvll[1].size() - 1 - i];
    int idx[2];
    idx[0] = a - x;
    idx[1] = b - y;
    REP(i, c)
    {
        if (idx[0] >= a && idx[1] >= b)
            break;
        int exidx = -1;
        if (idx[0] >= a)
            exidx = 1;
        if (idx[1] >= b)
            exidx = 0;
        if (exidx == -1) {
            if (vvll[0][idx[0]] < vvll[1][idx[1]])
                exidx = 0;
            else
                exidx = 1;
        }

        if (vvll[exidx][idx[exidx]] < vvll[2][c - 1 - i]) {
            ans += vvll[2][c - 1 - i] - vvll[exidx][idx[exidx]];
            idx[exidx]++;
        } else {
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6400
#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;
//const int mod = 100000;
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()
{
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n-1) cin >> a[i];
  vector<int> ans(n, 0);
  rep(i, n-1) ++ans[a[i]-1];
  for(auto x : ans) cout << x << endl;
}

Measured memory_bytes: 4844
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // two inputs
        int a = sc.nextInt();
        int b = sc.nextInt();

        int ave =  (int) Math.ceil((a+b)/(double)2);


        System.out.println(ave);
    }

}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  while(true){
    int n;
    cin>>n;
    if(n==0)break;
    int cnt = 0;
    int iter = 5;
    REP(i,10){
      cnt += n/iter;
      n /= iter;
      if(n==0)break;
    }
    cout<<cnt<<endl;
  }
  return 0;
}

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

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

	string	s;
	cin >> s;
	vector<int> v(s.size() - 2);
	rep(i, s.size() - 2)
		v.at(i) = stoi(s.substr(i, 3));
	sort(v.begin(), v.end());
	auto it = lower_bound(v.begin(), v.end(), 753);
	int a = abs(*(it--) - 753);
	int b = abs(*it - 753);
	if (it == v.begin())
		cout << abs(v.at(0) - 753) << endl;
	else if (a < b)
		cout << a << endl;
	else
		cout << b << endl;
}


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

long long gcd(long long a, long long b){
    while(b != 0){
        long long tmp = a % b;
        a = b;
        b = tmp;
    }
    return a;
}

vector<int> p, q, a, b;

long long solve(int curr)
{
    if(curr == -1)
        return 1;

    long long x = solve(a[curr]);
    long long y = solve(b[curr]);

    long long g = gcd(x * p[curr], y * q[curr]);
    return x * y * p[curr] / g + y * x * q[curr] / g;
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<bool> top(n, true);
        p = q = a = b = vector<int>(n);
        for(int i=0; i<n; ++i){
            cin >> p[i] >> q[i] >> a[i] >> b[i];
            -- a[i];
            -- b[i];
            if(a[i] >= 0)
                top[a[i]] = false;
            if(b[i] >= 0)
                top[b[i]] = false;
        }

        long long ret = 0;
        for(int i=0; i<n; ++i){
            if(top[i])
                ret += solve(i);
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 1216
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int n, t[300002];

int solve(int q){
  int res = 0;
  int pos = 0;
  int target = q;

  while(pos < n){
    int idx = lower_bound(t + pos, t + n, target) - t;
    if(idx - 1 >= 0){
      res = max(res, t[idx - 1] % q);
    }
    pos = idx;
    target += q;
  }
  return res;
}

int main(){
  int m;

  while(scanf("%d%d", &n, &m) != EOF){
    for(int i = 0; i < n; i++){
      scanf("%d", &t[i]);
    }
    sort(t, t + n);

    for(int i = 0; i < m; i++){
      int q;
      scanf("%d", &q);
      cout << solve(q) << endl;
    }
  }
}

Measured memory_bytes: 2396
#include <stdio.h>
 
int main(){
  int n,c=0,i,j;
  int x[n];
    
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
  }
  
  for(j=0;j<n;j++){
    if(x[j]!=j+1){
      c++;;
    }
  }
  
  if(c > 2){
	printf("NO");
  }
  else{
    printf("YES");
  }
}

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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, x) for (int i = 1, _##i = (x); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)

#define L(x) ((x)*2)
#define R(x) ((x)*2+1)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;
typedef pair<ll, ll> pll;

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    os << pai.first << ' ' << pai.second;
	return os;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    rep(i, sz(v)) cout << v[i] << ' ';
    return os;
}

template<typename T, typename V>
istream &operator>>(istream &is, pair<T, V> &pai) {
	is >> pai.first >> pai.second;
	return is;
}

int H, W;
char board[1000][1000];
int seg[1000][1000];
int cseg;

int c[1000000][2];

int x[] = {0, 0, 1, -1};
int y[] = {1, -1, 0, 0};

int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    
    cin >> H >> W;
    rep(i, H) cin >> board[i];

    rep(i, H) rep(j, W) {
        if (seg[i][j] == 0) {
            cseg++;

            queue<pii> q;
            q.push(mp(i, j));
            seg[i][j] = cseg;

            while(!q.empty()) {
                int a = q.front().fi, b = q.front().se; q.pop();
                c[cseg][board[a][b] == '.']++;

                rep(k, 4) {
                    int na = a + x[k], nb = b + y[k];
                    if (0 <= na and na < H and 0 <= nb and nb < W) {
                        if (board[a][b] != board[na][nb] and seg[na][nb] == 0) {
                            seg[na][nb] = cseg;
                            q.push(mp(na, nb));
                        }
                    }
                }
            }
        }
    }

    ll res = 0;
    repp(i, cseg) {
        res += (ll)c[i][0]*c[i][1];
    }

    cout << res;
}

Measured memory_bytes: 7552
#include<stdio.h>

int main(void)
{
  int x,a,b;
  scanf("%d%d%d",&x,&a,&b);
  if(a>=b)
    printf("delicious\n");
  else if(b-a<=x)
    printf("safe\n");
  else
    printf("dangerous\n");
  return 0;
}


Measured memory_bytes: 128
while line = gets
  a, op, b = line.chomp.split
  break if op == "?"
  case op
  when "+" then puts "#{a.to_i + b.to_i}"
  when "-" then puts "#{a.to_i - b.to_i}"
  when "*" then puts "#{a.to_i * b.to_i}"
  when "/" then puts "#{a.to_i / b.to_i}"
  end
end



Measured memory_bytes: 6876
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cstring>

using namespace std;

int main()
{
	int A,B,sum;
        cin >> A >> B;
	sum=A+B;
	if(sum>=10){cout << "error" << endl;}
	else{cout << sum << endl;}
	return 0;
}

Measured memory_bytes: 256
import math
from collections import Counter
N=int(input())
D=input().split()
T=[]
D_dict=Counter(D)
D_keys=list(D_dict.keys())
D_keyi=[int(n) for n in D_keys]
maxD=max(D_keyi)
D_keyi.sort()
ans=1
if D[0] != '0' or D_dict['0']!=1 or D_keyi != list(range(maxD+1)):
    print(0)
else:
    for i in range(maxD+1):
        T.append(D_dict[str(i)])
    for i in range(len(T)-1):
        ans=ans*(T[i]**T[i+1])
    print((ans%998244353))


Measured memory_bytes: 25064
N = int(input())
A = [int(i) for i in input().split()]

def solve():
    f, t, o = 0, 0, 0
    for a in A:
        if a % 4 == 0:
            f += 1
        elif a % 2 == 0:
            t += 1
        else:
            o += 1

    if t == 0:
        return (o <= f + 1)
    else:
        return (o <= f)

if solve():
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14252
abc = gets.split(" ").map(&:to_i)

def check(abc, count=0)
  return count if abc[0] == abc[1] && abc[0] == abc[2]
  if abc.count(abc.min) == 2
    abc = abc.map do |a|
      if a == abc.min
        a+1
      else
        a
      end
    end
  else
    abc = abc.map do |a|
      if a == abc.min
        a+2
      else
        a
      end
    end
  end
  count += 1
  check(abc, count)
end

puts check(abc)

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;


void disp(vector<vector <int> > table)
{
	cout << "\n";
	for (int ri = 0; ri < table.size(); ri++) {
		for (int ci = 0; ci < table[0].size(); ci++) {
			cout << table[ri][ci] << " ";
		}
		cout << "\n";
	}
}

int main()
{
	int a, b, c, d;

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

	string ans = "No";
	if (abs(a - c) <= d) {
		ans = "Yes";
	}
	else if (abs(a - b) <= d && abs(b - c) <= d) {
		ans = "Yes";
	}

	cout << ans;


	return 0;
}



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

int main()
{
	int n,m,p;
	while(cin>>n>>m>>p && n!=0){
		vector<int> V(n+1);
		int sum=0;
		for(int i=1;i<=n;i++){
			cin>>V[i];
			sum+=V[i];
		}
		sum*=100;

		if(V[m]==0){
			cout<<0<<endl;
		}
		else{
			sum*=(100-p);
			sum/=100;
			cout<<sum/V[m]<<endl;
		}
	}
	return 0;

}

Measured memory_bytes: 0
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> a >> s;
  b = (s[0] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
  ans = a * b;
  ans /= 100;
  Cout(ans);
  return 0;
}

Measured memory_bytes: 3616
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	int n, k;
	int x, y, z;
	int s, ans;
	bool v = true;
	ans = 0;
	scanf("%d %d", &n, &k);

	printf("%d\n", n+(k/2));


	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<queue>
using namespace std;
int main(){
    long n,m,a,ans=0L;
    cin>>n>>m;
    priority_queue<int>q;
    for(int i=0;i<n;i++){cin>>a;q.push(a);}
    while(m--){
        a=q.top();q.pop();
        q.push(a/2L);
    }
    while(!q.empty()){ans+=q.top();q.pop();}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 892
def solve():
    n = int(input())
    max_cake = n // 4
    max_donut = n // 7
    for c in range(max_cake + 1):
        for d in range(max_donut + 1):
            if n == 4 * c + 7 * d:
                return "Yes"
    return "No"


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 2940
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<set>

using namespace std;
vector<vector<int>> g;
int n, m;

vector<int> col;
int dfs(int node, int c = 0) {
    int nc = c == 0 ? 1 : 0;
    col[node] = c;
    int ans = 0;
    for (int adj : g[node]) {
        if (col[adj] != -1) {
            // DDD(node, adj, nc);
            if (col[adj] != nc) return -1;
            continue;
        }
        int b = dfs(adj, nc);
        if (b == -1) return -1;
        ans += b;
    }
    return ans + c;
}

void solve() {
    // D("===");
    // for(auto gi : g) {DV(gi);}
    // D("===");
    col = vector<int>(n, -1);
    int cnt = dfs(0);
    if (cnt == -1) {
        cout << 0 << endl;
        return;
    }
    set<int> st;
    if (cnt % 2 == 0) st.insert(cnt / 2);
    if ((n - cnt) % 2 == 0) st.insert((n - cnt) / 2);
    cout << st.size() << endl;
    for (int sti : st) {
        cout << sti << endl;
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1) {
        cin >> n >> m;
        if (n == 0) break;
        g.clear();
        g.resize(n);
        REP(i, m) {
            int u, v;
            cin >> u >> v;
            u--; v--;
            g[u].push_back(v);
            g[v].push_back(u);
        }
        solve();
    }
}



Measured memory_bytes: 3300
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    sort(ALL(a),greater<>());
    ll ans = a[0];
    int idx = 1;
    for(int i=2;i<n;i++){
        ans += a[idx];
        if(i%2==1)idx++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4792
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 100005
#define oo 2000000007
#define sz(a) (int)a.size()
#define MOD 1000000007

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n;
char s[2][maxN];
vector<int> a, f;

int main () {
    scanf("%d", &n);
    fto(i, 0, 1) scanf("%s", s[i]);

    fto(i, 0, n-1) {
        if (s[0][i] == s[1][i]) a.pb(1);
        else {
            a.pb(2);
            ++i;
        }
    }

    f.assign(sz(a), 0);
    f[0] = (a[0] == 1) ? 3 : 6;
    fto(i, 1, sz(f)-1) {
        if (a[i] == 1) {
            if (a[i-1] == 2) f[i] = f[i-1];
            else f[i] = (f[i-1]*2)%MOD;
        } else {
            if (a[i-1] == 1) f[i] = (f[i-1]*2)%MOD;
            else f[i] = (f[i-1]*3LL)%MOD;
        }
    }

    printf("%d", f[sz(f)-1]);

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

int32_t main(){_
   
   cin >> n;

   int ans = 0;

   for (int i = 1; i <= n; ++i)
   {
      for (int j = 1; j <= n; ++j)
      {
         for (int k = 1; k <= n; ++k)
         {
            ans += __gcd(__gcd(i, j), k);
         }
      }
   }
   
   cout<<ans;   

   return 0;
}

Measured memory_bytes: 3656
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
int main(){
   string s, t, u;
   int a, b;
   cin >> s >> t >> a >> b >> u;
   if(s==u) a--;
   if(t==u) b--;
   cout << a << ' ' << b << endl;
   }

    



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

bool ok(long long x, int K, vector<long long> &B) {
    int cnt = 0;
    for(long long num : B) {
        if((x & num) == x) ++cnt;
        if(cnt == K) return true;
    }
    return false;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i<N; ++i) cin >> A[i];
    vector<long long> B;
    B.reserve(N * (N + 1) / 2);
    for(int i=0; i<N; ++i) {
        long long sum = 0;
        for(int j=i; j<N; ++j) {
            sum += A[j];
            B.emplace_back(sum);
        }
    }

    long long res = 0;
    for(int b=50; b>=0; --b) {
        if(ok(res + (1LL << b), K, B)) res += (1LL << b); 
    }
    cout << res << endl;
}

Measured memory_bytes: 4224
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

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 x, a, b;
	cin >> x >> a >> b;
	if (b - a <= x) {
		if (b - a <= 0) {
			cout << "delicious" << endl;
		} else {
			cout << "safe" << endl;
		}
	} else {
		cout << "dangerous" << endl;
	}
}

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

int main() {
    string s;
    cin >> s;
    while (1) {
        if (s == "ABC") {
            cout << "Yes\n";
            return 0;
        }
        int cnt[3] = {0, 0, 0};
        for (int i = 0; i < s.length(); ++i) {
            ++cnt[s[i] - 'A'];
        }
        if (cnt[0] == 0 || cnt[1] == 0 || cnt[2] == 0) {
            cout << "No\n";
            return 0;
        }
        char c = cnt[0] < cnt[1] && cnt[0] < cnt[2] ? 'A' : (cnt[1] < cnt[0] && cnt[1] < cnt[2] ? 'B' : (cnt[2] < cnt[0] && cnt[2] < cnt[1] ? 'C' : 0));
        if (!c) {
            cout << "No\n";
            return 0;
        }
        string t = "";
        for (int i = 0; i < s.length(); ++i) {
            if (i + 2 < s.length() && s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
                t += c;
                i += 2;
                continue;
            }
            if (s[i] == c) {
                cout << "No\n";
                return 0;
            }
            t += s[i];
        }
        if (s == t) {
            cout << "No\n";
            return 0;
        }
        s = t;
    }
    return 0;
}

Measured memory_bytes: 3204
N = int(input())
A = list(map(int, input().split()))
ans = 0
hoge = 0
mod = 10**9+7
for i in range(N):
    hoge = hoge + A[i]
    hoge = hoge % mod

for i in range(N):
    hoge = hoge - A[i]
    if hoge < 0:
        hoge = hoge + mod
    ans = ans + A[i] * hoge
    ans = ans % mod

print(ans%mod)


Measured memory_bytes: 31560
N,Y = map(int,input().split())
Y = Y/1000
torf = False
for numoft in range(N+1):
    for numof5t in range(N-numoft+1):
        numof10t = (N)-(numoft+numof5t)
        if Y == numoft + 5*numof5t + 10*numof10t:
            print(numof10t,numof5t,numoft)
            exit()
print("-1 -1 -1")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
 
typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};
 
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

const int mod=1000000007;

string L;
int N;

PI ab[4]={PI(0,0),PI(0,1),PI(1,0),PI(1,1)};
int mem[100005][2][3];

void init(){
    for(int i=0;i<100005;++i)for(int j=0;j<2;++j)for(int k=0;k<3;++k)mem[i][j][k]=-1;
}

int check(int a, int b, int c, int dig){
    if(a+b+c>L[dig]-'0')return 2;
    if(a+b+c==L[dig]-'0')return 1;
    else return 0;
}

// isequal : 0=small, 1=equal, 2=bigger 
int calc(int n, int pre_c, int isequal){
    if(mem[n][pre_c][isequal]!=-1)return mem[n][pre_c][isequal];
    int ret=0;
    int a,b,c;
    int isequal_;
    if(n==N)return 0;
    for(int i=0;i<4;++i){
        a=ab[i].first,b=ab[i].second;
        if(a+b+pre_c>=2)c=1;
        else c=0;
        int same=check(a,b,pre_c,n);
        if(isequal==0||isequal==2){
            if(same==1)isequal_=isequal;
            else isequal_=same;
        }
        else isequal_=check(a,b,pre_c,n);
        if((a+b+pre_c)%2==a^b){
            if(!(n==N-1&&isequal_==2)){
                if((a==0&&b==0)||c!=0)ret+=calc(n+1,c,isequal_);
                else ret+=calc(n+1,c,isequal_)+1;
            }
            ret%=mod;
        }
    }
    return mem[n][pre_c][isequal]=ret%mod;
}

signed main(){
    init();
    cin>>L;
    N=L.size();
    reverse(L.begin(),L.end());
    cout<<(calc(0,0,1)+1)%mod<<endl;
    return 0;
}


Measured memory_bytes: 14672
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1e15;
const double eps = 1e-6;
typedef tuple<ll, ll, ll> T;

typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src, int dst, Weight weight) :
		src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void shortestPath(const Graph &g, int s,
	vector<Weight> &dist, vector<int> &prev) {
	int n = g.size();
	dist.assign(n, INF); dist[s] = 0;
	prev.assign(n, -1);
	priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
	for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
		Edge e = Q.top(); Q.pop();
		if (prev[e.dst] != -1) continue;
		prev[e.dst] = e.src;
		for (auto f = g[e.dst].begin(); f != g[e.dst].end(); f++) {
			if (dist[f->dst] > e.weight + f->weight) {
				dist[f->dst] = e.weight + f->weight;
				Q.push(Edge(f->src, f->dst, e.weight + f->weight));
			}
		}
	}
}

int main() {
	ll K;
	cin >> K;
	Graph g(K);
	for (ll from = 0;from < K;from++) {
		g[from].push_back(Edge(from, (from + 1)%K, 1));
		g[from].push_back(Edge(from, (from * 10) % K, 0));
	}
	vector<Weight> dist;
	vector<int> prev;
	ll ans = INF;
	shortestPath(g, 1, dist, prev);
	ans = min(ans, dist[0] + 1);
	cout << ans << endl;
	return 0;
}


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

int main(){

    int A, B, C, D;
    cin >> A >> B >> C >> D;

    if(A + B > C + D) cout << "Left" << endl;
    else if(A + B == C + D) cout << "Balanced" << endl;
    else if(A + B < C + D) cout << "Right" << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    ll a,b,n;
    ll max = 0;
    cin >> a >> b >> n;
    if(n <= b-1) max = (a*n)/b;
    else max = (a*(b-1))/b;
    cout << max << endl;
}

Measured memory_bytes: 3604
// Date: 2020-04-07

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int n, m, k;
pii a[N];

bool ok(int x, int y) {
    return x == 0 || x == n || y == 0 || y == m;
}

int get(int x, int y) {
    if(!x) return y;
    if(y == m) return m + x;
    if(x == n) return m + n + m - y;
    return m + n + m + n - x;
}

int stk[N], top;
int main() {
    FIO;
    cin >> n >> m >> k;
    int tot = 0;
    rep(i, 1, k) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if(ok(x1, y1) && ok(x2, y2)) {
            a[++tot] = mk(get(x1, y1), i);
            a[++tot] = mk(get(x2, y2), i);
        }
    }
    sort(a+1, a+1+tot);
    rep(i, 1, tot) {
        stk[++top] = a[i].se;
        if(top > 1 && stk[top] == stk[top-1]) top -= 2;
    }
    if(top == 0) cout << "YES";
    else cout << "NO";

    return 0;
}

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

int main(void){
  ll n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) cin >> c[i];
  sort(a.begin(), a.end());
  sort(c.begin(), c.end());
  ll ans = 0;
  rep(i,n) {
    ll s = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    ll t = c.end() - upper_bound(c.begin(), c.end(), b[i]);
    ans += s*t;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5632
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
	int n;
  char input[100][20] = {{0}};
  char *name[100] = {0}, *point[100] = {0};
  int pointnum[100] = {0};
  scanf("%d", &n);getchar();
  for(int i = 0; i < n; i++){
  	fgets(input[i], 20, stdin);
    name[i] = strtok(input[i], " ");
    point[i] = strtok(NULL, " ");
    pointnum[i] = strtol(point[i], NULL, 10);
  }
  int c[100] = {0};
  for(int i = 0; i < n; i++){
  	c[i] = i + 1;
  }
  for(int i = 0; i < n; i++){
  	for(int j = 0; j < n - 1; j++){
    	if(strcmp(name[c[j] - 1], name[c[j + 1] - 1]) > 0){
        	int buf = c[j];
          c[j] = c[j + 1];
          c[j + 1] = buf;
        }else if(strcmp(name[c[j] - 1], name[c[j + 1] - 1]) == 0){
        	if(pointnum[c[j] - 1] < pointnum[c[j + 1] - 1]){
            	int buf = c[j];
                c[j] = c[j + 1];
                c[j + 1] = buf;
            }
        }
    }
  }
  for(int i = 0; i < n; i++){
  	printf("%d\n", c[i]);
  }
  return 0;
}

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

int dp[101][101];

int main(){
	int h, w;	cin >> h >> w;
	char s[h][w];
	for (int i = 0; i < h; ++i){
		for (int j = 0; j < w; ++j){
			cin >> s[i][j];
		}
	}

	for (int i = 0; i < 101; ++i){
		for (int j = 0; j < 101; ++j){
			dp[i][j] = 1e8+10;	
		}
	}

	dp[0][0] = 0;
	if(s[0][0] == '#')	dp[0][0]++;

	for (int i = 1; i < h; ++i){
		dp[i][0] = dp[i-1][0];
		if(s[i-1][0] != '#' and s[i][0] == '#')	dp[i][0]++;
		dp[i][0] = min(dp[i][0], i+1-dp[i][0]+1);
	}

	for (int i = 1; i < w; ++i){
		dp[0][i] = dp[0][i-1];
		if(s[0][i-1] != '#' and s[0][i] == '#')	dp[0][i]++;
		dp[0][i] = min(dp[0][i], i+1-dp[0][i]+1);
	}

	for (int i = 1; i < h; ++i){
		for (int j = 1; j < w; ++j){
			if(dp[i-1][j] < dp[i][j]){
				dp[i][j] = dp[i-1][j];
				if(s[i-1][j] != '#' and s[i][j] == '#')	dp[i][j]++;
			}

			if(dp[i][j-1] < dp[i][j]){
				dp[i][j] = dp[i][j-1];
				if(s[i][j-1] != '#' and s[i][j] == '#')	dp[i][j]++;
			}

			// dp[i][j] = min(dp[i][j], dp[i-1][j]);
			// if(s[i-1][j] != )
			// dp[i][j] = min(dp[i][j], dp[i][j-1]);
			// if(s[i][j] == '#')	dp[i][j]++;
			dp[i][j] = min(dp[i][j], i+j+1-dp[i][j]+1);
		}
	}
	cout << dp[h-1][w-1] << endl;
	return 0;
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define double ld

signed main(){
	int xs=read(),ys=read(),xt=read(),yt=read();
	int n=read();
	vector<vector<pair<double,int>>> graph(n+2);
	const auto AddEdge=[&](int a,int b,double d){
		graph[a].PB(MP(d,b));
		graph[b].PB(MP(d,a));
	};
	vector<pair<pii,int>> cr;
	cr.PB(MP(MP(xs,ys),0.0));
	cr.PB(MP(MP(xt,yt),0.0));
	AddEdge(0,1,sqrt(double(Sq(xs-xt)+Sq(ys-yt))));
	FOR(i,2,n+2){
		int x=read(),y=read(),r=read();
		REP(j,cr.size()){
			double d=max(ld(0.0),sqrt(double(Sq(x-cr[j].first.first)+Sq(y-cr[j].first.second)))-r-cr[j].second);
			AddEdge(i,j,d);
		}
		cr.PB(MP(MP(x,y),r));
	}
	priority_queue<pair<double,int>,vector<pair<double,int>>,greater<pair<double,int>>> pq;
	vector<double> md(n+2,LLONG_MAX/2);
	md[0]=0;
	pq.push(MP(0.0,0));
	while(!pq.empty()){
		int v=pq.top().second;
		double d=pq.top().first;
		pq.pop();
		if(md[v]<d)
			continue;
		for(auto to:graph[v]){
			double k=d+to.first;
			int u=to.second;
			if(md[u]>k){
				md[u]=k;
				pq.push(MP(k,u));
			}
		}
	}
	cout<<fixed<<setprecision(19)<<md[1]<<endl;
}


Measured memory_bytes: 40720
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, i, x, sum=0;
  
  //input
  cin >> N >> K;
  for(i=0; i<N; i++){
    cin >> x;
    sum += min(K-x, x);
  }
  cout << 2*sum << endl;
}

Measured memory_bytes: 256
while True :
    name, type = map(str, input().split())
    
    if type == "X" :
        break
    
    else :
        N = list(name)
        
        if "_" in N :
            if type == "U" or type == "L" :
                cnt = 0
                
                for i in range(len(N)) :
                    if i == 0 and type == "U" :
                        N[i] = N[i].upper()
                    elif N[i] == "_" :
                        cnt += 1
                    elif cnt == 1 :
                        N[i] = N[i].upper()
                        cnt = 0
                
                N = [i for i in N if i != "_"]
                
        elif type == "U" :
            N[0] = N[0].upper()
            
        elif type == "L" :
            N[0] = N[0].lower()
            
        else :
            s = 0
            for i in range(len(N)) :
                if i == 0 :
                    N[s] = N[s].lower()
                    s += 1
                elif N[s].isupper() :
                    N[s] = N[s].lower()
                    N.insert(s, "_")
                    s += 2
                else :
                    s += 1
            
        for i in range(len(N)) :
            if i == len(N) - 1 :
                print(N[i])
            else :
                print(N[i], end = "")
                
                
                
                
        


Measured memory_bytes: 5592
n, m = [int(i) for i in input().split()]
prices = sorted([int(i) for i in input().split()], reverse=True)
d = 1
while(True):
	d *= 2
	if d * 2 > 10 ** 9:
		break
while(d > 0):
	for i, price in enumerate(prices):
		if price >= d:
			prices[i] = prices[i] // 2
			m -= 1
			if m == 0:
				d = 0
				break
	prices = sorted(prices, reverse=True)
	d /= 2
print (sum(prices))


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

int main(){
    vector<int> a,b;
    int a_,b_;
    while(cin >> a_ >> b_){
        a.push_back(a_);
        b.push_back(b_);
    }
    for(int i=0;i<a.size();i++){
        int c = 1;
        int s = a[i] + b[i];
        while(s >= 10){
            s /= 10;
            c++;
        }
        cout << c << endl;
    }
}

Measured memory_bytes: 3044
#include <iostream>
using namespace std;
int main(){
  long n,sum=0;
  cin >> n;
  for(int i=0;i<=n;i++){
    if(i%3==0) continue;
    else if(i%5==0) continue;
    else if(i%15==0) continue;
    else sum+=i;
  } 
  cout << sum << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<math.h>
using namespace std;
int p[50000] = { 0 };

int main(){
	int n, q, count, k, l = 0;
	
	for (int i = 2; i <= 300;i++)
		for (int j = i*2; j <= 50000; j += i){
			p[j] = 1;
		}
		
		while ((cin >> n), n){
			int count = 0;
			for (int i = 2; i <= n / 2; i++){
				if (p[n - i] == 0 && p[i] == 0)count++;
			}
			cout << count << endl;
		}
	return 0;
}

Measured memory_bytes: 1356