akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
  int num;
  cin >> num;
  for (int i=1; i<10; i++) {
    for (int j=i; j<10; j++) {
      if (num == i*j) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
  std::string s;
  std::cin >> s;
  if((s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])
    ||(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1])
    ||(s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[1]))
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
  return 0;
}
    

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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int x=nextInt();
		int y=nextInt();

		String ans = "No";
		int[] a = {1,3,5,7,8,10,12};
		int[] b = {4,6,9,11};
		int[] c = {2};
		boolean flg1 = false;
		boolean flg2 = false;
		for(int i=0;i<a.length;i++){
			if(x==a[i])
				flg1=true;
		}
		for(int i=0;i<a.length;i++){
			if(y==a[i])
				flg2=true;
		}
		if(flg1&&flg2){
			ans="Yes";
		}

		flg1 = false;
		flg2 = false;
		for(int i=0;i<b.length;i++){
			if(x==b[i])
				flg1=true;
		}
		for(int i=0;i<b.length;i++){
			if(y==b[i])
				flg2=true;
		}
		if(flg1&&flg2){
			ans="Yes";
		}

		flg1 = false;
		flg2 = false;
		for(int i=0;i<c.length;i++){
			if(x==c[i])
				flg1=true;
		}
		for(int i=0;i<c.length;i++){
			if(y==c[i])
				flg2=true;
		}
		if(flg1&&flg2){
			ans="Yes";
		}


		System.out.println(ans);

	}

	public static boolean isPalindromicStr(String s) {
		int h = 0;
		int t = s.length() - 1;
		while (h <= t) {
			if (s.charAt(h) != s.charAt(t)) {
				break;
			}
			h++;
			t--;
		}
		if (h > t) {
			return true;
		}
		return false;
	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 22996
n,k=map(int,input().split())
a=list(map(int,input().split()))
from collections import defaultdict
d=defaultdict(int)
for i in a:
  d[i]+=1
if len(d)<=k:
  print(0)
else:
  print(sum(sorted(list(d.values()))[:len(d)-k]))

Measured memory_bytes: 98896
import sys
import numpy as np

read = sys.stdin.read

n, m = map(int, input().split())
h = list(map(int, input().split()))
way = np.array(read().split(), dtype=np.int64).reshape([m,2]) - 1

o = np.ones(n)
for i in way:
    a, b = i
    if h[a] <= h[b]:
        o[a] = 0
    if h[b] <= h[a]:
        o[b] = 0
ans = np.count_nonzero(o)
print(ans)

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

int main() {
  int H,W;
  cin >> H >> W;
  
  for (int i = 0;i < W + 1;i++) {
    cout << "#";
  }
  
  cout << "#" << endl;
  
  vector<char> abc(W);
  
  for (int j = 0;j < H;j++) {
    
    cout << "#";
    
    for (int i = 0;i < W;i++) {
      cin >> abc.at(i);
      cout << abc.at(i);
    }
    
    cout << "#" << endl;
  }
  
  for (int i = 0;i < W + 2;i++) {
    cout << "#";
  }
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt(), b = scan.nextInt();

		System.out.print(a*b + " " + (2*a+2*b) + "\n");
		scan.close();
	}

}



Measured memory_bytes: 26408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second


int dp[100005][105];
void solve(){
	
	int N,W;
	cin>>N>>W;

	int item[N][2];

	int sum=0;
	rep(i,0,N){
		cin>>item[i][0]>>item[i][1];
		sum+=item[i][1];
	}
	rep(i,0,sum+1){
		rep(j,0,N+1){
			if(i==0){
				dp[i][j]=0;
				continue;
			}
			if(j==0){
				dp[i][j]=1e18;
				continue;
			}
			if(i>=item[j-1][1])
				dp[i][j] = min(dp[i-item[j-1][1]][j-1] + item[j-1][0], dp[i][j-1]);
			else
				dp[i][j] = dp[i][j-1];
		}
	}
	repd(i,sum,0){
		if(dp[i][N] <= W){
			cout<<i<<endl;
			return;
		}
	}



}
signed main(){
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand (static_cast <unsigned> (time(0)));
    int t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 82304
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define Min(a,b) a=min(a,b);
#define ret return puts("-1"),0;
#define N 500055
//#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,num[17],cnt[70005],f[70005],x,y,v,a[N],b[N],ans;
vector<int> vec[20];
void dp(int S){
    F(i,0,num[16]) cnt[i]=cnt[i>>1]+(i&1),vec[cnt[i]].push_back(i),f[i]=inf;
    f[S]=0;
    D(i,16,1)
        for (int j=0;j<vec[i].size();j++){
            int s=vec[i][j];
            if (f[s]==inf) continue;
            F(x,0,15)
                F(y,0,15){
                    if (!(s&num[x])||!(s&num[y])||x==y) continue;
                    Min(f[s^num[x]^num[x^y]^num[y]],f[s]+1+((s&num[x^y])>0));
                }
        }
}
signed main(){
	n=read();
	F(i,1,n-1){
		x=read();y=read();v=read();
		a[x]^=v;a[y]^=v;
	}
	F(i,0,n-1) b[a[i]]++;
	F(i,1,15) ans+=b[i]/2;
	num[0]=1;F(i,1,16) num[i]=num[i-1]*2;
	int sum=0;F(i,1,15) sum+=num[i]*(b[i]&1);
	dp(sum);
	wrn(f[0]+ans);
	return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>

using namespace std;

typedef struct edge_ {
    int num;
    int from;
    int to;
} edge;

vector<int> color;
vector<vector<edge> > G;

void dfs(int s, int p, int c) {
    int tmp = 1;
    for (auto e: G[s]) {
        if (e.to == p)
            continue;

        if (tmp == c)
            tmp++;
        color[e.num] = tmp;
        dfs(e.to, s, tmp);
        tmp++;
    }
}

int main() {
    int n;  cin >> n;
    G.resize(n);
    color.resize(n-1);
    for (int i = 0; i < n-1; i++) {
        int a, b;   cin >> a >> b;
        edge e1 = {i, a-1, b-1}, e2 = {i, b-1, a-1};
        G[a-1].push_back(e1);
        G[b-1].push_back(e2);
    }

    int cnt = 0;
    for (int i = 0; i < n; i++)
        cnt = max(cnt, (int)(G[i].size()));
    cout << cnt << endl;

    dfs(0, -1, -1);

    for (int i = 0; i < n-1; i++)
        cout << color[i] << endl;

    return 0;
}

Measured memory_bytes: 11044
N = gets.to_i
array = []
N.times{ array.push(gets.split(' ').map(&:to_i)) }
array.sort!{|a, b| a[1] <=> b[1] }
sum = 0
ret = true
array.each{ |x,y| sum += x; ret = false if sum > y }
if ret
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 18552
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define ld long double
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
const int mod=998244353;
int a[100005];
int main(){
	int mn=1e9;
	int n=read();
	for(int i=0;i<n;i++)a[i]=read();
	sort(&a[0],&a[n]);
	ll ans=a[0];
	for(int i=1;i<n;i++)ans=ans*__gcd(a[i],i)%mod;
	cout<<ans%mod<<endl;
}

Measured memory_bytes: 640
n = int(input())
a = [int(i) for i in input().split()]
sums = sum(a)
b = [int(i) for i in input().split()]

for i in range(n):
    if b[i] < a[i]+a[i+1]:
        if a[i] <= b[i]:
            a[i+1] = a[i]+a[i+1]-b[i]
            a[i] = 0
        else:
            a[i] = a[i]-b[i]
    else:
        a[i] = 0
        a[i+1] = 0

if sum(a)>0:
    ans = sums-sum(a)
else:
    ans = sums
print(ans)

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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> l(n);
  for (int i=0;i<n;i++){
    cin>>l[i];
  }
  
  sort(l.begin(),l.end());
  int ans=0;
  for(int i=0;i<k;i++){
    ans+=l[n-1-i];//「n個のうち大きい方からk個取る」の表現
  }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <queue>
#include <climits>

using namespace std;

typedef long long ll;

const int MAXN = 1000000+5;
const int MOD = 1000000000+7;

ll exgcd(ll a, ll b, ll& x, ll& y)
{
    ll d=a;
    if(b!=0){
        d=exgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }else{
        x=1;y=0;
    }
    return d;
}

ll mod_inverse(ll a, ll m)
{
    ll x, y;
    exgcd(a, m, x, y);
    return (m + x % m) % m;
}

ll mul[2*MAXN];

ll compute_f(int r, int c) 
{
    if(r==0 || c==0) return 1;
    ll a1 = mul[r+c];
    ll a2 = mod_inverse(mul[r], MOD);
    ll a3 = mod_inverse(mul[c], MOD);
    return (((a1*a2)%MOD)*a3) % MOD;
}

int t;

int main()
{
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout); 
    mul[0] = mul[1] = 1;
    for(int i=2;i<2*MAXN;++i) {
        mul[i] = (mul[i-1]*i) % MOD;
    }
    //cout<<compute_f(1,1)<<endl;
    //cout<<compute_f(2,2)<<endl;
    int r1,r2,c1,c2;
    while(cin>>r1>>c1>>r2>>c2) {
        ll ans = 0;
        for(int i=c1;i<=c2;++i) {
            ll ss = compute_f(r2,i);
            ans = (ans + ss) % MOD;
        }
        for(int i=r1+1;i<=r2;++i) {
            ll ss = compute_f(i, c2);
            ans = (ans + ss - compute_f(i, c1-1) + MOD) % MOD;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 15872
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def X(): return list(input())
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
A = l()
mi = 0

for i in A:
    if i % 2 == 0:
        mi += 1

print(3**N - 2 **mi)


Measured memory_bytes: 9988
#include<bits/stdc++.h>
using namespace std;
struct LIS{
  int n;
  vector<int>dp,a;
  LIS(int sz):dp(sz),a(sz),n(sz){}
  void Input(){
    for(int i=0;i<n;i++) cin>>a[i];
  }
  int lis(){
    dp[0]=a[0];
    int len=1;
    for(int i=1;i<n;i++){
      if(dp[len-1]<a[i]) dp[len++] = a[i];
      else *lower_bound(dp.begin(),dp.begin()+len,a[i]) = a[i];
    }
    return len;
  }
};
int main(){
  int n;
  cin>>n;
  LIS L(n);
  L.Input();
  cout<<L.lis()<<endl;
}


Measured memory_bytes: 3600
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  double x, h;
  while (cin >> x >> h, x) {
    cout << prec(8) << x * x + x * hypot(h, x / 2) * 2 << endl;
  }
}

Measured memory_bytes: 3248
import math
import fractions

n = int(input())
a = [int(i) for i in input().split()]
ans = 10 ** 6
for i in range(min(a), max(a) + 1):
    cost = 0
    for j in a:
        cost += (i - j) ** 2
    ans = min(ans, cost)
print(ans)

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

void solve(long long K)
{
    cout << (K % 2 == 1 ? (K * K - 1) / 4 : K * K / 4) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long K;
    scanf("%lld", &K);
    solve(K);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
int main(void)
{
    int N;
    cin >> N;
    vector<int> a;
    for (int i = 0; i < N - 1; i++)
    {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    int *tb;
    tb = new int[N];
    fill(tb, tb + N, 0);
    for (int i = 0; i < N - 1; i++)
    {
        tb[a[i] - 1]++;
    }
    for (int i = 0; i < N; i++)
    {
        cout << tb[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4992
use proconio::input;
use proconio::marker::Chars;
use std::collections::HashSet;
use std::iter::Iterator;

fn main() {
    input! {
    n: u32,
    m: u32,
    x: u32,
    c_a : [[u32;m+1];n],
    }

    let mut sum = 0;
    for i in 0..2u32.pow(n) {
        let mut sum_vec = vec![0; m as usize];
        let mut sum_m = 0;
        for op in 0..n {
            if i >> op & 1 == 1 {
                for (i, v) in c_a[op as usize].iter().enumerate() {
                    if i == 0 {
                        sum_m += v;
                    } else {
                        sum_vec[i - 1] += v;
                    }
                }
            }
        }


        if sum_vec.iter().all(|y| *y >= x) {
            if sum == 0 {
                sum = sum_m;
            }else{
                sum = std::cmp::min(sum, sum_m);
            }
        }

    }

    if sum == 0  {
        println!("-1");
    }else{
        println!("{}", sum);
    }

}


Measured memory_bytes: 2140
import java.math.BigInteger;
import java.util.Scanner;
class Main {
	long[][] dp;
	
	public static void main(String args[]){
		Main app = new Main();
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] number = new int[n];
		for(int i=0;i<n;i++){
			number[i] = scan.nextInt();
		}
		app.dp = new long[n][21];
		System.out.println(app.exec(number,n));
	}
	
	public long exec(int[] num,int n){
		for(int i=0;i<n;i++){
			for(int j=0;j<20;j++){
				dp[i][j] = 0;
			}
		}
		dp[0][num[0]]++;
		for(int i=0;i<n-2;i++){
			for(int j=0;j<=20;j++){
				if(dp[i][j]>0){
					if(j+num[i+1]<=20){
						dp[i+1][j+num[i+1]]+=dp[i][j];
					}
					if(j-num[i+1]>=0){
						dp[i+1][j-num[i+1]]+=dp[i][j];
					}
				}
			}
		}
		return dp[n-2][num[n-1]];
	}
}

Measured memory_bytes: 18148
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    cout << fixed << setprecision(10);
    
    int r; cin >> r;
    cout << 3*r*r << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int member_num,quorum;
int list[100];

int main(void) {
	int i,j;
	int date_num,date;
	int max_date,max_num;
	while(1) {
		scanf("%d%d",&member_num,&quorum);
		if(member_num==0 && quorum==0)break;
		for(i=0;i<100;i++)list[i]=0;
		for(i=0;i<member_num;i++) {
			scanf("%d",&date_num);
			for(j=0;j<date_num;j++) {
				scanf("%d",&date);
				list[date-1]++;
			}
		}
		max_date=0;max_num=0;
		for(i=0;i<100;i++) {
			if(list[i]>max_num) {
				max_num=list[i];
				max_date=i;
			}
		}
		printf("%d\n",(max_num>=quorum)?(max_date+1):0);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
using pii = pair<int,int>;
int n;
const int o = 32768;
vector<int> f, G[100005], H[100005];
int sz[100005][2];
int num_scc, dfs_clk, dt[100005], scc[100005];
pii P[20005];
int lf[20005];

void add_edge(int s, int e){
    G[s].emplace_back(e);
    H[e].emplace_back(s);
}

void init_seg_edges(int now, int s, int e){
    //cout << "ise(" << now << "," << s << "," << e << ")\n";
    if(s == e){
        lf[s] = now;
        return;
    }
    int m = s + e >> 1;
    add_edge(now, now*2);
    add_edge(now, now*2+1);
    init_seg_edges(now*2, s, m);
    init_seg_edges(now*2+1, m+1, e);
}

void upd(int now, int s, int e, int l, int r, int f){
    if(s > e || r < s || l > e) return;
    if(l <= s && e <= r){
        add_edge(f, now);
        return;
    }
    int m = s + e >> 1;
    upd(now*2, s, m, l, r, f);
    upd(now*2+1, m+1, e, l, r, f);
}

void dfs(int x){
    dt[x] = ++dfs_clk;
    for(int u : G[x]){
        if(!dt[u]) dfs(u);
    }
    f.push_back(x);
}

void dcp(int x){
    for(int u : H[x]){
        if(!scc[u]){
            scc[u] = scc[x];
            dcp(u);
        }
    }
}

void make_scc(){
    int N = 2*o + 2*n;
    fill(dt + 1, dt + N + 1, 0);
    fill(scc + 1, scc + N + 1, 0);
    f.clear(); num_scc = dfs_clk = 0;

    for(int i = 1; i <= N; i++){
        if(!dt[i]) dfs(i);
    }
    for(int i = N; i--;){
        if(!scc[f[i]]){ 
            scc[f[i]] = ++num_scc;
            dcp(f[i]);
        }
    }
}

bool pro(int d){
    //cout << "pro(" << d << ")\n";
    for(int i = 1; i <= 2*o + 2*n; i++){
        G[i].resize(sz[i][0]);
        H[i].resize(sz[i][1]);
    }
    for(int i = 1; i <= 2*n; i++){
        int L = upper_bound(P+1, P+2*n+1, pii(P[i].va - d, INT_MAX)) - P,
            R = lower_bound(P+1, P+2*n+1, pii(P[i].va + d, INT_MIN)) - P - 1;
        //cout << "itv(" << i << ") = [" << L << "," << R << "]\n";
        upd(1, 1, 2*n, L, i-1, 2*o + i);
        upd(1, 1, 2*n, i+1, R, 2*o + i);
    }
    make_scc();
    for(int i = 1; i <= 2*n; i++){
        if(scc[ lf[i] ] == scc[ 2*o + i ]){
            return false;
        }
    }
    return true;
}

int lst[10005];
//pos(x) == x + o + o, neg(x) == x + o - 1
int main(){
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> P[2*i-1].va >> P[2*i].va;
        P[2*i-1].vb = P[2*i].vb = i;
    }
    //cout << "Flag0\n";
    sort(P+1, P+2*n+1);
    init_seg_edges(1, 1, 2*n);
    //cout << "Flag1\n";
    for(int i = 1; i <= 2*n; i++){
        if(lst[P[i].vb]){
            int j = lst[P[i].vb];
            add_edge(lf[i], 2*o + j);
            add_edge(lf[j], 2*o + i);
            add_edge(2*o + i, lf[j]);
            add_edge(2*o + j, lf[i]);
        }else{
            lst[P[i].vb] = i;
        }
    }
    //cout << "Flag2\n";
    for(int i = 1; i <= 2*o + 2*n; i++){
        sz[i][0] = G[i].size();
        sz[i][1] = H[i].size();
    }
    //cout << "Flag3\n";
    int lo = 0, mi, hi = 1e9;
    while(lo < hi){
        mi = lo + hi + 1 >> 1;
        if(pro(mi)) lo = mi;
        else hi = mi - 1;
    }
    cout << lo << '\n';
}

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = sc.nextInt();
        }

        int ans = 0;
        Arrays.sort(a);
        for (int i = 0; i < k; ++i) {
            ans += a[n - i - 1];
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_map>

using namespace std;

void solve() {
    string str; cin >> str;
    sort(str.begin(), str.end());
    string spl[4];
    for(int i = 0; i < 4; i++){
        spl[i] = str.substr(i,1);
    }
    if(spl[0] == spl[1] && spl[2] == spl[3] && spl[0] != spl[3]){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main() {
    solve();
    return 0;
}

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

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

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

int main()
{
    long long int l,r,c,i,m=2019,j;

    cin>>l>>r;
    if((l+2020)<r)
    {
        r=l+2020;
    }

    for(j=l;j<r;j++)
    {

    for(i=l+1;i<=r;i++)
    {
    c=((j*i)%2019);

    if(c<m)
        m=c;

    }
    }
    cout<<m<<endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int n, m, q; cin >> n >> m >> q;
    int table[501][501] = {0};
    while (m--) {
        int l, r; cin >> l >> r;
        table[l][r]++;
    }
    rrep(i, 1, 501) rep(j, 501) table[i][j] += table[i - 1][j];
    rep(i, 501) rrep(j, 1, 501) table[i][j] += table[i][j - 1];
    while (q--) {
        int p, qq; cin >> qq >> p;
        cout << table[p][p] - table[p][qq - 1] - table[qq - 1][p] + table[qq - 1][qq - 1] << endl;
    }
}


Measured memory_bytes: 1920
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

using pdd = pair<double, double>;
int W,H;

bool check(int a, int b){
	if(a==0) return true;
	if(a==b) return true;
	return false;
}

void foo(int &a, int &b){
	if(a==0&&b==0) a++;
	if(a==0&&b==2*H) b--;
	if(a==2*W&&b==2*H) a--;
	if(a==2*W&&b==0) b++;
}

int func(int a, int b){
	if(b==0){
		return a;
	}
	if(a==W){
		return W+b;
	}
	if(b==H){
		return H+W+(W-a);
	}
	return W+H+W+(H-b);
}

bool mainmain(){
	int n;
	cin>>W>>H;
	cin>>n;
	bool ok = true;
	vector<pii> x;
	rep(i,n){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		if((check(a, W) || check(b, H)) && (check(c, W) || check(d, H))){
			int aa = func(a,b);
			int bb = func(c,d);
			x.PB(minmax(aa,bb));
		}
	}
	sort(ALL(x));
	stack<pii> st;
	rep(i,x.size()){
		while(st.size()){
			pii top = st.top();
			if(top.se < x[i].fi){
				st.pop();
				continue;
			}
			if(top.fi < x[i].fi && x[i].fi < top.se && top.se < x[i].se){
				return false;
			}
			break;
		}
		st.push(x[i]);
	}
	return true;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    cout<<(mainmain()?"YES":"NO")<<endl;
}

Measured memory_bytes: 1524
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))

int main(){
  long long w,h;
  cin >> w >> h;
  vector<long long> p(w),q(h);
  for(int i=0;i<w;i++){
    cin >> p[i];
  }
  for(int i=0;i<h;i++){
    cin >> q[i];
  }
  sort(p.begin(),p.end());
  sort(q.begin(),q.end());
  int pNow=0,qNow=0;
  long long ans=0;
  while(1){
    if(pNow>=w){
      for(;qNow<h;qNow++){
        ans+=q[qNow];
      }
      break;
    }
    if(qNow>=h){
      for(;pNow<w;pNow++){
        ans+=p[pNow];
      }
      break;
    }
    if(p[pNow]<q[qNow]){
      ans+=(h+1-qNow)*p[pNow];
      pNow++;
    }else{
      ans+=(w+1-pNow)*q[qNow];
      qNow++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

    ll N , K ;
    cin >> N >> K ;
    cout << (N%K ? 1:0) << endl; 


    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

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

	printf("%lld\n", abs(N*(LL)M - 2 * (LL)(N + M - 2)));

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

int main() {
    int n;
    cin >> n;
    bool flag = false;
    vector<int> d1(n), d2(n);
    for (int i = 0; i < n; i++) {
        cin >> d1[i] >> d2[i];
    }
    for (int i = 0; i < n - 2; i++) {
        if (d1[i] == d2[i] and d1[i + 1] == d2[i + 1] and
            d1[i + 2] == d2[i + 2]) {
            flag = true;
        }
    }
    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vb   = vector<bool>;
using vvb  = vector<vb>;
using pii  = pair<int,int>;
using vpii = vector<pii>;

int main() {
    string S, T; cin >> S >> T;
    int ans = 1000000;
    for (int i = 0; i < S.length()-T.length()+1; i++) {
        int tmp = 0;
        for (int j = 0; j < T.length(); j++) {
            if(S.at(i+j) != T.at(j)) {
                tmp++;
            }
        }
        if (ans>tmp ) ans = tmp;
    }
    cout << ans;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<int> p(A), q(B), r(C);
  rep(i,A) cin >> p[i];
  rep(i,B) cin >> q[i];
  rep(i,C) cin >> r[i];
  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());

  vector<int> V;
  rep(i,X) V.push_back(p[i]);
  rep(i,Y) V.push_back(q[i]);
  rep(i,C) V.push_back(r[i]);
  sort(V.rbegin(), V.rend());
  ll ans = 0;
  rep(i, X+Y) ans += V[i];
  cout << ans << endl;
}


Measured memory_bytes: 6448
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define forn(i,n) for(i=0;i<n;++i)
#define for1(i,n) for(i=1;i<=n;++i)
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fill(x,b) memset((x),b,sizeof((x)))
#define fill2D(x,r,c,b) memset((x),b, sizeof(x[0][0]) * r * c)
#define whatIs(a) cout<<#a<<" is : "<<a<<endl

typedef long long ll;
typedef vector<ll> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<vs> vvs;

const ll mod = 1e9 + 7;
clock_t t1, t2;

ll binPow(ll a, ll b) {ll x = 1, y = a; while (b) {if (b & 1)x = (x * y) % mod; y = (y * y) % mod; b >>= 1;} return x % mod;}

ll inverserEuler(ll n) {return binPow(n, mod - 2);}

ll C(ll k, ll n) {vll f(n + 1, 1); for (ll i = 2; i <= n; i++)f[i] = (f[i - 1] * i) % mod; return (f[n] * ((inverserEuler(f[k]) * inverserEuler(f[n - k])) % mod) % mod) % mod;}

/* Extend Euclid: ax + by = c;
ll x, y;

void extendEuclid(ll a, ll b){if(b == 0){x = 1;y = 0;return;}extendEuclid(b,a%b);ll x1 = y, y1 = x - (a/b) * y;x = x1;y = y1;}
// nghiem : x + (b/d)*k, y - (a/d) * k;
*/
/*--------------------------------------------------------------------------------------------------*/

void trunghieu()
{
	int n;
	cin>>n;
	vi a(n);
	int i,j;
	forn(i,n)
		cin>>a[i];
	auto b = a;
	sort(all(b));
	forn(i,n){
		for(j = i;j<n;j++){
			auto c = a;
			swap(c[i],c[j]);
			if(c == b){
				cout<<"YES";
				return;
			}
		}
	}
	cout<<"NO";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w",stdout);
#endif
    trunghieu();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    long n;
    long a[10000];
    int ans = 0;
    cin >> n;
    for (int i = 0; i < n ; ++i) {
        cin >> a[i];
        int check = 0;
        for (int j = 1; j*j <= a[i] ; ++j) {
            if( a[i] % j == 0) check++;
        }
        if(check == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1236
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}


int main(){
	FIO
	
	int w, h;
	while(cin >> w >> h){
		if(w == 0 && h == 0)break;
		for(int i = 0; i < w; i++){
			for(int j = 0; j < h; j++){
				if (i % 2 == j % 2)cout << '#';
				else cout << '.';
			}
			cout << '\n';
		}
		cout << '\n';
	}
	return 0;
}



Measured memory_bytes: 3216
main = do
  [n, a, b, c, d] <- map read . words <$> getLine
  s <- getLine
  let sraw = drop (a-1) $ take (max c d) s
  let srawshort = drop (b-2) $ take (1 + min c d) s
  if doublehash sraw then putStrLn "No"
    else if c < d || tripledot srawshort then putStrLn "Yes"
      else putStrLn "No"
  
doublehash (x:y:xs)
  | x == '#' && y == '#' = True
  | otherwise = doublehash (y:xs)
doublehash _ = False

tripledot (x:y:z:xs)
  | x == '.' && y == '.' && z == '.' = True
  | otherwise = tripledot (y:z:xs)
tripledot _ = False


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

long long sumN(long long N){
    long long ans = 0;
    for(long long i = N; i>=0;i--){
        ans += i;
    }
    return ans;
}

int main(){
    long long a,b;
    long long diff;
    cin >> a >> b;
    diff = b - a;
    cout << sumN(diff - 1) - a;

    return 0;
}


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

// #pragma comment(linker, "/STACK:16777216")

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define int ll
#define pii pair<int, int>
const int SZ = 3e5 + 4;
const double EPS = 1e-7;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

struct custom_hash {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return x + FIXED_RANDOM;
    }
};

int n;
int a[SZ];

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

void solve() {
    vector<vector<int>> suf(n, vector<int>(60));
    for (int i = 0; i < n; ++i) {
        int j = 0;
        int tmp = a[i];
        while (tmp > 0) {
            if (tmp % 2) {
                ++suf[i][j];
            }
            tmp /= 2;
            ++j;
        }
    }
    for (int i = n - 2; i >= 0; --i) {
        for (int j = 0; j < 60; ++j) {
            suf[i][j] += suf[i + 1][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n - 1; ++i) {
        bitset<60> b(a[i]);
        for (int j = 0; j < 60; ++j) {
            if (b[j]) {
                ans += ((1ll << j) % mod) * ((n - i - 1 - suf[i + 1][j]) % mod);
                ans %= mod;
            } else {
                ans += ((1ll << j) % mod) * (suf[i + 1][j] % mod);
                ans %= mod;
            }
        }
    }
    cout << ans;
}

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

    read();
    solve();

    return 0;
}

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

int main()
{
  int n, i, j, k, xlen, ylen;
  char x[1003], y[1003];
  int c[1001][1001];
  scanf("%d\n", &n);
  for (k=0; k<n; k++) {
    fgets(x, 1002, stdin);
    xlen = strlen(x);
    if (x[xlen-1]=='\n') x[xlen-- -1]='\0';
    fgets(y, 1002, stdin);
    ylen = strlen(y);
    if (y[ylen-1]=='\n') y[ylen-- -1]='\0';

    c[0][0]=0;
    
    for (i=0; i<xlen; i++) {
      for (j=0; j<ylen; j++) {
        if (x[i]==y[j]) 
          c[i+1][j+1] = c[i][j]+1;
        else
          c[i+1][j+1] = c[i][j+1] > c[i+1][j] ? c[i][j+1] : c[i+1][j];
      }
    }
    printf("%d\n", c[xlen][ylen]);
  }
  return 0;
}


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


int main()
{
    int K, A, B;
    cin >> K;
    cin >> A >> B;

    int x = 1;

    while(true){
        int d = K * x;

        if(A <= d && d <= B){
            cout << "OK";
            return 0;
        } else if (d > B){
            break;
        }

        ++x;
    }

    cout << "NG";

    return 0;
}


Measured memory_bytes: 3624
a,b,n=map(int,input().split())
l=a//b
if b==1:
  print(0)
  exit()
if n>=b-1:
  if a%b>0:
    print(a-l-1)
  else:
    print(a-1)
else:
  print(int((a*n)//b)-a*(n//b))

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }

vector<ll> v;

void enum_div(ll n)//nの約数を列挙
{
	for(ll i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			v.push_back(i);
			if(i!=1 && i*i!=n)
			{
				v.push_back(n/i);
			}
		}
	}
}


int main(void){
  ll n,m; cin >> n >> m;
  enum_div(m);
  ll ans = 1;
  v.PB(m);

  for(auto x: v){
    if(m/x>=n) chmax(ans,x);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a, b;
std::string s;
std::vector<std::string> vec;
int ans = 0;
int main() {
    cin >> a >> b;
    for (int i = a; i <= b; i++) {
        s = std::to_string(i);
        std::string s1 = s.substr(0, 2);
        std::string s2 = s.substr(s.size()-2, 2);
        std::reverse(s2.begin(), s2.end());
        if (s1 == s2) {
            ans++;
        }
    }
    cout << ans << endl;
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string n;
	cin >> n;
	rep(i, 0, n.size()) {
		if(n[i] == '1') cout << '9';
		else cout << '1';
	}
	cout << endl;
}


Measured memory_bytes: 256
A=input()
B=input()
C=input()
i,j,k=0,0,0
now="a"

while 1:
    if now=="a":
        if i<len(A):
            now=A[i]
            i += 1
        else:
            break
    elif now=="b":
        if j<len(B):
            now=B[j]
            j += 1
        else:
            break
    else:
        if k<len(C):
            now=C[k]
            k += 1
        else:
            break
print(now.upper())

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>

using namespace std;

int main() {
    string str;
    
    vector<int> v;
    while (getline(cin, str)) {
        if (str[0] == '0') {
            break;
        }
        
        int sum = 0;
        for (int i = 0; i < str.size(); i++) {
            //sum += atoi(&str[i]);
            sum += str[i] - '0';
        }
        v.push_back(sum);
    }

    for (int j = 0; j < v.size(); j++) {
        cout << v[j] << endl;
    }

    return 0;
}

Measured memory_bytes: 3116
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
using namespace std;
typedef long long ll;

const int INF = 1001001001;
const int MOD = 1e9+7;

int main() {
    int n; cin >> n;
    ll k; cin >> k;
    vector<int> a(n), f(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.begin(), f.end());
    reverse(f.begin(), f.end());

    ll left = -1, right = 1e12;
    while (left + 1 < right) {
        ll mid = (left+right)/2;
        bool ok = [&]  {
            ll cnt = 0;
            for (int i = 0; i < n; i++) {
                cnt += max(a[i]-mid/f[i], 0ll);
            }
            return cnt <= k;
        }();

        if(ok) right = mid;
        else left = mid;
    }
    cout << right << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#define TRUE 1
#define FALSE 0

int main(void){
  int a,b,k;
  int i;
  
  scanf("%d %d %d",&a,&b,&k);
  
  for( i=a; i<=b; i++){
    ( a+k <= i && i <= b-k) ? : printf("%d\n",i);
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){

	int card[4][13];
	int B,i,j,k;
	char A;
	int n;

	for (i = 0; i < 4; i++){
		for (j = 0; j < 13; j++){
			card[i][j] = 0;
		}
	}
	scanf("%d", &n);
	for (k = 0; k < (2*n); k++){
		scanf("%c %d", &A, &B);
		if (A == 'S'){ card[0][B-1] = 1; }
		else if (A == 'H'){ card[1][B-1] = 1; }
		else if (A == 'C'){ card[2][B-1] = 1; }
		else if (A == 'D'){ card[3][B-1] = 1; }
	}

		for (i = 0; i < 4; i++){
			for (j = 0; j < 13; j++){
				if (card[i][j] == 0){
					if (i == 0){ printf("S %d\n", j + 1); }
					else if (i == 1){ printf("H %d\n", j + 1); }
					else if (i == 2){ printf("C %d\n", j + 1); }
					else if (i == 3){ printf("D %d\n", j + 1); }
				}
			}
		}
	
	return 0;

}


Measured memory_bytes: 2140
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

const long long MOD = 1000000007; 
const long long INF = 1LL << 50;
// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int d, g;
int p[15], c[15], tmp[15];
int ans = INF;

void dfs(int i, int sum, int cnt, int u) {
	if (i == d) {
		if (sum >= g) {
			ans = min(ans, cnt);
		}
		else {
			if (u != -1) {
				int tmp2 = (g - sum + (u + 1) * 100 - 1) / ((u + 1) * 100);
				if (tmp2 < p[u]) {
					ans = min(ans, cnt + tmp2);
				}
			}
		}
	}
	else {
		dfs(i + 1, sum + tmp[i], cnt + p[i], u);
		dfs(i + 1, sum, cnt, i);
	}
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> d >> g;
	rep(i, d) {
		cin >> p[i] >> c[i];
		tmp[i] = 100 * (i + 1)*p[i] + c[i];
	}
	dfs(0, 0, 0, -1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = sorted(list(map(int,input().split())))
a.append(0)
cnt = 1
ans = 0
for i in range(n):
  if a[i] != a[i+1]:
    if cnt == a[i]:
      cnt = 1
    else:
      if cnt > a[i]:
        ans += cnt - a[i]
      else:
        ans += cnt
      cnt = 1
  else:
    cnt += 1
print(ans)

Measured memory_bytes: 14268