akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

  int main(){      
     lint n,q;
     string s,t;
     cin>>s>>t;
    s+=t[t.size()-1];
    if(s==t)cout<<"Yes";
   else  cout<<"No";
      }
      
    

  
          
  

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; cin >> n;
  ll sum = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 != 0 && i % 5 != 0) sum += i;
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3648
n, k = map(int, input().split())
a = list(map(int, input().split()))
ball = {}

for i in a:
    if i in ball.keys():
        ball[i] += 1
    else:
        ball[i] = 1

ball = sorted(ball.items(), key=lambda x: -x[1])

ans = 0
if len(ball) > k:
    for i in range(k):
        ans += ball[i][1]
    ans = n - ans
print(ans)


Measured memory_bytes: 38964
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int>broken(n + 1, 0), dp(n + 1, 0);
	for(int i = 0; i < m; i++)
	{
		int p; cin >> p;
		broken[p] = 1;
	}
	dp[0] = 1;
	for(int i = 1; i <= n; i++)
	{
		if(broken[i])
			continue;
		dp[i] += dp[i - 1];
		if(i > 1)
			dp[i] += dp[i - 2];
		dp[i] %= mod;
	}
	cout << dp[n] << "\n";
	return 0;
}

Measured memory_bytes: 1024
import sys
from itertools import islice
read = map(int, sys.stdin.read().split())

N = next(read)
candidates = [format(i, 'b').zfill(N) for i in range(2 ** N)]
A = [0] * N
xy = [[] for _ in range(N)]
for i in range(N):
    A[i] = next(read)
    xy[i].extend(list(islice(read, A[i] * 2)))

answer = 0

for candidate in candidates:
    tmp = 0
    truth = set()
    false = set()
    for k in range(N):
        if candidate[k] == '1':
            if k in false:
                break
            truth.add(k)
            for i, j in zip(*[iter(xy[k])] * 2):
                i -= 1
                if j == 1:
                    if i in false:
                        break
                    truth.add(i)
                else:
                    if i in truth:
                        break
                    false.add(i)
            else:
                continue
            break
        else:
            if k in truth:
                break
            false.add(k)
    else:
        if len(truth) > answer:
            answer = len(truth)

print(answer)

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

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

    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M, 0));
    for (size_t i = 0; i < N; i++)
    {
        cin >> C[i];
        for (size_t j = 0; j < M; j++)
        {
            cin >> A[i][j];
        }
    }

    int ans = INT_MAX;
    for (size_t i = 0; (int)i < (1 << (int)N); i++)
    {
        bitset<16> b(i);
        vector<int> p(M, 0);
        int tmp = 0;
        for (size_t j = 0; j < N; j++)
        {
            if (b[j])
            {
                for (size_t k = 0; k < M; k++)
                {
                    p[k] += A[j][k];
                }
                tmp += C[j];
            }
        }
        for (size_t j = 0; j < M; j++)
        {
            if (p[j] < X)
            {
                tmp = ans;
            }
        }
        ans = min(ans, tmp);
    }
    if (ans == INT_MAX)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << ans << endl;
    }
}


Measured memory_bytes: 3632
#include <cstdlib>
#include <iostream>
using namespace std;
int main(){
	int N;
	int a[110000];
	int ans = 0;
	cin >> N;
	for (int i = 1; i <= N; ++i)
	{
		scanf("%d",&a[i]);
	}
	for (int i = 1; i <= N; ++i)
	{
		if(a[a[i]]==i) ans++;
	}
	cout << ans/2 << endl;
	return 0;
}

Measured memory_bytes: 640
from collections import deque
from itertools import product

H, W = map(int, input().split())
Ch, Cw = map(lambda x: int(x)-1, input().split())
Dh, Dw = map(lambda x: int(x)-1, input().split())
maze = [list(input()) for _ in range(H)] # 迷路
walkFrom = deque([(Ch, Cw)]) # 歩く出発地点の候補集
warpFrom = deque() # ワープ出発地点の候補集
WalkRange = [(1, 0), (-1, 0), (0, 1), (0, -1)]
WarpRange = list(filter(lambda x: x != (0, 0), product(range(-2, 3), repeat=2)))
warpCount = 0

def move(h_from, w_from, moveRange):
  for h_dist, w_dist in moveRange:
    h_to, w_to = h_from + h_dist, w_from + w_dist
    if 0 <= h_to < H and 0 <= w_to < W and maze[h_to][w_to] == '.':
      maze[h_to][w_to] = warpCount
      walkFrom.append((h_to, w_to))

# 迷路上の到達可能な全ての場所について、道(".")を必要なワープ回数で上書きする
maze[Ch][Cw] = warpCount
while walkFrom:
  # 歩ける範囲をすべて歩く
  while walkFrom:
    h, w = walkFrom.popleft()
    warpFrom.append((h, w))
    move(h, w, WalkRange)
  # 一度のワープで到達できる未踏の場所すべてにワープする
  warpCount += 1
  while warpFrom:
    h, w = warpFrom.popleft()
    move(h, w, WarpRange)

goal = maze[Dh][Dw]
print('-1') if goal in ['.', '#'] else print(goal)


Measured memory_bytes: 174976
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

const int k_max =1005;

int n,k;
int imosu[2 * k_max][2 * k_max];
int Map[2 * k_max][2 * k_max];



int solve(int x1,int y1, int x2, int y2){
    if(x1 >= x2 or y1 >= y2) return 0;
    return imosu[y2][x2] - imosu[y2][x1] - imosu[y1][x2] + imosu[y1][x1];
}

signed main(){
    cin >> n >> k;
    int x,y;
    string s;
    REP(i,2 * k_max) REP(j,2 * k_max) Map[i][j] = 0;
    REP(i,n){
        cin >> x >> y >> s;
        if(s == "B") x += k;
        x %= 2 * k;
        y %= 2 * k;
        Map[y][x] ++;
    }

    REP(i,2 * k + 1){
        imosu[i][0] = 0;
        imosu[0][i] = 0;
    }

    REP(i,2 * k){
        REP(j,2 * k){
            imosu[i + 1][j + 1] = imosu[i + 1][j] + Map[i][j];
        } 
    }
    REP(j,2 * k){
        REP(i,2 * k){
            imosu[i+1][j + 1] += imosu[i][j+1];
        }
    }




    int ans = 0;
    REP(x_init, k){
        REP(y_init, k){
            int tmp = 0;
            tmp += solve(x_init,y_init,x_init + k , y_init + k );
            tmp += solve(x_init + k, y_init + k, 2 * k, 2 * k);
            tmp += solve(x_init + k, 0, 2 * k, y_init );
            tmp += solve(0,y_init + k, x_init , 2 * k);
            tmp += solve(0,0,x_init,y_init);

            chmax(ans, tmp   );
        }
    }


    REP(x_init,k){
        FOR(y_init,k,2 * k){
            int tmp = 0;
            tmp += solve(x_init,y_init,x_init + k,2 * k);
            tmp += solve(x_init + k, y_init -k,2 * k,y_init);
            tmp += solve(x_init,0,x_init + k,y_init-k);
            tmp += solve(0,y_init-k,x_init,y_init);
        
            chmax(ans,tmp);
        }
    }
    cout << ans << endl;


}

Measured memory_bytes: 63232
# -*- coding: utf-8 -*-
"""
Created on Fri Aug  7 01:25:31 2020

@author: saito
"""

# %% import phase
from math import sqrt

# %% define phase
def calcdist(x, y):
    return sqrt(x**2+y**2)

# %% input phase
N, D = list(map(int, input().split()))
x = [0]*N
y = [0]*N
for i in range(N):
    x[i], y[i] = list(map(int, input().split()))

# %% process phase
count = 0
for i in range(N):
    dist = calcdist(x[i], y[i])
    if D >= dist:
        count += 1

# %%output phase
print(count)

Measured memory_bytes: 24732
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int input,temp,a;
int print[11];

int main()
{
	while(scanf("%d",&input)!= EOF)
	{
	a=9;
	temp=512;
	for(int z=0;z<11;z++)
	{
		print[z]=0;
	}
	while(temp>=1)
	{
		if(input<temp)
		{
			temp=temp/2;
		}
		else if(temp<=input&&temp!=1)
		{
			input-=temp;
			print[a]=temp;
			a--;
			temp/=2;
		}
		else
		{
			input-=temp;
			print[a]=temp;
			a--;
			temp=0;
			break;
		}
	}
	for(int z=0;z<11;z++)
	{
		if(print[z]!=0&&print[z+1]!=0)
		printf("%d ",print[z]);
		else if(print[z]!=0)
		printf("%d",print[z]);
	}
	printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
int main(){
    string N;cin>>N;
    if(N[N.size()-1]=='2'||N[N.size()-1]=='4'||N[N.size()-1]=='5'||N[N.size()-1]=='7'||N[N.size()-1]=='9')cout<<"hon";
    else if(N[N.size()-1]=='3')cout<<"bon";
    else cout<<"pon";
}

Measured memory_bytes: 3596
//bismillah
//created by anaksoleh
//27 Nov 2019

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

typedef long long ll;
bool computed[103][100005];
ll memo[103][100005];
int weight[103];
int value[103];

ll solve(int i,int c)
{
    if(i == 0)return 0;
    if(computed[i][c])return memo[i][c];

    ll best = solve(i-1,c);
    if(c >= weight[i]){
        best = max(best,solve(i-1,c - weight[i]) + value[i]);
    }
    computed[i][c] = true;
    memo[i][c] = best;
    return best;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N,W;
    cin >> N >> W;
    for(int i = 1 ; i <= N ; i++){
        cin >> weight[i] >> value[i];
    }
    cout << solve(N,W) << '\n';
    return 0;
}


Measured memory_bytes: 89600
# coding: utf-8
# Your code here!

n,m,c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
for i in range(n):
    a = list(map(int, input().split()))
    sum_ab = 0
    for j in range(m):
        sum_ab += a[j] * b[j]
    sum_ab += c
    if sum_ab > 0:
        ans += 1

print(ans)
        
        

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;


int main(){

        int x,y;

        while(1){
                scanf("%d %d\n",&x,&y);
                if(x==0 && y==0)
                        return 0;
                if(x<y)
                        printf("%d %d\n",x,y);
                if(x>=y)
                        printf("%d %d\n",y,x);
        }

}


Measured memory_bytes: 3116
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<math.h>
#include<algorithm>
using namespace std;
#define ll long long


int H, W;
char A[1001][1001];
bool chk[1001][1001];

int di[4] = { 0,0,1,-1 };
int dj[4] = { 1,-1,0,0 };
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> H >> W;
	
	queue<pair<pair<int, int>,int>>q;
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++)
		{
			cin >> A[i][j];
			if (A[i][j] == '#')
			{
				q.push({ {i,j},0});
				chk[i][j] = true;
			}
		}


	int ans = 0;
	while (!q.empty())
	{
		pair<int, int>cur = q.front().first;
		int dist = q.front().second;
		q.pop();

		ans = max(ans, dist);
		for (int i = 0; i < 4; i++)
		{
			int next_i = di[i] + cur.first;
			int next_j = dj[i] + cur.second;
			if (next_i<0 || next_j<0 || next_i>=H || next_j>=W || chk[next_i][next_j])continue;

			chk[next_i][next_j] = true;
			q.push({ {next_i,next_j},dist + 1 });
		}
	}
	cout << ans;
}

Measured memory_bytes: 14352
n = int(input())
a = list(map(int, input().split()))
ave = sum(a)/n
b = [abs(a[i]-ave) for i in range(n)]
ans = 0
m = 1000000
for i in range(n):
    if b[i] < m:
        m = b[i]
        ans = i
print(ans)

Measured memory_bytes: 3064
N = int(input())
a = list(map(int, input().split()))

f = 0
t = 0

for i in a:
    if i % 4 == 0: f += 1
    elif i % 2 == 0: t += 1    

h = t // 2
s = ((N - h * 2) // 2)
s2 = N

if s <= f or s2 <= t:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252
n = int(input())
a = list(map(int,input().split()))

a_sum = 1

if 0 in a:
    print(0)
else:
    for i in range(n):
        a_sum *= a[i]
        if a_sum > 10**18:
            a_sum = -1
            break

    print(a_sum)

Measured memory_bytes: 21692
#coding: utf-8
 
n = int(raw_input())
 
def keitai(n1,n2):
    li1 = ['.', ',', '!', '?',' '] 
    li2 = ['a','b','c']
    li3 = ['d','e','f']
    li4 = ['g','h','i']
    li5 = ['j','k','l']
    li6 = ['m','n','o']
    li7 = ['p','q','r','s']
    li8 = ['t','u','v']
    li9 = ['w','x','y','z']
    li = [li1,li2,li3,li4,li5,li6,li7,li8,li9]
    lis = li[n1 - 1]
    n2 = n2 % len(lis)
    a = lis[n2 - 1]
    return a
 
for k in range(n):
    a = str(raw_input())
    num = 0
    string = ''
    for i in range(len(a)):
        if int(a[i]) == 0:
            if num != 0:
                string = string + keitai(b,num)
                num = 0
            else:
                pass
        else:
            num = num + 1
            b = int(a[i])
    print string

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

typedef long long ll;
typedef pair<int, pair<int, int>> piii;
//loop
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//STL
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

const int INF = 1e9;

void Main()
{
    int N; cin >> N;
    int cnt = 0;
    while (cnt * 1000 < N)
    {
        cnt++;
    }
    cout << 1000 * cnt - N << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3648
import java.util.*;

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

        int H1 = sc.nextInt();
        int M1 = sc.nextInt();
        int H2 = sc.nextInt();
        int M2 = sc.nextInt();
        int K = sc.nextInt();

        if(M1 > M2) {
            M2 += 60;
            H1++;
        }

        if(H1 > H2) {
            H1 += 24;
        }

        int h = H2 - H1;
        int m = M2 - M1;

        int result = m + h*60 - K;

        result = Math.max(result, 0);

        System.out.println(result);
    }
}

Measured memory_bytes: 35808
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll A,B,M,x,y,c;
	while(cin>>A>>B>>M) {
		VI a(A),b(B);
		REP(i, A) cin>>a[i];
		REP(i, B) cin>>b[i];
		ll ans=*min_element(ALL(a))+*min_element(ALL(b));
		REP(i, M) {
			cin>>x>>y>>c;
			x--;y--;
			minUpdate(ans, max(0LL, a[x]+b[y]-c));
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define vi vector<int>

#define ll long long int

int ctoi(char c) {return c-'0';}
int ord(char c) {return c-'a';}
int len(string s) {return s.length();}
int itoc(int i) {return i+'a';}

int main() {
int K,X;
cin>>K>>X;
cout<<((K*500)>=X ? "Yes" : "No")<<endl;
return 0;
}


Measured memory_bytes: 256
n=input()
n=n.split()
N=len(n)
B=[]
C=[s.strip(',') for s in n]
C=[s.strip('.') for s in C]
for i in range(N):
    A=len(C[i])
    if A>=3 and A<=6:
        B.append(C[i])
print(*B)
    


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

int main(){
    int n;cin>>n;
    ll dp[1000];
    dp[0]=2;dp[1]=1;
    for(int i=2;i<=n;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split(" "))
V = list(map(int,input().split(" ")))

maxcost = min(N,K)
o = []

A = 0
while A <= maxcost:
    B = 0
    while A + B <= maxcost:
        a = V[:A]+V[N-B:]
        b = sorted(list(filter(lambda x:x<0,a)))[:K-A-B]
        #print(a,b)
        o.append(sum(a)-sum(b))
        B += 1
    A += 1

print(max(o))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll bg=pow(10,9)+7;
#define ff(i,n) for(i=0;i<n;i++)
#define gg1(n1) cin>>n1;
#define gg(n1,n2) cin>>n1>>n2;
#define gg3(n1,n2,n3) cin>>n1>>n2>>n3;
#define hh(n) cout<<n<<endl;
#define t top
#define p push
#define pb push_back
#define mp make_pair
int main()
{
  string s,f;
  cin>>f>>s;
  ll n=f.length(),m=s.length();
  ll dp[n+1][m+1],i,j;
  for(i=0;i<=n;i++)
    for(j=0;j<=m;j++)
       dp[i][j]=0;
  for(i=1;i<=n;i++)
    for(j=1;j<=m;j++)
       {
            if(f[i-1]==s[j-1])
               dp[i][j]=max(dp[i][j],1+dp[i-1][j-1]);
            dp[i][j]=max(dp[i][j],max(dp[i-1][j],dp[i][j-1]));
       }
  string ans;
  ll maxi=dp[n][m];
  for(i=n;i>=1;i--)
    for(j=m;j>=1;j--)
    {
       if(dp[i][j]==maxi&&s[j-1]==f[i-1])  
         {
              maxi--;
              ans.pb(s[j-1]);
			  break;                    
         }
    }
   reverse(ans.begin(),ans.end()); 
  cout<<ans;
  return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    int H, W, N;
    cin >> H >> W >> N;

    vector<int> a(N);
    vector<vector<int>> c(H, vector<int>(W));

    rep(i, N) cin >> a[i];

    int h = 0, w = 0;
    rep(i, N) {
        rep(j, a[i]) {
            if (w == W) {
                w = 0;
                h++;
            }
            c[h][w] = i + 1;
            w++;
        }
    }

    /*
    rep(i, H) {
        rep(j, W) {
            cout << c[i][j];
        }
        cout << endl;
    }
    */

    rep(i, H) {
        if (i % 2 == 0) {
            rep(j, W) {
                if (j != W - 1) cout << c[i][j] << " ";
                else cout << c[i][j];
            }
        }
        else {
            rep(j, W) {
                if (j != W - 1) cout << c[i][W - j - 1] << " ";
                else cout << c[i][W - j - 1];
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=200005;
struct segtree
{
	#define lc now<<1
	#define rc now<<1|1
	int cov[MAXN*8],tag[MAXN*8],sum[MAXN*8];
	void pushup(int now,int l,int r)
	{
		if(cov[now])tag[now]=1,sum[now]=r-l+1;
		else
		{
			if(tag[lc]&tag[rc])tag[now]=1,sum[now]=r-l+1;
			else tag[now]=0,sum[now]=sum[lc]+sum[rc];
		}
	}
	void modify(int now,int l,int r,int ql,int qr,int c)
	{
		if(l==ql&&r==qr){cov[now]+=c;pushup(now,l,r);return ;}
		int mid=(l+r)/2;
		if(qr<=mid)modify(lc,l,mid,ql,qr,c);
		else if(mid+1<=ql)modify(rc,mid+1,r,ql,qr,c);
		else modify(lc,l,mid,ql,mid,c),modify(rc,mid+1,r,mid+1,qr,c);
		pushup(now,l,r);
	}
}seg;
int len[MAXN],a[MAXN],n,m;
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++)a[i]=read(),len[a[i]]++;
	for(int i=1;i<=n;i++)if(len[i])seg.modify(1,1,n,max(1,i-len[i]+1),i,1);
	while(m--)
	{
		int u=read(),x=read();
		seg.modify(1,1,n,max(1,a[u]-len[a[u]]+1),a[u],-1);
		len[a[u]]--;
		if(len[a[u]])seg.modify(1,1,n,max(1,a[u]-len[a[u]]+1),a[u],1);
		if(len[x])seg.modify(1,1,n,max(1,x-len[x]+1),x,-1);
		len[x]++;
		seg.modify(1,1,n,max(1,x-len[x]+1),x,1);
		a[u]=x;
		pr2(n-seg.sum[1]);
	}
	return 0;
}


Measured memory_bytes: 13568
S_a = list(input())
S_b = list(input())
S_c = list(input())
card = "a"
turn_dict = {"a": S_a, "b": S_b, "c": S_c}
while True:
    now = turn_dict[card]
    if not now:
        print(card.upper())
        break
    card = now.pop(0)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <stack>
#include <cmath>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <math.h>
#include <cstdlib>
#include <stdlib.h>
#include <set>
#include <unordered_set>
#include <cassert>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forn1(i, n) for (int i = 1; i <= n; ++i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll p = 997;
const ll base = 1e9 + 7;
const ll MAXN = 5e5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double PII = 3.14159265358979323846264338327950288419716939937510;
const double Epsilon = 1.19209e-9;
const ld fi = 1.6180339887498948482;
const ll one = 2147483647;
const ll two = 1e9 + 7;
void print_vectorll(vector<ll> & a) {
    forn(i, (int)a.size()) {
        cout << a[i] << " ";
    }
    cout << "\n";
}
void print_vectorint(vector<int> & a) {
    forn(i, (int)a.size()) {
        cout << a[i] << " ";
    }
    cout << "\n";
}
void read_vector(vector<ll> & a, ll n) {
    ll h;
    forn(i, n) {
        cin >> h;
        a.pb(h);
    }
}
bool check_four(int a){
  int sum = 0;
  while(a){
    sum += a % 10;
    a /= 10;
  }
  return sum % 4 == 0;
}
void upd_max(int & a, int b){
  a = max(a, b);
}
void upd_min(int & a, int b){
  a = min(a, b);
}
ll n, a, b;
bool check_sum(ll ss){
    while(ss){
        if(ss % 10 != a && ss % 10 != b){
            return false;
        }
        ss /= 10;
    }
    return true;
}
ll upd_mod(ll a, ll MOD){
    if (a > MOD){
        a %= MOD;
    }
    return a;
}
ll bin_pow(ll a, ll pow){
    if (pow == 0){
        return 1;
    }
    if (pow == 1){
        return a;
    }
    ll h = bin_pow(a, pow / 2);
    if (pow % 2 == 0){
        return upd_mod(h * h, MOD);
    }
    return upd_mod(upd_mod(h * h, MOD) * a, MOD);
}
//#define DEBUG
int main(){
    FastIO;
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
    #endif // DEBUG
    ll n;
    cin >> n;
    ll ans = 0;
    vector<int> eat(n);
    forn(i, n)cin >> eat[i];
    vector<int> score(n);
    forn(i, n)cin >> score[i];
    vector<int> add(n - 1);
    forn(i, n - 1)cin >> add[i];
    int last = -3;
    forn(i, n){
        int j = eat[i];
        ans += score[j - 1];
        if (j == last + 1){
            ans += add[last - 1];
        }
        last = j;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define Vi vector<int>
#define FOR(i,s,e) for (int i=s; i<e; i++)
#define ITER(v) v.begin(), v.end()

constexpr int MAX_LEN = 1'000;
int dp[MAX_LEN][MAX_LEN];

void set_val(int i, int j, int inc) {
    int val = inc;
    if (i > 0 && j > 0) {
        int tmp = dp[i-1][j-1] + inc;
        val = max(val, tmp);
    }
    if (i > 0) {
        int tmp = dp[i-1][j];
        val = max(val, tmp);
    }
    if (j > 0) {
        int tmp = dp[i][j-1];
        val = max(val, tmp);
    }
    dp[i][j] = val;
    //cout << i << " " << j << " " << val << endl;
}

int lcs(const string& x, const string& y) {
    int lx = x.length();
    int ly = y.length();
    for (int i=0; i<lx; ++i) {
        for (int j=0; j<ly; ++j) {
            if (x[i] == y[j]) {
                set_val(i, j, 1);
            } else {
                set_val(i, j, 0);
            }
        }
    }
    return dp[lx-1][ly-1];
}

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

    int n;
    cin >> n;

    string x, y;
    FOR(i,0,n) {
        cin >> x;
        cin >> y;
        cout << lcs(x, y) << endl;
    }

    return 0;
}

Measured memory_bytes: 7084
/*

            ░   ▒▓█  𝕿𝖆𝖑𝖐 𝖎𝖘 𝖈𝖍𝖊𝖆𝖕. 𝕾𝖍𝖔𝖜 𝖒𝖊 𝖙𝖍𝖊 𝖈𝖔𝖉𝖊 █▓▒░
   */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define ld long double
#define si(x) (ll)((x).size())
#define pb push_back
#define F first
#define S second
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>=1;i--)
#define all(x) (x).begin(), (x).end()
#define make_unique(x) (x).resize(unique(all(x))-(x).begin())
const int N = 1e2 + 7;
char g[N][N];
ll ans[N][N], x[N][N];

void solve()
{
    ll h, w;
    cin >> h >> w;

    rep1(i, h)
    rep1(j, w)
    {
        cin >> g[i][j];
        x[i][j] = (g[i][j] == '#');
        ans[i][j] = 1e9;
    }

    ans[1][1] = x[1][1];
    rep1(i, h)
    rep1(j, w)
    {
        if(x[i][j] == x[i + 1][j])
            ans[i + 1][j] = min(ans[i + 1][j], ans[i][j]);
        else
            ans[i + 1][j] = min(ans[i][j] + x[i + 1][j], ans[i + 1][j]);

        if(x[i][j] == x[i][j + 1])
            ans[i][j + 1] = min(ans[i][j + 1], ans[i][j]);
        else
            ans[i][j + 1] = min(ans[i][j] + x[i][j + 1], ans[i][j + 1]);
    }



    // rep1(i, h)
    // {
    //     rep1(j, w)
    //     cout << ans[i][j] << " ";
    //     cout << endl;

    // }

    cout << ans[h][w];


}





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(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;


    while(t--)
    {
        solve();
        cout << endl;
    }


}

Measured memory_bytes: 512
def MI(): return map(int, input().split())
def II(): return int(input())
def IS(): return input()
def LI(): return list(map(int, input().split()))


n = II()
s = list(IS())
black = [0] * 200005
black[0] = 0
counter = 0
for i in s:
    counter += 1
    if i == '#':
        black[counter] = black[counter-1] + 1
    else:
        black[counter] = black[counter-1]
mini = len(s) - black[n]
for i in range(1,n+1):
    mini = min(mini,(black[i] + n - i - (black[n] - black[i])))
print(mini)


Measured memory_bytes: 12580
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n; cin>>n; 
    vi a(n),b(n);
    for (int &i: a) cin >> i ; 
    for (int &i: b) cin >> i ; 
    int ok = 0,s=0;
    for (int i=0;i<n;i++){
        s += max(0LL,(a[i]-b[i]));
        ok += max(0LL,(b[i]-a[i])/2); 
    }
    if (ok >= s ) printf("Yes\n");
    else printf("No\n");
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3744
#include<iostream>
#include<vector>
#include<string>
#include<stdlib.h>
#include<algorithm>
#include<math.h>
using namespace std;


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

	double sum = 0;

	for (double i = 1; i <= N; i++) {
		double count = 0;

		while (i * pow(2,count) <= K-1)
			count++;

		sum += ((double)1.0 / N) * ((double)1.0 / pow(2, count));

	}

	printf("%.12f", sum);
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
n = int(input())
visited = [0]*n
dist = [0]*n
edge = [[] for _ in range(n)]
def dfs(k):
    visited[k]=1
    for i in edge[k]:
        if visited[i[0]]==0:
            dist[i[0]]=i[1]+dist[k]
            dfs(i[0])


    return dist
def main():

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

    q,k=map(int, input().split())
    #頂点kから各頂点への距離を最初に求めておくdist[i]:頂点kから頂点iまでの距離　 dist[k]=0

    visited[k-1]=1
    dist = dfs(k-1)

    res = [0]*q
    for i in range(q):
        x,y=map(int, input().split())
        res[i]=dist[x-1]+dist[y-1]


    for i in range(q):
        print(res[i])
if __name__ == '__main__':
    main()


Measured memory_bytes: 139724
# coding: utf-8
N, Y = input().split(" ")
N = int(N)
Y = int(Y)
F = Y - (1000 * N)
for x in range(int(F/9000)+1):
    y = int((F - (9000 * x)) / 4000)
    if (F - (9000 * x)) % 4000 == 0 and y >= 0 and (N - x - y) >= 0:
        print(str(x)+" "+str(y)+" "+str(N-x-y))
        break
else:
    print("-1 -1 -1")


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var R = l[0]; var G = l[1]; var B = l[2]; var n = l[3];

        var res = 0;
        for (var r = 0; 3001 > r; r++)
            for (var g = 0; 3001 > g; g++)
            {
                var b = ((n - (r * R + g * G)) % B == 0 && n - (r * R + g * G) >= 0 || n - (r * R + g * G) == 0) ? (n - (r * R + g * G)) / B : -1;
                if (b == -1) continue;
                res++;
            }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s1,s2,s3;
   while(cin>>s1>>s2>>s3)
   {
       s1[0]=s1[0]-32;
       s2[0]=s2[0]-32;
       s3[0]=s3[0]-32;
       cout<<s1[0]<<s2[0]<<s3[0]<<endl;
   }


   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main() {
  int n;
  cin >> n;
  P(n * 800 - (200 * (n / 15)));
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int a,b,t;
    cin>>a>>b>>t;
    cout<<t/a*b<<endl;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut x = vec![0; n];
    let mut y = vec![0; n];
    let mut h = vec![0; n];
    for i in 0..n {
        x[i] = iter.next().unwrap().parse().unwrap();
        y[i] = iter.next().unwrap().parse().unwrap();
        h[i] = iter.next().unwrap().parse().unwrap();
    }

    let mut t = 0;
    for i in 0..n {
        if h[i] > 0 {
            t = i;
            break;
        }
    }

    for cx in 0..101 {
        for cy in 0..101 {
            let ch = h[t] + i32::abs(cx - x[t]) + i32::abs(cy - y[t]);
            let mut ok = true;
            for i in 0..n {
                let h2 = std::cmp::max(0, ch - (i32::abs(cx - x[i]) + i32::abs(cy - y[i])));
                if h2 != h[i] {
                    ok = false;
                    break;
                }
            }
            if ok {
                println!("{} {} {}", cx, cy, ch);
                return;
            }
        }
    }
}


Measured memory_bytes: 4352
function main()
  
  (N, K) = map(x -> parse(Int, x), split(readline()))

  check = zeros(Int, N)
  
  for i in 1:K
    d = parse(Int, readline())
    A = map(x -> parse(Int, x), split(readline()))
    for i in A
      check[i] += 1
    end
  end
  
  cnt = 0
  
  for i in check
    if i == 0
      cnt += 1
    end
  end
  
  println(cnt)
  
end

main()

Measured memory_bytes: 167780
#include <stdio.h>

int main()
{
    int i,j,temp,height[10];

    for(i=0;i<10;i++)
    {
        scanf("%d", &height[i]);
    }
    for(i=0;i<10;i++)
    {
        for(j=i+1;j<=10;j++)
        {
            if(height[i] < height[j])
            {
                temp=height[i];
                height[i]=height[j];
                height[j]=temp;
            }
        }
    }
    for(i=0;i<3;i++) printf("%d\n", height[i]);
    return 0;
}

Measured memory_bytes: 600
N = input()
if len(N) == 1:
    ans = N
else:
    tmp = list(set(N))
    if len(tmp) == 1 and tmp[0] == "9":
        ans = len(N) * 9
    elif N[-1] == "9":
        ans = sum(list(map(int, N)))
    else:
        ans = 9 * (len(N) - 1) + int(N[0]) - 1
print(ans)

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    long long k;
    cin>>k;
    long long r = 7;
    if(k==7 || k==1){
        cout<<1;
        return 0;
    }
    for(int i=1; i<10000000; i++){
        r = (10*r+7) %k;
        if(r==0){
            cout<<i+1;
            return 0;
        }
    }
    cout<<-1;
    return 0;
}


Measured memory_bytes: 3688
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(i = p;i < q;i++)
#define ll long long

using namespace std;

int v, e;

int main(void) {
	cin >> v >> e;
	vector<vector<pair<int,int>>> graph(v, vector<pair<int,int>>());
	int i;
	rep(i, 0, e) {
		int s, t, w;
		cin >> s >> t >> w;
		graph[s].push_back(make_pair(w, t));
		graph[t].push_back(make_pair(w, s));
	}
	priority_queue < pair<int, int>, vector<pair<int, int>>,greater<>> queue;
	rep(i, 0, graph[0].size()) {
		queue.push(graph[0][i]);
	}

	vector<int> searched = vector<int>();
	searched.push_back(0);
	ll ans = 0;
	while (queue.size() > 0) {
		pair<int, int> edge = queue.top();
		queue.pop();
		
		if (find(searched.begin(), searched.end(), edge.second) == searched.end()) {
			ans += edge.first;
			searched.push_back(edge.second);
			rep(i, 0, graph[edge.second].size()) {
				if (find(searched.begin(), searched.end(), graph[edge.second][i].second) == searched.end()) {
					queue.push(graph[edge.second][i]);
				}

			}
		}
		
	}
	cout << ans << endl;
}


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

int main() {
  int n, M = 0, m = 0, s = 0;
  cin >> n;
  vector<int> v(n);
  for(int i = 0;i < n;i++) {
    cin >> v[i];
    if(M < v[i]) {
      m = M;
      M = v[i];
      s = 1;
    } else if(M == v[i]) {
      s++;
    } else if(m < v[i]) {
      m = v[i];
    }
  }
  if(s == 1) {
    for(int i = 0;i < n;i++) {
      if(v[i] == M) cout << m << endl;
      else cout << M << endl;
    }
  } else {
    for(int i = 0;i < n;i++) cout << M << endl;
  }
}

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

int main() {
    int x;
    cin >> x;
    if (x == 3 || x == 5 || x == 7)
    cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(a, b) for (a = 0; a < b; a++)

int main(){
  
  int H, A;
  cin >> H >> A;
  
  if (H % A == 0){
    cout << H / A << endl;
    return 0;
  } else {
    cout << H / A + 1 << endl;
    return 0;
  }
}

Measured memory_bytes: 256
n=int(input())
a=input()
b=input()
c=input()
d=0
for i in range(n):
    if a[i]==b[i] and b[i]==c[i]:
        d+=0
    elif a[i]!=b[i] and b[i]!=c[i] and a[i]!=c[i]:
        d+=2
    else:
        d+=1
print(d)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  string s;
  cin >> s;
  ll n=s.size();
  for(ll i=0;i<n;i++) {
    if(i%2==0) cout << s[i];
  }
  cout << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

string s,t;
vector<string> v;

int main(){
	cin>>s>>t;
	if(s.size()<t.size()){
		
		cout<<"UNRESTORABLE"<<endl;
		return 0;
	}
	for(int i=0;i<=s.size()-t.size();i++){
		int flag=0;
		for(int j=0;j<t.size();j++){
			if(s[i+j]!='?'&&s[i+j]!=t[j]){
				flag=1;
			}
		}
		if(flag)
			continue;
		
		string tt=s;
		tt.replace(i,t.size(),t);
		for(int j=0;j<tt.size();j++){
			if(tt[j]=='?'){
				tt[j]='a';
			}
		}
		v.push_back(tt);
	}
	if(v.empty()){
		cout<<"UNRESTORABLE"<<endl;
		return 0;
	}
	sort(v.begin(),v.end());
	cout<<v[0]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N;
    double x[11];
    string s[11];
    double sum = 0;
    
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> s[i];
        if (s[i] == "JPY") sum += x[i];
        else sum += x[i] * 380000.0;
    }
    cout << sum << endl;
}

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

using namespace std;

struct event {
    int type; // 0: start, 1: end
    int time;
    int weight;
    event(int type, int time, int weight) : type(type), time(time), weight(weight) {}
    bool operator>(const event &o) const {
        if (time == o.time) {
            return type < o.type;
        }
        return time > o.time;
    }
};

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        int w, a, b;
        priority_queue<event, vector<event>, greater<event> > events;
        for (int i = 0; i < n; i++) {
            cin >> w >> a >> b;
            events.push(event(0, a, w));
            events.push(event(1, b, w));
        }

        int curweight = 0;
        int curtime = 0;
        string ans = "OK";
        while (!events.empty()) {
            event ev = events.top(); events.pop();
            curtime = ev.time;
            if (ev.type == 0) { // start
                curweight += ev.weight;
            } else {
                curweight -= ev.weight;
            }
            if (curweight > 150) {
                ans = "NG";
                break;
            }
        }

        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF 1e9

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> d(101);
    ll m;
    REP(i, n)
    {
        cin >> m;
        d[m] = 1;
    }
    cout << accumulate(d.begin(), d.end(), 0) << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {

	var h, w, k int

	fmt.Scanf("%d %d %d", &h, &w, &k)

	val := make([][]bool, h)
	for i := 0; i < h; i++ {
		val[i] = make([]bool, w)

		var v string
		fmt.Scanf("%s", &v)
		for j, v := range v {
			if v == 35 {
				val[i][j] = true
			} else {
				val[i][j] = false
			}
		}
	}

	var ans int = 0
	for m := 0; m <= 1<<h; m++ {
		for n := 0; n <= 1<<w; n++ {

			cnt := 0
			for i := 0; i < h; i++ {
				for j := 0; j < w; j++ {
					if m>>i&1 == 0 {
						continue
					}
					if n>>j&1 == 0 {
						continue
					}
					if val[i][j] {
						cnt++
					}
				}
			}
			if cnt == k {
				ans++
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1836
Public Class Program
  Shared Sub Main()
    Dim n As Integer = Cin.Int()
    Dim a As Integer() = Cin.IntArr()
    Dim ans As String = "YES"
    Array.Sort(a)
    For i As Integer = 0 To n - 2
      If a(i) = a(i + 1) Then
        ans = "NO"
        Exit For
      End If
    Next
    Console.WriteLine(ans)
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

Measured memory_bytes: 38108