akhauriyash/Code-Regression huggingface dataset:
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXX 1e12

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N,W; cin>>N>>W;
    ll dp[N + 1][W + 1];
    memset(dp,0,sizeof(dp));
    
    ll wei[N],val[N];
    
    for(ll i=0;i<N;++i)
        cin>>wei[i]>>val[i];
    
    for(ll i=1;i<=N;++i)
    {
        for(ll j=0;j<=W;++j)
        {
            dp[i][j] = dp[i - 1][j];
            
            if(j >= wei[i - 1])
                dp[i][j] = max(dp[i][j],dp[i - 1][j - wei[i - 1]] + val[i - 1]);
        }
    }
    
    cout<<dp[N][W]<<endl;
}

Measured memory_bytes: 82420
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	sc(n);
	f1(i,n)sc(A[i]);
	A[0]=oo; cnt=0;
	f1(i,n){
		if(A[i]<=A[i-1]){
			cnt++;
			mxz(ans,cnt);
		}
		else{
			cnt=1;
		}
	}
	pr(ans-1);
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

Measured memory_bytes: 1152
#include<stdio.h>
    long calc(int x, int y)
    {
    long pat = 1;
    int i,j;
      if(0 == x-y || 0 == y-x){
        j = 2;
        for(i = 1;i < x;i++){
        pat = pat * j % 1000000007;
        j++;
        }
      pat = pat*pat*2 % 1000000007;
      }
      if(1 == x-y || 1 == y-x){
        j = 2;
        for(i = 1;i < x;i++){
        pat = pat * j % 1000000007;
        j++;
        }
        j = 2;
        for(i = 1;i < y;i++){
        pat = pat * j % 1000000007;
        j++;
        }
      }
      if(2 <= x-y || 2 <= y-x){
      pat = 0;
      }
    pat = pat % 1000000007;
    return pat;
    }
    int main()
    {
        int N,M;
        scanf("%d %d", &N,&M);
        printf("%ld\n",calc(N,M));
        return 0;
    }

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

ll maxl(ll x,ll y){
    if(x>y) return x;
    else return y;
}

int main(){
    int n;
    cin>>n;
    int x[105],y[105],xc,yc;
    ll h[105],hc;
    int a;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>h[i];
        if(h[i]!=0){
            xc=x[i];
            yc=y[i];
            hc=h[i];
        }
    }
    int anscx,anscy;
    ll ansh;
    for(int i=0;i<101;i++){
        for(int j=0;j<101;j++){
            int px=i,py=j;
            ll H=hc+abs(xc-px)+abs(yc-py);
            bool ok=true;
            for(int k=0;k<n;k++){
                if(h[k]!=maxl(0,H-abs(x[k]-px)-abs(y[k]-py))){
                    ok=false;
                }
            }
            if(ok){
                anscx=px,anscy=py,ansh=H;
                cout<<anscx<<" "<<anscy<<" "<<ansh<<endl;
                return 0;
            }
        }
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;

ll pow(ll now, ll x){
    if(now==x) return 1;
    return 2*pow(now+1,x);
}
int main(){
    int n,m; cin>>n>>m;
    cout<<(1900*m+100*(n-m))*pow(2,m)<<endl;
}

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

using namespace std;

int main() {
  
  int N;
  while(cin >> N && N) {
    int dp[35] = {1};
    for(int i=0; i<N; i++) {
      dp[i+1] += dp[i];
      dp[i+2] += dp[i];
      dp[i+3] += dp[i];
    }
    cout << dp[N]/3650 + (dp[N]%3650?1:0) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main(){
    map<string, int> ms, mt;
    int N, M;
    cin >> N;
    for(int i = 0; i < N; i++){
        string s;
        cin >> s;
        if(ms.count(s)==0){
            ms[s] = 1;
        }else{
            ms[s]++;
        }
    }
    cin >> M;
    for(int i = 0; i < M; i++){
        string s;
        cin >> s;
        if(mt.count(s)==0){
            mt[s] = 1;
        }else{
            mt[s]++;
        }
    }
    int ans = 0;
    for(auto itr = ms.begin(); itr != ms.end(); ++itr){
        ans = max(ans, itr->second - mt[itr->first]);
    }
    
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}

ll expMod(ll a, ll b, ll mod){
    ll ans = 1;
    while(b){
        if(b&1) ans = (ans*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return ans;
}

ll mod = 1e9 + 7;
vl fat, fatI;
void init(int m){
    fat.resize(m+1);
    fatI.resize(m+1);
    fat[0] = fatI[0] = 1;
    for(int i=1;i<=m;i++){
        fat[i] = (fat[i-1] * i)%mod;
        fatI[i] = expMod(fat[i], mod-2, mod);
    }
}

ll C(int n, int k){
    ll tmp = (fat[n]*fatI[k])%mod;
    tmp *= fatI[n-k];
    tmp %= mod;
    return tmp;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, i;
    cin >> n >> m;
    init(m);
    ll ans = 0;
    int sign = 1;
    for(i=0;i<=n;i++){
        ll cr = C(n,i) * C(m,n);
        cr %= mod;
        cr *= fat[n];
        cr %= mod;
        cr *= (C(m-i, n-i)*fat[n-i])%mod;
        cr %= mod;
        cr *= sign;
        ans += cr;
        ans %= mod;
        if(ans < 0) ans += mod;
        sign = -sign;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 11012
def solve(S,H,W):
    for i in range(H):
        S[i] = "." + S[i] + "."
    S = ["." * (W+2)] + S + ["." * (W+2)]

    for i in range(1,H+1):
        for j in range(1,W+1):
            if not judge(S,i,j):
                return False

    return True

def judge(S,h,w):
    V = [(-1,0),(1,0),(0,-1),(0,1)]
    if S[h][w] == ".":
        return True
    else:
        for vh,vw in V:
            if S[h+vh][w+vw] == "#":
                return True
        return False

def main():
    H,W = map(int,input().split())
    S = [input() for _ in range(H)]

    if solve(S,H,W):
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 9216
//https://atcoder.jp/contests/abc122/tasks/abc122_b

#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<char> arr = {'A', 'C', 'G', 'T'};
    string s;
    cin >> s;
    int a = 0;
    int temp = 0;
    for (int i = 0; i < s.length(); i++)
    {
        temp = count(arr.begin(), arr.end(), s[i]) ? temp + 1 : 0;
        a = max(a, temp);
    }
    cout << a << endl;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* [💭] [💡] [🎈] */

using namespace std;

int a[200000];

int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int s = 0;

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s ^= a[i];
    }
    for (int i = 0; i < n; i++) {
        cout << (s ^ a[i]) << ' ';
    }

    return 0;
}

Measured memory_bytes: 4436
import java.util.Scanner;

public class Main
{
    public static void main(String[] args) 
    {
        Scanner scanner = new Scanner(System.in);
        
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        
        
        
        if (a<b && b<c) {
            
        System.out.println("Yes");
        }
        if(a>=b || b>=c){ 
        System.out.println("No");
        }
        return;
    }
}


Measured memory_bytes: 26140
import sys

if __name__ == "__main__":
    a = int(input())
    n = list(map(int, input().strip().split(' ')))
    ans = 1
    n.sort()
    for i in n:
      ans *= i
      if ans > 10**18:
          break
    if ans > 10**18:
        print(-1)
    else:
        print(ans)

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

#define rep(i,n) for (int i=0;i<(int)n;++i)
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define ALL(x) x.begin(),x.end()

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
inline void chmin(int &x, int y) { if (x > y) x = y; }


int main() {
    LL N, num, den;
    cin >> N;
    for(int i=3500; i>0; i--){
        for(int j=i; j>0; j--){
            num = N*i*j;
            den = 4*i*j - i*N - N*j;
            if(den > 0 && num%den == 0){
                cout << num / den << " " << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#abc124d

n,k=map(int,raw_input().split())
s=raw_input()
l=[0]
for i in xrange(n-1):
 if s[i+1]!=s[i]:
  l.append(i+1)
l.append(n)
res=0
for i in xrange(len(l)-1):
 idx=min(i+k*2+int(s[l[i]]=='1'),len(l)-1)
 res=max(res,l[idx]-l[i])
print res


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

int main() {
    int n;
    ll ans = 0;
    cin >> n;
    vector<int> a(n+1);
    vector<int> b(n);
    for (int i = 0; i < n+1; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];

    for (int i = 0; i < n; i++)
    {
        if (b[i] > a[i]) {
            b[i] -= a[i];
            ans += a[i];
            if (b[i] > a[i+1]) {
                ans += a[i+1];
                a[i+1] = 0;
            }
            else {
                ans += b[i];
                a[i+1] -= b[i];
            }
        } else {
            ans += b[i];
            a[i] = 0;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

ll X, Y, Z, K;
ll A[1010], B[1010], C[1010];

ll D[1000100];

ll E[3000100];

int main()
{
	cin >> X >> Y >> Z >> K;
	for (ll i = 0; i < X; i++)
	{
		cin >> A[i];
	}
	for (ll i = 0; i < Y; i++)
	{
		cin >> B[i];
	}
	for (ll i = 0; i < Z; i++)
	{
		cin >> C[i];
	}
	//入力完了

	sort(A, A + X, greater<ll>());
	sort(B, B + Y, greater<ll>());
	sort(C, C + Z, greater<ll>());

	ll i_d = 0;

	for (ll i = 0; i < X; i++)
	{
		for (ll j = 0; j < Y; j++)
		{
			D[i_d++] = A[i] + B[j];
		}
	}

	sort(D, D + i_d, greater<ll>());

	ll i_e = 0;

	for (ll i = 0; i < K; i++)
	{
		for (ll j = 0; j < Z; j++)
		{
			E[i_e++] = D[i] + C[j];
		}
	}

	sort(E, E + i_e, greater<ll>());

	for (ll i = 0; i < K; i++)
	{
		cout << E[i] << endl;
	}
}

Measured memory_bytes: 31616
import java.util.*;
public class Main {
    
    static long ks(int weights[], int[] values, int n, int c, long[][] dp){
      
        if(dp[n][c]!=-1) return dp[n][c];
         if(n<=0 || c<=0) return 0;
    
    if(weights[n]>c){
        
         return ks(weights, values, n-1, c, dp);
        
    }
    else{

        long tmp1 = ks(weights, values, n-1, c, dp);
        long tmp2 = values[n] + ks(weights, values, n-1, c-weights[n], dp );
        dp[n][c] = Math.max(tmp1,tmp2);
         return Math.max(tmp1, tmp2);
    }
    
    
    
    }
   
    
    public static void main(String args[]) {
     Scanner in = new Scanner(System.in);
     int n = in.nextInt();
     int c = in.nextInt();
     
     int[] values = new int[n+1];
     int[] weights = new int[c+1];
     long dp[][] = new long[n+1][c+1];
     for(int i=0; i<n+1;i++){
         for(int j=0; j<c+1; j++){
             dp[i][j] = -1;
         }
     }
     for(int i=1; i<n+1; i++){
         
         weights[i] = in.nextInt();
         values[i] = in.nextInt();
     }
   
     
     long result = ks(weights, values, n, c, dp);
     System.out.println(result);
    }
}

Measured memory_bytes: 126932
#include <cstdio>

const int MOD				= static_cast<int>(1e9+7);
const int MAXARRAY			= 100;
const long long MULTILIMIT	= MOD;

int Combination(int n, int k)
{
	int i, j, index = 1;
	long long comb[MAXARRAY] ={ 1 };

	for (i = 0; i < k; i++) {
		for (j = 0; j < index; j++)
			comb[j] *= n - i;

		for (j = 0; j < index; j++)
			if (comb[j] >= MULTILIMIT) {
				comb[j+1] += comb[j] / MOD;
				comb[j] %= MOD;
			}

		if (comb[j])
			index++;
	}

	for (i = 2; i <= k; i++) {
		for (j = index-1; j > 0; j--) {
			comb[j-1] += (comb[j] % i) * MOD;
			comb[j] /= i;
		}
		comb[j] /= i;
	}

	return static_cast<int>(comb[0] % MOD);
}

int main()
{
	int N, M, i, j, comb, count = 0, factor = 3, factnum[30] = { 0 };
	long long ans = 1;
	std::scanf("%d%d", &N, &M);
	
	while (!(M & 1))
		count++, M >>= 1;
	factnum[count]++;

	while (M != 1) {
		count = 0;
		while (!(M % factor))
			count++, M /= factor;
		factnum[count]++, factor += 2;
	}

	for (i = 1; i < 30; i++) {
		if (factnum[i]) {
			comb = Combination(i + N - 1, i);
			for (j = 0; j < factnum[i]; j++) {
				ans *= comb;
				ans %= MOD;
			}
		}
	}

	std::printf("%d\n", static_cast<int>(ans));

	return 0;
}

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

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if ( (a < c && b > c )|| (a > c && b < c ) )
    cout << "Yes" << endl;
  else
    {
      cout << "No" << endl;
    }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1e18
/*long long dp[100001];
int arr1[105];
int arr2[105];
int main()
{
    int n,w;
    long long c;
    cin>>n>>w;
    for(int i=0;i<n;i++)
    {
        cin>>arr1[i]>>arr2[i];
    }
    for(int i=0;i<=w;i++)
    {
        dp[i]=0;
    }
    for(int i=0;i<n;i++)
    {
        for(int j=w;j>=0;j--)
        {
            if(i==0)
            {
                if(j>=arr1[0])
                {
                    dp[j]=arr2[0];
                }
            }
            else if(j-arr1[i]<0)
            {
                dp[j]=dp[j];
            }
            else
            {
                dp[j]=max(dp[j],arr2[i]+dp[j-arr1[i]]);
            }
        }
    }
    //for(int i=0;i<n;i++)
    //{
       /* for(int j=0;j<=w;j++)
        {
            cout<<dp[j]<<" ";
        }
        cout<<"\n";
    //}
    cout<<dp[w];
    return 0;
}*/
ll arr1[105];
ll arr2[105];
int main()
{
    int n,w;
    ll c=0;
    cin>>n>>w;
    for(int i=0;i<n;i++)
    {
        cin>>arr1[i]>>arr2[i];
        c+=arr2[i];
    }
    ll dp[c+1];
    for(int i=1;i<=c;i++)
    {
        dp[i]=INF;
    }
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=c;j>=0;j--)
        {
            if(i==0)
            {
                if(j<=arr2[0])
                {
                    dp[j]=min(dp[j],arr1[0]);
                }
            }
            else if(j>=arr2[i])
            {
                dp[j]=min(dp[j],arr1[i]+dp[j-arr2[i]]);
            }
        }
    }
    ll ans=0;
    for(ll i=0;i<=c;i++)
    {
        if(dp[i]<=w)
        {
            ans=max(ans,i);
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
use std::cmp::{min,max};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::VecDeque;
fn main(){
    input!{
        a:usize,
        b:usize,
        c:usize,
    }
    if a < c && c< b{
        println!("Yes");
    } else if b < c && c < a {
        println!("Yes")
    } else {
        println!("No")
    }
}

Measured memory_bytes: 4352
N, K = map(int, input().split())

mod_K_zero = len([i for i in range(1, N+1) if i % K == 0])
mod_K_half = len([i for i in range(1, N+1) if i % K == K/2])

print(pow(mod_K_zero, 3) + pow(mod_K_half, 3))

Measured memory_bytes: 52208
/***********************************************
#
#      Filename: sol.cpp
#
#        Author: Comsyl - ylsong15@fudan.edu.cn
#   Description: ---
#        Create: 2017-06-30 22:24:50
***********************************************/
#include <bits/stdc++.h>
using namespace std;

struct point {
  int id, x, y;
};

struct edge {
  int u, v, val;
  edge(int u, int v, int val) : u(u), v(v), val(val) {}
  bool operator>(const edge& e) const {
    return val > e.val;
  }
};

vector<point> points;
priority_queue<edge, vector<edge>, greater<edge> > E;
vector<int> par;

int mabs(int x, int y) {
  return x > y ? x - y : y - x;
}

int root(int v) {
  return par[v] < 0 ? v : (par[v] = root(par[v]));
}

void merge(int x, int y) {
  if ((x = root(x)) == (y = root(y))) return ;
  if (par[x] > par[y]) swap(x, y);
  par[x] += par[y];
  par[y] = x;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int x, y;
  for (int i = 0; i < n; ++ i) {
    point p;
    cin >> p.x >> p.y;
    p.id = i;
    points.push_back(p);
  }

  sort(points.begin(), points.end(), [](const point& a, const point& b) -> bool {
    return a.x < b.x;
    });
  for (int i = 0; i + 1 < points.size(); ++ i) {
    int u = points[i].id;
    int v = points[i + 1].id;
    int val = mabs(points[i].x, points[i+1].x);
    E.push(edge(u, v, val));
  }

  sort(points.begin(), points.end(), [](const point& a, const point& b) -> bool {
    return a.y < b.y;
    });
  for (int i = 0; i + 1 < points.size(); ++ i) {
    int u = points[i].id;
    int v = points[i + 1].id;
    int val = mabs(points[i].y, points[i+1].y);
    E.push(edge(u, v, val));
  }

  par = vector<int> (n, -1);

  int count = 0;
  long long cost = 0;
  while (count < n - 1) {
    edge e = E.top(); E.pop(); // not const edge& e !
    if (root(e.u) == root(e.v)) continue;
    else {
      merge(e.u, e.v);
      cost += e.val;
      ++ count;
    }
  }

  cout << cost << endl;
  return 0;
}


Measured memory_bytes: 6132
#include <stdio.h>
int main(void){
    short x,y;
    while(1){
        scanf("%d %d", &x, &y);
        if(x == 0 && y == 0)break;
        if(x<y){
            printf("%d %d\n", x, y);
        }else{
            printf("%d %d\n", y, x);
        }
    }
    return 0;
}



Measured memory_bytes: 2056
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll r,g;
  cin>>r>>g;
  rep(i,-100000,100000){
    if((40000+r+i)/2==g+20000){
      cout << i << endl;
      return 0;
    }
  }
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include <vector>
#include <set>
using namespace std;
long long MOD=1000000007;

int main(){
	int n,d;
	cin>>n>>d;
	int x=2*d+1;
	if(n%(2*d+1)==0)cout<<n/x<<endl;
	else cout<<n/x +1<<endl;
	
}


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

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> A){
    set<int> se;
    for(int i = 0;i < N;i++)se.insert(A[i]);
    if(se.size() == N){
        cout<<YES<<endl;
    }else{
        cout<<NO<<endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 11136
import java.awt.Point;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	static Scanner s=new Scanner(System.in);
	
	static int w,h;
	public static void main(String[] __){
		while(true){
			int n=s.nextInt();
			if(n==0) return;
			w=s.nextInt();
			h=s.nextInt();
			int[][] f=new int[h+1][w+1];
			Point[] ps=new Point[n];
			for(int i=0;i<n;i++)
				ps[i]=new Point(s.nextInt(),s.nextInt());
			int ww=s.nextInt(),hh=s.nextInt();
			for(Point p:ps){
										f[p.y   ][p.x   ]++;
				if(izryt(p.y+hh,p.x   ))f[p.y+hh][p.x   ]--;
				if(izryt(p.y   ,p.x+ww))f[p.y   ][p.x+ww]--;
				if(izryt(p.y+hh,p.x+ww))f[p.y+hh][p.x+ww]++;
			}
			//Arrays.stream(f).map(Arrays::toString).forEach(System.out::println);
			//System.out.println();
			
			for(int[] v:f)
				Arrays.parallelPrefix(v,Integer::sum);
			
			int r=0;
			for(int i=0;i<=w;i++)
				for(int j=1;j<=h;j++){
					r=Math.max(r,f[j][i]+=f[j-1][i]);
					if(i>=ww&&j>=hh)
						r=Math.max(r,f[j][i]-f[j-hh][i]-f[j][i-ww]);
				}
			//Arrays.stream(f).map(Arrays::toString).forEach(System.out::println);
			System.out.println(r);
		}
	}
	static boolean izryt(int y,int x){
		return 0<=y&&y<=h&&0<=x&&x<=w;
	}
}

Measured memory_bytes: 50112
#include<iostream>
#include<cmath>
using namespace std;
bool prime[1000000] = {false};
int main(){
    int n;
    while(cin >> n){
       
        prime[1] = true;
        prime[2] = false;
        int count = 0;
        
      
        for(int j = 2; j * j <= n ; j++){
            if(!prime[j]){
                for (int k = 2; k*j <= n;k++){
                   prime[j*k] = true;
                }
            }
        }
        for(int i = 1;i<=n;i++){
            if(!prime[i]) count = count +1;
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 2136
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 200005;
const ll mm = 1e+18;
int dx[4]={-1,1,0,0};
int dy[4]={0,0,1,-1};
void solve()
{
    set<pair<int,int>>s,new_s;
    int a[10]={0};
    int h,w,n;
    cin>>h>>w>>n;
    rep1(_i,n){
        int x,y;
        cin>>x>>y;
        s.insert({x,y});
        repp(i,-1,2)repp(j,-1,2){
            int xx=x+i;
            int yy=y+j;
            if(xx>=1&&xx<=h&&yy>=1&&yy<=w) new_s.insert({xx,yy});
        }
    }
    int z=0;
    for(auto p:new_s){
        if(min(p.f,h-p.f+1)==1||min(p.s,w-p.s+1)==1) continue;
        int tot=0;
        repp(i,-1,2)repp(j,-1,2){
            int x=p.f+i;
            int y=p.s+j;
            if(x>=1&&x<=h&&y>=1&&y<=w){
                if(s.find({x,y})!=s.end()) tot++;
            }
        }
        if(tot) z++;
        a[tot]++;
    }
    a[0]=(h-2)*(w-2)-z;
    rep0(i,10) cout<<a[i]<<"\n";
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}


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

std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
    if ('0' <= s[i] && s[i] <= '9')
      ret = 10 * ret + s[i] - '0';
  return ret;
}

int main(){
  ll a ;
  cin >> a ;
  ll A[a] ;
  rep(i,a) cin >> A[i] ;
  rep(i,a){
    if(A[i] == 0 ){
	cout << 0 << endl;
      return 0 ;
    }
  }
  __int128 ans = 1 ;
  rep(i,a){
   if( A[i]*ans > (ll) 1e18 ){
      cout << -1 << endl;
      return 0 ;
   }
    ans *= A[i] ;
  }
  cout << ans << endl ;
}



Measured memory_bytes: 4388
# C
import collections

inp = input()
N = int(inp)

inp = input().split(' ')
A = {i: int(inp[i-2]) for i in range(2, N+1)}
A[1] = None

buka = dict(collections.Counter(A.values()))


res = {i: buka.get(i, 0) for i in A.keys()}
for i in range(1, N+1):
    print(res[i])

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

#define INF (INT32_MAX/2)
#define MOD (1000000000+7)
#define MAX 100000

string s;

int cnt[26][MAX];

int main() {
	cin >> s;

	int sz = s.size();
	for( int i = 0; i < sz; i++ ) {
		cnt[s[i] - 'a'][i]++;
	}
	int ans1 = -1;
	int ans2 = -1;
	for( int i = 0; i < 26; i++ ) {
		int last = -INF;
		for( int j = 0; j < sz; j++ ) {
			if( cnt[i][j] ) {
				if( j - last <= 2 ) {
					ans1 = last + 1;
					ans2 = j + 1;
				}
				else {
					last = j;
				}
			}
		}
	}

	cout << ans1 << " " << ans2 << endl;

	return 0;
}


Measured memory_bytes: 10624
n,a,b=map(int,input().split())
if (a-b)%2==0:
  print(abs((a-b)//2))
else:
  c = max(n-a,n-b)
  d = max(a-1,b-1)
  e = min(n-a,n-b)
  f = min(a-1,b-1)
  g = min(e,f)
  h = g + (abs(a-b)+1)//2
  print(min(c,d,h))

Measured memory_bytes: 3064
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
//struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int n;
int a[10][3];

int main(){
  while (cin >> n, n){
    rep(i, n) rep(j, 3) cin >> a[i][j];
    vector<pair<vector<int>, int>> v;
    rep(i, n){
      sort(a[i], a[i] + 3);
      do {
        rep(j, 60){
          vector<int> b(3);
          rep(k, 3) b[k] = (a[i][k] + j) % 60;
          if (b[0] % 5 == b[1] / 12){
            b[0] /= 5;
            v.emplace_back(b, i);
          }
        }
      } while (next_permutation(a[i], a[i] + 3));
    }
    sort(all(v));
    array<int, 7> res{{inf, 0, 0, 0, 0, 0, 0}};
    rep(i, v.size()){
      bool f[n];
      memset(f, 0, sizeof(f));
      auto s = v[i].first, t = v[i].first;
      rep(j, v.size()){
        if (f[v[(i + j) % v.size()].second]) continue;
        f[v[(i + j) % v.size()].second] = true;
        t = v[(i + j) % v.size()].first;
      }
      int x = s[0] * 3600 + s[1] * 60 + s[2];
      int y = t[0] * 3600 + t[1] * 60 + t[2];
      if (x > y) y += 12 * 3600;
      chmin(res, array<int, 7>{{y - x, s[0], s[1], s[2], t[0], t[1], t[2]}});
    }
    printf("%02d:%02d:%02d %02d:%02d:%02d\n", res[1], res[2], res[3], res[4], res[5], res[6]);
  }
}

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

bool data[8][8];

int main(){
    int N,M;
    cin>>N>>M;
    
    for(int i=0;i<M;i++){
        int u,v;
        cin>>u>>v;
        u--;v--;
        data[u][v]=true;
        data[v][u]=true;
    }

    vector<int> v;
    for(int i=1;i<N;i++) v.push_back(i);

    int ans=0;
    if(N==2) ans=M;
    else{
        do{
            bool okay=true;
            if(data[0][v.at(0)]==false) okay=false;
            else{
                for(int i=0;i<N-2;i++){
                    if(data[v.at(i)][v.at(i+1)]==false) okay=false;
                }
            }
            if (okay) ans++;
            //if (okay) {for(int i=0;i<v.size();i++) {cout<<v.at(i)+1<<' ';} cout<<endl;}
        } while(next_permutation(v.begin(),v.end()));
    }

    cout<<ans<<endl;

}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, P;
    cin >> N >> P;
    int o = 0;
    for (int i = 0; i < N; i++)
    {
        int z;
        cin >> z;
        if (z % 2 == 1)
        {
            o++;
        }
    }
    long long int ans = 0;

    if (o == 0)
    {
        if (P == 0)
        {
            ans = pow(2, N);
        }
        else
        {
            ans = 0;
        }
    }
    else
    {
        if (P == 0)
        {
            ans = pow(2, N - 1);
        }
        else
        {
            ans = pow(2, N) - pow(2, N - 1);
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,c;
    int count = 0;
    scanf("%d %d %d",&a,&b,&c);
    for(int i = a ; i<= b ; i++){
        if(c % i == 0)
         count++;
    }
    printf("%d\n",count);
    
    return 0;
}


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

def WarshallFloyd(V: int, cost: "List[List[int]]"):
    """
    全ての頂点対の間の最短距離を求めます。
    ==============
    V: 頂点数
    cost: 隣接行列(辺が存在しない部分はINF)
    --------------
    cost: 最短距離の行列
    """
    INF = 1e18
    for k in range(V):
        for i in range(V):
            for j in range(V):
                if cost[i][k] != INF and cost[k][j] != INF:
                    cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])
    return cost

def solve(N: int, M: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    INF = 1e18
    cost = [[INF for _ in range(N)] for _ in range(N)]
    for i in range(M):
        cost[a[i] - 1][b[i] - 1] = c[i]
        cost[b[i] - 1][a[i] - 1] = c[i]
    for i in range(N):
        cost[i][i] = 0
    cost = WarshallFloyd(N, cost)
    # print(cost)
    counter = 0
    for i in range(M):
        flag = False
        for j in range(N):
            if cost[j][a[i]-1] + c[i] == cost[j][b[i]-1]:
                flag = True
        if not flag:
            counter += 1
    print(counter)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]"
    b = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, M, a, b, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <stdio.h>

int main() {
  int a,b,c,d;
  scanf("%d", &a);
  scanf("%d", &b);
  c = 1;
  d = 0;
  while(1) {
    d = ((b * 2) + 1) * c;
    if (d >= a) {
      break;
    }
    c++;
  }
  printf("%d", c);
  return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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 void debug(){ cerr << "Done" << endl; }

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n, m;
	cin >> n >> m;
	vi x(m);
	rep(i, m) cin >> x[i];

	if(n >= m){ cout << 0 << endl; return 0; }

	sort(all(x));
	vi l;
	rep(i, m-1) l.push_back(x[i+1]-x[i]);
	sort(all(l));
	reverse(all(l));
	ll dontVisit = 0;
	rep(i, n-1) dontVisit += l[i];
	ll ans = x.back() - x.front() - dontVisit;

	rep(i, l.size()) cerr << l[i] << ' ';
	cerr << endl;

	fprintf(
		stderr,
		"x.back: %d\nx.front: %d\ndon't visit: %d\n",
		x.back(), x.front(), dontVisit
		);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE
void solve(void)
{
  int P,Q,R;
  cin>>P>>Q>>R;
  cout<<min(P+Q,min(Q+R,R+P))<<endl; 
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
typedef pair<int,ll> P;
const int MOD=1e9+7;
int X,Y;
int A(int x)
{
    int re=1;
    for(int i=1;i<=x;i++)
        re=(ll)re*i%MOD;
    return re;
}
int ksm(int x,int y)
{
    int re=1;
    while(y)
    {
        if(y&1) re=(ll)re*x%MOD;
        x=(ll)x*x%MOD;
        y>>=1;
    }
    return re;
}
int inv(int x)
{
    return ksm(x,MOD-2);
}
int main()
{
    cin>>X>>Y;
    if((2*X-Y)%3!=0)
        return printf("0\n")*0;
    int n=(2*X-Y)/3,m=X-2*n;
    if(n<0 || m<0)
        return printf("0\n")*0;
    printf("%lld\n",(ll)A(m+n)*inv(A(m))%MOD*inv(A(n))%MOD);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	map<int, int> mp;
	int n;
	for(int i = 0; i<3 and cin>>n; i++)
		mp[n]++;
	cout<< (mp[5] == 2 and mp[7] == 1 ? "YES" : "NO");	
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
int n,m;
int main()
{
	cin >>n>>m;
	cout <<n-m+1;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,k;
	string s;
	cin >> n >> k >> s;
	for(int i=0;i<n;i++)
	{
		if(i+1==k)
		{
			s[i]=tolower(s[i]);
			cout << s[i];
		}
		else
		{
			cout << s[i];
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_gcd(_T first, _T second)
{
	_T num1 = first, num2 = second;
	_T remainder = 0, common = 0;

	if (!num1) return num2;
	if (!num2) return num1;

	while (!common) {
		remainder = num1 % num2;

		if (remainder == 0) {
			common = num2;
		}
		else {
			num1 = num2;
			num2 = remainder;
		}
	}
	return(common);
}
template <class _T> static _T tp_lcm(_T first, _T second) {
	_T gcd = tp_gcd<_T>(first, second);
	return first * second / gcd;
}

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static const long long MOD_NUM = 1000000007LL;

static void C_task();

int main()
{
	C_task();
	fflush(stdout);
	return 0;
}

static void C_task()
{
	int A, B;
	get2int(A, B);

	printf("%lld\n", tp_lcm<LLONG>((LLONG)A, (LLONG)B));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define P pair<int,int>
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
	int a, b, k;
	cin >> a >> b >> k;
	for (int i = a; i < b + 1; i++) {
		if (a + k > i || b - k < i) {
			cout << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

double x;

int main(){
	while(cin>>x){
		if(x<0)return 0;
		int n=(x-floor(x))*10000+1e-8;
		if(n%625)cout<<"NA"<<endl;
		else{
			n=x*16+1e-8;
			if(n>4095)cout<<"NA"<<endl;
			else{
				for(int i=0;i<12;i++){
					cout<<(n/(int)(pow(2,11-i)+1e-8))%2;
					if(i==7)cout<<".";
				}
				cout<<endl;
			}
		}
	}
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 200000;

int main() {
	ll n, k;
	cin >> n >> k;
	ll h[N];
	rep(i, n) cin >> h[i];
	sort(h, h + n, greater<ll>());
	ll ans = 0;
	if(k >= n) {
		cout << 0 << endl;
		return 0;
	}
	for(int i = k; i < n; i++) {
		ans += h[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second

using namespace std;
using vi=vector<int>;
using pii=pair<int, int>;
using ull=unsigned long long;

typedef long long ll;
const int m = (int)1e9+7;

int solve(int n, const vector<int> &b){
	vector<int> ans(n+1, -1);
	ans[0] = 1;
	ans[1] = 1;

	for (auto i : b) ans[i] = 0;

	for (int i = 2; i <= n; i++){
		if (ans[i] == -1)
			ans[i] = (ans[i-1] + ans[i-2]) % m;
	}

	return ans[n];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
	int n, m;
	cin >> n >> m;
	vector<int> b(m);

	for(int i=0; i < m;i++){
		cin >> b[i];
	}

	cout << solve(n, b) << endl;;
    return 0;
}


Measured memory_bytes: 1024