akhauriyash/Code-Regression huggingface dataset:
def main():
    N,M=map(int,input().split())
    L=2**N
    dp=[10**8 for i in range(L)]
    dp[0]=0


    for i in range(M):
        a, _ = map(int, input().split())
        key=sum([2**(int(i)-1) for i in input().split()])
        for j in range(L):
                q=j|key
                dp[q]=min(dp[j]+a,dp[q])


    ans=dp[L-1]
    print(ans if ans<10**8 else -1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
    int a, b, c, ans;
    cin >> a >> b >> c;
    ans = 0;
    for ( int i = a; i <= b; i++ ){
        if (c % i == 0) ans++;
    }

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



Measured memory_bytes: 3120
N=int(input())
A=[]
min_x=10**9+1
min_y=10**9+1
B=[0 for i in range(N)]
C=[0 for i in range(N)]
for i in range(N):
    x,y=map(int,input().split())
    A.append([x,y])
    min_x=min(min_x,x)
    min_y=min(min_y,y)
for i in range(N):
    A[i][0]=A[i][0]-min_x
    A[i][1]=A[i][1]-min_y
    B[i]=A[i][0]+A[i][1]
    C[i]=A[i][0]-A[i][1]
print(max(max(B)-min(B),max(C)-min(C)))

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

int main() {
  int A, B;
  cin >> A >> B;
  bool flg = false;
  int result;
  for (int i = 1; i < 1001; ++i) {
    int r1 = i * 0.08;
    int r2 = i * 0.1;
    if (A == r1 && B == r2) {
      result = i;
      break;
    } else if (A == r1 || B == r2) {
      flg = true;
    } else if (flg && A != r1 && B != r2) {
      result = -1;
      break;
    }
  }
  cout << result << endl;
}

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

using namespace std;

// z[i] = len of lcp of s, s[i..]; lcp(longest common prefix)
vector<int> z_fn(const string& s) {
    int n = s.size();
    vector<int> z(n, 0);
    for (int i = 1, l = 0, r = 0; i < n; i++) {
        if (i <= r)
            z[i] = min(r-i+1, z[i-l]);
        while (i+z[i] < n && s[z[i]] == s[i+z[i]]) {
            z[i]++;
        }
        if (i+z[i]-1 > r) {
            l = i; r = i+z[i]-1;
        }
    }
    return z;
}

const int N = 2e5+10; 
const int L = 30; 
bool ok[N][L];
void solve() {
    int n; cin >> n;
    vector<int> a(n), b(n);
    for (auto& x: a) {
        cin >> x;
    }
    for (auto& x: b) {
        cin >> x;
    }
    for (int i = 0; i < L; i++) {
        for (int _ = 0; _ < 2; _++) {
            string s; s.reserve(3*n);
            for (int x:b) s.push_back((x>>i&1) ^ _);
            for (int x:a) s.push_back(x>>i&1);
            for (int x:a) s.push_back(x>>i&1);
            auto z = z_fn(s);
            for (int k = 0; k < n; k++) {
                if (z[n+k] >= n) ok[k][i] |= true;
            }
        }
    }
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < L; i++) {
            if (!ok[k][i]) goto fail;
        }
        cout << k << ' ' << (a[k]^b[0]) << "\n";
fail:;;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 13836
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a>=b && c>=d){
    cout<<b+d<<endl;
  }
  else if(a<b && c>=d){
    cout<<a+d<<endl;
  }
  else if(a>=b && c<d){
    cout<<b+c<<endl;
  }
  else{
    cout<<a+c<<endl;
  }
  return 0;
}
    


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
#include <assert.h>
#include <queue>

using namespace std;

int main()
{
    int diff = 0;
    string S, T;
    cin >> S >> T;
    for(int i = 0; i < S.size(); i++)
    {
        if(S.substr(i,1) != T.substr(i,1))
            diff++;
    }

    cout << diff << "\n";
}

Measured memory_bytes: 3896
N,P = map(int,input().split())
A = list(map(int,input().split()))
C = {0:0,1:0}
for i in range(N):
    if A[i]%2==0:
        C[0] += 1
    else:
        C[1] += 1
if P==0:
    if C[1]==0:
        n = 2**C[0]
    else:
        n = 2**C[0]*2**(C[1]-1)
else:
    if C[1]==0:
        n = 0
    else:
        n = 2**C[0]*2**(C[1]-1)
print(n)

Measured memory_bytes: 38384
L = input()
N = len(L)
MOD = 10 ** 9 + 7

# dp[i][j]: (a,b)の組の個数
# i: 決定した桁数
# j: a + b < L[i] フラグ
dp = [[0] * 2 for _ in range(N + 1)]

dp[0][0] = 1

# 配るDP
for i in range(N):
    for j in range(2):
        # (a, b) = (0, 0)
        if int(L[i]): # 1
            dp[i + 1][1] = (dp[i + 1][1] + dp[i][j]) % MOD
        else: # 0
            dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD
        
        # a ^ b = 1
        if int(L[i]) or j:
            dp[i+1][j] = (dp[i+1][j] + dp[i][j] * 2) % MOD

print(sum(dp[N]) % MOD)

Measured memory_bytes: 19672
import math
import sys

a, b, c = map(int, input().split())
k = int(input())

for i in range(k):
    if (not (b > a)):
        b *= 2
    elif (not (c > b)):
        c *= 2

if (c > b and b > a):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9176
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

string s;

int main() {
    //freopen("in.txt", "r", stdin);
    
    cin >> s;
    s += 'Q';
    
    FOR (i,0,s.size()-1)
    {
        if (s[i] == 'A' && s[i+1] == 'C')
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		sc.close();

		if (n % 2 == 1) {
			System.out.println("No");
			return;
		}

		int n2 = n / 2;
		for (int i = 0; i < n2; i++) {
			if (s.charAt(i) != s.charAt(i + n2)) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>

using namespace std;

typedef long long ll;

#define rep(i, N) for (ll i = 0; i < (ll)(N); ++i)

int main(void){
    ll H,W;
    cin >> H >> W;
    if(H == 1||W == 1){
        cout << 1 << endl;
    }else{
    cout << (H * W + 1)/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
fib=[0,1]
for i in range(100000):
  fib.append(fib[-1]+fib[-2])
  
n,m=map(int,input().split())
hoge=[-1]
ans=1
for i in range(m):
  hoge.append(int(input()))
hoge.append(n+1)

for i in range(len(hoge)-1):
  if(hoge[i+1]-hoge[i]==1):
    print(0)
    exit()
    
for i in range(len(hoge)-1):
  sa=hoge[i+1]-hoge[i]-1
  ans=ans*fib[sa]
  ans=ans%1000000007
print(ans)

Measured memory_bytes: 464164
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,d,i,x,y;
    while(cin>>n>>d)
    {
        long long int c=0;
        for(i=0;i<n;i++)
        {
            cin>>x>>y;
            double  dis = sqrt((double)(x*x)+double(y*y));
            if(dis<=d)
                c++;
        }
        cout<<c<<endl;
    }
}


Measured memory_bytes: 3680
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int x,y;
    cin>>x>>y;
    int ok = false;
    for (int t = 0; t <= x; t++) {
        int k = x - t;
        if (2 * t + 4 * k == y) {
            ok = true;
            break;
        }
    }
    (ok)? cout<<"Yes":cout<<"No";
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    int x = a+b;
    if(x%3==0||a%3==0||b%3==0) cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	char imgN[n][n];
	char imgM[m][m];
	int i,j;
	char s[100];
	for(i=0;i<n;i++){
		scanf("%s",s);
		strcpy(imgN[i],s);
	}
	for(i=0;i<m;i++){
		scanf("%s",s);
		strcpy(imgM[i],s);
	}
	
	//n>=m
	int k,l;
	
	int existMinN;
	for(i=0;i<=n-m;i++){
		for(j=0;j<=n-m;j++){
			existMinN=1;
			for(k=0;k<m;k++){
				for(l=0;l<m;l++){
					if(imgM[k][l]!=imgN[k+i][l+j]){
						existMinN=0;
						break;
					}
				}
				if(existMinN==0){
					break;
				}
			}
			if(existMinN==1){
				break;
			}
		}
		if(existMinN==1){
			//printf("i:%d j:%d\n",i,j);
			break;
		}
	}
	
	if(existMinN){
		puts("Yes");
	}else{
		puts("No");
	}
	
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

double dist(pii a, pii b){
    return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second));
}
int main(){
    int n;
    cin >> n;
    vector<pii> a(n);
    for(auto& i : a) cin >> i.first >> i.second;
    vector<int> perm(n);
    iota(perm.begin(), perm.end(), 0);
    double ans = 0;
    do{
        for(int i = 0; i < n - 1; i++){
            ans += dist(a[perm[i]], a[perm[i + 1]]);
        }
    }while(next_permutation(perm.begin(), perm.end()));
    for(int i = 1; i <= n; i++) ans /= i;
    cout << fixed << setprecision(20) << ans << endl;
}




Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <functional>
using namespace std;

/** 東西の幅 */
int w;
#define W 100
/** 南北の幅 */
int h;
#define H 100
/** 見取り図 */
char map[ W ][ H ];

/** 指定された座標が範囲内かを判定する */
#define nanikaka(X,Y) \
  ( (X) >= 0 && (X) < w && (Y) >= 0 && (Y) < h )

/** 速度x 座標 */
#define VN 4
const int vx[ VN ] = { -1,  1,  0,  0 };
const int vy[ VN ] = {  0,  0, -1,  1 };

/** 重み付き座標 */
struct point
{
  int x;
  int y;
  int weight;

  point (
    int x,
    int y,
    int weight
    )
  {
    this->x      = x;
    this->y      = y;
    this->weight = weight;
  }

  bool
  operator> (
    const point &p
    )
  const
  {
    return ( weight > p.weight );
  }
};

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    priority_queue<point, vector<point>, greater<point> > lis;

    /* 基本情報読み込み */
    scanf ( " %d %d", &w, &h );
    if ( w == 0 && h == 0 ) break ;

    /* 見取り図読み込み */
    for ( i = 0; i < h; ++i )
    for ( j = 0; j < w; ++j )
    {
      scanf ( " %c", &map[ j ][ i ] );

      /* 天守閣を検出したら探索開始点として記録 */
      if ( map[ j ][ i ] == '&' )
      {
        map[ j ][ i ] = '.';
        lis.push ( point ( j, i, 0 ) );
      }
    }

    /* 天守閣から城外方向に堀優先探索 */
    while ( !lis.empty ( ) )
    {
      const point pt = lis.top ( );
      lis.pop ( );

      /* 城外に到達したら処理終了 */
      if ( !nanikaka ( pt.x, pt.y ) )
      {
        printf ( "%d\n", pt.weight );
        break ;
      }
      /* 既に探索済みなら処理しない */
      if ( map[ pt.x ][ pt.y ] == '&' )
        continue ;

      /* 隣接座標の探索を予約．堀脱出な移動には重みを加算． */
      for ( i = 0; i < VN; ++i )
      {
        const int nx = pt.x + vx[ i ];
        const int ny = pt.y + vy[ i ];
        lis.push ( point ( nx, ny, pt.weight + !!( nanikaka ( nx, ny )
                                                && map[ pt.x ][ pt.y ] != '#'
                                                && map[ nx ][ ny ] == '#' ) ) );
      }
      /* 探索済みのマークをつける */
      map[ pt.x ][ pt.y ] = '&';
    }
  }

  return ( EXIT_SUCCESS );
}

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

int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i=0;i<N;i++) cin >> A[i];
   
    int C[N];
    int sum1=0;
    for(int i=0;i<N;i++) {
        int b;
        cin >> b;
        sum1 += b;
    }

    for(int i=0;i<N-1;i++) cin >> C[i];

    int sum2 =0;

    for(int i=0;i<N-1;i++){
        if(A[i]+1 == A[i+1]) sum2 += C[A[i]-1];;
    }

    cout << sum1 + sum2 <<endl;

}

Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	headerLine := strToIntSlice(scanner.Text())
	n, m, c := headerLine[0], headerLine[1], headerLine[2]

	scanner.Scan()
	bLine := strToIntSlice(scanner.Text())

	correctCount := 0
	for i := 0; i < n; i++ {
		scanner.Scan()
		aLine := strToIntSlice(scanner.Text())
		if calcCode(m, aLine, bLine, c) > 0 {
			correctCount++
		}
	}
	
	fmt.Println(correctCount)
}

func strToIntSlice(line string) []int {
	strSlice := strings.Split(line, " ")

	var intSlice []int
	for _, str := range strSlice {
		intValue, _ := strconv.Atoi(str)
		intSlice = append(intSlice, intValue)
	}

	return intSlice
}

func calcCode(m int, aLine []int, bLine []int, c int) int {
	result := 0;
	for i := 0; i < m; i++ {
		result += aLine[i] * bLine[i]
	}
	result += c
	return result
}

Measured memory_bytes: 640
#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()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const int MOD = 1e9+7;

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK) 
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}

int main()
{
   ll n;
   cin >> n;
   vector<ll> a(n);
   map<ll,ll> mp;
   rep(i,n)cin >> a[i];
   
   rep(i,n)
   {
      ll k = a[i];
      ll foo,hoge=0;
      for(ll j=2;j*j<=a[i];j++)
      {  
         if(k%j!=0)continue;
         hoge=0;
         foo=j;
         while(k%j==0)
         {
            k/=j;
            hoge++;
         }
         //cout<<hoge<<endl;
         mp[foo] = max(mp[foo],hoge);
      }
      mp[k] = max(mp[k],1LL);
   }
   ll L=1;
   for( auto i = mp.begin(); i != mp.end() ; ++i ) 
   {
      rep(j,i->second)
      {
      L *= i->first;
      L %= MOD;
      }
   }
   //cout<<L<<endl;
   ll ans = 0;
   rep(i,n)
   {
      ans += L*modinv(a[i],MOD)%MOD;
      ans %= MOD;

   }
   cout<<ans<<endl;


   return 0;
}

Measured memory_bytes: 896
#include <iostream>

int findText(std::string text, std::string oldText){
	int times = 0, pos = 0;
	while(pos = text.find(oldText, pos), pos != std::string::npos){
		pos++, times++;
	}
	return times;
}

int main(){
	std::string s;
	while(std::cin >> s, !std::cin.eof()){
		std::cout << findText(s, "JOI") << std::endl;
		std::cout << findText(s, "IOI") << std::endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

constexpr ll LNF = 1LL<<60;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m,x; cin >> n >> m >> x;
    int ans = INF;
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));
    rep(i,0,n){
        cin >> c[i];
        rep(j,0,m) cin >> a[i][j];
    }
    rep(bit,0,1<<n){
        vector<int> p(m,0);
        int q = 0;
        rep(i,0,n){
            if(bit & (1<<i)){
                q += c[i];
                rep(j,0,m){
                    p[j] += a[i][j];
                }
            }
        }
        int flag = 1;
        rep(i,0,m){
            if(p[i]<x){
                flag = 0;
                break;
            } 
        }
        if(flag) chmin(ans,q);
    }
    if(ans>=INF){
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
} 

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e11;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    ll n,k,h;
    vector<ll> m;
    cin >> n >> k;
    rep(i,n){
        cin >> h;
        m.push_back(h);
    }
    SORT(m);
    ll c = 0;
    if (n <= k) PRINT(0);
    else{
        rep(i,n-k) c += m[i];
        PRINT(c);
    }
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if((a>=1 && a<=9) && (b>=1 && b<=9))
       {
           cout<<(a*b);
       }
       else{
        cout<<-1;
       }
       return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <stdio.h>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <queue>
#include <string>
#include <map>
#include <cmath>
#include <iostream>
using namespace std;

struct Point {
    int x;
    int y;

    Point(int x, int y) {
        this->x = x;
        this->y = y;
    }
};

Point grid[] = {
    Point(0, 1),
    Point(1, 0)
};

int main() {
    int N;
    cin >> N;
    vector<vector<int> > candy(2, vector<int>(N));
    vector<vector<int> > map(2, vector<int>(N, 0));

    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < N; j++) {
            cin >> candy.at(i).at(j);
        }
    }

    queue<Point> queue;
    queue.push(Point(0, 0));
    map.at(0).at(0) = candy.at(0).at(0);

    while(!queue.empty()) {
        Point point = queue.front();
        queue.pop();

        for(int i = 0; i < 2; i++) {
            int x = point.x + grid[i].x;
            int y = point.y + grid[i].y;

            if(x >= N || y >= 2) {
                continue;
            } else if(map.at(y).at(x) < map.at(point.y).at(point.x) + candy.at(y).at(x)) {
                map.at(y).at(x) = map.at(point.y).at(point.x) + candy.at(y).at(x);
                queue.push(Point(x, y));
            }
        }
    }
    
    /*
    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < N; j++) {
            printf("%d ", map.at(i).at(j));
        }
        printf("\n");
    }
    */

    printf("%d\n", map.at(1).at(N-1));
    return 0;
}

Measured memory_bytes: 256
#AtCoder 星には四種類の塩基 A, C, G, T が存在し、A と T、C と G がそれぞれ対になります。
#文字 b が入力されます。これは A, C, G, T のいずれかです。塩基 b と対になる塩基を表す文字を出力するプログラムを書いてください。

b = input()

if b == 'A':
    print('T')
elif b == 'T':
    print('A')
elif b == 'C':
    print('G')
elif b == 'G':
    print('C')

Measured memory_bytes: 8968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100002;
int fa[N],x[N],y[N],sz[N],i,n,m;
ll now,ans[N];
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int rd(){
    int x=0,fl=1;char ch=gc();
    for (;ch<48||ch>57;ch=gc())if(ch=='-')fl=-1;
    for (;48<=ch&&ch<=57;ch=gc())x=(x<<3)+(x<<1)+(ch^48);
    return x*fl;
}
inline void wri(ll a){if(a<0)a=-a,putchar('-');if(a>=10)wri(a/10);putchar(a%10|48);}
inline void wln(ll a){wri(a);puts("");}
int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}
void uni(int x,int y){
	int rx=find(x),ry=find(y);
	if (rx!=ry){
		now-=1ll*sz[rx]*sz[ry];
		fa[rx]=ry,sz[ry]+=sz[rx];
	}
}
int main(){
	n=rd(),m=rd();
	for (i=1;i<=m;i++) x[i]=rd(),y[i]=rd();
	for (i=1;i<=n;i++) fa[i]=i,sz[i]=1;
	now=1ll*n*(n-1)/2;
	for (i=m;i;i--){
		ans[i]=now;
		uni(x[i],y[i]);
	}
	for (i=1;i<=m;i++) wln(ans[i]);
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;

typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


int main(){
    ll n,x;
    cin >> n >> x;
    vector<ll>a(n);
    rep(i,n)cin >> a[i];
    sort(a.begin(),a.end());
    for(int i=1;i<n;i++){
        a[i]+=a[i-1];
    }
    ll cnt = -1;
    for(int i=0;i<n;i++){
        if(a[i]>x){
            cnt = i;
            break;
        }
    }
    if(cnt==-1){
        if(a[n-1]==x){
            cout << n << endl;
        }else{
            cout << n-1 << endl;
        }  
    }else{
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
ll d,g;
int main(void) {
    cin >> d >> g;
    ll task[d][2];
    vector<ll> perm;
    rep(i,d){
        cin >> task[i][0] >> task[i][1];
    }
    rep(i,d){
        perm.push_back(i);
    }
    ll res=1LL<<60;
    do {
        ll sum=0,cnt=0;
        for(auto x:perm){
            if(sum+(x+1)*100*task[x][0]+task[x][1]>=g){
                cnt+=min((g-sum-1)/((x+1)*100)+1,task[x][0]);
                if(res>cnt)res=cnt;
                break;
            }
            cnt+=task[x][0];
            sum+=(x+1)*100*task[x][0]+task[x][1];
        }
    }while(next_permutation(perm.begin(),perm.end()));
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define INF 100000


int A[N][N],n;

int Prims(){
  int i,j,u,v,cost[N][N],dis;
  int visit[N],no_edges,min_cost,distance[N],from[N];

  for(i=0;i<n;i++) for(j=0;j<n;j++) if(A[i][j]==-1) cost[i][j]=INF;
      else cost[i][j]=A[i][j];

  distance[0]=0;
  visit[0]=1;

  for(i=0;i<n;i++){
    distance[i]=cost[0][i];
    from[i]=0;
    visit[i]=0;
  }

  min_cost=0;
  no_edges=n-1;

  while(no_edges>0){
    dis=INF;
    for(i=1;i<n;i++){
      if(visit[i]==0 && distance[i]<dis){
	v=i;
	dis=distance[i];
      }
    }
    u=from[v];
    no_edges--;
    visit[v]=1;
    for(i=1;i<n;i++){
      if(visit[i]==0 && cost[i][v]<distance[i]){
	distance[i]=cost[i][v];
	from[i]=v;
      }
    }
    min_cost+=cost[u][v];
  }

  return min_cost;
}



int main(){
  int i,j;

  scanf("%d", &n);

  for(i=0;i<n;i++) for(j=0;j<n;j++) scanf("%d",&A[i][j]);

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



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

#define chmin(x, y) x = min(x, y)

// 入力
int n;
vector<long long> a;
// dp[left][right] := 区間 [left,right) におけるコストの最小値
vector<vector<long long>> dp(405, vector<long long>(405, -1));
// スライムの大きさの累積和
long long S[405];

// メモ化再帰
long long memo_rec(int left, int right){
    if(dp[left][right] != -1)   return dp[left][right];
    if(right - left == 1)   return dp[left][right] = a[left];

    long long res = numeric_limits<long long>::max();
    for(int pos = left + 1; pos < right; ++pos){
        long long tmp = 0;
        if(pos - left > 1)  tmp += memo_rec(left, pos) + S[pos] - S[left];
        else    tmp += memo_rec(left, pos);
        if(right - pos > 1) tmp += memo_rec(pos, right) + S[right] - S[pos];
        else    tmp += memo_rec(pos, right);
        chmin(res, tmp);
    }
    return dp[left][right] = res;
}

int main(){
    cin >> n;
    a.resize(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        S[i+1] = S[i] + a[i];
    }
    cout << memo_rec(0, n) << endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int INF = 1e9 +7;

int main(){
    float n;
    cin >> n;
    vector<float> a(n);
    REP(i, n){
        cin >> a[i];
    }

    float tmp, ans = 0;
    REP(i, n){
        tmp = 1 /a[i];
        ans += tmp;
    }

    float real_answer = 1 / ans;
    cout << real_answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <queue>
#include <cstring>
using namespace std;

#define PII pair<int, int>
#define A first
#define B second
#define MP make_pair
#define ll long long

const int YEAR = 2019;
int num[2][YEAR];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s; cin >> s;
    ll ans = 0;
    int cur = 0;
    num[cur][0] = 1;
    for (int i=0; i<s.size(); i++) {
        int now = s[i]-'0';
        for (int j=0; j<YEAR; j++) {
            num[cur][((j*10)+now)%YEAR] = num[!cur][j];
        }
        num[cur][now]++;
        ans += num[cur][0];
        cur = !cur;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3364
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define N 100005

struct Edge{
  int u, v, w;
}edge[N];

bool cmp(Edge a, Edge b) {
  return a.w < b.w;
}

int p[N], sub[N], ans[N];
LL val[N];

int root(int u) {
  while(u != p[u]) {
    p[u] = p[p[u]];
    u = p[u];
  }
  return u;
}
void merge(int uu, int vv, int wt) {
  int u = root(uu), v = root(vv);
  if (u == v) {
    if (val[u] < wt) ans[u]++;
    return;
  }
  p[v] = u;
  sub[u] += sub[v];
  val[u] += val[v];
  if (wt * 1LL <= val[u]) {
    ans[u] = 0;
  } else ans[u] = ans[u] + ans[v] + 1;
}

int main() {
  int n, i, m;
  cin >> n >> m;
  for (i=1;i<=n;i++) {
    cin >> val[i];
    p[i] = i;
    sub[i] = 1;
    ans[i] = 0;
  }
  for (i=0;i<m;i++) {
    cin >> edge[i].u >> edge[i].v >> edge[i].w;
  }
  sort(edge, edge + m, cmp);
  for (i=0;i<m;i++) {
    merge(edge[i].u, edge[i].v, edge[i].w);
  }
  int res = 0;
  for (i=1;i<=n;i++) if (p[i] == i) res += ans[i];
  cout << res << '\n';

  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;

const int MAX_N = 110;
const int MAX_V = 100100;

int N;
long long W, weight[MAX_N], value[MAX_N];
long long dp[MAX_N][MAX_V];

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];
    for (int i = 0; i < MAX_N; ++i) for (int j = 0; j < MAX_V; ++j) dp[i][j] = INF;
    dp[0][0] = 0;

    for (int i = 0; i < N; ++i) {
        for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {
            if (sum_v - value[i] >= 0) chmin(dp[i + 1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
            chmin(dp[i + 1][sum_v], dp[i][sum_v]);
        }
    }

    long long res = 0;
    for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {
        if (dp[N][sum_v] <= W) res = sum_v;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 86272
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

        StringTokenizer tokenizer = new StringTokenizer(input.readLine());

        StringBuilder output = new StringBuilder();

        while (tokenizer.hasMoreTokens())
            output.append(tokenizer.nextToken().charAt(0));

        System.out.println(output);
    }
}


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

#define pb push_back
#define mp make_pair
#define size(n) ( int( n.size() ) )
#define sqr(n) ( (n) * (n) )
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 2e5 + 5;

set < int > s[N];

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n, m;
    scanf("%d %d",&n,&m);
    int v, u;
    for ( int i = 1; i <= m; i++ ){
        scanf("%d %d",&v,&u);
        s[v].insert(u);
        s[u].insert(v);
    }
    int res = 0;
    for ( int i = 2; i <= n - 1; i++ ){
        if ( s[i].find(1) != s[i].end() && s[i].find(n) != s[i].end() ){
            res = 1;
        }
    }
    if (res){
        puts("POSSIBLE");
    }
    else{
        puts("IMPOSSIBLE");
    }
    return 0;
}




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

int main(){
  int N;
  cin >> N;
  bool n =true;
  for (int i=0;i<N;i++){
    int A;
    cin >> A;
    if (A%2==1){
      continue;
    }
    else{
      if(A%3==0||A%5==0){
        continue;
      }
      else{
        n = false;
        break;
      }
    }
  }
  if(n){
    cout << "APPROVED" << endl;
  }
  else{
    cout << "DENIED" << endl;
  }
}


Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    d = list()
    a = list()
    for i in range(k):
        d.append(int(input()))
        a.append(list(map(int, input().split())))

    kids = [0]*n

    for aa in a:
        for aaa in aa:
            kids[aaa-1] = 1

    print(n-sum(kids))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9192
#include <cstdio>
#include <algorithm>

int n, m, q, ans;
int a[55], b[55], c[55], d[55], t[15];

inline int sum() {
    int ans = 0;
    for (int i = 1; i <= q; ++i)
        if (t[b[i]] - t[a[i]] == c[i])
            ans += d[i];
    return ans;
}

void dfs(int x) {
    if (x == n + 1) {
        ans = std::max(ans, sum());
        return;
    }
    for (int i = t[x - 1]; i <= m; ++i) {
        t[x] = i;
        dfs(x + 1);
    }
}

int main() {
    scanf("%d%d%d", &n, &m, &q);
    for (int i = 1; i <= q; ++i) scanf("%d%d%d%d", a + i, b + i, c + i, d + i);
    t[0] = 1;
    dfs(1);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#define ll long long
#define add push_back
 
using namespace std; 


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

    int t;  t = 1; //cin >> t;
    while(t--){
        char ch; cin >> ch;
        if(ch >= 'a' && ch <= 'z')
            cout << "a" << endl;
        else    
            cout << "A" << endl;
    }
    return 0;
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
#define ll long long
ll a[600000], b[600000], dp[102][100005];

int main()
{
    IO;
    ll j, n, m, k, m1, m2, a1, a2, l  = 1, t, cnt=0, mn, h=0, mod=1e15, i; int tc=0;
    cin>>n>>m;
    for(i = 1; i<=n; i++) cin>>a[i]>>b[i];
    for(i = 1; i<=1e5; i++) dp[0][i]=mod;
    for(i=1; i<=n; i++)
    for(j=1; j<=1e5; j++){
        dp[i][j]=min(dp[i-1][j],((j-b[i])<0 ? mod : dp[i-1][j-b[i]])+a[i]);
    }
    for(i = 1e5; i>=0; i--)
         if(dp[n][i]<=m) {j = i; break; }
    cout<<j<<endl;
    return 0;
}


Measured memory_bytes: 82176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

map<string,bool> adj = {
    {"AB", true},
    {"AD", true},
    {"BA", true},
    {"BC", true},
    {"BE", true},
    {"CB", true},
    {"CF", true},
    {"DA", true},
    {"DE", true},
    {"DG", true},
    {"EB", true},
    {"ED", true},
    {"EF", true},
    {"EH", true},
    {"FC", true},
    {"FE", true},
    {"FI", true},
    {"GD", true},
    {"GH", true},
    {"HE", true},
    {"HG", true},
    {"HI", true},
    {"IF", true},
    {"IH", true}
};

int main() {
    string s;
    for (int i=0; i<1000; ++i) {
        cin >> s;
        bool ok = true;
        for (int i=1; i<(int)s.size(); ++i) {
            if ( ! adj[s.substr(i-1, 2)]) {
                ok = false;
                break;
            }
        }
        if (ok) cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
int A[100010];
int main(){
    int n, k, q;
    cin >> n >> k >> q;
    int c=q;
    while(c--){
        int a;
        cin >> a;
        A[a]++;
    }
    for(int i=1; i <= n; i++){
        if(k-q+A[i] > 0)    cout << "Yes" << endl;
        else    cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

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

        while (sc.hasNext()) {
            String S = sc.next();

            List<Integer> distance = new ArrayList<>();
            for (int i = 0; i < 10; i++) {
                distance.add(Integer.valueOf(S.split(",")[i]));
            }

            int vs = Integer.parseInt(S.split(",")[10]);
            int ve = Integer.parseInt(S.split(",")[11]);

            double h = (double)distance.stream().mapToInt(Integer::intValue).sum() / (vs + ve); // 0.1
            double d = vs * h; // 4

            double count = 0;
            for (int i = 0; i < 10; i++) {
                count += distance.get(i);

                if (count >= d) {
                    System.out.println(i + 1);
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 31768
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while( true ){
			String str = scan.nextLine();
			int circle = 0;	//?????¬??§????????¬??§??§+1????????¬??§??§-1???
			int block = 0;	//?§???¬??§????????¬??§??§+1????????¬??§??§-1???
			boolean ok = true;
			char[] nowRead = new char[100];
			int k = 0;
			if( str.charAt(0) == '.' ){
				break;
			}
			for( int i = 0; i < str.length(); i++ ){
				char c = str.charAt(i);
				if( c == '(' ){
					circle++;
					k++;
					nowRead[k] = '(';
					continue;
				}
				if( c == ')' ){
					circle--;
					if( circle < 0 || nowRead[k] != '(' ){
						ok = false;
						break;
					}
					nowRead[k] = '\0';
					k--;
					continue;
				}
				if( c == '[' ){
					block++;
					k++;
					nowRead[k] = '[';
					continue;
				}
				if( c == ']' ){
					block--;
					if( block < 0 || nowRead[k] != '[' ){
						ok = false;
						break;
					}
					nowRead[k] = '\0';
					k--;
					continue;
				}
			}
			if( ok && circle == 0 && block == 0 ){
				System.out.println("yes");
			}else{
				System.out.println("no");
			}
		}
		return;
	}
}

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

using namespace std;

const string key = "keyence";

int main() {
    string S;
    cin >> S;
    int N = S.length();

    int fore, back;
    for (fore = 0; fore < 7; ++fore) {
        if (S[fore] != key[fore]) break;
    }

    for (back = 0; back < 7; ++back) {
        if (S[N - back - 1] != key[6 - back]) break;
    }

    cout << (fore + back >= 7 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, dif = 0, tmp;
  cin >> N;
  vector<int> arr(N);
  for(int i = 0; i < N; i++) cin >> arr.at(i);
  
  for(int i = N - 1; i > 0; i--){
    for(int j = 0; j < i; j++){
      if(arr.at(j) <= arr.at(j + 1)){
        tmp = arr.at(j + 1);
        arr.at(j + 1) = arr.at(j);
        arr.at(j) = tmp;
      }
    }
  }
  for(int i = 0; i < N; i++){
    if(i % 2 == 0) dif += arr.at(i);
    else dif -= arr.at(i);
  }
  
  cout << dif << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int A[N+1], B[N];
    for (int i=0; i<(N+1); i++) {
        cin >> A[i];
    }
    for (int i=0; i<N; i++) {
        cin >> B[i];
    }

    long count = 0;
    for (int i=0; i<N; i++) {
        if (B[i] < A[i]) {
            count += B[i];
        } else {
            count += A[i];
            if ((B[i]-A[i]) < A[i+1]) {

                count += (B[i] - A[i]);
                A[i+1] -= (B[i] - A[i]);
            } else {
                count += A[i+1];
                A[i+1] = 0;
            }
        }
    }

    cout << count << "\n";

}

Measured memory_bytes: 1024
import java.io.*;
import java.io.IOException;
import java.util.*;
import java.util.stream.LongStream;

@SuppressWarnings({"rawtypes", "unchecked"})
class Main {
    final static int INF = 1 << 28;
    final static long LNF = 1L << 60;
    final static double EPS = 1e-9;
    final static double GOLDEN_RATIO = (1.0 + Math.sqrt(5)) / 2.0;

    static final long MOD = 1_000_000_007;

    public static void main(String[] args) throws Exception {
        final MyScanner sc = new MyScanner();
        long N;
        N = sc.nextLong();
        long[] A = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                A[i] = sc.nextLong();
        }
        solve(N, A);
    }

    static void solve(long N, long[] A){
        long[] noDuplicates = LongStream.of(A).distinct().toArray();
        System.out.println(noDuplicates.length % 2 == 0 ? noDuplicates.length - 1 : noDuplicates.length);
    }


    static class MyScanner {
 
        BufferedReader br;
        StringTokenizer st;
 
        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }
 
        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        String next() {
            return nn();
        }

        String nextLine() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }
 
        char nextChar() {
            return nn().charAt(0);
        }
 
        int nextInt() {
            return Integer.parseInt(nn());
        }
 
        long nextLong() {
            return Long.parseLong(nn());
        }
 
        double nextDouble() {
            return Double.parseDouble(nn());
        }
 
        Integer[] niArr0(int n) {
            Integer[] ar = new Integer[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Integer[] niArr1(int n) {
            Integer[] ar = new Integer[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Long[] nlArr0(int n) {
            Long[] ar = new Long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
 
        Long[] nlArr1(int n) {
            Long[] ar = new Long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
    }

}


Measured memory_bytes: 44188
#include<bits/stdc++.h>
#include<unordered_map>
/*
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*    ▀▀       ▀▀▀▀▀▀    ▀     ▀▀▀▀▀▀      ▀    ▀
*   ▀  ▀      ▀         ▀     ▀            ▀  ▀
*  ▀    ▀     ▀ ▀ ▀     ▀     ▀ ▀ ▀         ▀
* ▀ ▀▀▀▀ ▀    ▀         ▀     ▀             ▀
*▀        ▀   ▀         ▀     ▀             ▀
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*/
using namespace std;
void afify()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
#define ll long
#define ld long double
#define loopi(i,intial,n)  for(ll i=ll(intial);i<n;i++)
#define loopj(j,intial,n) for(ll j=ll(intial);j<n;j++)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(v) v.begin(),v.end()
///////////////////////////////////////
#define SCD(a) scanf("%d",&a)
#define SCD2(a,b) scanf("%d %d",&a,&b)
#define SCLL(a) scanf("%lld",&a)
#define SCLL2(a,b) scanf("%lld %lld",&a,&b)
#define PRD(a) printf("%d\n",a)
#define PRLL(a) printf("%lld\n",a)
///////////////////////////////////////
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vi> vvi;
typedef vector <vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<vpii> vvpii;
typedef stringstream ss;
const ll oo = (ll) 1e13;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
//ifstream ifs("input.txt");
//ofstream ofs("output.txt");

int main()
{
   afify();
   ll n;
   cin>>n;long long sum=0;
   vll v(3*n);
   loopi(i,0,3*n){
	  cin>>v[i];
   }
   sort(v.rbegin(),v.rend());
   for (int i = 0; i < n; i++)
   {
	   sum+=v[i*2+1];
   }
   cout<<sum<<endl;
	return 0; 
}

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

int main() {
  int d, n;
  cin >> d >> n;
  int ans = 0;
  int exp = 1;
  rep(i, d) exp *= 100;
  if(n == 100) ans = exp*n + exp;
  else ans = exp*n;
  
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N,L;
  cin >> N >> L;
  int all_sum = 0;
  int min_abs = 1000000;
  int min_num = 0;
 
  for (int i = 0; i < N; i++) {
    all_sum += L + (i+1) -1;
    if (min_abs > abs(L+i+1-1)) {
      min_num = L + (i+1) - 1;
      min_abs = abs(L+i+1-1);
    }  
  }

  cout << all_sum - min_num << endl;  
}

Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let c: i32 = read();

    println!("{}", if a <= c && c <= b { "Yes" } else { "No" });
}

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

Measured memory_bytes: 4352
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double dp[] = new double[n + 1];
        dp[0] = 1;
        for(int coin = 0; coin < n; coin++) {
            double p = sc.nextDouble();
            for(int i = coin + 1; i >= 0; i--) {
                dp[i] = ((i == 0) ? 0 : dp[i - 1] * p) + (dp[i] * (1 - p));
            }
        }
        double ans = 0;
        for(int heads = 0; heads <= n; heads++) {
            int tails = n - heads;
            if(heads > tails) {
                ans += dp[heads];
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 38084
#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
using namespace std;
using ll = long long;

int N,K;
vector<int> A;

bool C(int x){
  ll count=0;
  for(int i=0;i<N;i++){
    count+=(A[i]+x-1)/x-1;
  }
  return (count<=K);
}

int main(){
  cin >> N >> K;
  A.resize(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  int left=0,right=1e9;
  while(right-left>1){
    int mid=(left+right)/2;
    if(C(mid)){
      right=mid;
    }
    else{
      left=mid;
    }
  }
  cout << right << endl;
}

Measured memory_bytes: 4036
program main
implicit none
integer :: i, j, n, k

read(*,*) n, k
if( n == 1 ) then
   write(*,'(i0)') k
else
   i = k
   do j = 1, n-1
      i = i*(k-1)
   end do
   write(*,'(i0)') i
end if


end program main


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

int main(){
  
  int n, m, st[110], sh[110], sumt, sumh;

  while(cin>>n>>m, n){
    sumt=0;
    for(int i=0;i<n;i++){
      cin>>st[i];
      sumt+=st[i];
    }
    sumh=0;
    for(int i=0;i<m;i++){
      cin>>sh[i];
      sumh+=sh[i];
    }
    bool f=true;
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	if(sumt-st[i]+sh[j]==sumh-sh[j]+st[i]){
	  cout<<st[i]<<" "<<sh[j]<<endl;
	  f=false;
	  break;
	}
      }
      if(!f) break;
    }
    if(f) cout<<-1<<endl; 
  }
  
  return 0;
}

Measured memory_bytes: 3072