akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }

vector<int> g[101010];

signed main() { 
        int n, m;
        cin >> n >> m;
        deque<int> dq;
        bool f = true;
        bool used[101010];
        rep(i, n) used[i] = false;
        rep(i, m) {
                int a, b;
                cin >> a >> b;
                a --, b --;
                g[a].push_back(b);
                g[b].push_back(a);
                if (f) {
                        f = false;
                        dq.push_front(a);
                        dq.push_back(b);
                        used[a] = used[b] = true;
                }
        }
        f = true;
        while (f) {
                int a = dq.front();
                int b = dq.back();
                f = false;
                for (auto nexta : g[a]) {
                        if (!used[nexta]) {
                                f = true;
                                used[nexta] = true;
                                dq.push_front(nexta);
                                break;
                        }
                }
                for (auto nextb : g[b]) {
                        if (!used[nextb]) {
                                f = true;
                                used[nextb] = true;
                                dq.push_back(nextb);
                                break;
                        }
                }
        }
        cout << dq.size() << endl;
        while (!dq.empty()) {
                cout << dq.front() + 1;
                dq.pop_front();
                cout << (dq.empty() ? '\n' : ' ');
        }
        return 0;
}               



Measured memory_bytes: 6756
import itertools
N = int(input())
K = N.bit_length()
ans = [[] for _ in range(N)]
for a, b in itertools.combinations(range(1, N + 1), 2):
    c = a ^ b
    for i in range(K):
        if 1 << i & c:
            ans[a] += [i + 1]
            break
for _ in ans[1:]:
    print(*_)
# https://www.youtube.com/watch?v=JTH27weC38k


Measured memory_bytes: 5104
def resolve():
    N, M = map(int, input().split())
    A = []
    B = []
    ans = 0
    for _ in range(N):
        a = input()
        A.append(a)
    for __ in range(M):
        b = input()
        B.append(b)
    for i in range(N-M+1):
        for j in range(N-M+1):
            flag = 0
            for p in range(M):
                for q in range(M):
                    if A[i+p][j+q] != B[p][q]:
                        flag = 1
            if flag == 0:
                ans = 1
    print("Yes" if ans == 1 else "No")
resolve()

Measured memory_bytes: 9124
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/
 
int n,a,H;
ll b,l,r,mid;
vector<int>h;
 
bool check(int cnt){
  int index=upper_bound(all(h),cnt*b)-h.begin();
  ll con=cnt*b;
  for(int i=index;i<n;i++){
    cnt-=(h[i]-con)/(a-b);
    if((h[i]-con)%(a-b)!=0)cnt--;
    if(cnt<0)return false;
  }
  return true;
}
 
int main(){
  scanf("%d%d%d",&n,&a,&b);
  rep(i,n){scanf("%d",&H);h.pb(H);}
  sort(all(h));
  l=0;r=1000000001;mid=(l+r)/2;
  while(l<r){
    if(check(mid))r=mid;
    else l=mid+1;
    mid=(l+r)/2;
  }
  cout<<mid<<endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

#define INF 1000000000
#define MOD 1000000007
#define EPS 1e-9
#define DEBUG(x) cout<< '>' << #x << ':' << x << "\n";
#define all(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define tr(container, it) \
	for(typeof(container.begin()) it = container.begin(); it != container.end(); it++) 

// #define sz(a) int((a).size())
// #define pb push_back
// #define fill(a,v) memset(a,v,sizeof a)


#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;

#define trace3(x,y,z) cout<< '>' << #x << ':' << x \
		<< " | " << #y << ':' << y <<" | " << #z << ':' << z << endl;

#define trace4(x,y,z,w) cout<< '>' << #x << ':' << x \
	<< " | " << #y << ':' << y <<" | " << #z << ':' << z << " | " << #w << ':' << w << endl;


inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }

const double pi = acos(-1);

/////////////////////////////////////////////////////////////////////

// bool sortbysec(const pair<int,int> &a,
//               const pair<int,int> &b)
// {
//     return !(a.first < b.first);
// }

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } // __gcd(0,0) gives exception

const int MAX_N = 210;

int arr[27];

int main(){
	string s;
	cin>>s;
	if(s.length()>3 && s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I'){
		printf("Yes\n");
	}
	else
		printf("No\n");
    return 0;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] count = new int[n];
        for(int i = 0;i < m;i++) {
            count[sc.nextInt() - 1]++;
            count[sc.nextInt() - 1]++;
        }
        
        Arrays.stream(count).forEach(System.out::println);
    }
}


Measured memory_bytes: 26836
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
import std.typecons;

void main() {
	int n, m;
	scanf("%d %d\n", &n, &m);
	Tuple!(int, int)[][int] map;
	foreach (i; 0..m) {
		int p, y;
		scanf("%d %d\n", &p, &y);
		map[p] ~= tuple(i, y);
	}
	Tuple!(int, int, int)[] flat;
	foreach (p; map.keys) {
		auto cities = map[p];
		cities.sort!((a, b) => a[1] < b[1]);
		int cnt;
		foreach (city; cities) {
			++cnt;
			flat ~= tuple(city[0], p, cnt);
		}
	}
	flat.sort!((a, b) => a[0] < b[0]);
	foreach (city; flat) {
		writefln("%06d%06d", city[1], city[2]);
	}
}


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

int table_r[10]={0,5,3,3,3,3,3,4,3,4};
char t[10][5] = {{0,0,0,0,0},{'.', ',', '!', '?', ' '},};

int main(){
    char abc='a';
    for(int i=2; i<=9; i++){
        for(int j=0; j<table_r[i]; j++){
            t[i][j]=abc++;
        }
    }

    int n;
    cin >> n;
    char buf[1025];
    for(int i=0; i<n; i++){
        cin >> buf;
        for(int j=0; buf[j]!=0; j++){
            char tmp = buf[j];
            if(tmp=='0') continue;
            int ct;
            for(ct=0; buf[j+ct]!=0; ct++){
                if(buf[j+ct]=='0'){
                    int k = tmp-'0';
                    cout << t[k][(ct-1)%table_r[k]];
                    j+=ct;
                    break;
                }
            }
        }
        cout << endl;
    }
            
    return 0;
}

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

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

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

  printf("%lld\n", (ll)(a * b));
  return 0;
}


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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

const int maxn = 80, maxk = 1 << 14, init = 1 << 13;
bool dp[maxn][maxn][maxk];
int a[maxn][maxn];

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            int t;
            cin >> t;
            a[i][j] = abs(t - a[i][j]);
        }
    }

    dp[0][0][init - **a] = dp[0][0][init + **a] = true;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            int &d = a[i][j];
            for (int k = d; k < maxk - d; k++) {
                bool &cur = dp[i][j][k];
                if (i) {
                    auto &p = dp[i - 1][j];
                    if (p[k - d] || p[k + d]) cur = true;
                }
                if (j) {
                    auto &p = dp[i][j - 1];
                    if (p[k - d] || p[k + d]) cur = true;
                }
            }
        }
    }

    int ans = 1 << 30;
    for (int i = 0; i < maxk; i++) {
        if (dp[n - 1][m - 1][i]) ans = min(ans, abs(i - init));
    }
    cout << ans;
}


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

int main(){
 int n,m,l;
 cin >> n >> m >> l;
 int A[n][m],B[m][l];

 for(int r = 0; r < n; r++){
  for(int c = 0; c < m; c++) cin >> A[r][c];
 }
 for(int r = 0; r < m; r++){
  for(int c = 0; c < l; c++) cin >> B[r][c];
 }

 for(int r=0; r<n; r++){
  for(int c=0; c<l; c++){
   long int sum = 0;
   for(int i=0; i<m; i++) sum += A[r][i]*B[i][c];
   cout << sum << (c!=l-1?" ":"\n");
  }
 }
}


Measured memory_bytes: 3184
N = int(input())
S = [input() for _ in range(N)]

D = [[0] * 2 for _ in range(N)]

for i in range(N):
  s = S[i]
  ma = 0
  l = 0
  r = 0
  for j in s:
    if j == ")":
      r += 1
    else:
      l += 1
    ma = max(ma, r - l)
  D[i] = [l - r, ma, s]

cnt = 0
P = []
M = []
for x, y ,s in D:
  if x >= 0:
    if y <= 0:
      cnt += x
    else:
      P.append([x, y])
  else:
    M.append([x, y, s])

P.sort(key = lambda x:x[1])

for x, y in P:
  if y > cnt:
    print("No")
    exit()
  cnt += x

if len(M) == 0:
  if cnt == 0:
    print("Yes")
  else:
    print("No")
  exit()

M.sort(reverse = True)
M.sort(key = lambda x:x[1], reverse = True)

for i in range(len(M)):
  x, y, s = M[i]
  if x == -y:
    g = x
    M[i] = [0, 0, ""]
    break
else:
  print("No")
  exit()

for x, y, s in M:
  if cnt < y:
    print("No")
    exit()
  cnt += x

if cnt + g == 0:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 398400
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n, r;

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

    if (n >= 10) {
        cout << r << endl;
    }
    else {
        cout << r + (100 * (10 - n)) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
A,B = list(map(int,input().split()))

tasu = A+B
hiku = A-B
kakeru = A *B

ans =0

if tasu >= hiku and tasu >= kakeru:
  ans = tasu
elif hiku >= tasu and hiku >= kakeru:
  ans = hiku
elif kakeru >= tasu and kakeru >= hiku:
  ans = kakeru

print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class C
{
	public static void Main()
	{
		long N = GetLong();
		long P = GetLong();
		
		List<int> primes = sieve((int)Math.Sqrt(P));

		var numFactor = new Dictionary<long, long>();
		long tmp = P;
		for(int i = 0; i < primes.Count; i++)
		{
			long prime = (long)primes[i];
			while(tmp % prime == 0)
			{
				tmp /= prime;
				long currentNum = 0;
				numFactor.TryGetValue(prime, out currentNum);
				numFactor[prime] = currentNum + 1;
			}
			if(tmp == 1)
				break;
		}
		if(tmp != 1)
			numFactor[tmp] = 1;

		long gcdMax = 1;
		foreach(var key in numFactor.Keys)
			for(long i = 0; i < numFactor[key] / N; i++)
				gcdMax *= key;
		Console.WriteLine(gcdMax);
	}

	private static List<int> sieve(int N)
	{
		List<int> primeList = new List<int>();
		bool[] isPrime = new bool[N+1];
		for(int i = 2; i <= N; i++)
			isPrime[i] = true;

		for(int i = 2; i <= N; i++)
		{
			if(isPrime[i])
			{
				primeList.Add(i);
				for(int j = 2 * i; j <= N; j += i)
					isPrime[j] = false;
			}
		}

		return primeList;
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 13152
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


#define rep(i,r,l) for(int i = r; i < l; i++)
#define elif else if

int nextint(void){int n;scanf("%d",&n);return n;}
void printint(int d){printf("%d\n",d);}


int main(void){ 

    int n,k;
    scanf("%d %d",&n,&k);
    int a[200000]; 

    rep(i,1,n+1){
        a[i] = nextint();
        //printint(a[i]);
        if(i>k){(a[i-k]<a[i])?(puts("Yes")):(puts("No"));}
    }

    
    return 0;
}



Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;


int main() {
int64_t A,B;
int K;
cin >> A >> B >> K;
set<int64_t> ka;
for (int i = A;i < A+K;i++) {
    if (i <= B) {
    ka.insert(i);
    }
}
for (int i = B-K+1;i <= B;i++) {
    if (i >= A) ka.insert(i);
}
for (auto value : ka) {
    cout << value << endl;
}


return 0;
}


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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000001)
#define MOD (1000000007)
#define PI (acos(-1))

int isprime(int n){
  if(n==1){
    return false;
  }
  for(int i=2; i*i<=n; i++){
    if(n%i==0){
      return false;
    }
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  int cnt = 0;
  vector<int> ans;
  reps(i,2,55556){
    if(isprime(i) && i%5==1){
      ans.push_back(i);
      cnt++;
      if(cnt==n)break;
    }
  }
  rep(i,n){
    cout << ans[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 256
# AOJ 1063: Watchin' TVA
# Python3 2018.7.8 bal4u

while True:
	n = int(input())
	if n == 0: break
	dic, tbl = {}, []
	for i in range(n):
		nm, w, s = input().split()
		w, s = int(w), int(s)
		h, m = s//100, s%100
		s = (1440*w + h*60 + m) % 10080
		e = s + 30;
		tbl.append([s, e, 0, nm])
		dic[nm] = i
	for i in range(int(input())): tbl[dic[input()]][2] = 1
	if n == 1:
		print(1)
		continue
	tbl.sort(key=lambda x:(x[0],x[2]))
	for i in range(len(tbl)):
		if tbl[i][2]:
			k = i
			break
	ans, i, j = 1, k, k
	while True:
		j += 1
		if i >= n: i = 0
		if j >= n: j = 0
		if j == k: break
		e = tbl[i][1] - 10080 if tbl[i][1] >= 10080 else 0
		if (tbl[i][0] <= tbl[j][0] and tbl[j][0] < tbl[i][1]) \
		    or tbl[j][0] < e:
			if tbl[j][2] and tbl[i][2]:
				ans = -1
				break
			elif tbl[j][2]: i = j
		elif tbl[j][0] <= tbl[k][0] and tbl[k][0] < tbl[j][1]: pass
		else:
			ans += 1
			i = j
	print(ans)



Measured memory_bytes: 5776
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n, d = sc.nextInt
    sc.close()

    val calc = n / (d * 2 + 1)
    val nokori = n % (d * 2 + 1)
    if (nokori > 0) println(calc + 1)
    else println(calc)
  }
}

Measured memory_bytes: 27464
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




int main() {
    ll n;
    string s;
    cin >> n >> s;
    
    ll lw = 0, re = 0;
    for(int i = 1; i < n; i++){
        if(s[i] == 'E'){
            re++;
        }
    }
    ll ans = re;
    if(s[0] == 'W'){
        lw++;
    }
    for(int i = 1; i < n; i++){
        if(s[i] == 'E'){
            re--;
        }
        ans = min(ans, lw + re);
        if(s[i] == 'W'){
            lw++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
int a[200100],n,mn,flag,p;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	mn=a[1];
	for(int i=1;i<=n;++i)mn=min(mn,a[i]);
	for(int i=1;i<=n;++i){
		if(a[i]!=mn)flag=true,p++;
		if(a[i]!=mn&&a[i]!=mn+1)return puts("No"),0;
	}
		
	if(flag){
		if(p==1)return puts("No"),0;
		int ans1=0;
		for(int i=1;i<=n;++i)if(a[i]==mn)ans1++;
		if(ans1+1>mn+1||ans1+(n-ans1)/2<mn+1)return puts("No"),0;
		else return puts("Yes"),0;
	} else {
		if(n/2<mn&&mn+1!=n)return puts("No"),0;
		else return puts("Yes"),0;
	}
}

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

int main(){
    ll N;
    cin >> N;
    int A[N];
    ll sum = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        sum += A[i];
    }
    ll ans[N];
    ans[0] = sum;
    for(int i = 1; i < N-1; i+=2)
        ans[0] -= 2*A[i];
    cout << ans[0] << " ";
    for(int i = 1; i < N; i++){
        ans[i] = 2*A[i-1] - ans[i-1];
        cout << ans[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int maxn=1e5+10;
int n;
long long k,pre=0;
pair<int,int> p[maxn];
int main(){
	cin>>n>>k;
	for(int i=0,a,b;i<n;i++){
		cin>>a>>b;
		p[i].first=a;
		p[i].second=b;
	}
	sort(p,p+n);
	int ans;
	for(int i;i<n;i++){
	if(k>pre&&k<=p[i].second+pre){
			ans=p[i].first;
			break;
		}
		pre+=p[i].second;
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 1024
var
 n,i,j:longint;
 a,b:array[0..200001] of int64;
begin
 readln(n);
 for i:=1 to n do
  read(a[i]);
 a[0]:=a[1];
 for i:=1 to n div 2 do
  b[i]:=a[n-(i-1)*2];
 for i:=n downto n div 2+1 do
  b[i]:=a[(n+1)-(n-i+1)*2];
 for i:=1 to n do
  write(b[i],' ');
end.

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

int main()
{

        int a, b,c;
        cin >> a >> b >> c;

        if (a == b && b == c) {
                cout << 1 << endl;
        }
        else if (a == b || b == c || a == c) {
                cout << 2 << endl;
        }
        else {
                cout << 3 << endl;
        }


}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){

  int n,i,count;
  char str0[3],str1[3];

  while(scanf("%d",&n),n){
    
    count=0;
    scanf("%s",str0);
    
    
    for(i=1;i<n;i++){
      scanf("%s",str1);
      
      if(str0[1]==str1[1]){
	count++;
      }
      strcpy(str0, str1);
    }
    
    printf("%d\n",count);
    
  }
  
  return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#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, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int N;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int n, q;
    cin >> n;
    vector<int> A(n);
    REP(i, n) cin >> A.at(i);
    cin >> q;
    vector<int> m(q);
    REP(i, q) cin >> m.at(i);

    set<int> can;
    FOR(bit, 1, 1 << n) {
        int sum = 0;
        REP(j, n) {
            int mask = 1 << j;
            if ((bit & mask) > 0) {
                sum += A[j];
            }
        }
        can.insert(sum);
    }

    REP(i, q) {
        if (can.find(m[i]) != can.end()) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3152
#include<cstdio>
int main(void){
  int n,money,money1;
  money=100000;
 scanf("%d",&n);
 while(n>0){
   money=money+money*0.05;
   n--;
 money1=money;
 money=money%1000;
 if(money!=0){
   money1=money1-money+1000;
 }
 else if(money==0){
   money1=money1-money;
 }
 money=money1;
 }
 printf("%d\n",money);

  return 0;
}

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

int main() {
  
  int x=0;
  
  cin >> x;
  
  if( x < 1200 ) {
    
    cout << "ABC" << endl;
    
  } else {
    
    cout << "ARC" << endl;
    
  }
  
  return 0;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#define REP(i,n) for(int i=0;i<(n);i++)
#define EREP(i,x,n) for(int i=(x);i<(n);i++)
#define FOR(i,n) for(int i=1;i<(n);i++)
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(i%2==0){
			cout<<s[i];
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main()
{
    int x, y, tmp;
    
    while (1) {
        scanf("%d %d", &x, &y);
        if (!x && !y) {
            break;
        } else {
            if (x > y) {
                tmp = x;
                x = y;
                y = tmp;
            }
            printf("%d %d\n", x, y);
        }
    }
    return 0;
}


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

using namespace std;
const long long INF = 1LL <<60;  

int main(void){
  long long  a,res;
  string tmp;
  int b;

  cin>>a;
  cin>>tmp;
  /*
  if(tmp[2]=='0' && tmp[3]=='0'){
    b=stoi(tmp.substr(0,1))*100;
  }
  else if(tmp[3]=='0'){
    b=stoi(tmp.erase(1,1))*10;
  }
  else{
    b=stoi(tmp.erase(1,1));
  }*/
  b=stoi(tmp.erase(1,1));
  //cout<<a<<" "<<b<<" "<<a*b<<endl;
  res=(a*b)/100;
  cout<<res;
  
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
   int x,a,b;
   cin>>x>>a>>b;
   if(a>=b){
      cout<<"delicious"<<endl;
      return 0;
   }
   if(b-a<=x)cout<<"safe"<<endl;
   else cout<<"dangerous"<<endl;
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, s;
bitset<4000021> f;
int main () {
	scanf("%d", &n);
	f[0] = 1;
	for (int i = 1; i <= n; i++) {
		int x;
		scanf("%d", &x);
		f |= f << x;
		s += x;
	}
	for (int i = (s + 1) >> 1; i <= s; i++) {
		if (f[i]) {
			printf("%d\n", i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int A[200][200],b[200],ap[200][200];
int main()
{
    string ans="No";
    int i,j,n,k,cnt=0,m;
    for(i=0; i<3; i++)
    {
        for(j=0; j<3; j++)
            cin>>A[i][j];
    }
    cin>>k;
    for(i=0; i<k; i++)
        cin>>b[i];
    for(i=0; i<3; i++)
    {
        for(j=0; j<3; j++)
        {
             for(m=0; m<k; m++)
             {
                 if(b[m]==A[i][j])
                    {
                        ap[i][j]=1;
                    }
             }
        }
    }
      for(i=0; i<3; i++)
      {
          if((ap[i][0]==1&& ap[i][1]==1&& ap[i][2]==1))
            ans="Yes";
      }
      for(i=0; i<3; i++)
      {
          if((ap[0][i]==1&& ap[1][i]==1&& ap[2][i]==1))
            ans="Yes";
      }
 
 
    if((ap[0][0]==1&& ap[1][1]==1&& ap[2][2]==1) ||(ap[0][2]==1&& ap[1][1]==1&& ap[2][0]==1)) ans="Yes";
        cout<<ans<<"\n";
 
    return 0;
}

Measured memory_bytes: 256
H,W,K = map(int,input().split())
C = [input() for i in range(H)]

import itertools
h = list(itertools.product([0,1], repeat=H))
w = list(itertools.product([0,1], repeat=W))

ans = 0
for i in h:
    for j in w:
        tmp = 0
        for ii in range(H):
            for jj in range(W):
                if C[ii][jj] == '#' and i[ii] == 0 and j[jj] == 0:
                    tmp += 1
        if tmp == K:
            ans += 1
            
print(ans)    

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int a, b, h;
  cin >> a >> b >> h;
  int ans = (a+b) * h / 2;
  cout << ans << endl;
} 






Measured memory_bytes: 256
import { count } from 'console';

process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const card = inputs[0].split(' ').map(Number);
  let k = card[3];
  let num = 1;
  let max = 0;

  for (let i = 0; i < 3; i++) {
    if (k <= 0) break;

    if (card[i] > k) {
      max += num * k;
    } else {
      max += num * card[i];
    }
    num--;
    k -= card[i];
  }

  console.log(max);
}


Measured memory_bytes: 30104
#include <stdio.h>
#include <string.h>
 
#define LEN 100005
 
typedef struct pp {
    char name[100];
    int t;
} P;
 
P Q[LEN];
int head, tail, n;
 
void enqueue(P x) {
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}
 
P dequeue() {
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}
 
int min(int a, int b) {
    return a < b ? a : b;
}
 
int main(int argc, char const *argv[])
{
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);
 
    for (i = 1; i <= n; i++) {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1;
    tail = n + 1;
 
    while (head != tail) {
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if (u.t > 0) 
            enqueue(u);
        else
            printf("%s %d\n", u.name, elaps);
 
    }
    return 0;
}

Measured memory_bytes: 10756
import java.math.BigDecimal

import java.math.MathContext

fun main(args: Array<String>) = panasonic2020c()

fun panasonic2020c() {
    val (a, b, c) = readLine()!!.split(' ').map { BigDecimal(it) }

    val answer =
        if (sqrt(a, 1000) + sqrt(b, 1000) < sqrt(c, 1000)) "Yes" else "No"

    println(answer)
}

fun sqrt(a: BigDecimal, scale: Int): BigDecimal {
    var x = BigDecimal(Math.sqrt(a.toDouble()), MathContext.DECIMAL64)
    if (scale < 17) {
        x = x.setScale(scale, BigDecimal.ROUND_HALF_EVEN)
        return x
    }
    val b2 = BigDecimal(2)
    var tempScale = 16
    while (tempScale < scale) {
        x = x.subtract(
            x.multiply(x).subtract(a).divide(
                x.multiply(b2), scale, BigDecimal.ROUND_HALF_EVEN
            )
        )
        tempScale *= 2
    }
    return x
}


Measured memory_bytes: 38544
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
const ld pi = acos(-1);
const ll mod = 1000000007;
const ll inf = 1LL << 60;

int main(){
    ll n;
    cin>>n;
    ll cnt=0;
    rep2(a,1,pow(10,6)+1){
        rep2(b,1,pow(10,6)/a+1){
            if (n-(a*b)>0){
                cnt+=1;
            }
        }
    }
    cout<<cnt<<endl;
}

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

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

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

int main() {
  i64 X;
  cin >> X;

  vector<i64> prime(202020, -1);
  for(i64 i = 2;true;i++) {
    if(prime[i] == -1) {
      prime[i] = 1;
      if(X <= i) {
        cout << i << endl;
        return 0;
      }
      for(i64 j = i + i; j < 202020;j += i) {
        prime[j] = 0;
      }
    }
  }
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mod 1000000007
#define mod1 998244353
#define N 100003
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c));
#define max3(a,b,c) max(a,max(b,c));
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::floatfield );std::cout.precision(15)
#define PI M_PI
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define showzero cout<<std::showpoint
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define br "\n"
using namespace  std ;
typedef double db;
typedef long long ll ;
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
/*vbool isprime(N,true);
vll spf(N,0);
vll prime;
void sieve()
{
    isprime[0] = isprime[1] = false;
    for(ll i = 2 ; i<N ; i++)
    {
        if(isprime[i])
        {
            for(ll j=2*i ; j<N ; j+=i)
            {
                isprime[j] = false;
                if(spf[j]==0)
                {
                    spf[j] = i;
                }
            }
            prime.pb(i);
        }
    }
}*/
ll nck(ll n , ll k ,ll m=1e18+7)
{
    ll i , j,b=1,c=1 ;
    if(n-k<k)
    {
        k = n-k ;
    }
    while(k)
    {
        b*=n ;
        c*=k ;
        ll g = __gcd(b,c) ;
        b/=g ;
        c/=g ;
        n--;
        k-- ;
    }
    return(b) ;
}
long long power(long long k , long long n , long long m=mod)
{
    long long res = 1;
    while(n)
    {
        if(n%2!=0)
        {
            res = (res*k)%m ;
        }
        k = (k*k)%m ;
        n = n/2 ;
    }
    return(res) ;
}
void READ(vll &v, ll n)
{
    ll a ;
    for(ll i=0 ; i<n ; i=i+1)
    {
        cin>>a ;
        v.pb(a) ;
    }
}
void PRINT(vll &v , ll a = 0)
{
    //ll a ;
    for(ll i=a ; i<v.size() ; i=i+1)
    {
        v[i] = max((ll)0,v[i]);
        cout<<v[i]<<" " ;
    }
    cout<<"\n" ;
}
ll n,m,k;
bool ok = true;
int main()
{
    FastIO ;
    PRECISION ;
    ll a,b,c,d,e,i,j,t,x,y,z,x1,y1,z1,f;
    //double p,q,r,u,w ;
    char ch,chr ;
    //string str,st,str2,str3;
    //ll a1=0,a2=0,b1=0,b2=0,c1=0 ;
    //cin>>str>>str1;
    cin>>n;
    showzero;
    cout<<(db)2*PI*n;
}

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

int main() {
    ll A;
    string B;
    cin >> A >> B;
    ll B100 = (B[0] - 48) * 100 + (B[2] - 48) * 10 + (B[3] - 48) * 1; //文字コード文引く'0'でもおっけ
    cout << A * B100 / 100 << endl;
}


Measured memory_bytes: 3540
#include <iostream>

#include <string>

using std::cin;
using std::cout;
using std::endl;

using std::string;

int
main()
{
  string s;
  cin >> s;
  int d[4];
  for (int n = 0; n < 4; n++)
  {
    d[n] = s[n] - '0';
  }
  for (int b = 0; b < 8; b++)
  {
    int val = d[0];
    for (int shift = 0; shift < 3; shift++)
    {
      int mask = 1 << shift;
      val += ((b & mask) ? -1 : 1) * d[shift + 1];
    }
    if (val == 7)
    {
      cout << d[0];
      for (int shift = 0; shift < 3; shift++)
      {
        int mask = 1 << shift;
        cout << ((b & mask) ? '-' : '+') << d[shift + 1];
      }
      cout << "=7" << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
const ll MOD=1e9+7;
int main()
{
    int n, k; cin>>n>>k;
    int a[301], b[301];
    for(int i=0; i<k; i++){
        cin>>a[i]>>b[i]; a[i]--; b[i]--;
        if(a[i]>b[i]) swap(a[i], b[i]);
    }
    ll f[301]; f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=(2*i-1)*f[i-1]%MOD;
    ll ct[601][601]={}, ct1[601][601]={}, ct2[601][601]={};
    ll ans=0;
    for(int i=1; i<2*n; i++){
        for(int j=i-1; j>=0; j-=2){
            int t=i-j+1, u=2*n-t;
            bool dame=0;
            for(int l=0; l<k; l++){
                if(j<=a[l] && b[l]<=i) t-=2;
                else if((j>a[l] && b[l]>i) || i<a[l] || b[l]<j) u-=2;
                else{
                    dame=1;
                    break;
                }
            }
            if(dame) continue;
            ct[j][i]=f[t/2], ct2[j][i]=f[u/2];
            ct1[j][i]=ct[j][i];
            for(int l=i-1; l>j; l-=2){
                ct1[j][i]-=ct[j][l-1]*ct1[l][i]%MOD;
                ct1[j][i]=(ct1[j][i]+MOD)%MOD;
            }
            ans+=ct1[j][i]*ct2[j][i];
          //cout<<ct1[j][i]<<" "<<ct2[j][i]<<" "<<j<<" "<<i<<endl;
            ans%=MOD;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a, b; cin >> a >> b;
	int c;
	if(b < 10) c = 10 * a + b;
	else if(b < 100) c = 100 * a + b;
	else c = 1000 * a + b;
	int d = sqrt(c);
	if(d * d != c) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#coding: utf-8

N, K = map(int, input().split())
A = list(map(int, input().split()))

for i in range(N):
    if(A[i] == 1):
        one = i
        #print('1は',one + 1,'番目')

ans = []

for i in range(K):
    start = one - (K - 1) + i
    end = one + i

    before = start
    after = N - (end+1)

    before_num = before//(K-1)
    if(before%(K-1) != 0):
        before_num += 1

    after_num = after//(K-1)
    if(after%(K-1) != 0):
        after_num += 1

    answer = before_num + after_num + 1
    ans.append(answer)

print(min(ans))

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

int main(){
    ll h; int n; int a; cin >> h >> n;
    ll sum = 0LL;
    rep(i,n){
        cin >> a;
        sum += a;
    }
    if(sum >= h) cout << "Yes";
    else cout << "No";
}

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

int main() {
	int H,W,N;
	cin >> H >> W >> N;
	int *a = new int[N];
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int grid[100][100];
	int row = 0, column = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < a[i]; j++) {
			grid[row][column] = i+1;
			if (row % 2 == 0) {
				if (column == W-1)
					row++;
				else
					column++;
				
			}
			else {
				if (column == 0)
					row++;
				else
					column--;
			}
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << grid[i][j] << " ";
		}
		cout << endl;
	}

	
}

Measured memory_bytes: 384
N, A, B = map(int, input().split())

def caluculate(n):
    sum = 0
    while n > 0:
        sum += n % 10
        n = n // 10
    return sum

ans = 0
for i in range(N+1):
    if A <= caluculate(i) <= B:
        ans += i

print(ans)

Measured memory_bytes: 9148
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, pair<int, int> > P;

vector<pair<int, int> > v_eq;
vector<pair<int, pair<int, int> > > v_alt;

bool comp(P hl, P hr){
	if(hl.first != hr.first) return hl.first < hr.first;
	if(hl.second.first != hr.second.first) return hl.second.first < hr.second.first;
	return hl.second.second < hr.second.second;
}

int main(){
	int h,w;

	cin >>h>>w;
	while((h != 0)&&(w != 0)){
		int ansh = 20000, answ = 20000,taikaku = h*h+w*w ;
		for(int i = 1; i< 151; i++){
			for(int j = i+1; j < 151;j++){
				if(taikaku == i * i + j * j and h < i) v_eq.push_back(make_pair(i, j));
				if(taikaku < i * i + j * j) v_alt.push_back(make_pair(i * i + j * j, make_pair(i, j)));
			}
		}
		if(v_eq.size() != 0){
			sort(v_eq.begin(), v_eq.end());
			cout << v_eq[0].first << " " << v_eq[0].second << endl;
		}
		else{
			sort(v_alt.begin(), v_alt.end(), comp);
			cout << v_alt[0].second.first << " " << v_alt[0].second.second << endl;
		}

		//init
		v_alt.clear();
		v_eq.clear();
		
		cin >>h>>w;
	}

	return 0;
}



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

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> p(N);
    for(int i=0; i<N; ++i){
        p[i] = i;
    }
    function<int(int)> root = [&](int x){
        if(p[x]==x) return x;
        return p[x] = root(p[x]);
    };
    for(int i=0; i<M; ++i){
        int x, y, z;
        cin >> x >> y >> z;
        int rx = root(x-1);
        int ry = root(y-1);
        if(rx==ry) continue;
        p[rx] = ry;
    }
    int count = 0;
    for(int i=0; i<N; ++i){
        if(p[i]==i) ++count;
    }
    cout << count << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{

    int n;
    cin >> n;
    cout << setprecision(15) << ((n + 1) / 2 / double(n)) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n,k,x,y,cost=0;
	scanf("%d %d %d %d",&n,&k,&x,&y);
	if(n<=k){
		cost += (x*n);
	}else{
		cost += (x*k);
		cost += (y*(n-k));
	}
	printf("%d\n",cost);
	return 0;
}

Measured memory_bytes: 128
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

const INF = int.max / 4;

struct Edge {
    int from, to, cost;
}
 
void main() {
    int N, M, L, K, A, H;
    Edge[][] G;
    static bool F[101];
    bool input() {
        scanf("%d %d %d %d %d %d\n", &N, &M, &L, &K, &A, &H);
        if (N == 0 && M == 0 && L == 0 && K == 0 && A == 0 && H == 0) return false;
        G = new Edge[][N];
        F[] = false;
        foreach (i; 0 .. L) {
            int x; scanf("%d", &x);
            F[x] = true;
        }
        foreach (i; 0 .. K) {
            int X, Y, T;
            scanf("%d %d %d\n", &X, &Y, &T);
            G[X] ~= Edge(X, Y, T);
            G[Y] ~= Edge(Y, X, T);
        }
        return true;
    }
    void solve() {
        struct State {
            int v, r;
            int cost;
            int charged;
        }
        static int D[101][101][2];
        foreach (i; 0 .. N) foreach (j; 0 .. M + 1) D[i][j][] = INF;
        BinaryHeap!(Array!State, "a.cost > b.cost") PQ;
        D[A][M][false] = 0;
        PQ.insert(State(A, M, 0, false));
        int Ans = INF;
        while (!PQ.empty) {
            State cur = PQ.front; PQ.removeFront;
            if (cur.v == H) {
                int c = cur.cost - min(cur.r, cur.charged);
                Ans = min(Ans, c);
            }
            if (F[cur.v]) {
                int ncost = cur.cost + M - cur.r;
                int ncharged = min(M, cur.charged + M - cur.r);
                if (D[cur.v][M][ncharged > 0] > ncost) {
                    D[cur.v][M][ncharged > 0] = ncost;
                    PQ.insert(State(cur.v, M, ncost, ncharged));
                }
                /*
                for (int i = cur.r + 1; i <= M; i++) {
                    int ncost = cur.cost + i - cur.r;
                    if (D[cur.v][i] > ncost) {
                        D[cur.v][i] = ncost;
                        PQ.insert(State(cur.v, i, ncost));
                    }
                }
                */
            }
            foreach (e; G[cur.v]) {
                int nr = cur.r - e.cost,
                    ncost = cur.cost + e.cost;
                if (nr < 0) continue;
                if (D[e.to][nr][cur.charged > 0] > ncost) {
                    D[e.to][nr][cur.charged > 0] = ncost;
                    PQ.insert(State(e.to, nr, ncost, cur.charged));
                }
            }
        }
        writeln(Ans == INF ? "Help!" : Ans.to!string);
    }
    while (input) solve;
}

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

int main(){
  string s;
  int n;
  cin >> n >> s;
  for(int i=0; i<s.size(); i++){
    if(s.at(i)+n<='Z'){
      s.at(i)+=n;
    }else{
      s.at(i)+=n-26;
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
int main() {
	int n; cin >> n;
	if (n == 0)cout << 1 << endl;
	else if (n == 1)cout << 2 << endl;
	else if (n == 2)cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 3060
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, h1: usize, m1: usize, h2: usize, m2: usize, k: usize);
    let mut d = 60 * (h2 - h1);
    d += m2;
    d -= m1;
    d -= k;
    println!("{}", d);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2120