akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func asInt(s string) []int {
	arr := strings.Split(s, " ")
	is := make([]int, 0, len(arr))
	for _, str := range arr {
		i, _ := strconv.Atoi(str)
		is = append(is, i)
	}
	return is
}

func main() {
	rdx := asInt(nextLine())
	r := rdx[0]
	d := rdx[1]
	x := rdx[2]

	ans := ""
	before := x
	for i := 0; i < 10; i++ {
		next := fn(r, d, before)
		ans += strconv.Itoa(next)
		ans += "\n"
		before = next
	}
	fmt.Printf("%s", ans)
}

func fn(r, d, x int) int {
	return r*x - d
}


Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>

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

using namespace std;


int main()
{
  int N,X;
  vector<int> L(N);
  cin >> N >> X;
  rep(i,N)cin >> L[i];

  int cnt = 1;
  int lo = 0;
  rep(j,N)
  {
    lo += L[j];
    if(lo <= X)cnt++;
    else break;
  }

  cout << cnt << endl;

  return 0;
}

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

#define INF 0x3f3f3f3f
#define MAXN 100010
#define endl "\n"
#define abs(a, b) ((a > b) ? a-b : b-a)

typedef long long int ll;

/* End */

int n;
ll a[MAXN];
ll pd[3];

int main() {
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];

	int m = 0;
	pd[(m-1)%3] = 0;
	for (int i = n-2; i >= 0; i--) {
		if (i < n-2) pd[m] = min(pd[(m+1)%3] + abs(a[i], a[i+1]),
              	            	         pd[(m+2)%3] + abs(a[i], a[i+2]));
		else pd[m] = abs(a[i], a[i+1]);
		m = (m == 0) ? 2 : m-1;
	}

	cout << pd[(m+1)%3] << endl;

	return 0;
}


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

int main()
{
	int n,b;
	cin>>n;
	if(n%1000!=0)
	b=n/1000+1;
	 else
	b=n/1000;
	
	b=b*1000;
	cout<<(b-n)<<endl;
	 
	return 0;
	
}

Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
S = input().rstrip()
T = input().rstrip()

def z_algorithm(s):
    N = len(s)
    ret = [0]*N
    ret[0] = N
    i,j = 1,0
    while i < N:
        while i+j < N and s[j] == s[i+j]:
            j += 1
        ret[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i+k < N and k + ret[k]<j:
            ret[i+k] = ret[k]
            k += 1
        i += k
        j -= k
    return ret

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self._size = [1] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self._size[ra] < self._size[rb]: ra,rb = rb,ra
        self._size[ra] += self._size[rb]
        self.parent[rb] = ra
        self.count += 1
    def size(self,a):
        return self._size[self.root(a)]

def solve():
    ls,lt = len(S),len(T)
    ns = 0--(lt+ls)//ls

    za = z_algorithm(T + '#' + S*ns)

    from fractions import gcd
    g = gcd(ls,lt)
    uf = UnionFind(ls)
    match = False
    for i in range(ls):
        if za[lt+1+i] == lt:
            match = True
            j = (i+lt) % ls
            if uf.is_same(i,j):
                if uf.size(i) == ls//g:
                    print(-1)
                    exit()
                continue
            uf.unite(i,j)
    if not match:
        print(0)
        exit()

    ans = 0
    for i in range(ls):
        ans = max(ans, uf.size(i)-1)
    print(ans)

solve()

Measured memory_bytes: 119424
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
using namespace std;

#define int long long

signed main() {
    int n; cin >> n;
    string s; cin >> s;
    int x = 0, ans = 0;

    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'I') {
            x++;
            ans = max(ans, x);
        } else {
            x--;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const N = readInt();
      int ans;
      foreach (x; 1 .. N) {
        if (x < N - x) {
          ++ans;
        }
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

def gcd(x, y):
    if x < y:
        x, y = y, x
    while True:
        if x % y == 0:
            return y
        x, y = y, x%y

x = b - a + 1
cx = b // c - (a-1) // c
dx = b // d - (a-1) // d
cdx = b // (c*d // gcd(c, d)) - (a-1) // (c*d // gcd(c, d))

print(x - cx - dx + cdx)



Measured memory_bytes: 9116
N, Y = map(int, input().split())

loop_break = False
for M in range(2002):
    total = 10000 * M
    if total > Y:
        print(-1, -1, -1)
        break
    for G in range(N - M + 1):
        S = N - M - G
        total += 5000 * G + 1000 * S
        if total == Y:
            print(M, G, S)
            loop_break = True
            break
        else:
            total = 10000 * M
    if loop_break:
        break

Measured memory_bytes: 9196
import sys

sys.setrecursionlimit(int(2E5))

SHEEP = True
WOLF = False


def print_tree(tree):
    print(''.join(['S' if e else 'W' for e in tree]))


def calc_next_animal(tree, cur_pos):
    if answer[cur_pos]:
        if tree[cur_pos] == SHEEP:
            return tree[cur_pos - 1]
        else:
            return not tree[cur_pos - 1]
    else:
        if tree[cur_pos] == SHEEP:
            return not tree[cur_pos - 1]
        else:
            return tree[cur_pos - 1]


def calc_prev_animal(tree, cur_pos):
    if answer[cur_pos]:
        if tree[cur_pos] == SHEEP:
            return tree[cur_pos + 1]
        else:
            return not tree[cur_pos + 1]
    else:
        if tree[cur_pos] == SHEEP:
            return not tree[cur_pos + 1]
        else:
            return tree[cur_pos + 1]


def wfs(tree, cur_pos, N):
    tree[cur_pos + 1] = calc_next_animal(tree, cur_pos)
    cur_pos += 1
    if cur_pos == N - 1:
        return tree[0] == calc_next_animal(tree, cur_pos) and tree[cur_pos] == calc_prev_animal(tree, 0)
    else:
        return wfs(tree, cur_pos, N)


if __name__ == '__main__':
    N = int(input())
    answer = [True if i == 'o' else False for i in input().rstrip()]
    aa = [[WOLF, WOLF]
        , [WOLF, SHEEP]
        , [SHEEP, SHEEP]
        , [SHEEP, WOLF]]
    super_list = [0] * int(2E5)
    for a in aa:
        super_list[:2] = a
        if wfs(super_list, 1, N):
            print_tree(super_list[:N])
            break
    else:
        print(-1)

Measured memory_bytes: 91396
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector <int> g[100005],used,dp;
void DFS(int v){
    used[v]=1;
    for(int k=0;k<g[v].size();k++){
       int to=g[v][k];
       if(used[to]==0)
            DFS(to);
            dp[v]=max(dp[v],dp[to]+1);
    }
}
int main(){
cin>>n>>m;
for(int k=1;k<=m;k++){
   int a,b;
   cin>>a>>b;
   g[a].push_back(b);
}
dp.resize(n+1,0);
used.resize(n+1,0);
int ans=0;
for(int k=1;k<=n;k++){
   if(used[k]==0)
        DFS(k);
}
for(int k=1;k<=n;k++)
    ans=max(ans,dp[k]);
cout<<ans;
return 0;
}


Measured memory_bytes: 8576
A,B,C=map(int, input().split())
x=0
y=0
if A==5:
    x+=1
if B==5:
    x+=1
if C==5:
    x+=1
if A==7:
    y+=1
if B==7:
    y+=1
if C==7:
    y+=1
if x==2 and y==1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
long long k,a,b;
long long p;
long long maxv(long long x,long long y){
	if (x>y) return x;else return y;
}
int main(){
	cin>>k>>a>>b;
	if (a<b){
		long long l=a-1;
		if (l>=k) cout<<1+k<<endl;else {
			long long m=k;
			k-=l;
			if (k%2==0) p=(b-a)*(k/2-1)+b;else p=(b-a)*(k/2-1)+b+1;
			cout<<maxv(p,1+m)<<endl;
		}
	}else {
		cout<<1+k<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int alice = 0;
  rep(i, n){
    if(i % 2 == 0) alice += a[i];
    else alice -= a[i];
  }
  cout << alice << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

using namespace std;

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int cntw[3*100000+1];
  int cnte[3*100000+1];
  int w = 0;
  int e = 0;
  for(int i=0;i<n;i++){
    if(s[i] == 'W'){
      w++;
    } else {
      e++;
    }
    cntw[i] = w;
    cnte[i] = e;
  }

  /*for(int i=0;i<n;i++){
    cout<<cntw[i]<<" ";
  }cout<<endl;
  for(int i=0;i<n;i++){
    cout<<cnte[i]<<" ";
  }cout<<endl;*/

  int mi = 3*100000+1;
  for(int i=0;i<n;i++){
    int tmp = 3*100000+1;
    tmp = cntw[i-1] + cnte[n-1] - cnte[i];
    mi = min(tmp,mi);
  }
  cout<<mi<<endl;
  return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;
struct edge { ll to, cost; };

const int MAX_V =300000;
const ll INF = 1LL<<60;

int V;
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(ll s) {
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        rep(i,G[v].size()) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

ll MOD = 1e9 + 7;

int main() {
    int N, M, u, v;
    cin >> N >> M;
    vector<vector<int>> edge(N * 3, vector<int>(0));
    rep(i, M) {
        cin >> u >> v;
        u--;
        v--;
        G[u].push_back({v + N, 1});
        G[u + N].push_back({v + N * 2, 1});
        G[u + N * 2].push_back({v, 1});
    }
    V = N * 3;
    int S, T;
    cin >> S >> T;
    S--;
    T--;
    dijkstra(S);
    if (d[T] == INF) cout << -1 << endl;
    else cout << d[T] / 3 << endl;
}

Measured memory_bytes: 25984
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 2e5 + 10;

string s;

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

	stack<char> q;
	reverse(s.begin(), s.end());

	for(auto x : s) q.push(x);

	ll ans = 0;
	ll cua = 0;
	while(q.size() >= 2){
		char fi = q.top(); q.pop();
		char se = q.top(); q.pop();
		if(fi == 'B' && se == 'C'){
			ans += cua;
		} else if(fi == 'A'){
			cua++;
			q.push(se);
		} else {
			cua = 0;
			q.push(se);
		}
	}
	
	cout << ans << endl;
}


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

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

    int n, k, ans = 0;
    cin >> n >> k;
    while (n != 0) {
        n /= k;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/**
 *    author:  [itmo] enot110
 *    created: 26.08.2017 15:00:35       
**/
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),a.end()
#define pw(x) (1LL<<(x))

using namespace std;

typedef long long ll;
typedef double dbl;
typedef vector<int> vi;
typedef pair<int, int> pi;

const int inf = 1.01e9;
const dbl eps = 1e-9;

/* --- main part --- */



int main()
{
    #ifdef HOME
        assert(freopen("1.in", "r", stdin));
        assert(freopen("1.out", "w", stdout));
    #endif
    ll q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;    
    h = min(h, q * 2);
    s = min(s, h * 2);
    d = min(d, s * 2);
    ll res = n / 2 * d + (n % 2) * s;
    cout << res;
    #ifdef HOME
        eprintf("time = %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
    return 0;
}


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

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

    while(true){
        int m, f, r;
        std::cin >> m >> f >> r;
        if(m==-1 && f==-1 && r==-1) break;
        char rank;
        if(m==-1 || f==-1) rank = 'F';
        else if(m+f>=80)   rank = 'A';
        else if(m+f>=65)   rank = 'B';
        else if(m+f>=50)   rank = 'C';
        else if(m+f>=30){
            if(r>=50)      rank = 'C';
            else           rank = 'D';
        }
        else               rank = 'F';
        std::cout << rank << "\n";
    }
    return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int c[n];
	for (auto &i : c) i = ri();
	int a[n][26];
	for (auto &i : a) for (auto &j : i) j = ri();
	
	for (int i = 0; i < n; i++) {
		printf("%d\n", (int) (std::max_element(a[i], a[i] + 26) - a[i] + 1));
	}
	
	return 0;
}


Measured memory_bytes: 3860
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

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

    vector<ll> dp(n,INT_MAX);
    dp[n-1] = 0;
    dp[n-2] = abs(h[n-2]-h[n-1]);
    
    for(int i = n-3; i >= 0; i--)
    {
        for(int j = 1; j <= k; j++)
        {
            if(i+j < n)
            {
                dp[i] = min(dp[i],dp[i+j]+abs(h[i]-h[i+j]));
            }
        }
    }
    
    cout << dp[0] << '\n';
    
    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(void)
{
    int x, a, b, c, d ;
    while (1) {
        scanf("%d%d", & a, & b) ;
        if (a == 0 && b == 0 || !(c = a + b)) {
            break ;
        }
        d = 0 ;
        for (x = 1 ; x < 5 ; x ++) {
            scanf("%d%d", & a, & b) ;
            if (a + b > c) {
                c = a + b;
                d = x ;
            }
        }
        printf("%c %d\n", 'A' + d, c) ;
    }
    return 0 ;
}



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

using namespace std;

int main() {
    int n;
    string s;

    cin >> n >> s;

    int ans = 0;
    for(int i = 0; i < n-2; i++) {
        if (s[i]=='A' & s[i+1]=='B' & s[i+2]=='C') {
            ans ++;
        } 
    }

    cout << ans << endl;
    

    return 0;
}

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

using namespace std;

int main()
{
    char c;
    cin >> c;

    bool vow = false;
    switch (c) {
        case 'a' :
        case 'e' : 
        case 'i' :
        case 'o' :
        case 'u' : vow = true; break;
        default : break;
    }

    cout << (vow ? "vowel" : "consonant") << endl;

    return 0;
}


Measured memory_bytes: 256
//23
#include<iostream>
#include<complex>

using namespace std;

int main(){
  for(;;){
    complex<double> p[4];
    for(int i=0;i<4;i++){
      double x,y;
      if(!(cin>>x>>y))return 0;
      p[i]=complex<double>(x,y);
    }
    int s=0;
    for(int i=0;i<3;i++){
      complex<double> e=p[(i+1)%3]-p[i],c=p[3]-p[i];
      s|=(e.real()*c.imag()-e.imag()*c.real()>0)<<i;
    }
    cout<<((s==0||s==7)?"YES":"NO")<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
temp = int(input())
head = temp//100
tail = temp%100

def judge(x):
  ans = ""
  if (x>12)or(x==0):
    ans="YY"
  else:
    ans="MM"
  return ans

h = judge(head)
t = judge(tail)

if h!=t:
  print(h+t)
elif h=="MM":
  print("AMBIGUOUS")
else:
  print("NA")


Measured memory_bytes: 3060
#include <cstdio>

int n;
int a,b;
int A,B;

int main()
{
  scanf("%d", &n);

  if(!n)return 0;
  
  A=B=0;

  for(int i=0;i<n;i++){
    scanf("%d%d",&a,&b);
    if (a>b) {
      A+=a+b;
    } else if (a<b) {
      B+=a+b;
    } else {
      A+=a;
      B+=b;
    }
  }

  printf("%d %d\n", A,B);

  main();
}

Measured memory_bytes: 0
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)


using namespace std;


template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};
ll N=1e5+5;



int main(){
    IOS;
    make2(ll,n,k);
    makevec(ll,a,n);
    cout<<1+(n-2)/(k-1)<<endl;



    return 0;
}


Measured memory_bytes: 3928
#include<iostream>
#include<string.h>
using namespace std;

int main(void)
{
  long double ans=0;
  int a, l[101];
  cin >> a;
  for(int i=0; i<a; i++)
    cin >> l[i];
  for(int i=0; i<a; i++)
    ans += 1.0/l[i];
  ans = 1.0/ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
/*
int main() {
	int n, m;
	cin >> n >> m;
	if (n <= 8 && m <= 8) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
}
*/

int main() {
	int n, m;
	cin >> m >> n;
	if (n == 100) {
		n++;
	}
	while (m > 0) {
		n *= 100;
		m--;
	}
	cout << n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,w; cin>>n>>w;
    vector<P> load;
    for(int i=0; i<n; i++){
        int v,w; cin>>v>>w;
        load.emplace_back(P(v,w));
    }
    vector<Int> ans(w+1,0);
    for(int i=1; i<=w; i++){
        for(int j=0; j<n; j++){
            if(i-load[j].second>=0) ans[i]=max(ans[i],ans[i-load[j].second]+load[j].first);
        }
    }
    cout<<ans[w]<<endl;
    return 0;
}


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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec)
    is >> x;
  return is;
}

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;

  string s;
  cin >> s;

  int zero = 0;
  int one = 0;

  REP(i, s.size()) {
    if (s[i] == '0')
      zero++;
    else
      one++;
  }

  cout << min(zero, one) * 2 << endl;

  return 0;
}


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

typedef long long int ll;

int main(){
	int x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	
	vector<int> p(a),q(b),r(c);
	
	for(int i=0;i<a;++i){
		cin >> p[i];
	}
	for(int i=0;i<b;++i){
		cin >> q[i];
	}
	for(int i=0;i<c;++i){
		cin >> r[i];
	}
	sort(p.begin(),p.end(),greater<int>());
	sort(q.begin(),q.end(),greater<int>());
	sort(r.begin(),r.end(),greater<int>());
	
	vector<int> sol;
	for(int i=0;i<min(a,x);++i){
		sol.push_back(p[i]);
	}
	for(int i=0;i<min(b,y);++i){
		sol.push_back(q[i]);
	}
	for(int i=0;i<c;++i){
		sol.push_back(r[i]);
	}
	
	
	
	unsigned long long int res = 0;
	sort(sol.begin(),sol.end(),greater<int>());
	for(int i=0;i<x+y;++i){
		res += sol[i];
	}
	cout << res <<endl;
	
	return 0;
}


Measured memory_bytes: 6144
//     . .. ... ..... be naame khodaa ..... .... ... .. .     \\

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

typedef long long ll;
typedef long double ld;

inline int in(){int x, y; y = scanf("%d", &x); return x;}

const int N = 230032, MOD = 1e9 + 7;

int c[N];
ll dp[N], pf[N];

int main() {
	int n = in();
	for(int i = 0; i < n; i++) {
		c[i] = in();
		if(i == 0) {
			dp[i] = 1;
			pf[c[i]] = 1;
			continue;
		}
		if(c[i] == c[i - 1]) {
			dp[i] = dp[i - 1];
			continue;
		}
		dp[i] = (dp[i - 1] + pf[c[i]])%MOD;
		pf[c[i]] = dp[i];
	}
	cout << dp[n - 1] << endl;
}



Measured memory_bytes: 4352
#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>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

bool bingo[3][3];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[3][3];
    rep(i,3)rep(j,3){
    	cin >> a[i][j];
    }
    int n;
    cin >> n;
    rep(i,n){
    	int b;
    	cin >> b;
    	rep(j,3)rep(k,3){
    		if(a[j][k] == b) bingo[j][k] = true;
    	}
    }
    string ans = "No";
    if(bingo[0][0] && bingo[0][1] && bingo[0][2]) 
    	ans = "Yes";
    if(bingo[1][0] && bingo[1][1] && bingo[1][2]) 
    	ans = "Yes";
    if(bingo[2][0] && bingo[2][1] && bingo[2][2]) 
    	ans = "Yes";
    if(bingo[0][0] && bingo[1][0] && bingo[2][0]) 
    	ans = "Yes";
    if(bingo[0][1] && bingo[1][1] && bingo[2][1]) 
    	ans = "Yes";
    if(bingo[0][2] && bingo[1][2] && bingo[2][2]) 
    	ans = "Yes";
    if(bingo[0][0] && bingo[1][1] && bingo[2][2]) 
    	ans = "Yes";
    if(bingo[0][2] && bingo[1][1] && bingo[2][0]) 
    	ans = "Yes";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int temp,i,j,n,costA,costB,calA;
	int *p;
	scanf("%d",&n);
	
	p = (int)malloc(sizeof(int)*n);
	
	scanf("%d %d", &costA, &costB);
	scanf("%d", &calA);


	for(i = 0; i < n; i++){
		scanf("%d",&p[i]);
	}


	for(i = 0; i < n-1; i++){
		for(j = n - 1; j > i; j--){
			if(p[j-1] < p[j]){
				temp = p[j];
				p[j] = p[j-1];
				p[j-1] = temp;
			}
		}
	}


	temp = calA;
	for(i = 0; i < n; i++){
		if( temp / ( i * costB + costA) > (temp + p[i]) / ( ( i + 1 ) * costB + costA ) )
			break;
		temp += p[i];
	}
	printf("%d\n", temp /( i * costB + costA));

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
	int n;
	scanf("%d", &n);
	int ans = 0;
	vector<int> vec(n);
	rep(i, n) scanf("%d", &vec[i]);
	rep(i, n) {
		for(int j = i + 1; j < n; j++)
		ans += vec[i] * vec[j];
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3736
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

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

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

    int ans = INF;
    for(int i = 1; i < n; i++){
        int x = i;
        int m = n - i;

        int tmp = 0;
        while(x > 0){
            tmp += x % 10;
            x /= 10;
        }

        while(m > 0){
            tmp += m % 10;
            m /= 10;
        }
        if(tmp < ans){
            ans = tmp;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
  
static const int MAX = 200005;
  
int main(){
    int n;
    cin >> n;
  
    int R[MAX];
    for (int idx = 0; idx < n; idx++){
        cin >> R[idx];
    }
  
    long long res = (long long)R[1] - R[0];
    int preMin = R[0];
    for (int idx = 1; idx < n; idx++){
        long long currRes = (long long)R[idx] - preMin;
        if (currRes > res){
            res = currRes;
        }
        preMin = min(R[idx], preMin);
    }
    cout << res << endl;
  
    return 0;
}

Measured memory_bytes: 3860
import copy

def is_stable(ax,bx):
    num=[]
    for ix in ax:
        if ix[1] not in num:
            num.append(ix[1])
    for ix in num:
        cx=[]
        for jx in ax:
            if jx[1]==ix:
                cx.append(jx)
        dx=[]
        for jx in bx:
            if jx[1]==ix:
                dx.append(jx)
        if cx!=dx:
            return "Not stable"
    else:
        return "Stable"

def array_print(ar):
    s=""
    for i in range(len(ar)):
        s+=(ar[i][0]+str(ar[i][1]))
        if i!=n-1:
            s+=" "
    return s

n=int(input())
a=[[i[0],int(i[1])]for i in input().split()]
b1=copy.deepcopy(a)
b2=copy.deepcopy(a)

#バブルソート
f=1
while f:
    f=0
    for i in range(n-1):
        if b1[n-i-1][1]<b1[n-i-2][1]:
            b1[n-i-1],b1[n-i-2]=b1[n-i-2],b1[n-i-1]
            f=1
print(array_print(b1))
print(is_stable(a,b1))

#選択ソート
for i in range(n):
    min=i
    for j in range(i+1,n):
        if b2[min][1]>b2[j][1]:
            min=j
    b2[min],b2[i]=b2[i],b2[min]
print(array_print(b2))
print(is_stable(a,b2))



Measured memory_bytes: 6348
from collections import deque
N,M = map(int,input().split())
G = [[] for i in range(N+1)]
for i in range(M):
  a,b = map(int,input().split())
  G[a].append(b)
  G[b].append(a)

ans = "Yes"
ansl = [0 for i in range(N+1)]
l = deque([1])
seen = [False for i in range(N+1)]
seen[1] = True
while len(l)>0:
  v = l.popleft()
  for i in G[v]:
    if seen[i] == False:
      seen[i] = True
      ansl[i] = v
      l.append(i)
###
if ans == "No":
  print(ans)
else:
  print(ans)
  for i in range(2,N+1):
    print(ansl[i])      

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

int N, h[100005], DP[3];

int main()
{
    scanf("%d", &N);
    for(int i = 0; i < N; i++) {
        scanf("%d", &h[i]);
    }

    DP[0] = 0;
    DP[1] = abs(h[0]-h[1]);
    DP[2] = 1<<30;

    if(N > 2) {
        for(int i = 2; i < N; i++) {
            DP[2] = min(DP[0] + abs(h[i-2] - h[i]), DP[1] + abs(h[i-1] - h[i]));
            DP[0] = DP[1];
            DP[1] = DP[2];
        }
        printf("%d\n", DP[2]);
    } else {
        printf("%d\n", DP[1]);
    }

    return 0;
}


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

vector<int> to[100010];
int kyori[2][100010]={};

void dfs(int i,int par,int j){
    for(int x:to[i]){
        if(x!=par){
            kyori[j][x]=kyori[j][i]+1;
            dfs(x,i,j);
        }
    }
    return;
}

int main(void){
    int n;
    cin>>n;
    int a,b;
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    dfs(1,0,0);
    dfs(n,0,1);
    int k0=0,k1=0;
    for(int i=1;i<=n;i++){
        if(kyori[0][i]<=kyori[1][i]){
            k0++;
        }
        else k1++;
    }
    if(k0>k1) cout<<"Fennec"<<endl;
    else cout<<"Snuke"<<endl;
}

Measured memory_bytes: 14336
#include <cstdio>
#include <cstring>
using namespace std;

const int MAXN = 100005;

int N, K;
char s[MAXN];

int main() {
	scanf("%s%d", s, &K);
	N = strlen(s);
	
	for (int i = 0; i < N; i++) {
		int go = ('z' - s[i] + 1) % 26;
		if (go <= K) {
			s[i] = 'a';
			K -= go;
		}
	}
	
	s[N - 1] = (s[N - 1] - 'a' + K % 26) % 26 + 'a';
	
	s[N] = '\0';
	puts(s);

	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
 
int main() {
    int N,res=0;
    bool f=true;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    while(f){
        for(int i = 0; i < N; i++)
        {
            if ( A[i]%2==0 ){
                f = true;
            }
            else{
                f=false;
                break;
            }
        }
        if(f){
            for(int i = 0; i < N; i++)
            {
                A[i] = A[i] / 2;
            }
            res++;
        }
    }
    
    cout << res << endl;

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    static ArrayList<Integer>[] g;
    static boolean[] vis;
    static int V, N, ans;

    static void dfs(int u) {
	vis[u] = true;
	N++;
	for (int v : g[u])
	    if (!vis[v])
		dfs(v);
	if (N == V)
	    ans++;
	vis[u] = false;
	N--;
    }

    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	V = sc.nextInt();
	int m = sc.nextInt();
	g = new ArrayList[V];
	for (int i = 0; i < V; i++)
	    g[i] = new ArrayList<>();
	for (int i = 0; i < m; i++) {
	    int u = sc.nextInt() - 1, v = sc.nextInt() - 1;
	    g[u].add(v);
	    g[v].add(u);
	}
	vis = new boolean[V];
	dfs(0);
	System.out.println(ans);
    }

}


Measured memory_bytes: 22996
#include <iostream>
    #include <string>
    #include <math.h>
    #include<algorithm>
    using namespace std;
     
    int main(){
      int K;
      cin >> K;
      if(K%2==0){
       cout << (K/2)*(K/2) << endl; 
      }
      else{
       cout << (K/2+1)*(K/2) << endl; 
      }
      return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,d,x,y,t,mx,v[2005][2005],s[2][2005][2005];
int S(int a1,int b1,int a2,int b2,int t){return s[t][a2][b2]-s[t][a1-1][b2]-s[t][a2][b1-1]+s[t][a1-1][b1-1];}
int chk(int x)
{
	int r=x%d;
	for(int i=1;i<=d;i++) for(int j=1;j<=d;j++)
	{
		int a1=i,b1=j,a2=a1+r,b2=b1+r,x3=a1+d-1,y3=b1+d-1;
		if(!S(a1,b2+1,x3,y3,1)&&!S(a2+1,b1,x3,y3,1)&&!S(a2+1,b2+1,x3,y3,0)) return 1;
	}
	return 0;
}
int main()
{
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++) scanf("%d%d",&x,&y),v[x%d+1][y%d+1]++;
	for(int i=1;i<=d;i++) for(int j=1;j<=d;j++) v[i+d][j]=v[i][j+d]=v[i+d][j+d]=v[i][j],mx=max(mx,v[i][j]);
	for(t=0;(t+1)*(t+1)<mx;t++);int l[3]={t*t+1,t*t+t+1,(int)1e9};
	for(int i=1;i<=d*2;i++) for(int j=1;j<=d*2;j++) for(int k=0;k<2;k++)
		s[k][i][j]=(l[k]<=v[i][j])+s[k][i-1][j]+s[k][i][j-1]-s[k][i-1][j-1];
	int L=t*d,R=t*d+d,ans=R,mid;
	for(mid=(L+R)>>1;L<=R;mid=(L+R)>>1) if(chk(mid)) R=mid-1,ans=mid;else L=mid+1;
	printf("%d\n",ans);
}

Measured memory_bytes: 47360
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
     
     
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] in = sc.next().toCharArray();
		int count = 0;
		for(int i = 0; i < in.length/2; i++) {
			char a = in[i];
			char b = in[in.length - i - 1];
			if(a == '(' && b == ')') continue;
			if(a == ')' && b == '(') continue;
			if(a == '(' || a == ')' || b == '(' || b == ')') count++;
			else if(a != b) count++;
		}
		char a = in[in.length/2];
		if(in.length % 2 == 1 && a != 'i' && a != 'w') count++; 
		System.out.println(count);
	}
}

Measured memory_bytes: 26244
n, k = (int(x) for x in input().split())
ab = []
for _ in range(n):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])
ans= 0
ab = sorted(ab, key=lambda x: x[0])

for i,j in ab:
    ans+=j
    if k<=ans:
        print(i)
        break

Measured memory_bytes: 64984
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;



int main() {
	string a;
	cin >> a;

	vector<string> s{ "dream", "dreamer", "erase", "eraser" };

	reverse(a.begin(), a.end());
	for (int i = 0; i < 4; i++) {
		reverse(s.at(i).begin(), s.at(i).end());
	}

	string n;
	bool b = true;

	for (int i = 0; i < a.size();) {
		bool c = false;
		for (int j = 0; j < 4; j++) {
			n = s.at(j);
			if (a.substr(i, n.size()) == n) {
				i += n.size();
				c = true;
			}
		}
		if (!c) {
			b = false;
			break;
		}
	}

	if (b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 3752
from collections import defaultdict

N = int(input())
abList = [list(map(int, input().split())) for _ in range(N-1)]

# 木構造の関係リスト作成
treeDict = defaultdict(list)
for a, b in abList:
    treeDict[a].append(b)
    treeDict[b].append(a)

# コストの辞書と疑似キューを作成
costDict = defaultdict(int)
treeQ = set()

# 葉(端)のコストを1にし、隣接ノードをキューに格納
for node in treeDict:
    if len(treeDict[node]) == 1:
        costDict[node] = 1
        treeQ.add(treeDict[node][0])

# 1つを除く隣接ノードにコストが設定されている(!= 0)場合、
# 隣接ノードの最大コスト + 1 でコストを設定し、コスト未設定のノードをキューに格納。
# 上記をキューに値が入らなくなるまで繰り返す。
node = 1
while(treeQ):
    tQ = set()
    costList = []
    for node in treeQ:
        if costDict[node] != 0: break
        decidedFlg = True
        cost = -1
        qNode = -1
        for nextNode in treeDict[node]:
            nextCost = costDict[nextNode]
            if nextCost == 0:
                # 隣接ノードがコスト未設定ならキューに格納
                # 隣接ノードが2つコスト未設定ならbreak
                if not decidedFlg:
                    cost = -1
                    qNode = -1
                    break
                decidedFlg = False
                qNode = nextNode
            else:
                # コストが設定されていれば大きいコストで更新
                cost = max(cost, nextCost + 1)

        if cost != -1:
            costList.append((node, cost))
        if qNode != -1:
            tQ.add(qNode)

    for cost in costList:
        costDict[cost[0]] = cost[1]
    treeQ = tQ


# コストが設定されていないノードを頂点として直径を図る
firstLen, secondLen = 0, 0
for nextNode in treeDict[node]:
    cost = costDict[nextNode]
    if cost > firstLen:
        secondLen = firstLen
        firstLen = cost
    elif cost > secondLen:
        secondLen = cost

diameter = firstLen + secondLen + 1
ans = "First" if diameter % 3 != 2 else "Second"
print(ans)



Measured memory_bytes: 129792
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
double dist(ll x1, ll y1, ll x2, ll y2)
{
	return sqrt((1.0*x1-x2)*(1.0*x1-x2)+(1.0*y1-y2)*(1.0*y1-y2));
}
void solve()
{
    ll n;
    cin>>n;
    double ans=0;
    ll factn=1, factn_1=1;
    vector<pl> coo(n);
    forr(i, n)
    	cin>>coo[i].first>>coo[i].second;
    forr1(i, n)
    {
    	if(i!=n)
    		factn_1*=i;
    	factn*=i;
    }
    forr(i, n)
    {
    	for(ll j=i+1; j<n; j++)
    	{
    		ans+=dist(coo[i].first, coo[i].second, coo[j].first, coo[j].second);
    	}
    }
	std::cout<<setprecision(15)<<(2*factn_1*ans/factn)<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3716
def m():
    MOD = 998244353
    N = int(input())
    D = [0] + list(map(int, input().split()))
    if D[1] != 0:
        return 0
    tree = {1:1}
    for i in range(2, N + 1):
        if D[i] == 0: return 0
        tree[D[i] + 1] = tree[D[i] + 1] + 1 if tree.get(D[i] + 1, False) else 1

    height = len(tree.keys())+1
    cnt = 1
    for i in range(2, height):
        if not tree.get(i, 0):
            return 0
        cnt = cnt * pow(tree[i-1], tree[i]) % MOD
    return cnt


print(m())


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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

const ll L = 55;

// vector <string> s(L);

ll ccnt[1005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll n;
    cin >> n;

    for(ll i=0; i<n; i++)
    {
        string s;
        cin >> s;

        ll tcnt[1005];

        for(ll j=97; j<123; j++)
        {
            tcnt[j] = 0;
        }

        for(ll j=0; j<sz(s); j++)
        {
            tcnt[(ll)s[j]]++;
        }

        for(ll j=97; j<123; j++)
        {
            if(i)
            {
                ccnt[j] = min(ccnt[j], tcnt[j]);
            }

            else
            {
                ccnt[j] = tcnt[j];
            }
        }
    }

    for(ll i=97; i<123; i++)
    {
        for(ll j=0; j<ccnt[i]; j++)
        {
            cout << (char)i;
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define endl '\n'
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
const ll mod = 1e9 + 7;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	vector<ll>v(n + 1);
	vector<ll>cpy(n + 1);
	v[0] = 0;
	for (ll i = 1; i <= n; i++) {
		cin >> v[i];
		cpy[i] = v[i];
		if (i >= 2)
			v[i] += v[i - 1];
	}
	ll ans = 0;
	for (ll i = 1; i <= n ; i++) {
		ll have = cpy[i];
		ll sum = v[n] - v[i];
		sum %= mod;
		have %= mod;
		ans += (have * sum) % mod;
		if (ans < 0)ans += mod;
		ans %= mod;
	}
	if (ans < 0)ans += mod;
	cout << ans % mod << endl;
}

Measured memory_bytes: 6360
// A

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll MOD=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

int main(){
  int H,W;
  string s[100];
  cin>>H>>W;
  for (int i(0);i<H;i++) cin>>s[i];
  int yoko[100]={0},tate[100]={0};
  for (int i(0);i<H;i++){
    bool flag = true;
    for (int j(0);j<W;j++){
      if (s[i][j] == '#') flag = false;
    }
    if (flag) yoko[i]++;
  }

  for (int i(0);i<W;i++){
    bool flag = true;
    for (int j(0);j<H;j++){
      if (s[j][i] == '#') flag = false;
    }
    if (flag) tate[i]++;
  }

  for (int i(0);i<H;i++){
    for (int j(0);j<W;j++){
      if (yoko[i] == 0 && tate[j] == 0){
        cout << s[i][j];
      }
    }
    if (yoko[i] == 0) cout << endl;
  }
  return 0;
}



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

// return {node, dist}
pair<int, int> dfs(int v, int prev, vector<vector<int> > &G) {
    pair<int, int> res = make_pair(v, 0);
    for (int i=0; i<(int)G[v].size(); ++i) {
        if (G[v][i] != prev) {
            auto t = dfs(G[v][i], v, G);
            t.second += 1;
            if (res.second < t.second) {
                res = t;
            }
        }
    }
    return res;
}

int diameter(vector<vector<int> > &G) {
    auto u = dfs(1, -1, G);
    auto v = dfs(u.first, -1, G);
    return v.second;
}

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

    vector<vector<int> > G(N+1);
    for (int i=0; i<N-1; ++i) {
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int L = diameter(G)+1;

    if (L == 0) {
        cout << "Second" << endl;
    }
    else if (L == 1) {
        cout << "First" << endl;
    }
    else if (L >= 2) {
        if (L % 3 == 2) {
            cout << "Second" << endl;
        } else {
            cout << "First" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":"\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

struct union_find {
    vector<int> data;
    union_find(int size) : data(size, -1) {}
    void unite(int x, int y) {
        x = root(x); y = root(y);
        if(x != y) {
            if(data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};
signed main() {
    int N,M;
    cin>>N>>M;
    union_find uf(N);
    REP(i,M) {
        int a,b;
        cin>>a>>b;
        a--,b--;
        uf.unite(a,b);
    }
    int A=uf.size(0);
    int B=uf.size(1);
    if(A<B) {
        B+=N-A-B;
    } else {
        A+=N-B-A;
    }
    int ans=B*(B-1)/2+A*(A-1)/2-M;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
//解答写し
string S;int n,d,c;
int main(){
	cin>>n>>S;
	for(int i=0;i<S.size();i++){
      if(S[i]=='(')c++;
      else c--;
      d=min(d,c);
    }
	for(int i=0;i<-d;i++){
      cout<<"(";
    }
    cout<<S;
    for(int i=0;i<c-d;i++){
      cout<<")";
    }
	return 0;
}

Measured memory_bytes: 256
Option Explicit On
Imports System

Module Program
    Sub Main(args As String())

        Dim tmp As String() = Split(Console.ReadLine(), " ")

        Dim X As Integer = CInt(tmp(0))
        Dim Y As Integer = CInt(tmp(1))

        For a As Integer = 0 To 100
            For b As Integer = 0 To 100
                If a + b = X And a * 2 + b * 4 = Y Then
                    Console.WriteLine("Yes")
                    Exit Sub
                End If
            Next
        Next
        Console.WriteLine("No")

    End Sub
End Module


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

using namespace std;

int main(){
    int n, d;
    vector<bool> diameter(102);
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> d;
        if (! diameter[d] ) {
            diameter[d] = 1;
        }
    }
    
    int how_many_different_d = 0;
    for (int i=0; i<102; i++) {
        how_many_different_d += diameter[i];
    }
    cout << how_many_different_d << endl;
}

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

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

    vector<vector<int>> train(510,vector<int>(510));
    int l,r;
    for(int i=0;i<M;i++){
        cin >> l >> r;
        train[l][r]++;
    }
    for(int i=1;i<=500;i++){
        for(int j=1;j<=500;j++){
            train[i][j]=train[i][j-1]+train[i][j];
        }
    }
    int p,q;
    int sum=0;
    for(int i=0;i<Q;i++){
        sum=0;
        cin >> p >> q;
        for(int j=p;j<=q;j++){
            sum+=train[j][q];
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 1920
from itertools import permutations
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    xys = [[int(i) for i in stdin.readline().rstrip().split()] for _ in range(N)]
    perm = list(permutations(range(N)))
    results = []
    for points in perm:
        dis = 0
        for i, point in enumerate(points[:-1]):
            p1 = point
            p2 = points[i + 1]
            x1, y1 = xys[p1]
            x2, y2 = xys[p2]
            dis += ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
        results.append(dis)
    print(sum(results) / len(results))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9332
def main():
    cin = input()
    n = int(cin.split(" ")[0])
    r = int(cin.split(" ")[1])
    
    if n >= 10:
        cout = r

    else:
        cout = r + 100 * (10 - n)

    print(cout)

if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
A, B, K = map(int, input().split())

cd = []

if A > B:
  nums = [i for i in range(1, B+1)]
elif A < B:
  nums = [i for i in range(1, A+1)]
else:
  nums = [i for i in range(1, A+1)]

for i in nums:
  if A % i == 0 and B % i == 0:
    cd.append(i)
print(cd[-K])

Measured memory_bytes: 3064