akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 100005, MAXM = 45004, Mod = 998244353 , MAXLog = 20;

int arr[MAXN];
int memo[MAXN][2];
int n;
int solve(int idx, bool done) {
    if (idx == n)
        return INT_MAX;
    int &ret = memo[idx][done];
    if (~ret)
        return ret;
    int gcd = solve(idx + 1, done);
    if (gcd == INT_MAX) {
        gcd = 0;
    }
    ret = __gcd(arr[idx], gcd);
    if (!done) {
        ret = max(ret, solve(idx + 1, 1));
    }
    return ret;
}

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;


    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }

    memset(memo, -1, sizeof memo);
    cout << solve(0, 0) << '\n';

    return 0;
}

Measured memory_bytes: 6144
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,a,b;
    while(~scanf("%d %d %d",&a,&b,&n))
    {
        if(a>n)
            printf("NO\n");
        else if(a==n)
            printf("YES\n");
        else
        {
            if(n-a>b)
                printf("NO\n");
            else
                printf("YES\n");
        }
    }

    return 0;
}


Measured memory_bytes: 128
// ※※※ 解答不能 ※※※
// vjudge2氏.
// https://atcoder.jp/contests/code-festival-2017-quala/submissions/4001102
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 101009, p = 998244353, inv2 = p + 1 >> 1;
char A[N], B[N], C[N], D[N];
int fac[N << 2], inv[N << 2];
int n, m, ans;

inline int qPow(int A, int B){
    int res(1);
    while(B){
        if(B & 1) res = (ll)res * A % p;
        A = (ll)A * A % p;
        B >>= 1;
    }
    return res;
}

inline int Com(int nn, int mm){
    return (ll)fac[nn] * inv[mm] % p * inv[nn - mm] % p;
}
void preWork(int A){
    fac[0] = inv[0] = 1;
    for(int i = 1; i <= A; ++i) fac[i] = (ll)fac[i - 1] * i % p;
    inv[A] = qPow(fac[A], p - 2);
    for(int i = A - 1; i ; --i) inv[i] = (ll)inv[i + 1] * (i + 1) % p;
}

void work(){
    int left = 0, right = 0,l = 0,r = 0, pre = 1, val;
    for(int i = 1; i <= n; ++i) left += A[i] - '0', right += B[i] - '0';
    for(int i = m; i; --i) r += C[i] - '0' + D[i] - '0';
    for(int i = 1; i <= m; i++){
        l += C[i] - '0' + D[i] - '0';
        r -= C[i] - '0' + D[i] - '0';
        if(C[i] == '0' && D[i] == '0') continue;
        if(C[i] == '1' && D[i] == '1') pre = 2ll * pre % p;
        if(right) val = Com(right + r - 1, r);
        else      val = (!r);
        ans = (ans + (ll)pre * val ) % p;
        if(left) val = Com(left + l - 1, l);
        else     val = (!l);
        pre = (pre + val) % p;
    }
}

int main(){
    scanf("%d %d", &n, &m);
    preWork(n + m + n + m);
    scanf("%s %s", A + 1, B + 1);
    scanf("%s %s", C + 1, D + 1);
    bool died = true;
    for(int i = 1; i <= n; ++i){
        if(A[i] == '1' || B[i] == '1' || C[i] == '1' || D[i] == '1'){
            died = false;
            break;
        }
    }
    if(died){
        puts("1");
        return 0;
    }
    work();
    swap(n, m);
    swap(A, C);
    swap(B, D);
    swap(C, D);
    work();
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define endl '\n'
#define int long long


int32_t  main()
{
    IOS;  
    int n,m;
    cin>>n>>m;
    int h[n+1];
    for(int i=1;i<=n;i++)
        cin>>h[i];
    vector<int> v[n+1];
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int flg=1;
        for(int j=0;j<v[i].size();j++)
        {
            if(h[v[i][j]]>=h[i])
            {
                flg=0;
                break;
            }
        }
        ans+=flg;
    }
    cout<<ans;
}

Measured memory_bytes: 10200
using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading;
using System.IO;

namespace Sweet
{
    class Program
    {
        static StreamWriter writer = null;
        private static int MAXARY=200;

        static void setstdio(string[] args)
        {
            if (0 < args.Length)
            {
                // Redirect standard input from the console to the input file.
                Console.SetIn(new StreamReader(args[0]));
                if (args.Length == 2)
                {
                    // Attempt to open output file.
                    writer = new StreamWriter(args[1]);
                    // Redirect standard output from the console to the output file.
                    Console.SetOut(writer);
                }
            }

        }
        static void fillmatrix(uint m, uint n, Int64[,] ary)
        {
            int i, j,a;

            for (i = 0; i < m; i++)
            {
                string str = Console.ReadLine();
                for (j = 0; j < n; j++)
                {
                    a = str.IndexOf(" ");
                    if (0 <= a)
                    {
                        ary[i, j] = uint.Parse(str.Substring(0, a));
                        str = str.Substring(a + 1);
                    }
                    else
                        ary[i, j] = uint.Parse(str.Substring(0));
                }
            }
        }
        private static int Sweep()
        {
            UInt32 m, n, l, i, j, k; Int64 sum;
            Int64[,] first=new Int64[MAXARY, MAXARY], second = new Int64[MAXARY, MAXARY], multiply = new Int64[MAXARY, MAXARY];
            
            string str = Console.ReadLine();
            m = uint.Parse(str.Substring(0, str.IndexOf(" ")));
            str=str.Substring(str.IndexOf(" ")+1);
            n = uint.Parse(str.Substring(0, str.IndexOf(" ")));
            str = str.Substring(str.IndexOf(" ") + 1);
            l = uint.Parse(str);
            fillmatrix(m, n, first);
            fillmatrix(n, l, second);
            for (i =0, sum = 0; i < m; i++)
            {
                for (j = 0; j < l; j++)
                {
                    for (k = 0; k < n; k++)
                    {
                        sum = sum + (first[i, k] * second[k, j]);
                    }

                    multiply[i, j] = sum;
                    sum = 0;
                }
            }
            for (i = 0; i < m; i++)
            {
                for (j = 0; j < l; j++)
                {
                    if (j != 0)
                        Console.Write(" ");
                    Console.Write("{0}", multiply[i, j]);
                }
                        Console.WriteLine();
            }

            return 0;
        }
        static void Main(string[] args)
        {
            setstdio(args);

            Sweep();
            if (writer != null)
                writer.Close();
            //Console.ReadLine();
        }
    }
}

Measured memory_bytes: 11836
#include<iostream>

#define CI cin <<
#define CO cout <<
#define E << endl;

using namespace std;

int main(void) {
	int a = 0, b = 0;

	cin >> a >> b;
	
	if (a < b) {
		cout << "a < b" << endl;
	}
	if (a > b) {
		cout << "a > b" << endl;
	}
	if (a == b) {
		CO "a == b" E
	}
}

Measured memory_bytes: 1156
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<functional>

using namespace std;

int K;
int dis[100000];

typedef pair<int, int> P;

void djk() {
	priority_queue<P, vector<P>, greater<P>> pq;
	for (int i = 0; i < K; i++)dis[i] = 1145141919;
	
	dis[1] = 1;
	pq.push(P(1, 1));
	while (pq.size()) {
		P now = pq.top(); pq.pop();
		int total = now.first, pos = now.second;
		if (dis[pos] < total)continue;

		//10倍する
		if (dis[(pos * 10) % K] > total) {
			int nxt = (pos * 10) % K;
			dis[nxt] = total;
			pq.push(P(total, nxt));
		}

		//+1する
		if (dis[(pos + 1) % K] > total + 1) {
			int nxt = (pos + 1) % K;
			dis[nxt] = total + 1;
			pq.push(P(total + 1, nxt));
		}
	}
}

int main() {
	cin >> K;
	djk();
	cout << dis[0] << endl;
	return 0;
}

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

int main() {
    int n, x; cin >> n >> x;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    sort(begin(a), end(a));
    for (int i = 0; i < n; i++) {
        if ((x -= a[i]) < 0) return !(cout << i << endl);
    }
    cout << n - (x > 0) << endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    (a:b:c:d:_) <- map ((subtract 1) . length) . group . sort . (["AC","WA","TLE","RE"] ++) <$> replicateM n getLine
    putStrLn $ "AC x " ++ show a
    putStrLn $ "WA x " ++ show d
    putStrLn $ "TLE x " ++ show c
    putStrLn $ "RE x " ++ show b

Measured memory_bytes: 38668
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	int n = in(), m = in();
	vector<tuple<int, int, int>>input(m);
	REP(i, m) {
		int p = in(), y = in();
		input[i] = make_tuple(p, y, i);
	}
	sort(ALL(input), [](const tuple<int, int, int>&t1, const tuple<int, int, int>&t2) {return get<1>(t1) < get<1>(t2); });
	vector<vector<int>>ms(n);
	REPC(&i, input) {
		ms[get<0>(i) - 1].push_back(get<2>(i));
	}
	vector<pair<string, int>>id;
	id.reserve(m);
	REP(i, n) {
		REP(j, ms[i].size()) {
			stringstream idstr;
			idstr << setw(6) << setfill('0') << i + 1 << setw(6) << setfill('0') << j + 1;
			id.push_back(make_pair(idstr.str(), ms[i][j]));
		}
	}
	sort(ALL(id), [](const pair<string, int>&p1, const pair<string, int>&p2) {return p1.second < p2.second; });
	REPC(i, id) {
		cout << i.first << endl;
	}
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;

const ll INF = (1LL<<60);

int main(){

    ll n; cin >> n;

    cout << pow(n, 3) << endl;

    return 0;
}

Measured memory_bytes: 256
import numpy as np

N, M, C = map(int, input().split())
B = np.array(list(map(int, input().split())))
ans = 0



for _ in range(N):
    A = np.array(list(map(int, input().split())))
    if sum(A * B.T) + C > 0:
        ans += 1

print(ans)


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{

    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    rep(i, M) cin >> A[i];

    ll s = 0;
    rep(i, M) s += A[i];
    int ans = N - s;
    if (ans >= 0)
    {
        cout << ans << endl;
    }
    else
    {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3612
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    String l,ans="";
    char[] a = new char[1200];
    Scanner sc = new Scanner(System.in);
    l = sc.nextLine();
    for(int i=0;i<l.length();i++){
    a[i] = l.charAt(i);
    if(a[i]>='A' && a[i]<='Z'){
      a[i] = Character.toLowerCase(a[i]);
    }else if(a[i]>='a' && a[i]<='z'){
      a[i] = Character.toUpperCase(a[i]);
    }
    ans += String.valueOf(a[i]);
    }
    
    System.out.println(ans);
    
    sc.close();
  }
  
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long l;
typedef unsigned long ul;
typedef pair<ll,ll> pll;
typedef pair<l,l> pl;
typedef pair<int,int> pi;
typedef vector<ll> vll;
typedef vector<l> vl;
typedef vector<int> vi;

#define pb push_back
#define mp make_pair
#define eb emplace_back

#define fi first
#define se second

int main(){
	ll N, K;
	cin >> N >> K;
	ll dis = 0;
	for (ll i = 0; i < N; ++i){
		ll temp;
		cin >> temp;
		dis += 2*min(abs(K-temp),temp);
	}
	cout << dis << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;

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

Measured memory_bytes: 3636
s=input()
s2=[]
for i in range(len(s)):
    s2.append(s[i])
s3=sorted(list(set(s2)))
ans=10**9
for x in range(len(s3)):
    memo=s3[x]
    cnt=0
    t=s
    p=len(s.replace(memo,""))
    while p!=0:
        t2=""
        l=len(t)
        k=0
        while k<l-1:
            if t[k]==memo or t[k+1]==memo:
                t2=t2+memo
            else:
                t2=t2+t[k]
            k+=1
        t=t2
        cnt+=1
        p=len(t2.replace(memo,""))
    if cnt<ans:
        ans=cnt
print(ans)


Measured memory_bytes: 3064
dic = {}
max_num = 0 
max_word = ""
for word in input().split():
    if word in dic:
        dic[word] += 1
    else:
        dic[word] = 1 

    if max_num <= len(word):
        max_num = len(word)
        max_word = word

print(max(dic, key=dic.get), max_word)


Measured memory_bytes: 5560
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());

        // 主処理
        int result = (int) Math.ceil(n / 2.0);

        // 出力
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 22612
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define INT_MAX 2147483647
#define LL long long

using namespace std;

int main(){
	int N,K;
	int A[100005];
	LL dp[100005];
	
	scanf("%d%d",&N,&K);
	
	for (int i=0;i<N;i++) scanf("%d",A+i);
	for (int i=0;i<N;i++) dp[i] = -1;
	
	dp[0]=0;
	
	for (int i=0;i<N;i++) {
		for (int j=1; j<=K; j++) {
			if (i+j >=N) break;
			if (dp[i+j] == -1) dp[i+j] = dp[i] + (LL)abs(A[i]-A[i+j]);
			else dp[i+j] = min(dp[i+j],dp[i] + (LL)abs(A[i]-A[i+j]));
		}
	}
	
	printf("%lld\n",dp[N-1]);
	
	return 0;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>

using namespace std;

int c[9];
class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
        int n, a;
        in >> n;
        memset(c, 0, sizeof(c));
        for (int i = 0; i < n; i++)
        {
            in >> a;
            c[(a >= 3200) ? 8 : (a / 400)]++;
        }

        int ans = 0;
        for (int i = 0; i < 8; i++)
        {
            if (c[i])
            {
                ans++;
            }
        }
        out << (ans ? ans : !!c[8]) << " " << ans + c[8] << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 256
using System;
class Practice
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int w = int.Parse(str[0]);
        int h = int.Parse(str[1]);
        int x = int.Parse(str[2]);
        int y = int.Parse(str[3]);
        int r = int.Parse(str[4]);
        Console.WriteLine(r <= x && x <= w - r && r <= y && y <= h - r ? "Yes" : "No");
    }
}


Measured memory_bytes: 17916
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n, bfo = 0, tmp = 0, ans = 0;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++)
    {
        tmp = 0;
        cin >> a.at(i);
        if (a.at(i) < bfo)
        {
            tmp = bfo - a.at(i);
            ans = ans + tmp;
        }
        bfo = a.at(i) + tmp;
    }
    cout << ans;
}

Measured memory_bytes: 4800
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#define ll long long
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;



int main() {
    ll N;
    cin >> N;
    vector<ll> A(N, 0);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    rep(j, N - 1) {
        if (A[j] == A[j + 1]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  char c;
  int judge=0;
  int cnt=0;
  for(int i=0;i<a+b+1;i++){
    cin>>c;
    if(c=='-'){
      cnt++;
      if(i!=a){
	judge=1;
	break;
      }
    }
  }
  if(judge==0&&cnt==1)
    cout<<"Yes"<<endl;
  else 
    cout<<"No"<<endl;
		      
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
 
double deg_rad( int angle){
 
    return angle * M_PI / 180;
 
}
 
 
int main(){
 
    int a, b, c;
    double side, h, c_rad;  
 
    scanf( "%d %d %d", &a, &b, &c );
 
    c_rad = deg_rad( c );
    h = b * sin( c_rad );
    side = sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(c_rad));
 
    printf( "%lf ", a*h/2 );
    printf( "%lf ", a+b+side );
    printf( "%lf\n", h );
 
    return 0;
}

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

int main(){
  int a,b,c;
  cin>>a>>b;
  if(a>=13){
    c=b;
  }else if(6<=a && a<=12){
    c=b/2;
  }else{
    c=0;
  }
  cout<<c<<endl;
  
  return 0;
}

  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);
// int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
// int a[12][12];
//平方根　= sqrt



int main() {
  int a,b;
  cin >> a >> b;
  for (int n=0; n< 10000; ++n) {
    int za = n*8/100;
    int zb = n*10/100;
    if (a == za && b == zb) {
      cout << n << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int nInput;
  cin >> nInput;
  int a = nInput % 10;
  int b = nInput / 10;
  int c = b % 10;
  int d = b / 10;
  int e = d % 10;
  cout << a + c + e << endl;
  
}

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


class Program
{
    static void Main(string[] args)
    {
        string[] NK = Console.ReadLine().Split(' ');
        long N = long.Parse(NK[0]);
        long K = long.Parse(NK[1]);

        if(N > K) N = N % K;

        Console.WriteLine(Math.Min(N, K-N));
    }
}

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

int main() {
  int n;
  cin >> n;
  if(n % 2 == 0) cout << 0.5 << endl;
  else {
    double ans = (double)(n/2+1) / n;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
const int N = 1e4+10, P = 924844033, G = 5, Gi = 554906420;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}

int lim,l,A[N],B[N],R[N];
void init(int n) {
    for (lim=1,l=0; lim<=n; lim<<=1,++l) ;
    REP(i,0,lim-1) R[i]=(R[i>>1]>>1)|((i&1)<<(l-1));
}

void NTT(int *J, int tp=1) {
    REP(i,0,lim-1) if (i<R[i]) swap(J[i],J[R[i]]);
    for (int j=1; j<lim; j<<=1) {
        ll T = qpow(tp==1?G:Gi,(P-1)/(j<<1));
        for (int k=0; k<lim; k+=j<<1) {
            ll t = 1;
            for (int l=0; l<j; ++l,t=t*T%P) {
                int y = t*J[k+j+l]%P;
                J[k+j+l] = (J[k+l]-y)%P;
                J[k+l] = (J[k+l]+y)%P;
            }
        }
    }
    if (tp==-1) {
        ll inv = qpow(lim, P-2);
        REP(i,0,lim-1) J[i]=(ll)inv*J[i]%P;
    }
}

int n,k,fac[N],ifac[N],a[N],b[N];
int C(int n, int m) {
	if (m>n) return 0;
	return (ll)fac[n]*ifac[m]%P*ifac[n-m]%P;
}

int main() {
	fac[0] = 1;
	REP(i,1,N-1) fac[i] = (ll)fac[i-1]*i%P;
	ifac[N-1] = inv(fac[N-1]);
	PER(i,0,N-2) ifac[i]=(ll)ifac[i+1]*(i+1)%P;
	scanf("%d%d", &n, &k);
	int x=n/k,y=n/k+1;
	REP(i,0,x) a[i]=C(x-i,i);
	REP(i,0,y) b[i]=C(y-i,i);
	init(n+2);
	NTT(a),NTT(b);
	REP(i,0,lim-1) a[i]=qpow(a[i],(k-n%k)*2)*qpow(b[i],n%k*2)%P;
	NTT(a,-1);
	int ans = 0;
	REP(i,0,n) {
		if (i&1) ans=(ans-(ll)a[i]*fac[n-i])%P;
		else ans=(ans+(ll)a[i]*fac[n-i])%P;
	}
	if (ans<0) ans += P;
	printf("%d\n", ans);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, n,m , M, K,a;

vector<ll> v,w;
int main(){
    cin >> N >>M;
    string str;
    vector<ll> ac(N,0), wa(N,0);
    for(int i = 0; i < M; ++i){
        cin >> n >> str;
        if(str == "AC") ac[n-1] = 1;
        if(str == "WA"){
            if(ac[n-1] != 1 ) wa[n-1] +=1;
        }
    }
    ll acnum = 0;
    ll wanum = 0;
    for(int i = 0; i < N; ++i){
        if(ac[i] == 1){
            ++acnum;
            wanum += wa[i];
        }
    }
    cout << acnum << " " << wanum << "\n";
    return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int n;
	cin >> n;
	vector<string> s(n);
	rep(i, n)
	{
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}

	sort(s.begin(), s.end());

	ll ans = 0;
	ll onaji = 0;
	for (int i = 0; i < n - 1; )
	{
		for (int j = i + 1; j < n; j++)
		{
			if (s[i] == s[j])
			{
				onaji++;
			}
			else
			{
				ll tmp = (onaji + 1) * onaji;
				ans += tmp / 2;
				i = j;
                onaji=0;
				break;
			}
			if (j == n - 1)
			{
				ll tmp = (onaji + 1) * onaji;
				ans += tmp / 2;
				i = j;
                onaji=0;
				break;
			}
		}
	}
	cout << ans << endl;


}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int a,p; cin >> a >> p;
	cout << (a*3 + p)/2;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


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

int main(){
    long long A,B,C,cnt=0,sum=0;
    cin >> A >> B >> C;
    while(1){
        sum+=A;
        if(sum%B==C){
            cout << "YES" << endl;
            return 0;
        }
        cnt++;
        if(cnt>1000000){
            cout << "NO" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define mem(x,y)		(x*)malloc(sizeof(x)*(y))

int main()
{
	int pasta[3];
	int juice[2];
	scanf("%d",&pasta[0]);
	scanf("%d",&pasta[1]);
	scanf("%d",&pasta[2]);
	scanf("%d",&juice[0]);
	scanf("%d",&juice[1]);
	int val = 0;
	if(pasta[0] < pasta[1])
	{
		if(pasta[0] < pasta[2])
		{
			val += pasta[0];
		}
		else if(pasta[1] < pasta[2])
		{
			val += pasta[1];
		}
		else
		{
			val += pasta[2];
		}
	}
	else if(pasta[1] < pasta[2])
	{
		val += pasta[1];
	}
	else
	{
		val += pasta[2];
	}
	if(juice[0] < juice[1])
	{
		val += juice[0];
	}
	else
	{
		val += juice[1];
	}
	printf("%d\n",val-50);
	return 0;
}

Measured memory_bytes: 0
from _collections import deque

s = deque(input())
q = int(input())
reverse_flg = False

for i in range(q):
    query = list(input().split())
    if query[0] == '1':
        reverse_flg = not reverse_flg
    else:
        if query[1] == '1':
            if reverse_flg:
                s.append(query[2])
            else:
                s.appendleft(query[2])
        else:
            if reverse_flg:
                s.appendleft(query[2])
            else:
                s.append(query[2])
if reverse_flg:
    s.reverse()
print("".join(s))


Measured memory_bytes: 8180
def isok(arg):
    if arg < 0:
        return False
    count = 0
    for i in range(n):
        count += max(0,-(-(a[i]*f[i]-arg)//f[i]))
    if count <= k:
        return True
    else:
        return False

def bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if isok(mid):
            ok = mid
        else:
            ng = mid
    return ok 

n,k = map(int,input().split())
a = list(map(int,input().split()))
f = list(map(int,input().split()))
a.sort()
f.sort(reverse = True)
print(bisect(-1,10**12))


Measured memory_bytes: 119500
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9 + 7;
const long long LLINF = 1e18;

int main()
{
	ll x, y;
	cin >> x >> y;

	ll ans = LLINF;
	if (x <= y) ans = min(ans, y - x);
	if (-x <= y) ans = min(ans, y + x + 1);
	if (x <= -y) ans = min(ans, -y - x + 1);
	if (-x <= -y) ans = min(ans, -y + x + 2);

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

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <fstream>
#include <complex>
using namespace std;

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

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

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

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

const int MAX = 1000 * 2 + 7;

int F[MAX * 4], RF[MAX * 4];
PII A[200007];


int BP(LL a, int n)
{
    LL res = 1;
    while(n)
    {
        if (n & 1)res = (res * a) % MOD;
        a *= a;
        a %= MOD;
        n >>= 1;
    }
    return res;
}

int C(int a, int b)
{
    LL res = F[a];
    res *= RF[b];
    res %= MOD;
    res *= RF[a-b];
    res %= MOD;
    return res;
}

int DP[2 * MAX][2 * MAX];
int get(int x, int y)
{
    //cout << x << " " << y << endl;
    if (DP[x][y] != -1)
    {
        //if (DP[x][y])cout << x << " " << y << " " << DP[x][y] << endl;
        return DP[x][y];
    }
    LL res = 0;
    if (x)res += get(x-1, y);
    if (y)res += get(x, y-1);
    while(res >= MOD)res -= MOD;
    return DP[x][y] = res;
}


int main()
{
    //cout << f(2, 1) << endl;
    //freopen("input.txt", "r", stdin);
    //ios::sync_with_stdio(false);cin.tie(NULL);
    int n;
    scanf("%d", &n);
    
   FILL(DP, -1);
    
    RF[0] = F[0] = 1;
    FOR(i, 1, 4 * MAX)
    {
        F[i] = (F[i-1] * 1LL * i) % MOD;
        RF[i] = BP(F[i], MOD - 2);
    }
    
    int tot = 0;
    FOR(i, 0,  n)
    {
        scanf("%d%d", &A[i].first, &A[i].second);
        int aa = -A[i].first + MAX;
        int bb = -A[i].second + MAX;
    //    if (DP[aa][bb] == -1)DP[aa][bb] = 0;
  //      DP[aa][bb]++;
        tot += C(2 * A[i].first + 2 * A[i].second, 2 * A[i].first);
        if (tot >= MOD)tot -= MOD;
        A[i].first = -A[i].first;
        A[i].second = -A[i].second;
    }
    LL ans = 0;
    
    sort(A, A + n);
    FOR(i, 0, n)
    {
    //   cout << A[i].first << " " << A[i].second << endl;
        int aa = A[i].first + MAX, bb = A[i].second + MAX;
        get(aa, bb);
        DP[aa][bb]++;
        if (DP[aa][bb] >= MOD)
            DP[aa][bb] -= MOD;
   //     cout << DP[A[i].first + MAX][A[i].second + MAX] << endl;
    }
    
    FOR(i, 0, n)
    {
        ans += get(-A[i].first + MAX, -A[i].second + MAX);
        if (ans >= MOD)ans -= MOD;
    }
    
    ans -= tot;
    if (ans < 0)ans += MOD;
    ans *= BP(2, MOD-2);
    ans %= MOD;
    
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 66560
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;
typedef long long ll;

int main() {

    char a;
    cin >> a;
    if (a - 'a' + 1 <= 26 && a - 'a' >= 0) cout << "a" << endl;
    else cout << "A" << endl;
    
    return 0;
}

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

int main()
{
				bool num[100];
				int pnum, cnum, chnum, pchnum, scr =0;
				cin >> pnum;
				cin >> cnum;

				for (int i = 0; i < 100; i++)
				{
								num[i] = pnum > i;
				}
				for (int i = 0; i < cnum; i++)
				{
								cin >> chnum;
								for (int j = 0; j < chnum; j++)
								{
												cin >> pchnum;
												num[pchnum - 1] = false;
								}
				}
				for (int i = 0; i < 100; i++)
				{
								if (num[i])
								{
												scr++;
								}
				}
				cout << scr;
}

Measured memory_bytes: 3644
n,m = map(int,input().split())
a = list(int(input()) for i in range(m))
a.append(0)

dp = [0] * (n+1)
b = 0
for i in range(1,n+1):
    if a[b] == i:
        b += 1
    else:
        if i != 1 and i != 2:
            dp[i] = dp[i-1] + dp[i-2]
        else:
            if i == 1:
                dp[1] = 1
            elif i == 2 and a[0] == 1:
                dp[2] = 1
            else:
                dp[1] = 1
                dp[2] = 2
print(dp[-1] % (10 ** 9 + 7))

Measured memory_bytes: 465720
#include<stdio.h>
int main()
{
  long int a,b,c,d,i;
  long long int e[4],n;
  scanf("%ld %ld %ld %ld",&a,&b,&c,&d);
  e[0]=a*c;e[1]=a*d;e[2]=b*c;e[3]=b*d;
  n=e[0];
  for(i=1;i<=3;i++)
  {
    if(n < e[i])
    {
      n=e[i];
    }
  }
  printf("%lld",n);
}


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


long long A[100000];
int N;
long long dp[100001][2];
// dp[i][0] := A[i]とA[i+1]に-1をかけなかった場合のA[0: i + 1)の和の最大値
// dp[0][0] = A[0], dp[0][1] = -A[0]
// dp[i + 1][0] = max(dp[i][0] + A[i + 1], dp[i][1] - A[i + 1])
// 答えはdp[N-1][0] + A[N - 1], dp[N-1][1] - A[N - 1]

int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    dp[0][0] = A[0];
    dp[0][1] = -A[0];
    for(int i = 0; i + 1 < N - 1; i++){
        dp[i + 1][0] =
            max(dp[i][0] + A[i + 1],
                dp[i][1] - A[i + 1]);
        dp[i + 1][1] =
            max(dp[i][0] - A[i + 1],
                dp[i][1] + A[i + 1]);
    }
    cout << max(dp[N - 2][0] + A[N - 1], dp[N - 2][1] - A[N - 1]) << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <set>
#include <vector>

using namespace std;
typedef long long ll;
int main(int argc, const char * argv[]) {
  int N, T;
  cin >> N >> T;
  vector<int> list(N);
  for (int i = 0; i < N; i++) {
    cin >> list[i];
  }

  ll ans = 0;
  for (int i = 1; i < N; i++) {
    if (list[i] - list[i - 1] < T) {
      ans += list[i] - list[i - 1];
    } else {
      ans += T;
    }
  }
  cout << ans + T << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/range/adaptor/indexed.hpp>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
std::ostream &operator<<(std::ostream &ostr, const std::vector<T> &v) {
  for (const auto &i : v | boost::adaptors::indexed())
    ostr << (i.index() > 0 ? " " : "") << i.value();
  return ostr;
}

inline void Main() {
  // code
  int n;
  cin >> n;

  int a=1;
  rep(i, n)
    if(a*2<=i+1) a*=2;
    
  cout << a << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<vector>
#include<array>
#include<algorithm>
#include<chrono>

int const INF = 1e9;

uint64_t xor64(void) {
  static uint64_t x = 88172645463325252ULL;
  x = x ^ (x << 7);
  return x = x ^ (x >> 9);
}

auto b_cl = std::chrono::system_clock::now();
inline double get_time() {
  auto e_cl = std::chrono::system_clock::now();
  double msec = std::chrono::duration_cast<std::chrono::milliseconds>(e_cl - b_cl).count();
  return msec;
}

struct state {
  int score_k;
  int type;
  int last[26];
  int score;
  std::vector<state>::iterator prev;
  bool operator< (state const& rhs) const { return score_k > rhs.score_k; } // reverse order
};

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int D; std::cin >> D;
  int c[26];
  for(auto& ci: c) std::cin >> ci;
  std::vector<std::array<int,26>> s(D);
  for(int d = 0; d < D; ++d) {
    for(auto& si: s[d]) std::cin >> si;
  }
  int const B = 750;
  int const K = 3;
  std::vector<int> t(D);
  
  std::vector<std::vector<state>> states(D+1);
  auto beam_step = [&](int d, int k) {
    auto& prev = states[d];
    auto& curr = states[d+1];
    curr.reserve(prev.size()*26);
    int dd = std::min(d+k, D-1);
    for(auto it = prev.begin(); it != prev.end(); ++it) {
      for(int T = 0; T < 26; ++T) {
        curr.push_back(*it);
        state& st = curr.back();
        st.prev = it;
        st.last[T] = d;
        st.type = T;
        st.score_k = st.score + s[d][T];
        for(int cx = 0; cx < 26; ++cx) {
          st.score_k -= c[cx]*(d+dd - 2*st.last[cx])*(dd-d+1)/2;
        }
      }
    }
    std::sort(curr.begin(), curr.end());
    if(curr.size() > B) curr.resize(B);
    for(auto& st: curr) {
      st.score += s[d][st.type];
      for(int cx = 0; cx < 26; ++cx) {
        st.score -= c[cx]*(d - st.last[cx]);
      }
    }
  };
  
  auto beam_search = [&](int k) {
    states.assign(D+1, std::vector<state>());
    states[0].emplace_back();
    states[0][0].score = 0;
    states[0][0].score_k = 0;
    std::fill_n(states[0][0].last, 26, -1);
    for(int d = 0; d < D; ++d) beam_step(d, k);
    auto it = states[D].begin();
    for(int d = D-1; d >= 0; it = it->prev, --d) {
      t[d] = it->type;
    }
  };
  beam_search(K);
  for(auto ti: t) std::cout << ti+1 << "\n";
  return 0;
}


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

int main(int argc, const char * argv[]) {
    string a, b;
    cin >> a >> b;
    
    double x, y;
    x = stoi(a + b);
    y = sqrt(x);
    
    if (y == (int)y) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
def divide_problems(n,d):
    ans = 0
    _d = sorted(d)
    ans = _d[n/2] - _d[n/2-1]
    return ans

if __name__ == '__main__':
    n = int(raw_input())
    d = list(map(int,raw_input().split()))

    print divide_problems(n,d)

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

int main(){
  int A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;
  vector <int> a;
  for (int i(0);i<=30;i++){
    for (int j(0);j<=30;j++){
      if (i*A*100+j*B*100 <= F) a.push_back(i*A*100+j*B*100);
    }
  }
  vector <int> b;
  for (int i(0);i<=30*E;i++){
    for (int j(0);j<=30*E;j++){
      if (i*C+j*D<=30*E) b.push_back(i*C+j*D);
    }
  }
  // for (int i(0);i<b.size();i++) cout << b[i] << " ";
  double noudo(0);
  int satousui(0);
  int satou(0);
  for (int i(0);i<a.size();i++){
    for (int j(0);j<b.size();j++){
      if ((100*b[j])/(double)(a[i]+b[j])>=noudo && a[i]+b[j]<=F && b[j]<=E*a[i]/(double)100){
        // cout << a[i] <<" "<< b[j] << endl;
        noudo = (100*b[j])/(double)(a[i]+b[j]);
        satousui = a[i]+b[j];
        satou = b[j];
      }
    }
  }
  cout << satousui << " " << satou << endl;
}



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

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

	long double a[n], dp[n+1][n+1];

	for(int i=0;i<n;i++)
    	cin>>a[i];

    //dp[0][0]=1;

    for (int i = 0; i <= n; ++i)
	for(int j=0;j<=n;j++)
		 dp[i][j]=1;
         
	for (int i = 1; i <=n; ++i)
	{   	 
		  	dp[i][0]=dp[i-1][0]*(1-a[i-1]);
            dp[0][i]=dp[0][i-1]*(a[i-1]);
		  
	}

	for (int i = 1; i <= n; ++i)
	{
		for(int j=1;j<=n;j++)
		{   dp[i][j]=0;
			if((i+j)<=n)
            dp[i][j]=dp[i-1][j]*(1-a[i+j-1])  + dp[i][j-1]*a[i+j-1];
		}
	}
    
    long double ans=0;

    for (int i = 0; i <= n; ++i)
	{
		for(int j=0;j<=n;j++)
		{     

			//cout<<setprecision(19)<<dp[i][j]<<"  ";
            if(i+j==n  && j>i)
            	ans+=dp[i][j];
		}
		//cout<<endl;

    }		

    cout<<setprecision(9)<<ans;



	return 0;
}

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

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

    vector<int> data(k);
    int ans;
    int pre;

    int a;
    data[1] = 7 % k;
    ans = 1;
    pre = data[1];

    if(data[1] != 0){
        for(int i = 2 ; i <= k ; i++){
            data[i] = 10 * data[i-1] + 7;
            data[i] = data[i] % k;
            pre = data[i];
            if(data[i] == 0){
                ans = i ; 
                pre = data[i];
                break;
            }
        }
    }

    if(pre == 0){
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
    

    return 0;
}

Measured memory_bytes: 7212
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,ans=1e13;
inline void chkmin(int &x,int y)
{
	if(y<x)
		x=y;
}
signed main()
{
	scanf("%lld",&n);
	for(register int i=1;i*i<=n;i++)
		if(n%i==0)
			chkmin(ans,i+n/i-2);
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
  int64_t L0 = 2, L1 = 1, L;
  int N;
  cin >> N;
  for (int i = 1; i < N;i++){
      L = L0 + L1;
      L0 = L1;
      L1 = L;
  }
  cout << L1 <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> A(N);

    for(int i = 0; i < N; i++) cin >> A[i];

    sort(A.begin(), A.end());


    vector<bool> b(pow(10, 6) + 10);
    vector<bool> c(pow(10, 6) + 10);

    for(int i = 0; i < N; i++) {
        if(c[A[i]]) continue;
        if(b[A[i]]) {
            c[A[i]] = true;
            continue;
        }
        b[A[i]] = true;
        int x = 2;
        while(A[i] * x <= pow(10, 6)) {
            c[A[i] * x] = true;
            x++;
        }
    }

    int ans = 0;

    for(int i = 0; i < N; i++) {
        if(!c[A[i]]) {
            //cerr << A[i] << endl;
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4292
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

void solve(){
  ll n,W; cin>>n>>W;
  vector<ll> w(n),v(n);
  rep(i,n) cin>>w[i]>>v[i];
  const ll V=accumulate(v.begin(),v.end(),(ll)0);
  vector<ll> dp(V+1,INF);
  dp[0]=0;
  rep(i,n){
    auto newdp=dp;
    rep(x,V+1) if(x+v[i]<V+1) chmin(newdp[x+v[i]],dp[x]+w[i]);
    dp=newdp;
  }
  rep(i,V,-1,-1) if(dp[i]<=W){
    cout<<i<<"\n";
    return;
  }
}

Measured memory_bytes: 1792
#!/usr/bin/ruby -Ku

require 'pp'

def getGCD(a, b)
  return a if b == 0
  return getGCD(b, a%b)
end

loop do
  n = gets.to_i
  break if n == 0
  
  d = Array.new(n)
  v = Array.new(n)
  n.times{ |i|
    data = gets.split(nil).map!{|e| e.to_i}
    d[i], v[i] = data
  }
  
  dpro = d.inject(1){ |p, i| p * i}
  
  p = Array.new(n)
  n.times{|i| p[i] = dpro/d[i]*v[i] }
  
  # p のGCDを求めて割る
  st = Marshal.load(Marshal.dump(p))
  # stの要素数が1になるまでGCD出す
  loop do
    break if st.size == 1
    x = getGCD(st.pop, st.pop)
    st.push x
  end  
  gcd = st.pop
  
  n.times{|i|
    puts p[i]/gcd
  }  
end

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

int main(){
    int n;
    string s;
    cin >> n;
    int tmp;
    for(int i = 0; i < n; i++){
        cin >> tmp;
        s += to_string(tmp);
    }
    
    for(int i = 0;  ;i++){
        if(s.find(to_string(i)) == -1){
            cout << i << endl;
            return 0;
        }
    }


    return 0;
}

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

int main()
{
  int n,h;
  cin >> n >> h;
  vector<int> a(n);
  vector<int> b(n);
  for(int i=0;i<n;++i){
    cin >> a.at(i) >> b.at(i);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  
  int ans=0;
  for(int i=n-1;h>0;--i,++ans){
    if(i<0){
      ans+=(h-1)/a.at(n-1);
      h=0;
    }else if(a.at(n-1)<b.at(i)){
      h-=b.at(i);
    }else{
      ans+=(h-1)/a.at(n-1);
      h=0;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define INF 1000000
using namespace std;
int s, pre_a, arr_a[INF], count_a=1;
int check(int s){
  pre_a = s;
  arr_a[pre_a]++;
  for(int i=1;i<=INF;i++){
    count_a++;
    if(pre_a%2==0) pre_a = pre_a/2;
    else pre_a = 3*pre_a+1;
    if(arr_a[pre_a]==0) arr_a[pre_a]++;
    else return count_a;
  }
  return 0;
}
int main(){
  cin>> s;
  cout<< check(s);
  return 0;
}

Measured memory_bytes: 256