akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
int n, x[20][2], p[20];
ll xp[35000][16][2], ans[20];
inline void chmin(ll &a, ll b){if(a>b) a=b;}
void rec(int i, int xs, int ys, int cnt){
	if(i == n){
		ll sm = 0;
		rep(i,n) sm += min(xp[xs][i][0], xp[ys][i][1]);
		chmin(ans[cnt],sm);
	}else{
		rec(i+1,xs,ys,cnt);
		rec(i+1,xs+(1<<i),ys,cnt+1);
		rec(i+1,xs,ys+(1<<i),cnt+1);
	}
}
int main(){
	scanf("%d", &n);
	fill(ans,ans+n+1,(ll)1e15);
	rep(i,n) scanf("%d%d%d", x[i], x[i]+1, p+i);
	rep(bt,1<<n) rep(i,n) rep(k,2){
		xp[bt][i][k] = abs(x[i][k]);
		rep(j,n) if(bt>>j&1) chmin(xp[bt][i][k], abs(x[i][k]-x[j][k]));
		xp[bt][i][k] *= p[i];
	}
	rec(0,0,0,0);
	rep(i,n+1) printf("%lld\n", ans[i]);
}

Measured memory_bytes: 12016
#include<cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define For(i, a, n) for(int i = a; i < (n); i++)
#define out(n) cout << (n) << endl;
#define vut(v) rep(i, v.size()) out(v[i]);
const int maxn = 105;
using namespace std;
typedef long long LL;

int n, w;
LL w1,x,y;
LL ans=0;
LL sumv[4][maxn];
vector<LL> v[4];
int main()
{
    cin>>n>>w;
    cin>>w1>>y;
    v[0].pb(y);
    for (int i=1;i<n;i++){
        cin>>x>>y;
        v[x-w1].pb(y);
    }
    for (int i=0;i<4;i++) sort(v[i].begin(),v[i].end());
    for (int i=0;i<4;i++) reverse(v[i].begin(),v[i].end());
    for (int i=0;i<4;i++) {
        sumv[i][0]=0;
        for(int j = 0; j < v[i].size(); j++){
            sumv[i][j+1]=sumv[i][j]+v[i][j];
        }
    }
    for(int i = 0; i <=v[0].size(); i++){
        for(int j = 0; j <= v[1].size(); j++){
            for(int k = 0; k <= v[2].size(); k++){
                if (i*w1+j*(w1+1)+k*(w1+2)>w) break;
                int p=(w-(i*w1+j*(w1+1)+k*(w1+2)))/(w1+3);
                p=min(p,(int)v[3].size());
                ans=max(ans,sumv[0][i]+sumv[1][j]+sumv[2][k]+sumv[3][p]);
            }
        }
    }
    
    cout<<ans;
    return 0;
    
}

Measured memory_bytes: 764
using System;
using System.Linq;

namespace aoj_ALDS1_1_D
{
    class MainClass
    {
        public static void Main(string[] args)
        {
			int priceCount = int.Parse(Console.ReadLine());
			long[] priceArray = new long[priceCount];
            for (int i = 0; i < priceCount; i++)
			{
				priceArray[i] = long.Parse(Console.ReadLine());
			}

			long maxDifference = -999999999;
			long maxPrice = priceArray.Max();
            for (int i = 0; i < priceCount; i++)
			{
				if (i == priceCount - 1) break;

				if (maxPrice == priceArray[i]) maxPrice = priceArray.Where((d, index) => index > i).Max();

				maxDifference = Math.Max(maxDifference, maxPrice - priceArray[i]);
			}

			Console.WriteLine(maxDifference);
        }
    }
}



Measured memory_bytes: 13276
A, B, K = map(int, raw_input().split())
if B - A + 1 > 2 * K:
	for i in range(A, A + K):
		print i
	for i in range(B - K + 1, B + 1):
		print i
else:
	for i in range(A, B + 1):
		print i


Measured memory_bytes: 2568
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long min = N;
        
        for(long i=1; i*i<=N; i++){
            if(N%i==0){
                if(min > (i+(N/i)-2)){
                    min = i+(N/i)-2;
                }
            }
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 35676
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include<bits/stdc++.h>
using namespace std ;

using ll = long long ;

class B121 {
public:
	void solve(std::istream& cin, std::ostream& cout) {
	    string a , b ;
	    cin >> a >> b ;
	    string  x = a + b ;
	    int number = 0 ;
	    for(char c : x){
	        number *= 10 ;
	        number +=  c - '0' ;
	    }
	    int n  = (int)sqrt(number) ;
	    if( (n * n) == number) cout << "Yes" ;
	    else cout << "No" ;
	}
};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	B121 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    ll a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    cout << (c * 60 + d - a * 60 - b) - e << endl;
}

Measured memory_bytes: 3672
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
using namespace std;

int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i += 2) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

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

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

int main() {
	int num;
	cin >> num;
	cout << num * num * num << endl;
	return 0;
}



Measured memory_bytes: 3084
import sys
from io import StringIO
import unittest
import math

def resolve():
    r = int(input())
    ans = math.pi * r * 2
    print('{:.20f}'.format(ans))

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """1"""
        output = """6.28318530717958623200"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """73"""
        output = """458.67252742410977361942"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m, u, v; cin >> n >> m;
	int ans = -1;
	vector <vector<int>> adj(n);
	vector <bool> vis(n, false);
	for (int i = 0; i < m; ++i){
		cin >> u >> v; --u; --v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for (int i = 0; i < n; ++i){
		if (vis[i]) continue;
//		vis[i] = true;
		int number = 0;
		queue<int> q;
		q.push(i);
//		cout << "CURRENT " << i << "\n";
		while (!q.empty()){
			int cur = q.front();
			q.pop();
			if (vis[cur]) continue;
			vis[cur] = true;
			for (int j : adj[cur]){
				if (!vis[j]) q.push(j);
			}
			++number;
//			cout << cur << "\n";
		}
		ans = max(number, ans);
	}	
		cout << ans << "\n";	
	return 0;
}


Measured memory_bytes: 14760
import std.stdio, std.string, std.conv;
import std.algorithm, std.array;
import std.math, core.bitop;
 
auto solve(string s_)
{
    immutable N = s_.to!int();
    immutable xs = readln.split.map!(to!int).array();
    immutable L = readln.chomp.to!int();
    immutable Q = readln.chomp.to!int();
    auto ab = new int[2][Q];
    foreach(ref v;ab) v = readln.split.map!(to!int).array();
    immutable D = (xs[$-1]-xs[0]+L-1)/L;
    immutable M = bsr(D)+((D&D-1)?0:1);
    auto ld = new int[][](N+1,M);
    for(int i=0,j=0; i<N; ++i)
    {
        while(j<i && (xs[i]-xs[j])>L) ld[j++][0]=i-1;
        if(i+1==N) while(j<N) ld[j++][0]=i;
    }
    ld[N-1][0]=N;
    ld[N][]=N;
    foreach(i;1..M) foreach(j;0..N) ld[j][i]=ld[ld[j][i-1]][i-1];
    int[] r; r.reserve(Q);
    foreach(ref v;ab)
    {
        auto a=v[0]-1,b=v[1]-1;
        if(a>b) swap(a,b);
        int d=0;
        while(a<b)
        {
            int lo=0, hi=M;
            while(lo+1<hi)
            {
                immutable m = (lo+hi)/2;
                if(ld[a][m]<=b) lo=m;
                else            hi=m;
            }
            d+=1<<lo;
            a=ld[a][lo];
        }
        r~=d;
    }
    return r.map!(to!string).join("\n");
}

void main(){ for(string s; (s=readln.chomp()).length;) writeln(solve(s)); }

Measured memory_bytes: 23468
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());

		if(A > 0 && A <10 && B > 0&& B <10) {
			System.out.println(A*B);
		} else {
			System.out.println(-1);
		}

	}
}

Measured memory_bytes: 22868
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
long long n,k,h[K],ans;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	sort(h+1,h+1+n);
	for(int i=n;i>=1;i--)
	{
		if(k>0)
			k--;
		else
			ans+=h[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
const int N = 1e5 + 5;

void solve(){
	int n; cin >> n;
    map<string, int> mp;
    for(int i = 0;i < n; ++i){
        string x;
        cin >> x;
        mp[x]++;
    }
    string ans;
    int best = 0;
    for(auto & x: mp){
        if(x.second > best){
            best = x.second;
            ans = x.first;
        }
    }

    for(auto & x: mp){
        if( x.second == best){
            cout << x.first << '\n';
        }
    }
    
	
}


int main(){
	ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
	//int t; cin >> t;
	//while(t--)
		solve();
}


Measured memory_bytes: 23808
#include<bits/stdc++.h>
using namespace std;
long long n,m;
vector<long long> box,sum;

bool check (long long mid) {
  long long cnt=0;
  for(int i=0;i<n;i++) {
    cnt+=n-(lower_bound(box.begin(),box.end(),mid-box.at(i))-box.begin());
  }
  if(cnt<m) {
    return false;
  }
  else {
    return true;
  }
}

int main() {
  cin >> n >> m;
  box.resize(n,0);
  sum.resize(n+1,0);
  for(int i=0;i<n;i++) {
    cin >> box.at(i);
  }
  sort(box.begin(),box.end());
  for(int i=0;i<n;i++) {
    sum.at(i+1)=sum.at(i)+box.at(n-1-i);
  }
  long long ok=0,ng=1e12;
  long long mid=(ng+ok)/2;
  while(ng-ok>1) {
    if(check(mid)) {
      ok=mid;
    }
    else {
      ng=mid;
    }
    mid=(ng+ok)/2;
  }
  long long ans=0,cnt=0;
  for(int i=0;i<n;i++) {
    int temp=n-(lower_bound(box.begin(),box.end(),ok-box.at(i))-box.begin());
    cnt+=temp;
    ans+=box.at(i)*temp+sum.at(temp);
  }
  ans-=ok*(cnt-m);
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
 
#define lli long long int
#define endl "\n"
 
using namespace std;
 
typedef long long int LLI;
typedef double DB;
 
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
 
 
bool comparator(pair<lli,lli> a,pair<lli,lli> b)
{
    if(a.first>b.first)
        return true;
    else if (a.first==b.second)
    {
        if(a.second>=b.second)
            return false;
        return true;
    }
    return false;
}
 
int mods(int x)
{
    if(x>0)
        return x;
    return -x;
}
 
lli gcd(lli a,lli b)
{
    return __gcd(a,b);
}
 
lli lcm(lli x,lli y,lli z)
{
    lli j=gcd(x,y);
    lli k=gcd(y*x/j,z);
    return (((x*y)/j)*z)/k;
} 

int arr[3][3];
bool vis[3][3]={0};

int main()
{
    fastio();
    lli n,k; cin>>n>>k;
    if(n>=k) cout<<min(n%k,k-n%k); 
    else cout<<min(n,k-n);
    return 0;
}

Measured memory_bytes: 3608
SS = input().split()


stack = []
for s in SS:
    if s == '+':
        a = stack.pop() + stack.pop()
        stack.append(a)
    elif s == '-':
        a = stack.pop()
        b = stack.pop()
        stack.append(b - a)
    elif s == '*':
        a = stack.pop() * stack.pop()
        stack.append(a)
    else:
        stack.append(int(s))

print(stack.pop())



Measured memory_bytes: 5596
#include <stdio.h>

int main(void){
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	if (a < 1 || b<1 || b > 100 || a > 100){
		printf("Impossible");
	}else if(((a+b)%3 == 0) || a%3 == 0 || b % 3 == 0){
		printf("Possible");
	}else printf("Impossible");
	return (0);
}

Measured memory_bytes: 128
a=input().split()
Even = int(a[0])
Odd = int(a[1])
if Even < 2 :
    Evenresult = 0
else:
    Evenresult = Even * (Even -1) / 2
if Odd < 2 :
    Oddresult = 0
else:
    Oddresult = Odd * (Odd -1) / 2
print(int(Evenresult + Oddresult))



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;




int main() {
    int n,l;
    cin >> n >> l;
    vector<string> vec;
    for(int i = 0;i < n;i++){
        string b;
        cin >> b;
        vec.push_back(b);
    }
    sort(vec.begin(),vec.end());
    string ans;
    for(int i = 0;i < n;i++){
        ans += vec[i];
    }
    cout << ans;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for (int i=0, h; i<n; i++) {
        cin >> h;
        if (h >= k) ans++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int main()
{
       ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
       long long n;
       cin >> n;
       cout << (n+n*n+n*n*n) << endl;
	return 0;
}



Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    String line = in.nextLine();
    in.close();
    String[] ary = line.split(" ");
    boolean w7 = false;
    boolean[] w5 = {false, false};

    for (String w : ary) {
      int intW = Integer.parseInt(w.trim());
      if (intW != 5 && intW != 7) {
        System.out.println("NO");
        return;
      } else if (intW == 7 && w7) {
        System.out.println("NO");
        return;
      } else if (intW == 5 && w5[0] && w5[1]) {
        System.out.println("NO");
        return;
      } else if (intW == 7 && w7 == false) {
        w7 = true;
      } else if (intW == 5) {
        if (w5[0] == false) {
          w5[0] = true;
        } else if (w5[1] == false) {
          w5[1] = true;
        }
      }
    }

    if (w7 && w5[0] && w5[1]) {
      System.out.println("YES");
    }
  }
}


Measured memory_bytes: 9428
from collections import deque


k = int(input())
d = deque([1,2,3,4,5,6,7,8,9])

for i in range(k):
    a = d.popleft()
    if a % 10 != 0:
        d.append(a*10 + a % 10 - 1)
    d.append(a*10 + a % 10)
    if a % 10 != 9:
        d.append(a*10 + a % 10 + 1)

print(a)




Measured memory_bytes: 11908
#include <bits/stdc++.h>
 
using namespace std;
 
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define forab(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define fst first
#define snd second
 
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
using vvi = vector<vi>;
 
#define FILE_NAME "a"
 
string s;
int k;
 
bool read() {
    if (!(cin >> s >> k)) {
        return 0;
    }
    return 1;
}

void remax (int &x, int y)
{
    x = max(x, y);
}

const int N = 310;
const int inf = (int)1e9;
int dp[N][N][N];
 
void solve() {
    fill_n(&dp[0][0][0], N * N * N, -inf);
    
    const int n = sz(s);

    forn (r, n + 1) ford (l, r + 1) forn (ch, k + 1)
    {
        int &cur = dp[l][r][ch];

        const int len = r - l;
        
        if (len <= 1)
        {
            cur = len;
            continue;
        }
            
        remax(cur, dp[l][r - 1][ch]);
        remax(cur, dp[l + 1][r][ch]);
        if (s[l] == s[r - 1])
            remax(cur, dp[l + 1][r - 1][ch] + 2);
        else if (ch)
            remax(cur, dp[l + 1][r - 1][ch - 1] + 2);
    }

    int ans = 0;
    forn (ch, k + 1)
       remax(ans, dp[0][n][k]);
    cout << ans << endl; 
}
 
int main() {
#ifdef LOCAL
    freopen(FILE_NAME ".in", "r", stdin);
//    freopen(FILE_NAME ".out", "w", stdout);
#endif
 
    while (read()) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 116608
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;cin>>N;
    vector<vector<long long>>V(N,vector<long long>(2));
    long long x=0;
    for(int i=0;i<N;i++){
        cin>>V[i][0]>>V[i][1];
        x=max(x,V[i][0]);
    }
    long long y;
    for(int i=0;i<N;i++){
        if(x==V[i][0])y=V[i][1];
    }
    cout<<x+y<<endl;
}

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

string ans;vector<int> abcd;bool check=false;

string solve(int count,int sum)
{
if(check)return ans;
if(count==3&&sum==7){check=true;return ans;}
if(count<3&&!check){ans.replace(count*2+1,1,"+");ans=solve(count+1,sum+abcd[count+1]);}
if(count<3&&!check){ans.replace(count*2+1,1,"-");ans=solve(count+1,sum-abcd[count+1]);}
return ans;
}

int main()
{
string S;cin>>S;abcd.resize(4);
for(int i=0;i<4;i++)abcd[i]=S[i]-'0';
ans=to_string(abcd[0])+"+"+to_string(abcd[1])+"+"+to_string(abcd[2])+"+"+to_string(abcd[3])+"=7";
cout<<solve(0,abcd[0]);
}


Measured memory_bytes: 3676
#import
#import math
#import numpy as np
#= int(input())
#= input()
N, K = map(int, input().split())
h = list(map(int, input().split()))
#= [input(), input()]

dp = [0] * N

dp[1] = abs(h[1] - h[0])

for i in range(2, N):
    t = dp[i - 1] + abs(h[i] - h[i - 1])
    for j in range(2, min(K + 1, i + 1)):
        tt = dp[i - j] + abs(h[i] - h[i - j])
        t = min(t, tt)

    dp[i] = t

print(dp[-1])
        

Measured memory_bytes: 84772
#include<stdio.h>
int main()
{
int a,j,d;
scanf("%d",&a);
int b[a-1],c[a];
for(j=0;j<a;++j){
 c[j]=0;
 }
for(j=0;j<a-1;++j)
 {scanf("%d",&b[j]);
  d=b[j];
  c[d-1]=c[d-1]+1;
 }

for(j=0;j<a;++j){
 printf("%d\n",c[j]);
 }
  
return 0;
}

Measured memory_bytes: 3292
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define BUF_SIZE 10
#define DIVISOR 1000000007

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}


int main(void) {
    int num = get_int();
    int pat = 0;
    int i;
    for(pat = 0; pat < (1<<num); pat++) {
        printf("%d:", pat);
        int pos[18] = {0};
        int idx = 0;
        for(i = 0; i < num; i++) {
            if(pat & (1<<i)) pos[idx++] = i;
        }
        for(i = 0; i < idx; i++) {
            printf(" %d", pos[i]);
        }
        putchar('\n');
    }
    return 0;
}


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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < 3505; i++) {
    for (int j = 1; j < 3505; j++) {
      long long up = 1LL * n * i * j, down = 4LL * i * j - (i + j) * 1LL * n;
      if (down <= 0) continue;
      if (up % down) continue;
      long long w = up / down;
      cout << i << " " << j << " " << w << endl;
      return 0;
    }
  }
  assert(false);
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
// using ll = long long;
// using vi = vector<int>;
// using vvi = vector<vi>;
// using vl = vector<long long>;
// using vvl = vector<vl>;
// using vs = vector<string>;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

int kaijo (int a, int result) {
  if (a == 0) {
    return result;
  } else {
    return kaijo(a-1, result * a);
  }
}

int kaijo(int a) {
  return kaijo(a,1);
}

ll kaijo_ll (ll a, ll result) {
  if (a == 0) {
    return result;
  } else {
    return kaijo_ll(a-1, result * a);
  }
}

ll kaijo_ll(ll a) {
  return kaijo_ll(a,1);
}

int main () {
  string s;
  bool flag = true;
  cin >> s;
  std::vector<ll> v(s.length(), 0), result(s.length(), 0);
  ll count = s.length();
  s += "R";
  ll num = 1;
  for (ll i = 1; i < s.length(); i++) {
    if(s[i] == s[i-1]) {
      num++;
    } else if(flag) {
      for (ll j = 1; j <= num; j++) {
        v[i-j] = j;
      }
      flag = !flag;
      num = 1;
    } else {
      for (ll j = 1; j <= num; j++) {
        v[i-(num-j+1)] = -j;
      }
      flag = !flag;
      num = 1;
    }
  }

  rep(i,count) {
    if(v[i]%2 && v[i] < 0) {
      result[i+v[i]+1]++;
    } else if(v[i]%2 && v[i] > 0){
      result[i+v[i]-1]++;
    } else {
      result[i+v[i]]++;
    }
  }
  rep(i,count){
    cout << result[i] << ' ';
  }
}


Measured memory_bytes: 2176
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = LIST()

money = 1000
for i in range(1, N):
	if A[i-1] < A[i]:
		kabu = money//A[i-1]
		money -= kabu*A[i-1]
		money += kabu*A[i]

print(money)

Measured memory_bytes: 10564
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N, K;
	cin >> N >> K;
	ll ans = 0;
	for (int i = K + 1; i <= N; i++) {
		ans += max(0, (N % i) + 1 - K);
		ans += (N / i) * (i - K);
	}
	if (K == 0) ans = (ll)N * N;
	cout << ans << endl;
}

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

int n,a[100010];

int gcd(int a,int b){return b?gcd(b,a%b):a;}

bool solve()
{
	int s=0,mn=1<<30;
	for (int i=1; i<=n; i++)
		s+=(a[i]-1)&1,mn=min(mn,a[i]);
	if (s&1)  return 1;
	else  if ((n-s>1)||(mn==1))  return 0;
	else
		{
			int g=0;
			for (int i=1; i<=n; i++)  g=gcd(g,a[i]-=a[i]&1);
			for (int i=1; i<=n; i++)  a[i]/=g;
			return !solve();
		}
}

void work()
{
	scanf("%d",&n);
	for (int i=1; i<=n; i++)
		scanf("%d",&a[i]);
	puts(solve()?"First":"Second");
}

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


Measured memory_bytes: 640
import sys

sys.setrecursionlimit(10 ** 9)
N = input()
N_len = len(N)
'''
75333
'''


# t = []


def dfs(a, depth):
    if depth == N_len:
        if int(a) <= int(N) and a.count('3') > 0 \
                and a.count('5') > 0 and a.count('7') > 0 and str(int(a)).count('0') == 0:
            return 1
        else:
            return 0

    ret1 = dfs(a + '0', depth + 1)
    ret2 = dfs(a + '3', depth + 1)
    ret3 = dfs(a + '5', depth + 1)
    ret4 = dfs(a + '7', depth + 1)
    return ret1 + ret2 + ret3 + ret4


ans = dfs('', 0)
print(ans)
# print(t)


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

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, W; cin >> n >> W;
	vector<ll> w(n + 1), v(n + 1);
	rep(i, 1, n)cin >> w[i] >> v[i];
	vector<vector<ll>> dp(n + 1, vector<ll>(200005));
	rep(i, 0, n - 1)rep(j, 0, W)
	{
		dp[i + 1][j + w[i + 1]] = max(dp[i][j + w[i + 1]], dp[i][j] + v[i + 1]);
		dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
	}
	cout << dp[n][W] << endl;
}

Measured memory_bytes: 159744
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
#pragma endregion

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n+1);
    for (int i=0; i<m; i++) {
        int aa, bb;
        cin >> aa >> bb;
        a.at(aa)++;
        a.at(bb)--;
    }
    for (int i=1; i<n+1; i++) {
        a.at(i) += a.at(i-1);
    }
    for (int i=1; i<n; i++) {
        if (a.at(i)%2 != 0) {
            cout << "NO" << "\n";
            return;
        }
    }
    cout << "YES" << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll x,y;cin>>x>>y;
  cout<<floor(log2((long double)(y/x)))+1<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#define MI 2147483647 / 3;
int ag = 2, am = 380, ags = 10, ams = 1520;
int bg = 3, bm = 550, bgs = 12, bms = 1870;
int cg = 5, cm = 850, cgs = 15, cms = 2244;
int dp[100];
int min(int a, int b) {
	if(a > b) return b;
	return a;
}
void solve() {
	int i;
	for(i = 0; i < 100; ++ i) dp[i] = MI;
	dp[0] = 0;
	for(i = 0; i < 50; ++ i) {
		dp[i + ag] = min(dp[i + ag], dp[i] + am);
		dp[i + bg] = min(dp[i + bg], dp[i] + bm);
		dp[i + cg] = min(dp[i + cg], dp[i] + cm);
		dp[i + ags] = min(dp[i + ags], dp[i] + ams);
		dp[i + bgs] = min(dp[i + bgs], dp[i] + bms);
		dp[i + cgs] = min(dp[i + cgs], dp[i] + cms);
	}
}
int main() {
	int N;
	solve();
	while(1) {
		scanf("%d", &N);
		if(N == 0) break;
		printf("%d\n", dp[N / 100]);
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        // 空白入力
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int d = scan.nextInt();
        // 空白入力
        int ans=0;
        while(n > 0){
            ans++;
            n = n - (d * 2 + 1);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(N: int, S: "List[str]"):

    def f(s):
        ans = [0]*(len(s)+1)
        m = 0
        for i, c in enumerate(s):
            if c == "(":
                m += 1
            else:
                m -= 1
            ans[i] = m
        return min(*ans), m, s

    # 数値化(最小値, 到達値)
    T = [f(s) for s in S]

    front = []
    back = []
    for a, b, s in T:
        if b >= 0:
            front.append((a, b, s))
        else:
            back.append((a, b, s))

    front.sort(key=lambda x: x[0], reverse=True)
    back.sort(key=lambda x: min(0, x[0]-x[1]), reverse=True)
    # print(front)
    # print(back)

    m = 0
    for ma, mb, s in front+back[::-1]:
        if m + ma < 0:
            no()
            # print("負", s)
            return
        m += mb

    if m == 0:
        yes()
    else:
        # print("非零到達")
        no()

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 375652
#!/usr/bin/env pypy3

import math, itertools, operator
from math import *
from math import factorial as fact
from itertools import permutations, combinations
from functools import reduce
from statistics import mean, median, median_low, median_high, mode
# Before Python 3.5
from fractions import gcd

#import numpy
#import scipy, scipy.special
#from sympy import isprime, nextprime
#from sympy.ntheory import factorint

inf = float('inf')

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))

################################################################################


N, K = input_ints()

print(N-K+1)


Measured memory_bytes: 5892
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;
    cin >> n;
    map<ll, ll> m;

    ll ans = 0;

    for (int i = 0; i < n; i++)
    {
        ll x;
        cin >> x;
        m[x]++;
        ans += x;
    }

    int q;
    cin >> q;

    for (int i = 0; i < q; i++)
    {
        int b, c;
        cin >> b >> c;

        ans += (c - b) * m[b];
        m[c] += m[b];
        m[b] = 0;

        cout << ans << endl;
    }
}


Measured memory_bytes: 9448
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
ll n,c,ans=10000000000;
bool flag;
ll color[3][30]={};
void Main(){    
    cin>>n>>c;
    vector<vector<ll>> cost(c,vector<ll>(c));
    For(i,0,c){
        For(j,0,c){
            cin>>cost.at(i).at(j);
        }
    }
    For(i,0,n){
        For(j,0,n){
            ll x;cin>>x;
            color[(i+j)%3][x-1]++;
        }
    }
    For(i,0,c){
        ll change0=0;
        For(t,0,c){
            change0+=color[0][t]*cost.at(t).at(i);
        }
        For(j,0,c){
            if(i==j) continue;
            ll change1=0;
            For(t,0,c){
                change1+=color[1][t]*cost.at(t).at(j);
            }
            For(k,0,c){
                if(i==k||j==k) continue;
                ll change2=0;
                For(t,0,c){
                    change2+=color[2][t]*cost.at(t).at(k);
                }
                ans=min(ans,change0+change1+change2);
            }
        }
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 256
import numpy as np
import math
 
N,K=list(map(int,input().split()))
 
ans = 0
for n in range(1,N+1):
    p = np.log2(K/n)
    p = math.ceil(p)
    
    if p < 0:
        p=0
    
    ans_temp = (1/N)*(1/2)**p
    ans+=ans_temp
    
print(ans)

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

using namespace std;

const int M = 3e3 + 1;
int n, arr[M], memo[M][M], mod = 998244353, halph;

int add(int a, int b) { return a + b - (a + b >= mod) * mod; }
int sub(int a, int b) { return a - b + (a - b < 0) * mod; }
int mul(int a, int b) { return (1ll * a * b) % mod; }
int powM(int n, int p) { return (!p ? 1 : (p & 1) ? mul(n, powM(n, p - 1)) : powM(mul(n, n), p / 2)); }
int divM(int a, int b) { return mul(a, powM(b, mod - 2)); }

int solve(int i, int cur) {
    if (cur < 0)
        return 0;
    if (i == n)
        return !cur;

    int &res = memo[i][cur];
    if (res == -1)
        res = add(mul(halph, solve(i + 1, cur - arr[i])), solve(i + 1, cur));
    return res;
}

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

    memset(memo, -1, sizeof memo);
    int s;
    cin >> n >> s;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    halph = divM(1, 2);
    cout << mul(powM(2, n), solve(0, s)) << "\n";

    return 0;
}


Measured memory_bytes: 39024
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(S: str):
    N = len(S)
    dp = [[0 for _ in range(13)] for _ in range(len(S))]
    if S[N-1] != '?':
        dp[0][int(S[N-1])] = 1
    else:
        dp[0] = [1,1,1,1,1,1,1,1,1,1,0,0,0]
    ten = [1]
    for i in range(1, len(S)):
        ten.append(ten[-1] * 10 % 13)
        ii = len(S) - i - 1
        for j in range(13):
            if S[ii] == '?':
                for ll in range(10):
                    kk = ll * ten[i] % 13
                    dp[i][j] += dp[i-1][(13 + j - kk)%13]
                    dp[i][j] %= MOD
            else:
                x = int(S[ii])
                m = x * ten[i] % 13
                dp[i][j] = dp[i-1][(13+j-m)%13]
                dp[i][j] %= MOD
    print(dp[len(S)-1][5])
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a.begin(),a.end());
  cout<<a[n-1]-a[0]<<endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
//typedef long long ll;
//typedef long double ld;
//typedef unsigned long long ull;
//typedef unsigned long double uld;
typedef pair<int,int> P;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
//struct area

//function area

//main area
int main(){
    char check[4] = {'N', 'W', 'S', 'E'};
    string s;
    cin >> s;
    int n = s.size();
    vector<bool> count_NWSE(4, false);
    rep(i, n){
        rep(j, 4){
            if(s[i] == check[j]){
                count_NWSE[j] = true;
            }
        }
    }
    if(count_NWSE[0] ^ count_NWSE[2] || count_NWSE[1] ^ count_NWSE[3]){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}
/*

N y += any
W x -= any
S y -= any
E x += any

*/

Measured memory_bytes: 3640
s = input()
acgt = set(["A","C","G","T"])
acgt_max = 0
acgt_len = 0
for i in range(len(s)):
    if s[i] in acgt:
        acgt_len += 1
        acgt_max = max(acgt_len, acgt_max)
    else:
        acgt_len = 0
print(acgt_max)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
typedef long long ll;

int a[200005];
int n;
int main()
{
	int i, k, res=0;
	scanf("%d%d", &k, &n);
	scanf("%d", &a[0]);
	for (i = 1; i < n; i++) {
		scanf("%d", &a[i]);
		if (a[i]-a[i-1] > res)
            res = a[i]-a[i-1];
	}
	if (k-a[n-1]+a[0] > res)
           res = k-a[n-1]+a[0];
	printf("%d\n", k-res);
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

bool stage[6][6];
signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int h, w, k;
    cin >> h >> w >> k;
    int black = 0;
    rep(i, h){
        rep(j, w){
            char t;
            cin >> t;
            if(t=='#'){
                stage[i][j] = 1;
                black++;
            }
        }
    }
    vi nh(h);
    vi nw(w);
    rep(i, h){
        rep(j, w){
            if(stage[i][j]){
                nh[i]++;
                nw[j]++;
            }
        }
    }
 
    int ans =0;
    for(int bit =0 ; bit<(1 << (h+w)); ++bit){
        int tblack = black;
        vi vh;
        rep(i, h){
            if(bit &(1<<i)){
                tblack -= nh[i];
                vh.emplace_back(i);
            }
        }
        vi vw;
        rep(i, w){
            if(bit &(1<<(i+h))){
                tblack -= nw[i];
                vw.emplace_back(i);
            }
        }
        rep(i, vh.size()){
            rep(j, vw.size()){
                if(stage[vh[i]][vw[j]])
                {
                    tblack++;
                }
            }
        }
        if(tblack == k){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long           ll;
typedef unsigned long long  ull;
 
#define srev                reverse(s.begin(),s.end())
#define sortstr             sort(s.begin(), s.end());
#define gtl(x)              getline(cin, (x))
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define PI                  acos(-1)
#define Precision(a) 		cout << fixed << setprecision(a)
#define Faster       		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
template <typename T> T Sqr(T x) { T n = x * x ; return n ;}
template <typename T> T Pow(T B,T P){ if(P==0) return 1; if(P&1) return B*Pow(B,P-1);  else return Sqr(Pow(B,P/2));}
template <typename T> T Abs(T a) {if(a<0)return -a;else return a;}
template <typename T> T Gcd(T a,T b){if(a<0)return Gcd(-a,b);if(b<0)return Gcd(a,-b);return (b==0)?a:Gcd(b,a%b);}
template <typename T> T Lcm(T a,T b) {if(a<0)return Lcm(-a,b);if(b<0)return Lcm(a,-b);return a*(b/Gcd(a,b));}
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());
 
int main()
{
    string a, b, x, y;
    cin >> a >> b;
    int i, j, flag=0;
    int l=b.length();
    x=b.substr(0, l-1);
    if(a==x)cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    double ans = 0.0;
    for(int i = 0; i < n; ++i)
    {
        double temp;
        cin >> temp;
        ans += 1.0 / temp;
    }
    cout << 1.0 / ans << endl;
}

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

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

int N, K;
vector<pii> P;

int main() {
    scanf("%d %d", &N, &K);
    P.resize(N);
    for(int i = 0; i < N; i++) {
        scanf("%d %d", &P[i].first, &P[i].second);
    }

    ll mx = 0;
    ll cost = 0;
    for(int i = 0; i < N; i++) {
        if((K | P[i].first) == K) cost += P[i].second;
    }
    mx = cost;

    while(1) {
        if(K == 0) break;
        int nK = K - 1;
        ll cost = 0;
        for(int i = 0; i < N; i++) {
            if((nK | P[i].first) == nK) cost += P[i].second;
        }
        mx = max(mx, cost);
        K -= (K & -K);
    }
    printf("%lld", mx);
}


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

using namespace std;

const double PI = M_PI;
int main()
{
	int x, n;
	cin >> x >> n;
	int sum = 0;
	for(int i = 0; i < n; i++){
		int mm; cin >> mm;
		sum += mm;
	}
	if(x >= sum) cout << x-sum;
	else cout << -1;
}


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;


#define SZ(x) ((int)(x).size())
#define BIT(n) (1ll<<(n))
#define SORT(c) sort((c).begin(),(c).end())
#define RALL(a) (a).rbegin(), (a).rend()
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define CLR(a) memset((a), 0 ,sizeof(a))
#define retrun return
#define INF 1000000010ll
#define MOD 1000000007ll
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define RREP(i,n)  
#define rep(i,n) for(int i=n-1;i>=0;--i)
#define COUT(str) cout << str << endl


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }

//------------------------------------------------------------------------------------------------------

ll n,k;
ll h[100005];
ll dis;
ll dp[100005];
//------------------------------------------------------------------------------------------------------

int main() {
	cin >> n >> k;
	REP(i, 0, n) {
		cin >> h[i];
	}

	sort(h, h + n);

	dis = INF;

	ll base = h[0];

	REP(i, 0, n) {
		h[i] -= base;
	}

	REP(i, 0, n - k+1) {
		dis = min(dis, h[i + k - 1] - h[i]);
	}

	COUT(dis);



	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s; cin>>s;
    cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
}


Measured memory_bytes: 256
module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;

struct Input
{
	int n;
	int[] a;
}

void parseInput(T)(out Input input, T file)
{
	with (file) with (input)
	{
		n = readln().strip().to!int;
		a = readln().strip().split().map!(to!int).array;
	}
}

struct Output
{
}

auto main2(Input* input)
{
    input.a.sort();
    int prev = -1;
    foreach (i; input.a)
    {
        if (prev == i)
            return "NO";
        prev = i;
    }

	return "YES";
}

unittest { writeln("begin unittest"); }

unittest // example1
{
	string example =
`5
2 6 1 4 5`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == "YES");
}

unittest // example2
{
	string example =
`6
4 1 3 1 6 2`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == "NO");
}

unittest // example3
{
	string example =
`2
10000000 10000000`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == "NO");
}

unittest { writeln("end unittest"); }

void parseExample(out Input input, string example)
{
	struct Adapter
	{
		string[] _lines;
		this(string input) { _lines = input.splitLines(); }
		string readln() { auto line = _lines[0]; _lines = _lines[1..$]; return line; }
	}
	parseInput(input, Adapter(example));
}

void main()
{
	Input input = void;
	parseInput(input, stdin);
	auto result = main2(&input);
	writeln(result);
}


Measured memory_bytes: 10328
#include<cstdio>
#include<cstring>
#define maxn 500005
#define mod (int)(1e9+7)
#define p 10007
char s[maxn];
int n,pw[maxn]={1},f[maxn];
bool pre[maxn],nxt[maxn];
int hash(int l,int r) { return ((f[r]-1ll*f[l-1]*pw[r-l+1]%mod)%mod+mod)%mod; }
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++) pw[i]=1ll*pw[i-1]*p%mod;
	for(int i=1;i<=n;i++) f[i]=1ll*(1ll*f[i-1]*p+s[i]-'a')%mod;
	for(int d=1;d<=n;d++)
		for(int i=2*d;i<=n;i+=d)
			if(hash(1,i-d)==hash(d+1,i)) pre[i]=true;
	for(int d=1;d<=n;d++)
		for(int i=n-2*d+1;i>0;i-=d)
			if(hash(i+d,n)==hash(i,n-d)) nxt[i]=true;
	if(!pre[n])
	{
		printf("1\n1\n");
		return 0;
	}
	int cnt=0;
	for(int i=1;i<n;i++)
		if(!pre[i]&&!nxt[i+1]) cnt++;
	if(cnt) printf("2\n%d\n",cnt);
	else printf("%d\n1\n",n);
}

Measured memory_bytes: 5504