akhauriyash/Code-Regression huggingface dataset:
import fractions as fr

A , B , K = map(int,input().split()) # A,B <= 100

k = 0

R = int(max(fr.gcd(A,B),1))

for i in range(R,0,-1) :
    if A % i == 0 and B % i == 0 :
        k += 1
        if k >= K :
            print(i)
            break



Measured memory_bytes: 5048
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	if(a>b){
		cout<<a-1<<endl;
	}else{
		cout<<a<<endl;
	}
	return 0;
}

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

using namespace std;

#define int long long
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define all(x) x.begin(), x.end()
#define el '\n'
#define remax(a,b) a = max(a, b)
#define remin(a,b) a = min(a, b)
#define sz(x) int32_t(x.size())

typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
// --------------------------------------------------------------------

const pii dxy[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} };
const int mod = 1e9 + 7;
const int inf = 2e18;
const ld eps = 1e-9;
const int NN = 1e5 + 2;


void solve() {
      int i = 0, j = 0, k = 0, n = 0, m = 0; 
      cin >> k;
      fr(i, 1, k+1) {
            fr(j, 1, k+1) {
                  fr(n, 1, k+1) {
                        int t = __gcd(i, j);
                        t = __gcd(t, n);
                        m += t;
                  }
            }
      }
      cout << m << el;
}

int32_t main() {
      ios::sync_with_stdio(false); cin.tie(0); 
      int T = 1; 
      // cin >> T;
      for(int tc = 1; tc <= T; tc++) {
            solve();
       }

      return 0;
}

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

int main() {
int A,B;
  string S,T;
  cin >> S;
  if(S=="Sunny"){
    T="Cloudy";
  }else if(S=="Cloudy"){
    T="Rainy";
  }else{
    T="Sunny";
  }
cout << T << endl;

}






Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            System.out.println((1000-(n%1000))%1000);
        }


    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt(){return  Integer.parseInt(next());}
        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

Measured memory_bytes: 33048
def calc_saidaikouyaku(a, b):
    if (b == 0):
        return(a)
    
    return calc_saidaikouyaku(b, a % b)

k = int(input())

result = []

for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            result.append(calc_saidaikouyaku(a, calc_saidaikouyaku(b, c)))

print(sum(result))

Measured memory_bytes: 194492
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

LL dp[110][101010];
int main(){
    int n, W;
    cin >> n >> W;
    vector<LL> w(n), v(n);
    rep(i, n) cin >> w[i] >> v[i];

    memset(dp, 0, sizeof(dp));
    dp[0][0] = 0;
    rep(i, n){
        rep(j, W+1){
            chmax(dp[i+1][j], dp[i][j]);
            if(j+w[i]<=W) chmax(dp[i+1][j+w[i]], dp[i][j] + v[i]);
            // cout << dp[i+1][j] << " ";
        }
        // cout << endl;
    }
    cout << dp[n][W] << endl;

}


Measured memory_bytes: 87040
#include "bits/stdc++.h"

using namespace std;

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

    string S;
    cin >> S;

    int cnt[2] = {};
    for (int i = 0; i < N; ++i) {
        if (S[i] == '(') {
            ++cnt[0];
        } else {
            if (cnt[0]) --cnt[0];
            else ++cnt[1];
        }
    }
    for(int i = 0; i < cnt[1]; ++i)
        cout << '(';
    cout << S;
    for(int i = 0; i < cnt[0]; ++i)
        cout << ')';
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a, b, c[999], i, j, w, g;
    scanf("%d %d",&a, &b);
    for ( i = 0; i < a; i++)
    {
        scanf("%d",&c[i]);
    }
    
    for ( i = 0; i < a; i++)
    {
        for (j = (i + 1); j < a; j++)
        {
            if (c[i] > c[j])
            {
                w = c[i];
                c[i] = c[j];
                c[j] = w;
            }
            
        }
        
    }

    g = 0;
    for ( i = 0; i < b; i++)
    {
        g = g + c[i];
    }
    printf("%d\n",g);
    return 0;
}

Measured memory_bytes: 1704
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int a, b;
  cin >> a >> b;
   int t = abs(a - b);
   if (t % 2 == 0) {
     cout << (a + b) / 2 << endl;
   } else {
     cout << "IMPOSSIBLE" << endl;
   }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n;
  scanf("%d", &n);
  int ans = 0;
  for(int i = 1; i <= 9; i++){
    if((n % i == 0) && (n / i >= 1) && (n / i <= 9)){
      ans = 1;
    }
  }
  if(ans){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


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

int comand(string s) {
    if (s == "print") {
        return 1;
    }
    else if (s == "reverse") {
        return 2;
    }
    else if (s == "replace") {
        return 3;
    }
}

int main() {
    int a, b, q, num;
    string str, com;
    string temp, rep, r_str;
    cin >> str >> q;
    for (int i = 0; i < q; i++) {
        cin >> com;
        num = comand(com);
        switch (num) {
        case 1:
            cin >> a >> b;
            cout << str.substr(a, b - a + 1) << endl;
            break;
        case 2:
            cin >> a >> b;
            temp = str.substr(a, b - a + 1);
            r_str = temp;
            for (int i = 0; i < temp.size(); i++) {
                r_str[i] = temp[b - a - i];
            }
            str = str.replace(a, b - a + 1, r_str);
            break;
        case 3: 
            cin >> a >> b >> rep;
            str = str.replace(a, b - a + 1, rep);
            break;
        default:
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;

int values[100010];
pair<int, int> dp[100010][2];

const int INF = 1 << 29;
const pair<int, int> INIT_UP(INF, INF);
const pair<int, int> INIT_DN(INF, -INF);

void update(pair<int, int>& A, pair<int, int> B, int id)
{
    if (A.first > B.first)
        A = B;
    else if (A.first == B.first) {
        if (id == 0)
            A.second = min(A.second, B.second);
        else
            A.second = max(A.second, B.second);
    }
}

int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> values[i];
    }
    for (int i = 0; i < N + 2; i++) {
        dp[i][0] = INIT_UP;
        dp[i][1] = INIT_DN;
    }
    dp[1][0] = dp[1][1] = make_pair(0, values[0]);

    for (int i = 1; i < N; i++) {
        // next: up
        if (dp[i][0].second < values[i]) {
            update(dp[i + 1][1], make_pair(dp[i][0].first, values[i]), 1);
        } else {
            // swap (i - 1 and i)
            update(dp[i + 1][1], make_pair(dp[i][0].first + 1, dp[i][0].second), 1);

            if (i + 1 < N) {
                // swap (i and i + 1)
                if (dp[i][0].second < values[i + 1] and values[i + 1] > values[i]) {
                    update(dp[i + 2][0], make_pair(dp[i][0].first + 1, values[i]), 0);
                }
            }
        }

        // next: down
        if (dp[i][1].second > values[i]) {
            update(dp[i + 1][0], make_pair(dp[i][1].first, values[i]), 0);
        } else {
            // swap (i - 1 and i)
            update(dp[i + 1][0], make_pair(dp[i][1].first + 1, dp[i][1].second), 0);

            if (i + 1 < N) {
                // swap (i and i + 1)
                if (dp[i][1].second > values[i + 1] and values[i + 1] < values[i]) {
                    update(dp[i + 2][1], make_pair(dp[i][1].first + 1, values[i]), 1);
                }
            }
        }
    }

    /*
    for (int i = 0; i <= N; i++) {
        for (int k = 0; k < 2; k++) {
            if (dp[i][k] == INIT_UP or dp[i][k] == INIT_DN) continue;
            fprintf(stderr, "dp[%d][%d] = (%d, %d)\n", i, k, dp[i][k].first, dp[i][k].second);
        }
    }
    */
    cout << min(dp[N][0].first, dp[N][1].first) << endl;
    return 0;
}



Measured memory_bytes: 5032
using DataStructures

function main()
    n = parse(Int, readline())
    a = parse.(Int, split(readline()))
    m = maximum(a)
    b = zeros(Int, m)

    for x in a
        if b[x] != 0
            b[x] = 2
            continue
        end
        for i in x:x:m
            b[i] += 1
        end
    end

    println(sum(b[a] .== 1))
end

main()


Measured memory_bytes: 232488
#include <iostream>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

int gcd(int x, int y)
{
	if (y == 0) return x;
	return gcd(y, x % y);
}

int main()
{
	int n;
	
	cin >> n;
	
	vector<int> a(n);
	
	rep(i, n) cin >> a[i];
	
	vector<int> l(n), r(n);
	
	rep(i, n - 1) l[i + 1] = gcd(l[i], a[i]);
	
	for (int i = n - 1; i >= 1; --i) r[i - 1] = gcd(r[i], a[i]);
	
	int ans = 1;
	
	rep(i, n) ans = max(ans, gcd(l[i], r[i]));
	
	cout << ans << endl;
}


Measured memory_bytes: 1408
import java.util.*;

public class Main {

    static class Node {
        long x, y;
        Node (long x, long y) {
            this.x = x;
            this.y = y;
        }
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
//        long mod = 1000000007;
        Node[] a = new Node[n];
        for (int i = 0; i < n; i++) {
            long x = scan.nextLong();
            long y = scan.nextLong();
            a[i] = new Node(x, y);
        }
        Arrays.sort(a, (e1, e2) -> (int) (e1.x == e2.x ? e1.y - e2.y : e1.x - e2.x));
        long ans = 0;
        long m1 = -a[0].x - a[0].y;
        long m2 = -a[0].x + a[0].y;
        for (int i = 1; i < n; i++) {
            ans = Math.max(ans, a[i].x + a[i].y + m1);
            ans = Math.max(ans, a[i].x - a[i].y + m2);
            m1 = Math.max(m1, -a[i].x - a[i].y);
            m2 = Math.max(m2, -a[i].x + a[i].y);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 67328
#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)

int main(){
    string s;
    cin >> s;
    int ans = 0;
    while(s.size() != 0){
        if(s[0] == s[s.size() - 1]){
            s.pop_back();
            if(!s.empty())
                s.erase(s.begin());
        }
        else{
            if(s[0] != 'x' && s[s.size() - 1] == 'x'){
                s.insert(s.begin(), 'x');
                ans++;
            }
            else if(s[s.size() - 1] != 'x' && s[0] == 'x'){
                s.push_back('x');
                ans++;
            }
            else{
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;

using ll = long long;

int main() {
    for (int i = 0; i < 5; i++) {
        int x;
        cin >> x;
        if (x == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
}

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

int main() {
  int64_t N, M, max;
  cin >> N >> M;
  
  vector<int64_t> A(N);
  rep(i, N) cin >> A[i];
  
  priority_queue<int64_t> pq;
  rep(i, N){
  	pq.push(A[i]);
  }
  
  while(M > 0){
  	max = pq.top();
    pq.pop();
    max /= 2;
    pq.push(max);
    M--;
  }
  
  int64_t ans = 0;
  rep(i, N){
    max = pq.top();
    pq.pop();
    ans += max;
  }
  cout << ans << endl;
  

}

Measured memory_bytes: 2168
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        boolean[] rf = new boolean[8];
        int wc = 0;
        for (int i = 0; i < n; i++) {
            int r = a[i] / 400;
            if (r < 8) {
                rf[r] = true;
            } else {
                wc++;
            }
        }

        long count = IntStream.range(0, rf.length).filter(i -> rf[i]).count();
        long min = Math.max(count, 1);
        long max = count + wc;
        
        System.out.println(String.format("%d %d", min, max));
    }
}

Measured memory_bytes: 28240
import std.stdio, std.conv, std.string, std.math, std.algorithm;

void main(){
	auto ip = readln.chomp;
	if(ip[0] == 'H'){
		if(ip[2] == 'H') 'H'.writeln;
		else if(ip[2] == 'D') 'D'.writeln;
	} else if(ip[0] == 'D') {
		if(ip[2] == 'H') 'D'.writeln;
		else if(ip[2] == 'D') 'H'.writeln;
	}
}

Measured memory_bytes: 256
import math

n = int(input())
Hs = list(map(int, input().split()))

i = 0
ans = 0
node = [0 for i in range(n)]

for i in range(n):
    if i == 0:
        node[i] = 0
        continue
    
    if i == 1:
        node[i] = abs(Hs[i-1] - Hs[i])
        continue

    # i >= 2 
    
    s_long = node[i-2] + abs(Hs[i-2] - Hs[i])
    s_short = node[i-1] + abs(Hs[i-1] - Hs[i])

    node[i] = min((s_long, s_short))

print(node[-1])


    

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

typedef long long lli;
typedef vector<int> Vi;
typedef vector<lli> Vl;
typedef pair<int, int> Pii;
typedef pair<lli, lli> Pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<": ";REP(i,v.size())cout<<" "<<v[i];cout<<endl

#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))


//===


int main()
{
	int A, B, C;
	cin >> A >> B >> C;

	cout << (A == B && A == C ? "Yes" : "No") << endl;
}

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

void solve(int N)
{
    int r = N % 1000;
    if (r == 0)
        cout << 0 << endl;
    else
        cout << 1000 - r << endl;
}

int main()
{
    int N;
    cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 3616
import sys
sys.setrecursionlimit(100000)

def ins(): return input().split()
def ii(): return int(input())
def iil(): return list(map(int, ins()))
def lin(): return list(input())
def iin(): return map(int, ins())

h,w = iin()
if h==1 or w==1:
    res = 1
else:
    s1 = (h+1)//2
    s2 = h//2
    if w%2==0:
        res = s1 * (w//2) + s2 * (w//2)
    else:
        res = s1 * (w // 2 + 1) + s2 * (w // 2)
print(res)

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


int N, T, A;
vector<int> H;


void input() {
    cin >> N >> T >> A;
    H = vector<int>(N);
    rep(i, N) cin >> H[i];
}


int main() {
    input();
    vector<pair<double, int>> w(N);
    rep(i, N) {
        double t = T - H[i] * 0.006;
        w[i] = make_pair(max(A-t, t-A), i);
    }
    sort(w.begin(), w.end());
    int ans = w[0].second + 1;
    cout << ans << endl;
}


Measured memory_bytes: 256
S = str(input())
K = int(input())
count = 0
connected = []
for i,x in enumerate(S[1:]):
    count += 1
    if x!=S[i]:
        connected.append(count)
        count=0
    if i==len(S)-2:
        connected.append(count+1)

result = 0
if len(S)==1:
    result=K//2
elif len(connected)==1:
    result=(connected[0]*K)//2
elif S[0]!=S[-1]:
    for c in connected:
        result+=c//2
    result *= K
elif S[0]==S[-1]:
    _connected = connected[1:]
    _connected[-1] += connected[0]
    for _c in _connected:
        result+=_c//2
    result *= (K-1)
    for c in connected:
        result+=c//2    
print(result)

Measured memory_bytes: 38256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }




string s;

int main() {
    while (cin >> s) {
        int res = 0;
        for (int i = 0; i < s.size(); ++i) {
            if (s[i] == 'g') ++res;
            else --res;
        }
        cout << res/2 << endl;
    }
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P = pair<int,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; }

signed main(){
  int n,x;
  cin >> n >> x;
  int ans = 1;
  int sum = 0;
  rep(i,0,n){
    int a;
    cin >> a;
    sum += a;
    if(sum <= x)ans++;
  }
  cout << ans << endl;
}

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

int main(){
    int A, B;
    cin >> A >> B;
    if (B == 1)
    {
        cout << 0 << endl;
        return 0;
    }

    
    int ans = 1;
    int count = A;
    while (count < B)
    {
        count += (A - 1);
        ans++;
    }
    
    // int ans = 0;
    // if (B <= A)
    // {
    //     cout << 1 << endl;
    //     return 0;
    // }
    
    // ans = B / (A - 1);
    // if (B % (A - 1) != 0 && B % (A - 1) != 1)
    // {
    //     ans++;
    // }
    
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    long long int n,k;
    cin>>n>>k;
    long long int ans=min(n%k,k-n%k);
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N;
  cin >> N;
  map<P, int> mp{};
  REP(i, N + 1) {
    if (i % 10 == 0) continue;
    P p;
    p.first = i % 10;
    string s = to_string(i);
    p.second = s[0] - '0';
    mp[p]++;
  }
  ll ans = 0;
  REP(i, N + 1) {
    P p;
    p.first = i % 10;
    string s = to_string(i);
    p.second = s[0] - '0';
    swap(p.first, p.second);
    ans += mp[p];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/*
  AtCoder Beginner Contest 086
  D - Checker
*/

#include<iostream>
#include<vector>
using namespace std;

int N, K;
int memo[2001][2001] = {0}; // 黒の始点(x,y)

void imos(int x1, int y1, int x2, int y2) {
  ++memo[x1][y1];
  ++memo[x2][y2];
  --memo[x1][y2];
  --memo[x2][y1];
}

int main() {
  scanf("%d%d", &N, &K);
  for (int i = 0; i < N; ++i) {
    int x, y;
    char c;
    scanf("%d %d %c", &x, &y, &c);

    // covert request from white to black
    if (c == 'W') x += K;
    x %= 2 * K;
    y %= 2 * K;

    if ((x < K && y < K) || (x >= K && y >= K)) { // lower left or upper right
      int x_ = x % K, y_ = y % K;

      imos(0, 0, x_ + 1, y_ + 1);
      imos(x_ + K + 1, 0, 2 * K, y_ + 1);
      imos(x_ + 1, y_ + 1, x_ + K + 1, y_ + K + 1);
      imos(0, y_ + K + 1, x_ + 1, 2 * K);
      imos(x_ + K + 1, y_ + K + 1, 2 * K, 2 * K);
    }
    else { // lower right or upper right
      int x_ = x % K, y_ = y % K;

      imos(x_ + 1, 0, x_ + K + 1, y_ + 1);
      imos(0, y_ + 1, x_ + 1, y_ + K + 1);
      imos(x_ + K + 1, y_ + 1, 2 * K, y_ + K + 1);
      imos(x_ + 1, y_ + K + 1, x_ + K + 1, 2 * K);
    }
  }

  for (int i = 0; i <= 2 * K; ++i) {
    for (int j = 1; j <= 2 * K; ++j) {
      memo[i][j] += memo[i][j - 1];
    }
  }

  for (int i = 1; i <= 2 * K; ++i) {
    for (int j = 0; j <= 2 * K; ++j) {
      memo[i][j] += memo[i - 1][j];
    }
  }

  int maxval = 0;
  for (int i = 0; i <= 2 * K; ++i) {
    for (int j = 0; j <= 2 * K; ++j) {
      maxval = max(memo[i][j], maxval);
    }
  }

  // // print imos
  // for (int j = 4 * K + 1; j >= 0; --j) {
  //   for (int i = 0; i < 4 * K + 2; ++i) {
  //     printf("%d", imos[j][i]);
  //   }
  //   printf("\n");
  // }

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

Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>

using namespace std;
 
const double eps=1e-10;

const int dy[]={-1,-1,0,1,1, 1, 0,-1};
const int dx[]={ 0, 1,1,1,0,-1,-1,-1};

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

	for(int i=0;i<n;i++){
		string s;
		cin>>s;

		set<string> org;
		for(int i=1;i<s.size();i++){
			string s1=s.substr(0,i);
			string s2=s.substr(i);

			string s1r=s1; reverse(s1r.begin(),s1r.end());
			string s2r=s2; reverse(s2r.begin(),s2r.end());

			org.insert(s1+s2);
			org.insert(s1+s2r);
			org.insert(s1r+s2);
			org.insert(s1r+s2r);

			org.insert(s2+s1);
			org.insert(s2+s1r);
			org.insert(s2r+s1);
			org.insert(s2r+s1r);


		}

		cout<<org.size()<<endl;

	}


	return 0;
}

Measured memory_bytes: 1292
#include<iostream>
using namespace std;
int bubble(int A[],int N){
        int count=0;
        bool flag=true;
        for(int i=0; flag; i++){
                flag=false;
                for(int j=N-1; j>i; j--){
                        if(A[j]<A[j-1]){
                                count++;
                                swap(A[j],A[j-1]);
                                flag=true;
                        }
                }
        }
        return count;
}
int main(){
        int N;
        cin>>N;
        int A[100];
        for(int i=0; i<N; i++)
                cin>>A[i];
        int count=bubble(A,N);
        for(int i=0; i<N; i++){
                cout<<A[i];
                if(i<N-1)
                        cout<<' ';
        }
        cout<<endl<<count<<endl;
        return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>
int main(){
    int a,b,c,t;
    scanf("%d %d %d",&a,&b,&c);
    if(a > b){
        t = a;
        a = b;
        b = t;
    }
    if(c < a){
        t = c;
        c = b;
        b = a;
        a = t;
    } else if(c >= a && b > c){
        t = c;
        c = b;
        b = t;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}

    


Measured memory_bytes: 2044
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
   		String s = sc.nextLine();
      	if(s.substring(2,3).equals(s.substring(3,4)) && s.substring(4,5).equals(s.substring(5,6)))
           System.out.println("Yes");
        else System.out.println("No");
    	
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	forn(i, n) cin >> a[i];
	int cur = 0;
	forn(i, n) {
		if(cur + 1 == a[i])
			cur++;
	}
	if(cur == 0)
		cout << -1 << endl;
	else cout << n - cur << endl;
	return 0;
}



Measured memory_bytes: 3972
#include <iostream>
using namespace std;
int N, A, combo = 0, max_combo = 0;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A;
    if (A == 1) {
      combo++;
    } else {
      combo = 0;
    }
    if (combo > max_combo) {
      max_combo = combo;
    }
  }
  cout << max_combo + 1 << '\n';
  return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define ll long long 
#define hell 1000000007
#define F first
#define re 15000000
#define S second
#define pb push_back
#define all(a)  (a).begin(),(a).end()
#define rep(i,a,b) for(ll int i = a;i<b;i++)
#define pi 3.1415926536
#define Mod 998244353
//char a[2000][2000];
using namespace std;
bool check(ll m,ll k,ll n,ll a ,ll b){
  ll rem = n-m;
  if( k > rem*b + a*m)
      return 1;
  else
    return 0;

}
int getMod(string s,int k){
  ll sum = 0;
  for(int i = 0;i<s.size();i++){
    sum = sum*10+(s[i]-'0');
    sum = sum%k;
  }
  return sum%k;

}
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);            
    //std::setprecision(20);    
    int tests=1;
      //freopen("input.txt", "r", stdin);   
     // cin>>tests;
  while(tests--)
    {
      int n,d;
      cin>>n>>d;
      int  v[n][d];
      for(int i = 0;i<n;i++){
        for(int j = 0;j<d;j++){
            cin>>v[i][j];
        }
      }
      int cnt = 0;
      for(int i = 0;i < n;i++){
        for(int j = i+1;j<n;j++){
          //double sum = 0.0;
          ll sum = 0;
          for(int k = 0;k<d;k++){
              sum = sum + (v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
          }
          int x = sqrt(sum);
          if(x*x == sum)
             cnt++;
        }
      }
      cout<<cnt;
    }
    
}

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

using namespace std;
using ll = long long;

int count(ll n) {
  int cnt = 0;
  while (n > 0) {
    n /= 10;
    cnt++;
  }
  return cnt;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N;
  cin >> N;
  ll p = sqrt(N);
  for (ll p = sqrt(N); p >= 0; p--) {
    if (N % p == 0) {
      cout << max(count(p), count(N / p)) << '\n';
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
public class Main {
	public static void main(String[] args)throws Exception{
		PrintWriter out = new PrintWriter(System.out);
		int N=nextInt();
		int A[]=new int[N];
		long ans=0;
		for(int i=0;i<N;i++){
			A[i]=nextInt();
			if(i!=0&&A[i-1]>A[i]){
				ans+=A[i-1]-A[i];
				A[i]=A[i-1];
			}
		}
		System.out.println(ans);
	}
	public static long lmod(long i, long j) {
	     return (i%j)<0?(i%j)+0+(j<0?-j:j):(i%j+0);
	 }
	static boolean isOK(int index,int key,int[]a){
		if (a[index]>=key) return true;
	    else return false;
	}
	static int binary_search(int key,int[] a) {
	    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	    int ok = (int)a.length; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	    while (Math.abs(ok - ng) > 1) {
	        int mid = (ok + ng) / 2;
	        if (isOK(mid,key,a)) ok = mid;
	        else ng = mid;
	    }
	    return ok;
	}
	//FastScanner
	static InputStream in = System.in;
	static  byte[] buffer = new byte[1024];
	static int length = 0, p = 0;
	public static boolean hasNextByte () {
		if (p < length) return true;
		else {
			p = 0;
			try {length = in.read(buffer);}
			catch (Exception e) {e.printStackTrace();}
			if (length == 0) return false;
		}
		return true;
	}
	public static int readByte () {
		if (hasNextByte() == true) return buffer[p++];
		return -1;
	}
	public static boolean isPrintable (int n) {return 33<=n&&n<=126;}
	public static void skip () {
		while (hasNextByte() && !isPrintable(buffer[p])) p++;
	}
	public static boolean hasNext () {skip(); return hasNextByte();}
	public static String next () {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int temp = readByte();
		while (isPrintable(temp)) {
			sb.appendCodePoint(temp);
			temp = readByte();
		}
		return sb.toString();
	}
	public static int nextInt () {return Math.toIntExact(nextLong());}
	public static int[] nextInts (int n) {
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = nextInt();
		return ar;
	}
	public static long nextLong () {
		if (!hasNext()) throw new NoSuchElementException();
		boolean minus = false;
		int temp = readByte();
		if (temp == '-') {
			minus = true;
			temp = readByte();
		}
		if (temp<'0' || '9'<temp) throw new NumberFormatException();
		long n = 0;
		while (isPrintable(temp)) {
			if ('0'<=temp && temp<='9') {
				n *= 10;
				n += temp - '0';
			}
			temp = readByte();
		}
		return minus? -n : n;
	}
}



Measured memory_bytes: 35856
from copy import copy
import random
import math
import sys
input = sys.stdin.readline
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(D)]
last = [0]*26
ans = [0]*D
score = 0
for i in range(D):
    ps = [0]*26
    for j in range(26):
        pl = copy(last)
        pl[j] = i+1
        ps[j] += s[i][j]
        for k in range(26):
            ps[j] -= c[k]*(i+1-pl[k])
    idx = ps.index(max(ps))
    last[idx] = i+1
    ans[i] = idx+1
    score += max(ps)
for k in range(1,40001):
    na = copy(ans)
    x = random.randint(1,365)
    y = random.randint(1,365)
    if x == y:
        continue
    na[x-1],na[y-1] = na[y-1],na[x-1]
    last = [0]*26
    ns = 0
    for i in range(D):
        last[na[i]-1] = i+1
        ns += s[i][na[i]-1]
        for j in range(26):
            ns -= c[j]*(i+1-last[j])
    T = 3000-(2980*k/40000)
    p = pow(math.e,-abs(ns-score)/T)
    if ns > score or random.random() < p:
        ans = na
        score = ns
for a in ans:
    print(a)

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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int k, a, b; gi(k), gi(a), gi(b);
	for(int i=a; i<=b; i++) {
		if(i%k == 0) {
			pstr("OK\n");
			return 0;
		}
	}
	pstr("NG\n");
}


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

uint_fast64_t N, A, B, tap[101010], cnt[4], ans;
vector<tuple<uint_fast64_t, size_t, bool>> p;
bool flg;

int main(){
    scanf("%lld", &N);
    for(size_t i = 0; i < N; ++i){
        scanf("%lld%lld", &A, &B);
        p.emplace_back(A, i, true);
        p.emplace_back(B, i, false);
    }
    sort(p.begin(), p.end());
    for(size_t j = 0; j < N; ++j){
        uint_fast64_t x;
        bool f;
        size_t i;
        tie(x, i, f) = p[j];
        tap[i] += (1 << f);
        ans += x;
    }
    for(size_t i = 0; i < N; ++i)cnt[tap[i]] += 1;
    if(!(cnt[3] || ((!!cnt[1]) ^ (!!cnt[2])))){
        if(get<1>(p[N]) != get<1>(p[N - 1]) || cnt[tap[get<1>(p[N - 1])]] == 1)ans += get<0>(p[N]) - get<0>(p[N - 1]);
        else ans += min(get<0>(p[N]) - get<0>(p[N - 2]), get<0>(p[N + 1]) - get<0>(p[N - 1]));
    }
    printf("%lld\n", ans);
    return 0;
}


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


int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b - 3)/(a-1);
  return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n, m, p;
    cin >> n >> m >> p;
    vector<vector<pii>> adj(n);
    REP(i,m){
        int32 a, b, c;
        cin >> a >> b >> c;
        a--;b--;
        c -= p;
        adj[a].emplace_back(b, -c);
    }
    vector<int64> dist(n, LLINF);
    dist[0] = 0;
    REP(i,2 * n){
        REP(v,n){
            if(dist[v] == LLINF)continue;
            for(pii e : adj[v]){
                if(i < n-1 && dist[e.first] > dist[v] + e.second){
                    dist[e.first] = dist[v] + e.second;
                }else{
                    if(dist[v] == -LLINF || dist[e.first] > dist[v] + e.second){
                        dist[e.first] = -LLINF;
                    }
                }
            }
        }
    }
    if(dist[n-1] == -LLINF){
        cout << -1 << endl;
    }else{
        cout << max<int64>(0, -dist[n-1]) << endl;
    }
    return 0;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
//m.emplace(x,0).fi->second++;

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,x;cin>>n>>x;
  if(n==2){
    if(x==2)cout<<"Yes\n1\n2\n3"<<endl;
    else cout<<"No"<<endl;
  }
  else{
    if(x==1||x==2*n-1)cout<<"No"<<endl;
    else{
      cout<<"Yes"<<endl;
      if(x<=n){
        for(i=2;i<=n-1;i++){
          if(i!=x)cout<<i<<endl;
        }
        cout<<2*n-1<<endl;
        cout<<x<<endl;
        cout<<1<<endl;
        cout<<2*n-2<<endl;
        for(i=n;i<=2*n-3;i++){
          if(i!=x)cout<<i<<endl;
        }
      }
      else{
        for(i=3;i<=n-1;i++){
          if(i!=x)cout<<i<<endl;
        }
        cout<<1<<endl;
        cout<<x<<endl;
        cout<<2*n-1<<endl;
        cout<<2<<endl;
        for(i=n;i<=2*n-2;i++){
          if(i!=x)cout<<i<<endl;
        }
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep2(i, s, n) for (int i = s; i < (int)n; i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	int n; cin >> n;
	vvi ch(n); // child
	vector<bool> is_parent(n, true); // is_parent
	int k, c; int node;
	rep(i, n) {
		cin >> node;
		cin >> k;
		rep(j, k) {
			cin >> c;
			ch.at(node).push_back(c);
			is_parent.at(c) = false;
		}
	}	
	vi p(n), d(n); // parent, depth
	queue<int> q;
	rep(node, n) {
		if (is_parent.at(node)) {
			q.push(node); p.at(node) = -1;
			break;
		}
	}
	while (q.size()) {
		int u = q.front(); q.pop();
		for (int v : ch.at(u)) {
			q.push(v); p.at(v) = u; d.at(v) = d.at(u) + 1;
		}
	}
	string type;
	rep(node, n) {
		if (p.at(node) == -1) type = "root";
		else if (ch.at(node).size() == 0) type = "leaf";
		else type = "internal node";
		printf("node %d: parent = %d, depth = %d, %s, [", node, p.at(node), d.at(node), type.c_str());
		rep(j, ch.at(node).size()) {
			cout << ch.at(node).at(j);
			if (j < ch.at(node).size() - 1) cout <<", ";
		}
		cout << "]\n";
	}
}


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


int main(){

  int N,K;
  int i;
  int x=1;
  cin >> N >> K;

  for(i=0;i<N;++i){
    if(x*2 > x + K){
      x += K;
    }else{
      x *= 2;
    }
  }

  cout << x << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N; cin >> N;
    vector<int> f(N + 1, 1);
    for (int i = 2; i <= N; i++) {
        if (f[i] != 1) continue;
        int t = 2;
        for (Int j = i; j <= N; j *= i, t++) {
            for (int k = j; k <= N; k += j) {
                f[k] /= t - 1;
                f[k] *= t;
            }
        }
    }
    for (int i = 2; i <= N; i++) {
        if (f[i] == 1) f[i] = 2;
    }
    Int ans = 0;
    for (int k = 1; k <= N; k++) {
        ans += (Int)k * f[k];
    }
    cout << ans << endl;
    return 0;
}


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

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef long long ll; 
typedef long double ld; 
typedef pair<int,int> p32;   
typedef pair<ll,ll> p64;  
typedef pair<double,double> pd; 
typedef pair<ld,ld> pld; 
typedef vector<int> v32;  
typedef vector<ll> v64;  
typedef vector<pd> vpd;   
typedef vector<p32> vp32;  
typedef vector<p64> vp64;  
typedef vector<v32> vv32;  
typedef vector<v64> vv64;  

#define pb push_back
#define mp make_pair
#define prarr(a,n) cerr<<#a<<" : ";for(ll i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define prmat(mat,row,col) cerr<<#mat<<" :\n";for(ll i=0;i<row;i++) {for(ll j=0;j<col;j++) cerr<<mat[i][j]<<"\t";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(NULL); cin.tie(NULL)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {ll idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
template <class T> void prall(T a) { prc(all(a)); }

#include <bits/extc++.h> /** keep-include */
using namespace __gnu_pbds;
template <class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag,
        tree_order_statistics_node_update>;

const int inf=1000*1000*1000+9; 
const ll infl=1ll*inf*inf; 
int mod=1000*1000*1000+7;  
// ----------------------------------------------------------------------------	-------------- 

void pre(){
}
void solve(){
  int h,w,n; cin>>h>>w>>n; 
  if(h>w) swap(h,w); 
  cout<<(n+w-1)/w<<endl; 
}



int main(){
	// clock_t beg=clock(); 
  fast_io; 
  int testcases=1; 
  pre(); 
  // cin>>testcases; 
  cout << fixed << setprecision(13); 
  while(testcases--){
    solve(); 	
  }
	// clock_t end=clock(); 
	// fprintf(stderr, "%lf\n", (double)(end-beg)/(CLOCKS_PER_SEC));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  
  cout <<(d==1?"1":"0") << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int n,ans=0;
	cin >> n;
	vector<char> a(n);
	vector<int> cnt(26);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, 26) {
		cnt[i] = 0;
		rep(j, n) {
			if (i == a[j] - 'A') {
				cnt[i]++;
			}
		}
		if (cnt[i] > 0) {
			ans++;
		}
	}
	if (ans == 3) {
		cout << "Three" << endl;
	}
	else {
		cout << "Four" << endl;
	}
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll K;
  cin >> K;
  queue<ll> lun;
  for (ll i = 1; i <= 9; ++i) {
    lun.push(i);
  }
  ll cnt = 0;
  while (true) {
    cnt += 1;
    ll now = lun.front();
    lun.pop();
    if (cnt == K) {
      cout << now << endl;
      return 0;
    }
    if (now % 10 == 0) {
      lun.push(now * 10);
      lun.push(now * 10 + 1);
    }
    else if (now % 10 == 9) {
      lun.push(now * 10 + 8);
      lun.push(now * 10 + 9);
    }
    else {
      lun.push(now * 10 + now % 10 - 1);
      lun.push(now * 10 + now % 10);
      lun.push(now * 10 + now % 10 + 1);
    }
  }
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int mx = max(a,c);
    int mn = min(b,d);
    if(mx>=mn){
        cout << 0 << endl;
    }else{
        cout << mn-mx << endl;
    }
}


Measured memory_bytes: 256
S = list(input())
T = list(input())

lenS = len(S)
lenT = len(T)

match = 0
for i in range(lenS - lenT + 1):
    cnt = 0
    for j in range(lenT):
        if S[i + j] == T[j]:
            cnt += 1
    match = max(match, cnt)

print(lenT - match)



Measured memory_bytes: 9048