akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

var MOD = 998244353

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func exGcd(a, b int) (int, int, int) {
	r0 := a
	x0 := 1
	y0 := 0
	r1 := b
	x1 := 0
	y1 := 1
	for r1 != 0 {
		// Calc
		r2 := r0 % r1
		q := r0 / r1 // quotient
		x2 := x0 - q*x1
		y2 := y0 - q*y1

		// Update
		r0 = r1
		r1 = r2
		x0 = x1
		x1 = x2
		y0 = y1
		y1 = y2
	}

	return r0, x0, y0
}

func prepare(fac []int, fInv []int, inv []int, upper int) {
	fac[0] = 1
	fac[1] = 1
	fInv[0] = 1
	fInv[1] = 1
	inv[1] = 1
	for i := 2; i <= upper; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		fInv[i] = fInv[i-1] * inv[i] % MOD
	}
}

func calcCombination(fac []int, fInv []int, n, a int) int {
	if n < a {
		return 0
	}
	if n < 0 || a < 0 {
		return 0
	}
	return fac[n] * (fInv[a] * fInv[n-a] % MOD) % MOD
}

func main() {
	var N, A, B, K int
	fmt.Scanf("%d %d %d %d", &N, &A, &B, &K)

	ans := 0

	// Calc NCx * NCy
	// nCa = (n)!/(n-a)!(a)! = (n!)(a!)^-1((n-a)!)^-1
	// n >= a   -->   Prepare (n!), (a!)^-1
	fac := make([]int, N+1)
	fInv := make([]int, N+1)
	inv := make([]int, N+1)
	prepare(fac, fInv, inv, N)

	// xA + yB = K
	for x := 0; x <= N; x++ {
		r := K - x*A
		if r%B != 0 {
			continue
		}
		y := r / B
		if y > N {
			continue
		}
		ans += (calcCombination(fac, fInv, N, x) * calcCombination(fac, fInv, N, y) % MOD)
		ans %= MOD
	}

	fmt.Println(ans)
}


Measured memory_bytes: 7808
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
ll mod = 1000000007,MAX = 200000,dp[3010][2] = {},ans = 0;
pair<ll,ll> p[3010];
ll inv[200010],fact[200010],fi[200010];
void inverse(){
	int i;
	inv[1] = 1;
	for(i=2;i<=MAX;i++){
		inv[i] = mod - (mod/i)*inv[mod%i]%mod;
	}
	fact[0] = fi[0] = 1;
	for(i=1;i<=MAX;i++){
		fact[i] = fact[i-1]*i%mod;
		fi[i] = fi[i-1]*inv[i]%mod;
	}
}

ll comb(ll n,ll k){
	if(n<0 || k<0 || n<k){
		return 0;
	}else{
		return fact[n]*fi[k]%mod*fi[n-k]%mod;
	}
}

int main(){
	ll h,w,n,i,j;
	cin >> h >> w >> n;
	h--; w--;
	for(i=0;i<n;i++){
		ll r,c;
		cin >> r >> c;
		r--; c--;
		p[i] = {r,c};
	}
	inverse();
	p[n] = {0,0};
	sort(p,p+n+1);
	dp[0][0] = 1;
	for(i=1;i<=n;i++){
		for(j=0;j<i;j++){
			if(p[j].first<=p[i].first && p[j].second<=p[i].second){
				ll x = p[i].first - p[j].first,y = p[i].second - p[j].second;
				(dp[i][0] += comb(x+y,y)*dp[j][1]) %= mod;
				(dp[i][1] += comb(x+y,y)*dp[j][0]) %= mod;
			}
		}
	}
	ll sum = 0;
	for(i=1;i<=n;i++){
		ll x = h - p[i].first, y = w - p[i].second;
		(sum += comb(x+y,y)*((dp[i][1] - dp[i][0] + mod)%mod)) %= mod;
	}
	ans = (comb(h+w,h) - sum + mod)%mod;
	cout << ans << endl;
}

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

int main() {
  int N;
  string Ans="No";
  cin>>N;
  
  for (int i=1;i<10;i++){
      for (int j=1;j<10;j++){
        if(i*j==N){Ans="Yes";break;}
      }
    if(Ans=="Yes"){break;}
  }
  cout<<Ans<<endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <deque>
#include <cmath>

using namespace std;

const int maxN=1e5+2;
const int INF=(1<<30);

int n,k;
int v[maxN];

int dp[maxN];

int main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>v[i];
    }

    //Brut
    for(int i=2;i<=n;i++){
        int val=INF;
        for(int j=max(1,i-k);j<i;j++){
            val=min(val,dp[j]+abs(v[i]-v[j]));
        }
        dp[i]=val;
    }

    cout<<dp[n];

    return 0;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
INF = 10**18

minDist = [[INF] * N for _ in range(N)]
for i in range(N):
    minDist[i][i] = 0

edges = []
for _ in range(M):
    fr, to, d = map(int, input().split())
    fr -= 1
    to -= 1
    edges.append((fr, to, d))
    minDist[fr][to] = d
    minDist[to][fr] = d

for k in range(N):
    for i in range(N):
        for j in range(N):
            d = minDist[i][k] + minDist[k][j]
            if minDist[i][j] > d:
                minDist[i][j] = d

ans = 0
for fr, to, d in edges:
    if minDist[fr][to] < d:
        ans += 1
print(ans)


Measured memory_bytes: 41836
#include <stdio.h>

#define N 40

int pre[N],in[N],po[N];
int n,mark=0;
int j = 0;

void rec(int l, int r) {
	int i;
	int c,m;

	if (l >= r) return;
	c = pre[mark++];
	for (i = 0; i < n;i++) {
		if (in[i] == c) {
			m = i;
			break;
		}
	}

	rec(l, m);
	rec(m+1, r);
	po[j++] = c;
}

int main() {
	int i;

	scanf("%d",&n);
	for (i = 0;i < n;i++) scanf("%d",&pre[i]);
	for (i = 0;i < n;i++) scanf("%d",&in[i]);

	rec(0,n);
	for (i = 0;i < n;i++) {
		if (i) printf(" ");
		printf("%d",po[i]);
	}
	printf("\n");

	return 0;
}

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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        long a = in.nl(), b = in.nl(), c = in.nl();
        if(c<=a+b){
            out.println("No");
        }else{
            if((c-a-b)*(c-a-b)>4*a*b)out.println("Yes");
            else out.println("No");
        }
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 22996
import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())
G = [[] for i in range(N)]
indegree = [0 for i in range(N)]

for i in range(M):
  x,y = map(int,readline().split())
  G[x - 1].append(y - 1)
  indegree[y - 1] += 1
  
stack = []
for i in range(len(indegree)):
  if indegree[i] == 0:
    stack.append(i)
    
cnt = -1
while stack:
  cnt += 1
  newstack = []
  while stack:
    v = stack.pop()
    for child in G[v]:
      indegree[child] -= 1
      if indegree[child] == 0:
        newstack.append(child)
  stack = newstack

print(cnt)

Measured memory_bytes: 18736
#include <iostream>
#include <cstdio>
#include <algorithm>

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

using namespace std;

int main(){
    int N;
    while(cin>>N,N){
        int prizes[10000];
        int sum = 0;
        rep(i,N){
            scanf("%d",prizes+i);
            if(prizes[i]){
                sum++;
            }
        }

        int ans = 1<<20;
        rep(i,N){
            if(prizes[i]>=2){
                int cou = sum + 2 - 1;
                ans = min(cou,ans);
            }
        }
        if(ans==1<<20){
            puts("NA");
        }else{
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1284
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int main(){
    int n , T , t , last = 0 , ans = 0;
    scanf("%d%d",&n,&T);
    rep(i,0,n) {
        scanf("%d",&t);
        ans += min(T , t - last);
        last = t;
    }
    ans += T;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#ABC143-D Triangles
from bisect import bisect_left, bisect_right
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        ans += max(bisect_right(L, L[i]+L[j]-1) - j - 1, 0)
        #print([i,j, 100, L[i],L[j], 100, bisect_right(L, L[i]+L[j]-1)-j-1])
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

using VS = vector<string>;
using PII = pair<int,int>;
#define mp(a,b) make_pair(a,b)

int bfs(int H, int W, VS &S){
	int dx[4]={0,-1,0,1}, dy[4]={-1,0,1,0};
	vvi dist(H+1,vi(W+1, -1));
	dist[1][1] = 0;
	queue<PII> q;
	q.push(mp(1,1));
	while(!q.empty()){
		int i,j; tie(i,j)= q.front(); q.pop();
		if(S[i][j] == '_') continue;
		S[i][j] = '_';
		if(i==H && j==W) break;
		rpz(k,4){
			int y=i+dy[k], x=j+dx[k];
			if(S[y][x] != '.') continue;
			dist[y][x] = dist[i][j] + 1;
			q.push(mp(y,x));
		}
	}
	return dist[H][W];
}

int solve(int H, int W, VS &S){
	int dist = bfs(H, W, S);
	int block = 0;
	rp(i,1,H+1) rp(j,1,W+1) if(S[i][j] == '#') block++;
	return dist<0? -1: H*W - block - dist - 1;
}

int main(){
	int H,W; cin>>H>>W;
	VS S(H+2);
	rpz(j, W+2) S[0] += "#";
	rpz(j, W+2) S[H+1] += "#";
	rp(i, 1, H+1){
		string s; cin>>s;
		S[i] = "#" + s + "#";
	}
	ote(solve(H, W, S));
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pp;

int N;
const int MAX_N = 100010;

int a[MAX_N];
pp s[MAX_N];
ll ans[MAX_N];

bool cmp(pp x,pp y){
	return x.first!=y.first?x.first>y.first:x.second>y.second;
}

int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		scanf("%d",&a[i]);
		s[i]=pp(a[i],i);
	}

	sort(s+1,s+N+1,cmp);

	s[N+1]=pp(0,0);

	ll id=N;
	for(ll i=1,j=1;i<=N;i=j){
		while(s[i].first==s[j].first)j++;
		id=min(id,s[j-1].second);
		ans[id]+=(j-1)*(s[j-1].first-s[j].first);
	}

	for(int i=1;i<=N;i++){
		printf("%lld\n",ans[i]);
	}
	return 0;
}


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

int main() {
  string s; cin >> s;
  string ans;
  rep(i,s.size()){
    if(i==0 || i%2==0) ans += s.at(i);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
//#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
 
 
int main(){
   double ans=0;
   int n;
   cin>>n;
   
   
   vector<int> x(n),y(n);
   rep(i,n)cin>>x.at(i)>>y.at(i);
   
  for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
          double dx=(x.at(i)-x.at(j));
          double dy=(y.at(i)-y.at(j));
          ans+=sqrt(dx*dx+dy*dy);
      }
  }
  cout << fixed << setprecision(10);
   cout<<ans*2/n<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}
 
int main() {
    int N; cin >> N;
    vector<int> A(N + 1), B(N + 1);
    repp(i, 1, N) cin >> A[i];
    for(int i = N; i > 0; --i) {
        int sumi = 0;
        for(int j = 2; i * j <= N; ++j) {
            sumi += B[i * j];
        }
        B[i] = (2 + A[i] - (sumi % 2)) % 2;
    }
    vector<int> ans;
    for(int i = 1; i <= N; ++i) {
        if(B[i]) ans.push_back(i);
    }
    cout << sz(ans) << "\n";
    for(auto &x : ans) cout << x << " ";
    cout << "\n";
}


Measured memory_bytes: 3064
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int N, K;
    scan(N, K);
    auto a = readln.split.to!(int[]);

    a.sort();

    bool check(int k) {
        if (a[k] >= K) return true;
        auto dp = new bool[][](N + 1, K + 1);
        dp[0][0] = 1;
        foreach (i ; 1 .. N + 1) {
            foreach (j ; 0 .. K + 1) {
                dp[i][j] = dp[i - 1][j];
                if (i - 1 == k) continue;
                if (j - a[i - 1] >= 0) {
                    dp[i][j] |= dp[i - 1][j - a[i - 1]];
                }
            }
        }

        foreach (i ; max(0, K - a[k]) .. K) {
            if (dp[N][i]) {
                return true;
            }
        }

        return false;
    }

    int ng = -1, ok = N;
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        (check(mid) ? ok : ng) = mid;
    }
    auto ans = ok;
    writeln(ans);
}






void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


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

namespace Contest20191106
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int t = int.Parse(s[2]);
            Console.WriteLine(t / a * b);


        }
    }
}


Measured memory_bytes: 13140
#define E(n,e)else if(!(k&n))for(x=0;x<5;x++)puts(k&1<<(e+x)?"1":"2");
#define K(n)||(k&n)==n
i,k;main(x){for(;;i++){scanf("%d",&x);if(!x)return 0;k+=1<<(5*x+i);if(i==4){if((k&992&&k&31744&&k&1015808)K(992)K(31744)K(1015808))for(x=5;x--;)puts("3");E(992,10)E(31744,15)E(1015808,5)k=0,i=-1;}}}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;long long a,b,c[200005],n,d,ans,x[200005],y[200005],l,k;struct node{long long x,y;}w[200005];inline bool cmp(node x,node y){return x.x<y.x;}int main(){scanf("%lld%lld%lld",&n,&d,&a);d*=2;for(int i=1;i<=n;++i){scanf("%lld%lld",&w[i].x,&w[i].y);w[i].y=(w[i].y+a-1)/a;}sort(w+1,w+n+1,cmp);l=1;for(int i=1;i<=n;++i){while(l<i&&w[i].x-w[l].x>d)k-=c[l++];c[i]=w[i].y-k;if(c[i]<0)c[i]=0;ans+=c[i];k+=c[i];}printf("%lld",ans);}

Measured memory_bytes: 5888
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    food = []
    sc = 0
    for _ in range(N):
        a,b = map(int,input().split())
        sc -= b
        food.append(a+b)
    
    food.sort(reverse= True)
    tf = sum(food[::2])
    print(tf+sc)

if __name__ == "__main__":
    main()


Measured memory_bytes: 7500
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        String [][] a = new String [H+2][W+2];
        for (int i = 0 ; i < H + 2 ; i++ ) {
            for (int j = 0 ; j < W + 2 ; j++ ) {
                a[i][j] = "#";
            }
        }
        for (int i = 1 ; i <= H ; i++ ) {
            String s = sc.next();
            for (int j = 1 ; j <= W ; j++) {
                a[i][j] = String.valueOf(s.charAt(j - 1));
            }
        }

        for (int i = 0 ; i < H + 2 ; i++ ) {
            for (int j = 0 ; j < W + 2 ; j++ ) {
                System.out.print(a[i][j]);
            }
            System.out.println("");
        }
    }

}

Measured memory_bytes: 28840
#define CIN_ONLY 1
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
const int MOD = 1000000007;
const ld PI = acos(ld(-1));
int fix(ll n) { return (n % MOD + MOD) % MOD; }
int fix(ll n, int MOD) { return (n % MOD + MOD) % MOD; }

int main()
{
  if (CIN_ONLY) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  }
  int a, b, c, ans = 0;
  cin >> a >> b >> c;
  if (c <= a) {
    ans = c + b;
  } else if (c <= a + b) {
    ans = c + b;
  } else {
    ans = a + b + b + 1;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  scanf("%d%d%d",&a,&b,&k);
  for(int i=a;i<min(b+1,a+k);i++){
    printf("%d\n",i);
  }
  for(int i=max(a+k,b-k+1);i<=b;i++){
    printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 256
# D - Not Divisible
from collections import deque
N = int(input())
A = list(map(int,input().split()))
A.sort()
A = deque(A)
B = [0]*(10**6+1)
ans = 0
for _ in range(N):
    x = A.popleft()
    if B[x]==0:
        ans += 1
        B[x] = 2
        tmp = 2*x
        while tmp<=10**6:
            B[tmp] = 1
            tmp += x
    elif B[x]==2:
        B[x] = 1
        ans -= 1
print(ans)

Measured memory_bytes: 34104
def main():
  s = input()
  divisor = 10 ** 9 + 7
  dp = [[0] * 13 for _ in range(len(s) + 1)]
  dp[0][0] = 1
  lut = [i % 13 for i in range(130)]
  list10 = list(range(10))
  list13 = list(range(13))
  for i in range(len(s)):
    dpi = dp[i]
    dpi1 = dp[i + 1]
    if s[i] == '?':
      j10 = 0
      for j in list13:
        dpij = dpi[j]
        for k in list10:
          dpi1[lut[j10 + k]] += dpij
        j10 += 10
    else:
      t = int(s[i])
      for j in list13:
        dpi1[t] += dpi[j]
        t = lut[t + 10]
    for k in list13:
      dpi1[k] %= divisor
  print(dp[len(s)][5])
main()


Measured memory_bytes: 62460
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int A[n];
    REP(i,n){
        cin >> A[i];
    }

    REPR(i,n-1){
        if(A[i] > A[i+1]){
            A[i] --;
        }
    }
    REP(i,n-1){
        if(A[i] > A[i+1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

}

Measured memory_bytes: 1024
from operator import itemgetter
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
flag = True
AB.sort(key = itemgetter(1))
now = 0
for a, b in AB:
    now += a
    if now > b:
        flag = False

print("Yes") if flag else print("No")

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL N,K;
  cin >> N >> K;

  double per = 0;

  FOR(i,1,N+1){
    LL j = i;
    double nn = (double)1 / (double)N;
    while (j <K){
      j *= 2;
      nn /= 2;
    }
    per += nn;
  }
  cout << per << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
tf = []

for _ in range(N):
    A = input()[:-1]
    
    if '.' in A:
        i = A.index('.')
        p = len(A)-i-1
        A = int(A[:i]+A[i+1:])
    else:
        p = 0
        A = int(A)
    
    t, f = 0, 0
    
    while A%2==0:
        A //= 2
        t += 1
    
    while A%5==0:
        A //= 5
        f += 1
    
    tf.append((t-p, f-p))

tf.sort(key=lambda x: x[0])
r_idx = N-1
cnt = defaultdict(int)
ans = 0

for t, f in tf:
    while r_idx>=0 and t+tf[r_idx][0]>=0:
        cnt[tf[r_idx][1]] += 1
        r_idx -= 1
    
    for k, v in cnt.items():
        if f+k>=0:
            ans += v
    
    if 2*t>=0 and 2*f>=0:
        ans -= 1

print(ans//2)

Measured memory_bytes: 94244
#include <iostream>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)
int main() {
	int a, b; cin >> a >> b;
	if (b < 10) a *= 10;
	else if (b < 100) a *= 100;
	else if (b == 100) a *= 1000;

	for (int i = 1; i * 1 < (a + b); i++) {
		if (i * i == (a + b)) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>

using namespace std;

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

    int N;
    cin >> N;
    int *V, *C;
    V = new int[N];
    C = new int[N];
    for (int i = 0; i < N; i++)
    {
        cin >> V[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> C[i];
    }

    int ret = 0;

    for (int i = 0; i < N; i++)
    {
        ret += (*V > *C) ? *V - *C : 0;
        V++;
        C++;
    }

    cout << ret << "\n";

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
int main(void){
    int n,a,b;
    cin>>n>>a>>b;
    int sum=0;
    FOR(i,1,n+1){
        int q=i;
        int c=0;
        while(q>0){
            int d;
            d=q%10;
            c+=d;
            q=q/10;
        }
        if(c>=a && c<=b) sum+=i;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int f[MAX_N]={};
int b[MAX_N]={};
bool dp[MAX_N]={};

int main() {
	string str;
	cin>>str;
	if(str=="BBB"||str=="AAA"){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;
const ll mod = 998244353;
const int DEG = 30;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
static auto faster_iostream = []() {
    std::ios::sync_with_stdio(false);  // turn off sync
    std::cin.tie(nullptr);             // untie in/out streams
    return 0;
}();
ll a[N];
int main(){
	int n;
	while(cin >> n){
		for(int i = 1; i <= n; i++){
			cin >> a[i];
		}
		sort(a + 1, a + 1 + n);
		ll l = a[n / 2], r = a[n / 2 + 1];
		cout << r - l << endl;
	}
	return 0;
} 

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

typedef long long ll;
const int maxn = 50;
int n, a[maxn][maxn];
ll ans, f[maxn][maxn][maxn];

int main() {
    scanf("%d", &n), n <<= 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            scanf("%1d", &a[i][j]);
        }
    }
    memset(f, -1, sizeof(f));
    function<ll(int, int, int)> F = [&](int l, int r, int k) {
        if (l == k || r == k) return ll(l == r);
        if (~f[l][r][k]) return f[l][r][k];
        f[l][r][k] = 0;
        for (int x = l; x < k; x++) {
            for (int y = k + 1; y <= r; y++) if (a[x][y]) {
                for (int p = x; p < k; p++) {
                    for (int q = k + 1; q <= y; q++) {
                        f[l][r][k] += F(l, p, x) * F(p + 1, q - 1, k) * F(q, r, y);
                    }
                }
            }
        }
        return f[l][r][k];
    };
    for (int i = 2; i <= n; i++) {
        if (a[1][i]) ans += F(2, n, i);
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main(void){
	int k,x;
	int i;

	scanf("%d %d",&k,&x);


	for(i=0;i<2*k-1;i++){
		printf("%d ",x - k + i + 1);
	}

	printf("\n");

	return 0;
}

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

int main() {
    int x, y;
    while (1) {
    cin >> x >> y;
        if (x == 0 && y == 0) {
            return 0;
        } else {
            if (x < y) {
                cout << x << " " << y << endl;
            } else if (x > y) {
                cout << y << " " << x << endl;
            } else {
                cout << x << " " << y << endl;
            }
        }
    }
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    string s,t;
    cin >> s >> t;
    int cnt=0;
    rep(i,s.size()){
        if(s[i] != t[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3928
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string s;
    cin >> s;
    int N = SZ(s);
    set<char> ch = {'A', 'T', 'C', 'G'};
    int ans = 0;
    REP(i, N) {
        int cnt = 0;
        REP(j, N) {
            if (i + j >= N) break;
            if (!CONTAIN(ch, s[i + j])) {
                break;
            }
            cnt++;
        }
        chmax(ans, cnt);
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define MOD 1000000007
 
int main(){
    int N; cin >> N;
    long long int sum = 0;
    for(int i=N;i>1;i--) sum += i-1;
  	if(N == 1) cout << 0;
    else cout << sum;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
#define CEIL(A,B) ((A)+(B)-1)/(B)
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll N, M, D;

int main() {
    fastio();
    cin >> N >> M >> D;
    double ans = (D == 0 ? 1.0 : 2.0) * (N - D) * (M - 1);
    ans /= N;
    ans /= N;
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from math import hypot
readline = sys.stdin.readline

N = int(readline())
Points = [tuple(map(int, readline().split())) for _ in range(N)]

inf = 10**9+7
EPS = 1e-8
ans = inf
for i in range(N):
    for j in range(i):
        a = Points[i][0]
        b = Points[i][1]
        c = Points[j][0]
        d = Points[j][1]
        px, py = (a+c)/2, (b+d)/2
        R = hypot(a-px, b-py)
        if all(hypot(px-xi, py-yi) <= R+EPS for xi, yi in Points):
            ans = min(ans, R)
            
for i in range(N):
    for j in range(i):
        for k in range(j):
            a = Points[i][0]
            b = Points[i][1]
            c = Points[j][0]
            d = Points[j][1]
            e = Points[k][0]
            f = Points[k][1]
            
            ea = hypot(c-e, d-f) + EPS
            eb = hypot(a-e, b-f) + EPS
            ec = hypot(a-c, b-d) + EPS
            cA = (ec**2+eb**2-ea**2)/(2*ec*eb)
            cB = (ec**2-eb**2+ea**2)/(2*ec*ea)
            cC = (-ec**2+eb**2+ea**2)/(2*ea*eb)
            sA = (1-cA**2)**0.5
            sB = (1-cB**2)**0.5
            sC = (1-cC**2)**0.5
            s2A = 2*sA*cA
            s2B = 2*sB*cB
            s2C = 2*sC*cC
            if max(s2A, s2B, s2C) < EPS:
                continue
            else:
                px = (a*s2A + c*s2B + e*s2C)/(s2A+s2B+s2C)
                py = (b*s2A + d*s2B + f*s2C)/(s2A+s2B+s2C)
                R = hypot(px - a, py - b)
            
            if all(hypot(px-xi, py-yi) <= R+EPS for xi, yi in Points):
                ans = min(ans, R)
print(ans)


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

int n, a[100], rate[9];

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

	for (int i = 0; i < n; i++) {
		if (a[i] < 400) {
			rate[0] = 1;
		}
		else if (a[i] < 800) {
			rate[1] = 1;
		}
		else if (a[i] < 1200) {
			rate[2] = 1;
		}
		else if (a[i] < 1600) {
			rate[3] = 1;
		}
		else if (a[i] < 2000) {
			rate[4] = 1;
		}
		else if (a[i] < 2400) {
			rate[5] = 1;
		}
		else if(a[i] < 2800){
			rate[6] = 1;
		}
		else if (a[i] < 3200) {
			rate[7] = 1;
		}
		else {
			rate[8]++;
		}
	}

	int Min = 0, Max = 0;
	for (int i = 0; i < 8; i++) {
		Min += rate[i];
	}
	Max = Min + rate[8];

	if (Min == 0)Min = 1;
	cout << Min << " " << Max << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {
    int N, T;
    int c[100],t[100];

    cin >> N >> T;

    int min = 1001;
    for (int i = 0; i < N; ++i) {
        cin >> c[i] >> t[i];
    }

    for (int i = 0; i < N; ++i) {
        if(T>=t[i]){
            if(min > c[i]){
                min = c[i];
            }
        }
    }

    if(min < 1001) {
        cout << min << endl;
    }
    else{
        cout << "TLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    FAST_IO
    string s;
    cin >> s;
    string prev = "",now = "";
    ll count = 0;
    rep(i,s.size()){
        now += s[i];
        if(now != prev){
            prev = now;
            now = "";
            count++;
        }
    }
    cout << count;
}

Measured memory_bytes: 3452
using System;

class A10{
  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    long n1 = 1;
    long n2 = 1;

    if(n == 0) Console.WriteLine(n1);
    else if(n == 1) Console.WriteLine(n2);
    else{
      for(int i = 2;i <= n;i++){
        long n3 = n1 + n2;
        n1 = n2;
        n2 = n3;
      }
      Console.WriteLine(n2);
    }
  }
}



Measured memory_bytes: 17908
R,r,g=range,raw_input,int;N,K=map(g,r().split());L=K+1;P,Q=R(K),R(L);D=[L*[0]for i in Q];a=b=0
for i in R(N):x,y,c=r().split();x,y=g(x),g(y);p=(x/K+y/K+ord(c))%2;D[y%K+1][x%K+1]+=1-2*p;b+=p
for i in P:
 for j in Q:D[i+1][j]+=D[i][j]
for i in P:
 for j in Q:D[j][i+1]+=D[j][i]
for i in Q:
 for j in Q:S=D[i][K]+D[K][j]-D[i][j]*2;a=max(a,S,D[K][K]-S)
print a+b

Measured memory_bytes: 23664
p=10**9+7

n,m=map(int,input().split())
x=list(map(int,input().split()))
w=[((x[i+1]-x[i])*(1+i)*(n-i-1))%p for i in range(n-1)]
y=list(map(int,input().split()))
h=[((y[k+1]-y[k])*(1+k)*(m-k-1))%p for k in range(m-1)]

print(((sum(w)%p)*(sum(h)%p)%p))

Measured memory_bytes: 85220
#include <stdio.h>
#include <math.h>
#define MAXNUM 1299709

int main(void){
	int flag[MAXNUM + 1], i, j, n;
	for(i = 0;i <= MAXNUM;i++)
		flag[i] = 1;
	for(i = 2;i <= sqrt((double)MAXNUM);i++){
		for(j = i * 2;j <= MAXNUM;j += i)
			flag[j] = 0;
	}
	flag[0] = flag[1] = 0;
	while(1){
		scanf("%d",&n);
		if(!n)
			break;
		for(i = n;!flag[i];i++);
		for(j = n;!flag[j];j--);
		printf("%d\n",i - j);
	}
	return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(Args&&... args) const { print(std::forward<Args>(args)...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(T&& head, Tail&&... tail) const { std::cout << head, print_rest(std::forward<Tail>(tail)...); }
        template <class T, class... Tail>
        void print_rest(T&& head, Tail&&... tail) const { std::cout << sep << head, print_rest(std::forward<Tail>(tail)...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
    template <class T>
    void print_vec(const std::vector<T>& vec, const char* sep = " ", const char* term = "\n") const {
        const size_t sz = vec.size();
        for (size_t i = 0; i < sz; i++) std::cout << vec[i] << (i == sz - 1 ? term : sep);
    }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    map<ll, ll> cnt1, cnt2;
    for (ll i = 0; i < N; i++) {
        ll a;
        cin >> a;
        if (i & 1) {
            ++cnt2[a];
        }
        else {
            ++cnt1[a];
        }
    }
    ll mx1 = 0, mx2 = 0;
    ll smx1 = 0, smx2 = 0;
    ll val1, val2, sval1, sval2;
    for (auto [a, b] : cnt1) {
        if (b >= mx1) {
            smx1 = mx1;
            sval1 = val1;
            mx1 = b;
            val1 = a;
        }
        else if (b > smx1) {
            smx1 = b;
            sval1 = a;
        }
    }
    for (auto [a, b] : cnt2) {
        if (b >= mx2) {
            smx2 = mx2;
            sval2 = val2;
            mx2 = b;
            val2 = a;
        }
        else if (b > smx2) {
            smx2 = b;
            sval2 = a;
        }
    }
    if (val1 != val2)
        prints()(N - mx1 - mx2);
    else
        prints()(N - max(mx1 + smx2, mx2 + smx1));
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 9852
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int l[210];

int main(){
	cin>>n;
	REP(i,2*n){
		int t;
		cin>>t;
		l[i]=t;
	}
	sort(l,l+2*n);
	int ans=0;
	for(int i=0;i<2*n;i+=2){
		ans+=l[i];
	}
	cout<<ans<<endl;
	return 0;
}
		

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

bool pass[1<<21];
int n;
int a[1<<21];

bool dfs(int p){
    //cerr << p <<" ";
    pass[p] = true;
    if(a[p] == 0){
        return false;
    }
    bool ret = true;
    for(int i=0;i<n;i++){
        if(!((1<<i)&p) && !pass[p+(1<<i)]){
            ret &= dfs(p+(1<<i));
        }
    }
    return ret;
}


int main(){
    cin>>n;
    for(int i=0;i<(1<<n);i++){
        cin >> a[i];
    }
    int ans = 0;
    for(int k=1;k<n;k++){
        int comb = (1<<k) -1;
        //cerr << comb << endl;
        while(comb < 1 << n){
            
            if(!pass[comb] && a[comb]){
                ans++;
                if(!dfs(comb)){
                    cout << -1 << endl;
                    return 0;
                }
            }
            int x = comb & -comb, y = comb + x;
            comb = ((comb & ~y) / x>>1) | y;
        }

    }
    cout << ans << endl;
}


Measured memory_bytes: 8240
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
#include<map>
#include<set>
using namespace std;
int main(){
	int n,m;
	while(cin>>n>>m,n||m){
		multiset<int> box;
		int y[1510],x[1510],s;
		map<int,int> mpx,mpy;
		x[0]=0;
		y[0]=0;
		for(int i=1;i<=n;i++){
			cin>>s;
			x[i]=x[i-1]+s;
		}
		for(int i=1;i<=m;i++){
			cin>>s;
			y[i]=y[i-1]+s;
		}
		for(int i=0;i<=n;i++)
		for(int j=i+1;j<=n;j++){
			if(mpx[x[j]-x[i]]==0)
			box.insert(x[j]-x[i]);
			mpx[x[j]-x[i]]++;
		}
		
		for(int i=0;i<=m;i++)
		for(int j=i+1;j<=m;j++){
			
			mpy[y[j]-y[i]]++;
		}
		int ans=0;
		set<int>::iterator ite=box.begin();
		while(ite!=box.end()){
			ans+=mpx[*ite]*mpy[*ite];
			ite++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 27000
import collections

n = int(input())
a = list(map(int,input().split()))
c = dict(collections.Counter(a))

d1 = []
d2 = []
for num,v in c.items():
  if v >= 2:
    d1.append(num)
  if v >= 4:
    d2.append(num)
    
d1.sort()
d2.sort()

if d2:
  ans = max(d2[-1]**2, d1[-1]*d1[-2])
  print(ans)
else:
  if len(d1)>=2:
    print(d1[-1]*d1[-2])
  else:
    print(0)
  



Measured memory_bytes: 21668
#include <cstdlib>
#include <stdio.h>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <string>
#define lp(i,n) for(int i=0;i<n;i++)
#define si(n) scanf("%lld",&n)
#define si3(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define pt(n) printf("%lld ",n)
#define ll long long
using namespace std;

int main()
{
    ll n,k,q,ipt;
    vector<ll> A,ansIdx;
    
    si3(n,k,q);
    
    lp(i,n){
        A.push_back(k-q);
    }
    
    lp(i,q){
        si(ipt);
        A[ipt-1]++;
    }
    
    lp(i,n){
        if(A[i]<=0){
            puts("No");
        }else{
            puts("Yes");
        }
    }
   
    return 0;

}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 1524
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

def eratosthenes(n):
    is_prime = [True] * n
    is_prime[0] = is_prime[1] = False
    is_prime[4::2] = [False] * (n // 2 - 2)
    m = int(n**.5) + 1
    for i in range(3, m, 2):
        if is_prime[i]:
            is_prime[i*i::2*i] = [False] * ((n - i*i - 1) // (2*i) + 1)
    # return [2] + [i for i in range(3, n, 2) if is_prime[i]]
    return is_prime

# prime = eratosthenes(2*10**6+10)
l = [0] * (10**6+1)
for a in A:
    l[a] += 1
ans = 0
for i in range(10**6+1):
    if l[i] == 1:
        # print(i)
        ans += 1
    if l[i] >= 1:
        for j in range(i, 10**6+1, i):
            l[j] = 0
print(ans)


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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



ll pow_mod(ll n, ll k, ll m) {
	ll r = 1;
	for (; k > 0; k >>= 1) {
		if (k & 1)r = (r*n) % m;
		n = (n*n) % m;
	}
	return r;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	ll ans = pow_mod(2, n, mod);
	ans--;
	ans += mod;
	ans %= mod;
	COMinit();

	ll cur = 1;


	REP(i, a) {
		cur *= (n - i);
		cur %= mod;
		cur *= modinv(i + 1, mod);
		cur %= mod;
	}
	ans -= cur;
	ans += mod;
	ans %= mod;
	
	
	cur = 1;
	REP(i, b) {
		cur *= (n - i);
		cur %= mod;
		cur *= modinv(i + 1, mod);
		cur %= mod;
	}

	ans -= cur;
	ans += mod;
	ans %= mod;

	cout << ans << endl;
	
}




Measured memory_bytes: 12160