akhauriyash/Code-Regression huggingface dataset:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
a = inpl()
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse = True)
    return divisors
pr = make_divisors(sum(a))
def sol(p):
    mo = []
    pl = []
    for i in a:
        if i%p != 0:
            mo += [i%p]
            pl += [p-i%p]
    mo.sort(); pl.sort()
    m = 0; c = sum(pl)
    ln = len(mo)
    for i in range(ln):
        m += mo[i]
        c -= pl[ln-i-1]
        if max(m,c) <= k and m%p == c%p:
            return True
    return False
for p in pr:
    if sol(p):
        res = p
        break
else:
    res = 1
print(res)



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

public class Main{

static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split("\\s+");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split("\\s+");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
//......................................@uthor_Alx..............................................
static long mod=(long)1e9+7;

public static void main(String[] args) throws  IOException{
                assign();
                int[] x=int_arr();
                int n=x[0],m=x[1];
                List<Integer>[] g=new ArrayList[n+1];
                for(int i=0;i<=n;i++) g[i]=new ArrayList<>();
                for(int i=0;i<m;i++){
                    int[] e=int_arr();
                    g[e[0]].add(e[1]);
                    g[e[1]].add(e[0]);
                }
                int[] r=new int[n+1];
                Queue<Integer> q=new LinkedList<>();
                boolean[] b=new boolean[n+1];b[1]=true;
                q.add(1);
                while(!q.isEmpty()){
                    int p=q.poll();
                    for(int c:g[p]){
                        if(!b[c]){
                            r[c]=p;
                            q.add(c);
                            b[c]=true;
                        }
                    }
                }
                for(int i=2;i<=n;i++){
                    if(r[i]==0){
                        out.write("No");
                        out.flush();return;
                    }
                }
                out.write("Yes\n");
                for(int i=2;i<=n;i++){
                    out.write(r[i]+"\n");
                }
                out.flush();

    }
}


Measured memory_bytes: 80328
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>

using namespace std;


int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    map<long long, long long> mp;
    long long tmp;
    for(int i = 0; i < n; i++){
        cin >> tmp;
        mp[tmp]+= 1;
    }
    int ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        //cout << mp[itr->first] << "," << itr->first << endl;
        if(mp[itr->first] < itr->first){
            ans += mp[itr->first];
        }else{
            ans += abs(mp[itr->first] - itr->first);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6272
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define ll  long long
  #define ld long double
  #define pb push_back
  #define mp3 make_pair
  #define rep1(i,a,b) for(ll i=a;i<=b;i++)
  #define rep2(i,a,b) for(ll i=a;i<b;i++)
  const ll  mod=1e9+7;
  template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
  template<typename T> T add(T a,T b,ll m){a+=b;while(a>=0)a-=m;while(a<0)a+=m; return a;}
  template<typename T> T mul(T a,T b,ll m){return (a*1ll*b)%m;}

 int main(){
   IOS;
  ll n;
  cin>>n;
  ll a[n+1];
  for(ll i=1;i<=n;i++){
    cin>>a[i];
  }
  ll pre[n+1]={0};
  for(ll i=1;i<=n;i++){
    pre[i]=add(a[i],pre[i-1],mod);
  }
  ll ans=0;
  for(ll i=1;i<=n;i++){
    ans=add(ans,mul(a[i],(pre[n]-pre[i]),mod),mod);
  }
  cout<<ans<<endl;
 }

Measured memory_bytes: 6740
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int[] G => ReadLine().Split().Select(int.Parse).ToArray();
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int V, Mod;
	List<int>[] es;
	long[] dp0, dp1;
	void Solve()
	{
		var I = G;
		V = I[0];
		Mod = I[1];
		es = new List<int>[V];
		dp0 = new long[V];
		dp1 = new long[V];
		for (var u = 0; u < V; u++) es[u] = new List<int>();
		for (var e = 0; e < V - 1; e++)
		{
			I = G;
			es[I[0] - 1].Add(I[1] - 1);
			es[I[1] - 1].Add(I[0] - 1);
		}
		DFS0(0, -1);
		DFS1(0);
		for (var u = 0; u < V; u++) WriteLine(dp0[u] * (dp1[u] + 1) % Mod);
	}
	long DFS0(int u, int p)
	{
		dp0[u] = 1L;
		es[u].Remove(p);
		foreach (var v in es[u]) dp0[u] = dp0[u] * (DFS0(v, u) + 1) % Mod;
		return dp0[u];
	}
	void DFS1(int u)
	{
		var W = es[u].Count;
		var x = new long[W + 1];
		var y = new long[W + 1];
		x[0] = y[W] = 1;
		for (var i = 0; i < W; i++) x[i + 1] = x[i] * (dp0[es[u][i]] + 1) % Mod;
		for (var i = W - 1; i >= 0; i--) y[i] = y[i + 1] * (dp0[es[u][i]] + 1) % Mod;
		for (var i = 0; i < W; i++) dp1[es[u][i]] = (dp1[u] + 1) * x[i] % Mod * y[i + 1] % Mod;
		x = y = null;
		foreach (var v in es[u]) DFS1(v);
	}
}


Measured memory_bytes: 39820
#include <iostream>
#include <string.h>
#include <vector>
using namespace std;

int n, m, k, ct;
int ma[100001];
int f[100001];
vector<int> tr[100001];

void dfs(int i, int b) {
	f[i] = b;
	ct++;

	for (int j = 0; j < tr[i].size(); j++) {
		int w = tr[i][j];

		if (f[w] == 0)
			dfs(w, b);
	}
}

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

	memset(f, 0, sizeof(f));

	for (int i = 0; i < m; i++) {
		int a, b;

		cin >> a >> b;
		tr[a].push_back(b);
		tr[b].push_back(a);
	}

	for (int i = 1; i <= n; i++) {
		ct = 0;
		if (f[i] == 0) {
			dfs(i, i);
			ma[i] = ct;
		}
	}

	for (int i = 1; i <= n; i++)
		ma[i] = ma[f[i]];

	for (int i = 1; i <= n; i++)
		ma[i] -= tr[i].size() + 1;

	for (int i = 0; i < k; i++) {
		int c, d;

		cin >> c >> d;

		if (f[c] == f[d]) {
			ma[c]--;
			ma[d]--;
		}
	}

	for (int i = 1; i < n; i++)
		cout << ma[i] << " ";
	cout << ma[n] << endl;
}


Measured memory_bytes: 7936
f=f=1,*(1..m=1000003).map{f=f*_1%m}
$<.map{x,d,n=_1.split.map &:to_i
d&&p(d<1?x.pow(n,m):(f[n+t=x*d.pow(m-2,m)%m-1]||0)*f[t].pow(m-2,m)*d.pow(n,m)%m)}

Measured memory_bytes: 31128
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.buffer.readline
mod = 998244353
INF = float("inf")


class lazySegTree(object):
	def __init__(self, N):
		self.N = N
		self.LV = (N-1).bit_length()
		self.N0 = 2**self.LV
		self.data = [0]*(2*self.N0) #桁の値を管理(lazy*size)
		self.lazy = [0]*(2*self.N0) #桁の文字を管理
		self.size = [1]*(2*self.N0) #桁の和を管理(10^n)(更新しない)
		for i in range(self.N):
			self.size[self.N0-1+i] = pow(10, self.N-i-1, mod)
		for i in range(self.N0-2, -1, -1):
			self.size[i] = (self.size[2*i+1] + self.size[2*i+2])%mod
	# 遅延セグ木の初期化
	def initialize(self):
		for i in range(self.N):
			self.data[self.N0-1+i] = pow(10, self.N-i-1, mod)
		for i in range(self.N0-2, -1, -1):
			self.data[i] = (self.data[2*i+1] + self.data[2*i+2])%mod

  # 遅延伝播を行うindexを生成
	def gindex(self, l, r):
		L = l + self.N0
		L >>= 1
		R = r + self.N0
		R >>= 1
		if l & 1:
			lc = 0
		else:
			lc = (L & -L).bit_length()
		if r & 1:
			rc = 0
		else:
			rc = (R & -R).bit_length()
		for i in range(self.LV):
			if rc <= i:
				yield R
			if L < R and lc <= i:
				yield L
			L >>= 1 
			R >>= 1

	# 遅延伝搬処理
	def propagates(self, *ids):
		for i in reversed(ids):
			v = self.lazy[i - 1]
			if not v:
				continue
			self.lazy[2*i-1] = v
			self.lazy[2*i] = v
			self.data[2*i-1] = v * self.size[2*i-1]
			self.data[2*i] = v * self.size[2*i]
			self.lazy[i-1] = 0

	def update(self, l, r, x):
		*ids, = self.gindex(l, r+1)
		self.propagates(*ids)
		L = self.N0 + l
		R = self.N0 + r + 1
		while L < R:
			if R & 1:
				R -= 1
				self.lazy[R-1] = x #桁の文字を更新
				self.data[R-1] = x * self.size[R-1] #桁の値を更新
			if L & 1:
				self.lazy[L-1] = x
				self.data[L-1] = x * self.size[L-1]
				L += 1
			L >>= 1
			R >>= 1
		for i in ids:
			self.data[i-1] = (self.data[2*i-1] + self.data[2*i])%mod

	# 区間[l, r]内のdataの和を求める
	def query(self, l, r):
		self.propagates(*self.gindex(l, r+1))
		L = self.N0 + l
		R = self.N0 + r + 1
		s = 0
		while L < R:
			if R & 1:
				R -= 1
				s = (s + self.data[R-1])%mod
			if L & 1:
				s = (s + self.data[L-1])%mod
				L += 1
			L >>= 1
			R >>= 1
		return s

N, Q = map(int, input().split())
lSeg = lazySegTree(N)
lSeg.initialize()

for i in range(Q):
	L, R, D = map(int, input().split())
	L -= 1
	R -= 1
	lSeg.update(L, R, D)
	ans = lSeg.query(0, N-1)
	ans %= mod
	print(ans)

Measured memory_bytes: 124544
import java.util.Arrays;
import java.util.Scanner;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(scanner.next());
        }
        int gcd = a[0];
        for (int i = 1; i < N; i++) {
            gcd = (int) gcd(gcd, a[i]);
        }

        System.out.println(gcd);
    }

    private static long gcd(long x, long y) {
        if (x < y) {
            return gcd(y, x);
        }
        if (y == 0) {
            return x;
        }
        return gcd(y, x % y);
    }
}



Measured memory_bytes: 49180
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

typedef long long int lli;

using namespace std;

int main() {

   int A;
   cin >> A;
   string test;
   set<string> S;
   for(int i=0;i<A;i++){
   	cin >> test;
    S.insert(test);
   }
   cout << S.size() << endl;    
}

Measured memory_bytes: 19124
#include<cstdio>
using namespace std;
int n,m,dep[100005],head[100005],cc,ans[100005],A,B,all[100005],l,r,sz[100005];
bool check[100005],c[100005];
struct sd{int next,to;}seg[100005];
inline void addseg(int v,int r) {seg[++cc].next=head[v];head[v]=cc;seg[cc].to=r;}
inline void dfs(int v) {
	all[l=r=1]=v;
	for(int i=1;i<=n;++i) {
		int now=all[l++];
		for(int i=head[now];i;i=seg[i].next) {
			sz[seg[i].to]--;
			if(!sz[seg[i].to]) all[++r]=seg[i].to;
			if(dep[seg[i].to]<dep[now]+1) {dep[seg[i].to]=dep[now]+1;ans[seg[i].to]=now;}
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<n+m;++i) {
		scanf("%d%d",&A,&B);check[B]=true;
		addseg(A,B);sz[B]++;
	}
	for(int i=1;i<=n;++i) if(!check[i]) {dep[i]=1;dfs(i);break;}
	for(int i=1;i<=n;++i) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
using namespace std;
long long N,A,x;
long long dp[300][8000],ans;
int main(){
    dp[0][0]=1;
    scanf("%lld%lld",&N,&A);
    for(int i=1;i<=N;i++){
        scanf("%lld",&x);
        for(int j=i;j>0;j--){
            for(int k=A*N;k>=x;k--){
                dp[j][k]+=dp[j-1][k-x];
            }
        }
    }
    for(int i=1;i<=N;i++){
        ans+=dp[i][i*A];
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 3072
import Control.Monad
import Control.Applicative
import Data.List
import Data.Array
strToInt s = (read :: String -> Int) s

main = do

    n <- readLn :: IO Int
    an <- map strToInt . words <$> getLine
    let bn = group $ sort ((map (1+) an) ++ an ++ (map (\x -> (x-1) ) an))
   
    let x = maximum (map length bn)
    print x

Measured memory_bytes: 49532
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int a[N],sum[N],n,max1; 
int main() {
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	a[0]=-1;
	int l,r,mid;
	for(int i=1;i<=n;i++) {
		if(a[i]==a[i-1]) continue;
		l=1,r=i;
		while(l<r) {
			mid=l+r>>1;
			if(a[mid]<a[i]-1) l=mid+1;
			else r=mid;
		}
		sum[a[i]]+=max(0,i-l);
		l=i,r=n;
		while(l<r) {
			mid=l+r+1>>1;
			if(a[mid]>a[i]+1) r=mid-1;
			else l=mid;
		}
		sum[a[i]]+=max(0,r-i);
		sum[a[i]]++;
		max1=max(max1,sum[a[i]]);
	}
	cout<<max1;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](long a, long b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  ll a,b,c,k,ans;
  cin >> a >> b >> c >> k;
  if(k<=a){cout << k << endl;return 0;}
  if(k<=a+b){cout << a << endl;return 0;}
  else{
    cout << a-(k-a-b)<<endl;
  }

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;

signed main(){
    int N;
    string S;
    cin >> N >> S;
    
    int r=0,g=0,b=0;
    for(int i=0;i<N;i++){
        if(S[i] == 'R') r++;
        if(S[i] == 'G') g++;
        if(S[i] == 'B') b++;
    }
    
    int ans = r*g*b;
    int cnt = 0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            int k = i*2 - j;
            if(j < k && k < N){
                if(S[i] != S[j] && S[j] != S[k] && S[i] != S[k]) cnt++;
            }
        }
    }
    
    cout << ans - cnt << endl;
    return 0;
}





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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
const int mod = 1000000007;

int main() {
    ll n;
    string s;
    cin >> n >> s;

    ll cnt = 0;
    for(ll i = 0; i < n - 1; i++) {
        char now = s[i];
        if(s[i] == s[i + 1]) {
            cnt++;
        }
    }

    cout << n - cnt << endl;

    return 0;
}

Measured memory_bytes: 3724
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())

a,b,c=reads()
if a<=b*c:
    print("Yes")
else:
    print("No")

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

int main(void){
    int N;
    string S;
    cin>>N;
    cin>>S;
    int delL = 0;
    int delR = 0;
    for(int i = 0; i<N; i++){
        if(S[i]=='.'){//右側にある白石を数える
            delR++;
        }
    }
    int minDel = delR;
    for(int i = 0; i<N; i++){
        if(S[i]=='.'){//境目を超す石が白の時は
            delR--;
        }else{
            delL++;
        }
        minDel = min(minDel,delR+delL);
    }
    cout<<minDel<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
class Baseball{
private:
    int score,out,runner,inning;
public:
    Baseball();
    ~Baseball()=default;
    void checkEvent(std::string event);
    void hit();
    void homerun();
    void countOut();
    int getInning();
};

Baseball::Baseball(){
    score=0,out=0,runner=0,inning=0;
}

void Baseball::checkEvent(std::string event){
    if(event=="HIT"){
        this->hit();
    }
    else if(event=="OUT"){
        this->countOut();
    }
    else if(event=="HOMERUN"){
        this->homerun();
    }
}

void Baseball::hit(){
    runner<3?++runner:++score;
}
	
void Baseball::countOut(){
    if(out<2){
        ++out;
    }
    else{
	std::cout << score << std::endl;
	runner=0,out=0,score=0;++inning;
    }
}
	
void Baseball::homerun(){
    score+=runner+1;
    runner=0;
}	

int Baseball::getInning(){
    return inning;
}

int main() {
    Baseball game;
    int num;
    std::cin >> num;
    while(game.getInning()<num){
        std::string event;
	std::cin >> event;
	game.checkEvent(event);
    }
    return 0;
}

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

int main(){
  string sa,sb;
  int w,n,a,b,c;
  cin>>w>>n;
  int num[w];
  for(int i=0;i<w;i++)
    num[i] = i+1;
  for(;n>0;n--){
    getline(cin,sa,',');
    getline(cin,sb,'\n');
    a = atoi(sa.c_str())-1;
    b = atoi(sb.c_str())-1;
    c = num[a];
    num[a] = num[b];
    num[b] = c;
  }
  for(int i=0;i<w;i++)
    cout << num[i] << endl;
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define boost  ios_base::sync_with_stdio(0);
#define N 1000
#define ll long long int
#define pb push_back
#define f first
#define s second
#define fo(i,a,b) for(i = a; i < b; i++)
#define foe(i, a,b) for(i = a; i <= b; i++)
#define tc long long int t; cin >> t; while(t--)
#define vect vector <ll>
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll>>
#define be begin
#define en end

int main(){
	boost;
	ll i;
	ll n;
	ll k;
	cin >> n >> k;;
	ll a[n];
	fo(i,0,n){
		cin >> a[i];
	}
	ll dp[n+1];
	fo(i,0,n){
		dp[i] = INT_MAX;
	}
	dp[0] = 0;
	fo(i,0,n){
		for(ll j = i+1; j <= k+i; j++){
			if(j < n){
				dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
			}
		}
	}
	cout << dp[n-1] <<endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int isprime[(int)1e6+5];
vector<int> pl;
void sieve(){
	for(int i = 2;i<=1e6;i++){
		if(isprime[i]!=0) continue;
		isprime[i]= 1;
		pl.push_back(i);
		for(int j = 2*i;j<=1e6;j+=i) isprime[j] = -1;
	}
}

int binser(int find){
	int l = 0, r = pl.size()-1, ret = -1;
	while(l<=r){
		int m = (l+r);
		if(pl[m] == find){
			return find;
		}else if(pl[m] < find){
			l = m+1;
		}else{
			ret = pl[m];
			r = m-1;
		}
	}
	return ret;
}

int main(){
	sieve();
	int n;
	cin>>n;
	cout<<binser(n)<<"\n";
	
	return 0;
}

Measured memory_bytes: 4732
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	while(1){
		getline(cin,s);
		if(s==".")break;
		stack<char> st;
		bool ans = true;
		FOR(i,0,s.size()){
			if(s[i]=='('||s[i]=='['){
				st.push(s[i]);
			}else if(s[i]==')'){
				if(st.size()==0){
					ans = false;
				}else{
					if(st.top()=='(')st.pop();
					else ans = false;
				}
			}else if(s[i]==']'){
				if(st.size()==0){
					ans = false;
				}else{
					if(st.top()=='[')st.pop();
					else ans = false;
				}	
			}
		}
		if(st.size()!=0)ans = false;
		if(ans){
			cout << "yes" << endl;
		}else{
			cout << "no" << endl;
		}
	}
}


Measured memory_bytes: 3240
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#define SIZE 300005

using namespace std;
typedef long long int ll;

int A[SIZE];
ll dp[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	n*=3;
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	priority_queue <ll,vector <ll>,greater <ll> > que;
	ll sum=0;
	for(int i=0;i<n;i++)
	{
		que.push(A[i]);
		sum+=A[i];
		if(que.size()>n/3)
		{
			sum-=que.top();
			que.pop();
		}
		dp[i]=sum;
	}
	priority_queue <ll> que2;
	sum=0;
	for(int i=n-1;i>=0;i--)
	{
		que2.push(A[i]);
		sum+=A[i];
		if(que2.size()>n/3)
		{
			sum-=que2.top();
			que2.pop();
		}
		if(i>=1) dp[i-1]-=sum;
	}
	ll ret=dp[n/3-1];
	for(int i=n/3-1;i+n/3<n;i++) ret=max(ret,dp[i]);
	//for(int i=n/3-1;i+n/3<n;i++) printf("%lld ",dp[i]);puts("");
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 6004
#include<cstdio>
#include<cstring>
using namespace std;

char a[30];
int len;

inline bool check(int end,char c)
{
	for(register int i=1;i<=end;i++)
		if(a[i]==c)  return 0;
	return 1;
}

int main()
{
	scanf("%s",a+1);
	len=strlen(a+1);
	a[len+1]='a'-1;
	for(register int i=1;i<=len;i++)
		for(register int j=1;j<i;j++)
			if(a[i]==a[j])  return printf("-1"),0;
	for(register int i=1;i<=len;i++)
		if(a[i]<'a'||a[i]>'z')  return printf("-1"),0;
	for(register int i=len+1;i>=1;i--)
	{
		for(register char j=a[i]+1;j<='z';j++)
			if(check(i-1,j))
			{
				for(register int t=1;t<i;t++)
					putchar(a[t]);
				putchar(j);
				return 0;
			}
	}
	printf("-1");
	return 0;
}

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

int main(){
    
    int N,W;
    int v[100],w[100];
    int dp[101][10001] = {};
    
    cin >> N >> W;
    for (int i = 0; i < N; i++){
        cin >> v[i] >> w[i];
    }
    for (int i = 1; i <= N; i++){
        for (int j = 0; j <= W; j++){
            if (j - w[i - 1] < 0) dp[i][j] = dp[i - 1][j];
            else dp[i][j] = max(dp[i - 1][j],dp[i - 1][j - w[i - 1]] + v[i - 1]);
        }
    }
    
    cout << dp[N][W] << endl;
    return 0;
}


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

pair<int, int> C[105]; int N; vector<pair<int, int>>vec;

int main() {
	cin >> N; int Z = N; if (N % 2 == 1) Z--;
	for (int i = 1; i <= N / 2; i++) {
		C[i] = make_pair(i, Z + 1 - i);
	}
	if (N % 2 == 1) C[(N + 1) / 2] = make_pair(N, N);
	for (int i = 1; i <= (N + 1) / 2; i++) {
		pair<int, int> Z1 = C[i];
		pair<int, int> Z2 = C[i + 1]; if (i == (N + 1) / 2) Z2 = C[1];

		vec.push_back(make_pair(Z1.first, Z2.first));
		vec.push_back(make_pair(Z1.first, Z2.second));
		vec.push_back(make_pair(Z1.second, Z2.first));
		vec.push_back(make_pair(Z1.second, Z2.second));
	}
	for (int i = 0; i < vec.size(); i++) { if (vec[i].first > vec[i].second) swap(vec[i].first, vec[i].second); }
	sort(vec.begin(), vec.end());
	vec.erase(unique(vec.begin(), vec.end()), vec.end());

	cout << vec.size() << endl;
	for (int i = 0; i < vec.size(); i++) cout << vec[i].first << " " << vec[i].second << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
  char s[200000+2]={0},*ptr1,*ptr2;
  scanf("%s",s);
  ptr1 = strchr(s,'A');
  ptr2 = strrchr(s,'Z');
  printf("%d",ptr2-ptr1+1);
  return 0;
}

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

#ifdef LOCAL
  #include <contest/local.hpp>
#else
  #define LOG(...) do {} while (false)
#endif

#define REP(i,n) for (decltype (n) i = 0, i ## __len = (n); i < i ## __len; ++ i)
#define ALL(x) (x).begin (), (x).end ()

using namespace std;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);
  cout << fixed << boolalpha;
  cerr << fixed << boolalpha;


  int n;
  cin >> n;
  vector <pair <int64_t, int64_t>> v;
  REP (i, n)
  {
    int64_t a, b;
    cin >> a >> b;
    v.emplace_back (a, b);
  }

  sort (ALL (v), [](auto && p1, auto && p2){
    int64_t a1, b1, a2, b2;
    tie (a1, b1) = p1;
    tie (a2, b2) = p2;
    return b1 < b2;
  });

  LOG(v);

  bool ans = true;
  int64_t t = 0;
  for (auto && elem : v)
  {
    int64_t a, b;
    tie (a, b) = elem;
    t += a;
    if (t > b)
    {
      ans = false;
      break;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
}



Measured memory_bytes: 6256
#include<bits/stdc++.h>
using namespace std;
#define debug(x)        cout<<#x<<" :"<<x<<endl;
#define ff              first
#define ss              second
#define ar              array
#define int             long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,n)          for(int i=0;i<n;i++)
#define MOD             1000000007
#define pi              3.14159265
#define umii            unordered_map<int,int>
#define umci            unordered_map<char,int>
#define umsi            unordered_map<string,int>

void k_007()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
  freopen("ip1.txt", "r", stdin);
  freopen("op1.txt", "w", stdout);
#endif
}

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
  return (a.second < b.second);
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int prime(int n) {
  int flag = 1;
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {flag = 0; break;}
  }
  return flag;
}
int power(int x, int y)
{
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return ((power(x, y / 2) % MOD) * ( power(x, y / 2) % MOD)) % MOD;
  else
    return ((x % MOD) * (power(x, y / 2) % MOD) * (power(x, y / 2) % MOD)) % MOD;
}
int lcm(int a, int b)
{
  return (a * b) / gcd(a, b);
}

int32_t main()
{
  k_007();
  int n;
  cin >> n;
  int ans = 0;

  ans += (n / 500) * 1000;
  n = n % 500;
  ans += (n / 5) * 5;

  cout << ans << endl;
}


Measured memory_bytes: 3564
#include<stdio.h>
#define N 101
  int main(){
  int lengh;
  int A[N],i,j,key,count=0;
  scanf("%d",&lengh); 
for(i=1;i<=lengh;i++){
    scanf("%d",&A[i]);}
  for(i=1;i<=lengh;i++){
    for(j=lengh;j>=i+1;j--){
      if(A[j]<A[j-1]){
    key=A[j];
    A[j]=A[j-1];
    A[j-1]=key;
    count++;}}}
  for(i=1;i<=lengh;i++){
if(i==lengh){
printf("%d\n",A[i]); 
	break;
}
 printf("%d ",A[i]);
}
   
printf("%d\n",count);
  return 0;}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std; typedef long long ll;

ll dp[110][100010];

int main(){
ll N,W; cin >> N >> W; vector<ll> w(N); vector<ll> v(N);
  for(ll i = 0; i < N; i++){ cin >> w[i] >> v[i];}
  for(ll i = 0; i < 110; i++){
    for(ll j = 0; j < 100010; j++){ dp[i][j] = 0;}} //初期化
  
  for(ll i = 0; i < N; i++){
    for(ll sum_w = 0; sum_w <= W; sum_w++){
      if( sum_w >= w[i]){ 
        dp[i+1][sum_w] = max( dp[i+1][sum_w], dp[i][sum_w - w[i]] + v[i]);}
      dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w]);}}
    
    cout << dp[N][W] << endl; return 0;}
                           
  
  

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

int main(){
  int N;
  string S;
  cin>>N;
  cin>>S;
  for(int i=0;i<S.size();i++){
    if((S.at(i)+N)<='Z')
      S.at(i)+=N;
    else{
      int M=(S.at(i)+N)-'Z'-1;
      S.at(i)='A'+M;
    }
  }
  cout<<S<<endl;
}

Measured memory_bytes: 256
import fractions

def lcm(x, y):
    return x*y//fractions.gcd(x, y)

def func(n, p, q):
    return n - (n//p + n//q - n//lcm(p, q))

a, b, c, d = map(int,input().split())

print(func(b, c, d) - func(a-1, c, d))

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;

int main(){
    ll n,x,ans=0;
    cin >> n >> x;
    vl a(n);
    lrp(i,n){
        cin >> a[i];
    }
    lrep(i,1,n-1){
        if(a[i-1]+a[i]>x){
            if(x-a[i-1]<0){
                ans += a[i-1]+a[i]-x;
                a[i]=0;
                a[i-1] -= a[i-1]-x;
            }else{
                ans+=a[i-1]+a[i]-x;
                a[i]-=a[i-1]+a[i]-x;

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



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 

ll N;
vector<ll> A(2e5+1), S(2e5+1);
map<i_i, ll> dp;
ll solve(int i, int k){
    
    
    if (N - i == k * 2 - 1){
        return S[i];
    } else if (i > N - 1 || N - i < k * 2 - 1){
        return -1e15;
    }
    if (dp[make_pair(i, k)] != 0)return dp[make_pair(i, k)];
    ll ans = A[i] + solve(i + 2, k - 1);
    chmax(ans, A[i] + solve(i + 3, k - 1));
    chmax(ans, A[i] + solve(i + 4, k - 1));
    if (i + 1 < N){
        chmax(ans, A[i + 1] + solve(i + 3, k - 1));
        chmax(ans, A[i + 1] + solve(i + 4, k - 1));
        if (i + 2 < N){
            chmax(ans, A[i + 2] + solve(i + 4, k - 1));
        }
    }
    return dp[make_pair(i, k)] = ans;
}
    
int main() {
    cin >> N;
    
    rep(i, N)cin >> A[i];
    
    S[N - 1] = A[N - 1];
    for (int i = N - 3; i >= 0; i-=2){
        S[i] = S[i + 2] + A[i];
    }
    
    ll ans = solve(0, N/2);
    cout << ans;
    return 0;
}



Measured memory_bytes: 31396
N = int(input())
A = list(map(int, input().split()))

minus = 0

for a in A:
    if a < 0:
        minus += 1


ans = 0
minA = float('inf')
for a in A:
    ans += abs(a)
    if minA > abs(a):
        minA = abs(a)

if 0 in A or minus % 2 == 0:
    print(ans)
    exit(0)

ans -= 2 * minA
print(ans)


Measured memory_bytes: 14412
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<uint64_t> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end(), greater<uint64_t>());
	int i = 0;
	int count = 0;
	uint64_t edges[2];
	while (count < 2 && i < N) {
		if (A[i] == A[i + 1]){
			edges[count] = A[i];
			count++;
			i++;
		}
		i++;
	}
	cout << edges[0] * edges[1] << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<sstream>
using namespace std;
long t(string s){stringstream r;r<<s;long a;r>>a;return a;}
main()
{
	string s;cin>>s;
	int n=s.size()-1;
	long c=0;
	for(int i=0;i<1<<n;i++)
	{
		long a=0;
		int b=0;
		for(int j=0;j<n;j++)
		{
			if(i&1<<j)
			{
				a+=t(s.substr(b,j-b+1));
				b=j+1;
			}
		}
		a+=t(s.substr(b));
		c+=a;
	}
	cout<<c<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=k-n+1;i<=k+n-1;i++)
	{
		if(i==k+n-1) printf("%d",i);
		else printf("%d ",i);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;

int par[100010],r[100010]={};
void init(int n);
int root(int a);
void unite(int a,int b);

int main(void){
  int n,m,k,i,j,l;
  vector<int> lan[100010];
  set<int> s;
  cin >> n >> m;
  init(n);
  for (i=0;i<n;i++){
    cin >> k;
    for (j=0;j<k;j++){
      cin >> l;
      lan[l-1].push_back(i);
    }
  }
  for (i=0;i<m;i++){
    for (j=1;j<lan[i].size();j++) unite(lan[i][j-1],lan[i][j]);
  }
  for (i=0;i<n;i++) s.insert(root(i));
  if (s.size()==1) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

void init(int n){
  int i;
  for (i=0;i<n;i++) par[i]=i;
}

int root(int a){
  if (par[a]==a) return a;
  return par[a]=root(par[a]);
}

void unite(int a,int b){
  a=root(a);
  b=root(b);
  if (a==b) return;
  if (r[a]<r[b]){
    par[a]=b;
    r[b]++;
  }else{
    par[b]=a;
    r[a]++;
  }
}

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

int main()
{

    int n;
    cin>>n;
    int x[n],y[n],h[n];
    for(int i=0;i<n;i++)
    {
        cin>>x[i]>>y[i]>>h[i];
    }



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

            int H;
            for(int k=0;k<n;k++)
            {
                if(h[k]>0)
                {
                H=h[k]+(abs(x[k]-i))+abs(y[k]-j);
                break;

                }
            }
            int c=0;
            for(int k=0;k<n;k++)
            {
                int hs=max((H-(abs(x[k]-i))-abs((abs(y[k]-j)))),0);
                if(hs!=h[k])
                {
                    break;
                }
                c++;

            }

            if(c==n)
            {
                cout<<i<<" "<<j<<" "<<H<<"\n";
            }


        }


    }


return 0;
}


Measured memory_bytes: 256
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int a, b;
    cin >> a >> b;
    int t = a - 1;
    a = 1;
    int cnt = 0;
    while( a < b ) {
        ++cnt;
        a += t;

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main(){
    int k , a , b;
    cin >> k >> a >> b;
    
    if(b/k > (a-1)/k){
        cout << "OK\n";
    } else {
        cout << "NG\n";
    }
    
    return(0);
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>

char s[ 1000001 ], pn[ 2000002 ];

int main( void ) {
	char *p;
	int i, n, t;

	for ( ; scanf( "%d %*d %s", &n, s ), n; printf( "%d\n", t ) ) {
		for ( i = 0 ; i < n * 2 + 1; i++ )
			sprintf( pn + i, i & 1 ? "O" : "I" );

		t = 0;
		for ( p = s - 2; ( p = strstr( p + 2, pn ) ) != NULL; t++ ) ;
	}

	return 0;
}

Measured memory_bytes: 1604
import java.util.*;

public class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] h = new long[n];

        for (int i=0; i<n; i++){
            h[i] = sc.nextInt();
        }

        Arrays.sort(h);

        long sum = 0;

        for (int i=0; i<n-k; i++){
            sum += h[i];
        }

        System.out.println(sum);


    }
}






Measured memory_bytes: 67228
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
   int n, x, t;
   cin>>n>>x>>t;

   int kai=(n-1)/x+1;
   int ans=t*kai;

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


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,m;
signed main() {
	cin>>n>>m;
	int ans=1;
	for(int i=1;i*i<=m;i++)if(m%i==0){
		if(i>=n)ans=max(ans,m/i);
		if(m/i>=n)ans=max(ans,i);
	}
	cout<<ans;






}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	ll ans = 0;
	if(n >= m/2){
		ans += m/2;
		n -= m/2;
		m %= 2; 
	}
	else{
		ans += n;
		m -= 2*n;
		n = 0;
	}
	ans += m / 4;
	cout << ans << endl;
	return 0;
}


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

int main(){
    ll a, b;
    cin >> a >> b;

    int k;
    cin >> k;

    int flag = 0;
    for(int i = 0; i < k; i++){
        if(flag == 0){
            if(a % 2 == 1){
                a--;
            }

            b += (a / 2);
            a /= 2;
            flag = 1;
        }else{
            if(b % 2 == 1){
                b--;
            }

            a += (b / 2);
            b /= 2;
            flag = 0;
        }
    }

    cout << a << " " << b << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	int N,A=0,B=0;
	cin >> N;
	vector<int> a(N);
	for(int i=0;i<N;i++)	cin >> a[i];
	sort(a.begin(),a.end());
	if(N%2==1){
		A+=a[0];
		for(int i=1;i<N;i+=2){
			B+=a[i];
			A+=a[i+1];
		}
	}
	else{
		for(int i=0;i<N;i+=2){
			A+=a[i+1];
			B+=a[i];
		}
	}
	cout << A-B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            :oyhhhhhhyo:    
#define next         .sdNNNmNNNNNNNmds. 
#define y0          -hNNNNy`yNNNNNN`/Nh-
#define y1          mNNNNNd+dNNNNNN+sNNm
#define yn          mNNNNNNNNy--:smNNNms
#define tm          .+oooooosyysooooo+- 
#define read               :yhy/        
#define rank              :mNmo         
#define index              ... 
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 111111;
int a[N];
int n;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    rep(i, 1, n) {
        cin >> a[i];
    }
    a[n + 1] = -1;
    int cur = 0, ans = 0;
    rep(i, 1, n) {
        if(a[i] > a[i - 1]) {
            cur = 0;
        } else {
            cur++;
        }
        ans = max(ans, cur);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;

void solve(){
	int n,k;
	cin >> n >> k;
	int a[n + 1];
	for(int i = 1; i <= n; ++i)cin >> a[i];
	for(int i = k + 1; i <= n; ++i){
		if(a[i] > a[i - k])cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}	

int32_t main(){
	IO;
	
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


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

//10**9+7で割るので
int mod = 1'000'000'007;

//最後のすべて0のときのためにmodpowを作っておく
long long modpow(int x, int y){
    if (y==0) return 1;
    if (y%2 == 0) return modpow(x, y/2) * modpow(x, y/2) % mod;
    else return x * modpow(x, y-1) % mod;
}

int main(){
    //ansは非常に大きくなることがある
    long long ans;
    //nは10**5ぐらい
    int n;
    cin >> n;
    //累積XOR
    vector<long long> acc(n);
    for (int i = 0; i<n; i++){
        cin >> acc[i];
        if (i) acc[i] ^= acc[i-1];
    }
    //最後が0ではないとき
    if (acc.back()){
        //0 X 0 X...0 Xとなるのでdpで簡単に行ける
        vector<long long> dp(2, 0);
        dp[0] = 1;
        for (int i = 0; i<n-1; i++){
            if (acc[i] == 0) dp[0] += dp[1];
            else if (acc[i] == acc.back()) dp[1] += dp[0];
            dp[0] %= mod;
            dp[1] %= mod;
        }
        ans = dp[0];
    }
    //最後が0ならば 0 X 0 X ... 0 もしくは 0 0 0 0 ... 0
    else{
        //ある数が存在するか
        vector<vector<int>> num(1<<20);
        //0番目は0なので
        num[0].push_back(0);
        //それぞれ対応するとこに突っ込む　こうすると、結局dpを回す部分がn個になるのでO(N)で求まる
        for (int i = 0; i<n; i++) num[acc[i]].push_back(i+1);
        //ある区間の0の数をO(1)で求めるために累積和を求める 0番目からn番目まで
        vector<int> zero(n+1, 0);
        zero[0] = 1;
        for (int i = 0; i<n; i++){
            if (acc[i]==0) zero[i+1]++;
        }
        for (int i = 1; i<n+1; i++){
            zero[i] += zero[i-1];
        }
        ans = 0;
        //X=0のとき以外についてdpをする
        for (int i = 1; i<(1<<20); i++){
            if (num[i].size() > 0){
                int left = 0;
                int right = num[i][0];
                vector<long long> dp(2, 0);
                dp[0] = 1;
                for (int k = 0; k<(int)num[i].size(); k++){
                    //modをとりつつdpする
                    dp[0] += (dp[1] * (zero[right] - zero[left]) % mod);
                    dp[0] %= mod;
                    dp[1] += dp[0];
                    dp[1] %= mod;
                    left = num[i][k];
                    right = num[i][k+1];
                }
                //のこりは全部0なので、もう選べない
                ans += dp[1];
                ans %= mod;
            }
        }
        //最後に全て0のときを求める　単純にその0を使うか使わないかなので2**(0の個数)となる
        ans += modpow(2, zero.back() - 2);
        ans %= mod;
    }
    cout << ans << endl;
}



Measured memory_bytes: 40308
Md,MN=1000000007,1000006
fac,ifac,a,res,inv=[1,1],[1,1],[0],0,[1,1]
for i in range(2,MN):
    inv.append(inv[Md%i]*(Md-Md//i)%Md)
    fac.append(fac[-1]*i%Md)
    ifac.append(ifac[-1]*inv[i]%Md)
def C(x,y):
    if(x<y):
        return 0
    return fac[x]*ifac[y]*ifac[x-y]
def D(x,y):
    return C(x-y+1,y)

n=int(input())
for i in range(1,n):
    if i*2-n>=0:
        a.append(D(n-3,n-i-1)*fac[i]*fac[n-i-1]%Md)
    else:
        a.append(0)
for i in range(n-1,0,-1):
    a[i]=(a[i]-a[i-1])%Md
    res=res+a[i]*i
res=res%Md
print(res)


Measured memory_bytes: 175020
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for(int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)
 
#define rsz resize
#define eb emplace_back
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define f first
#define s second

 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

const int N = 1e5 + 5;
int dp [N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); 
  int n, q;
  string w;
  cin >> n >> q >> w;
  F0R (i, n - 1) {
    dp[i] += dp[i - 1];
    if (w[i] == 'A' && w[i + 1] == 'C') ++dp[i];
  }
  while (q--) {
    int l, r;
    cin >> l >> r;
    --l; --r;
    if (r - 1 < 0) cout << 0 << '\n';
    else cout << dp[r - 1] - (l - 1 >= 0 ? dp[l - 1] : 0) << '\n';
  }
  return 0; 
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
bool f(char c) {
	return c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o';
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	bool ok = true;
	int cnt = 0;
	FOR(i, 2, s.size() - 1)cnt += s[i] == 'C';
	ok = cnt == 1 && s[0] == 'A';
	FOR(i, 1, s.size()-1) {
		if (s[i] != 'C'&&isupper(s[i]))ok = false;
	}
	if (isupper(s.back()))ok = false;
	if (ok)cout << "AC" << endl;
	else cout << "WA" << endl;
}


Measured memory_bytes: 256