akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

long long int INF = 1e18;
using namespace std;

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

long long int n, k;
long long int w[200000];

bool check(long long int num){
	int cnt = 0;
	long long int s = 0;
	for(int i = 0; i < n; i++){
		if(w[i] > num){
			return false;
		}
		if(s + w[i] > num){
			cnt++;
			s = w[i];
		}else{
			s += w[i];
		}
	}
	cnt++;
	if(cnt <= k){
		return true;
	}
	return false;
}

long long int bin_search(long long int lef, long long int rig){
	long long int middle = (lef + rig) / 2;
	//cout << middle << " ";
	if(rig - lef <= 1){
		if(check(lef)){
			return lef;
		}else{
			return rig;
		}
	}
	if(check(middle)){
		rig = middle;
	}else{
		lef = middle;
	}
	return bin_search(lef, rig);
}

int main(){
	
	cin >> n >> k;
	
	for(int i = 0; i < n; i++){
		cin >> w[i];
	}
	
	cout << bin_search(0, 1e18) << endl;
	
	return 0;
}


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

const int maxn = 110;
int n, m, a[maxn][maxn], b[maxn][maxn], c[maxn][maxn], lnk[maxn], vis[maxn];
vector<int> G[maxn];
int id(int i, int j) { return (i - 1) * m + j; }

bool match(int v) {
    for (int i = 0, u; i < G[v].size(); i++) {
        if (vis[u = G[v][i]]) continue; vis[u] = 1;
        if (!lnk[u] || match(lnk[u])) { lnk[u] = v; return 1; }
    }
    return 0;
}

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            G[j].clear();
            for (int k = 1; k <= m; k++) {
                if (!b[j][k]) G[j].push_back((a[j][k] - 1) / m + 1);
            }
        }
        memset(lnk, 0, sizeof(lnk));
        for (int j = 1; j <= n; j++) {
            memset(vis, 0, sizeof(vis)), match(j);
        }
        for (int j = 1; j <= n; j++) {
            for (int k = 1; k <= m; k++) {
                int x = (a[j][k] - 1) / m + 1;
                if (!b[j][k] && lnk[x] == j) { b[j][k] = i; break; }
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            c[b[i][j]][i] = a[i][j];
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            printf("%d%c", c[j][i], " \n"[j == m]);
        }
    }
    for (int i = 1; i <= m; i++) {
        sort(c[i] + 1, c[i] + n + 1);
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            printf("%d%c", c[j][i], " \n"[j == m]);
        }
    }
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n,l,r;
  while(cin>>n>>l>>r,n|l|r){
    vector<int> data(n);
    for(int i=0;i<n;i++){
      cin>>data[i];
    }

    int ans=0;
    for(int i=l;i<=r;i++){
      int index=-1;
      for(int j=0;j<n;j++){
	if(i%data[j]==0){
	  index=j+1;break;
	}
      }

      if(index!=-1){
	if(index%2==1)ans++;
      }else{
	if(n%2==0)ans++;
      }
    }
    
    cout<<ans<<endl;
  }
  return 0;
}



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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;
LL N,T,t;
int main(){
   cin>>N>>T;
   
   LL sum=0;
   LL pushtime=0,endtime=0;
   REP(i,N){
        cin>>pushtime;
       // dump(endtime);
       // dump(pushtime);
        if(pushtime>=endtime){
            endtime=pushtime+T;
            sum+=T;
        }
        else{
            LL oldendtime=endtime;
            endtime+=max(T+pushtime-endtime,0LL);
            sum+=max(T+pushtime-oldendtime,0LL);
        }
   }

   cout<<sum<<endl;





}


Measured memory_bytes: 256
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(13)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N, M, k[10], s[10][10], p[10];
  cin >> N >> M;
  REP(i, M){
    cin >> k[i];
    REP(j, k[i]) cin >> s[i][j];
  }
  REP(i, M) cin >> p[i];
  int ans = 0;
  REP(i, pow(2, N)){
    bool swi[10] = {};
    int bit = i;
    REP(j, N){
      swi[j] = bit % 2;
      bit /= 2;
    }
    bool yes = 1;
    REP(j, M) {
      int cnt = 0;
      REP(K, k[j]){
        if(swi[s[j][K]-1]) cnt++;
      }
      if(cnt % 2 != p[j]) yes = 0;
    }
    if(yes) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define f(x) ((a*x/b)-a*(x/b))
ll INF=1000000000000000001;
ll mod=1000000007;
 
ll i,j,k;

int main(){
    ll a,b,n;cin>>a>>b>>n;
 
    ll ng=min(b+1,n+1),ok=0;
    while(ng-ok>1){
        ll mid=(ng+ok)/2;
        
        if(f(mid)>=f(ok)){
            ok=mid;
        }else{
            ng=mid;
        }
    }

    cout<<f(ok)<<endl;
    return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];
ll S[100005];
ll T[100005];

int main()
{
    ll N, K;
    cin >> N >> K;
    S[0] = T[0] = 0;
    REP(i, N)
    {
        cin >> A[i];
        S[i + 1] += S[i] + A[i];
        T[i + 1] += T[i] + std::max(0LL, A[i]);
    }

    ll max = -INF;
    REP(i, N)
    {
        if (i + K > N)
            break;
        ll m = T[i] + std::max(S[i + K] - S[i], 0LL) + T[N] - T[i + K];
        max = std::max(max, m);
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<algorithm>
using namespace std;
int arr[100005];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)
        scanf("%d",&arr[i]);
    int min=0x3f3f3f3f;
    int temp;
    sort(arr,arr+n);
    for(int i=0;i<=n-k;i++)
    {
        temp=arr[i+k-1]-arr[i];
        if(temp<min)
            min=temp;
    }
    printf("%d\n",min);
    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        static Dictionary<Tuple<long, long>, long> dic = new Dictionary<Tuple<long, long>, long>();

        static long mod = 1000000007;
        static long[] factorial = new long[100001];
        static long[] invFactorial = new long[100001];

        private static void calcFanctorial(long N)
        {
            factorial[0] = 1;
            for(int i=1; i< N+1; i++)
            {
                factorial[i] = factorial[i - 1] * i;
                factorial[i] %= mod;
            }
            invFactorial[N] = inv(factorial[N]);
            for (int i = (int)N; i > 0; i--)
            {
                invFactorial[i - 1] = invFactorial[i] * i % mod;
            }

        }

        static void Main(string[] args)
        {


            var AA = ReadLong();
            var BB = ReadLongArr();

            long res = 0;

            long min = AA + 1;
            for(int i=0; i<AA; i++)
            {
                if(BB[i] < min) {
                    res++;
                    min = BB[i];
                }
            }

            Console.WriteLine(res);

        }

        private static long nCm(long n, long m)
        {
            if (n < m) return 0;

             return (factorial[n] * invFactorial[m] % mod) * invFactorial[n-m] % mod;
        }

        public static long pow(long a, long b, long mod)
        {
            a %= mod;

            if (b <= 0) return 1;
            var t = pow(a, b / 2, mod);
            if ((b & 1) == 0) return t * t % mod;
            return t * t % mod * a % mod;
        }

        public static long pow(long a, long b) => pow(a, b, mod);
        public static long inv(long a) => pow(a, mod - 2);


        private static string ReadString()
        {
            return Console.ReadLine();
        }
        private static string[] ReadStringArr()
        {
            return Console.ReadLine().Split(' ');
        }
        private static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadLongArr()
        {
            string[] s = ReadStringArr();
            long[] l = new long[s.Length];
            for(int i=0; i<l.Length; i++)
            {
                l[i] = long.Parse(s[i]);
            }

            return l;
        }
    }

}


Measured memory_bytes: 35036
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using namespace std;
using ll=long long;
const ll maxn=2e5+5,inf=1e18+18;
ll n,m,x,y,par[maxn];
bool mark[maxn],b;
vector <ll> adj[maxn];
vector <ll> e[maxn];
void bfs(int u){
	for(int i:e[u]){
		for(int a:adj[i]){
			if(!mark[a]){
				par[a]=i;
				mark[a]=1;
				e[u+1].push_back(a);
			}
		}
	}
}
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	x=0;
	mark[1]=1;
	e[0].push_back(1);
	while(e[x].size()){
		bfs(x);
		x++;
	}
	for(int i=2;i<=n;i++)if(par[i]==0)b=1;
	if(b)cout<<"No";
	else{
		cout<<"Yes"<<endl;
		for(int i=2;i<=n;i++)cout<<par[i]<<endl;
	}
}


Measured memory_bytes: 20828
n = int(input())
d = list(map(int, input().split()))
d.sort()
k_count = 0
i = n // 2 - 1
arc = len(list(filter(lambda x: x > d[i], d)))
abc = len(list(filter(lambda x: x <= d[i], d)))
if arc == abc:
    k_count += (d[i+1] - d[i])
print(k_count)

Measured memory_bytes: 14428
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <iterator>
#define MAX 200001

using namespace std;

int main()
{
    int m, n, temp;
    vector<int> arr, brr;
    scanf("%d", &m);

    for (int i = 0; i < m; i++)
    {
        scanf("%d", &temp);
        arr.push_back(temp);
    }

    scanf("%d", &n);
    for (int j = 0; j < n; j++)
    {
        scanf("%d", &temp);
        brr.push_back(temp);
    }

    vector<int> vec;
   vector<int>::iterator it;
            set_symmetric_difference(
                arr.begin(), arr.begin() + m, brr.begin(), brr.begin() + n, back_inserter(vec)
                );
    //vec.resize(it - vec.begin());
    for (it = vec.begin(); it != vec.end(); it++)
    {
        printf("%d\n", *it);
    }
    return 0;
}



Measured memory_bytes: 6528
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

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

    int out = 0;
    if (N > 1)
        out += N * (N - 1) / 2;
    if (M > 1)
        out += M * (M - 1) / 2;

    cout << out << endl;
}


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

using namespace std;

int dist[2005][2005];
int cnt[2005];
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, x, y;

	cin >> n >> x >> y;


	for (int i = 1; i <= n; i++)
	{
		fill(dist[i], dist[i] + 2005, 1e9);
		priority_queue <pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> que;
		dist[i][i] = 0;
		que.push(make_pair(0,i));

		while (!que.empty())
		{
			int now = que.top().second;
			que.pop();

			if (now + 1 <= n)
			{
				if (dist[i][now + 1] > dist[i][now] + 1)
				{
					dist[i][now + 1] = dist[i][now] + 1;
					que.push(make_pair(dist[i][now+1],now+1));
				}
			}
			if (now == x)
			{
				if (dist[i][y] > dist[i][now] + 1)
				{
					dist[i][y] = dist[i][now] + 1;
					que.push(make_pair(dist[i][y], y));
				}
			}
			if (now - 1 > 0)
			{
				if (dist[i][now - 1] > dist[i][now] + 1)
				{
					dist[i][now - 1] = dist[i][now] + 1;
					que.push(make_pair(dist[i][now - 1], now - 1));
				}
			}
			if (now == y)
			{
				if (dist[i][x] > dist[i][now] + 1)
				{
					dist[i][x] = dist[i][now] + 1;
					que.push(make_pair(dist[i][x], x));
				}
			}
		}
	}

	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
		{
			cnt[dist[i][j]]++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 19344
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h1, m1, h2, m2, K;
  cin >> h1 >> m1 >> h2 >> m2 >> K;
  int t1 = h1*60 + m1;
  int t2 = h2*60 + m2;
  cout << max(-1,t2-t1-K) << endl;
}

Measured memory_bytes: 3656
n,p=map(int,input().split())
A=list(map(int,input().split()))

for i in range(n):
    A[i]%=2
zero=A.count(0)
if zero==n and p==0:
    print(2**n)
elif zero==n and p==1:
    print(0)
else:
    print(2**(n-1))

Measured memory_bytes: 3064
from sys import stdin
import math


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = math.factorial(N)%(10**9+7)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


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

using namespace std;

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    if(n == 0)
    {
        if(m==100) printf("101");
        else printf("%d",m);
    }
    if(n==1)
    {
        if(m == 100)printf("10100");
        else printf("%d",m*100);
    }
    if(n==2)
    {
        if(m==100) printf("1010000");
        else printf("%d",m*100*100);
    }
    return 0;
}

Measured memory_bytes: 256
s = list( raw_input( ) )
n = int( raw_input( ) )
for i in range( n ):
	cmd = raw_input( ).split( " " )
	a = int( cmd[1] )
	b = int( cmd[2] ) + 1
	if "print" == cmd[0]:
		print( "".join( s[ a:b ] ) )
	elif "reverse" == cmd[0]:
		for i in reversed( s[ a:b ] ):
			s[ a ] = i
			a += 1
	elif "replace" == cmd[0]:
		for i in cmd[3]:
			s[ a ] = i
			a += 1

Measured memory_bytes: 4240
#include<bits/stdc++.h>
using namespace std;
vector<int> G[100100];
int H[100100];
int main()
{
  int N,M;
  cin>>N>>M;
  for(int i=1;i<=N;i++)
    cin>>H[i];
  while(M--)
  {
    int A,B;
    cin>>A>>B;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  int Ans=0;
  for(int i=1;i<=N;i++)
  {
    bool OK=true;
    for(int j=0;j<(int)(G[i].size());j++)
      if(H[i]<=H[G[i][j]])
        OK=false;
    if(OK)
      Ans++;
  }
  cout<<Ans<<endl;
  return 0;
}

Measured memory_bytes: 9160
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
ll L, R;

int main(){
	cin >> L >> R;

	ll ans = 1e5;
	for(ll i=L; i<=min(L+2020, R); i++){
		for(ll j=i+1; j<=min((ll)i+2020, R); j++){
			ans = min(ans, (i*j)%2019);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int m = sc.nextInt();
    List<Integer> as = new ArrayList<>();
    for (int i = 0; i < a; i++) {
      as.add(sc.nextInt());
    }
    List<Integer> bs = new ArrayList<>();
    for (int i = 0; i < b; i++) {
      bs.add(sc.nextInt());
    }

    long r = Long.MAX_VALUE;
    
    for (int i = 0; i < m; i++) {
      List<Integer> cs = new ArrayList<>();
      for (int j = 0; j < 3; j++) {
        cs.add(sc.nextInt());
      }
      int t = as.get(cs.get(0) - 1) + bs.get(cs.get(1) - 1) - cs.get(2);
      if (t < r) {
        r = t;
      }
    }
    
    as.sort(Comparator.naturalOrder());
    bs.sort(Comparator.naturalOrder());
    if (as.get(0) + bs.get(0) < r) {
      r = as.get(0) + bs.get(0);
    }

    sc.close();
    System.out.println(r);
  }
}


Measured memory_bytes: 64556
import numpy as np

H, W, K = map(int, input().split())

board = np.zeros((H, W), dtype=int)

for row in range(H):
    C = list(input())
    for col in range(W):
            board[row][col] = int(C[col] == "#")

ans = 0
for h in range(2 ** H):
    h_idx = list(map(int, list(map(int, str(bin(h))[2:].zfill(H)))))
    h_idx = [i for i, flag in enumerate(h_idx) if flag]
    for w in range(2 ** W):
        w_idx = list(map(int, list(map(int, str(bin(w))[2:].zfill((W))))))
        w_idx = [i for i, flag in enumerate(w_idx) if flag]
        if np.sum(board[h_idx][:, w_idx]) == K:
            ans += 1
print(ans)

Measured memory_bytes: 27308
X1, Y1, X2, Y2 = map(int, input().split())

X3 = X2 + (Y1 - Y2)
Y3 = Y2 - (X1 - X2)
X4 = X3 + (X1 - X2)
Y4 = Y3 + (Y1 - Y2)

print(X3, Y3, X4, Y4)

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
#include <bitset>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int main(){
    int n;
    cin >> n;
    vector<int> l;
    REP(i, 2 * n){
        int tmp;
        cin >> tmp;
        l.pb(tmp);
    }
    SORT(l);
    int ans = 0;
    REP(i, n){
        ans += l[i * 2];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if "DEBUG" in sys.argv else dump_dummy

N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
ans = 10**20
for use in it.product({0, 1, 2, 3}, repeat=N):
    ABC = {0: [], 1: [], 2: [], 3: []}
    for i, u in enumerate(use):
        dump(i, u, use)
        ABC[u].append(l[i])
    if any([len(ABC[u]) == 0 for u in {1, 2, 3}]):
        continue
    ans = min(ans, sum([abs(sum(ABC[i]) - x) + (len(ABC[i]) - 1)
                        * 10 for i, x in zip([1, 2, 3], [A, B, C])]))
print(ans)


Measured memory_bytes: 49116
#include <stdio.h>

//-------------------------------------------------------------
void hairetu_zero(int bill[][10]);             //??????????????????
void tenant(int b[][10], int f, int r, int v); //??\?±?????????????
void output(int b[][10]);                      //??????
//--------------------------------------------------------------
int main(void)
{
	int n;      //?????±??°
	int b;      //?£?
	int f;      //???
	int r;      //??????
	int v;      //??????
	
	int b1[3][10];  //b1?£?
	int b2[3][10];  //b2?£?
	int b3[3][10];  //b3?£?
	int b4[3][10];  //b4?£?
	
	hairetu_zero(b1);  //??????????????????
	hairetu_zero(b2);
	hairetu_zero(b3);
	hairetu_zero(b4);
	
	scanf("%d", &n);     //?????±??°?????\???
	
	for(int i = 0; i < n; i++){
		scanf("%d %d %d %d", &b, &f, &r, &v);  //?????±?????\???
		
		if(b == 1){
			tenant(b1, f, r, v);
		}
		else if(b == 2){
			tenant(b2, f, r, v);
		}
		else if(b == 3){
			tenant(b3, f, r, v);
		}
		else if(b == 4){
			tenant(b4, f, r, v);
		}
	}
	
	output(b1);
	printf("####################\n");
	output(b2);
	printf("####################\n");
	output(b3);
	printf("####################\n");
	output(b4);
	
	return 0;
}

//--------------------------------------------------------//??????????????????
void hairetu_zero(int bill[][10])
{
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 10; j++){
			bill[i][j] = 0;
		}
	}
}
//--------------------------------------------------------//??\?±?????????????
void tenant(int b[][10], int f, int r, int v)
{
	b[f-1][r-1] += v;
	
	if(b[f-1][r-1] < 0){
		b[f-1][r-1] = 0;   //?????????????¨???§?????¨?±??????\?±??????°?????????????°??????????????????¨?????????
	}
	if(b[f-1][r-1] > 9){
		b[f-1][r-1] = 9;   //?????????????¨???§?????¨?±??????\?±??????°???9???????????????????????¨?????????
	}
}
//--------------------------------------------------------//??????
void output(int b[][10])
{
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 10; j++){
			printf(" %d", b[i][j]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 2712
x,y = map(int,input().split())

flg = 0

for i in range(x+1):
    if 2*i + 4*(x-i) == y:
        flg = 1

    if flg == 1:
        break
    #print(i,x-i,2*i + 4*(x-i))

if flg == 1:
    print("Yes")
else:
    print("No")
        
    
    

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  vector<int> p(m);
  for(int i=0;i<m;i++){
    int k;cin >> k;
    s[i].resize(k);
    for(int j=0;j<k;j++){
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  for(int i=0;i<m;i++){
    cin >> p[i];
  }
  int ans=0;
  for(int bit=0;bit<(1<<n);bit++){
    int sum=0;
    for(int i=0;i<m;i++){
      int cnt=0;
      for(int j=0;j<s[i].size();j++){
        if(bit&(1<<s[i][j])){
          cnt++;
        }
      }
      if(cnt%2==p[i]){
        sum++;
      }
    }
    if(sum==m){
      ans++;
    }
  }
  cout << ans << endl;
}

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

using ll=long long;



void solve(){
    vector<int> a(4);
    for(auto& e:a)cin>>e;
    sort(a.begin(), a.end());
    if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

signed main(){
    //while(1)
    solve();
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int low = 1e9, high = -1e9;
  while (n--) {
    int x;
    cin >> x;
    low = min(low, x);
    high = max(high, x);
  }
  cout << abs(high - low) << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class BCoins
    {        
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            var c = int.Parse(Console.ReadLine());
            var x = int.Parse(Console.ReadLine());

            var cnt = 0;

            for (int i = 0; i <= a; i++)
            {
                for (int j = 0; j <= b; j++)
                {
                    for (int k = 0; k <= c; k++)
                    {
                        int t = 500 * i + 100 * j + 50 * k;
                        if (t == x)
                        {
                            cnt++;
                        }
                    }
                }
            }

            Console.WriteLine(cnt);
            Console.ReadLine();
        }
  }
}

Measured memory_bytes: 13140
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: i64,
    a: i64,
    b: i64,
    c: i64,
    d: i64,
  }
  let mut ans = false;
  for pos in 0 .. n - 1 {
    let neg = n - 1 - pos;
    let min = a + c * pos - d * neg;
    let max = a + d * pos - c * neg;
    if min <= b && b <= max {
      ans = true;
      break;
    }
  }

  println!("{}", if ans { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
A, B, C, D = list(input())

op_set = [[op1, op2, op3, ""] for op1 in ["+", "-"] for op2 in ["+", "-"] for op3 in ["+", "-"]]

for i in range(8):
    string = "".join([s1 + s2 for s1, s2 in zip([A, B, C, D], op_set[i])])
    if eval(string) == 7:
        print(string + "=7")
        break


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n;
    cin>>n;
    for(int i=0;i<=50000;i++)
        if(floor(i*1.08)==n)
            cout<<i<<endl,exit(0);
    cout<<":("<<endl;
}


Measured memory_bytes: 256
import math
N,D = list(map(int, input().split()))

Xarray = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N-1):
    for j in range(i+1,N):
        sum = 0
        for k in range(D):
            sum += abs(Xarray[i][k] - Xarray[j][k]) ** 2
        
        if math.sqrt(sum).is_integer():
            ans += 1

print(ans)

Measured memory_bytes: 9184
N = int(input())
h = list(map(int,input().split()))
higest = max(h)
count = 0

for i in range(1,higest+1):
    a = 0
    for j in h:
        if j < i:
            a = 1
        elif a == 1:
            count += 1
            a = 0
    if h[0] >= i:
        count += 1

print(count)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ll long long int
int n ;
ll dp[100005][2];vector<int> v[100005];int x, y ; 

ll func(int node, int p, int c)
{
	
	if(dp[node][c]!=-1)
	return(dp[node][c]);
	
   
    if(c==1)
    {
	ll ans = 1; 
    for(int i = 0 ; i<v[node].size(); i++)
    {
    	if(v[node][i]!=p)
    	{
    		ans =(ans*func(v[node][i],node,0))%mo;
		}
	}
	return(dp[node][c]=ans);
}
else
{ ll ans = 1; 
	 for(int i = 0 ; i<v[node].size(); i++)
    {
    	if(v[node][i]!=p)
    	{ 
    		ans =(ans*((func(v[node][i],node,0)+func(v[node][i],node,1))%mo))%mo;
		}
	}
	return(dp[node][c]=ans);
}
}

int main()
{
	ios_base:: sync_with_stdio(false);cin.tie(NULL);
	cin>>n;
	for(int i = 0; i<n-1; i++)
	{
		cin>>x>>y; 
		v[x].push_back(y);
		v[y].push_back(x);

	}

memset(dp,-1,sizeof(dp));
cout<<(func(1,-1,0)+func(1,-1,1))%mo;

return(0);
}


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

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    int n;
    cin >> n;
    if (n==1) {
        cout << 0 << endl;
        return 0;
    }
    mint nine = 10;
    mint eight = 9;
    mint seven = 8;
    mint ans = nine.pow(n);
    ans -= eight.pow(n) * 2;
    ans += seven.pow(n);
    cout << ans << endl;
    return 0;
}
/*
g++ -std=c++17 -Wall -Wextra -g -O0 -fsanitize=undefined,address main.cpp && oj t
*/

Measured memory_bytes: 3620
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
5 3
10 30 40 50 20
---+/
/+---test
3 1
10 20 10
---+/
/+---test
2 100
10 10
---+/

void main(string[] args) {
  int N, K;
  readf(" %d %d ", &N, &K);

  const heights = readln.split.map!(to!long).array;

  auto dp = new long[N];
  dp[]  = long.max;
  dp[0] = 0;

  foreach (i; 0..N-1) {
    foreach (k; 0..min(K, i+1)) {
      dp[i+1] = dp[i+1].min(dp[i-k] + abs(heights[i-k] - heights[i+1]));
    }
  }
  dp[$-1].writeln;
}


Measured memory_bytes: 4516
main :: IO ()
main = do
    n <- getLine
    putStrLn $ ' ':(ints2string $ call (read n :: Int))

ints2string :: [Int] -> String
ints2string = unwords.map show

call :: Int -> [Int]
call n = [x | x <- [1..n], check x]

check :: Int -> Bool
check n = checkMod3 n || checkMod10 n

checkMod3 :: Int -> Bool
checkMod3 n = n `mod` 3 == 0

checkMod10 :: Int -> Bool
checkMod10 0 = False
checkMod10 n = n `mod` 10 == 3 || checkMod10 (n `div` 10)

Measured memory_bytes: 4080
#include <iostream>
using namespace std;
int main () {
	int K;
	cin >> K;
	long long int N=0;
	if (K%2==0) {
		cout << "-1" << endl;
		return 0;
	}
	int ans=1;
	while (N>=0) {
		N=(N*10+7)%K;
		if (ans>K) {
			cout << "-1" << endl;
			break;
		}
		if (N==0) {
			cout << ans << endl;
			break;
		}
		ans++;
	}
}

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


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

	ll n, k;	cin >> n >> k;

	ll final = n - (n / k) * k;

	if (n > k)
		cout << min(final, abs(final - k)) << endl;
	else
		cout << min(n, abs(k - n)) << endl;


	return 0;
}

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

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

fn parse_quadraple<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let line = parse_line::<String>();
    let mut iter = line.split_whitespace();
    (
        iter.next().unwrap().parse().ok().unwrap(),
        iter.next().unwrap().parse().ok().unwrap(),
        iter.next().unwrap().parse().ok().unwrap(),
        iter.next().unwrap().parse().ok().unwrap(),
    )
}

// ------------------------------------------------------------------------

fn main() {
    let (w, h, x, y) = parse_quadraple::<f64, f64, f64, f64>();

    let (center_x, center_y) = (w / 2.0, h / 2.0);

    println!("{} {}", w * h / 2.0, if x == center_x && y == center_y { 1 } else { 0 });
}


Measured memory_bytes: 4352
#include"bits/stdc++.h"
using namespace std;

int keta(int x) {
  int k = 0;
  while (x) {
    x /= 10;
    k++;
  }
  return k;
}

void Main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (keta(i) % 2 != 0) {
      ans++;
    }
  }

  cout << ans << endl;
}

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

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

using namespace std;

typedef long long       ll;

#define all(x)            (x).begin(),(x).end()
#define Sort(x)            sort(all(x))
#define A               first
#define B               second
#define sep             ' '
#define fast_io         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random     mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count())

const int MAX1 = 1e6+10,
         Md = 1e9+7,
		 Base = 257;

ll n, bol, root;
string s;

int main(){
    fast_io;
    cin >> s;
    n = s.size();
    for (int i = 0; i < n-1; ++i){
    	if (s[i] != s[n-2-i])	bol = 1;
	}
	if (bol || s[0] == '0' || s[n-1] == '1'){
		cout << -1;
		return 0;
	}
	root = 1;
	for (int i = 0; i < n-1; ++i){
		cout << root << sep << i+2 << '\n';
		if (s[i] == '1')	root = i+2;
	}
    return 0;
}
/*               now or never                 */


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

bool check(const char c){
    return(c=='A' or c=='C' or c=='G' or c=='T');
}

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

    size_t len{0};

    for(size_t s{0}; s<S.size(); ++s){
        for(size_t n{0}; n<S.size()-s; ++n){

            if(not check(S.at(s+n))){
                break;
            }

            if(n+1>len){
                len = n+1;
            }
        }

    }


    cout << len << endl;
}


Measured memory_bytes: 3596
s=input()
a=int(s[0])*10+int(s[1])
b=int(s[2])*10+int(s[3])
pp=['NA','MMYY','YYMM','AMBIGUOUS']
c=0
if 1<=a<=12:
  c+=1
if 1<=b<=12:
  c+=2
print(pp[c])

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
int isprime(int x){
	if(x==2)return 1;
	if(x<2||x%2==0)return 0;
	int i=3;
	while(i<=sqrt(x)){
		if(x%i==0)return 0;
		i++;
		}
	return 1;
	}
int main(){
	int x,n,c=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		if(isprime(x)==1)c++;
	}
	printf("%d\n",c);
	return 0;
	}


Measured memory_bytes: 2040
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];
    
    deque<int> b;
    for(int i=0; i<n; ++i){
        if(i % 2 == 0)
            b.push_back(a[i]);
        else
            b.push_front(a[i]);
    }
    if(n % 2 != 0)
        reverse(b.begin(), b.end());
    
    cout << b[0];
    for(int i=1; i<n; ++i)
        cout << ' ' << b[i];
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <map>
#include <numeric>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll A,B;
ll gcd(ll a,ll b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int main(){
    cin >> A >> B;
    ll u = gcd(A,B);
    ll count = 0;
    if(u%2==0)count++;
    while(u%2==0)u /= 2;
    for(ll i = 3;i*i<u;i++){
        if(u%i==0){
            count++;
            while(u%i==0){
                u /= i;
            }
        }

    }
    if(u!=1)count++;
    cout << count+1 << endl;
    return 0;

}

Measured memory_bytes: 256
#!/usr/bin/perl

my ($n) = map {$_ - 0} split(/\s+/o,<STDIN>);
my @s = ();
my %cnt = ();
my $res = 0;
for(my $i=0;$i<$n;$i++){
  my $s = <STDIN>;
  $s =~ s/[\x00-\x20]+$//ios;
  push(@s,$s);
  my $c1 = substr($s,0,1);
  my $c2 = substr($s,-1,1);
  $c1 = 'x' if $c1 ne 'B';
  $c2 = 'x' if $c2 ne 'A';
  $cnt{"$c1$c2"} ++;
  my $o_c = ( $s =~ s/AB//gio );
  $res += $o_c;
}

if( $cnt{'BA'} - 0 > 0 ){
  $res += ( $cnt{'BA'} - 1 );
  if( $cnt{'Bx'} - 0 > 0 ){
    $cnt{'Bx'} = $cnt{'Bx'} - 1;
    $res ++;
  }
  if( $cnt{'xA'} - 0 > 0 ){
    $cnt{'xA'} = $cnt{'xA'} - 1;
    $res ++;
  }
}

my $bx = $cnt{'Bx'} - 0;
my $xa = $cnt{'xA'} - 0;

my $mn = ($bx > $xa ? $xa : $bx );
$res += $mn;
print "$res\n";


Measured memory_bytes: 1408
//   Rishabh Agarwal
#include <bits/stdc++.h>
#define F first
#define S second
#define MAX 10000003
using namespace std;

typedef long long int ll;
const ll mod = 1e9+7;
const ll INF= 1e18;
long double PI=3.1415926;

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll temp=power(a,b/2)%mod;
    if(b%2==0){
        return (temp*temp)%mod;
    }
    else{
        return ((a*temp)%mod*temp)%mod;
    }
}

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

vector<ll>v;
vector<ll>::iterator it;
map<ll,ll>mp;

void primeFactors(ll n)  
{  
    while (n % 2 == 0)  
    {  
        mp[2]++;
        n = n/2;  
    }  
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        while (n % i == 0)  
        {  
            mp[i]++;
            n = n/i;  
        }  
    }  
    if (n > 2){ 
        mp[n]++; 
    } 
}  



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    //cin>>t;
    t=1;
    //ll c=1;
    while(t--){
        ll n,k;
        cin>>n>>k;
        ll a[n];
        for(ll x=0; x<n; x++){
            cin>>a[x];
        }
        ll dp[n+1][k+1];
        for(ll x=0; x<=n; x++){
            for(ll y=0; y<=k; y++){
                if(x==0||y==0){
                    dp[x][y]=1;
                }
                else if(y-a[x-1]-1<0){
                    dp[x][y]=dp[x][y-1]+dp[x-1][y];
                }
                else{
                    dp[x][y]=dp[x][y-1]+dp[x-1][y]-dp[x-1][y-a[x-1]-1];
                    if(dp[x-1][y]-dp[x-1][y-a[x-1]-1]<0){
                        dp[x][y]+=mod;
                    }
                }
                dp[x][y]%=mod;
            }
        }
        ll ans=dp[n][k];
        if(k-1>=0){
            ans-=dp[n][k-1];
        }
        if(ans<0){
            ans+=mod;
        }
        cout<<ans<<"\n";
        mp.clear();  
        v.clear();
        //cout<<"Case #"<<c<<": "<<ans<<"\n";
        //c++;
    }
    return 0;
}

Measured memory_bytes: 79232
/*
 KUNAL RAUT (ZUKONIT14)  :- "DO WHAT YOU LIKE!"
 -PICT,PUNE! :)
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define mod9 1000000009
#define pi 3.1415926535
#define MAXN 100005
#define N 1000001
#define MAX2N 1*1000 + 10
#define all(v) v.begin(), v.end()
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define forci(p,n) for(ll i=p;i<(ll)n;i++)
#define forcj(p,n) for(ll j=p;j<(ll)n;j++)
#define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define bits(a) __builtin_popcount(a)
#define test ll t;cin>>t;for(ll testi=1;testi<=t;testi++)
ll zero = 0;
ll one = 1;
ll gcd(ll a, ll b) {    if (b == 0) return a;    return gcd(b, a % b);}
ll lcm(ll a, ll b) {    return (a / gcd(a, b) * b);}
ll expo(ll x, ll y) {
    ll res = 1; x = x % mod; while (y > 0) {
        if (y & 1)res = (1ll * res * x) % mod;
        y = y >> 1; x = (1ll * x * x) % mod;
    } return res;
}
ll ncr(ll n, ll r) { ll res = 1; if (r > n - r)r = n - r; for (ll i = 0; i < r; i++) {  res *= n - i;  res /= i + 1; } return res;}
ll max(ll a, ll b) {return (a > b) ? a : b;}
bool prime(ll n) {ll i; for (i = 2; i <= sqrt(n); i++) {if (n % i == 0)return false;} return true;}
bool sortbysec(const pair<ll, ll> &a, const pair<ll, ll> &b)
{   if (a.second == b.second)
        return a.first < b.first;
    return (a.second < b.second);
}
//https://www.youtube.com/watch?v=WTJSt4wP2ME

ll rr[] = {0, 1, 1, 1, 0, -1, -1, -1,};
ll cc[] = {1, 1, 0, -1, -1, -1, 0, 1};

ll a[MAXN], ans[MAXN];

signed main()
{
    bolt;
// #ifndef ONLINE_JUDGE
//     freopen("input00.txt", "r", stdin);
//     freopen("output00.txt", "w", stdout);
// #endif
    string s; cin >> s;
    if (s[2] == s[3] && s[4] == s[5])    cout << "Yes";
    else    cout << "No";
}








Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <complex>

using namespace std;

typedef complex<double> P;

const double EPS = 1e-8;

double cross(P a, P b) { return imag(conj(a)*b); }

vector<P> convexCut(const vector<P> &vp, P p, P q){
	vector<P> res;
	int n = vp.size();
	for(int i=0;i<n;i++){
		P A(vp[i]), B(vp[(i+1)%n]);
		double p1 = cross(q-p,A-p);
		double p2 = cross(q-p,B-p);
		if(p1 > -EPS) res.push_back(A);
		if(p1*p2 < -EPS)
			res.push_back(A+cross(q-p,q-A)/cross(q-p,B-A)*(B-A));
	}
	return res;
}

int main(){
	int n;
	while(cin >> n, n){
		vector<P> vp;
		for(int i=0;i<n;i++){
			int x, y; cin >> x >> y;
			vp.push_back(P(x,y));
		}
		double L = 0.0, R = 1e6;
		for(int cnt=0;cnt<200;cnt++){
			double mid = 0.5*(L+R);
			vector<P> cur = vp;
			for(int i=0;i<n;i++){
				P dir = P(0,1)*(vp[(i+1)%n]-vp[i]);
				dir = dir/abs(dir)*mid;
				cur = convexCut(cur, vp[i]+dir, vp[(i+1)%n]+dir); 
			}
			cur.empty() ? R = mid : L = mid;
		}
		printf("%.8lf\n", 0.5*(L+R));
	}
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;
typedef long double ld;

const ll mod = 1e9+7;


ll fpow(ll a, ll b, ll p){
	ll res = 1; a%=p;
	while(b>0){
		if (b&1) res = res*a%p;
		a = a*a%p;
		b>>=1;
	}
	return res;
}

const int maxn = 2e6+5;
ll f[maxn], rcnt[maxn], ccnt[maxn];
ll r1, r2, c1, c2;

ll inv(ll n) { return fpow(n, mod-2, mod); } 
ll ncr(ll n, ll k, ll p) { 
    if (k == 0 or n == k) return 1;
    ll ans = f[n]*inv(f[k])%p * inv(f[n-k])%p;
    return ans%p;
} 


int main(){
	f[0] = f[1] = 1;
	for(ll i = 2; i<maxn; i++) f[i] = (f[i-1]*i)%mod;
	cin >> r1 >> c1 >> r2 >> c2;
	ll ans = 0;
	for(ll row = r1+1; row<=r2+1; row++){
		ans += ncr(row+c2, c2, mod);
		ans -= ncr(row+c1-1, c1-1, mod);
		ans = ((ans%mod)+mod)%mod;
	}
	ans = ((ans%mod)+mod)%mod;
	cout << ans << endl;
	return 0;
}


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

int main() {
    int n,k,t=0,ans=0,u=1;
    cin >> n >> k;
  while (true) {
      if (n-t<u) break;
      if (u*k>=t) {t+=u;ans++;}
      else {u++;continue;}
  }
  cout << ans << endl;
}


Measured memory_bytes: 3100