akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  int ans = 0;
  for(int i=0; i<N; i++){
    cin >> A[i];
    ans += min(K-A[i],A[i])*2;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
using namespace std;
int min(int a, int b){
    if(a < b){
        return a;
    }else{
        return b;
    }
}

int main(){
    char s[100000];
    int one = 0;
    int zero = 0;
    cin >> s;
    for(int i = 0 ; ; i++){
        if (s[i] == '1'){
            one++;
        }
        else if (s[i] == '0'){
            zero++;
        }
        else {
            break;
        }
    }
    int ans = min(one, zero) * 2;
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,t;
cin >>n >>t;
int c[n],tt[n];
int cosso=10000;
for (int i=0;i<n;i++){
cin >>c[i] >>tt[i];
if (tt[i]<=t) {
if (c[i]<=cosso) cosso=c[i];
}
}
if (cosso==10000)cout <<"TLE"<<endl;
else cout << cosso <<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
L_list = list(map(int, input().split()))

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            if L_list[i] == L_list[j] or L_list[j] == L_list[k] or L_list[k] == L_list[i]:
                continue
            if L_list[i] + L_list[j] > L_list[k] and L_list[j] + L_list[k] > L_list[i] and L_list[k] + L_list[i] > L_list[j]:
                ans += 1

print(ans)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
#include <iostream>
#define mem(f, x) memset(f, x, sizeof(f))
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;
const int M = 2*1e5 + 50;
const int N = 2*1e5 + 50;
const int MOD = 998244353;
ll m, n, k;
ll jie[N], inv[N];

ll q_pow( ll x, ll y ){ // x^y
    x %= MOD, y %= MOD;
    ll ret = 1;
    while( y ){
        if( y&1ll ) ret = ret*x%MOD;
        x = x*x%MOD;
        y >>= 1ll;
    }
    return ret%MOD;
}

void init( ){
    jie[0] = inv[0] = 1ll;
    for( int i = 1; i < N; i++ ){
        jie[i] = jie[i-1]*i%MOD;
        inv[i] = q_pow( jie[i], MOD-2 );
    }
}

ll C( ll x, ll y ){ //C(x, y)
    if( !y ) return 1;
    return ( jie[x]*inv[y]%MOD )*inv[x-y]%MOD;
}

int main( ){
    init( );
    while( scanf( "%lld %lld %lld", &n, &m, &k ) != EOF ){
        ll ret = 0;
        for( ll i = 0; i <= k; i++ ){
            ll tmp = q_pow( m-1, n-1-i );
            ret = ( ret+( C(n-1, i)*tmp%MOD ) ) %MOD;
        }
        printf( "%lld\n", ret*m%MOD );
    }
    return 0;
}


Measured memory_bytes: 6988
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def solve():
    N, D = Scanner.map_int()
    ans = 0
    for i in range(N):
        x, y = Scanner.map_int()
        if x * x + y * y <= D * D:
            ans += 1
    print(ans)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10788
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int N, W;
    cin >> N >> W;
    vector<lli> w(N);
    vector<lli> v(N);
    REP (i, 0, N) cin >> w[i] >> v[i];
    lli ww = w[0];
    REP (i, 0, N) w[i] -= ww;
    lli best = 0;
    vector<lli> cost[4];
    REP (i, 0, N) cost[w[i]].push_back(v[i]);
    REP (i, 0, 4) sort(cost[i].begin(), cost[i].end(), greater<lli>());
    vector<lli> sumcost[4];
    REP (i, 0, 4) {
        sumcost[i].push_back(0);
        REP (j, 0, cost[i].size()) {
            sumcost[i].push_back(sumcost[i][j] + cost[i][j]);
        }
    }

    REP (n, 0, N + 1) {
        lli score = W - n * ww;
        REP (x, 0, n + 1) REP (y, 0, n + 1) REP (z, 0, n + 1) {
            int t = n - x - y - z;
            if (t < 0 || t > n) continue;
            if (x <= cost[0].size() && y <= cost[1].size() && z <= cost[2].size() && t <= cost[3].size()) {
                lli s = y + 2 * z + 3 * t;
                if (s <= score) {
                    lli temp = sumcost[0][x] + sumcost[1][y] + sumcost[2][z] + sumcost[3][t];
                    best = max(best, temp);
                }
            }
        }
    }
    cout << best << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <stack>
using namespace std;

#define INF 1e18
#define int long long
#define MAX 200010

signed main() {
    int n, k; cin >> n >> k;
    int cnt[MAX];
    for(int i = 0; i < MAX; i++) cnt[i] = 0;
    for(int i = 0; i < n; i++) {
        int a; cin >> a;
        cnt[a]++;
    }

    int sum = 0;
    for(int i = 1; i <= MAX; i++) {
        if(cnt[i] > 0) sum++;
    }

    int res = 0;
    if(sum > k) {
        sort(cnt, cnt + MAX);
        for(int i = 1; i <= MAX && sum != k; i++) {
            if(cnt[i] > 0) {
                sum--;
                res += cnt[i];
            }
        }
    }

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


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
	int width;
	int height;
	int x, y, r;
	char input[30];
	
	fgets(input, sizeof(input), stdin);
	width = atoi(strtok(input, " "));
	height = atoi(strtok(NULL, " "));
	x = atoi(strtok(NULL, " "));
	y = atoi(strtok(NULL, " "));
	r = atoi(strtok(NULL, " "));
	
	if ((x - r) < 0 || (y - r) < 0){
		printf("No\n");
		return 0;
	}else if ((x + r) > width || (y + r) > height){
		printf("No\n");
		return 0;
	}else{
		printf("Yes\n");
	}

	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<ll,ll>;
#define For(i,a,b)  for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF (2e9)
#define EPS (1e-6)
#define int ll
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<endl;}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif
void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
	INIT();
	//code...
	int n; cin>>n;
	cout<<(n>=30?"Yes":"No")<<"\n";
	return 0;
}

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

int main() {
    long long N, S;
    cin >> N >> S;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    vector<long long> dp(S+1);
    dp[0] = 1;
    for (int i = 0; i < N; ++i) {
        vector<long long> p(S+1);
        swap(dp, p);
        for (int j = 0; j < S+1; ++j) {
            dp[j] += p[j] * 2;
            dp[j] %= 998244353;
            if (j + A[i] <= S) {
                dp[j + A[i]] += p[j];
                dp[j + A[i]] %= 998244353;
            }
        }
    }

    cout << dp[S] << endl;
    return 0;
}

Measured memory_bytes: 3224
#include<iostream>
#include<cmath>


using namespace std;


int main(){
    long long A,B,N,answer;
    cin >> A >> B >> N;
    if(N>=B) answer=floor(A*(B-1)/B);
    else answer = floor((A*N)/B);
    cout <<answer<< endl;
    return 0;
}


Measured memory_bytes: 3620
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int sum,matrix[20][20],n,m,dp[20][1<<15],num[1<<15];
int main(){
	fastio;
	cin>>n>>m;
	rb(i,1,m){
		int u,v,c;
		cin>>u>>v>>c;
		u--;
		v--;
		matrix[u][v]=matrix[v][u]=c;
		sum+=c;
	}
//	cout<<sum<<endl;
	rep(i,1<<n){
		if(i==0) continue;
		int las=i&(i-1);
		num[i]=num[las];
		int now;
		rep(j,n)
		{
			if(i&(1<<j)){
				now=j;
				break;
			} 
		}
//		cout<<i<<" "<<now<<endl;
		rep(j,n)
			if(las&(1<<j)){
				num[i]+=matrix[now][j];
			}
	}
	memset(dp,-0x3f,sizeof(dp));
	dp[0][1]=0;
	int tmp=0;
	rep(mask,1<<n){
		if(mask)
		rep(i,n)
		{
			if(mask&(1<<i))
			{
			rep(j,n){
					//上一个顶点
					if(mask&(1<<j))
					if(matrix[i][j]) 
					dp[i][mask]=max(dp[i][mask],dp[j][mask-(1<<i)]+matrix[i][j]); 
				}
			for(int nmask=mask;;nmask=(nmask-1)&mask){
				if(nmask&(1<<i));
				else
				dp[i][mask]=max(dp[i][mask],dp[i][mask^nmask]+num[nmask|(1<<i)]);
				if(!nmask)  break;
			}
			}
			if(mask==(1<<n)-1){
//				cout<<dp[i][mask]<<endl;
				if(i==n-1)
				tmp=max(tmp,dp[i][mask]);
			}
		}
	}
	cout<<sum-tmp<<endl;
	return 0;
}


Measured memory_bytes: 2944
import heapq
x,y,z,k = list(map(int, input().split())) 
a = sorted(list(map(int, input().split())),reverse=True)
b = sorted(list(map(int, input().split())),reverse=True)
c = sorted(list(map(int, input().split())),reverse=True)

ans = []
log = set()

total = (a[0] + b[0] + c[0]) * (-1)
heapq.heappush(ans, (total, 0, 0, 0))
log.add((0, 0, 0))

for i in range(k):
  (total, aa, bb, cc) = heapq.heappop(ans)
  print(total * (-1))
  if (aa+1, bb, cc) not in log:
    if aa+1 < x:
      total = (a[aa+1] + b[bb] + c[cc]) * (-1)
      heapq.heappush(ans, (total, aa+1, bb, cc))
      log.add((aa+1, bb, cc))
  if (aa, bb+1, cc) not in log:
    if bb+1 < y:
      total = (a[aa] + b[bb+1] + c[cc]) * (-1)
      heapq.heappush(ans, (total, aa, bb+1, cc))
      log.add((aa, bb+1, cc))
  if (aa, bb, cc+1) not in log:
    if cc+1 < z:
      total = (a[aa] + b[bb] + c[cc+1]) * (-1)
      heapq.heappush(ans, (total, aa, bb, cc+1))
      log.add((aa, bb, cc+1))

Measured memory_bytes: 4976
#include<stdio.h>
int main(){
	int i,j,H,W;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0){
			break;
		}
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1000
#include <iostream>

using namespace std;

int main() {

	int h1 = 0, m1 = 0, h2 = 0, m2 = 0, t = 0;
	cin >> h1 >> m1 >> h2 >> m2 >> t;
	cout << (h2 * 60 + m2) - (h1*60 + m1) - t;
	return 0;
}

Measured memory_bytes: 3604
A=int(input())
B=int(input())
C=int(input())
X=int(input())

cnt = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500 * i + 100 * j + 50 * k == X:
                cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int sum = 0;
    int a[100010];
    rep(i, N) cin >> a[i];
    rep(i, N) {
        sum += max(0LL, a[i]);
    }
    int ans = 0;
    int tmp1 = 0, tmp2 = 0;
    rep(i, K) {
        tmp1 -= max(0LL, a[i]);
        tmp2 += a[i];
    }
    rep(i, N - K + 1) {
        ans = max(ans, sum + tmp1 + max(0LL, tmp2));
        //cout << sum << " " << tmp1 << " " << tmp2 << endl;
        tmp1 += max(0LL, a[i]);
        tmp1 -= max(0LL, a[K + i]);
        tmp2 -= a[i];
        tmp2 += a[K + i];
        
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1024
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const N = parseInt(args[0][0], 10)
	if (Math.floor(N / 90) === 1 || N % 10 === 9) console.log('Yes')
	else console.log('No')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 9420
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << (x) << '\n'

using namespace std;
using Graph = vector<vector<int>>;

typedef int64_t Int;
const double pi = M_PI;

int main() {
    int N;
    string S;
    cin >> N >> S;

    int ans = 0;
    char integ[10] = {};
    for (int i = 0; i < 10; i++) {
        integ[i] = i + '0';
    }

    for (auto i : integ) {
        for (auto j : integ) {
            for (auto k : integ) {
                queue<char> digits;
                digits.push(i);
                digits.push(j);
                digits.push(k);

                for (auto n : S) {
                    if (!digits.empty() && digits.front() == n) {
                        digits.pop();
                    }
                }

                if (digits.empty()) {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    [n, k] <- map read.words <$> getLine :: IO [Int]
    xs <- U.unfoldrN n (B.readInt.B.dropWhile isSpace) <$> B.getLine
    print $ solve n k xs

solve :: Int -> Int -> U.Vector Int -> Int
solve n k xs = foldl' max (f 0) $ f k:f(clearBit k 1):[g i | i<-[0..63], testBit k i]
  where
    f x = U.sum $ U.map (xor x) xs
    g i = f $ foldl' (.|.) (k .&. complement (shiftL 1 (i + 1) - 1))
        [bool 0 (bit j) $ fj < n - fj | j<-[0..i-1], let !fj = freq U.! j]

    !freq = U.generate 64 $ \i -> do
        U.length . U.filter (flip testBit i) $ xs

Measured memory_bytes: 8744
#include<stdio.h>
//#include<stdlib.h>

void mergesort(int[],int,int);
void merge(int[],int,int,int);
int cnt = 0;

int main(){

  int S[1000000];
  int i,j;
  
  scanf("%d",&i);
 
  // S=(int *)malloc(i*sizeof(int));

  for(j = 0; j < i; j++){
    scanf("%ld",&S[j]);
  }

  mergesort(S,0,i);
  
  for(j = 0; j < i; j++){
   
    printf("%ld",S[j]);
    if(j < i-1){
      printf(" ");
    }
  }
  printf("\n%ld\n",cnt);
  
  //free(S);
  return 0;
}


void mergesort(int A[],int left,int right){

  int mid;
  
  if(left+1 < right){
    mid = (left + right)/2;
    mergesort(A,left,mid);
    mergesort(A,mid,right);
    merge(A,left,mid,right);
  }
  }


void merge(int A[],int left,int mid,int right){
  int n1,n2,i,j,k;
  int L[mid - left];
  int R[right - mid];

   n1 = mid - left;
  n2 = right - mid;

  for(i = 0; i < n1; i++){
    L[i] = A[left + i];
  }

  for(i = 0; i < n2; i++){
    R[i] = A[mid + i];
  }

  L[n1] = 999999999;
  R[n2] = 999999999;
  i = 0;
  j = 0;
  for(k = left; k < right; k++){
    if(L[i] < R[j]){
      A[k] = L[i];
      i++;
    }else{
      A[k] = R[j];
      j++;
    }
    cnt++;
  }
}



Measured memory_bytes: 5608
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 2e5+7;
const ll mod = 1e9+7;
int a[N];
int n;
ll ans;
ll cal(int b)
{
    ll ret=0;
    for(int i=1;i<=n;i++)
        ret+=abs(a[i]-b);
    return ret;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++){
        a[i]-=i;
    }
    sort(a+1,a+1+n);
    ans=cal(a[(n+1)>>1]);
    printf("%lld\n",ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B; 
  cin >> N >> A >>B  ; 
  if(A*N > B){  
  cout << B <<endl;
  }
  else if (A*N < B){
  cout << A*N <<endl;
  }
    else{
    cout << B <<endl;
    }
}

Measured memory_bytes: 256
function main(input) {
  const args = input.split('\n');
  const A = parseInt(args[0]); const B = parseInt(args[1]);
  const C = parseInt(args[2]); const X = parseInt(args[3]);
  
  var cnt = 0;
  for (var a = 0; a <= A; ++a) {
    for (var b = 0; b <= B; ++b) {
      for (var c = 0; c <= C; ++c) {
        var x = 500*a + 100*b + 50*c;
        if (x === X) {
          ++cnt;
        }
      }
    }
  }
  console.log(cnt);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if(a >= k) {
    cout << k << endl;
  }
  else if(a + b >= k) {
    cout << a << endl;
  }
  else {
    cout << a - (k - a - b) << endl;
  }
}

Measured memory_bytes: 3632
H, W = map(int, input().split())
path = []
for i in range(H):
    path.append(input())
dp = [[0 for i in range(W+1)] for j in range(H+1)]
for i in range(1, H+1):
    if path[i-1][0] == "#":
        break
    else:
        dp[i][1] = 1
for i in range(1, W+1):
    if path[0][i-1] == "#":
        break
    else:
        dp[1][i] = 1
for i in range(1, H):
    for j in range(1, W):
        if path[i][j] == "#":
            dp[i+1][j+1] = 0
        else:
            dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j]) % 1000000007
print(dp[H][W])


Measured memory_bytes: 53980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
ll f(ll a,ll b,ll x){
    return (a*x)/b-a*(x/b);
}
int main(void){
    ll a,b,n;
    cin>>a>>b>>n;
    if(n<b)cout<<f(a,b,n);
    else cout<<f(a,b,b-1);
}

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

int main(){
//srandom((unsigned long)time(NULL));
int n,m;
cin>>n>>m;
int an,am;
if(n<1) an=0;
else an=(n*(n-1))/2;
if(m<1) am=0;
else am=(m*(m-1))/2;

cout<<an+am<<endl;

return 0;
}

Measured memory_bytes: 256
import sys 
from itertools import accumulate
from bisect import bisect_left
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = map(int, readline().split())
A = list(map(int,readline().split()))
A = sorted(A)
S = [0] + list(accumulate(A[::-1]))

def solve(mid):
    cnt_all = 0
    for a in A:
        cnt = N-bisect_left(A,mid-a)
        cnt_all += cnt   
    if cnt_all < M:
        return True
    else:
        return False
left = 0
right = 10**6

while right-left > 1:
    mid = (right+left) // 2
    flag = solve(mid)
    if flag:
        right = mid
    else:
        left = mid

ans = 0 
all_cnt = 0
for a in A:
    cnt = N-bisect_left(A,left-a)
    all_cnt += cnt
    ans += S[cnt]
    ans += cnt*a
    
count = all_cnt-M
ans -= count*left
print(ans)

    

Measured memory_bytes: 20004
import java.util.*;
public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
    	while(true) {
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            
            if(m == -1 && f == -1 && r == -1) break;
            
            if(m == -1 || f == -1) System.out.println("F");
            else if(m + f >= 80) System.out.println("A");
            else if(m + f >= 65) System.out.println("B");
            else if(m + f >= 50 || r >= 50) System.out.println("C");
            else if(m + f >= 30) System.out.println("D");
            else System.out.println("F");
    	}
    }
}



Measured memory_bytes: 26364
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    while (true) {
        int n, x;
        scan(n, x);

        if (n == 0 && x == 0) return;

        auto ans = solve(n, x);
        writeln(ans);
    }
}

int solve(int n, int x) {
    int ans;

    foreach (i ; 1 .. n + 1) {
        foreach (j ; i + 1 .. n + 1) {
            foreach (k ; j + 1 .. n + 1) {
                if (i + j + k == x) ans++;
            }
        }
    }

    return ans;
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}



Measured memory_bytes: 2492
import sys
sys.setrecursionlimit(300000)

N, M = map(int, input().split())
A = []
B = []
P = [[] for _ in range(N)]
C = [[] for _ in range(N)]
for i in range(N-1+M):
    a, b = map(int, input().split())
    C[a-1].append(b-1)
    P[b-1].append(a-1)


# print(P)
# print(C)

dp = [-1] * N
def calc(i):
    if dp[i] >= 0:
        return dp[i]
    if not P[i]:
        dp[i] = 0
        return 0
    ma = -1
    for p in P[i]:
        ma = max(ma, calc(p))
    dp[i] = ma+1
    return ma+1

for i in range(N):
    calc(i)

for i in range(N):
    if dp[i] == 0:
        print(0)
    else:
        for p in P[i]:
            if dp[p] == dp[i] - 1:
                print(p+1)
                break
                


Measured memory_bytes: 91280
#include<iostream>
using namespace std;
int main(){
long n,i,j,p[10001];
while(cin>>n){
if(n==0)break;
p[1]=0;
for(i=2;i<=n;i++)p[i]=1;
for(j=4;j<n;j+=2)p[j]=0;
for(i=3;i<=n;i+=2){
if(p[i]==1){
for(j=i*i;j<=n;j+=i)p[j]=0;
}
}
for(i=n;i>=4;i--)if(p[i]==1&&p[i-2]==1)break;
cout<<i-2<<" "<<i<<endl;
}
return 0;
}

Measured memory_bytes: 1236
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let k: usize = read();

    println!("{}", (n % k != 0) as u32);
}


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

int main(){
    std::map<std::string, std::vector<int> > ind;
    while (true){
        std::string s;
        int n;
        std::cin>>s>>n;
        if(std::cin.fail())break;
        ind[s].push_back(n);
    }
    for (auto &i : ind) {
        std::cout<< i.first<<std::endl;
        std::sort(i.second.begin(),i.second.end());
        for (size_t j = 0; j < i.second.size()-1; ++j) {
            std::cout<< i.second[j]<<" ";
        }
        std::cout<< i.second[i.second.size()-1]<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 3200
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int h = sc.nextInt();
        int w = sc.nextInt();
        int k = sc.nextInt();
        int count = 0;
        int i,j;
        int ans = 0;
        String aa,bb;
        String hw[][] = new String[h][k];
        String check[] = new String[6];
        String check2[] = new String[6];
      
        for(i = 0;i < h;i++){
          hw[i] = sc.next().split("");
        }
      
        int retu = (int)Math.pow(2,h);
        int gyou = (int)Math.pow(2,w);
      
		for(i = 0;i < retu;i++){
          for(j = 0;j < gyou;j++){
			count = 0;
            
            for(int tate = 0;tate < h;tate++){
              for(int yoko = 0;yoko < w;yoko++){
                if(hw[tate][yoko].equals("#") && ((i >> tate) & 1) == 0
                  && ((j >> yoko) & 1) == 0){
                  count += 1;
                }
              }
            }
            if(count == k){
              ans += 1;
            }
            
            
          }
        }
        
        
        System.out.println(ans);
               
    }
}

Measured memory_bytes: 36600
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
from fractions  import gcd


n,k=map(int,input().split())
inf = 0
m=300001
num_min =2**(m-1).bit_length()
dat=[inf]*(2*num_min-1)

#初期化

#親のノード(n-1)//2
#子のノード2n+1,2n+2

def segfunc(x,y):
    return max(x,y)

def update(i,x):
    i+=num_min-1
    dat[i]=x
    while i>0:
        i=(i-1)//2
        dat[i]=segfunc(dat[2*i+1],dat[2*i+2])
def query(a,b): #半開区間、[a,b)の最小値
    if b<=a:
        return inf
    res=inf
    a += num_min-1
    b += num_min-2
    while b-a>1:
        if a&1==0:
            res = segfunc(res,dat[a])
        if b&1==1:
            res = segfunc(res,dat[b])
            b-=1
        a=a//2
        b=(b-1)//2
    if a==b:
        res = segfunc(res,dat[a])
    else:
        res=segfunc(segfunc(res,dat[a]),dat[b])
    return res

ans=0
for i in range(n):
    x=int(input())
    l=max(0,x-k)
    r=min(300000,x+k)
    tmp=query(l,r+1)+1
    ans=max(tmp,ans)
    update(x,tmp)
print(ans)

Measured memory_bytes: 125212
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
struct data{
    int a,b;
};

//小さい順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}


int main(){
    int X,Y;
    scanf("%d%d",&X,&Y);
    int a[Y];
    for(int i=0;i<Y;i++){
        scanf("%d",&a[i]);
    }
    int j=0;
    while(1){
        int cnt1=0,cnt2=0;
        for(int i=0;i<Y;i++){
            if((X-j)!=a[i])
                cnt1++;
        }
        if(cnt1==Y){
            printf("%d",X-j);
            return 0;
        }
        for(int i=0;i<Y;i++){
            if((X+j)!=a[i])
                cnt2++;
        }
        if(cnt2==Y){
            printf("%d",X+j);
            return 0;
        }
        j++;
    }
}


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

int main(){
	int n;
	string s;
	cin>>n>>s;
	int west[n+1]={0};
	int east[n+1]={0};
	for(int i=0; s[i]; i++){
		if(s[i]=='W') west[i+1] = 1;
		else east[i+1] = 1;
	}
	for(int i=1; i<=n; i++){
		west[i]+=west[i-1];
		east[i]+=east[i-1];
	}
	int minchange = n;
	for(int i=1; i<=n; i++){
		int change = west[i-1]+(east[n]-east[i]);
		minchange = min(minchange,change);
	}
	cout<<minchange;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> x(n), l(n);
  vector<pair<ll, ll>> y;
  for(int i = 0; i < n; i++){
    cin >> x.at(i) >> l.at(i);
    y.push_back(make_pair(x.at(i) + l.at(i), x.at(i) - l.at(i)));
  }
  
  sort(y.begin(), y.end());
  
  ll now = -1e15, ans = 0;
  for(int i = 0; i < n; i++){
    if(y.at(i).second >= now){
      now = y.at(i).first;
      ans++;
    }
  }
  
  cout << ans << '\n';
}

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

int main(){
    string s; cin >> s;
    if(s.at(3) == s.at(2) && s.at(4) == s.at(5)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
/****************************************************************
# @Author:      iLovePKU_zbtxdy
# @DateTime:    2020-01-27 11:55:12
# @Description: You build it. You run it
# @More: Once lots of AC, try Brute-force,dynamic programming
****************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define close std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define eps 1e-8
typedef long long ll;
const int maxn = 1e6+10;
const int INF = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
ll mod = 1e9+7;
ll mod_pow(ll x, ll n ,ll mod){
	ll res = 1;
	while(n > 0){
		if(n & 1)res = res *x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}
ll invf[maxn], fac[maxn] = {1};
void fac_inv_init(int n , int p){
    for(int i = 1; i < n;i++){
        fac[i] = i * fac[i-1] % p;
    }invf[n-1] = mod_pow(fac[n-1], p-2 , p);
    for(int i = n-2; i >= 0; i--){
        invf[i] = invf[i+1] * (i+1) % p;
    }
}
ll C(ll n , ll m){
    return n < m || m < 0 ? 0 : fac[n]*invf[m]%mod*invf[n-m]%mod;
}
int32_t main()
{
    int h , w , a , b ;
    cin >> h >> w >> a >> b;
    fac_inv_init(maxn, mod);
    int ans = 0;
    for(int i = 1; i <= h-a; i++){
        ans = (ans + C(b+i-2,i-1)*C(w+h-b-i-1,w-b-1))%mod;
    }cout << ans << endl;
    //system("pause");
}
/***************************************************************************
*stuff you should look for
*int overflow, array bounds
*special cases (n=1?), set tle
*do smth instead of nothing and stay organized
***************************************************************************/

Measured memory_bytes: 15872
#include <iostream>
#include <string>

using namespace std;

int main() {
    int N;
    cin >> N;
    for (int i=0; i<N; i++) {
        string a, b;
        cin >> a >> b;
        int sum, ret=0;
        if (a.length() < b.length()) swap(a,b);
        int l = b.length()-1;
        for (int i=a.length()-1; i>=0; i--) {
            if (l >= 0) {
                sum = (a[i]-'0')+(b[l]-'0')+ret;
                l--;
            } else {
                sum = (a[i]-'0')+ret;
            }
            if (sum>=10) {
                ret = 1;
                sum -= 10;
            } else {
                ret = 0;
            }
            a[i] = sum+'0';
        }
        if (ret != 0) {
            a.insert(a.begin(), ret+'0');
        }
        if (a.length() > 80) cout << "overflow" << endl;
        else cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cmath>
#include<cstdint>
//#include<>
using namespace std;

typedef int64_t i64;typedef int32_t i32;
typedef int16_t i16;typedef int8_t i8;
typedef uint64_t ui64;typedef uint32_t ui32;
typedef uint16_t ui16;typedef uint8_t ui8;


typedef i32 int__;
#define rep(i,j) for(int__ i=0;i<j;i++)
#define repeat(i,j,k) for(int__ i=(j);i<(k);i++)
#define repeat_eq(i,j,k) for(int__ i=(j);i<=(k);i++)
#define all(v) begin(v),end(v)

typedef vector< vector<i32> > Mat;
typedef pair<i32,i32> pii;


const i32 INF=1<<30;//=10E10
const i32 dx[9]={1,1,1,1,1,2,2,2,3};
const i32 dy[9]={2,1,0,-1,-2,1,0,-1,0};


int W,H;
vector< vector<i32> > G;
vector<int> sx,sy,gx,gy;

struct state{
  int y,x;
  int cost;
  bool foot;
  state(int y_,int x_ ,int c,bool f):y(y_),x(x_),cost(c),foot(f){;}
  bool operator<(const state &r)const{return cost<r.cost;}
  bool operator>(const state &r)const{return cost>r.cost;}  
};


vector< vector<i32> > dist[2];

void dijkstra(){
  priority_queue< state ,vector<state>,greater<state> > que;

  rep(i,2)dist[i].resize(H,vector<i32>(W,INF));

  rep(i,sx.size()){
    que.push(state(sy[i],sx[i],0,true));
    que.push(state(sy[i],sx[i],0,false));
  }

  while(!que.empty()){
    state now=que.top();que.pop();
    if(dist[now.foot][now.y][now.x]<INF)continue;
    dist[now.foot][now.y][now.x]=now.cost;

    rep(i,9){
      i32 nx=now.x + dx[i]*(now.foot? 1:-1);
      i32 ny=now.y+dy[i];
      if(0<=nx && nx<W && 0<=ny && ny<H){
	if(G[ny][nx]<INF)
	  que.push(state(ny,nx,now.cost+G[ny][nx],!now.foot));
      }
    }   
  }
  
}


int main()
{
  while(1){
    G.clear();
    dist[0].clear();
    dist[1].clear();
    sx.clear();
    sy.clear();
    gy.clear();
    gx.clear();
    
  cin>>W>>H;
  if(W==0)break;
  G.resize(H,vector<int>(W,INF));
  
  rep(y,H)rep(x,W){
    char s;
    cin>>s;
    if(s=='S'){
      sx.push_back(x);
      sy.push_back(y);
      G[y][x]=0;
    }
    else if(s=='T'){
      gx.push_back(x);
      gy.push_back(y);
      G[y][x]=0;
    }
    else if(s=='X')G[y][x]=INF;
    else G[y][x]=s-'0';
  }
  
  dijkstra();

  int ans=INF;
  
  rep(i,gx.size()){
    ans=min(ans,dist[0][gy[i]][gx[i]]);
    ans=min(ans,dist[1][gy[i]][gx[i]]);
  }
  
  cout<<(ans>=INF ? -1 : ans)<<endl;

  } 
  return 0;
}

Measured memory_bytes: 1364
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;



int main(){
    ll distance = 5'000'000'000'000'000;
    string S;cin>>S;
    ll K;cin>>K;
    for(int i = 0; i < S.size(); i++)
    {   ll expo = distance+1;
        ll tmp = (long long)(S[i]-'0');
        K -= pow(tmp,expo);
        if (K<=0){
            cout<<S[i]<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <numeric>
#include <vector>
#include <regex>

using namespace std;
using ll = long long;
template<typename T> void print(T t) {cout << t << endl;}


int main() {
	int N, ans = 0, s;
	vector<int> not10;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s;
		ans += s;
		if (s % 10 != 0) not10.push_back(s);
	}

	sort(not10.begin(), not10.end());
	if (ans % 10 == 0) {
		if (not10.empty()) {
			print(0);
		}
		else {
			print(ans - not10[0]);
		}
	}
	else {
		print(ans);
	}
}

Measured memory_bytes: 3604
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<map>
#include<vector>
#include<queue>
using namespace std;
const int MAXN=(int)1e5;
const int INF=(int)1e9;
int n_pnt,n_edg,cnt;
map<int,int> ID[MAXN+5];
int input[2*MAXN+5][3];
vector<pair<int,int> > lnk[5*MAXN+5];
int dist[5*MAXN+5];
bool vis[5*MAXN+5];
int main()
{
	scanf("%d%d",&n_pnt,&n_edg);
	cnt=n_pnt+1;
	for(int i=0;i<n_edg;i++)
	{
		int u,v,c;scanf("%d%d%d",&u,&v,&c);
		input[i][0]=u;input[i][1]=v;input[i][2]=c;
		if(!ID[u].count(c)) ID[u][c]=cnt++;
		if(!ID[v].count(c)) ID[v][c]=cnt++;
		lnk[ID[u][c]].push_back(make_pair(ID[v][c],0));
		lnk[ID[v][c]].push_back(make_pair(ID[u][c],0));
	}
	for(int i=1;i<=n_pnt;i++)
		for(map<int,int>::iterator it=ID[i].begin();it!=ID[i].end();it++)
		{
			int id=it->second;
			lnk[i].push_back(make_pair(id,1));
			lnk[id].push_back(make_pair(i,1));
		}
	fill(dist,dist+5*MAXN+5,INF);
	dist[1]=0;vis[1]=true;
	queue<int> que;que.push(1);
	while(!que.empty())
	{
		int u=que.front();que.pop();
		for(int i=0;i<lnk[u].size();i++)
		{
			int v=lnk[u][i].first,l=lnk[u][i].second;
			if(dist[v]>dist[u]+l)
			{
				dist[v]=dist[u]+l;
				if(!vis[v])
					vis[v]=true,que.push(v);
			}
		}
		vis[u]=false;
	}
	if(dist[n_pnt]==INF) printf("%d\n",-1);
	else printf("%d\n",dist[n_pnt]/2);
	return 0;
}

Measured memory_bytes: 58752
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long m,n,i,j,res,arr[55],arr1[55],c[55],d[55],mini=1000000000000000,mini1=2000000,in=0;
   cin>>m>>n;

   for(i=0;i<m;i++)
   {

       cin>>arr[i]>>arr1[i];

   }
    for(i=0;i<n;i++)
    {

        cin>>c[i]>>d[i];

    }


    for(i=0;i<m;i++)
    {
        mini=1000000000000000;
        for(j=0;j<n;j++)
        {
            res=abs(arr[i]-c[j])+abs(arr1[i]-d[j]);

            if(mini>res)
            {

                mini=res;
                in=j;
            }
        }
        cout<<in+1<<endl;


    }



  return 0;
}


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

int main(){
  int n,al=0,bo=0;cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  reverse(all(a));
  rep(i,n)i%2==0?al+=a[i]:bo+=a[i];
  cout << al-bo;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,a[300000],s;
    cin>>n;
    for(int i=1;i<=3*n;i++) cin>>a[i];
    sort(a+1,a+1+3*n);
    s=0;
    for(int i=(3*n)-1;i>=n+1;i-=2) s+=a[i];
    cout<<s;
}

Measured memory_bytes: 2560
import sys

N = int(input())
now = [0]*3
for i in range(N):
    a, b, c = map(int, input().split())
    val0 = a-now[0]
    val1 = abs(b-now[1]) + abs(c-now[2])
    
    while val1 < val0:
        val1 += 2
    if val1 != val0:
        print('No')
        sys.exit()
    now = [a, b, c]
print('Yes')
    


Measured memory_bytes: 9040
x1,y1,x2,y2 = map(float, raw_input().split())

q = int(raw_input())
for _ in xrange(q):
  x,y = map(float, raw_input().split())
  if x1 == x2:
    print "%f %f" % (x1*2-x, y)
  elif y1 == y2:
    print "%f %f" % (x, y1*2-y)
  else:
    a0 = (y2 - y1) / (x2 - x1)
    b0 = y1 - a0 * x1
    ap = -1 / a0
    bp = y - ap * x
    xe = (bp - b0) / (a0 - ap)
    ye = a0 * xe + b0
    xe = xe + (xe - x)
    ye = ye + (ye - y)
    print "%.12f %.12f" % (xe, ye)

Measured memory_bytes: 6484
#include <bits/stdc++.h>
using namespace std;
const double INF = 1e12;

// computational complexity : O(E*logV)

struct edge{ int to; double cost; };

int V,E;// number of (vertices, edges)
vector<vector<edge>> graph;
vector<double> d;// shortest distances

void Dijkstra(int s){// s = starting point
    priority_queue<
        pair<double, int>// temporarily keeping (shortest distance, vertex)
        , vector<pair<double, int>>, greater<pair<double, int>>// shorter ones first
    > pq;

    // initialize (INF)
    for(int i=0; i<V; i++){
        d[i] = INF;
    }
    d[s] = 0;
    pq.push({0,s});

    // search
    pair<double, int> current;// (shortest-distance confirmed, vertex)
    while(!pq.empty()){
        current = pq.top(); pq.pop();

        int v = current.second;
        if(d[v] < current.first){
            continue;// ignore (not the shortest path)
        }
        // else (need to check)
        for(edge e : graph[v]){// adjacent nodes
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;// update minimum cost
                pq.push({d[e.to], e.to});
            }
        }
    }
}

struct circle{ int x, y, r; };

int main(){
    int xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;

    cin >> V;
    V += 2;
    graph.resize(V);
    d.resize(V);

    vector<circle> barrier(V);
    barrier[0]   = {xs, ys, 0};
    barrier[V-1] = {xt, yt, 0};
    for(int i=1; i<=V-2; i++){
        cin >> barrier[i].x >> barrier[i].y >> barrier[i].r;
    }

    for(int i=0; i<V; i++){
        for(int j=i+1; j<V; j++){
            long long int xi = barrier[i].x;
            long long int yi = barrier[i].y;
            long long int ri = barrier[i].r;
            long long int xj = barrier[j].x;
            long long int yj = barrier[j].y;
            long long int rj = barrier[j].r;

            long long int dist = (xj - xi) * (xj - xi) + (yj - yi) * (yj - yi);

            double w = max(0., sqrt(dist) - ri - rj);
            graph[i].push_back({j, w});
            graph[j].push_back({i, w});
            //cout << i << " " << j << " " << w << endl;
        }
    }

    Dijkstra(0);
    cout << fixed << setprecision(12) << d[V-1] << endl;
    return 0;
}

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

int main() {
  string b;
  cin >> b;
  string ans;

  if(b=="A") ans='T';
  if(b=="T") ans='A';
  if(b=="G") ans='C';
  if(b=="C") ans='G';

  cout << ans << endl;
  


  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
par=[-1 for i in range(n)]    #par<0なら自身が親で要素の個数、>0なら子で親の位置示す

def root(a):
    if par[a]<0:
        return a
    else:
        return root(par[a])

def size(a):
    return -par[root(a)]

def connect(a,b):
    a=root(a)
    b=root(b)
    if a==b:
        return False
    if size(a)<size(b):
        a,b=b,a
    par[a]+=par[b]
    par[b]=a
    return True

a=[]
for i in range(m):
    a.append([int(j)-1 for j in input().split()])

ans=0
for i in range(m):
    par=[-1 for i in range(n)] 
    for j in range(m):
        if j==i:
            continue
        if root(a[j][0])!=root(a[j][1]):
            connect(a[j][0],a[j][1])
    if -1*min(par)!=n:
        ans+=1
print(ans)




Measured memory_bytes: 3064
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      long D = sc.nextLong();
      long[] X = new long[N];
      long[] Y = new long[N];
      for(int i = 0; i < N; i++){
        X[i] = sc.nextLong();
        Y[i] = sc.nextLong();
      }
      
      // 判定
      int count = 0;
      D = D*D;
      for(int i = 0; i < N; i++){
        long dist = X[i]*X[i] + Y[i]*Y[i];
        if(dist <= D){
          count++;
        }
      }
      
      
      // 出力
      System.out.println(count);
    }

}

Measured memory_bytes: 64188
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a=ii()
b=int(math.sqrt(a))
for i in range(b):
  if a%(b-i)==0:
    print(int(a/(b-i))+b-i-2)
    sys.exit()



Measured memory_bytes: 3572
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::collections::VecDeque;

fn dijkstra(sn: usize, map: &Vec<Vec<(usize, i64)>>, dist: &mut Vec<i64>) {
    // cn, pn
    let mut q: VecDeque<(usize, usize)> = VecDeque::new();
    q.push_back((sn, 0));
    while !q.is_empty() {
        let cn = q.pop_front().unwrap();
        // println!("cn: {:?}", cn);
        for i in 0..map[cn.0].len() {
            let mi = map[cn.0][i];
            if mi.0 == cn.1 {
                continue;
            }
            if mi.1 + dist[cn.0] < dist[mi.0] {
                dist[mi.0] = mi.1 + dist[cn.0];
            }
            q.push_back((mi.0, cn.0));
        }
    }
}

fn main() {
    let n: usize = read();
    let mut map: Vec<Vec<(usize, i64)>> = vec![vec![]; n + 1];

    for _ in 0..n - 1 {
        let a: usize = read();
        let b: usize = read();
        let c: i64 = read();
        map[a].push((b, c));
        map[b].push((a, c));
    }
    let q: usize = read();
    let k: usize = read();
    let mut set: Vec<(usize, usize)> = vec![];
    for _ in 0..q {
        let x: usize = read();
        let y: usize = read();
        set.push((x, y));
    }
    let mut dist: Vec<i64> = vec![std::i64::MAX; n + 1];
    dist[k] = 0;
    dist[0] = 0;
    dijkstra(k, &map, &mut dist);
    // println!("{:?}", dist);
    for i in 0..q {
        let si = set[i];
        println!("{}", dist[si.0] + dist[si.1]);
    }
}


Measured memory_bytes: 22780
n,k = map(int,input().split())

if k == 0:
    G = []
    for i in range(1,n):
        for j in range(i+1,n+1):
            G.append((i,j))
    print(len(G))
    for u,v in G:
        print(u,v)
    exit(0)

if k-(n-1)*(n-2)//2 > 0:
    print(-1)
    exit(0)

G = []
for i in range(1,n):
    G.append((i,n))

count = (n-1)*(n-2)//2-k
for i in range(1,n-1):
    for j in range(i+1,n):
        if count == 0:
            print(len(G))
            for u,v in G:
                print(u,v)
            exit(0)
        G.append((i,j))
        count -= 1


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

using namespace std;
#define sync   freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);freopen("error.txt","w",stderr);
#define ll long long

int main(){
	// sync;
	ll n,w;
	cin>>n>>w;
	vector<ll >dp(w+1,0);
		ll wt,p;
	for(int i=0;i<n;i++){
		cin>>wt>>p;
		for(int j=w;j>=wt;--j){
				dp[j]=max(dp[j],dp[j-wt]+p);
		}
	}
		
		cout<<dp[w]<<endl;
}

Measured memory_bytes: 4052