akhauriyash/Code-Regression huggingface dataset:
h, w, k = map(int,input().split())
s = [input() for _ in range(h)]
a = [[0]*w for _ in range(h)]

# 番号を数える
strno = 1
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            a[i][j] = strno
            strno += 1

# 番号を埋める           
for i in range(h):
    for j in range(w-1):
        if a[i][j+1] == 0:
            a[i][j+1] = a[i][j]
for i in range(h):
    for j in range(w-1):
        if a[i][w-j-2] == 0:
            a[i][w-j-2] = a[i][w-j-1]
            
for i in range(h-1):
    for j in range(w):
        if a[i+1][j] == 0:
            a[i+1][j] = a[i][j]
for i in range(h-1):
    for j in range(w):
        if a[h-i-2][j] == 0:
            a[h-i-2][j] = a[h-i-1][j]
            
for row in a:
    print(*row)


Measured memory_bytes: 48348
N = int(input())
li = list()
n = N + 1
for i in range(1, int(N**0.5+1)):
	if N % i == 0:
		li.append([i, int(N/i)])
for x in li:
	tmp = x[0] + x[1]
	if tmp <= n:
		n = tmp
ans = n - 2
print(ans)

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  ll N,K;cin>>N>>K;
  cout<<min(N%K,K-N%K)<<endl;
}





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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int64_t gcd(int64_t a, int64_t b) {
    if (a == 0) {
        return b;
    }

    return gcd(b % a, a);
}

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

    vector<int64_t> a(n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    vector<int64_t> l(n), r(n);
    l[0] = a[0];
    r[n - 1] = a[n - 1];
    for (auto i : irange(0L, n - 1)) {
        l[i + 1] = gcd(l[i], a[i + 1]);
        r[n - i - 2] = gcd(r[n - i - 1], a[n - i - 2]);
    }

    int64_t ans = max(l[n - 2], r[1]);
    for (auto i : irange(1L, n - 1)) {
        ans = max(ans, gcd(l[i - 1], r[i + 1]));
    }

    cout << ans << endl;
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descsort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void)
{
    ll x,y;
    cin>>x>>y;
    if(x%y)cout<<x<<endl;
    else cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 3628
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = (int) 1e5 + 5;
const int mod = (int) 1e9 + 7;

int n, c, k, a[N], l = 1, ans;

inline void solve () {
        scanf ("%d%d%d", &n, &c, &k);
        for (int i = 1; i <= n; i++) {
                scanf ("%d", &a[i]);
        }
        sort (a + 1, a + n + 1);
        for (int i = 2; i <= n; i++) {
                if (i - l == c || a[l] + k < a[i]) {
                        ans++;
                        l = i;
                }
        }
        ans++;
        printf ("%d\n", ans);
}

int tests = 1;

int main () {
//        freopen (".in", "r", stdin);
//        freopen (".out", "w", stdout);
//        scanf ("%d", &tests);
        srand (time (NULL));
        while (tests--) {
                solve ();
        }
        return 0;
}


Measured memory_bytes: 640
//コンパイラ最適化用
#pragma GCC optimize("O3")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

signed main(){
  int x;
  cin >> x;
  if(x < 30)
    cout << "No";
  else
    cout << "Yes";
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    int N, M;
    cin >> N >> M;
    int X, Y;
    cin >> X >> Y;
    int x[N], y[M];
    cins(x, x + N);
    cins(y, y + M);
    bool is_war = true;
    for(int Z = X + 1; Z <= Y; Z++){
        bool is_ok = true;
        for(int i = 0; i < N; i++){
            if(x[i] >= Z){
                is_ok = false;
            }
        }
        for(int i = 0; i < M; i++){
            if(y[i] < Z){
                is_ok = false;
            }
        }
        if(is_ok){
            is_war = false;
        }
    }
    if(is_war){
        cout << "War" << endl;
    }else{
        cout << "No War" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<queue>
#include<map>
#include<queue>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) for(int i=0;i<n;i++)

const int maxn=311,maxm=110,INF = 110000;
const int COST = 0, TIME = 1;

int n,m;

struct edge
{
    unsigned int to,cost;
    edge(int to,int cost):to(to),cost(cost){};
};

typedef pair<int,int> p;

int main()
{
    while(cin >> n >> m && (n||m))
    {
        vector<edge> cost[2][maxn];
        int a,b,tc,tt;
        REP(n)
        {
            cin >> a >> b >> tc >> tt;
            cost[TIME][a].push_back(edge(b,tt));
            cost[TIME][b].push_back(edge(a,tt));
            cost[COST][a].push_back(edge(b,tc));
            cost[COST][b].push_back(edge(a,tc));
        }

        int k; cin >> k;

        int start,goll,r;
        while(k--)
        {
            cin >> start >> goll >> r;
            int d[maxm] = {};
            memset(d,INF,sizeof(d));
            d[start] = 0;

            priority_queue<p,vector<p>, greater<p> > que;
            que.push(p(0,start) );

            while(!que.empty())
            {
                p tp = que.top(); que.pop();
                int v = tp.second; //確定ノード
                //cout << v << endl;
                if(d[v] < tp.first) continue;
                REP(cost[r][v].size())
                {
                    edge e = cost[r][v][i];
                    if(d[e.to] > d[v] + e.cost)
                    {
                        d[e.to] = d[v] + e.cost;
                        que.push(p(d[e.to], e.to));
                    }
                }
            }
            cout << d[goll] << endl;
        }
    }

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    bool same[n];
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        same[i] = a == i + 1;
    }
    int count = 0, ans = 0;
    for (bool t: same) {
        if (t) {
            count++;
        } else {
            ans += (count + 1) / 2;
            count = 0;
        }
    }
    ans += (count + 1) / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
typedef struct{
	char moji;
	int su;
}P;
int partition(P *,int ,int);
void quicksort(P *,int,int);
int antei(P *,P *,int);
void sort(P *,int,int);
void merge(P *,int,int,int);

int main(){
	P *a,*b;
	int n,i,c;
	scanf("%d",&n);
	b=(P *)malloc(sizeof(P)*(n+1));
	a=(P *)malloc(sizeof(P)*(n+1));
	for(i=0;i<n;i++){
		scanf(" %c%d",&a[i].moji,&a[i].su);
		b[i].su=a[i].su;
		b[i].moji=a[i].moji;
	}
	sort(b,0,n);
	quicksort(a,0,n-1);
	c=antei(a,b,n);
	if(0==c)printf("Not stable\n");
    else printf("Stable\n");
	for(i=0;i<n;i++){
		printf("%c %d\n",a[i].moji,a[i].su);
	}
	free(b);
	free(a);
	return 0;
}

void quicksort(P *A,int p,int r){
	int q;
	if(p<r){
		q=partition(A,p,r);
		quicksort(A,p,q-1);
		quicksort(A,q+1,r);
	}
}
int partition(P *A,int p,int r){
  int x,i,j,box;
  char m;
  x=A[r].su;
  i=p-1;
  for(j=p;j<r;j++){
    if(x>=A[j].su){
      i++;
	  box=A[i].su;
      A[i].su=A[j].su;
      A[j].su=box;
      m=A[i].moji;
      A[i].moji=A[j].moji;
      A[j].moji=m;
    }
  }
  i++;
    box=A[r].su;
    A[r].su=A[i].su;
    A[i].su=box;
	m=A[i].moji;
    A[i].moji=A[j].moji;
    A[j].moji=m;
    return i;
}

int antei(P *a,P *b,int n){
  int i;
  for (i = 0;i<n;i++){
    if(a[i].su!=b[i].su || a[i].moji!=b[i].moji)return 0;
  }
  return 1;
}
void sort(P *a,int L,int R){
  int mid;
  if(L+1<R){
    mid =(L+R)/2;
    sort(a,L,mid);
    sort(a,mid,R);
    merge(a,L,mid,R);
  }
}

void merge(P *a,int L,int mid,int R){
  int n1=mid-L,n2=R-mid,i,j,k;
  P *l,*r;
  l=(P *)malloc(sizeof(P)*(n1+1));
  r=(P *)malloc(sizeof(P)*(n2+1));
  for(i=0;i<n1;i++){
    l[i].su=a[L+i].su;
	l[i].moji=a[L+i].moji;
  }
  for(i=0;i<n2;i++){
    r[i].su=a[mid+i].su;
	r[i].moji=a[mid+i].moji;
  }
  l[n1].su=1000000001;
  r[n2].su=1000000001;
  i=0;
  j=0;
  for(k=L;k<R;k++){
    if(l[i].su>r[j].su){
      a[k].su=r[j].su;
	  a[k].moji=r[j].moji;
      j++;
    }else{
      a[k].su=l[i].su;
	  a[k].moji=l[i].moji;
      i++;
    }
  }
  free(l);
  free(r);
}



Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define INF (1e9 + 7)
using namespace std;
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(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, T; cin >> N >> T;
  int ans = 1e9;
  REP(i, N){
    int c, t; cin >> c >> t;
    if(t <= T){
      ans = min(ans, c);
    }
  }
  if(ans == 1e9){
    cout << "TLE" << endl;
  }else{
    cout << ans << endl;
  }
}


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

using namespace std;

int main()
{
  int N;
  cin>>N;
  int x;
  vector<int>A,B,C;
  int result=0;
  for(int i=0;i<N;i++)
  {
    cin>>x;
    A.push_back(x);
  }
  for(int i=0;i<N;i++)
  {
    cin>>x;
    B.push_back(x);
  }
  for(int i=0;i<N-1;i++)
  {
    cin>>x;
    C.push_back(x);
  }
  for(int i=0;i<N;i++)
  {
    result+= B[i];
    if(i>0 && A[i]==A[i-1]+1)
    {
        result += C[A[i-1]-1];
    }
  }
  cout << result << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
const long long INF = 1LL << 61;
const int MOD = 2019;

int main() {
	int L, R; cin >> L >> R;
	if (L == 0 || ((R - L) >= 2019))cout << 0;
	else{
		long long ans = INF;
		for (long long i = L; i <= R; ++i) {
			for (long long j = i + 1; j <= R; ++j) {
				long long num = (i * j) % MOD;
				if (ans > num)ans = num;
			}
		}
		cout << ans;
	}
}

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

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  int n1 = a1.size();
  int n2 = a2.size();
  if (n1 != n2) {
    return n1 - n2;
  }
  for (int i=0; i<n1; i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

int gcd(int a, int b) {
  if(a % b == 0) {
    return b;
  }
  return gcd(b, a % b);
}

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

vector<vector<int>> all_comb(int n, int k) {
  vector<vector<int>> combs(nCr(n, k), vector<int>(k));
  for(int i=0; i<k; i++) {
    combs[0][i] = i;
    combs[1][i] = i;
  }
  
  for(long i=1; i<nCr(n, k); i++) {
    int p = 1;
    while(combs[i][k - p] == n - p) {
      p++;
      if(p > k) {
        break;
      }
    }
    combs[i][k - p]++;
    int q = combs[i][k - p];
    for(int j=1; j<p; j++) {
      combs[i][k - p + j] = q + j;
    }

    if(i < nCr(n, k) - 1) {
      for(int j=0; j<k; j++) {
        combs[i + 1][j] = combs[i][j];
      }
    }
  }

  return combs;
}

template <typename TYPE> void co(TYPE a) {
  cout << a << endl;
}

template <typename TYPE> void co_2(TYPE a, TYPE b) {
  cout << a << ' ' << b << endl;
}

template <typename TYPE> void co_l(vector<TYPE> as) {
  int n = as.size();
  for(int i=0; i<n; i++) {
    cout << as[i] << endl;
  }
}

template <typename TYPE> void co_s(vector<TYPE> as) {
  int n = as.size();
  for(int i=0; i<n; i++) {
    if(i > 0) {
      cout << ' ';
    }
    cout << as[i];
  }
  cout << endl;
}

int main() {
  std::cout << std::setprecision(9);
  long mod = 1000000007;
  int d, t, s;
  cin >> d >> t >> s;

  if(s * t >= d) {
    co("Yes");
  }
  else {
    co("No");
  }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define dd(x) cout<<#x<<" = "<<x<<" "
#define de(x) cout<<#x<<" = "<<x<<"\n"
#define sz(x) int(x.size())
#define All(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef priority_queue<int> BQ;
typedef priority_queue<int,vector<int>,greater<int> > SQ;
const int maxn=3e5+10,mod=1e9+7,INF=0x3f3f3f3f;
int vis[maxn];
int main()
{
	int n,k;
	cin>>n>>k;
	for (int i=1;i<=k;++i){
		int d;
		cin>>d;
		for (int j=0;j<d;++j){
			int x;
			cin>>x;
			vis[x]=1;
		}
	}
	int ans=0;
	for (int i=1;i<=n;++i)
		ans+=(vis[i]==0);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3636
import fractions


def lcm(x, y):  # 最小公倍数
    return (x * y) // fractions.gcd(x, y)


a, b, c, d = map(int, input().split())
all = b - (b // c + b // d - b // lcm(c, d))
part = (a - 1) - ((a - 1) // c + (a - 1) // d - (a - 1) // lcm(c, d))


print(all - part)


Measured memory_bytes: 5048
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int n;
  cin >> n;
  vector<pair<string, pair<int, int>>> v(n);
  REP(i, n) {
    string s; int p;
    cin >> s >> p;
    v[i] = make_pair(s, make_pair(p * -1, i + 1));
  }
  sort(v.begin(), v.end());

  REP(i, n) {
    cout << v[i].second.second << endl;
  }
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

string vow = "aeiou";
const ld pie = 3.14159265358979 ;

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    int n ; cin >> n ;

    vi v ( n + 1 ) ;
    for ( int i=1 ; i < n+1 ; i++ ) cin >> v[i] ;

    vi b ( n + 1 ) ;
    for ( int i=1 ; i < n + 1 ; i++ ) cin >> b[i] ;

    vi c ( n ) ;
    for ( int i=1 ; i < n ; i++ ) cin >> c[i] ;

    ll ans = b[v[1]] ;

    for ( int i=2 ; i < n + 1 ; i++ )
    {
        ans += b[v[i]] ;
        if ( v[i] - v[i-1] == 1 )
        {
            ans += c[v[i-1]] ;
        }
    }

    cout << ans ; line
}

int main()
{fast
    int t = 1;
    //cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


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

using namespace std;
typedef long long int ll;

int f(vector<int> v){
  int res=0x7fffffff;
  int result = 0;
  int a = v[v.size()-1];
  v.pop_back();
  for(int i = 0;i<v.size();i++){
    if(res>max(a-v[i],v[i])){
      res= max(a-v[i],v[i]);
      result = v[i];
    }
  }
  return result;
}
    
  

int main() {
  int N;
  cin>>N;
  vector<int> v;
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    v.push_back(x);
  }

  sort(v.begin(),v.end());

  cout<<v[v.size()-1]<<" "<<f(v)<<endl;

  return 0;
}


Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,i,j;
  set<int> z={1};
  cin>>x;
  for(i=2;i*i<=x;i++){
    j=i*i;
    while(j<=x){
      z.insert(j);
      j*=i;
    }
  }
  cout<<*rbegin(z)<<endl;
}

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

int main(){
    int x, y;
    cin >> x >> y;
    int key = 1;
    if (x >= y){
        while(key != 0){
            key = x % y;
            x = y;
            y = key;
        }
        cout << x << endl;
    }
    else {
        while(key != 0){
            key = y % x;
            y = x;
            x = key;
        }
        cout << y << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = (int)1e9 + 7;

int main() {
    int n; 
    cin >> n;
    vector<double> head(n + 1), tail(n + 1);
    for(int i = 1; i <= n; ++i) {
        cin >> head[i];
        tail[i] = 1 - head[i];
    }
    vector<vector<double>> dp(n + 1, vector<double>(n + 1));
    dp[1][1] = head[1];
    dp[1][0] = tail[1];
    for(int i = 2; i <= n; ++i) {
        dp[i][i] = dp[i-1][i-1] * head[i];
        dp[i][0] = dp[i-1][0] * tail[i];
    }
    for(int i = 2; i <= n; ++i) {
        for(int j = 1; j < i; ++j) {
            dp[i][j] = dp[i-1][j-1]*head[i] + dp[i-1][j]*tail[i];
        }
    }
    double ans = 0;
    for(int i = 0; i <= n; ++i) {
        if(i > n - i)
            ans += dp[n][i];
    }
    cout << fixed << setprecision(10) << ans;


}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#include<functional>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
using namespace std;
int main()
{
  int N, L;
  cin >> N  >> L;
  int tot = N*(L - 1) + N*(N + 1)/2;
  //  cout << tot << endl;
  int a = min(abs(L), abs(L + N - 1));
  if(L*(L + N - 1) <= 0){
    cout << tot << endl;
  }else if (L < 0){
    cout << tot + a << endl;
  }else {
    cout << tot - a << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    string S;
    cin >> S;
    if (S == "ARC") {
        cout << "ABC" << endl;
    }
    if (S == "ABC") {
        cout << "ARC" << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def solve(inp):
    S = inp.readline().strip()
    Q = int(inp.readline().strip())
    Queries = [inp.readline().strip() for i in range(Q)]

    l = []
    r = []
    dir = False
    for Query in Queries:
        if Query == "1":
            dir = not dir
        else:
            (T, F, C) = Query.split(' ')
            if dir == (F == "1"):
                r.append(C)
            else:
                l.append(C)

    if dir:
        return "".join(reversed(r)) + "".join(reversed(S)) + "".join(l)
    else:
        return "".join(reversed(l)) + S + "".join(r)


def main():
    import sys
    result = solve(sys.stdin)
    if result is not None and result != '':
        print(result)


if __name__ == '__main__':
    main()


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

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

Measured memory_bytes: 3632
n, k = map(int, input().split())
mod = 10**9 + 7

m = 4*10**5 + 500

fac = [1] * (m + 1)
facinv = [1] * (m + 1)
for i in range(1, m+1):
    fac[i] = (fac[i-1] * i) % mod
    facinv[i] = (facinv[i-1] * pow(i, -1, mod)) % mod

def nCk(n, k):
    return (fac[n] * facinv[k] * facinv[n-k]) % mod

if k > (n - 2):
    print(nCk(2*n-1, n))
else:
    ans = 0
    for i in range(k+1):
        ans = (ans + nCk(n-1, i) * nCk(n, i)) % mod
    print(ans)

Measured memory_bytes: 40600
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;

ll dp[110][100010] = {0};

int main() {
    ll N, W;
    cin >> N >> W;
    ll w[N], v[N];
    for (int i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= W; ++j) {
            if (j >= w[i]) {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
            } else {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }

    cout << dp[N][W] << endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

const long long MOD = 1000000007;

int main(){
  ll a,b,n;
  cin >> a >> b >> n;
  ll x = min(b-1,n);
  ll ans=a*x/b;
  cout<<ans<<endl;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
map<int,int> ct;
int main(){
    int n;
    scanf("%d",&n);
    long long ans = 0;
    for (int i = 0,x; i < n; i++){
        scanf("%d",&x);
        ans += ct[x-i];
        ct[-i-x]++;
    }
    printf("%lld",ans);
}


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

using namespace std;

const int N = 123;

int f[N + 5][N + 5][N + 5];

const int inf = (int)1e9;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      for (int k = 0; k < N; ++k) {
        f[i][j][k] = inf;
      }
    }
  }
  f[a][b][c] = 0;
  for (int i = a; i < N; ++i) {
    for (int j = b; j < N; ++j) {
      for (int k = c; k < N; ++k) {
        f[i + 1][j + 1][k] = min(f[i + 1][j + 1][k], f[i][j][k] + 1);
        f[i + 1][j][k + 1] = min(f[i + 1][j][k + 1], f[i][j][k] + 1);
        f[i][j + 1][k + 1] = min(f[i][j + 1][k + 1], f[i][j][k] + 1);
        f[i + 2][j][k] = min(f[i + 2][j][k], f[i][j][k] + 1);
        f[i][j + 2][k] = min(f[i][j + 2][k], f[i][j][k] + 1);
        f[i][j][k + 2] = min(f[i][j][k + 2], f[i][j][k] + 1);
      }
    }
  }
  int ans = inf;
  for (int i = a; i < N; ++i) {
    for (int j = b; j < N; ++j) {
      for (int k = c; k < N; ++k) {
        if (i == j && j == k) {
          ans = min(ans, f[i][j][k]);
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int homura = 8000;
#define pb push_back
#define mp make_pair
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, m, i, j;
    vector<pair<int, int> > drinks;
    cin>>n>>m;
    for(i=0; i<n; ++i){
        int a, b;
        cin>>a>>b;
        drinks.pb(mp(a, b));
    }
    int ans = 0;
    sort(drinks.begin(), drinks.end());
    for(i=0; i<n; ++i){
        int ck = min(m, drinks[i].second);
        if(ck>0){
            m -= ck;
            ans += drinks[i].first * ck;
        }
        else break;
    }
    cout<<ans;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	int n, m;
	cin >> n >> m;
	vector<vi> adj(n);
	rep(i,0,m) {
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	vi side(n, -1);
	bool is_bipartite = true;
	queue<int> q;
	q.push(0);
	side[0] = 0;
	while(!q.empty()) {
		int v = q.front();
		q.pop();
		for(int u : adj[v]) {
			if(side[u] == -1) {
				side[u] = (side[v] ^ 1);
				q.push(u);
			} else {
				is_bipartite &= (side[u] != side[v]);
			}
		}
	}
	if(is_bipartite) {
		int b, w;
		b = w = 0;
		rep(i,0,n) {
			if(side[i] == 0) {
				b++;
			} else {
				w++;
			}
		}
		cout << (ll)b * w - m << '\n';
	} else {
		cout << (ll)(n-1)*n / 2 - m << '\n';
	}
	return 0;
}


Measured memory_bytes: 6272
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;


int main()
{
	int n;
	double x[1000], y[1000];
	cin >> n;
	for (int i = 0;i < n;i++)
		cin >> x[i];
	for (int j = 0;j < n;j++)
		cin >> y[j];
	double D1 = 0, D2 = 0, D3 = 0, D4 = 0, b;
	for (int k = 0;k < n;k++)
		D1 = D1 + fabs(x[k] - y[k]);
	for (int l = 0;l < n;l++)
		D2 = D2 + pow(x[l] - y[l], 2);
	D2 = sqrt(D2);
	for (int m = 0;m < n;m++)
		D3 = D3 + pow(fabs(x[m] - y[m]), 3);
	D3 = cbrt(D3);
	for (int o = 0;o < n;o++) {
		b= fabs(x[o] - y[o]);
		if (D4 < b)
			D4 = b;
	}
	printf("%.8lf\n", D1);
	printf("%.8lf\n", D2);
	printf("%.8lf\n", D3);
	printf("%.8lf\n", D4);

    return 0;
}


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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

int main() {
	ll n, m;
	cin >> n >> m;
	ll sum = 0;
	rep(i, m) {
		ll a;
		cin >> a;
		sum += a;
	}
	cout << max(n - sum, ll(-1)) << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
 
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define forab(i,a,b) for(int i=a;i<=b;i++)
#define all(x) x.begin(),x.end()
#define trav(i,x) for(auto& i:x)
#define endl cout<<"\n";
const int mod = 1e9+7;
const int maxn= 1e6+7;
int factors[maxn];
void sieve(){
	factors[1]=1;
	
	for(int i=2;i<=1000000;i++)
		factors[i]=i;
	
	for(int i=2;i*i<=1000000;i++){
		
		if(factors[i]==i){
		for(int j = i*i;j<=1000000;j+=i){
				if(factors[j]==j)
					factors[j]=i;
		}
	}
	}
}

int calculate(int n){
	if(n==1)	return 1;
		
		int ans=1;
		int dup = factors[n];
		
		int c=1;
		
		int j = n/factors[n];
		
		while(j!=1){
			
			if(factors[j]==dup)
				c++;
			else{
				dup = factors[j];
				ans=ans*(c+1);
				c=1;
			}
			
			j = j / factors[j];
			
		}
		
		ans=ans*(c+1);
		return ans;
}
int main()
{
	sieve();
    FAST_IO;
    ll n;
    cin>>n;
    int ans=0;
    for(int i=1;i<n;i++)
    {
		int x = calculate(n-i);
		ans+=(x);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 7552
#include <iostream>
#include <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include <climits>
#include <cmath>

int main(void) {
  int N;
  std::cin >> N;

  int count = 0;
  std::map<long long int, bool> A;
  for (int i = 0; i < N; i++) {
    long long int ai;
    std::cin >> ai;
    if (A.count(ai)) {
      A.erase(ai);
      count--;
    } else {
      A.emplace(ai, true);
      count++;
    }
  }

 std::cout << count << std::endl;

  return 0;
}


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






#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   100007
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/




int main()
{

    ll q=0,i,j,a[N],n,k=0;
    cin>>n;
    for0(i,n)
		cin>>a[i];

	for(i=0;i<n;i++)
	{
		if(a[i]%2==0)
		{
			while(a[i]%2==0)
			{
				k++;
				a[i]/=2;
			}
		}
	}
	cout<<k<<endl;
    return 0;

}



Measured memory_bytes: 384
import numpy as np

n, m, x = map(int, input().split())
books = [list(map(int, input().split())) for _ in range(n)]

ans = float('inf')
for i in range(2 ** n):
    cost = 0
    exp = np.array([0] * m)
    for j , b in enumerate(books):
        if i >> j & 1: continue
        cost += b[0]
        exp = exp + np.array(b[1:])
    if (exp < x).any(): continue
    ans = min(cost, ans)

if ans == float('inf'): ans = -1
print(ans)

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

int n,m;
int g[55][55];
int vis[55];

void check(int k) {
  vis[k]=1;
  for(int i=0;i<n;i++){
    if(g[k][i]&&!vis[i])check(i);
  }
}

int count_vis(){
  int t=0;
  for(int i=0;i<n;i++)
    if(vis[i])t++;
  return t==n;
}

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

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

  int res=0;

  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(g[i][j]){
        g[i][j]=g[j][i]=0;
        memset(vis,0,sizeof(vis));
        check(0);
        if(!count_vis())res++;
        g[i][j]=g[j][i]=1;
      }
    }
  }

  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#define ll long long
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<double> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    vector<double> exp(n);
    for(int i=0;i<n;i++){
        exp[i]=(p[i]+1)/2;
    }
    
    double sum=0;
    for(int i=0;i<k;i++){
        sum+=exp[i];
    }
    double ans=sum;
    for(int i=0;i+k<n;i++){
        sum=sum-exp[i]+exp[i+k];
        if(ans<sum){
            ans=sum;
        }
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> vp(n);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    vp[i] = make_pair(a, b);
  }
  sort(vp.begin(), vp.end());
  ll ans = 0;
  int drink = 0;
  for (int i = 0; i < n; i++) {
    if (drink > m) {
      break;
    }
    if (vp[i].second > m - drink) {
      ans += (ll)vp[i].first * (m - drink);
      drink += (m - drink);
    } else {
      ans += (ll)vp[i].first * vp[i].second;
      drink += vp[i].second;
    }
  }
  cout << ans << endl;
}


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

def solve():
    L, R = list(map(int, input().split()))
    MOD = 2019
    
    if R-L >= MOD:
        print(0)
        return

    L %= MOD
    R %= MOD

    if R < L:
        print(0)
        return
    
    ans = MOD
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ans = min(ans, i*j%MOD)
    print(ans)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3060
import sys
input = sys.stdin.readline

import math

def main():
    n = int(input())

    x = int(math.ceil(n / 1.08))
    xn = int(x*1.08)

    # print('x',x)
    # print('xn',xn)

    if xn == n:
        print(x)
    else:
        print(':(')




if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <string>
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define pb push_back
#define ll long long int
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)

using namespace std;
int prime(int n);
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b);
ll gcd(ll a, ll b);

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int prime(int n){
    int flag=1;
for(int i=2;i<=sqrt(n);i++){
    if(n%i==0){flag=0;break;}
}
  return flag;
}

int main(){
       ios_base::sync_with_stdio(false);
    cin.tie(NULL);
int n,k;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++)cin>>a[i];
ll dp[n];
memset(dp,1000000,sizeof(dp));
dp[0]=0;
dp[1]=abs(a[0]-a[1]);
for(int i=2;i<n;i++){//cout<<dp[i]<<endl;
  for(int j=1;j<=k;j++){ if(i-j>=0) dp[i]=min(dp[i-j]+abs(a[i-j]-a[i]),dp[i]);}
//cout<<dp[i]<<endl;
}
cout<<dp[n-1];
}


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

string s;

int main()
{
    cin >> s;
    sort(s.begin(), s.end());
    printf("%s\n", (s[0] != s[3] && s[0] == s[1] && s[2] == s[3])? "Yes": "No");
    return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < (int)(n) ; i++)

void solve(long long N, long long Y){
	rep(i,N+1)rep(j,N+1){
		if( i + j > N ) continue;
		int k = N - i - j;
		if( Y == i * 10000 + j * 5000 + k * 1000){
			cout << i << " " << j << " " << k << endl; 
			return;
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
}

int main(){	
	long long N;
	long long Y;
	scanf("%lld",&N);
	scanf("%lld",&Y);
	solve(N, Y);
	return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
 
using namespace std;
 
bool is_prime(int n, int k = 3)
{
    if(n < k * k) { return true; }
     
    if(n % k == 0) { return false; }
     
    return is_prime(n, k + 2);
}
 
int main()
{
    vector<int> prime = {2};
     
    for(int i = 3; i < 101300; i += 2)
    {
        if(is_prime(i))
        {
            prime.push_back(i);
        }
    }
     
    int n, m;
     
    while(true)
    {
        scanf("%d", &n);
        scanf("%d", &m);
         
        if(n == -1 && m == -1) { break; }
         
        int ptr = distance(prime.begin(), lower_bound(prime.begin(), prime.end(), n + 1));
         
        vector<int> c;
         
        for(int i = ptr; i < ptr + m; i++)
        {
            for(int j = i; j < ptr + m; j++)
            {
                c.push_back(prime[i] + prime[j]);
            }
        }
         
        sort(c.begin(), c.end());
         
        printf("%d\n", c[m - 1]);
    }
     
    return 0;
}

Measured memory_bytes: 3364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll m=1000000007;
int main() {
	ll n,k,i,j,w;
	cin>>n>>w;
	ll a[n+1],b[n+1];
	for(i=1;i<=n;i++)
	{
	    cin>>a[i]>>b[i];
	}
	vector<vector<ll>>dp(n+1,vector<ll>(w+1,0));
	for(i=1;i<=n;i++)
	{
	    for(j=1;j<=w;j++)
	    {
	        dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
	        if(j>=a[i])
	        {
	            dp[i][j]=max(dp[i][j],b[i]+dp[i-1][j-a[i]]);
	        }
	    }
	}
	cout<<dp[n][w];
	return 0;
}

Measured memory_bytes: 83080
a,*x=list(map(int,input()))
for i in range(8):
    k=a
    ans=str(a)
    for j in range(3):
        if i>>j&1:
            k+=x[j]
            ans+="+"+str(x[j])
        else:
            k-=x[j]
            ans+="-"+str(x[j])
    if k==7:
        print(ans+"=7")
        exit()

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

int64_t GCD(int64_t A, int64_t B){
  if(A<B) swap(A,B);
  if(A%B==0) return B;
  else return GCD(B,A-B*(A/B));
}

vector<int64_t> prime(int64_t A){
  vector<int64_t> ans;
  int64_t B = A;
  int judge = 0;
  if(A==3){
    return {3};
  }
  for(int64_t i=2; i*i<=B;){
    if(A%i==0){
      A /= i;
      ans.push_back(i);
    }
    else{
      i++;
      if(i*i>B && A!=1){
        ans.push_back(i);
      }
    }
  }
  return ans;
}

int main(){
  int64_t A, B;
  cin >> A >> B;
  vector<int64_t> res = prime(GCD(A,B));
  sort(res.begin(),res.end());
  if(res.size()==0){
    cout << 1 << endl;
    return 0;
  }
  vector<int64_t> ans = {1,res.at(0)};
  for(int64_t i=0; i<res.size()-1; i++){
    if(res.at(i)!=res.at(i+1)){
      ans.push_back(res.at(i));
    }
  }
  cout << ans.size() << endl;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> q;
    ll ans = 0;
    
    rep(i, n) {
        int a;
        cin >> a;
        q.push(a);
    }
    
    rep(i, m) {
        int a = q.top();
        q.pop();
        q.push(a / 2);
    }
    
    rep(i, n) {
        ans += q.top();
        q.pop();
    }
    
    cout << ans << endl;
    return 0;
}


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

#define ll long long
#define pb push_back

const int maxn = 1e5 + 20;

vector<int> adj[maxn];

int grundy[maxn];

void dfs(int v , int p = -1)
{
	for(auto u : adj[v])
		if(u != p)
		{
			dfs(u , v);
			grundy[v] ^= (grundy[u] + 1);
		}
}

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

	int n;
	cin >> n;

	for(int i = 0; i < n - 1; i++)
	{
		int a , b;
		cin >> a >> b;
		a-- , b--;

		adj[a].pb(b);
		adj[b].pb(a);
	}

	dfs(0);

	cout << (grundy[0]? "Alice" : "Bob") << endl;
}






















Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<n;++i)
#define rep1(i,n) for (int i=1; i<=n;++i)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
typedef long long ll;
const ll INF=1e17;

int main(){
    ll H,N;cin>>H>>N;
    vector<ll> a(N),b(N);
    rep(i,N) cin>>a[i]>>b[i];
    vector<vector<ll>> dp(N+5,vector<ll>(H+5,INF));
    dp[0][0]=0;
    rep(i,N+1)rep(j,H+1){
        chmin(dp[i+1][j],dp[i][j]);
        chmin(dp[i][min(j+a[i],H)],dp[i][j]+b[i]);
    }
    cout<<dp[N-1][H]<<endl;
}


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

int main() {
  string s,t;
  cin >> s >> t;
  bool ans=true;
  rep(i,s.size()) {
    if(s[i]!=t[i]) ans=false;
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" <<endl;
}

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

int n, m, a[100004];
pair<int, int> query[100004];

int main() {
	cin>>n>>m;
	for(int i = 0;i<n;i++)	cin>>a[i];
	for(int i = 0;i<m;i++)
		cin>>query[i].second>>query[i].first;
	sort(query,query+m);
	sort(a,a+n);
	int use = 0, idx = m-1;
	for(int i = 0;i<n;i++){
		if(a[i] < query[idx].first){
			a[i] = query[idx].first;
			use++;
		}
		if(use >= query[idx].second){
			use = 0;
			idx--;
		}
	}
	long long sum = 0;
	for(int i = 0;i<n;i++)	sum += a[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <math.h>
int main()
{
	long long int n;
	long long int a,b;
	long long int i;
	scanf("%lld",&n);
	for(i=1;i<=sqrt(n);i++)
	{
		if(n%i==0)
		{
			a=n/i;
			b=i;	
		}	
	}
	printf("%lld",a+b-2);
	return 0;
 } 


Measured memory_bytes: 128