akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0028
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            List<int> Xs = new List<int>();
            List<int> Ys = new List<int>();

            for (int i = 0; i < N; i++)
            {
                var r = Console.ReadLine();

                Xs.Add(int.Parse(r.Split(' ')[0]));

                Ys.Add(int.Parse(r.Split(' ')[1]));
            }

            List<int[]> Nums = GetAllPermutation(N);

            double result = 0;

            for (int i = 0; i < Nums.Count(); i++)
            {
                for (int j = 0; j < Nums[i].Count() - 1; j++)
                {
                    var tmp =
                        Math.Pow((Xs[Nums[i][j]] - Xs[Nums[i][j + 1]]), 2) +
                        Math.Pow((Ys[Nums[i][j]] - Ys[Nums[i][j + 1]]), 2);

                    result += Math.Sqrt(tmp);
                }
            }

            double rt = result / (double)Nums.Count();

            Console.WriteLine(rt);

        }
        
        static List<int[]> GetAllPermutation(int N)
        {
            var res = new List<int[]>();
            var array = Enumerable.Range(0, N).ToArray();

            do
            {
                var copy = new int[N];
                array.CopyTo(copy, 0);
                res.Add(copy);
            } while (NextPermutation(array));

            return res;
        }

      
        static bool NextPermutation(int[] array)
        {
            var size = array.Length;
            var ok = false;

            int i = size - 2;
            for (; 0 <= i; i--)
            {
                if (array[i] < array[i + 1])
                {
                    ok = true;
                    break;
                }
            }

            if (ok == false)
            {
                return false;
            }

            int j = size - 1;
            for (; ; j--)
            {
                if (array[i] < array[j])
                {
                    break;
                }
            }

            var tmp = array[i];
            array[i] = array[j];
            array[j] = tmp;

            Array.Reverse(array, i + 1, size - (i + 1));

            return true;
        }
    }
}


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

int main() {
  int A,B,C,D;
  
  cin >> A >> B >> C >> D ;
  
  while(true){
    C = C - B;
    if(C <= 0){
      cout << "Yes" << endl;
      break;
    }
    
    A = A - D;
    if (A <= 0){
      cout << "No" << endl;
      break;
    }
    

  }
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
// #include<stack>
// #include<queue>
using namespace std;
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2;
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
// vector<vector<ll>> vec(100,vector<ll>(100));
int main(){
  ll a,b;
  cin >> a >> b;
  ll sum = 0;
  rep(i,20){
    if(1 + (a-1) * i >= b){
      sum = i;
      break;
    }
  }
  cout << sum;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

struct Edge{
  int from;
  int to;
  long cost;
};

vvl dp(100010,vl(2,-1));

vector<vector<Edge>> Graph(100010);

long dfs(int v, int pv, int w){
  if(dp[v][w] != -1) return dp[v][w];
  long res = 1;
  for(Edge ed : Graph.at(v)){
    int nv = ed.to;
    if(pv == nv) continue;
    if(w) res = (res * (dfs(nv,v,1) + dfs(nv,v,0)) % MOD) % MOD;
    else res = (res * dfs(nv,v,1)) % MOD;
  }
  return dp[v][w] = res;
}

void dfs2(int v, int pv){
  dp[v][0] = 1;
  dp[v][1] = 1;
  for(Edge ed : Graph.at(v)){
    int nv = ed.to;
    if(pv == nv) continue;
    dfs2(nv, v);
    dp[v][0] = (dp[v][0] * (dp[nv][0] + dp[nv][1])) % MOD;
    dp[v][1] = (dp[v][1] * dp[nv][0]) % MOD;
  }
}

int main(){
  int n;
  cin >> n;
  rep(i,n-1){
    int x,y;
    cin >> x >> y;
    x--;y--;
    Graph.at(x).push_back({x,y,1});
    Graph.at(y).push_back({y,x,1});
  }
  dfs2(0,-1);
  cout << (dp[0][0] + dp[0][1]) % MOD << endl;
}

Measured memory_bytes: 23268
import java.io.InputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

class MyScanner{
    InputStream stream;
    public MyScanner(){
        stream = System.in;
    }
    
    public int nextInt(){
        int ret = 0;
        boolean minus = false;
        try{
            stream.mark(1);
            if((char)stream.read() == '-'){
                minus = true;
            }else{
                stream.reset();
            }
            while(true){
                char readed = (char)stream.read();
                if(readed < '0' || readed > '9'){
                    break;
                }
                ret = ret * 10 + (readed - '0');
            }
            if(minus){
                ret *= -1;
            }
        }catch(IOException e){
            e.printStackTrace();
        }finally{
            return ret;
        }
    }
}

class Main {
    public static void main(String args[]) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        MyScanner sc = new MyScanner();
        int y = sc.nextInt(), m = sc.nextInt(), d = sc.nextInt();
        if(m < 5){
            System.out.println("Heisei");
        }else{
            System.out.println("TBD");
        }
    }
}


Measured memory_bytes: 20436
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
	string s;
	cin >> s;
	rep(i, 4) cout << s.at(i);
	cout << ' ';
	for(int i=4; i<12; i++) cout << s.at(i);
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import itertools
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,Y = IL()

if N*1000 <= Y <= N*10000:
	Y -= N*1000 - 4000
	for i in range(N+1):
		Y -= 4000
		if Y%9000 == 0 and 0 <= Y//9000 <= N and 0 <= N-Y//9000-i:
			print(Y//9000,i,N-Y//9000-i)
			exit()
print(-1,-1,-1)

Measured memory_bytes: 13088
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;




int main() {
	ll n, a;
	cin >> n >> a;
	vector<ll> data(n);
	ll sum = 0LL;
	
	rep(i, 0, n) {
		cin >> data[i];
	}


	//dp[i][j][k]:i枚目までのなかからj枚選んで和がkになる通り数
	vector< vector< vector<ll> > >dp(n + 1, vector< vector<ll> >(n+1,vector<ll>(n*50+1,0)));

	
	rep(i, 0, n+1) {
		dp[i][0][0] = 1LL;
	}
	rep(i, 0, n) {
		rep(j, 0, i+1) {
			rep(k, 0, n*50 + 1) {
				if (k - data[i] >= 0) {
					dp[i + 1][j + 1][k] += dp[i][j][k - data[i]] + dp[i][j+1][k];
				}
				else {
					dp[i + 1][j + 1][k] += dp[i][j+1][k];
				}
			}
		}
	}


	rep(i, 1, n+1) {
		sum += dp[n][i][i*a];
	}
	
	cout << sum << endl;

	
	return 0;
}


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

using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

signed main(void){
  string s,o;
  cin >> s;
  debug(s.size());
  REP(i,(int)s.size()){
    if(s[i] == '0')o.PB('0');
    if(s[i] == '1')o.PB('1');
    if(s[i] == 'B'&&o.size()!=0)o.pop_back();
  }
  cout << o << endl;

  return 0;
}



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

const ll INF = 1e17;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<ll> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	auto hs = H;
	hs.push_back(0);
	sort(hs.begin(), hs.end());
	hs.erase(unique(hs.begin(), hs.end()), hs.end());
	for (auto& h : H) {
		h = lower_bound(hs.begin(), hs.end(), h) - hs.begin();
	}
	const int M = hs.size();
	vector<vector<vector<ll>>> dp(N + 1, vector<vector<ll>>(K + 1, vector<ll>(M, INF)));
	dp[0][0][0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= K; j++) {
			for (int k = 0; k < M; k++) {
				if (j + 1 <= K) {
					dp[i + 1][j + 1][k] = min(dp[i + 1][j + 1][k], dp[i][j][k]);
				}
				dp[i + 1][j][H[i]] = min(dp[i + 1][j][H[i]], dp[i][j][k] + max(0LL, hs[H[i]] - hs[k]));
			}
		}
	}
	ll res = INF;
	for (int i = 0; i <= K; i++) {
		for (int j = 0; j < M; j++) {
			res = min(res, dp[N][i][j]);
		}
	}
	cout << res << endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> x(N); 
  vector<int> y(N);
  
  cin >> x.at(0) >> y.at(0);
  int min = x.at(0) + y.at(0);
  int mini = 0;
  int max = x.at(0) + y.at(0);
  int maxi = 0;
  
  int maxxminy = x.at(0) - y.at(0);
  int maxxminyi = 0;
  int minxmaxy = y.at(0) - x.at(0);
  int minxmaxyi = 0;
  
  for (int i = 1; i < N; i++) {
    cin >> x.at(i) >> y.at(i);
    if (min > x.at(i) + y.at(i)) {
      min = x.at(i) + y.at(i);
      mini = i;
    }
    if (max < x.at(i) + y.at(i)) {
      max = x.at(i) + y.at(i);
      maxi = i;
    }
    if (maxxminy < x.at(i) - y.at(i)) {
      maxxminy = x.at(i) - y.at(i);
      maxxminyi = i;
    }
    if (minxmaxy < y.at(i) - x.at(i)) {
      minxmaxy = y.at(i) - x.at(i);
      minxmaxyi = i;
    }
  }
  
  int ans;
  ans = x.at(maxi) - x.at(mini) + y.at(maxi) - y.at(mini);
  int ans2;
  ans2 = abs(x.at(maxxminyi) - x.at(minxmaxyi)) + abs(y.at(maxxminyi) - y.at(minxmaxyi));
  if (ans < ans2) {
    ans = ans2;
  }
  cout << ans << endl;
}


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

int main()
{
	int x, y, ans = 0, nx, ny, m, cm;
	int n, w, h;

	cin >> w >> h >> n;

	cin >> nx >> ny;
	for (int i = 1; i < n; i++){
		cm = 0;
		m = 0;
		cin >> x >> y;
		if (nx > x && ny > y){
			cm = min(nx - x, ny - y);
			m += nx - cm - x;
			m += ny - cm - y;
		}
		else if (nx < x && ny < y){
			cm = min(x - nx, y - ny);
			m += x - cm - nx;
			m += y - cm - ny;
		}
		else {
			m += max(x, nx) - min(x, nx);
			m += max(y, ny) - min(y, ny);
		}
		nx = x;
		ny = y;
		ans += m + cm;
		//cout << ans << endl;

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

Measured memory_bytes: 3072
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <climits>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <unordered_map>
#include <numeric>
#include <random>
#include <memory>
#include <chrono>
#include <iterator>
#include <functional>
#ifdef LOCAL
#include "debug.h"
#else
#define debug(x...)
#endif
//#pragma GCC optimize("Ofast")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
#define mp make_pair
#define pb push_back
#define sz(x) int((x).size())

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2e5 + 7;
const int inf = INT_MAX / 2;
const ll INF = LLONG_MAX / 3;
const int MOD = 998244353;
const ld eps = 1e-6;
const string cars[] = {"🚗", "🚕", "🚙"};


signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cout << fixed << setprecision(3);
    cin.tie();
    cout.tie();

    string s, t;
    cin >> s >> t;

    int ans = 0;
    ans += (s[0] == t[0]);
    ans += (s[1] == t[1]);
    ans += (s[2] == t[2]);

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
/*
 *created by Kraken on 27-04-2020 at 18:05
 */
import java.util.*;
import java.io.*;

public class Main {

  public static void main(String[] args) {
    FastReader sc = new FastReader();
    String s = sc.next(), t = sc.next();
    if (s.length() < t.length()) {
      String temp = s;
      s = t;
      t = temp;
    }
    int n = s.length(), m = t.length();
    int[][] dp = new int[n + 1][m + 1];
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (s.charAt(i - 1) == t.charAt(j - 1))
          dp[i][j] = dp[i - 1][j - 1] + 1;
        else
          dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
    String sb = "";
    int i = n, j = m;
    while (i > 0 && j > 0) {
      if (dp[i - 1][j - 1] == dp[i][j] - 1 && s.charAt(i - 1) == t.charAt(j - 1)) {
        sb = s.charAt(i - 1) + sb;
        i--; j--;
      } else {
        if (dp[i - 1][j] > dp[i][j - 1]) i--;
        else j--;
      }
    }
    System.out.println(sb);
  }

  static class FastReader {

    BufferedReader br;

    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        }
        catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

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

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

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      }
      catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


Measured memory_bytes: 86808
package main

import "fmt"

const (
	// MOD is .
	MOD = 1000000000 + 7
)

func main() {
	var n, k int
	fmt.Scanf("%d %d", &n, &k)
	if k > n {
		k = n
	}
	A := 1
	sum := 0
	for i := 0; i <= k; i++ {
		sum += A
		sum %= MOD
		val := (n - i) * (n - i - 1) % MOD
		val = val * modPow((i+1)*(i+1)%MOD, MOD-2) % MOD
		A = A * val % MOD
	}
	fmt.Println(sum)
	// fmt.Println(combMod(n, a))
}

func multiCombMod(n, k int) int {
	return combMod(n+k-1, k)
}

func combMod(n, k int) int {
	if k == 0 {
		return 1
	}

	res := n
	div := k
	for i := 1; i < k; i++ {
		res = res * (n - i) % MOD
		div = div * (k - i) % MOD
	}
	div = modPow(div, MOD-2)
	return res * div % MOD
}

func modPow(a, n int) int {
	if n == 0 {
		return 1
	}
	res := 1
	for p := n; p > 0; p >>= 1 {
		if p&1 == 1 {
			res = res * a % MOD
		}
		a = a * a % MOD
	}
	return res
}


Measured memory_bytes: 512
#include <iostream>
#include <map>

using namespace std;

map <int, int> a;

int main()
{
    int x;

    for (int i = 0; i < 6; i++)
    {
        cin >> x;
        a[x]++;
    }

    if (a[1] == 3 || a[2] == 3 || a[3] == 3 || a[4] == 3)
    {
        cout << "NO";
    }
    else
    {
        cout << "YES";
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  cin >> s;
  int c = 0;
  for(int i = 0; i < (int)s.size(); i++) {
    if (s[i] == '0') c++;
  }
  cout << min(c,(int)s.size()-c)*2 << endl;
  return 0;
}

Measured memory_bytes: 3720
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	r := make([][]bool, n+1)
	for i := 1; i <= n; i++ {
		r[i] = make([]bool, n+1)
	}
	var a, b int
	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b)
		r[a][b], r[b][a] = true, true
	}

	res := solve(n, r)
	fmt.Println(res)
}

func solve(n int, r [][]bool) int {
	count := 0

	var dfs func(a int, used []int)
	dfs = func(a int, used []int) {
		if len(used) == n {
			count++
			return
		}

		for b := 1; b <= n; b++ {
			if r[a][b] && !contains(used, b) {
				t := append(used, b)
				dfs(b, t)
			}
		}
	}
	dfs(1, []int{1})

	return count
}

func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <sstream>
#include <iomanip>
using namespace std;

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

Measured memory_bytes: 1408
#include <stdio.h>
int main(void){
    int N, Y;
    if (scanf("%d %d", &N, &Y) == -1) return -1;
    for (int x = 0; x <= N; x++) {
        for (int y = 0; y <= N - x; y++) {
            int z = N - x - y;
            if (10000 * x + 5000 * y + 1000 * z == Y) {
                printf("%d %d %d\n", x, y, z);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}

Measured memory_bytes: 128
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#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>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#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>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#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 <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

int main ()
{
	char a , b , c;
	int x[3] = { 1 , 0 , 0 };
	while( cin >> a >> b >> c )
	{
		swap ( x[a - 'A'] , x[c - 'A'] );
	}
	if( x[0] )cout << 'A' << endl;
	if( x[1] )cout << 'B' << endl;
	if( x[2] )cout << 'C' << endl;
	return 0;
}

Measured memory_bytes: 1132
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(ll itr=mp.begin();itr!=mp.end();itr -++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

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

    //A:0, G:1, C:2, T:3, 文字なし:4(~3文字のため)
    // dp[x][i][j][k] : x文字で末尾がijkのときに条件を満たす個数
    ll dp[n+1][5][5][5] = {};
    dp[0][4][4][4] = 1;

    rep(x, n){
        //i,j,k,lの四文字
        rep(i, 5)rep(j, 5)rep(k, 5)rep(l, 4){
            //AG?C
            if(i == 0 && j == 1 && l == 2)continue;
            //A?GC
            if(i == 0 && k == 1 && l == 2)continue;
            //?AGC
            if(j == 0 && k == 1 && l == 2)continue;
            //?ACG
            if(j == 0 && k == 2 && l == 1)continue;
            //?GAC
            if(j == 1 && k == 0 && l == 2)continue;

            dp[x+1][j][k][l] += dp[x][i][j][k];
            dp[x+1][j][k][l] %= MOD;
        }
    }

    ll ans = 0;
    rep(i, 4)rep(j, 4)rep(k, 4)ans += dp[n][i][j][k];

    cout << ans % MOD << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h> 
 
using namespace std; 
const int MAX_N = 105; 
const int MAX_V = 100005; 
const int inf = 1000000007; 
 
int dp[MAX_N][MAX_V]; 
int n, M;
int v[MAX_N]; 
int m[MAX_N]; 
int T; 
 
int main () { 
	//freopen("SC6.inp", "r", stdin); 
	//freopen("SC6.out", "w", stdout); 
		scanf("%d %d", &n, &M); 
 
		int sum = 0; 
		for (int i = 1; i <= n; i++) {
			scanf("%d %d", &m[i], &v[i]); 
			sum += v[i]; 
		}

 
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= sum; j++) {
				dp[i][j] = inf; 
			}
		}
 
		dp[0][0] = 0; 
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= sum; j++) {
				if (dp[i][j] != inf) {
					dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]); 
					if (j + v[i + 1] <= sum && dp[i][j] + m[i + 1] <= M) {
						dp[i + 1][j + v[i + 1]] = min(dp[i + 1][j + v[i + 1]], dp[i][j] + m[i + 1]);
					}
				}
			}
		}
 
		int res = 0; 
		for (int i = 1; i <= sum; i++) {
			if (dp[n][i] <= M) {
				res = i; 
			}
		}
 
		cout << res << endl; 
	
	return 0; 
}

Measured memory_bytes: 41216
#include<stdio.h>
#include<math.h>

typedef long long int lli;

int a[600000];
lli b[600000];
int dd[600000];

int main(void) {
    int n,d;
    scanf("%d%d",&n,&d);
    for(int i=0; i<n; i++)
        scanf("%d",&dd[i]);
    a[0] = d;
    for(int i=0; i<n; i++)
        a[i+1] = abs(a[i] - dd[i]) > a[i] ? a[i] : abs(a[i] - dd[i]);

    b[n] = 1;
    for(int i=n-1; i>=0; i--) {
        if(b[i+1] <= dd[i]/2)
            b[i] = b[i+1];
        else
            b[i] = b[i+1] + dd[i];
    }

    int q;
    scanf("%d",&q);
    for(int i=0; i<q; i++) {
        int qq;
        scanf("%d",&qq);
        puts(a[qq-1] >= b[qq] ? "YES" : "NO");
    }
}


Measured memory_bytes: 10880
#include <iostream>
int main(){int n,k,x,y,i;std::cin >> n >> k;n++;for(;k;k--){std::cin >> x >> y;x = (x > n/2)?(n-x):x;y = (y > n/2)?(n-y):y;i = ((x<y)?x:y)%3;std::cout << (i?i:3) << "\n";}return 0;}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define   sz           1000010
using namespace std;

typedef long long int ll;
ll n, T[sz], m, p, x;

int main()
{

    cin >> n;

    ll sum = 0;
    
    for(int i=1; i<=n; i++) cin >> T[i], sum += T[i];

    cin >> m;

    for(int i=1; i<=m; i++)
    {
        cin >> p >> x;

        ll res = sum;

        res -= T[p];

        res += x;

        cout << res << endl;
    }
    return 0;
}

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

using namespace std;

const int MAX_N = 1e5 + 5;
vector <int> graph[MAX_N];
vector <int> component(MAX_N, 0);

void dfs(int v, int parent_v, int component_no)
{
    component[v] = component_no;

    for(int i = 0; i < graph[v].size(); i++)
    {
        int child_v = graph[v][i];

        if(parent_v == child_v || component[child_v] != 0) continue;

        dfs(child_v, v, component_no);
    }
}

int main()
{
    int no_of_vertices, no_of_edges;
    cin >> no_of_vertices >> no_of_edges;

    for(int i = 1; i <= no_of_edges; i++)
    {
        int u, v, z;
        cin >> u >> v >> z;

        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    int no_of_components = 0;
    for(int i = 1; i <= no_of_vertices; i++)
    {
        if(component[i] == 0)
        {
            no_of_components++;

            dfs(i, 0, no_of_components);
        }
    }

    cout << no_of_components;
    return 0;
}


Measured memory_bytes: 12288
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);    
  int n;
  cin >> n;
  int c = 0;
  bool ok = 0;
  while (n--) {
    int x, y;
    cin >> x >> y;
    if (x - y) {
      c = 0;
    } else {
      if (++c == 3) {
        ok = 1;
      }
    }
  }
  if (ok) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
#define int long long 
typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=500005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int N, M;
int ffmod[MAXN], ifmod[MAXN];

ll qmult(ll X, ll Y, ll M) {    
    return X * Y % M;
}

ll qexp(ll A, ll B, ll M) {
    if (B == 0) return 1; 
    ll half = qexp(A, B/2, M);
    half = qmult(half, half, M); 
    half %= M;
    if (B%2==1) half *= A%M;
    return half%M;
}

int modinv(int x){
	return qexp(x, MOD-2, MOD);
}
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> M;
	ffmod[0] = 1;
	FOR(i,1,MAXN-1) ffmod[i] = (ffmod[i-1] * i) % MOD;
	ifmod[MAXN-1] = modinv(ffmod[MAXN-1]);
	DEC(i,MAXN-2,0) ifmod[i] = (ifmod[i+1] * (i+1))%MOD;
	int ans = 0;
	FOR(i,0,N){
		int tmp = 1;
		if (i%2==1) tmp = -1;
		tmp *= ffmod[N]; tmp %= MOD;
		tmp *= ifmod[i]; tmp %= MOD;
		tmp *= ifmod[N-i]; tmp %= MOD;
		tmp *= ffmod[M]; tmp %= MOD;
		tmp *= ifmod[M-i]; tmp %= MOD;
		tmp *= ffmod[M-i]; tmp %= MOD;
		tmp *= ifmod[M-N]; tmp %= MOD;
		tmp *= ffmod[M-i]; tmp %= MOD;
		tmp *= ifmod[M-N]; tmp %= MOD;
		ans += tmp + MOD; ans %= MOD;
	}
	cout<<ans;
}


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

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

int main() {
  ll n, nn, ans = 0, d;
  cin >> n;

  for (ll a = 2; a * a <= n; ++a) {
    if (n % a != 0) continue;
    ll ex = 0, x = 0;
    while (n % a == 0) ++ex, n /= a;
    while ((x + 1) * (x + 2) / 2 <= ex) x++;
    ans += x;
  }
  if (n != 1) ans++;

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


Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <utility>
using namespace std;

using ll = int;
using PII = pair<ll, ll>;
ll n, m, a[10], y[10], x[10];
ll h, ans;

void dfs(ll cur, ll last, vector<PII>& v) {
	// cout << "cur=" << cur << endl;
	if (cur == m) {
		// cout << "a" << endl;
		vector<vector<ll>> p(h);
		for (ll i = 0; i < m; ++i) {
			p[v[i].first].push_back(v[i].second);
		}
		bool flag = true;
		for (ll i = 0; i < n; ++i) x[i] = i;
		for(auto q: p) {
			// for (auto i : q) cout << i << " ";
			// cout << endl;
			sort(q.begin(), q.end());
			for (ll i = 1; i < q.size(); ++i) {
				if (q[i] == q[i - 1] + 1) {
					flag = false;
					break;
				}
			}
			if (!flag) break;
			for (auto i : q) {
				swap(x[i], x[i + 1]);
			}
		}
		for (ll i = 0; i < n; ++i) {
			if (x[i] != y[i]) {
				flag = false;
				break;
			}
		}
		if (flag) ans = h;
		return;
	}
	
	ll st = 0;
	if (cur && a[cur - 1] == a[cur]) st = last + 1;
	for (ll i = st; i < h; ++i) {
		v.push_back({ i, a[cur] });
		dfs(cur + 1, i, v);
		v.pop_back();
	}
}

int main() {
	cin >> n >> m;
	for (ll i = 0; i < m; ++i) cin >> a[i], a[i]--;

	for (ll i = 0; i < n; ++i) y[i] = i;
	for (ll i = 0; i < m; ++i) {
		swap(y[a[i]], y[a[i] + 1]);
	}
		
	vector<PII> vp;
	sort(a, a + m);
	ans = m;
	for (ll i = 0; i < m-1; ++i) {
		// cout << "i=" << i << endl;
		h = i + 1;
		dfs(0, -1, vp);
		if (ans != m) break;
	}

	cout << ans << endl;
}


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

int main() {
  
  int N,f = 0;
  string A = "No";
  
  cin >> N;
  for (int i = N; i > 0; i /= 10) {
    f += i%10;
  }
  if ( N%f == 0) A = "Yes";
  cout << A << endl;
}


Measured memory_bytes: 256
x = int(input())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
    
a = False
while a ==False:
    a = is_prime(x)
    if a == False:
        x+=1

print(x)

Measured memory_bytes: 38684
#include <iostream>
#include <algorithm>
using namespace std;
 
constexpr int kN = int(2E5 + 10);
int w[kN], r[kN];
 
int main() {
	int n, ans = kN;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		w[i + 1] = w[i] + (s[i] == 'W');
		r[i + 1] = r[i] + (s[i] == 'R');
	}
	for (int i = 0; i <= n; i++) {
		ans = min(ans, max(w[i], r[n] - r[i])); 
	}
 
 
	cout << ans << '\n';
}

Measured memory_bytes: 5268
N = int(input())
A = list(int(i) for i in input().split())

ans = 0
for i in range(N):
    for j in range(A[i]):
        if A[i] % 2 == 0:
            ans += 1
            A[i] = A[i]/2
        else:
            break
print(ans)


Measured memory_bytes: 4148
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}

int main()
{
    ll d,t,s;
    cin >> d >> t >> s;
    if(d>s*t){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3588
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

int cnt[10][10];

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    REP(i, 1, N) {
        string S = to_string(i);
        cnt[S.front() - '0'][S.back() - '0']++;
    }
    int ans = 0;
    REP(i, 1, N) {
        string S = to_string(i);
        ans += cnt[S.back() - '0'][S.front() - '0'];
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,m=0,cnt=0,sx[900],sy[900];
  string str[30];
  cin>>h>>w;
  for(int i=0;i<h;++i) cin>>str[i];
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      if(str[i][j]=='B'){
	sx[cnt]=j; sy[cnt]=i; ++cnt;
      }
    }
  }
  for(int i=0;i<cnt-1;++i){
    for(int j=i+1;j<cnt;++j){
      m=max(m,abs(sx[j]-sx[i])+abs(sy[j]-sy[i]));
    }
  }
  cout<<m<<endl;
      
  return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	ll s;
	cin >> s;
	bool used[100000];
	for(int i = 0; i < 100000; i++) used[i] = false;
	int m = 1;
	while(true) {
		if(used[s]) {
			cout << m << "\n";
			return 0;
		}
		used[s] = true;
		m++;
		if(s % 2 == 0)
			s /= 2;
		else
			s = 3 * s + 1;
	}
	return 0;
}


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

priority_queue<ll> Q;
vector<ll> v[100001];

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

    ll ans = 0;
    for(int i=1; i<=m; i++){
        for(auto k:v[i])Q.push(k);
        if(!Q.empty()){
            ans += Q.top();
            Q.pop();
        }
    }

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

Measured memory_bytes: 5632
#include<iostream>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define pb push_back
#define ll long long
#define ff first
#define ss second
using namespace std;

int n;
double p[3000];
double dp[3000][3000];

double fun(int i,int c){
    if(i==n && c>(n)/2){
        return 1;
    }
    else if(i>=n){
        return 0;
    }
    if(dp[i][c]!=-1){
        return dp[i][c];
    }
    
    return dp[i][c] = fun(i+1,c+1)*p[i]+fun(i+1,c)*(1-p[i]);
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            dp[i][j] = -1;
        }
    }
    cout<<fixed;
    cout<<setprecision(10)<<fun(0,0)<<endl;
    return 0;
}

Measured memory_bytes: 70784
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
int main() {
	ll n;
	ll sum = 0;
	cin>>n;
	for(ll i=1;i<=n;i++){
		if(i%3==0||i%5==0){
			continue;
		}
		sum+=i;
	} 
	cout<<sum<<endl;
    return 0;
}



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

using namespace std;

void test()
{
    int n;
    cin>>n;

    for(int x=1;true;x++)
    {
        if(x*n%360==0)
        {
            cout<<x;
            return ;
        }
    }
}

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

    test();

    return 0;
}



Measured memory_bytes: 3596
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    long[] h = new long[n];
    for(int i = 0; i < n; i++) {
      h[i] = sc.nextLong();
    }
    Arrays.sort(h);
    long ans = 0;
    for(int i = 0; i < n - k; i++) {
      ans += h[i];
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 87884
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
ll INF = (1LL << 50) - 1;
int MOD = 1e9+7;
template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;

template< typename T > vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}
main(){
    int N,M,S,T;
    cin >> N >> M >> S >> T;
    S--;T--;
    WeightedGraph<ll> g1(N),g2(N);
    rep(i,0,M){
        ll a,b,c,d;
        cin >> a >> b >> c >> d;
        a--;b--;
        g1[a].emplace_back(b,c);
        g1[b].emplace_back(a,c);
        g2[a].emplace_back(b,d);
        g2[b].emplace_back(a,d);
    }
    auto dist1 = dijkstra(g1, S);
    auto dist2 = dijkstra(g2, T);

    vector<ll> ans;
    ll mini = INF;
    //rep(i,0,N)cout << dist1[i] << endl;
    //cout << endl;
    for(int i = N-1;i >= 0;i--){
        ll d = dist1[i] + dist2[i];
        mini = min(mini, d);
        ans.push_back(mini);
    }
    ll cost = 1e15;
    rep(i,0,N){
        cout << cost - ans[N-i-1] << endl;
    }
}

Measured memory_bytes: 19964
#include <bits/stdc++.h>
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int N;
    scan(N);
    int ans = -1;
    rep(i, 50001) {
        int x = i * 1.08;
        if (x == N) {
            print(i);
            return 0;
        }
    }
    print(":(");

    return 0;
}

Measured memory_bytes: 256
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using V = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(a, b, n);
    if (n >= b)
        cout << a * (b-1) / b << endl;
    else
    {
        cout << a * n / b - a * (n / b) << endl;
    }
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3652
#-------------------------------------------------------------------
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------
n=int(input())

X = [ [] for _ in range(n) ]			#=> [[], [], [], [], [], [], [], []]
L = [ [] for _ in range(n) ]			#=> [[], [], [], [], [], [], [], []]
A = [ [] for _ in range(n) ]			#=> [[], [], [], [], [], [], [], []]


for i in range(n):
	x,l = map(int, input().split())
	X[i],L[i] = x,l
	
	a = x-l
	b = x+l
	
	A[i]=[a,b]


B = sorted(A, key=lambda x: (x[1],-x[0]))

#p(X)
#p(L)
#p(A)
#p(B)


l=B[0][0]
r=B[0][1]
ans=1

for x,y in B:
	if r <= x:
		ans+=1
		l,r=x,y

print(ans)
	
	

Measured memory_bytes: 39584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int a[200005];
int main()
{
  int n;cin>>n;
  for(int i=0;i<n;i++)
  cin>>a[i];
  sort(a,a+n);
  int flag=0;
  for(int i=1;i<n;i++)
  if(a[i]==a[i-1])
  flag=1;
  if(flag)
  cout<<"NO"<<endl;
  else
  cout<<"YES"<<endl;
}

Measured memory_bytes: 1024
import re

S = input().replace('?', '.')
T = input()

ans = []

for i in range(len(S)-len(T), -1, -1):
    if re.match(S[i:i+len(T)], T):
        ans.append((S[:i] + T + S[i+len(T):]).replace('.', 'a'))

print(min(ans) if ans else 'UNRESTORABLE')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 2e5+5;

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n, m;

    cin >> n >> m;

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

    return 0;
}


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

template <class T>
using V = vector<T>;

template <class T>
using VV = V<V<T>>;

template <class T>
using P = pair<T, T>;

// 重さに対する価値の最大値ではなく、
// 価値に対する重さの最小値を求める。
// 双対法的な？

const int MAX_N = 110;
const int MAX_V = 1010;
const int MAX_NV = MAX_N * MAX_V + 1;
long long dp1[MAX_N * MAX_V + 1], dp2[MAX_N * MAX_V + 1];

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

    memset(dp1, -1, sizeof(dp1));
    memset(dp2, -1, sizeof(dp2));
    long long *prev = dp1, *nxt = dp2;

    prev[0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < MAX_NV; ++j) {
            nxt[j] = prev[j];
        }
        for (int j = 0; j < MAX_NV; ++j) {
            if (prev[j] != -1 && j + v[i] < MAX_NV) {
                if (nxt[j + v[i]] == -1)
                    nxt[j + v[i]] = prev[j] + w[i];
                else
                    nxt[j + v[i]] = min(nxt[j + v[i]], prev[j] + w[i]);
            }
        }
        swap(prev, nxt);
    }

    int res = 0;
    for (int i = MAX_N * MAX_V; i >= 0; --i) {
        if (prev[i] != -1 && prev[i] <= W) {
            res = i;
            break;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5336
#include<iostream>
using namespace std;
int64_t x,y;
int64_t f(int64_t x,int64_t z)
{
  y+=x+z;
  for(int64_t i=10;i<x;i*=10)
  {
    f(x/i,x%i+z);
  }
  return y;
}
int main()
{
  cin>>x;
  cout<<f(x,0)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>

using namespace std;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    int n;
    cin >> n;
    long mx = 0;
    long ans = 0;
    for (int i = 0; i < n; i++) {
        long a;
        cin >> a;
        if (mx < a) {
            mx = a;
        } else {
            ans += mx - a;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int c[5];
  char cm;
  while (cin >> c[0] >> cm >> c[1] >> cm >> c[2] >> cm >> c[3] >> cm >> c[4]) {
    sort(c, c + 5);
    int same = 0, two = 0, t = 1, i;
    for (i = 0; i < 4; i++)
      if (c[i] == c[i + 1]) {
        t++;
        if (t == 2) two++;
        same = max(same, t);
      }
      else t = 1;
    bool full = false;
    if (c[0] == c[1] && c[3] == c[4] && (c[1] == c[2] || c[2] == c[3])) full =
      true;
    bool st = true;
    if (c[0] == 1 && c[1] == 10) {
      for (i = 1; i < 4; i++)
        if (c[i] + 1 != c[i + 1]) st = false;
    }
    else {
      for (i = 0; i < 4; i++)
        if (c[i] + 1 != c[i + 1]) st = false;
    }
    cout
      << ((same == 4) ? "four card" : (full) ? "full house" :
          (st) ? "straight" : (same == 3) ? "three card" :
          (same == 2) ? ((two == 2) ? "two pair" : "one pair") : "null")
      << endl;
  }
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
typedef long long ll;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    int N, M; cin >> N >> M;
    vector<int> v[M];
    rep(i, N) {
        int a, b; cin >> a >> b;
        if (a > M) continue;
        a--;
        v[a].pb(b);
    }
    priority_queue<int> que;
    ll ans = 0;
    rep(i, M) {
        for (int x : v[i]) {
            que.push(x);
        }
        if (!que.empty()) {
            ans += que.top(); que.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5504
# ABC131D - Megalomania
from operator import itemgetter as gt


def main():
    N, *AB = map(int, open(0).read().split())
    cur, TD = 0, sorted([(i, j) for i, j in zip(*[iter(AB)] * 2)], key=gt(1))
    for task, deadline in TD:  # check all tasks greedily
        cur += task
        if cur > deadline:  # fail to finish a task within its deadline
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()

Measured memory_bytes: 48708