akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 N;
  cin >> N;
  vector<i64> P(N);
  rep(i,0,N) cin >> P[i], P[i]--;
  vector<i64> idx(N);
  rep(i,0,N) idx[P[i]] = i;
  i64 MIN = 1e9;
  i64 ans = 0;
  rep(x,0,N) {
    i64 i = idx[x];
    if(i < MIN) {
      ans++;
      MIN = i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3328
#include<time.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

template<typename ...Ts>
void show(Ts... ts){
  cout<<"#:";
  auto print=[](auto v){cout<<v<<" ";};
  initializer_list<int>{(void(print(ts)),0)...};
  cout<<endl;
}

int main(void){
    int a[3];
    int ans;
    rep(i,3)cin>>a[i];
    sort(a,a+3);
    ans=a[2]-a[0];
    cout<<ans;
}






Measured memory_bytes: 256
package main

import (
	"fmt"
	"log"
)

func solution(a [][]int, b []int) string {
	m := make([][]int, 3)
	for i := range m {
		m[i] = make([]int, 3)
	}

	for _, n := range b {
		for i := 0; i < 3; i++ {
			for j := 0; j < 3; j++ {
				if n == a[i][j] {
					m[i][j] = 1
				}
			}
		}
	}
	log.Print(m)

	for i := 0; i < 3; i++ {
		if m[i][0] == 1 && m[i][1] == 1 && m[i][2] == 1 {
			return "Yes"
		}
	}

	for i := 0; i < 3; i++ {
		if m[0][i] == 1 && m[1][i] == 1 && m[2][i] == 1 {
			return "Yes"
		}
	}

	if (m[0][0] == 1 && m[1][1] == 1 && m[2][2] == 1) || (m[0][2] == 1 && m[1][1] == 1 && m[2][0] == 1) {
		return "Yes"
	}
	return "No"
}

func main() {
	var x, y, z int
	a := make([][]int, 3)
	for i := range a {
		a[i] = make([]int, 3)
	}
	for i := 0; i < 3; i++ {
		fmt.Scan(&x, &y, &z)
		a[i][0] = x
		a[i][1] = y
		a[i][2] = z
	}

	var n int
	fmt.Scan(&n)

	b := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		b[i] = x
	}

	fmt.Println(solution(a, b))
}


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

#define ll long long
#define endl "\n"
#define ios ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);

using namespace std;

const ll mod = 1e9 + 7, A = 2e6;

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    else {
        return gcd(b, a % b);
    }
}
    ll md[A + 2];


int main() {
    ios
    int n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; ++ i) {
        cin >> a[i];
    }
    map <ll, int> was;
    int f = 0;
    for (int i = 1; i <= A; ++ i) {
        md[i] = i;
    }
    for (int i = 2; i <= A; ++ i) {
        for (ll j = 1ll * i * i; j <= A; j += i) {
            md[j] = min(md[j], 1ll * i);
        }
    }
    for (int i = n - 1; i >= 0; -- i) {
        vector <ll> v;
        ll cop = a[i];
        while(cop > 1) {
            v.push_back(md[cop]);
            cop /= md[cop];
        }
        for (int j = 0; j < v.size(); ++ j) {
            if (was[v[j]] == 1) {
                f = 1;
            }
        }
        for (int j = 0; j < v.size(); ++ j) {
            was[v[j]] = 1;
        }
    }
    if (!f) {
        cout << "pairwise coprime";
        return 0;
    }
    ll now = a[0];
    for (int i = 1; i < n; ++ i) {
        now = gcd(now, a[i]);
    }
    if (now == 1) {
        cout << "setwise coprime";
        return 0;
    }
    else {
        cout << "not coprime";
        return 0;
    }
}


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

int main(){
	string S;
	cin >> S;
	int c = 0;
	if(S[0] == 'o') c += 100;
	if(S[1] == 'o') c += 100;
	if(S[2] == 'o') c += 100;
	cout << 700+c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <string>
#include <climits>

#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define PRINT(STR) cout << (STR) << endl

typedef long long ll;
using namespace std;

const int SEA = 0;
const int GROUND = 1;

int w, h;
int board[51][51];

void dfs(int y, int x) {
	if (x < 0 || x >= w) return;
	if (y < 0 || y >= h) return;
	if (board[y][x] == 0) return;
	board[y][x] = 0;
	dfs(y - 1, x);
	dfs(y - 1, x + 1);
	dfs(y, x + 1);
	dfs(y + 1, x + 1);
	dfs(y + 1, x);
	dfs(y + 1, x - 1);
	dfs(y, x - 1);
	dfs(y - 1, x - 1);
}

void calc() {
	int count = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (board[i][j] == GROUND) {
				count++;
				dfs(i, j);
			}
		}
	}
	PRINT(count);
}

int main() {
	cin.tie(0); //対話型には使えない
	ios::sync_with_stdio(false); //printfと共には使えない
	while (cin >> w >> h, w + h != 0) {
		REP(i, h) {
			REP(j, w) {
				char c;
				cin >> c;
				if(c == '0') {
					board[i][j] = SEA;
				} else {
					board[i][j] = GROUND;
				}
			}
		}
		calc();
	}
	return 0;
}

Measured memory_bytes: 1348
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final List<Pair> list = IntStream.range(0, n)
                .mapToObj(i -> new Pair(scanner.nextLong(), scanner.nextLong()))
                .sorted(Comparator.comparingLong(pair -> -(pair.t + pair.a)))
                .collect(Collectors.toList());

        final long answer = IntStream.range(0, n)
                .filter(i -> i % 2 == 0)
                .mapToLong(i -> list.get(i).t)
                .sum()
                - IntStream.range(0, n)
                .filter(i -> i % 2 == 1)
                .mapToLong(i -> list.get(i).a)
                .sum();

        System.out.println(answer);
    }

    private static class Pair {
        final long t;
        final long a;

        Pair(final long t, final long a) {
            this.t = t;
            this.a = a;
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}
    

Measured memory_bytes: 50512
#include<iostream>
#define R(i,n) for(int i=0;i<=n;i++)
using namespace std;int a,H,W,A;main(){int c[10][10];cin>>H>>W;R(i,9)R(j,9)cin>>c[i][j];R(k,9)R(i,9)R(j,9)c[i][j]=min(c[i][j],c[i][k]+c[k][j]);R(i,H-1)R(j,W-1){cin>>A;a+=c[A>=0?A:1][1];}cout<<a;}


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mp(v1, v2)       make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------
int main(void) {
  ll ans_num=0, ans_0=0, ans_p=0, ans_m=0;
  while(1){
    vec a(3, 0);
    cin >> a[0] >> a[1] >> a[2];
    sortall(a);

    if(a[2]<(a[0]+a[1])){
      ans_num++;
      ll judge=(a[0]*a[0] + a[1]*a[1] - a[2]*a[2]);
      if(judge>0) ans_p++;
      if(judge<0) ans_m++;
      if(judge==0) ans_0++;
    } else {
      cout << ans_num << " " << ans_0 << " " << ans_p << " " << ans_m << "\n";
      return 0;
    }
  }
}



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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    LL n;
    cin>>n;
    LL mx=INF;
    for(LL i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            mx=min(mx,n/i+i-2);
        }
    }
    cout<<mx;

}


Measured memory_bytes: 3684
S = input()
T = input()
pos = 0

for s in T:
  if not s in S:
    pos = -1
    break
  if s in S[pos%len(S):]:
    pos += S[pos%len(S):].index(s)+1
  else:
    pos += S.index(s)+len(S[pos%len(S):])+1
print(pos)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    string s; cin>>s;
    int n=s.size();
    int ans=0;
    rep(i,n-1){
        if(s[i]!=s[i+1]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String b = sc.next();
        if(b.equals("A")) System.out.println("T");
        if(b.equals("C")) System.out.println("G");
        if(b.equals("G")) System.out.println("C");
        if(b.equals("T")) System.out.println("A");
    }
}

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

int main(){
  char N;
  cin >> N;
  if(N == 'A'){
    cout << 'T' << endl;
  }else if(N == 'T'){
    cout << 'A' << endl;
  }else if(N == 'C'){
    cout << 'G' << endl;
  }else{
    cout << 'C' << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG_ARR(x, a, b) for(int i=a; i<=b; i++) cerr<<x[i]<<" "; cerr<<endl;
#define DEBUG_STR(x, a, b) for(int i=a; i<=b; i++) cerr<<x[i]; cerr<<endl;


using namespace std;

typedef long long ll;
typedef unsigned long long llu;

bool numbers[10];

bool isValid(int n){
//	DEBUG_ARR(numbers, 0, 9);
//	system("pause");
	while(n){
//		cout<<n;
		int d = n%10;
		if(numbers[d]) return false;
		n /= 10;
	}
	cout<<endl;
	return true;
}

int main() {
	FIO;
	int n,k;
	cin>>n>>k;
//	cout<<n<<endl;
//	system("pause");
	memset(numbers, 0, 10);
	for(int i=0; i<k; i++){
		int inp;
		cin>>inp;
		numbers[inp] = true;
	}
	while(1){
//		cout<<n<<" "<<isValid(n)<<endl;
		if(isValid(n)){
			cout<<n;
			break;
		}
		n++;
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
sp_list = [list((input().split(),i+1)) for i in range(n)]
sp_list = sorted(sp_list, key=lambda x:(int(x[0][1])),reverse = True)
sp_list = sorted(sp_list, key=lambda x:(x[0][0]))

for i in range(n):
    print(sp_list[i][1])

Measured memory_bytes: 3060
// AFTER CONTEST, WIP

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

// Utility
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, X, Y) for (int I = (X); I < (Y); I++)
using ll = int64_t;
using ull = uint64_t;
namespace std {
template<class ...Ts>        istream& operator>>(istream& i, tuple<Ts...>& x) { apply([&](auto&&... ys){ ((i >> ys), ...); }, x); return i; }
template<class T1, class T2> istream& operator>>(istream& i, pair<T1, T2>& x) { i >> x.first >> x.second; return i; }
template<class T>            istream& operator>>(istream& i, vector<T>& x)    { for (auto& y : x) { i >> y; } return i; }
}

// Debugging
#define DD(X) std::cout << #X ": " << (X) << std::endl << std::flush
namespace std {
template<class ...Ts>        ostream& operator<<(ostream& o, const tuple<Ts...>& x) { o << "("; apply([&](auto&& y, auto&&... ys){ o << y; ((o << ", " << ys), ...); }, x); o << ")"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const pair<T1, T2>& x) { o << tie(x.first, x.second); return o; }
template<class T>            ostream& operator<<(ostream& o, const vector<T>& x)    { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const set<T1, T2>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
}

// Modulo
constexpr ll kModulo = 998244353; // prime
ll madd(ll x, ll y) { return (x + y) % kModulo; }
ll mmul(ll x, ll y) { return (x * y) % kModulo; }
ll mexp(ll b, ll e) {
  ll res = 1, be = b;
  while (e > 0) {
    if (e & 1) { res = (res * be) % kModulo; }
    be = (be * be) % kModulo;
    e >>= 1;
  }
  return res;
}
ll minv(ll x) { return mexp(x, kModulo - 2); } // Zp* inverse
vector<ll> mfactorials(ll x) {
  vector<ll> res(x + 1, 0);
  res[0] = 1;
  FOR(i, 1, x + 1) {
    res[i] = mmul(res[i - 1], i);
  }
  return res;
}

// Main
void mainCase() {
  ll n, m, k; // n <= 10^6
  cin >> n >> m >> k;

  // Precompute factorials
  auto fs = mfactorials(n + k);
  auto binom = [&](ll n, ll k) { return mmul(fs[n], mmul(minv(fs[n - k]), minv(fs[k]))); };

  ll res = 0;
  FOR(c, 0, k + 1) {
    ll x = binom(n - 1, c);
    ll y = mexp(m - 1, n - 1 - c);
    ll z = mmul(x, mmul(y, m));
    res = madd(res, z);
  }
  cout << res << endl;
}

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

Measured memory_bytes: 6292
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        // 主処理
        String result = "2018" + s.substring(4);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21588
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF (1LL<<60)
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);  
  //問題文を読む時間をケチらない！！

  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  int ans = a[0];
  REP(i,n) ans = __gcd(ans,a[i]);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
from collections import deque
import sys
sys.setrecursionlimit(10**9)

n = int(input())
tree = [[] for _i in range(n)]
for _i in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

c = deque(sorted(list(map(int, input().split())), reverse=True))
visit = [-1 for _i in range(n)]
visit[0] = c.popleft()

def solve(p):
    r = 0
    for i in tree[p]:
        if visit[i] < 0:
            visit[i] = c.popleft()
            r += visit[i]
            r += solve(i)
    return r
x = solve(0)
print(x)
print(*visit)

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

#define int long long

signed main() {
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> v(n+1,k-q);
	for(int i = 0; i < q; i++) {
		int t; cin >> t;
		v[t]++;
	}
	for(int i = 1; i <= n; i++) {
		if(v[i] > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
package main

import (
	"fmt"
	"sort"
)

func main() {
	var A, B, K int
	var n []int
	fmt.Scan(&A, &B, &K)
	for i := 1; i <= 100; i++ {
		if A%i == 0 && B%i == 0 {
			n = append(n, i)
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(n)))
	fmt.Println(n[K-1])
}


Measured memory_bytes: 512
#include <iostream>

int main() {
	int in, i;
	std::cin >> in;

	int base = 2;
	for (i = 0; i < in; i++) {
		base *= 2;
		if (base >= in) break;
	}

	if (base == in) std::cout << base << std::endl;
	if (base > in) std::cout << base / 2 << std::endl;

	return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int i,n,old,list[7],a[10];

void check(int *old){
	if(*old>60)*old=60;
	list[*old/10]++;
}

int main(){
	while(scanf("%d",&n)*n){
		for(;n>9;n-=10){
			scanf("%d %d %d %d %d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9]);
			for(i=0;i<10;i++)check(&a[i]);
		}
		for(;n>0;n--){
			scanf("%d",&old);
			check(&old);
		}
		for(n=0;n<7;n++){
			printf("%d\n",list[n]);
			list[n]=0;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  cout << n*n - a << endl;

  return 0;
}


Measured memory_bytes: 384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M >> K;
	L = max(N, M);
	K += L - 1;
	cout << K / L << endl;

	return 0;
}

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

typedef long long ll;
typedef unsigned long long llu;

int main(int argc, char *argv[]) {
  ll n, m;
  cin >> n >> m;

  vector<vector<ll>> v(m+1);
  for (ll i = 0; i < n; ++i) {
    ll a, b;
    cin >> a >> b;
    if (a > m) continue;
    v[a].push_back(b);
  }

  priority_queue<ll> pq;
  ll ans = 0;
  for (ll i = 1; i <= m; ++i) {
    for (auto itr = v[i].begin(); itr != v[i].end(); ++itr) {
      pq.push(*itr);
    }

    if (pq.empty()) continue;
    ans += pq.top();
    pq.pop();
  }

  cout << ans << endl;
    
  return 0;
}

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

kk = 0
out = 0

for i in range(min(a,b),0,-1):
    aa = a % i
    bb = b % i
    
    if (aa+bb)==0:
        kk += 1
        #print(aa,bb,i)
        if kk==k:
            out = i
            break
print(out)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int p[8025][4125],co[200005][2];
int pp[4025][4025];
main()
{
	p[0][0]=1;
	for(int i = 0;i < 8022;i++)
	{
		for(int k = 0;k < 4122;k++)
		{
			for(int j = 0;j < 2;j++)
			{
				p[i+1][k+j]+=p[i][k];
				p[i+1][k+j]%=1000000007;
			}
		}
	}
	int t;
	scanf("%d",&t);
	for(int i = 0;i < t;i++)
	{
		scanf("%d%d",&co[i][0],&co[i][1]);
		pp[2010-co[i][0]][2010-co[i][1]]++;
	}
	for(int i = 0;i < 4015;i++)
	{
		for(int j = 0;j < 4015;j++)
		{
			pp[i+1][j]+=pp[i][j];
			pp[i][j+1]+=pp[i][j];
			pp[i+1][j]%=1000000007;
			pp[i][j+1]%=1000000007;
		}
	}
	long long sm=0;
	for(int i = 0;i < t;i++)
	{
		sm+=pp[2010+co[i][0]][2010+co[i][1]];
		sm%=1000000007;
	}
	/*for(int i = 1998;i <= 2005;i++)
	{
		for(int j = 1998;j <= 2005;j++)
		printf("%lld ",pp[i][j]);
		printf("\n");
	}*/
	long long ps=1000000007;
	ps*=100;
	for(int i = 0;i < t;i++)
	{
		sm-=p[co[i][0]*2+co[i][1]*2][2*co[i][1]];
		//printf("%d %d %d  ",co[i][0],co[i][1],p[co[i][0]*2+co[i][1]*2][co[i][1]+co[i][0]]);
		sm+=ps;
		sm%=1000000007;
	}
	int q=500000004;
	printf("%lld",(sm*q)%1000000007);
}

Measured memory_bytes: 194304
<?php
  $n = trim(fgets(STDIN));
  $p = explode(" ",trim(fgets(STDIN)));
  $p_cp = $p;
  sort($p_cp);
  $count = 0;
  for($i=0; $i<$n; $i++){
    if($p[$i] != $p_cp[$i]){
      $count++;
    }
  }
  if($count <= 2){
    echo "YES\n";
  }else{
    echo "NO\n";
  }

Measured memory_bytes: 4728
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using System.Text;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var X = LnLng();
        decimal money = 100m;
        var year = 0;
        while ((long)money < X)
        {
            money = (long)(money * 1.01m);
            year++;
        }
        print(year);
    } 



    public static void print(object obj) { Console.WriteLine(obj); }
    public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
}

Measured memory_bytes: 27396
#include <cctype>
#include <cstdio>
#include <bitset>

typedef long long i64;

const int N = 2000 + 10, MOD = 1000000007;

int nextInt() {
  char ch;
  while (!isdigit(ch = getchar())) {}
  int res = ch - '0';
  while (isdigit(ch = getchar())) res = 10 * res + ch - '0';
  return res;
}

int power(int base, int exp) {
  int res = 1;
  for (; exp; exp >>= 1) {
    if (exp & 1) res = (i64)res * base % MOD;
    base = (i64)base * base % MOD;
  }
  return res;
}

int fact[N], ifact[N];

inline int binom(int n, int m) { return m > n ? 0 : (i64)fact[n] * ifact[m] % MOD * ifact[n - m] % MOD; }

int n;
std::bitset<N> c[N];

int pivot[N];

int gauss() {
  int res = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) if (pivot[j] && c[i][j]) c[i] ^= c[pivot[j]];
    for (int j = 1; j <= n; ++j) {
      if (!pivot[j] && c[i][j]) {
        pivot[j] = i;
        ++res;
        break;
      }
    }
  }
  return res;
}

int p[N];

int calc(int n, int m) {
  int res = 1;
  for (int i = 0; i < m; ++i) res = res * ((i64)p[n] - p[i]) % MOD;
  return res;
}

inline int solve(int n, int m) {
  return (i64)calc(n, m) * power(calc(m, m), MOD - 2) % MOD;
}

int f[N][N];

int main() {
  fact[0] = 1;
  for (int i = 1; i < N; ++i) fact[i] = (i64)fact[i - 1] * i % MOD;
  ifact[1] = 1;
  for (int i = 2; i < N; ++i) ifact[i] = ((i64)MOD - MOD / i) * ifact[MOD % i] % MOD;
  ifact[0] = 1;
  for (int i = 1; i < N; ++i) ifact[i] = (i64)ifact[i - 1] * ifact[i] % MOD;
  p[0] = 1;
  for (int i = 1; i < N; ++i) p[i] = 2 * p[i - 1] % MOD;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      c[i][j] = nextInt();
  int rank = gauss();
  f[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    f[i][0] = 1;
    for (int j = 1; j <= n; ++j) {
      int &cur = f[i][j] = (i64)f[i - 1][j] * p[j] % MOD;
      cur = (cur + (i64)f[i - 1][j - 1] * (p[n] - p[j - 1])) % MOD;
    }
  }
  int ans = 0;
  for (int i = rank; i <= n; ++i) {
    int cur = (i64)f[n][i] * power(solve(n, i), MOD - 2) % MOD;
    cur = (i64)cur * solve(n - rank, i - rank) % MOD;
    ans = (ans + (i64)cur * power(p[n - i], n)) % MOD;
  }
  printf("%d\n", (ans + MOD) % MOD);
  return 0;
}


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

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


	int c = 0;
	int t;
	for (int i = 0; i < n; ++i) {
		cin >> t;
		if (k <= t) {
			++c;
		}
	}

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <cmath>
#include <string>
#include <iterator>
#include <vector>
 
using namespace std;

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 3*1e5;
char s[MAXN];

int largest(int a, int b){
	return (a<b)?b:a;
}


int main() {
	int n = 0;
	cin >> n;
	bool check = true;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		if(a[i] % 2 != 0){
			check = false;
		}
	}
	int t = 1;
	int ans = 0;
	if(!check){
		cout << 0 << endl;
		return 0;
	}
	while(t != 0){
		bool ok = true;
		for(int i = 0; i < n; ++i){
			if(a[i] % 2 != 0){
				ok = false;
				break;
			}
			else{
				a[i] = a[i] / 2;
			}
		}
		if(!ok){
			t = 0;
		}
		else{
			++ans;
		}
	}
	cout << ans << endl;
	

    return 0;
} 

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

const int MAX = 400000; // 欲しい最大数に応じて変動 n*2でOK
const int MOD = 1000000007; // 10^9+7用mod

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  long long a,b;
  cin>>a>>b;
  COMinit();
  
  if(a<=b){
    long long total;
    total=COM(a*2-1,a-1);
    cout << total << endl;
  }
  
  else{
    long long ans=0;
    for(int i=0; i<b; i++){
      ans = (ans + COM(a,b-i) * COM(a-1,a-1-b+i) % MOD) % MOD;
    }
    cout << ans + 1 << endl; // 22583772
  }
  

}

Measured memory_bytes: 9600
/**
 *     author: qodjf
 *     created: 04.22.2020 19:37:06
 */
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

ll lcm(ll a, ll b) { return a * b / __gcd(a, b); }

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

  int N, M;
  cin >> N >> M;
  vector<int> a(N);
  ll lc = 1;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    lc = lcm(lc, a[i]);
  }

  for (int i = 0; i < N; i++) {
    if ((lc / a[i]) % 2 == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  lc /= 2;
  ll ans = (M / lc + 1) / 2;
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    string s;
    int k;
    cin>>s;
    cin>>k;
    //abc 097 k-th substring 
    vector<string>a;
    int val=s.size();
    val=min(val,k);
    for(int i=1;i<=val;i++){
        for(int j=0;j<=s.size()-i;j++){
            a.push_back(s.substr(j,i));
        }
    }
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
  cout<<a[k-1]<<endl;
 return 0;   
}

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

struct Card{ char suit, value; };

void bubble(struct Card A[], int N) {
  for(int i = 0; i<N; i++) {
    for(int j = N-1; j >= i; j--) {
      if(A[j].value < A[j-1].value) {
        Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(struct Card A[], int N) {
  for(int i=0;i<N;i++) {
    int minj = i;
    for(int j=i; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    Card t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(struct Card A[], int N) {
  for(int i=0; i<N; i++) {
    if(i>0) cout << " ";
      cout << A[i].suit << A[i].value;
  }
  cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
  for(int i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return false;
  }
  return true;
}

int main(void) {
  Card C1[100], C2[100];
  int N;
  char ch;

  cin >> N;
  for(int i=0;i<N; i++) {
    cin >> C1[i].suit >> C1[i].value;
  }
  for(int i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  cout << "Stable" << endl;
  print(C2,N);
  if(isStable(C1,C2,N)) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }

  return 0;
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 998244353;

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

  LL a, b, t;
  cin >> a >> b >> t;
  LL cnt = 0;
  FOR(i, 1, t + 1)
  {
    if(i%a==0){
      cnt += b;
    }
  }
  cout<<cnt<<endl;
}


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

int main()
{
   int n;cin>>n;
  int k;cin>>k;
  int h[n];
  for(int i=0;i<n;i++)
  cin>>h[i];
  vector<int>dp(n,INT_MAX);
  dp[0]=0;
  int j;
  for(int i=0;i<n;i++)
  { j=1;
    while(j<=k && i+j<n)
    {
      dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
     j++;
    }
  }
 cout<<dp[n-1];
 return 0;

}

Measured memory_bytes: 1024
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	int N, K;
	cin >> N >> K;

	vector<char> D;
	for(int i=0; i<K; i++)
	{
		char c;
		cin >> c;

		D.push_back(c);
	}

	int ret;
	for(int i=N; i<10*N; i++)
	{
		string str = to_string(i);

		bool ok = true;
		for(auto it=D.begin(); it!=D.end(); it++)
		{
			if(str.find(*it) != string::npos)
			{
				ok = false;
				break;
			}
		}

		if(ok == true)
		{
			ret = i;
			break;
		}
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <list>
#include <stack>
#include <queue>
#include <utility>

using namespace std;

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

int main()
{
    int n,m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i,n)
    {
        cin >> a[i];
    }
    priority_queue<int> queue;
    rep(i,n)
    {
        queue.push(a[i]);
    }
    ll ans = 0;
    ll temp;
    rep(i,m)
    {
        temp = queue.top();
        queue.pop();
        temp/=2;
        queue.push(temp);
    }

    rep(i,n)
    {
        ans += queue.top();
        queue.pop();
    }
     cout << ans << endl;

}

Measured memory_bytes: 1660
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll N, K; cin >> N >> K;
	bool M[10] = {};
	repe(i, 1, K) {
		ll p; cin >> p;
		M[p] = true;
	}

	repe(i, N, 10 * N) {
		ll s = i;
		bool v = true;
		while (s > 0) {
			if (M[s % 10]) {
				v = false;
				break;
			}
			s /= 10;
		}
		if (v) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}

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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0;i<n;i++){
    cin >> d[i];
  }
  if(d[0]!=0){
    int s=0;
    cout << s << endl;
    return 0;
  }
  sort(d.begin(),d.end());
  map<int,int> m;
  int count=1;
  for(int i=1;i<n;i++){
    if(d[i]!=d[i-1]){
      count++;
    }
  }
  for(int i=0;i<n;i++){
    m[d[i]]++;
  }
  long long ans=1;
  for(int i=1;i<count;i++){
    for(int j=0;j<m[i];j++){
      ans*=m[i-1];
      ans%=998244353;
    }
  }
  if(m[0]!=1){
    ans=0;
  }
  for(int i=0;i<count;i++){
    if(m[i]==0){
      ans=0;
      break;
    }
  }
  cout << setprecision(10);
  cout << ans << endl;
}


Measured memory_bytes: 5376
N, M = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(M)]

answer = 0
for x in edges:
    l = range(N)
    for y in edges:
        if y != x:
            l = [l[y[0]-1] if l[i] == l[y[1]-1] else l[i] for i in range(N)]
    if len(set(l)) != 1: answer += 1
print(answer)

Measured memory_bytes: 3064
use proconio::input;

fn main() {
    input! {
        a: usize,
        b: usize,
    }

    solve(a, b);
}

fn solve(a: usize, b: usize) {
    if a < 10 && b < 10 {
        println!("{}", a * b);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 2164
#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))

# 最初が0から始まる場合
a_list = [0] + a_list
b_list = [0] * (N + 1)
# インデックスがずれるのがややこしいので、
# b_list[0]は欠番として1始まりで考えていく

for i in range(N):
    # 大きい方から決めていく
    idx = N - i
    total = sum(b_list[idx : N + 1 : idx])

    if total % 2 != a_list[idx]:
        b_list[idx] = 1

idx_list = [str(i) for i, b in enumerate(b_list) if b == 1]
ans = sum(b_list[1:])
print(ans)
if ans != 0:
    print(" ".join(idx_list))


Measured memory_bytes: 17204
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
//using ll = long long;
//void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    long long a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k%2 == 0)cout << a-b;
    else cout << b-a;
}

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

int main()
{
    // Fast_IO();
    char ch; cin >> ch;
    if((int)ch <= 96) cout << 'A';
    else cout << 'a';
    return 0;
}

Measured memory_bytes: 3592
#!/usr/bin/env python3
from itertools import product

s = input()
op_patterns = product(['+', '-'], repeat=3)

for operators in op_patterns:
    expression = f"{s[0]}{operators[0]}{s[1]}{operators[1]}{s[2]}{operators[2]}{s[3]}"
    if eval(expression) == 7:
        print(f"{expression}=7")
        break


Measured memory_bytes: 9000
#include"bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
const int N = 3e3 + 5 ;
const int MOD = 1e9+7;
typedef long long int ll;
vector< pair< ll , ll > > vp;
map<ll , ll > mp , mpp;
vector < ll > v , v1 , v2 ;
ll dp[N][N] , visit[N] ;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<"  ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
string s , s1 ;
ll go(int uidx , int didx ) {
	if(uidx == (int)s.size() || didx == (int)s1.size()) return dp[uidx][didx] = 0 ;
	if(dp[uidx][didx] != -1) return dp[uidx][didx] ;
	ll x = -1e9 + 5 , y = -1e9 + 5 , z = -1e9 + 5  ;
	if(s[uidx] == s1[didx]) x = 1 + go(uidx + 1 , didx + 1) ;
	y = go(uidx + 1 , didx) ;
	z = go(uidx , didx + 1) ;
	return dp[uidx][didx] = max(x , max(y , z)) ;

}

void goa(ll cur, ll uidx, ll didx){
	if(uidx == (int)s.size() || didx == (int)s1.size()) return ;
	if(s[uidx] == s1[didx]){
		if(dp[uidx + 1][didx + 1] == cur - 1){
			cout << s[uidx];
			goa(cur - 1, uidx + 1, didx + 1);
			return ;
		}
	}
	if(dp[uidx + 1][didx] == cur){
		goa(cur, uidx + 1, didx);
		return ;
	}
	goa(cur, uidx, didx + 1);
}

int main()
{ fast;
   ll n, m, val, k, d, mi=1e9, mx(0) ;
   ll sum(0), ct(0), p(0), q(0);
   cin >> s >> s1 ;
   memset(dp , -1 , sizeof(dp)) ;
   ll gg = go(0 , 0 ) ;
   //cout << gg  ;
   goa(gg, 0, 0);
}


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


int main(){
  int N, M;
  cin >> N >> M;

  cout << N+1-M << endl;
  
  return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

dp = [0]
for i in range(1, n):
    if i == 1:
        dp.append(dp[i - 1] + abs(h[i] - h[i - 1]))
    else: # i >= 2
        dp.append(min(dp[i - 1] + abs(h[i] - h[i -1]), dp[i - 2] + abs(h[i] - h[i - 2])))
print(dp[n - 1])

Measured memory_bytes: 20548
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

#define PI 3.141592653589793

int main(){
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double ans = sqrt(A*A + B*B -2*A*B*cosl(fabs(6*M-(30*H+0.5*M))*PI/180.0));
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 4168
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<map>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  map<string,int> m;
  string str;
  string ans1 = "";
  string ans2 = "";
  int cnt = 0;
  while(cin>>str) m[str]++;
  FOR(it,m){
    if(it->f.size() > ans2.size())
      ans2 = it->f;
    if(cnt < it->s){
      ans1 = it->f;
      cnt  = it->s;
    }
  }
  cout << ans1 << " " << ans2 << endl;
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main(void){
    int A,B,x,y,z;
    scanf("%d %d",&A,&B);
    x=A+B;
    y=A-B;
    z=A*B;
    if(x>y&&x>z)printf("%d",x);
    else if(y>z)printf("%d",y);
    else printf("%d",z);
    return 0;
    
}


Measured memory_bytes: 128
// ABC065A - Expired?

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

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	int X, A, B;
	cin >> X >> A >> B;

	if (A >= B) {
		cout << "delicious" << endl;
	} else if (B - A <= X) {
		cout << "safe" << endl;
	} else {
		cout << "dangerous" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
while True:
    try:
        s=input()
        if s=="-":
            break
        m=int(input())
        for i in range(m):
            h=int(input())
            f=s[:h]

            l=s[h:len(s)]
            s=l+f
        print(s)
        
    except:
        break
        


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char a,b;
    cin>>a;
    cin>>b;
    char ara[1000000];
    char arb[1000000];
    int ia = a - '0';
    int ib = b - '0';
    for(int i=0;i<ia;i++){
        arb[i]=b;
    }
    for(int i=0;i<ib;i++){
    ara[i]=a;
    }

    if(strcmp(ara,arb)<=0){
               for(int i=0;i<ib;i++)
        cout<<ara[i];
    }
    else{
             for(int i=0;i<ia;i++){
        cout<<arb[i];

    }

    }


}


Measured memory_bytes: 3644