akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
  string s; cin >> s;
  int K; cin >> K;
  vector<string> vec;
  int N = s.size();
  for(int i = 1; i <= 5; i++){
    for(int j = 0; j + i <= N; j++){
      vec.push_back(s.substr(j, i));
    }
  }
  sort(vec.begin(), vec.end());
  int counter = 1;
  if(K == 1){
    cout << vec[0] << endl;
    return 0;
  }
  for(int i = 1; i < vec.size(); i++){
    if(vec[i] != vec[i - 1]) counter++;
    if(counter == K){
      cout << vec[i] << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1660
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<functional>
#include<iomanip>

#define LLI long long int

using namespace std;

vector<bool>done;
int N,M;
vector<vector<int> >G;

void dps(int p){
	done[p]=true;
	for(int i=0;i<G[p].size();i++){
		int q=G[p][i];
		if(!done[q]){
			dps(q);
		}
	}
}
int main(){
	cin>>N>>M;
	G=vector<vector<int> >(N);
	for(int i=0;i<M;i++){
		int X,Y,Z;cin>>X>>Y>>Z;
		X--;Y--;
		G[X].push_back(Y);
		G[Y].push_back(X);
	}
	done=vector<bool>(N,false);
	int ans=0;
	for(int i=0;i<N;i++){
		if(!done[i]){
			dps(i);
			ans++;
		}		
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 8832
from collections import defaultdict
N, T = map( int, input().split())
A = list( map( int, input().split()))
now = A[0]
c = 0
for i in range(N):
    c = max( c, A[i]-now)
    now = min( now, A[i])
d = defaultdict( lambda :-1)
for i in range(N):
    d[A[i]] = i
ans = 0
for i in range(N):
    if d[A[i]+c] == -1:
        continue
    if d[A[i]+c] > i:
        ans += 1
print( ans)

Measured memory_bytes: 32988
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(c)   (c).begin(),(c).end()

main(){
  string a,b;
  while(cin>>a>>b && a != "0"){
    int hit=0,blow=0;
    rep(i,b.size()){
      if (a[i] == b[i])hit++;
    }
    rep(i,b.size()){
      blow+=count(ALL(a),b[i]);
    }
    cout << hit <<" " << blow-hit << endl;
  }
  return false;
}

Measured memory_bytes: 912
inputs = input().split()
n = int(inputs[0])
k = int(inputs[1])
s = input()

if s[k-1] == 'A':
    s = s[0:k-1] + 'a' + s[k:]
elif s[k-1] == 'B':
    s = s[0:k-1] + 'b' + s[k:]
elif s[k-1] == 'C':
    s = s[0:k-1] + 'c' + s[k:]

print(s)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        public static List<long> GeneratePrime(long max)
        {
            long prime;
            double sqrtMax = Math.Sqrt(max);
            var primeList = new List<long>();

            List<long> searchList = new List<long>();
            for (long i = 2; i <= max - 1; i++)
            {
                searchList.Add(i);
            }

            do
            {
                prime = searchList.First();
                primeList.Add(prime);
                searchList.RemoveAll(n => n % prime == 0);
            } while (prime < sqrtMax);

            primeList.AddRange(searchList);

            return primeList;
        }

        void Omame()
        {
            cin = new Scanner();
            int N = cin.nextInt();
            int K = cin.nextInt();

            List<long> h = new List<long>();

            for (int i = 0; i < N; i++)
            {
                h.Add(cin.nextLong());
            }

            h.Sort();

            long ans = long.MaxValue;
            for (int i = 0; i < N - K + 1; i++)
            {
                ans = Math.Min(ans, h[i + K - 1] - h[i]);
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 17108
#include <stdio.h>

int main(){
  char S[3];
  scanf("%s",S);
  int ans=700;
  int i;
  for(i=0;i<3;i++){
    if(S[i]=='o'){
      ans=ans+100;
    }
  }
  printf("%d", ans);
  return 0;
}


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

int main() {
  long long n;
  cin >>n;
  long long kotae=0;
  if(360%n==0)kotae=360/n;
  else {
    for(int i=1;i<=360;i++){
      if(360*i%n==0){
        kotae=360*i/n;
        break;
      }
    }
  }
  cout<<kotae<<endl;
  return 0;
}

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

using ll = long long;
const int mod = 1e9 + 7;

int cnt[2000];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X, Y, Z;
    cin >> X >> Y >> Z;
    swap(X, Y);
    swap(X, Z);
    cout << X << " " << Y << " " << Z << endl;
}

Measured memory_bytes: 256
N = int(input())

A = sorted(list(map(int, input().split())))[::-1]

k = 0
i = 0
while i < N - 1:
    if A[i] == A[i + 1]:
        if k == 0:
            k = A[i]
            i += 1
        else:
            print(k * A[i])
            exit()
    i += 1

print(0)


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

using namespace std;

long long solve(int N, int P, string S)
{
    long long ans = 0;
    vector<int> r(N);
    r[N - 1] = (S[N - 1] - '0') % P;
    int d = 1;
    for (int i = N - 2; i >= 0; --i) {
        d *= 10;
        d %= P;
        r[i] = ((S[i] - '0') * d + r[i + 1]) % P;
    }

    vector<int> h(P, 0);
    for (auto x : r) {
        ++h[x];
    }
    for (int i = 0; i < N; ++i) {
        if (r[i] == 0) {
            ans += h[r[i]];
            --h[r[i]];
        }
        else {
            --h[r[i]];
            ans += h[r[i]];
        }

    }
    return ans;
}

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

    cout << solve(N, 2019, S) << endl;
}

Measured memory_bytes: 4352
def sToTree(S):
#    print(S)
    if len(S)==0:
        return 'N'
    c = 0
    left=0
    right=0
    #print(S)
    for i in range(len(S)):
        if S[i] =='(':
            c+=1
        elif S[i] ==')':
            c-=1
        elif c==0 and S[i]=='[':
            left=i
        elif c==0 and S[i] ==']':
            right=i
            break
#    print(S[right+1:len(S)-1],right,left)   
    return[sToTree(S[1:left-1]),int(S[left+1:right]),sToTree(S[right+2:len(S)-1])]
    
def dfs(S1,S2):
    if S1=='N' or S2=='N':
        return 'N'

    ret = [dfs(S1[0],S2[0]),S1[1]+S2[1],dfs(S1[2],S2[2])]
    return ret

def my_print(ans):
    if ans == 'N':
        return
    print('(',end='')
    my_print(ans[0])
    print(")[{0}](".format(ans[1]),end = '')
    my_print(ans[2])
    print(')',end='')

S1 = input()
S2 = input()


S1 = sToTree(S1)
S2 = sToTree(S2)

ans = dfs(S1,S2)
my_print(ans)
print()



Measured memory_bytes: 5732
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

    string s,t;
    cin >> s >> t;
    int a,b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(s == u)a--;
    else if(t == u)b--;
    cout << a << " " << b << endl;

    

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2020-qual.contest.atcoder.jp/tasks/ddcc2020_qual_b
// rm -r -f test;oj dl https://abc154.contest.atcoder.jp/tasks/abc154_b

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    double A, B, H, M; cin >> A >> B >> H >> M;
    double PI2RAD = 3.14159265359 / 180.0;
    double angA = ((H + M / 60.0) * 30.0) * PI2RAD;
    double angB = (M * 6.0) * PI2RAD;
    double xA = cos(angA) * A, yA = sin(angA) * A;
    double xB = cos(angB) * B, yB = sin(angB) * B;
    cout << setprecision(12)
        << sqrt(pow(xA - xB, 2.0) + pow(yA - yB, 2.0))
        << endl;
}

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

int main(){
    int N;
    cin >> N;
    double v[N] = {};
    for (int i = 0;i < N;i++){
        cin >> v[i];
    }
    sort(v,v + N);
    double ans = (v[0] + v[1]) / 2;
    for (int i = 2;i < N;i++){
        ans = (ans + v[i]) / 2;
    }
    cout << setprecision(15) << ans << endl;
}

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

using db = double;
using ll = long long;
using vi = vector <int>;
#define op operator
#define pb push_back

int main() {
	cout << fixed << setprecision(9);
	ios :: sync_with_stdio(0);

	int t; cin >> t;
	string s; getline(cin, s);
	while(t --) {
		string s;
		getline(cin, s);
		list <char> l;
		for(char c : s)
			l.push_back(c);
		auto i = l.begin();
		int q; cin >> q;
		while(q --) {
			string s, t; cin >> s;
			getline(cin, t); t = t.substr(1);
			if(s == "forward") {
				if(t == "char") {
					if(i != l.end()) i ++;
				} else {
					bool word = 0;
					while(i != l.end()) {
						if(*i != ' ')
							word = 1;
						else if(word)
							break;
						i ++;
					}
				}
			}

			if(s == "backward") {
				if(t == "char") {
					if(i != l.begin()) i --;
				} else {
					bool word = 0;
					while(i != l.begin()) {
						i --;
						if(*i != ' ')
							word = 1;
						if(word && *prev(i) == ' ')
							break;
					}
				}
			}

			if(s == "insert") {
				t = t.substr(1, t.size() - 2);
				i = l.insert(i, t.begin(), t.end());
				advance(i, t.size());
			}

			if(s == "delete") {
				if(t == "char") {
					if(i != l.end()) {
						i ++;
						l.erase(prev(i));
					}
				} else {
					if(i != l.end()) {
						bool word = 0;
						for(auto j = i; j != l.end(); j ++)
							if(*j != ' ') word = 1;
						if(word) {
							word = 0;
							while(i != l.end()) {
								if(*i != ' ')
									word = 1;
								else if(word)
									break;
								i ++;
								l.erase(prev(i));
							}
						}
					}
				}
			}
			/*
			for(auto it = l.begin(); it != l.end(); it ++) {
				if(it == i) cout << '^';
				cout << *it;
			}
			if(i == l.end()) cout << '^';
			cout << '\n';
			*/
		}

		for(auto it = l.begin(); it != l.end(); it ++) {
			if(it == i) cout << '^';
			cout << *it;
		}
		if(i == l.end()) cout << '^';
		cout << '\n';
	}

	return 0;
}

Measured memory_bytes: 3272
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

K = I()
A, B = LI()

for i in range(A, B+1):
    if i % K == 0:
        print("OK")
        break
else:
    print("NG")



Measured memory_bytes: 65332
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    long x = sc.nextLong();
    long ans = x;
    for(int i = 0; i < n; i++) {
      long a = sc.nextLong();
      for(long j = 1; j <= d; j += a) {
        ans++;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23380
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const ll MOD = 1000000007;
const int MSIZE = 100007;
const double Pi = 3.14159265358979323146;

int main(){
  ll x, y, a, b, c;  cin >> x >> y >> a >> b >> c;
  vector<ll> P(a), Q(b), R(c);
  REP(i, a) cin >> P.at(i);
  REP(i, b) cin >> Q.at(i);
  REP(i, c) cin >> R.at(i);
  sort(RALL(P));
  sort(RALL(Q));
  while(P.size()>x) P.pop_back();
  while(Q.size()>y) Q.pop_back();
  vector<ll> con{P};
  for(auto &p:Q)  con.emplace_back(p);
  sort(ALL(con));
  ll add=0;
  sort(RALL(R));
  for(int i=0; i<c && i<con.size(); i++){
    add+= max(R.at(i)-con.at(i), 0ll);
  }
  cout << add+accumulate(ALL(P), 0LL)+accumulate(ALL(Q), 0LL) << endl;

}


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

#define llint long long int

using namespace std;

int main()
{
    int N;

    cin >> N;

    vector<int> A(N);

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

    for (int i = 0; i < N; i++)
    {
        auto it = lower_bound(dp.begin(), dp.end(), A[i] + 1);

        dp[it - dp.begin()] = A[i];
    }
    for (int i = 0; i < N; i++)
    {
        if (dp[i] == INT_MAX)
        {
            cout << i << endl;

            return 0;
        }
    }
    cout << N << endl;
}

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





int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll n;
	cin>>n;
	vector<ll> a(n),b(n),c(n);
	ll dp[n][3];

	for(ll i=0;i<n;++i) cin>>a[i]>>b[i]>>c[i];

	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];

	for(ll i=1;i<n;++i){
		dp[i][0] = a[i] + max(dp[i-1][1] , dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][0] , dp[i-1][2]);
		dp[i][2] = c[i] + max(dp[i-1][1] , dp[i-1][0]);
	}

	cout<<max( {dp[n-1][0] , dp[n-1][1] ,dp[n-1][2]} )<<"\n";

	return 0;
}

Measured memory_bytes: 7864
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    vector<int> A(3); cin >> A[0] >> A[1] >> A[2];
    int K; cin >> K;
    sort(A.begin(),A.end());
    int x=1;
    for(int i=0;i<K;i++){
        x *= 2;
    }
    cout << A[2]*x+A[0]+A[1] << endl;
    return 0;
}


Measured memory_bytes: 3564
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

/**
 * The Number of Island
 */
public class Main {

	final static int LAND = 1;
	final static int VISITED = -1;

	final static int[] V = { 1, -1, 0, 0 };
	final static int[] H = { 0, 0, 1, -1 };

	static Queue<Integer> xs, ys;
	static int count;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (true) {

			// load map
			int[][] map = new int[14][14];
			xs = new ArrayDeque<Integer>();
			ys = new ArrayDeque<Integer>();

			for (int i = 1; i < 13; i++) {
				line = br.readLine();
				for (int j = 1; j < 13; j++) {
					map[i][j] = line.charAt(j - 1) - '0';
				}
			}

			// solve
			count = 0;
			for (int i = 1; i < 13; i++) {
				for (int j = 1; j < 13; j++) {
					if (map[i][j] == LAND) {
						xs.add(i);
						ys.add(j);
						while (!xs.isEmpty() && !ys.isEmpty()) {
							visit(map);
						}
						count++;
					}
				}
			}

			// output.
			System.out.println(count);

			// next map
			line = br.readLine();
			if (line == null) {
				break;
			} else {
				continue;
			}
		}
		//
	}

	public static void visit(int[][] map) {

		int x, y;
		x = xs.remove();
		y = ys.remove();

		if (map[x][y] == LAND) {
			map[x][y] = VISITED;

			// next choices
			for (int i = 0; i < 4; i++) {
				int xv, yh;
				xv = x + V[i];
				yh = y + H[i];
				if (map[xv][yh] == LAND) {
					xs.add(xv);
					ys.add(yh);
				}
			}
		}
	}
}

Measured memory_bytes: 16888
#include <bits/stdc++.h>
#define ll long long
#define f(i, x, n) for(int i = x; i < n; i++)
#define dbg(x) cout << x << endl
#define dbg2(x, y) cout << x << "  " << y << endl
#define dbg3(x, y, z) cout << x << "  " << y << "  " << z << endl;
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    int n, b, i = 0;
    cin >> n >> b;
    while(n > 0){
        n /= b;
        i++;
    }
    cout << i << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
long long Lucus(int n);

int main() {
    int N;
    cin >> N;
    vector<long long> Lucus(N+1);

    Lucus.at(0) = 2LL;
    Lucus.at(1) = 1LL;

    for(int i = 2; i <= N; i++){
        Lucus.at(i) = Lucus.at(i-1) + Lucus.at(i-2);
    }

    cout << Lucus.at(N);
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, C;
    cin >> N >> C;
    vector<vector<int>> D(C, vector<int>(C));
    vector<vector<int>> A(N, vector<int>(N));
    for (int i = 0; i < C; i++) for (int j = 0; j < C; j++) cin >> D[i][j];
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) cin >> A[i][j];
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) A[i][j]--;

    vector<vector<int>> v(3, vector<int>(C));
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) v[(i+j)%3][A[i][j]]++;
    int minD = INF;
    for (int c1 = 0; c1 < C; c1++) {
        for (int c2 = 0; c2 < C; c2++) {
            if (c1 == c2) continue;
            for (int c3 = 0; c3 < C; c3++) {
                if (c2 == c3 || c1 == c3) continue;
                int cur = 0;
                for (int j = 0; j < C; j++) {
                    cur += D[j][c1] * v[0][j];
                    cur += D[j][c2] * v[1][j];
                    cur += D[j][c3] * v[2][j];
                }
                minD = min(minD, cur);
            }
        }
    }

    cout << minD << '\n';
}


Measured memory_bytes: 4628
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;

const int N   = 3e5+7;
const int MOD = 1e9+7;
const int INF = (~(1<<31));

int fre(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}

inline int read(){
	int x=0,f=1;char ch=getchar();
	for(;ch<'0'||'9'<ch;ch=getchar())if(ch=='-') f=-1;
	for(;'0'<=ch&&ch<='9';ch=getchar())x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}

#define lal puts("****");
#define pb  push_back
#define mp  make_pair
#define x   first
#define y   second

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

int a;
LL b,lcm;
int s[222];
int main(){
    scanf("%d",&a);
    lcm = 1;
    for(int i=1;i<=a;i++){
        scanf("%lld",&b);
        lcm = lcm/__gcd(lcm,b)*b;
    }
    printf("%lld\n", lcm);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define MOD 1000000007
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) (v).begin() , (v).end()
#define sumof(v) accumulate(all(v), 0LL, plus<ll>())
#define maxof(v) max_element(all(v))
#define minof(v) min_element(all(v))
#define inf INT_MAX

int main(){
    FASTIO
    ll N; cin>>N;
    ll freq[10001] = {0};
    for(int x=1; x<=100; ++x){
        for(int y=1; y<=100; ++y){
            for(int z=1; z<=100; ++z){
                if(x*x + y*y + z*z + x*y + y*z + z*x>10000) continue;
                freq[x*x + y*y + z*z + x*y + y*z + z*x]++;
            }
        }
    }
    for(int i=1; i<=N; ++i) cout<<freq[i]<<endl;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
    Scanner   sc   = new Scanner(System.in);

    void run() {
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] v = new int[N];
        int[] w = new int[N];
        for (int i = 0; i < N; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }

        long base = w[0] - 1;
        for (int i = 0; i < N; i++) {
            w[i] -= base;
        }
        int M = 1000;
        long[][][] dp = new long[2][N + 1][M + 10];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                for (int k = 0; k <= M; k++) {
                    if (k - w[i] >= 0 && dp[i & 1][j + 1][k] < dp[i & 1][j][k - w[i]] + v[i]) {
                        dp[(i + 1) & 1][j + 1][k] = dp[i & 1][j][k - w[i]] + v[i];
                    } else if (dp[(i + 1) & 1][j][k] < dp[i & 1][j][k]) {
                        dp[(i + 1) & 1][j][k] = dp[i & 1][j][k];
                    }
                }
            }
        }

        long ans = 0;
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j <= N; j++) {
                for (int k = 0; k <= M; k++) {
                    if (dp[i][j][k] > ans && j * base + k <= W) {
                        ans = Math.max(ans, dp[i][j][k]);
                    }
                }
            }
        }
        System.out.println(ans);
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 26964
#include <iostream>
#include <algorithm>

int main(void) {
  int X, N;
  int *m;
  int res;
  std::cin >> N >> X;
  res = N;
  m = (int *) malloc(sizeof(int) * N);
  for (int i=0;i < N;i++) {
    std::cin >> m[i];
    X = X - m[i];
  }
  std::sort(m, m+N);
  bool flag=true;
  int  idx=0;
  while(flag) {
    if (X-m[idx] >= 0) {
      res++;
      X = X - m[idx];
    } else {
      flag = false;
    }
  }
  std::cout << res << std::endl;
  return 0;
}


Measured memory_bytes: 256
from math import factorial
N = int(input())
P = {}
ans = 0
def counter(s):
    ret = [0]*26
    for ss in s:
        ret[ord(ss)-ord('a')] += 1
    return tuple(ret)
for _ in range(N):
    s = input()
    c = counter(s)
    if not c in P.keys():
        P[c] = 1
    else:
        P[c] += 1
for v in P.values():
    if v > 1:
        ans += factorial(v) // factorial(2) // factorial(v-2)
print(ans)


Measured memory_bytes: 35932
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vll a(n);
    map<ll, int> cnt;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    ll s = accumulate(ALL(a), 0LL);

    int q; cin >> q;
    for (int i = 0; i < q; i++) {
        ll b, c; cin >> b >> c;
        s -= b * cnt[b];
        s += c * cnt[b];
        ll ccc = cnt[b];
        cnt[b] = 0;
        cnt[c] += ccc;
        cout << s << '\n';
    }
    return 0;
}


Measured memory_bytes: 10116
n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]

for i in range(1, n):
    a[0][i] += a[0][i - 1]

a[1][0] += a[0][0]

for i in range(1, n):
    a[1][i] += max(a[0][i], a[1][i - 1])

print(a[-1][-1])

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
	int n;
	string s;
	cin>>n>>s;
	int x=0;
	for(int i=0;i<=n-3;i++){
		if(s.at(i)=='A'&&s.at(i+1)=='B'&&s.at(i+2)=='C'){
			x++;
		}
	}
	cout<<x<<endl;
}

Measured memory_bytes: 256
N = int(input())

INF = 10 ** 5 + 1

dp = [0 for _ in range(INF)]

for n in range(1, N + 1):
    dp[n] = INF
    power = 1
    while power <= n:
        dp[n] = min(dp[n], dp[n - power] + 1)
        power *= 6

    power = 1
    while power <= n:
        dp[n] = min(dp[n], dp[n - power] + 1)
        power *= 9

print(dp[N])


Measured memory_bytes: 3864
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int al = 0;
		int bl = 0;
		int cl = 0;
		int dl = 0;
		int ar = 0;
		int br = 0;
		int cr = 0;
		int dr = 0;
		while(sc.hasNext()){
			double l = sc.nextDouble();
			if(l >= 1.1){
				al++;
			}else if(l >= 0.6 && l < 1.1){
				bl++;
			}else if(l >= 0.2 && l <0.6){
				cl++;
			}else {
				dl++;
			}
			double r = sc.nextDouble();
			if(r >= 1.1){
				ar++;
			}else if(r >= 0.6 && r < 1.1){
				br++;
			}else if(r >= 0.2 && r <0.6){
				cr++;
			}else {
				dr++;
			}
		}
			System.out.println(al+" "+ar);
			System.out.println(bl+" "+br);
			System.out.println(cl+" "+cr);
			System.out.println(dl+" "+dr);
		
		sc.close();
	}

}

Measured memory_bytes: 20700
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public int[] A;

        public void Run()
        {
            N = Input.ReadInt();
            A = Input.ReadIntArray();

            bool answer = (A.Where(e => e % 2 == 1).Count()) % 2 == 0;

            Console.WriteLine(answer ? "YES" : "NO");


        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

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

int main() {
  ios::sync_with_stdio(false);cin.tie(nullptr);
  int n;double d;
  cin >> n >> d;
  int count = 0;
  for (int i = 0; i < n; ++i) {
    long double x, y;
    cin >> x >> y;
    long double dist = sqrt(x * x + y * y);
    if (dist <= d) {
      ++count;
    }
  }

  cout << count << '\n';
  return 0;
}


Measured memory_bytes: 3864
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0);
int n;
int a[1000001];
int ret;
int num;
bool ok;
int cnt;

int gcd(int a, int b){
    if(!b) return a;
    return gcd(b,a%b);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n;
    rep1(i,0,n){
        cin >> num;
        a[num]++;
        ret = gcd(ret,num);
    }

    for(int i = 2; i <= 1000000; i++){
        cnt = 0;
        for(int j = i; j <= 1000000; j += i) cnt += a[j];
        if(cnt > 1){
            ok = true;
            break;
        }
    }

    if(!ok) cout << "pairwise coprime";
    else if(ret == 1) cout << "setwise coprime";
    else cout << "not coprime";

	return 0;
}

Measured memory_bytes: 7564
// 「なにもしない」ができる。バイナリが使えそうな雰囲気
// と思ったけど微妙に違いそう
// 常に進むとすると 1 3 6 10 15 21...  これが最高値になる
// ex) 逆に今登場しなかった数値 たとえば4だと？
// 1. 4秒後に4移動する	...  4
// 2. 1秒後に"1", 2秒目では止まり、3秒後に1から"3"へ移動する ... 3
// ex) 5では？
// 1. 5秒後...5
// 2. 2秒後に"2", 3秒後に"5"で 3 が達成可能

// それまでに登場したやつ以下ならそれで倒せる？？？？（エスパーだけどなんでかな？？？？？？？？？？？？？？
package main

import (
	"fmt"
	"sort"
)

func main() {
	var X int
	fmt.Scan(&X)
	n := 1
	arr := []int{n}
	for i := 2; n <= int(1e9); i++ {
		n = arr[len(arr)-1] + i
		arr = append(arr, n)
	}
	idx := sort.Search(len(arr), func(j int) bool {
		return X <= arr[j]
	})
	fmt.Println(idx + 1)
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> vec(32);
  vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << vec.at(k-1) << endl;
}

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

using namespace std;
typedef long long int64;
const int kMaxN = 1e5+10;

int n, m, q;
vector<int> G[kMaxN];
int col[kMaxN], pot[kMaxN];
int v[kMaxN], c[kMaxN], maxd[kMaxN];

void bfs(int s, int maxd, int c) {
	queue<int> Q;
	if (maxd > pot[s]) {
		if (col[s] == 0) {
			col[s] = c;
		}
		pot[s] = maxd;
		Q.push(s);
	}

	while (!Q.empty()) {
		int x = Q.front();
		// cout << x << "\n";
		Q.pop();

		for (auto y : G[x]) {
			if (pot[x] - 1 > pot[y]) {
				if (col[y] == 0) {
					col[y] = c;
				}
				pot[y] = pot[x] - 1;
				Q.push(y);
			}
		}
	}
}

void solve() {

	cin >> n >> m;

	for (int i = 1; i <= m; ++i) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	for (int i = 1; i <= n; ++i) {
		pot[i] = -1;
		col[i] = 0;
	}

	cin >> q;

	for (int i = 1; i <= q; ++i) {
		cin >> v[i] >> maxd[i] >> c[i];
	}

	for (int i = q; i >= 1; --i) {
		// cout << "Here\n";
		bfs(v[i], maxd[i], c[i]);
	}

	for (int i = 1; i <= n; ++i) {
		cout << col[i] << "\n";
	}
	cout << "\n";
}

void reset() {
	for (int i = 1; i <= n; ++i) {
		G[i].clear();
	}
}

int main() {
	int tests = 1;
	for (;tests; --tests) {
		solve();
		reset();
	}
}

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

int main()
{
    int r, g, b;
    cin >> r>>g>>b;

    if((r*100+g*10+b)%4==0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define repf(i,n) for(int i=0;i<=n;i++)
const ll mod = 1e9 + 7;

ll dp[2020][2020];	// dp[i][j] := Sをi番目、Tをj番目まで選んだ時の組み合わせの数
ll sum[2020][2020]; // 累積和

int main(){
	ll N,M;cin >> N >> M;
	vector<ll> S(N+1),T(M+1);
	for(int i=0;i<N;++i) cin >> S[i];
	for(int i=0;i<M;++i) cin >> T[i];
	
	ll ans = 0;
	for(int i=0;i<N;++i){
		for(int j=0;j<M;++j){
			if(S[i] == T[j]) dp[i+1][j+1] = dp[i+1][j] + dp[i][j+1] + 1;
			else dp[i+1][j+1] = dp[i+1][j] + dp[i][j+1] - dp[i][j];
			dp[i+1][j+1] = dp[i+1][j+1] + mod;
			dp[i+1][j+1] %= mod;

			//printf(" %d : %d : %ld : %ld \n",i,j,dp[i][j],sum[i][j]);
		}
	}
	cout << (dp[N][M] + 1 + mod) % mod << endl;
}

Measured memory_bytes: 33024
import java.util.Scanner;

class Main {

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int num;
		num = scan.nextInt();
		int[] array = new int[num];
		for (int i = 0; i < num; i++) {
			array[i] = scan.nextInt();
		}
		insertionSort(array);
		scan.close();

	}

	private static void insertionSort(int[] A) {
		// N個の要素を含む0-オリジンの配列A
		int v = 0;
		int j = 0;
		for (int i = 0; i < A.length; i++) {
			v = A[i];
			j = i - 1;
			while (j >= 0 && A[j] > v) {
				A[j + 1] = A[j];
				j -= 1;
				A[j + 1] = v;

			}
			for (int n = 0; n < A.length; n++) {
				if (n > 0) {
					System.out.print(" ");
				}
				System.out.print(A[n]);
			}
			System.out.print("\r\n");

		}
	}
}


Measured memory_bytes: 34208
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    static final int MODULUS = 1_000_000_007;

    static int[] inverses;

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int K = sc.nextInt();

        System.out.println(solve(N, M, K));

        sc.close();
    }

    static int solve(int N, int M, int K) {
        inverses = new int[N * M + 1];
        for (int i = 1; i < inverses.length; ++i) {
            inverses[i] = BigInteger.valueOf(i).modInverse(BigInteger.valueOf(MODULUS)).intValue();
        }

        int result = 0;
        for (int r = 0; r < N; ++r) {
            for (int c = 0; c < M; ++c) {
                result = addMod(result, addMod(multiplyMod(N, addMod(computePrefixSum(c), computePrefixSum(M - 1 - c))),
                        multiplyMod(M, addMod(computePrefixSum(r), computePrefixSum(N - 1 - r)))));
            }
        }

        for (int i = 0; i < K - 2; ++i) {
            result = divideMod(multiplyMod(result, N * M - 2 - i), i + 1);
        }

        result = divideMod(result, 2);

        return result;
    }

    static int computePrefixSum(int limit) {
        return divideMod(multiplyMod(limit, limit + 1), 2);
    }

    static int addMod(int x, int y) {
        return (x + y) % MODULUS;
    }

    static int multiplyMod(int x, int y) {
        return (int) ((long) x * y % MODULUS);
    }

    static int divideMod(int x, int y) {
        return multiplyMod(x, inverses[y]);
    }
}

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

typedef long long ll;

int main()
{
    ll n;cin>>n;
    ll b =26;
    int l = 1;
    while (n>b)
    {
        n-=b;
        b*=26;
        l++;
    }
    n--;
    string an(l,'0');
    for (int i = l-1;i>=0; i--)
    {
        an[i] = n%26+'a';
        n/=26;
    }
    
    cout<<an;
}


Measured memory_bytes: 3572
use proconio::input;

fn main() {
	input! {
		a: usize,
		b: usize,
		c: usize,
	}

	let mut s = 0;
	for _i in 0..b {
		s += a;
		if s % b == c {
			println!("YES");
			return;
		}
	}
	println!("NO");
}



Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int a, b, c, d; 
  a = N/1000, b = N/100 % 10, c = N/10 % 10, d = N % 10; 
  if (a+b+c+d == 7) cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl; 
  else if (a+b+c-d == 7) cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl; 
  else if (a+b-c+d == 7) cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl; 
  else if (a+b-c-d == 7) cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl; 
  else if (a-b+c+d == 7) cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl; 
  else if (a-b+c-d == 7) cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl; 
  else if (a-b-c+d == 7) cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl; 
  else if (a-b-c-d == 7) cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl; 
}

Measured memory_bytes: 256
import sys
from collections import deque
input=sys.stdin.readline
sys.setrecursionlimit(10**6)

n=int(input().rstrip())
a=[list(map(int,input().split())) for _ in range(2)]
ans=0
for i in range(n):
    ans=max(ans,sum(a[0][:i+1])+sum(a[1][i:]))
print(ans)

Measured memory_bytes: 3316
# -*- coding: utf-8 -*-
# C

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

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

# val = 1
# for k in range(K):
#     val *= A[k]

for i in range(K, N):
    if A[i-K] < A[i]:
        print('Yes')
    else:
        print('No')


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll a, b, c;
    cin >> a >> b >> c;
    if (b / a >= c)
    {
        cout << c << endl;
    }
    else
    {
        cout << b / a << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.BitSet

fun main(args: Array<String>) {
    val (n, m) = readInputLine().split(" ").map{it.toInt()}
    
    val switches = mutableListOf<List<Int>>()
    
    for (i in 1..m) {
        val s = readInputLine().split(" ").map{it.toInt() - 1}
        switches.add(s.drop(1))
    }
    
    val p = readInputLine().split(" ").map{it.toInt()}

    println(dfs(0, n, BitSet(n), p, switches))
}

fun readInputLine(): String {
    return readLine()!!
}

fun dfs(index:Int, n: Int, s: BitSet, p: List<Int>, switches: List<List<Int>>): Int {
    if (index == n) {
        var ok = true
        for ((i, switch) in switches.withIndex()) {
            var on = 0
            for (k in switch) {
                if (s[k]) {
                    on++
                }
            }
            if (on % 2 != p[i]) {
                ok = false
                break
            }
        }
        if (ok) {
            return 1
        } else {
            return 0
        }
    }
    
    var ret = 0
    
    ret += dfs(index + 1, n, s, p, switches)
    
    val newSet = s.clone() as BitSet
    newSet[index] = true
    ret += dfs(index + 1, n, newSet, p, switches)

    return ret
}


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

int n, m, e, j;

int main(){
	while (cin >> n && n != 0) {
		for (int i = 0; i < n; i++) {
			cin >> m >> e >> j;
			if ((m == 100 || e == 100 || j == 100) || (m + e >= 180) || (m + e + j >= 240)) {
				cout << "A" << endl;
			}
			else if ((m + e + j >= 210) || (m + e + j >= 150 && (m >= 80 || e >= 80))) {
				cout << "B" << endl;
			}
			else {
				cout << "C" << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(src,dst)    for(int i=src; i<dst;  i++)
#define rep2(src,dst)   for(int j=src; j<dst;  j++)
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define PI  acos(-1)
#define ll long long
template<typename T> inline void ChMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void ChMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  DivUp(T a, T b)   {return ((a+b-1)/b);}

int main(){
    int a, b, c, d; cin >> a >> b >> c >> d;
    int t_ans = DivUp(a,d);
    int a_ans = DivUp(c,b);
    if(t_ans >= a_ans){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}
/*

*/


Measured memory_bytes: 3608
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, m) = (v[0] as usize, v[1]);
    let a = read_vec::<i64>();

    let mut a0 = a[0];
    let mut count = 0;
    while a0 % 2 == 0 {
        a0 >>= 1;
        count += 1;
    }
    for i in 1..n {
        let mut a0 = a[i];
        let mut temp_count = 0;
        while a0 % 2 == 0 {
            a0 >>= 1;
            temp_count += 1;
        }
        if count != temp_count {
            println!("0");
            return;
        }
    }

    let a = a.into_iter().map(|x| x >> 1).collect::<Vec<_>>();
    // let m = m >> count - 1;

    let mut lcmnum = a[0];
    for i in 1..n {
        let gcdnum1 = gcd(lcmnum, a[i]);
        lcmnum = lcmnum / gcdnum1 * a[i];
        if lcmnum > m * 2 {
            println!("0");
            return;
        }
    }
    let all = m / lcmnum;
    let ans = (all + 1) / 2;
    println!("{}", ans);
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;

ll dp[110][8]; // 高さhで縦棒iに到達するパターン数
int main(){
    int h, w, k;
    cin >> h >> w >> k;
    k--;
    dp[0][0] = 1;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            for(int bit = 0; bit < 1 << (w - 1); bit++){
                bool f = true;
                // kへ到達するには最低w-1本必要
                for(int kk = 0; kk < w - 2; kk++){
                    // 今の地点より右の棒の有無
                    if(bit >> kk & 1 && (bit >> (kk + 1)) & 1) f = false;
                }
                if(!f) continue;
                int nj = j;
                // 今いる棒に既に棒がある
                if(bit >> j & 1) nj = j + 1;
                // 今いる棒の左に棒がある
                if((bit >> (j - 1)) & 1) nj = j - 1;
                dp[i + 1][nj] += dp[i][j];
                dp[i + 1][nj] %= mod;
            }
        }
    }
    cout << dp[h][k] << endl;
    return 0;
}

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

using namespace std;

int main(){
	int L,a,b,c,d,temp;
	int doo,doo1,doo2;
	double dtemp;
	
	scanf("%d",&L);
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	dtemp = a/c;
	if(a%c==0)
	doo1=(int)dtemp;
	else
	doo1=(int)dtemp+1;
	//
	dtemp = b/d;
	if(b%d==0)
	doo2=(int)dtemp;
	else
	doo2=(int)dtemp+1;
	if(doo1>doo2)
	doo=doo1;
	else
	doo=doo2;
	printf("%d\n",L-doo);
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	ll n,k,temp;
	cin >> n >> k;
	ll mod = n%k ;
	temp = min(mod , abs(k - mod));
	cout << temp << nl;
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t = 1;
	 //cin >> t;
	for(ll i = 1; i <= t; i++){
		doit();
	}
}


Measured memory_bytes: 3580