akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = (int) 1e6 + 2, n = sc.nextInt();
		boolean[] div = new boolean[N];
		int[] a = sc.nxtArr(n);
		sort(a);
		int ans=0;
//		System.out.println(Arrays.toString(a));
		for (int i = 0; i < n; i++) {
//			System.out.println(i);
			for(int m=a[i]+a[i];m<N;m+=a[i])
				div[m]=true;
			if (i + 1 < n && a[i + 1] == a[i]) {
				int j = i;
				while (j < n && a[j] == a[i])
					j++;
				i = j - 1;
				continue;
			}
			if(!div[a[i]])
				ans++;
		}
		System.out.println(ans);
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

		int[] nxtArr(int n) throws IOException {
			int[] ans = new int[n];
			for (int i = 0; i < n; i++)
				ans[i] = nextInt();
			return ans;
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}

Measured memory_bytes: 56636
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(R, G, B, N):
    ans = 0
    r = -R
    for i in range(N//R + 1):
        r += R
        g = -G
        for j in range((N-r)//G + 1):
            g += G
            if (N-r-g) % B == 0:
                ans += 1

    return ans


def main():
    R, G, B, N = read_int_n()
    # A = [read_int_n() for _ in range(N)]
    print(slv(R, G, B, N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62444
import java.io.*;
import java.util.*;

public class Main implements Runnable {
	public static void main (String[] args) {new Thread(null, new Main(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int n = fs.nextInt();
		int[] a = fs.nextIntArray(n);
		int res = 0;
		for(int i = 1; i < n-1; i++) {
			int mx = Math.max(a[i-1], a[i+1]);
			int mn = Math.min(a[i-1], a[i+1]);
			if(mn < a[i] && a[i] < mx) res++;
		}
		out.println(res);
		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
string ss[100000];
set<string> sets;
int main() {
    ios::sync_with_stdio(false);
    string s; int k;
    cin >> s >> k;
    vector<string> v;
    
    for (int i = 0; i < s.size(); i++) {
        for (int j = 1; j <= k; j++) {
            string t = s.substr(i, j);
            if (t.size() <= k)
                v.push_back(t);
        }
    }
    
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    
    cout << v[k-1] << endl;
    //for (int i = 0; i < v.size(); i++)
    //    cout << v[i] << endl;
    
    
    return 0;
}


Measured memory_bytes: 2428
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  int ans = 0;
  for(int i = 1; i <= n; i++){
    if(s[i - 1] == s[i]) ++ans;
  }

  ans = min(ans + 2 * k, n - 1);

  cout << ans << endl;

  return 0;
}


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

using namespace std;

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

    int sum = 0;
    for (int i = 1; i <= l; i++) {
        for (int j = 1; j <= l; j++) {
            for (int k = 1; k <= l; k++) {
                sum += __gcd(__gcd(i, j), k);
            }
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
int n,m;
stack < pair<int,int> > bridge;
int parent[200000],sz[200000];
ll sum;
stack<ll> ans;
ll C2 (ll x){
    ll res = (x*(x-1))/2;
    return res;
}
int findrep(int x){
    if(parent[x]==x) return parent[x];
    else{
        return findrep (parent[x]);
    }
}
void join (int a, int b){
    int repa,repb;
    repa = findrep(a);
    repb = findrep(b);
    if(repa>repb)swap(repa,repb);
    parent[repb]=repa;
    sz[repa] = sz[repa] + sz[repb];
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int a,b;
        cin>>a>>b;
        if(a>b){swap(a,b);}
        bridge.push(make_pair(a,b));
    }
    for(int i=1;i<=n;i++){parent[i]=i;sz[i]=1;}
    sum = C2(n);
    ans.push(sum);
    while(!bridge.empty()){
        int a = bridge.top().first;
        int b = bridge.top().second;
        bridge.pop();
        int para,parb;
        para = findrep(a);
        parb = findrep(b);

        if(para!=parb){
            sum += C2(sz[para]);
            sum += C2(sz[parb]);
            sum -= C2(sz[para]+sz[parb]);
            join(para,parb);
            //cout<<C2(sz[para])<<" "<<C2(parb)<<" "<<C2(para+parb)<<endl;
        }
        ans.push(sum);
    }
    ans.pop();
    while(!ans.empty()){
        cout<<ans.top()<<endl;
        ans.pop();
    }
}


Measured memory_bytes: 2944
import java.util.Scanner;

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

        String input = stdIn.nextLine();
        int d = Integer.parseInt(input.split(" ")[0]);
        int t = Integer.parseInt(input.split(" ")[1]);
        int s = Integer.parseInt(input.split(" ")[2]);

        if(d <= (t * s)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35652
w,h,n = gets.split.map(&:to_i)
s = [0, 0, w, h]

n.times do
    x,y,a = gets.split.map(&:to_i)

    case a
    when 1
        s[0] = x if s[0] < x
    when 2
        s[2] = x if s[2] > x
    when 3
        s[1] = y if s[1] < y
    when 4
        s[3] = y if s[3] > y
    end
end

puts s[0] >= s[2] || s[1] >= s[3] ? 0 : (s[2] - s[0]) * (s[3] - s[1])

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005;

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

int main(){
    
    int N;cin>>N;
    vector<ll> A(N),B(N),d(N,0);
    bool check=true;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        cin>>B[i];
    }
    ll now=0;
    for(int i=0;i<N;i++){
        if(A[i]>now){
            now=A[i];
            d[i]=A[i];
        }
    }
    now=0;
    for(int i=N-1;i>=0;i--){
        if(B[i]>now){
            now=B[i];
            if(d[i]!=0&&d[i]!=B[i]) check=false;
            d[i]=B[i];
        }
    }
    bool cor=true;
    ll co,co2;
    for(int i=0;i<N;i++){
        if(!cor){
            if(A[i]!=co&&A[i]>B[i]) check=false;
        }
        if(A[i]==B[i]){
            cor=false;
            co=A[i];
        }
    }
    cor=true;
    for(int i=N-1;i>=0;i--){
        if(!cor){
            if(B[i]!=co2&&A[i]<B[i]) check=false;
        }
        if(A[i]==B[i]){
            cor=false;
            co2=A[i];
        }
    }
    if(cor) check=false;
    if(check){
        ll ans=1,cnt=0,pre=0;
        for(int i=0;i<N;i++){
            if(d[i]==0) cnt++;
            else if(d[i]!=0){
                if(cnt!=0&&pre!=0){
                    ans*=rui(min(pre,d[i]),cnt);
                }
                ans=ans%mod;
                cnt=0;
                pre=d[i];
            }
        }
        cout<<ans<<endl;
    }
    else cout<<0<<endl;
    
}


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll r; cin >> r;
  cout << r*r << endl;

  return 0;
}



Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
  int n, d;
  cin >> n>>d;
  int x[n][d];

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

  int cnt=0;

  int ssum;
  for(int i=0; i<n-1; i++){
    for(int j=i+1; j<n; j++){
      ssum=0;
      for(int k=0; k<d; k++){
        ssum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }

      for(int l=0; l<160; l++){
        if(ssum==l*l) cnt++;
      }
    }

  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
int main(){
 string s;cin>>s;
  int cnt=0;
  for(int i=0;i<s.size();i++)if(s[i]=='2')cnt++;
  cout<<cnt<<endl;
}

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

using namespace std;

int main()
{
	long long k;
	cin >> k;
	
	if (k == 0)
	{
		cout << "2\n1 1";
		return 0;
	}
	else if (k == 1)
	{
		cout << "2\n2 0";
		return 0;
	}
	
	if (k < 50)
	{
		cout << k << endl;
		
		for (int i = 0; i < k; i++)
			cout << k << " ";
	}
	else
	{
		if (k % 50 == 0)
		{
			cout << "50\n";
			
			for (int i = 0; i < 50; i++)
				cout << k/50+49 << " ";
		}
		else
		{
			cout << "50\n";
			
			for (int i = 0; i < k%50; i++)
				cout << k/50+50 << " ";
				
			for (int i = 0; i < 50-k%50; i++)
				cout << k/50+49-k%50 << " ";
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl a(n); cin>>a;
	ll p=0,c=1;;
	rrep(i,n){
		p=p+c*a[i];
		c*=-1;
	}
	vl ans(1,p);
	rep(i,n-1){
		ans.push_back((a[i]-ans.back()/2)*2);
	}
	puta(ans);

	return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

int a, b;

void solve()
{
	string x, y;
	for(int i=0;i<b;++i)x+='0'+a;
	for(int i=0;i<a;++i)y+='0'+b;
	cout << min(x,y) << '\n';
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> a >> b;
	solve();
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
N,K,L = map(int,input().split())

p_road = [i for i in range(N)]
p_rail = [i for i in range(N)]

def root(a,par):
    if a == par[a]: return a
    par[a] = root(par[a],par)
    return par[a]

def unite(a,b,par):
    ra = root(a,par)
    rb = root(b,par)
    if ra == rb: return
    par[ra] = rb

for i in range(K):
    a,b = map(lambda x:int(x)-1, input().split())
    unite(a,b,p_road)

for i in range(L):
    a,b = map(lambda x:int(x)-1, input().split())
    unite(a,b,p_rail)

road_ids = []
rail_ids = []
for i in range(N):
    road_ids.append(root(i,p_road))
    rail_ids.append(root(i,p_rail))

ctr = Counter()
for a,b in zip(road_ids, rail_ids):
    ctr.update([(a,b)])

print(' '.join(list(map(str, [ctr[(road_ids[i], rail_ids[i])] for i in range(N)]))))

Measured memory_bytes: 64548
nums = [int(e) for e in input().split()]
for i in range(len(nums)):
    for j in range(i):
        if nums[i]<nums[j]:
            a = nums[i]
            nums[i] = nums[j]
            nums[j] = a

nums_2 = " ".join(map(str, nums))
print(nums_2)


Measured memory_bytes: 5600
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int n;
int c() {
    return n-gi()+1;
}

int main() {
    n = gi();
    printf("%d\n", c()*c());

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

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

    if (m == 0) {
        if (k != 0) cout << -1 << endl;
        else cout << 0 << " " << 0 << endl;
        return 0;
    }
    if (m == 1) {
        if (k != 0) cout << -1 << endl;
        else cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
        return 0;
    }

    if (k >= (1 << m)) {
        cout << -1 << endl;
        return 0;
    }

    cout << k;
    for (int i = 0; i < (1 << m); ++i) {
        if (i == k) continue;
        cout << " " << i;
    }
    cout << " " << k;
    for (int i = (1 << m) - 1; i >= 0; --i) {
        if (i == k) continue;
        cout << " " << i;
    }
    cout << endl;

    return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int n, m;
    ll k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    vector<ll> cum_a(n+1, k+10), cum_b(m+1, k+10);
    cum_a[0] = 0;
    cum_b[0] = 0;
    rep(i, n)
    {
        cin >> a[i];
        if(cum_a[i]+a[i] > k)
            continue;
        cum_a[i+1] = cum_a[i] + a[i];
    }
    rep(i, m){
        cin >> b[i];
        if(cum_b[i]+b[i] > k)
            continue;
        cum_b[i + 1] = cum_b[i] + b[i];
    }
    ll cnt_book = 0;
    ll a_read;
    ll tot_read;
    rep(i, n+1)
    {
        a_read = cum_a[i];
        if(a_read>k)
            break;
        auto itr = upper_bound(cum_b.begin(), cum_b.end(), k - a_read);
        itr--;
        tot_read = i + itr - cum_b.begin();
        if (tot_read > cnt_book)
            cnt_book = tot_read;
    }
    cout << cnt_book << endl;

    return 0;
}

Measured memory_bytes: 9576
// ABC112_B
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    ll N, T, c, t, res = 10000;
    cin >> N >> T;
    
    // calculation
    REP(i, N) {
        cin >> c >> t;
        if (t <= T) {
            res = min(res, c);
        }
    }
    if (res == 10000) {
        cout << "TLE" << "\n";
    } else {
        cout << res << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
NK = list(map(int, input().split()))
N = NK[0]; K = NK[1]

result = [0]*N

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for j in range(d):
        result[A[j]-1] += 1

cnt = 0

for i in range(N):
    if result[i] == 0:
        cnt += 1

print(cnt)
        

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

using namespace std;

int main(void) {
	string S;
	cin >> S;
	bool x = true;
	for(int i = 0; i < S.length(); ++i) {
		if((x && S[i] != 'h') || (!x && S[i] != 'i')) {
			cout << "No\n";
			return 0;
		}
		x ^= true;
	}
	if(x) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	return 0;
}



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

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

using namespace std;

int main(){
	int n; scanf("%d",&n);

	int ans=0;
	rep(i,n){
		int a; scanf("%d",&a);
		ans+=a-1;
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=100050;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	char S[50];
	cin>>S;
	set<char> tes;
	for(int i=0;i<strlen(S);i++){
		tes.insert(S[i]);
	}
	if(tes.size()==strlen(S))
		cout<<"yes"<<endl;
	else
		cout<<"no"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
using namespace std;
int main() {
    string S;
    cin >> S;
    long long ans = 0;
    vector<int>A(S.size()+1,0);
    int N = int(S.size()) + 1;
    for (int i = 1; i < N; i++) {
        if (S[i-1] == '<') {
            A[i] = max(A[i], A[i-1]+1);
        }
    }
    for (int i = N-2; i >= 0; i--) {
        if (S[i] == '>') {
            A[i] = max(A[i], A[i+1]+1);
        }
    }
    rep(i, 0, A.size()){
        ans += A[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2820
#include <stdio.h>
#include <stdbool.h>

int main() {
	int n, a[100] = {0}, c[100];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)scanf("%d", &a[i]);
	for (int i = 0; i < n; i++) {
		if (a[i] < a[i + 1])c[i] = 1;
		else if (a[i] == a[i + 1]) c[i] = 0;
		else c[i] = -1;
	}

	long long int st = 0, mon = 1000;
	bool buy = true;

	for (int i = 0; i < n; i++) {
		if (buy == true) {
			if (c[i] != 1)continue;
			else {
				st = mon / a[i];
				mon -= st * a[i];
				buy = false;
			}
		}
		if(buy == false){
			if (c[i] != -1)continue;
			else {
				mon += st * a[i];
				st = 0;
				buy = true;
			}
		}
	}

	printf("%lld", mon);

	return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x,i,j,k,l;
  cin >> x;
  j=8;
  k=399;
  while(1)
  {
    k+=200;
    if(x<=k)
    {
      l=j;
      break;
    }
    j--;
  }
  cout << l << endl;
}
  

Measured memory_bytes: 3552
#include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>


int main() {


    int a, b, c, d, e, k;
    std::cin >> a >> b >> c >> d >> e >> k;

    std::vector<int> vs = {a, b, c, d, e};

    bool ok = true;

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

            if (abs(vs[i] - vs[j]) > k) {
                ok = false;
            }
        }
    }

    if (ok) {
        std::cout << "Yay!" << "\n";
    } else {
        std::cout << ":(" << "\n";
    }

    return 0;
}


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

ll calc(ll target, ll init)
{
	ll ret = 0;
	while(init<target){
		ret++;
		init*=2LL;
	}
	return ret;
}
int main()
{	
	ios_base::sync_with_stdio(0);
	ll n,k;
	double po[100005];
	po[0] = 1;
	for(int i=1; i<=100000; i++) po[i] = po[i-1]/2.0;
	while(cin>>n>>k){
		double ans = 0;
		double p = 1.0/n;
		for(ll i=1; i<=n; i++){
			ll need = calc(k,i);
			ans+=p*po[need];
		}
		cout<<fixed<<setprecision(12)<<ans<<endl;
	}
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    int a[10]; memset(a,0,sizeof(a));
    for (int i = 0; i < k; i++){
        int x;
        scanf("%d",&x);
        a[x] = 1;
    }
    while (n){
        bool can = true;
        int cur = n;
        while (cur){
            //printf("checking %d\n",cur);
            //printf("%d %d\n",cur%10,a[cur%10]);
            if (a[cur%10] == 1) {can = false; break;}
            cur /= 10;
        }
        if (can){
            printf("%d",n);
            break;
        }
        n++;
    }
}


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

int dp[18][2];

int main()
{
  char s[18];
  scanf("%s", s);
  int i;
  for (i = 0; s[i]; ++i)
  {
    int D = s[i] - '0';
    for (int j = 0; j < 2; ++j)
    {
      if (j == 1 && i == 0) continue;
      for (int k = 0; k <= (j ? 9 : D); ++k)
      {
        dp[i + 1][j || k < D] = std::max(dp[i + 1][j || k < D], dp[i][j] + k);
      }
    }
  }
  printf("%d\n", std::max(dp[i][0], dp[i][1]));
  return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

const int maxn = 100 + 5;
int r, c, n;
int a[maxn * maxn];
int b[maxn][maxn];

void solve() {
    cin >> r >> c >> n;
    FOR(i, 0, n) cin >> a[i];
    int st = 0;
    FOR(i, 0, r) {
        if (!(i & 1)) {
            FOR(j, 0, c) {
                if (!a[st]) st++;
                b[i][j] = st;
                a[st]--;
            }
        }
        else {
            FORd(j, c, 0) {
                if (!a[st]) st++;
                b[i][j] = st;
                a[st]--;
            }
        }
    }
    FOR(i, 0, r) FOR(j, 0, c) cout << b[i][j] + 1 << " \n"[j == c - 1];
}

int main() {
    int JUDGE_ONLINE = 1;
    if (fopen("in.txt", "r")) {
        JUDGE_ONLINE = 0;
        assert(freopen("in.txt", "r", stdin));
        //assert(freopen("out.txt", "w", stdout));
    }
    else {
        ios_base::sync_with_stdio(0), cin.tie(0);
    }
    solve();
    if (!JUDGE_ONLINE) {
        //cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    }
    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define inf 0x7fffffff
#define llinf 0x7fffffffffffffffll
using namespace std;
string s;
int main()
{
	int i,j,k,n,m,x;
	ll l;
	cin>>s;
	scanf("%I64d",&l);
	for(i=0;i<l&&i<s.size();i++)
	{
		if(s[i]>'1')
		{
			putchar(s[i]);
			return 0;
		}
	}
	printf("1");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


int main() {
  int N;
  cin>>N;
  vector<pair<string,int>> s(N);
  REP(i,N){
    cin>>s[i].first>>s[i].second;
  }
  string x;cin>>x;
  int ans=0;
  bool f=false;
  for(int i=0;i<N;i++){
    if(f)ans+=s[i].second;
    if(!f&&s[i].first==x)f=true;
  }
  cout<<ans<<endl;
  
  
  


  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  cin >> n;

  vector<llong> a(n), b(n), c(n);
  REP(i,n){
    cin >> a[i] >> b[i] >> c[i];
  }

  llong dp[100000][3] = {};
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  for(int i = 1; i < n; ++i){
    REP(j,3){
      REP(k,3){
        if(j != k){
          if(k == 0)
            dp[i][k] = max(dp[i][k], dp[i-1][j] + a[i]);
          else if(k == 1)
            dp[i][k] = max(dp[i][k], dp[i-1][j] + b[i]);
          else
            dp[i][k] = max(dp[i][k], dp[i-1][j] + c[i]);
        }
      }
    }
  }

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



Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define EPS 1e-9
using namespace std;

typedef complex<double> P;
typedef vector<int> vec;
typedef vector<vec> mat;

double cross (P a, P b) {
    return (a.real() * b.imag() - a.imag() * b.real());
}

bool is_intersected_ls(P a1, P a2, P b1, P b2) {
    return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < - EPS ) &&
        ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < - EPS );
}

P intersection_l(P a1, P a2, P b1, P b2) {
    P a = a2 - a1; P b = b2 - b1;
    return a1 + a * cross(b, b1-a1) / cross(b, a);
}

void solve() {
    int ax, ay, bx, by;
    cin >> ax >> ay >> bx >> by;
    int N;
    cin >> N;

    vec sx(N), sy(N), tx(N), ty(N), o(N), l(N);
    for (int i = 0; i < N; i++) {
        cin >> sx[i] >> sy[i] >> tx[i] >> ty[i] >> o[i] >> l[i];
    }

    P ap(ax, ay);
    P bp(bx, by);
    vec crossed_idx;
    for (int i = 0; i < N; i++) {
        P sp(sx[i], sy[i]);
        P tp(tx[i], ty[i]);
        if (is_intersected_ls(ap, bp, sp, tp)) crossed_idx.push_back(i);
    }

    vector<pair<double,int> > points;
    for (int i = 0, len = crossed_idx.size(); i < len; i++) {
        int c = crossed_idx[i];
        P sp(sx[c], sy[c]);
        P tp(tx[c], ty[c]);
        P point = intersection_l(ap, bp, sp, tp);
        double dist = abs(point - ap);
        points.push_back(pair<double,int>(dist, c));
    }

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

    int fst;
    bool is_over;
    if (points.size()) {
        fst = points[0].second;
        if (o[fst]) {
            if (l[fst]) is_over = true;
            else is_over = false;
        } else {
            if (!l[fst]) is_over = true;
            else is_over = false;
        }
    }

    int ans = 0;
    for (int i = 0, len = points.size(); i < len; i++) {
        int now = points[i].second;
        if (o[now]) {
            if (l[now] != is_over) {
                ans++;
                is_over = !is_over;
            }
        } else {
            if (l[now] == is_over) {
                ans++;
                is_over = !is_over;
            }
        }
    }

    cout << ans << endl;
}

int main() {
    int N; cin>> N;
    while (N--) solve();

    return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define ll long long
#define fort(i,n) for (int i = 1; i <= n; ++i)
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz size()
#define er erase
#define fr first
#define sc second
#define rc(x) return cout << x, 0
using namespace std;



int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a,b) << ' ' << max(0,a+b-n);
}


Measured memory_bytes: 256
from functools import lru_cache


@lru_cache(maxsize=None)
def prime_factorization(n):
    """
    nを素因数分解して素因数のリストを返却する
    """
    primes = []
    while n % 2 == 0:
        primes.append(2)
        n //= 2
    i = 3
    while i ** 2 <= n:
        while n % i == 0:
            primes.append(i)
            n //= i
        i += 2
    if n != 1:
        primes.append(n)
    return primes


A, B = map(int, input().split(' '))

a_primes = set(prime_factorization(A))
b_primes = set(prime_factorization(B))

print(len(a_primes & b_primes) + 1)


Measured memory_bytes: 9608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[],int n,int g){
  for ( int i = g; i < n; i++){
    int v = A[i];
    int j = i -g;
    while( j>= 0 && A[j] > v){
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void shellSort(int A[], int n){
  for ( int h = 1;;){
    if (h > n)break;
    G.push_back(h);
    h = 3 * h + 1;
  }

  for ( int i = G.size()-1; i >= 0; i--){
    insertionSort(A,n,G[i]);
  }
}

int main(){
  cin >> n;
  for ( int i = 0; i < n; i++) scanf("%d", &A[i]);
  cnt = 0;

  shellSort(A, n);

  cout << G.size() << endl;
  for (int i = G.size() -1; i >= 0; i--){
    printf("%d", G[i]);
    if (i)printf(" ");
  }
  printf("\n");
  printf("%d\n",cnt);
  for(int i = 0;i<n;i++)printf("%d\n",A[i]);

  return 0;
}



Measured memory_bytes: 7108
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}


long long getDigit(long long n){
	if(n==1)return 1;
	else return log10(n)+1;
}

class Point{
public:
	long long x;
	long long y;
};
long long N,M;
vector<long long>X(100006,0);
bool isOK(long long N){
	string s=to_string(N);
	set<char>set;
	for(int i=0;i<s.length();i++){
		set.insert(s[i]);
	}
	return set.size()==1;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long N,T;
	cin>>N>>T;
	long long ans=INF;
	for(int i=0;i<N;i++){
		long long t,c;
		cin>>c>>t;
		if(t<=T)ans=min(c,ans);
	}
	if(ans==INF){
		cout<<"TLE"<<endl;
		return 0;
	}cout<<ans<<endl;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args) {
        FastReader fs=new FastReader();
        PrintWriter out=new PrintWriter(System.out);
        int t=1;
        //t=fs.nextInt();
        while(t-->0){
            solve(out,fs);
        }
        out.close();
    }
    public static void solve(PrintWriter out,FastReader fs){
        long x=fs.nextLong(),k=fs.nextLong(),d=fs.nextLong();
        x=Math.abs(x);
        long ans=-1;
        if((x/d)>k){
            ans=x-k*d;
        }else{
            k-=x/d;
            if(k%2l==1l){
                ans=d-x%d;
            }else{
                ans=x%d;
            }
        }
        out.println(ans);
    }
}
class FastReader{
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st=new StringTokenizer("");
    String next(){
        while(!st.hasMoreTokens()){
            try {
                st=new StringTokenizer(br.readLine());
            } catch (IOException e) {
				e.printStackTrace();
			}
        }
        return st.nextToken();
    }
    int nextInt(){
        return Integer.parseInt(next());
    }
    long nextLong(){
        return Long.parseLong(next());
    }
    int[] nextIntArray(int n){
        int a[]=new int[n];
        for(int i=0;i<n;i++)a[i]=nextInt();
        return a;
    }
    long[] nextLongArray(int n){
        long a[]=new long[n];
        for(int i=0;i<n;i++)a[i]=nextInt();
        return a;
    }
    char[] nextCharArray(){
        char a[]=next().toCharArray();
        return a;
    }
}

Measured memory_bytes: 25404
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int n=s.length();
    if(s[n-1]=='s')
    {
        s+='e';
        s+='s';
    }
    else
        s+='s';
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
//#include <algorithm>
#include <vector> 

int main(int argc, char* argv[])
{
    long n, m;
    scanf("%ld %ld", &n, &m);

	std::vector<long> va;

	long i;
	for(i=1; i<40000; i++) {
		if( m % i == 0 ) {
			va.push_back(i);
		}
	}

	for(i=0; i<va.size(); i++) {
		if(va[i] >= n) {
			printf("%d\n", m/va[i]);
			return 0;
		}
	}

	for(i=0; i<va.size(); i++) {
		long value = m / va[va.size()-i-1];
		if(value >= n) {
			printf("%d\n", va[va.size()-i-1]);
			return 0;
		}
	}

	printf("1\n");

    return 0;
}


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

int main(){
  int s,w;
  cin >> s >> w;
  if(s>w) cout << "safe" << endl;
  else cout << "unsafe" << endl;
}

Measured memory_bytes: 3556
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

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

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> s(h);

	rep(i, h) {
		cin >> s[i];
	}

	vector<int> c(26,0);
	rep(i, h) {
		rep(j, w) {
			c[s[i][j] - 'a']++;
		}
	}
	int n4 = (w / 2) * (h / 2);
	int n1 = (w % 1 == 1 &&  h % 1 == 1) ? 1 : 0;
	int n2 = 0;
	if (w % 2) {
		n2 = h / 2;
	}
	if (h % 2) {
		n2 += w / 2;
	}


	rep(i, 26) {
		
		int cur4 = min(c[i] / 4, n4);
		n4 -= cur4;
		c[i] -= cur4 * 4;
		
		int cur2 = min(c[i] / 2, n2);
		n2 -= cur2;
		c[i] -= cur2 * 2;

		int cur1 = min(c[i], n1);
		n1 -= cur1;
		c[i] -= cur1 * 1;
	}

	if (n4 > 0 || n2 > 0 || n1 > 0) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



class UnionFind {
public:
    vector<int> Parent;
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    int size(int A) {
        return -Parent[root(A)];
    }
    bool connect(int A, int B) {
        A = root(A);
        B = root(B);
        if (A == B) {
            return true;
        }
        if (size(A) < size(B)) swap(A, B);
        Parent[A] += Parent[B];
        Parent[B] = A;
        return false;
    }
};







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

    int N, K, L;
    cin >> N >> K >> L;
    
    UnionFind uni2(N), uni3(N);
    
    rep(i, K) {
        int p, q;
        cin >> p >> q;
        p--; q--;
        uni2.connect(p, q);
    }
    
    rep(i, L) {
        int r, s;
        cin >> r >> s;
        r--; s--;
        uni3.connect(r, s);
    }
    
    int ar[N], br[N];
    rep(i, N) { ar[i] = uni2.root(i); br[i] = uni3.root(i); }
    
    // outa(ar, N);
    // outa(br, N);
    
    map<pii, int> mp;
    rep(i, N) mp[pii{ar[i], br[i]}]++;
    
    rep(i, N) { if (i) cout << " "; cout << mp[pii{ar[i], br[i]}]; }
    cout << endl;
    
}




Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;
const ll L  = 0;
const ll G = 1e9;

ll n, k, a[N];
map<ll, ll> Fen;
ll ps[N], rem[N];

void Add(ll x) {
	x += L;
	for (; x < G; x += x & -x) {
		Fen[x] ++;
	}
}
ll Get(ll x) {
	x += L;
	ll res = 0;
	for (; x; x ^= x & -x) {
		res += Fen[x];
	}
	return res;
}
int main () {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		ps[i] = ps[i - 1] + a[i];
	}
	ll ans = 0;
	vector<ll> vec;
	for (int i = 0; i <= n; i ++) {
		rem[i] = ps[i] - k * i;
		vec.pb(rem[i]);
	}
	sort(all(vec));
	vec.resize(unique(all(vec)) - vec.begin());
	for (int i = 0; i <= n; i ++) {
		rem[i] = lower_bound(all(vec), rem[i]) - vec.begin();
		rem[i] += 5;
	}
	for (int i = 0; i <= n; i ++) {
		ans += Get(rem[i]);
		Add(rem[i]);
	}
	cout << ans;
	
}

Measured memory_bytes: 19056
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define ll long long 
const int maxn=200010;
char s[maxn];
int n;
int f[maxn][2];
int lst[maxn][2],nxt[maxn][2];
char ans[maxn];
int main(){
    scanf("%s",s+1); n=strlen(s+1);
    for (int i=1;i<=n;++i){
        if (s[i]=='P'||s[i]=='?'){
            if (f[i-1][0]>f[i-1][1]) lst[i][0]=0;
            else lst[i][0]=1;
            f[i][0]=f[i-1][lst[i][0]];
        }
        if (s[i]=='D'||s[i]=='?'){
            if (f[i-1][0]+1>f[i-1][1]) lst[i][1]=0;
            else lst[i][1]=1;
            f[i][1]=max(f[i-1][0]+1,f[i-1][1])+1;
        }
    }
    int flag=(f[n][0]<f[n][1]);
    for (int i=n;i>=1;--i){
        if (flag) ans[i]='D';
        else ans[i]='P';
        flag=lst[i][flag];
    }
    for (int i=1;i<=n;++i){
        printf("%c",ans[i]);
    }
    return 0;
}

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

#define lli long long int
int ar[1001];
lli dp[18][170][2];

lli getSum(int n,lli sum,int ind,bool flag){
	if(ind > n)return sum;
	lli res=0;
	int lim = 9;
	if(!flag)lim = ar[ind];
	if(dp[ind][sum][flag]!=-1)return dp[ind][sum][flag];
	for(int i=0; i<=lim; i++){
		if(flag||i<lim)
		res = max(res,getSum(n,sum+i,ind+1,true));
		else
		res = max(res,getSum(n,sum+i,ind+1,flag));
	}
	dp[ind][sum][flag]=res;
	return res;
} 

int main(){
	string n;
	cin>>n;
	int sum = 0;
	memset(dp,-1,sizeof dp);
	for(int i=0;i<n.length();i++){
		ar[i+1] = n[i] -'0';
	}
	lli one=getSum(n.size(),0,1,0);
	cout<<one;
}

Measured memory_bytes: 3684
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main() {
    string S; cin >> S;
    vector<bool> vc;

    // A-Zの登場フラグ．Aを0, Zを25とする
    rep(i, 26) vc.push_back(false);

    // 登場した文字のフラグを立てる
    rep(i, S.size()) vc[S[i] - 'a'] = true;

    string ans = "";
    bool found = false;
    rep(i, 26) {
        if (!vc[i]) {
            ans = 'a' + i;
            found = true;
            break;
        }
    }

    if (!found) ans = "None";

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


Measured memory_bytes: 512