akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Linq;
using System.Text;

class Program{
    static void Main(string[] args){
        var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = arr[0];
        var a = arr[1];
        var b = arr[2];
        var c = 0;
        var d = 0;
        var s = Console.ReadLine();
        var stringBuilder = new StringBuilder();
        for (int i = 0; i < n; i++){
            if(c < a + b){
                if (s[i] == 'a'){
                    stringBuilder.Append("Yes").AppendLine();
                    c++;
                    continue;}
                if (s[i] == 'b' && d < b){
                    stringBuilder.Append("Yes").AppendLine();
                    c++;
                    d++;
                    continue;}}
            stringBuilder.Append("No").AppendLine();}
        var answer = stringBuilder.ToString();
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

void solve(long long N) {
  ll n = -N;
  while (n < 0) {
    n += 1000;
  }
  cout << n << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 3760
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE ViewPatterns          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Builder     as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import qualified System.IO                   as IO
import           Unsafe.Coerce

main :: IO ()
main = do
    [h, w] <- map read.words <$> getLine :: IO [Int]
    mat <- U.unfoldrN (h*w) C.uncons . C.filter (\c -> c == '#' || c == '.') <$> C.getContents
    print $ solve h w mat

solve :: Int -> Int -> U.Vector Char -> Int
solve h w mat = U.maximum $ U.zipWith3 score mat lr ud
  where
    ix i j = i * w + j

    score '.' lr ud = lr + ud - 3
    score '#' _ _ = 0

    trans :: U.Vector Int -> U.Vector Int
    trans m = U.unsafeBackpermute m $ U.generate (h * w) $ \ij ->
        let (i, j) = quotRem ij w
        in j * h + i

    lr :: U.Vector Int
    lr = U.concatMap (\i ->
        let row = U.unsafeSlice (i * w) w mat
        in U.zipWith (+)
            (U.postscanl' (\acc c -> if c == '#' then 0 else acc + 1) 0 row)
            (U.postscanr' (\c acc -> if c == '#' then 0 else acc + 1) 0 row)
        )
        $ U.generate h id

    ud :: U.Vector Int
    ud = trans
        . U.concatMap (\j ->
            let column = U.map (U.unsafeIndex mat) $ U.iterateN h (+w) j
            in U.zipWith (+)
                (U.postscanl' (\acc c -> if c == '#' then 0 else acc + 1) 0 column)
                (U.postscanr' (\c acc -> if c == '#' then 0 else acc + 1) 0 column)
        )
        $ U.generate w id


Measured memory_bytes: 151292
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define debug(...)                                                             \
    { cerr << "# " << __VA_ARGS__ << "\n"; }
#else
#define debug(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
  public:
    i64 c[maxn];
    i64 n, p;
    string s;
    void solve() {
        cin >> n >> p >> s;
        i64 a = 0, ans = 0, deg = 1;
        if (p == 2 || p == 5) {
            for (int i = 0; i < n; ++i) {
                if ((s[i] - '0') % p == 0) {
                    ans += i + 1;
                }
            }
            cout << ans << '\n';
            return;
        }
        c[0] = 1;
        for (int i = 0; i < n; ++i) {
            int cr = s[i] - '0';
            a = (a * 10 + cr) % p;
            ans += c[a * pw(deg, p - 2) % p];
            c[a * pw(deg, p - 2) % p]++;
            deg = deg * 10 % p;
        }
        cout << ans << '\n';
    }
    i64 pw(i64 a, i64 b) {
        i64 res = 1;
        while (b) {
            if (b & 1ll)
                res = res * a % p;
            a = a * a % p;
            b >>= 1;
        }
        return res;
    }
} NSPACE;
int main() {
    FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

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

int main(){
  long long n, m, ans = 0;
  
  cin >> n >> m;
  
  if(n * 2 <= m){
    ans += n;
    m -= n * 2;
    ans += m / 4;
  }else ans += m / 2;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		Scanner scan = new Scanner(System.in);
		String answer = "";
		String temp = "";
		
		while(true){
			temp = scan.next();
			if(temp.equals("-")){
				break;
			}
			char[] targetChar = temp.toCharArray();
			int targetLength = temp.length();
			int shuffleTimes = scan.nextInt();
			int[] shuffleBegin = new int[shuffleTimes];

			for(int i =0; i<shuffleTimes; i++){
				shuffleBegin[i] = scan.nextInt();
				answer = "";

				for(int j=0; j<(targetLength - shuffleBegin[i]) ; j++){
					answer = answer + targetChar[j + shuffleBegin[i]];
				}
				for(int j=0; j<shuffleBegin[i]; j++){
					answer = answer + targetChar[j];
				}
				targetChar = answer.toCharArray();
			}
			System.out.println(answer);
		}
	}
}

Measured memory_bytes: 46112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int aa(int a, int b){return min(a, b)*10000+max(a, b);}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int n,m;
    cin>>n;
    vvint a;
    initvv(a, n, n-1, 0);
    rep(i, n){
        rep(j, n-1){
            cin>>a[i][j];
        }
    }
    vint pos(n, 0);
    //vint t(n*(n+1)+n-1 + 1, 0);
    int day = 0;
    rep(i, min(n*(n-1)/2+1, 10000)){
        unordered_map<int, int> mm;
        rep(j, n){
            if(pos[j]>=n-1)continue;
            int aite = a[j][pos[j]];
            int v = mm[max(j+1, aite)*(n+1)+min(j+1, aite)];//mm[P(max(j+1, aite), min(j+1, aite))];
            //mm[P(max(j+1, aite), min(j+1, aite))]++;
            mm[max(j+1, aite)*(n+1)+min(j+1, aite)]++;
            //t[max(j+1, aite)*(n+1)+min(j+1, aite)]++;
        }
        bool flag = true, df = false;
        /*rep(j, n*(n+1)+n-1 + 1){
            if(t[j]==2){
                pos[j/(n+1)-1]++;
                pos[j%(n+1)-1]++;
                
                df = true;
                flag = false;
            }
            t[j] = 0;
        }*/
        for(auto i = mm.begin();i!=mm.end();i++){
            if(i->second==2){
                pos[(i->first)/(n+1)-1]++;
                pos[(i->first)%(n+1)-1]++;
                
                df = true;
                flag = false;
            }
        }
        //rep(k, n){
        //    debug("day(%d) pos %d : %d\n", day, k, pos[k]);
        //}
        if(df){day++;}
        if(flag){
            rep(k, n){
                if(pos[k]!=n-1){
                    cout << -1 << endl;
                    return 0;
                }
            }
            cout << day << endl;
            return 0;
        }
    }
    cout << n*(n-1)/2 << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

void ABC132A()
{
	string S;
	cin >> S;
	sort(S.begin(), S.end());
	bool good = S[0] == S[1] && S[1] != S[2] && S[2] == S[3];
	if (good)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main()
{
	ABC132A();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        cout<<"node "<<i<<": "<<"key = "<<a[i]<<", ";
        if(i/2>0){
            cout<<"parent key = "<<a[i/2]<<", ";
        }
        if(2*i<=n){
            cout<<"left key = "<<a[2*i]<<", ";
        }
        if((2*i+1)<=n){
            cout<<"right key = "<<a[2*i+1]<<", ";
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
constexpr ll INF = 1LL<<60;

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

    ll ans = 0;
    FOR(a, 1, k+1) FOR(b, 1, k+1) FOR(c, 1, k+1) ans += gcd(a, gcd(b, c));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3656
n, y = map(int, input().strip().split(' '))
flag = False
for i in range(n+1):
        for j in range(n-i+1):
                if 10000*i+5000*j+1000*(n-i-j) == y:
                        print(i,j,n-i-j)
                        flag = True
                        break
        if flag:
                break
if flag == False:
        print(-1,-1,-1)

Measured memory_bytes: 3060
import java.util.*;


public class Main {
    public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      int[] ary = new int[3];
      for (int i = 0; i < ary.length; i++) {
        ary[i] = Integer.parseInt(sc.next());
      }
      System.out.println(ary[2] + " " + ary[0] + " " + ary[1]);
    }
}

Measured memory_bytes: 20820
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    cout << min(B/A,C) << endl;
}

Measured memory_bytes: 764
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import sys, math, random
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"
# S=numpp.assaray(S)=="#"
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LLS(): return [list(sys.stdin.readline().rstrip()) for _ in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()



def main():
    A=S()
    B=S()
    out=0
    if A[0]==B[0]:
        out+=1
    if A[1]==B[1]:
        out+=1
    if A[2]==B[2]:
        out+=1
    print(out)


if __name__ == "__main__":
    main()

Measured memory_bytes: 22712
#include <bits/stdc++.h>
using namespace std;
int dp2[3100][6100] = {};
 
int main() {
    int N, T; cin >> N >> T;
    vector<pair<int, int>> A(N);
    for(int i=0; i<N; ++i) cin >> A[i].first >> A[i].second;
    sort(begin(A), end(A));
 
    for(int i=0; i<N; ++i) {
        for(int j=0; j<=T + 3000; ++j) {
            dp2[i + 1][j] = dp2[i][j];
            if(j >= A[i].first && (j - A[i].first) < T) dp2[i + 1][j] = max(dp2[i][j - A[i].first] + A[i].second, dp2[i + 1][j]);
        }
    }
 
    int res = 0;
    for(int j=0; j<=T+3000; ++j) res = max(res, dp2[N][j]);
    cout << res << endl;
}

Measured memory_bytes: 71936
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void push(int x);
int pop(void);

int top,S[1000];

int main(){
  int a,b;
  top = 0;
  char s[100];
  while(scanf("%s",s)!=EOF){
    if(s[0] == '+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(s[0] == '-'){
      b=pop();
      a=pop();
      push(a-b);
    }
    else if(s[0] == '*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());

  return 0;
}

void push(int x){
  top++;
  S[top] = x;
}
int pop(){
  top--;
  return S[top+1];
}



Measured memory_bytes: 2104
N = int(input())
A = list(map(int, input().split()))
ans = 1
flag = 0
if(0 in A):
  print(0)
else:
  for i in range(N):
    if(ans*A[i] > 10**18):
      flag = 1
      break
    else:
      ans *= A[i]
  if(flag == 1):
    print(-1)
  else:
    print(ans)

Measured memory_bytes: 21784
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

struct node{
  string name;
  double prime;
  node(string s,double d):name(s),prime(d){}
  bool operator >(const node &e) const{
    if(prime==e.prime)
      return name>e.name;
    return prime<e.prime;
  }
};

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      priority_queue<node,vector<node>, greater<node> > qu;
      for(int i=0;i<n;i++)
	{
	  int p,a,b,c,d,e,f,s,m;
	  string l;
	  cin>>l>>p>>a>>b>>c>>d>>e>>f>>s>>m;
	  double time=a+b+c+(d*m)+(e*m);
	  double prime=(m*f*s)-p;
	  qu.push(node(l,prime/time));
	}
      while(!qu.empty())
	{
	  node tmp=qu.top();
	  qu.pop();
	  cout<<tmp.name<<endl;
	}
	  cout<<"#"<<endl;
    }

}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int get(int h, int m) {
	return h * 60 + m;
}
int main() {
	int h1, m1, h2, m2, k;
	read(h1), read(m1), read(h2), read(m2), read(k);
	cout << get(h2, m2) - get(h1, m1) - k << endl;
	return 0;
}


Measured memory_bytes: 3536
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
using namespace std;
using ll = long long;
int main()
{
	ll a, b, c = 0, d;
	cin >> a;
	ll s[1000];
	for (int i = 0; i < a; i++)
	{
		cin >> s[i];
	}
	sort(s, s + a);


	for (int i = 0; i < a; i++)
	{
		c += s[i];
	}
	if (c % 10 == 0)
	{
		for (int i = 0; i < a; i++)
		{
			if (s[i]%10!=0)
			{
				c -= s[i];
				cout << c << endl;
				return 0;
			}
		}
		cout << 0 << endl;
		return 0;
	}


	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;

LL n,x,v,w;
LL dp[105][100005] = {0};

int main(){
	scanf("%lld %lld",&n,&x);
	for(LL i = 1;i <= n;i ++){
		scanf("%lld %lld",&w,&v);
		for(LL j = 0;j <= x;j ++){
			dp[i][j] = dp[i - 1][j];
			if(j >= w) dp[i][j] = max(dp[i][j],dp[i - 1][j - w] + v);
		}
	}
	printf("%lld\n",dp[n][x]);
	return 0;
}

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

int main() {
  string s;
  cin >> s ;
  if(s.at(0)==s.at(1) || s.at(1)==s.at(2) || s.at(2)==s.at(3))cout <<"Bad"<<endl;
  else cout << "Good" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include <cstdint>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
#define ll long long int
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}

ll kai(ll x) {
	ll a = 1;
	if (x <= 0)
		return 1;
	else {
		for (ll i = 0; i < x; i++)
			a = a * (i + 1);
		return a;
	}
}

ll rui(ll x, ll y) {
	ll a = 1;
	for (ll i = 0; i < y; i++)
		a = a * x;
	return a;
}
const int nmax = 150;
int cccc[nmax][nmax];
ll comb(ll n, ll k) {
	if (n < k) {
		cout << "error n<k" << endl;
		return -1;
	}
	if (cccc[n][k] > 0)return cccc[n][k];
	if (k == 0 || n == k)return 1;
	return cccc[n][k] = comb(n - 1, k - 1) + comb(n - 1, k);
}


int main() {
	//cout.precision(16);
	ll N, M, X;
	cin >> N >> M >> X;
	vector<ll>C(N);
	vector<vector<ll>>A(N);
	rep(N) {
		cin >> C[i];
		A[i].resize(M);
		For(j, M)
			cin >> A[i][j];
	}
	int flag = 1;
	ll cnt;
	for (int i = 0; i < M; i++) {
		cnt = 0;
		for (int j = 0; j < N; j++)
			cnt += A[j][i];
		if (X > cnt) {
			flag = 0;
		}
	}
	if (flag == 0) {
		cout << -1;
		return 0;
	}
	ll ans = 9999999999999;
	ll count=0;
	vector<ll>counterM(M);
	vector<ll>counterX(M);
	vector<int>check(12);
	For(i, 2) {
		For(j, 2) {
			For(k, 2) {
				For(i1, 2) {
					For(j1, 2) {
						For(k1, 2) {
							For(i2, 2) {
								For(j2, 2) {
									For(k2, 2) {
										For(i3, 2) {
											For(j3, 2) {
												For(k3, 2) {
													check[0] = i;
													check[1] = j;
													check[2] = k;
													check[3] = i1;
													check[4] = j1;
													check[5] = k1;
													check[6] = i2;
													check[7] = j2;
													check[8] = k2;
													check[9] = i3;
													check[10] = j3;
													check[11] = k3;
													count = 0;
													For(ck, M)
														counterM[ck] = 0;
													For(ck, N) {
														if (check[ck] == 1) {
															count += C[ck];
															For(ck2, M) {
																counterM[ck2] += A[ck][ck2];
															}
														}
														
													}
													flag = 1;
													For(ck, M) {
														if (counterM[ck] < X)
															flag = 0;
													}
													if (flag == 1) {
														ans = min(ans, count);
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int n,i,s=0,sum=0,ans;
	int w[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&w[i]);
		sum+=w[i];
	}
	ans=sum;
	for(i=0;i<n;i++){
		s+=w[i];
		if(abs(sum-2*s)<ans){
			ans=abs(sum-2*s);
		}
	}
	printf("%d",ans);
	return 0;
}

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

int main(){


  int n,m,f[100],t[100],x; 

  memset(&f[0],0,sizeof(f));
  memset(&t[0],0,sizeof(t));

  cin >> n>>m;

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


  for(int i=0;i<m;++i){
    for(int k=0; k<n;++k){
      cin >> x;
      if(x == t[i]) {
	++f[k];
      }else ++f[t[i]-1];
      
    }
  }


  for(int i=0; i<n;++i){
    cout << f[i] <<endl;
  }



  
  return 0;
}



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

using namespace std;

int main(){
    int n,h; cin >> n >> h;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    int maxattack = a[n-1];
    int maxthrow = b[n-1];
    int ans = 0;
    if(maxattack >= maxthrow){
        ans = (h + maxattack-1)/ maxattack;
    }
    else{
        vector<int>::iterator lb = lower_bound(b.begin(), b.end(), maxattack);
        bool flag = false;
        for(vector<int>::iterator itr = b.end()-1;itr >= lb; itr--){
            ans++;
            h -= *itr;
            if(h <= 0){
                flag = true;
                break;
            }
        }
        if(!flag){
            ans += (h + maxattack-1)/maxattack;
        }
    }
    cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1024
g = [[-1 for _ in range(15)] for _ in range(15)]
n = int(input())
ans=0
for i in range(n):
  m = int(input())
  for j in range(m):
    x,y = map(int, input().split())
    g[i][x-1] = y
for i in range(1<<n):
  honests = [0 for _ in range(n)]
  for j in range(n):
    if (i>>j) &1:
      honests[j] = 1     
  ok = True  
  for j in range(n):
    if honests[j]:
      for k in range(n):
        if g[j][k] == -1: continue
        if g[j][k] != honests[k]: ok = False
  if ok:
    ans = max(ans, honests.count(1))
print(ans)

Measured memory_bytes: 9148
#include<iostream>

using namespace std;
int main()
{
    int a, b, c,d ,a1,a2;
    cin>>a>>b>>c>>d;
    a1=a*b;
    a2=c*d;
    if(a1>a2)
        cout<<a1;
    else if(a2>a1)
        cout<<a2;
    else
        cout <<a1;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//THIS IS seemingly 2 dimensional dp prblem can be solved by bitmasks
//Here we represent the number of woman matched by bitmasks
//The number of bits mean that many woman are matched already so you match (the no of set bits + 1)th man with
//any of the unmatched woman
//dp[0]=1
int main()
{int n;
cin>>n;int mod=1e9+7;
int ar[n][n];
for(int i=0;i<n;i++)
{for(int j=0;j<n;j++)
cin>>ar[i][j];
}
int y1=1<<n;
int dp[y1]={0},u1;
for(int i=0;i<y1;i++)
dp[i]=0;
dp[0]=1;
for(int j=0;j<y1;j++)
{int y2=__builtin_popcount(j);
	for(int k=0;k<n;k++)
{if(ar[y2][k]==1&&(!(j&(1<<k))))
{u1=j|(1<<k);
dp[u1]=(dp[u1]+dp[j])%mod;
}}}
cout<<dp[y1-1]<<endl;
return 0;}


Measured memory_bytes: 8448
#include<stdio.h>

int main(void)
{
   int a, b, c, i;

   scanf("%d%d%d",&a,&b,&c);

   for(i=1;i<=b;i++)
      if(a*i%b==c){
         printf("YES\n");
         return 0;
      }
   printf("NO\n");
   return 0;
}

Measured memory_bytes: 1660
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, l = map(int, input().split())
    apple = [l+i-1 for i in range(1, n+1)]
    if apple[-1] < 0:
        print(sum(apple[:-1]))
    elif apple[0] > 0:
        print(sum(apple[1:]))
    else:
        print(sum(apple[:]))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9176
#include<stdio.h>
#define MAX 44

int fibonacci(int );

int F[MAX];

main()
{
  int n, i;

  scanf("%d", &n);
  printf("%d\n", fibonacci(n));

  return 0;
}

int fibonacci(int n)
{
  if(n == 0 || n == 1)
    {
      F[n] = 1;
      return F[n];
    }
  if(F[n] != 0)
    {
      return F[n];
    }

  return F[n] = fibonacci(n-1) + fibonacci(n-2);
}

Measured memory_bytes: 596
#ifndef ___CLASS_MODINT
#define ___CLASS_MODINT

#include <cstdint>

template<std::uint32_t mod>
class modint {
private:
	std::uint32_t n;
public:
	modint() : n(0) {};
	modint(std::uint64_t n_) : n(n_ % mod) {};
	bool operator==(const modint& m) const { return n == m.n; }
	bool operator!=(const modint& m) const { return n != m.n; }
	std::uint32_t get() const { return n; }
	modint& operator+=(const modint& m) { n += m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator-=(const modint& m) { n += mod - m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator*=(const modint& m) { n = std::uint64_t(n) * m.n % mod; return *this; }
	modint operator+(const modint& m) const { return modint(*this) += m; }
	modint operator-(const modint& m) const { return modint(*this) -= m; }
	modint operator*(const modint& m) const { return modint(*this) *= m; }
	modint binpow(std::uint64_t b) const {
		modint ans = 1, m = modint(*this);
		while (b) {
			if (b & 1) ans *= m;
			m *= m;
			b >>= 1;
		}
		return ans;
	}
	modint inv() { return (*this).binpow(mod - 2); }
};

#endif // ___CLASS_MODINT

#include <vector>
#include <iostream>
using namespace std;
using modulo = modint<1000000007>;
modulo solve(vector<int> A) {
	int N = A.size();
	vector<int> D(N);
	for (int i = 0; i < N; ++i) {
		int x = A[i];
		while (x > 0) {
			x /= 10;
			++D[i];
		}
		if (A[i] == 0) D[i] = 1;
	}
	int sum = 0;
	for (int i = 0; i < N; ++i) sum += D[i];
	vector<modulo> pw(sum + 1); pw[0] = 1;
	for (int i = 1; i <= sum; ++i) pw[i] = pw[i - 1] * 10;
	vector<vector<modulo> > dp(N + 1);
	dp[0] = { modulo(1) };
	for (int i = 0; i < N; ++i) {
		dp[i + 1].resize(i + 2);
		for (int j = 0; j <= i; ++j) {
			dp[i + 1][j] += dp[i][j];
			dp[i + 1][j + 1] += dp[i][j] * pw[D[i]];
		}
	}
	vector<vector<modulo> > rdp(N + 1);
	rdp[N] = { modulo(1) };
	for (int i = N - 1; i >= 0; --i) {
		rdp[i].resize(N - i + 1);
		for (int j = 0; j <= N - i - 1; ++j) {
			rdp[i][j] += rdp[i + 1][j];
			rdp[i][j + 1] += rdp[i + 1][j] * pw[D[i]];
		}
	}
	vector<vector<modulo> > comb(N + 1);
	for (int i = 0; i <= N; ++i) {
		comb[i].resize(i + 1);
		comb[i][0] = 1;
		for (int j = 1; j <= i; ++j) {
			comb[i][j] += comb[i - 1][j - 1];
			if (j != i) comb[i][j] += comb[i - 1][j];
		}
	}
	vector<modulo> fact(N + 1);
	vector<modulo> sumfact(N + 1);
	fact[0] = 1;
	sumfact[0] = 1;
	for (int i = 1; i <= N; ++i) {
		fact[i] = fact[i - 1] * i;
		for (int j = 0; j <= i; ++j) {
			sumfact[i] += fact[j] * comb[i][j];
		}
	}
	modulo ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= i; ++j) {
			for (int k = 0; k <= N - i - 1; ++k) {
				modulo sub = dp[i][j] * rdp[i + 1][k];
				ans += sub * A[i] * fact[j + k] * sumfact[N - j - k - 1];
			}
		}
	}
	return ans;
}
int main() {
	int N;
	cin >> N;
	vector<int> A(N), ANZ;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		if (A[i] != 0) ANZ.push_back(A[i]);
	}
	modulo ans = solve(A);
	if (A != ANZ) ans -= solve(ANZ);
	cout << ans.get() << endl;
	return 0;
}


Measured memory_bytes: 3296
<?php
  
    $inputs = explode(' ',trim(fgets(STDIN)));
	$total = 0;
	$check = abs($inputs[1]);
	
for($x = 0;$x < $inputs[0];$x++){
	$apple = $inputs[1] + $x;
	$total += $apple;
	if(abs($check) > abs($apple)){
      $check = $apple;
    }
}
$total -= $check;

print $total;

Measured memory_bytes: 4604
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

answer = 0
cost = 0
index_a = -1
for i in range(len(A)):
    if i == len(A) or cost + A[i] > K:
        break
    cost += A[i]
    answer += 1
    index_a = i

max_answer = answer
index_b = 0
while (index_b < len(B)):    
    if cost + B[index_b] > K:
        if index_a < 0:
            break
        cost -= A[index_a]
        index_a -= 1
        answer -= 1
    else:
        cost += B[index_b]
        index_b += 1
        answer += 1
    if max_answer < answer:
        max_answer = answer
print(max_answer)

Measured memory_bytes: 40536
import bisect
import itertools
n,m,k = map(int,input().split())
A = list(itertools.accumulate([0]+list(map(int,input().split()))))
B = list(itertools.accumulate([0]+list(map(int,input().split()))))

ans = 0
for i,a in enumerate(A):
    if a>k:
        break
    cnt = bisect.bisect_right(B,k-a)-1
    ans = max(ans,i+cnt)
print(ans)

Measured memory_bytes: 42788
l, r, d = list(map(int, input().split()))
# b = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# ab = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))

print(r//d-(l-1)//d)


Measured memory_bytes: 9148
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define int long long

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;


ll N,K,i,j,k;
int a[100010],b[100010];
signed main() {
	cin>>N;
	REP(i,N){
		cin>>a[i]>>b[i];
	}
	ll cnt=0;
	for(int i=N-1;i>=0;i--){
		a[i]+=cnt;	
		int rem=b[i]-a[i]%b[i];
		if(a[i]%b[i]==0)rem=0;
		cnt+=rem;
	}
	cout<<cnt<<endl;
}




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

int main() {
  string s;cin>>s;
  if (s[0]=='7' || s[1]=='7' || s[2]=='7') cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

    public Main() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();

        int[] A = new int[N];
        int max = 0;
        for (int i = 0; i < N; i++) {
            int in = scanner.nextInt();
            A[i] = in;
            max = Math.max(in , max);
        }

        int left = 0, right = max+1;
        while(right - left > 1){
            int mid = left + ( right - left ) / 2;

            int sum = 0;
            for (int i = 0; i < N; i++) {
                sum += (A[i]+mid-1)/mid - 1;
            }

            if (sum <= K){
                right = mid;
            } else {
                left = mid;
            }
        }

        System.out.println(right);
    }

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


Measured memory_bytes: 59624
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
//FILE *fi = freopen("1.txt", "r", stdin);
//FILE *fo = freopen("1", "w", stdout);
//FILE *fi = freopen("P.inp", "r", stdin);
//FILE *fo = freopen("P.out", "w", stdout);
int n, k;
long long a[200001];
const long long Mod = 1e9 + 7;
void update(long long &x)
{
    if (x < 0)
        x += Mod * Mod;
    x %= Mod;
}
bool cmp1(long long a, long long b)
{
    return abs(a) > abs(b);
}
bool cmp2(long long a, long long b)
{
    return abs(a) < abs(b);
}
long long calc(long long x, long long y)
{
    long long ans = 1;
    for (int i = 1; i <= k; i++)
    {
        if (a[i] == x)
        {
            x = 2e9;
            continue;
        }
        ans *= a[i];
        update(ans);
    }
    ans *= y;
    update(ans);
    return ans;
}
int main()
{
    //------------------------------
    // Faster
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //------------------------------
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    long long ans = 1;
    sort(a + 1, a + n + 1, cmp1);
    int cnt = 0;
    for (int i = 1; i <= k; i++)
    {
        ans *= a[i];
        cnt += int(a[i] < 0);
        update(ans);
    }
    if (cnt % 2)
    {
        long long x = 2e9, y = 2e9, z = 2e9, t = 2e9;
        for (int i = k; i >= 1; i--)
        {
            if (a[i] <= 0 && x == 2e9)
            {
                x = a[i];
            }
            if (a[i] >= 0 && z == 2e9)
            {
                z = a[i];
            }
        }
        for (int i = k + 1; i <= n; i++)
        {
            if (a[i] >= 0 && y == 2e9)
                y = a[i];
            if (a[i] <= 0 && t == 2e9)
                t = a[i];
        }
        if ((x != 2e9 && y != 2e9) && ((z == 2e9 || t == 2e9) || (y * z > t * x)))
        {
            cout << calc(x, y);
        }
        else if (z != 2e9 && t != 2e9)
        {
            cout << calc(z, t);
        }
        else
        {
            sort(a + 1, a + n + 1, cmp2);
            long long ans = 1;
            for (int i = 1; i <= k; i++)
            {
                ans *= a[i];
                update(ans);
            }
            cout << ans;
        }
    }
    else
    {
        cout << ans;
    }

    return 0;
}

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

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

  cout << R / d - (L - 1) / d << endl;
  return 0;
}

Measured memory_bytes: 3640
from collections import deque
H, W = [int(x) for x in input().split()]
masu = [input() for i in range(H)]
move = [[0, 1], [0, -1], [1, 0], [-1, 0]]
d = [[-1] * W for i in range(H)]

def bfs():
    q = deque()
    for x in range(H):
        for y in range(W):
            if masu[x][y] == '#':
                q.append([x, y])
                d[x][y] = 0
    while q:
        x, y = q.popleft()
        for v in move:
            nx = x + v[0]
            ny = y + v[1]
            if 0 <= nx < H and 0 <= ny < W and d[nx][ny] == -1:
                q.append([nx, ny])
                d[nx][ny] = d[x][y] + 1
    ans = -1
    for x in range(H):
        for y in range(W):
            ans = max(ans, d[x][y])
    return ans

print(bfs())


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

#define mod 1000000007
#define LOCAL 0
#define pb push_back
#define ll long long

ll po(ll a,ll b){
	ll x = 1,y=a;
	while(b>0){
		if(b%2){
			x = x*y;
			x %= mod;
		}
		y=y*y;
		y%=mod;
		b/=2;
	}
	return x;
}

int main(){
	if(LOCAL){
    	freopen("C:/Users/gold/Desktop/sublime IO/input.txt","r",stdin);
    	freopen("C:/Users/gold/Desktop/sublime IO/output.txt","w",stdout);
	}
	int T = 1;
	//scanf("%d",&T);
	while(T--){
		int n;
		scanf("%d",&n);
		map<int,int> dp;
		static int a[500005];
		for(int i=0;i<n;i++){
			scanf("%d",&a[i]);
			dp[a[i]]++;
		}		
		long long ans = 0ll;
		for(int i=0;i<n;i++){
			if(dp[a[i]] == 0){
				continue;
			}
			if(dp[a[i]] > a[i]){
				ans += dp[a[i]] - a[i];
			} else 
			if(dp[a[i]] < a[i]){
				ans += dp[a[i]];
			}
			dp[a[i]] =0 ;
		}
		printf("%lld\n",ans);
	}
	return 0;	
}

Measured memory_bytes: 5120
import sys
from functools import reduce
from operator import mul
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def cmb(n: int, r: int):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def main():
    n, p = input_int_list()
    A = input_int_list()
    even = 0
    odd = 0
    for a in A:
        if a % 2 == 1:
            odd += 1
        else:
            even += 1

    if p == 1:
        ans = 2**even
        tmp = 0
        for i in range(1, odd + 1, 2):
            tmp += cmb(odd, i)
        print(ans * tmp)
    elif p == 0:
        ans = 2**even
        tmp = 0
        for i in range(0, odd + 1, 2):
            tmp += cmb(odd, i)
        print(ans * tmp)
    return


if __name__ == "__main__":
    main()


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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

long long solve(long long k) {
  return k / 2;
}

int main() {
  int k;
  string s;
  cin >> s >> k;
  long long res = 0;
  vector<pair<int, int>> cur;
  cur.emplace_back(0, 0);
  range(i, 1, (int) s.length()) {
    if(s[i] != s[i - 1]) cur.emplace_back(i, i);
    else cur.back().second++;
  }
  if(s.front() != s.back()) {
    for(auto ss : cur) res += solve(ss.second - ss.first + 1);
    res *= k;
  } else {
    if(cur.size() == 1) {
      res = solve(1LL * s.length() * k);
    } else {
      int a = cur.back().second - cur.back().first + 1, b = cur.front().second - cur.front().first + 1;
      res = solve(a) + solve(b);
      res += solve(1LL * (a + b)) * (k - 1);
      cur.pop_back();
      cur.erase(cur.begin());
      for(auto ss : cur) {
        res += solve(ss.second - ss.first + 1) * k;
      }
    }
  }
  cout << res;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

using ll = long long;
using P = std::pair<int, ll>;

constexpr int MAX_N = 100000;
constexpr ll INF = 1e18;

int N;
std::vector<P> G[MAX_N];
int Q, K;
ll d[MAX_N];
bool used[MAX_N];

int main()
{
	scanf("%d", &N);
	rep(i, N - 1)
	{
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		--a; --b;
		G[a].push_back( P( b, c ) );
		G[b].push_back(P(a, c));
	}

	scanf("%d%d", &Q, &K);
	--K;
	
	std::fill( d, d+N, INF );
	
	std::queue<P> que;
	que.push( P( K, 0 ) );

	while (!que.empty())
	{
		P p = que.front(); que.pop();
		int v = p.first;
		ll dist = p.second;

		if( d[v] == INF )
			d[v] = dist;

		used[v] = true;

		for (auto &e : G[v]) if (!used[e.first])
			que.push( P( e.first, dist+e.second ) );
	}

	rep(i, Q)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		--x; --y;

		printf("%lld\n", d[x] + d[y]);
	}

	return 0;
}

Measured memory_bytes: 10992
import scala.io.Source

object Main{
  def main(args: Array[String]){
    var list = List[String]()
    for(in <- Source.stdin.getLines.toList){
      list = in :: list
    }

    for(i <- 0 until list.length){
      if(list(list.length - i - 1).size > 4){
        val arr = list(list.length - i - 1).split(Array(' '))

        arr(1) match {
          case "+" => println(arr(0).toInt + arr(2).toInt)
          case "-" => println(arr(0).toInt - arr(2).toInt)
          case "*" => println(arr(0).toInt * arr(2).toInt)
          case "/" => println(arr(0).toInt / arr(2).toInt)
          case "?" =>
        }
      }
    }
  }
}

Measured memory_bytes: 44008
n,m,k=gets.split.map(&:to_i)
has=false
(n+1).times do |i|
    (m+1).times.each do |j|
        if m*i+n*j-2*i*j==k
            has=true
        end
    end
end

if has==true
    puts "Yes"
else
    puts "No"
end


Measured memory_bytes: 14384
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#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
#define ll long long

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

using namespace std;

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

/*==================================================*/
/*variable*/
int N, M;
/*==================================================*/
/*function*/
bool isPrime[10000100]; // n<1000010


void hurui(int n) {

    for (int i = M; i < n + 1; i++) isPrime[i] = true;

    int p = M;
    while(0 < N){
        if(isPrime[p]){
            N--;
            for (int j = p; j < n + 1; j += p) {
                isPrime[j] = false;       // 素数でない
            }
        }
        p++;
    }

    return;
}

/*==================================================*/

int main() {
    while(cin>>M>>N && M){
        hurui(10000000);
        REP(i,M,10000000){
            if(isPrime[i]) {
                cout<<i<<endl;
                break;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 12836
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

const int MAX_N = 1e5 +6;

int a[MAX_N];

int main () {
	int n,c,k;
	while (scanf("%d %d %d",&n,&c,&k) != EOF) {
		int last=-1;
		int lastid = -1;
		int cnt=0;
		for (int i=1;n>=i;i++) {
			scanf("%d",&a[i]);
		}
		sort(a+1,a+n+1);
		for (int i=1;n>=i;i++) {
			if (last == -1) {
				cnt++;
				last = a[i];
				lastid=i;
			}
			else if (a[i] - last <=k && i-lastid+1<=c) {
				;
			}
			else {
				cnt++;
				last=a[i];
				lastid=i;
			}
		}
		printf("%d\n",cnt);
	}
}


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

class Dice{
public:
  int n, face[6];
  char m[101] = {};

  void scan(){
    for( int i = 0; i < 6; i++){
      cin >> face[i];
    }
  }

  void move(){
     for( int i = 0; i < 101; i++){
	n = face[0];
        if( m[i] == 'N'){
           face[0] = face[1];
	   face[1] = face[5];
	   face[5] = face[4];
	   face[4] = n;
        } else if( m[i] == 'S'){
           face[0] = face[4];
	   face[4] = face[5];
	   face[5] = face[1];
	   face[1] = n;
	      } else if( m[i] == 'E'){
	   face[0] = face[3];
	   face[3] = face[5];
	   face[5] = face[2];
	   face[2] = n;
        } else if( m[i] == 'W'){
	   face[0] = face[2];
	   face[2] = face[5];
	   face[5] = face[3];
	   face[3] = n;
	} else break;
    }
  }	      
};

int main(){
  Dice p1;
  p1.scan();
  cin >> p1.m;
  p1.move();
  cout << p1.face[0] << endl;

  return 0;
}

Measured memory_bytes: 3112
#include<cstdio>
#include<algorithm>
using namespace std;
struct node{
	int t,c;
}a[101];
int n,T;
bool cmp(node A,node B)
{
	if(A.t<=T&&B.t<=T) return A.c<B.c;
	else return A.t<B.t;
}
int main()
{
	scanf("%d%d",&n,&T);
	for(int i=1;i<=n;i++)
	  scanf("%d%d",&a[i].c,&a[i].t);
	sort(a+1,a+n+1,cmp);
	if(a[1].t<=T) printf("%d",a[1].c);
	else puts("TLE");
	return 0;
}

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

int main(){
  long int N, K;
  long int count = 0;
  cin >> N >> K;
  if (K == 0) {
    cout << N*N << endl;
  }
  else{
    for (int b = K+1; b <= N; b++) {
      long int p = N / b;
      long int r = N % b;
      if (b - K > 0) count += p * (b-K);
      if (r - K + 1 > 0) count += r - K + 1;
    }
    cout << count << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
signed main() {
  long long N;
  cin >> N;
  long long ans=1;
  for(int i=1; i<N+1; i++) {
    ans=ans*i%mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N,H;
  cin>>N>>H;
  vector<pair<int,int>> A(N*2);
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    A[i]=make_pair(a,0),A[N+i]=make_pair(b,1);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  int j=0;
  for(pair<int,int> p:A){
    if(p.second==0){
      cout<<j+(H+p.first-1)/p.first<<endl;
      return 0;
    }
    j++,H-=p.first;
    if(H<=0){
      cout<<j<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 6400
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

void warshallFloyd(ll** graph, int n) noexcept {
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			for (int k = 0; k < n; ++k) {
				graph[j][k] = min(graph[j][k], graph[j][i] + graph[i][k]);
			}
		}
	}
}

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

	int n, m, rn;
	cin >> n >> m >> rn;
	int* r = new int[rn];
	rep(i, rn) cin >> r[i];

	ll** graph = new ll*[n];
	rep(i, n) {
		graph[i] = new ll[n];
		rep(j, n) graph[i][j] = _MOD;
	}

	int a, b, c;
	rep(i, m) {
		cin >> a >> b >> c;
		graph[a - 1][b - 1] = c;
		graph[b - 1][a - 1] = c;
	}
	warshallFloyd(graph, n);

	ll ans = _MOD;
	sort(r, r + rn);
	do {
		ll sum = 0;
		REP(i, 1, rn) sum += graph[r[i - 1] - 1][r[i] - 1];

		ans = min(ans, sum);
	} while (next_permutation(r, r + rn));

	cout << ans << "\n";

	return 0;
}



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

constexpr double eps = 1e-12;
double deg2rad(double x) { return x / 360 * (2 * M_PI); }
double frem(double x, double y) { return fmod(fmod(x, y) + y + eps, y); }
enum face_t { ABC, ACD, ADB, BCD };

face_t get_face() {
    string xy; int d, l; cin >> xy >> d >> l;
    double face_theta =
        xy == "BC" ? 0 :
        xy == "CD" ? 60 :
        xy == "DB" ? 120 :
        NAN;
    double theta = deg2rad(face_theta + d);
    double x = l * cos(theta);
    double y = l * sin(theta);
    double z60 = x + y / sqrt(3);
    double z120 = - x + y / sqrt(3);
    z60 = frem(z60, 2);
    z120 = frem(z120, 2);
    double w = (z60 + z120) * (sqrt(3) / 2);
    return
        w < sqrt(3) / 2 ?
            ACD :
        w < sqrt(3) ?
            z60 > 1 ? ABC :
            z120 > 1 ? ADB :
            BCD :
        w < 3 * sqrt(3) / 2 ?
            z60 < 1 ? ABC :
            z120 < 1 ? ADB :
            BCD :
        ACD;
}

int main() {
    face_t a = get_face();
    face_t b = get_face();
    cout << (a == b ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 3448