akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

int wt(int x) {
    int ans = 0;
    for (int i=0;i<18;i++) {
        if (x & (1<<i)) ans++;
    }
    return ans;
}

constexpr int maxL = 100000;
constexpr int cutoff = 511;

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

    int N;
    cin >> N;

    vi V(N+1);
    vi W(N+1);

    for (int i=1;i<=N;i++) cin >> V[i] >> W[i];

    vll sack(maxL+1, 0);
    vvll sacks(513, sack);

    for (int i=1;i<=min(N, cutoff);i++) {
        for (int w=0;w<=maxL;w++) sacks[i][w] = sacks[i/2][w];
        for (int w=W[i];w<=maxL;w++) {
            sacks[i][w] = max(sacks[i/2][w-W[i]] + V[i], sacks[i][w]);
        }
    }

    int Q;
    cin >> Q;

    for (int q=0;q<Q;q++) {
        int v, L;
        cin >> v >> L;

        if (v <= cutoff) {
            cout << sacks[v][L] << "\n";
            
        } else {
            vi tmpV;
            vi tmpW;
            while (v > cutoff) {
                tmpV.pb(V[v]);
                tmpW.pb(W[v]);
                v /= 2;
            }

            ll best = 0;
            int tmpN = tmpV.size();
            for (int i=0;i<(1<<tmpN);i++) {
                ll curv = 0;
                ll curw = 0;
                for (int j=0;j<tmpN;j++) {
                    if (i & (1<<j)) {
                        curv += tmpV[j];
                        curw += tmpW[j];
                    }
                }

                if (curw <= L) {
                    best = max(sacks[v][L-curw] + curv, best);
                }
            }

            cout << best << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 408144
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(10);
		   ll n,x;
           cin>>n>>x;
           vll a(n);
           rep(i,0,n)cin>>a[i];
           ll sum=0;
           //後ろを食べれば良い？
           rep(i,0,n-1){
             if(a[i]+a[i+1]>x){
               ll q=a[i]+a[i+1];
               sum+=q-x;
               //-に注意
               if(a[i+1]>=q-x)a[i+1]-=q-x;
               else {
                 a[i+1]=0;
               }
             }
           }
           cout<<sum<<endl;
}

Measured memory_bytes: 3984
#include <stdio.h>
#include <stdint.h>

int main(void) {
    uint64_t x, y, d;
    int len = 0;
    
    scanf("%llu %llu", &x, &y);

    d = y / x;

    while (d >= 1) {
        len += 1;
        d >>= 1;
    }

    printf("%d\n", len);
    
    return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	list := getStdinIntArr()
	N := list[0]
	M := list[1]
	X := list[2]
	C := make([]int, N)
	A := make([][]int, N)
	for i := 0; i < N; i++ {
		A[i] = make([]int, M)
	}

	for i := 0; i < N; i++ {
		list2 := getStdinIntArr()
		C[i] = list2[0]
		for j := 0; j < M; j++ {
			A[i][j] = list2[j+1]
		}
	}

	maxBit := (1 << N) - 1
	moneyMin := math.MaxInt32
	for bit := 1; bit <= maxBit; bit++ {
		money := 0
		AC := make([]int, M)
		for i := 0; i < N; i++ {
			mask := 0
			if i == 0 {
				mask = 1
			} else {
				mask = 1 << i
			}
			if (bit & mask) != 0 {
				money += C[i]
				for n := 0; n < M; n++ {
					AC[n] += A[i][n]
				}
			}
		}
		flag := true
		for i := 0; i < M; i++ {
			if AC[i] < X {
				flag = false
				break
			}
		}
		if flag && money < moneyMin {
			moneyMin = money
		}
	}

	if moneyMin == math.MaxInt32 {
		fmt.Printf("%d\n", -1)
	} else {
		fmt.Printf("%d\n", moneyMin)
	}
}

func getStdin() string {
	sc.Scan()
	return sc.Text()
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}


Measured memory_bytes: 2148
#include <stdio.h>

#define N 100000

int main() {
	static int hh[N];
	int n, i, cnt, max;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &hh[i]);
	max = cnt = 0;
	for (i = n - 2; i >= 0; i--)
		if (max < (cnt = hh[i] >= hh[i + 1] ? cnt + 1 : 0))
			max = cnt;
	printf("%d\n", max);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

const int MOD=1000000007;
const int MAX = 1000000;
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(){
    COMinit();
    int x,y;
    cin>>x>>y;
    int n,m;
    n = 2*y-x;
    m = 2*x-y;
    //cout<<n<<" "<<m<<endl;
    int64_t ans;
    if(n%3!=0 || n<0 || m%3!=0 || m<0){
        ans = 0;
    }
    else{
        n /=3,m /=3;
        ans = COM(m+n,n);
        //m+nCnを求めればいい
    }
    //cout<<"Power(m+n,n)="<<power(m+n,m,big)<<endl;
    cout<<ans<<endl;

}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    ll a,b,c,cnt=0; cin>>a>>b>>c;
    while(1){
        if(a%2==1 || b%2==1 || c%2==1) break;
        if(a==b && b==c && c==a){
            cnt=-1;
            break;
        }
        ll x=a,y=b,z=c;
        a = (y+z)/2;
        b = (z+x)/2;
        c = (x+y)/2;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3620
//
// Created by yamunaku on 2020/06/28.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int d;
vi c;
mti s;
vi sched;
vector<set<int>> last;
int score = 0;

unsigned long long xor128(){
    static unsigned long long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long long t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

int init_score(){
    int score = 0;
    rep(t, d){
        int x = sched[t];
        last[x].insert(t);
        score += s[t][x];
        rep(i, 26){
            score -= c[i] * (t - (*last[i].rbegin()));
        }
    }
    return score;
}

inline int sub(int d){
    return d * (d - 1) / 2;
}

int del_score(int day, int from, int to){
    int delta = s[day][to] - s[day][from];
    int l, r;
    auto itr = last[from].upper_bound(day);
    r = *itr;
    itr--;
    itr--;
    l = *itr;
    delta += c[from] * (sub(day - l) + sub(r - day) - sub(r - l));
    itr = last[to].upper_bound(day);
    r = *itr;
    itr--;
    l = *itr;
    delta += c[to] * (-sub(day - l) - sub(r - day) + sub(r - l));
    return delta;
}

void change(int day, int from, int to){
    score += del_score(day, from, to);
    last[from].erase(day);
    last[to].insert(day);
    sched[day] = to;
}

int main(){
    //CFS;
    cin >> d;
    c = vi(26);
    s = mti(d, vi(26));
    rep(i, 26) cin >> c[i];
    rep(i, d){
        rep(j, 26) cin >> s[i][j];
    }
    sched = vi(d);
    rep(i, d){
        int maid = 0;
        rep(j, 26){
            if(s[i][maid] < s[i][j]) maid = j;
        }
        sched[i] = maid;
    }
    last = vector<set<int>>(26);
    rep(i, 26) last[i].insert(-1);
    score = init_score();
    rep(i, 26) last[i].insert(d);
    rep(i, 100000){
        int day = xor128() % d;
        int to = xor128() % 26;
        int from = sched[day];
        int delta = del_score(day, from, to);
        if(delta > 0) change(day, from, to);
    }
    rep(i, d){
        cout << sched[i] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3716
import java.util.Scanner;

public class Main {

	static String[] alphabet = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q",
			"r", "s", "t", "u", "v", "w", "x", "y", "z" };

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] ary = new long[N];
		for (int i = 0; i < N; i++) {
			ary[i] = sc.nextLong();
		}
		long cstKisu = 0;
		long[] aryKisu = new long[N];
		System.arraycopy(ary, 0, aryKisu, 0, ary.length);
		long sumKisu = 0;
		for (int i = 0; i < aryKisu.length; i++) {
			sumKisu += aryKisu[i];
			if (i % 2 == 0) {
				if (sumKisu <= 0) {
					aryKisu[i] += 1 - sumKisu;
					cstKisu += 1 - sumKisu;
					sumKisu = 1;
				}
			} else {
				if (sumKisu >= 0) {
					aryKisu[i] -= sumKisu + 1;
					cstKisu += sumKisu + 1;
					sumKisu = -1;
				}
			}
		}

		long cstGusu = 0;
		long[] aryGusu = new long[N];
		System.arraycopy(ary, 0, aryGusu, 0, ary.length);
		long sumGusu = 0;
		for (int i = 0; i < aryGusu.length; i++) {
			sumGusu += aryGusu[i];
			if (i % 2 == 0) {
				if (sumGusu >= 0) {
					aryGusu[i] -= sumGusu + 1;
					cstGusu += sumGusu + 1;
					sumGusu = -1;
				}
			} else {
				if (sumGusu <= 0) {
					aryGusu[i] += 1 - sumGusu;
					cstGusu += 1 - sumGusu;
					sumGusu = 1;
				}
			}
		}
		System.out.println(Math.min(cstGusu, cstKisu));

	}

}

Measured memory_bytes: 51400
/**
*    author:  yuya1234
*    created: 25.06.2020 09:45:21
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n,l;
    cin>>n>>l;

    vector<string> s;
    string tmp;

    REP(i,n)
    {
        cin>>tmp;
        s.push_back(tmp);
    }

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

    REP(i,n)
    {
        cout<<s[i];
    }

    cout<<endl;

    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意

int main(){
  int f[10007];
  rep(i,10005)f[i]=0;
  
  int n,memo; cin>>n;
  
  for(int x=1;x<101;x++){
    for(int y=1;y<101;y++){
      for(int z=1;z<101;z++){
    
        memo=x*x+y*y+z*z+x*y+y*z+z*x;
        if(memo<10005)f[memo]++;
    
    
      }
    }
    
  }
  
  //string s; cin>>s;
  
  rep(i,n)cout<<f[i+1]<<endl;
}

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

cnt = 0

for i in range(0, N):
    for j in range(i+1, N)[::-1]:
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            cnt = cnt + 1

print(' '.join([str(item) for item in A]))
print(cnt)

Measured memory_bytes: 7724
def CountingSort(A):
    B = [0]*len(A)
    maxnumber = 0
    for n in range(len(A)):
        if maxnumber < A[n]:
            maxnumber = A[n]
    C = [0]*(maxnumber + 1)

    for j in range(len(A)):
        C[A[j]] += 1
    for r in range(1, maxnumber+1):
        C[r] = C[r] + C[r-1]

    for s in range(len(A))[::-1]:
        B[C[A[s]]-1] =A[s]
        C[A[s]] -= 1

    return B


if __name__ == '__main__':
    cnt = input()
    A = list(map(int,input().split()))
    Ans = list(map(str,CountingSort(A)))
    print(" ".join(Ans))

Measured memory_bytes: 245920
#include <cstdio>
#include <cstring>
int main()
{
  char s[100],c[2]={'C','F'};
  scanf("%s",s);
  int len=strlen(s),k=0;
  for(int i=0;i<len&&k<2;i++)
  if(s[i]==c[k]) k++;
  if(k==2)printf("Yes");
  else printf("No");
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
    int x, y;
    int area, perimeter;
    char buf[256];

    fgets(buf, 256, stdin);
    buf[255] = '\0';
    sscanf(buf, "%d %d", &x, &y);

    area = x * y;
    perimeter = (x << 1) + (y << 1);
    printf("%d %d\n", area, perimeter);
    return 0;
}



Measured memory_bytes: 2708
d = {}
for i in range(1, 1000):
    if i ** 5 - (i-1) ** 5 > 10 ** 9:
        break
    for j in range(i-1, -i-1, -1):
        if i ** 5 - j ** 5 > 10 ** 9:
            break
        d[i ** 5 - j ** 5] = (i, j)
print(*d[int(input())])

Measured memory_bytes: 9624
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

vector<int> to[200005];
vector<int> ans;

void dfs(int v,int p=-1){
    for(int u: to[v]){
        if(u==p)continue;
        ans[u]+=ans[v];
        dfs(u,v);
    }
}


int main(void){
    int n,q;
    cin >> n >> q;
    REP(i,n-1){
        int a,b;
        cin >> a >> b;
        --a;--b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    REP(i,q){
        int p,x;
        cin >> p >> x;
        --p;
        ans[p]+=x;
    }
    dfs(0);
    REP(i,n){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 24344
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    s = input()
    edge = collections.deque()
    for i in s:
        if i == "0":
            edge.append("0")
        elif i == "1":
            edge.append("1")
        elif len(edge) > 0:
            edge.pop()
    print("".join(edge))
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 10292
def ki(graph, qs)
  weight = Array.new(graph.size + 1) { 0 }
  qs.each do |q|
    weight[q[0]] += q[1]
  end

  # ans = []
  #
  # f = ->(node, parent_weight) {
  #   return if ans[node]
  #   ans[node] = weight[node] + parent_weight
  #   return if graph[node].nil?
  #   graph[node].each do |n|
  #     f.call(n, ans[node])
  #   end
  # }
  # f.call(1, 0)
  #
  # ans.join("\s")

  visited = {}
  queue = [1]
  while !queue.empty?
    node = queue.shift
    next if visited[node]
    visited[node] = true
    graph[node].each do |n|
      if !visited[n]
        weight[n] += weight[node]
        queue << n
      end
    end
  end

  weight.shift
  weight.join("\s")
end

n, q = gets.split.map(&:to_i)
graph = Hash.new{|h,k| h[k] = []}
(n - 1).times do
  a, b = gets.split.map(&:to_i)
  graph[a] << b
  graph[b] << a
end

qs = []
q.times do
  qs << gets.split.map(&:to_i)
end


puts ki(graph, qs)


Measured memory_bytes: 62072
import itertools
import math

n = int(input())
xy = []
for _ in range(n):
    xy.append(list(map(int, input().split())))

s = 0
for _p in itertools.permutations(xy, n):
    for i in range(0, n-1):
        s += math.sqrt((_p[i][0]-_p[i+1][0])**2 + (_p[i][1]-_p[i+1][1])**2)

print(s/math.factorial(n))


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

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

  while(1){
    c -= b;
    if(c<=0) {
        cout << "Yes" << endl;
        return 0;
    }
    a-=d;
    if(a<=0){
        cout << "No" << endl;
        return 0;
    }
  }
}

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

#define MAX 100000
#define WHITE -1

int n, m, q;
vector<int> G[MAX];
int col[MAX];

void dfs(int s, int c) {
	col[s] = c;
	for (int v = 0; v < G[s].size(); v++) {
		if (col[G[s][v]] == WHITE)
			dfs(G[s][v], c);
	}
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		col[i] = WHITE;
	}
	for (int i = 0; i < m; i++) {
		int s, t;
		cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s);
	}
	int id = 0;
	for (int i = 0; i < n; i++) {
		if (col[i] == WHITE) {
			dfs(i, ++id);
		}
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		int s, t;
		cin >> s >> t;
		cout << (col[s] == col[t] ? "yes" : "no") << endl;
	}
	return 0;
}



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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int sum=0;
    double execTime = c+0.5;
    while ( execTime > a)
    {
        sum+=b;
        execTime-=a;
    }
    cout << sum;        
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <cctype>
#define rep(x,y,z) for(long long x=y;x<z;++x)
#define dwn(x,y,z) for(long long x=y;x>z;--x)
using namespace std;

typedef long long ll;

int main() {
    ll n;
    cin >> n;
    vector<ll> h(n);
    for (auto& x: h) {
        cin >> x;
    }
    vector<ll> res(n);
    res[n - 1] = 0;
    for (ll i = n - 2; i >= 0; i--) {
        if (i + 2 < n) {
            res[i] = min(llabs(h[i] - h[i + 1]) + res[i + 1], llabs(h[i] - h[i + 2]) + res[i + 2]);
        } else {
            res[i] = llabs(h[i] - h[i + 1]) + res[i + 1];
        }
    }
    cout << res[0] << endl;
    return 0;
}


Measured memory_bytes: 1792
/*
// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculations
*/
/*
*/
#include <bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                   long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                   1000000007
#define eps                  0.000000000000001
#define endl                       '\n'
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int> ii;
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={1,-1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
vector<int> adj[100010],vis(100010,0),dis(100010,0),par(100010,0);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    string s;
    cin>>s;
    sort(all(s));
    if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2])
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}



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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,m;

int main()
{
	cin>>n>>m;
	if(n%2==1) for(int i=1,j=n;i<=m;i++,j--) cout<<i<<' '<<j<<endl;
	else
	{
		for(int i=1,j=n;i<=m;i++,j--)
		{
			if(i<=m/2&&j-i!=n/2||j-1-i==n/2) cout<<i<<' '<<j<<endl;
			else cout<<i<<' '<<j-1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3644
N, M = map(int, input().split())
Q = {i: 0 for i in range(1, 1 + N)}

correction = 0
penalty = 0

for _ in range(M):
    p, s = input().split()
    p = int(p)
    s = s == "AC"

    # already answered correctly
    if Q[p] > 0:
        continue

    if s:
        correction += 1
        penalty -= Q[p]
        Q[p] = 1
    else:
        Q[p] -= 1

print(correction, penalty)


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

int main() {
  int H1,M1,H2,M2,K,H,M,T;
  cin>>H1>>M1>>H2>>M2>>K;
  H = H2 - H1;
  M = M2 - M1;
  T = H*60 + M - K;
  cout<<T<<endl;
}


Measured memory_bytes: 3588
#include <iostream>

using namespace std;

int partition(int A[], int p, int r)
{
    int x = A[r];
    int i = p - 1;
    for (int j = 0; j < r; j++)
    {
        if (A[j] <= x)
        {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}

int main()
{
    int n;
    cin >> n;
    int A[n];
    for(int i = 0; i < n; i++)
        cin >> A[i];
    int q = partition(A, 0, n - 1);
    for(int i = 0; i < n; i++)
    {
        if (i == q)
        {
            cout << "[" << A[i] << "]";
        }
        else
            cout << A[i];

        if (i == n - 1)
            cout << endl;
        else
            cout << " ";
    }
}


Measured memory_bytes: 3384
def nCk(n, k):
    if k == 0:
        return 1
    elif k == 1:
        return n
    elif k == 2:
        return n * (n - 1) // 2
    else:
        return n * (n - 1) * (n - 2) // 6


def solve(N, K):
    if N < K:
        return 0

    if K == 0:
        return 1

    M = len(str(N))
    hd, tl = divmod(N, 10 ** (M - 1))

    res = nCk(M - 1, K) * (9 ** K)
    if hd == 0:
        return res

    res += solve(tl, K - 1)
    res += (hd - 1) * nCk(M - 1, K - 1) * (9 ** (K - 1))

    return res


N = int(input())
K = int(input())

print(solve(N, K))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		long a = scn.nextLong();
		long b = scn.nextLong();
		System.out.println(f(b) ^ f(a-1));
		scn.close();
	}
	static long f(long x) {
	    if (x % 4 == 0)return x;
	    else if (x % 4 == 1)return x^(x-1);
	    else if (x % 4 == 2)return x^(x-1)^(x-2);
	    else return 0;
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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() {
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin(),h.end());

  int ans = 1e9;
  rep(i,n-k+1){
    ans = min(ans,h[i+k-1]-h[i]);
  }
  cout << ans << endl;
}


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

vector<int> e[200001];
int c[200001];
long long ans[200001];

void dfs(int x, int pre, long long cur)
{
    cur += c[x];
    ans[x] = cur;
    for (int nex : e[x])
    {
        if (nex == pre)
            continue;
        dfs(nex, x, cur);
    }
}

int main()
{
    int n, q;
    scanf("%d%d", &n, &q);
    for (int i = 1; i < n; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        e[x].push_back(y);
        e[y].push_back(x);
    }
    while (q--)
    {
        int p, x;
        scanf("%d%d", &p, &x);
        c[p] += x;
    }
    dfs(1, 0, 0ll);
    for (int i = 1; i <= n; i++)
        printf("%lld ", ans[i]);
    return 0;
}


Measured memory_bytes: 24832
import java.util.Scanner;

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

        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        System.out.println(solve(N, A, B));

        sc.close();
    }

    static int solve(int N, int A, int B) {
        return Math.min(N * A, B);
    }
}

Measured memory_bytes: 35960
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned long;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

    int arr[4][3][10] = {};

    void Solve() {
        UL N; cin >> N;
        rep(i, N) {
            int a, b, c, d; cin >> a >> b >> c >> d; a--; b--; c--;
            arr[a][b][c] += d;
        }
        rep(a, 4) {
            if (a) cout << "####################" << endl;
            rep(b, 3) {
                rep(c, 10) {
                    cout << " " << arr[a][b][c];
                } cout << endl;
            }
        }
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}



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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s; cin>>s;
	for(int i=0;i<(1<<3);++i){
		int sum=s.front()-'0';
		for(int j=0;j<3;++j){
			int num=s.at(j+1)-'0';
			if(i&(1<<j))sum+=num;
			else sum-=num;
		}
		if(sum==7){
			cout<<s.front();
			for(int j=0;j<3;++j){
				if(i&(1<<j))cout<<'+';
				else cout<<'-';
				cout<<s.at(j+1);
			}
			cout<<"=7\n"s;
			return 0;
		}
	}
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll n;
  cin>>n;
  ll i=0;
  ll a=n,b=n;
  while(1){
    a=a/10;
    b=n%10;
    i++;
    if(a==0)break;
  }
  ll tem=1,ans=0;
  for(ll j=0;j<i-1;j++){
    if(j%2==0){
      ans+=9*tem;
    }
    tem*=10;
  }
  if(i%2==1){
    ans+=n-tem;
    ans++;
  }
  cout<<ans<<endl;
}

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

using namespace std;

struct spell{
    int AT;
    int MP;
};

int main(){
    int H, N;
    cin >> H >> N;
    vector<spell> spells(N);
    
    int A, B;
    int maxA;
    maxA = 0;
    for(int i=0;i<N;i++){
        cin >> A >> B;
        spells.at(i).AT = A;
        spells.at(i).MP = B;
        maxA = max( maxA, A);
    }

    int l = H + maxA + 1;
    constexpr int M = 100000000; 
    vector<int> dp( l, M);

    dp[0] = 0;
    int nh, nm; 

    for(int i=0;i<H;++i){

        // cout << "i = " << i << endl;
        // for(auto e : dp){
        //     cout << e << ", ";
        // }
        // cout << endl;
        
        if(dp[i] == M) continue;
        for(int j=0;j<N;++j){
            nh = i + spells.at(j).AT;
            nm = dp[i] + spells.at(j).MP;
            if( dp[nh] > nm ){
                dp[nh] = nm;
            }
        }
    }

    int ans;
    ans = M;
    for(int i=H;i<dp.size();++i){
        ans = min(ans, dp[i]);
    }
    
    cout << ans << endl;
    
    return 0;
}


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

int n;
pair<int, int> arr[10];

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> arr[i].first >> arr[i].second;
    }

    vector<int> vec;
    ll div = 1;
    for (int i = 1; i <= n; ++i) vec.push_back(i), div *= i;

    double res = 0;
    do {
        pair<int, int> last = arr[vec[0]];

        for (int i = 2; i <= n; ++i) {
            int curr = vec[i - 1];
            int d1 = (last.first - arr[curr].first);
            int d2 = (last.second - arr[curr].second);
            res += sqrt(d1 * d1 + d2 * d2);
            last = arr[curr];
        }

    } while( next_permutation(begin(vec), end(vec)) );

    cout << fixed << setprecision(10);
    cout << res / div << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
int x[100000],y[100000];
signed main(){
	int a,b;
	cin>>a>>b;
	if(b%a==0) cout<<b+a<<endl;
	else cout<<b-a<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    int n,a,b;
  	cin>>n>>a>>b;
  	int count=0;
  	for(int i=1;i<=n;i++){
      int test=i;
      int sum=0;
      while(test){
        int ama;
        ama=test%10;
        sum=sum+ama;
        test=test/10;
      }
      if(sum>=a&&sum<=b){
        count=count+i;
      }
  }
      cout<<count;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  char C[H*W];
  for(int i = 0; i < H*W; i++){
  	cin >> C[i];
  }
  for(int i = 0; i < H*W; i++){
  	cout << C[i];
    if( (i+1) % W == 0){
    	cout << endl;
      	for(int j = i + 1 - W; j < i + 1; j++){
        	cout << C[j];
        }
      	cout << endl;
    }
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static int n;
  public static int[] c;
  public static ArrayList[] edge;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    n = sc.nextInt();
    c = new int[n];
    edge = new ArrayList[n];
    for(int i = 0; i < n; i++) {
      edge[i] = new ArrayList<Integer>();
    }
    for(int i = 0; i < n - 1; i++) {
      int a = sc.nextInt() - 1;
      int b = sc.nextInt() - 1;
      edge[a].add(b);
      edge[b].add(a); 
    }
    dfs(0, -1);
    int p1 = 0;
    int p2 = 0;
    for(int i = 0; i < n; i++) {
      if(c[i] == 0) {
        p1++;
      } else {
        p2++;
      }
    }
    int[] ans = new int[n];
    int[] used = new int[n + 1];
    
    if(p1 <= (n / 3)) {
      int p = 1;
      for(int i = 0; i < n; i++) {
        if(c[i] == 0) {
          ans[i] = (3 * p);
          p++;
          used[ans[i]] = 1;
        }
      }
      ArrayList<Integer> list = new ArrayList<Integer>(); 
      for(int i = 1; i <= n; i++) {
        if(used[i] == 0) list.add(i);
      }
      int q = 0;
      for(int i = 0; i < n; i++) {
        if(c[i] == 1) {
          ans[i] = list.get(q);
          q++;
        }
      }
    } else if(p2 <= (n / 3)) {
      int p = 1;
      for(int i = 0; i < n; i++) {
        if(c[i] == 1) {
          ans[i] = (3 * p);
          p++;
          used[ans[i]] = 1;
        }
      }
      ArrayList<Integer> list = new ArrayList<Integer>(); 
      for(int i = 1; i <= n; i++) {
        if(used[i] == 0) list.add(i);
      }
      int q = 0;
      for(int i = 0; i < n; i++) {
        if(c[i] == 0) {
          ans[i] = list.get(q);
          q++;
        }
      }      
    } else {
      int p = 0;
      int q = 0;
      for(int i = 0; i < n; i++) {
        if(c[i] == 0) {
          if((3 * p + 1) <= n) {
            ans[i] = (3 * p + 1);
            p++;
          }
        } else {
        if(c[i] == 1) {
          if((3 * q + 2) <= n) {
            ans[i] = (3 * q + 2);
            q++;
          }          
        }
        }
      }
      int r = 1;
      for(int i = 0; i < n; i++) {
        if(ans[i] == 0) {
          ans[i] = (3 * r);
          r++;
        }
      }
    }
    for(int i = 0; i < n; i++) {
      System.out.println(ans[i]);
    }
  }

  public static void dfs(int v, int p) {
    for(int i = 0; i < edge[v].size(); i++) {
      int t = (int)(edge[v].get(i));
      if(t != p) {
        c[t] = 1 - c[v];
        dfs(t, v);
      }
    }    
  }
}

Measured memory_bytes: 166096
#include <iostream>

int main(void)
{
  int x, a, b;

  std::cin >> x >> a >> b;

  if (-a + b <= 0)
    std::cout << "delicious" << std::endl;
  else if (0 < -a + b && -a + b <= x)
    std::cout << "safe" << std::endl;
  else
    std::cout << "dangerous" << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d,e,s,f,t;
	cin>>a>>b>>c>>d>>e;

	s=a*e;
	
	f=e-c;
	if(f>0){
	t=b+(d*f);
	}
	else{t=b;}
	
	if(s>t){swap(s,t);}

	cout<<s<<endl;

	return 0;
}




Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {

     static Scanner scanner;

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

         int N=gi();
         String S=gs();

         int[] red=new int[N];
         int[] green=new int[N];
         int[] blue=new int[N];
         for(int i=0; i<S.length();i++) {
        	 char c=S.charAt(i);
        	 if(i!=0) {
        	     red[i]=red[i-1];
        	     green[i]=green[i-1];
        	     blue[i]=blue[i-1];
        	 }
        	 if(c=='R') {
        		 red[i]++;
        	 } else if(c=='G') {
        		 green[i]++;
        	 } else {
        		 blue[i]++;
        	 }
         }

         long ans=0;
         for (int i=0; i<N;i++) {
        	 char ci=S.charAt(i);
        	 for (int j=i+1; j<N;j++) {
            	 char cj=S.charAt(j);
            	 if(ci!=cj) {
            		 if((ci=='R' && cj=='G') || (ci=='G' && cj=='R')){
            			 ans+=blue[N-1]-blue[j];
            			 if(j+(j-i)<N && S.charAt(j+(j-i))=='B')ans--;
            		 } else if((ci=='B' && cj=='G') || (ci=='G' && cj=='B')){
            			 ans+=red[N-1]-red[j];
            			 if(j+(j-i)<N && S.charAt(j+(j-i))=='R')ans--;
            		 } else if((ci=='R' && cj=='B') || (ci=='B' && cj=='R')){
            			 ans+=green[N-1]-green[j];
            			 if(j+(j-i)<N && S.charAt(j+(j-i))=='G')ans--;
            		 }
            	 }
             }
         }

         System.out.println(ans);
     }

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

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


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

    int sum=0;
    for (int i=1;i<=k;i++)
        for (int j=1;j<=k;j++)
            for (int p=1;p<=k;p++)
            {
                sum+=__gcd(__gcd(i,j),p);
            }

    cout<<sum<<'\n';
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <cctype>
//小文字を大文字 c-0x20;


#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define vvll(z,a,b) vector<vector<ll>>z(a,vector<ll>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) c.begin(),c.end()
#define fix(k) fixed<<setprecision(k)
#define PI 3.141592653589793
using namespace std;


int hantei(int a,int b,int k){
    vi youso(100);
    int w=0;
    for(int j=1;j<=a;j++){
        if((a%j==0)&&(b%j==0)){
            youso.at(w)=j;
            




            w++;
        }
    }
    
    return youso.at(w-k);
   
}

int main(){
    int a,b,k;cin>>a>>b>>k;
    int x=hantei(a,b,k);
    cout<<x<<endl;
}


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

int main()
{
	char a[3];
	cin>>a;
	if(strlen(a)==2) cout<<a<<endl;
	else{
		for(int i=2;i>=0;i--)
		cout<<a[i];
	}
	
	
return 0;
}

Measured memory_bytes: 256
n= int(input())
a = list(map(int, input().split()))
q = int(input())
b = [list(map(int,input().split())) for i in range(q)]
num = [0]*(10**5+1)
for i in a:
  num[i] += 1
sum_a = sum(a)

for i in range(q):
  dif = b[i][1]-b[i][0]
  #print(dif)
  sum_a += dif*num[b[i][0]]
  num[b[i][1]] += num[b[i][0]]
  num[b[i][0]] = 0
  print(sum_a)

Measured memory_bytes: 32092
#include <stdio.h>

int main(void) {

	int a;
	int b;
	char op;
	
	while (1) {
		scanf("%d %c %d", &a, &op, &b);
		switch (op) {
		case '+':
			printf("%d\n", a + b);
			break;
		case '-':
			printf("%d\n", a - b);
			break;
		case '*':
			printf("%d\n", a * b);
			break;
		case '/':
			printf("%d\n", a / b);
			break;
		default:
			return 0;
		}
		
		
	}

	return 0;
}

Measured memory_bytes: 600
import sys
import copy
n = int(input())
dist = [list(map(int,input().split())) for _ in range(n)]
e = copy.deepcopy(dist)
for k in range(n):
    for i in range(n):
        for j in range(n):
            if dist[i][j]>dist[i][k] + dist[k][j]:
                print(-1)
                sys.exit()
            if i!=j and i!=k and j!=k and dist[i][j]==dist[i][k] + dist[k][j]:
                #print(i,j,k)
                e[i][j]=float("inf")

#[print(*dist[l]) for l in range(n)]
ans = 0
for i in range(n):
    for j in range(n):
        if e[i][j]!=float("inf"):
            ans += dist[i][j]
print(ans//2)



Measured memory_bytes: 77748
#include <stdio.h>

int main()
{
  char s[101];
  int i;
  i = 0;
  scanf("%s",&s);
  printf("%c",s[0]);
  while (s[i])
  {
    i++;
  }
  printf("%d",i-2);
  printf("%c",s[i-1]);
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int n = 100;
        /*
        long n = long.Parse(Console.ReadLine());
        long[] input = new long[5];
        for(int a = 0; a < 5; a++)
        {
            input[a]=long.Parse(Console.ReadLine());
        }
        */
        int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        input = input.Select(i => i).Distinct().ToArray();

        Console.WriteLine(input.Length);

        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法

        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();
        
    }
}

Measured memory_bytes: 11348
#include <cstdio>
#include <cstring>
typedef long long ll;
int m, g;
int a[7], b[7];
ll dp[8][1001];
int main() {
    while (scanf("%d",&m)) {
        if (!m) break;
        for (int i=0; i<m; i++) scanf("%d%d",&a[i],&b[i]);
        memset(dp, 0, sizeof(dp));
        dp[0][0]=1;
        for (int i=0; i<m; i++) {
            for (int k=0; k<=1000; k++) {
                for (int j=0; j<=b[i]; j++) {
                    if (k+a[i]*j>1000) continue;
                    dp[i+1][k+a[i]*j]+=dp[i][k];
                }
            }
        }
        scanf("%d",&g);
        for (int i=0; i<g; i++) {
            int n; scanf("%d",&n);
            printf("%lld\n",dp[m][n]);
        }
    }
}

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

using namespace std;

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

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

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

    k -= m;
    cout << k << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int H,W;
  cin >> H >> W;
  v(string) G(2*H,string(W,'.'));
  rep(i,H) {
    string s;
    cin >> s;
    rep(j,W) {
      rep(di,2) {
        G[2*i+di][j]=s[j];
      }
    }
  }
  rep(i,2*H) {
    cout << G[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long n,cnt[60];
    for(long long i = 0 ; i < 60 ; i += 1){
        cnt[i] = 0;
    }
    cin >> n;
    long long val1=0,val2=0,sum;
    for(long long i = 0 ; i < n ; i += 1){
        long long a;
        cin >> a;
        if(i == 0){
        	val1 = a;
        	continue;
        }else if(i == 1){
        	val2 = a;
        	continue;
        }
        long long tag=0;
        while(a){
            if(a % 2 == 1){
                cnt[tag] += 1;
            }
            a /= 2;
            tag += 1;
        }
    }

    // fact ---> a+b = a^b + 2*(a&b)
    // fact ---> a|b = a^b + a&b
    sum = val1+val2;
    long long val3 = 0;
    for(long long i = 0 ; i < 60 ; i += 1){
    	if(cnt[i] % 2 == 1){
    		val3 += (1ll<<i);
    	}
    }
    if(val3 > sum){
    	cout << -1 << endl;
    	return 0;
    }
    if((sum-val3)%2 == 1){
    	cout << -1 << endl;
    	return 0;
    }
    long long val4 = (sum-val3)/2;
    // this value --> ((a&b) & (a^b)) is always zero , we want to achieve (a^b) = 'some value', than that value must satisfy this fact
    if(val4 & val3){
    	cout << -1 << endl;
    	return 0;
    }
    long long ans = val4;
    for(long long i = 59 ; i >= 0 ; i -= 1){
    	// there are four cases (0, 0) (0, 1) (1, 0) (1, 1)
    	// (1, 1) case has already been taken care of as it was included in the initial answer (a & b). (0, 0) will not increase our answer
    	// so only two cases remain (0, 1) and (1, 0) for both of them 0&1 = 0 = 1&0 and they were not include in our initial answer, and we 
    	// need to maximise our value so we will always try to add (1 << i) to our number
    	if(ans + (1ll << i) <= val1 && (val3 & (1ll<<i))){
    		ans += (1ll<<i);
    	}
    }

    // ans -> how many stones will remain in first pile, so they cannot be more than initial because
    // we are not allowed to borrow stones from other pile, and it cannot be zero as well according to question.

    if(ans == 0 || ans > val1){
    	cout << -1 << endl;
    	return 0;
    }
    cout << val1-ans << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int main(){
    int A,B,T;
    cin>>A>>B>>T;
    cout<<(T/A)*B<<endl;
    return 0;
}

Measured memory_bytes: 764
#include <map>
#include <string>
#include <iostream>

using std::cin;
using std::map;
using std::endl;
using std::cout;
using std::string;

int main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) {
			break;
		}
		map<char,char> cvs; // map of conversion
		while (n--) {
			char a,b;
			cin >> a >> b;
			cvs[a] = b;
		}
		int m;
		cin >> m;
		string s = "";
		while (m--) {
			char c;
			cin >> c;
			if (cvs.find(c) != cvs.end()) {
				s.push_back(cvs[c]);
			} else {
				s.push_back(c);
			}
		}
		cout << s << endl;
	}
}

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

int n,q;
vector<int> A,m;

int main()
{
    int k, n;
    cin >> k >> n;
    vector<int> v(n);
    int mx = 0;
    for(int i = 0; i < n; ++i){
        cin >> v[i];
        if(i != 0) {
            mx = max(mx, v[i]-v[i-1]);
        } 
    }
    mx = max(mx, k-v[n-1]+v[0]);
    cout << k-mx << endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
struct UnionFind {
    vector<int> par, rank;

    UnionFind(int N) : par(N), rank(N) {
        rep(i, N) par[i] = i, rank[i] = 0;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (rank[rx] < rank[ry]) {
            par[rx] = ry;
        }
        else {
            par[ry] = rx;
            if (rank[rx] == rank[ry]) rank[rx]++;
        }
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);

    rep(i, M) cin >> a[i] >> b[i];

    int ans = 0;
    rep(i, M) {
        UnionFind tree(N);
        rep(j, M) {
            if (i == j) continue;
            tree.unite(a[j] - 1, b[j] - 1);
        }
        int root = tree.root(0);
        repd(i, 1, N) {
            if (root != tree.root(i)) {
                ans++;
                break;
            }
        }
    }

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

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll ,string> Tlls;
#define PI 3.141592

int main()
{

  double R;
  cin >> R;
  double a = PI;
  //小数点以下を指定したい場合　https://marycore.jp/prog/cpp/stream-format-float/
  cout << fixed;
  cout << setprecision(12) << 2 * R * a << endl;

  return 0;
}


Measured memory_bytes: 3784