akhauriyash/Code-Regression huggingface dataset:
#include	<bits/stdc++.h>
using	namespace	std;

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int H, W, K;
	cin >>H >>W >>K;
	vector<string> s(H);
	for (int i=0; i<H; i++)
		cin >>s.at(i);
	vector<vector<int>> a(H, vector<int> (W, 0));
	int rr=0;
	bool Found=false;
	while(!Found) {
		for (int i=0; i<W; i++)
			if ('#'==s.at(rr).at(i)) {
				Found =true;
				break;
			}
		if (!Found)
			rr++;
	}
	int B=1;
	for (int i=rr; i<H; i++) {
		Found=false;
		int w=0;
		while(w<W) {
			if ('#'==s.at(i).at(w)) {
				Found=true;
				break;
			}
			w++;
		}
		if (Found) {
			for (int j=0; j<=w; j++)
				a.at(i).at(j)=B;
			for (int j=w+1; j<W; j++) {
				if ('#'==s.at(i).at(j))
					B++;
				a.at(i).at(j)=B;
			}
			B++;
		} else {
			for (int j=0; j<W; j++)
				a.at(i).at(j)=a.at(i-1).at(j);
		}
		if (i==rr) {
			for (int ii=i-1; ii>=0; ii--)
				for (int j=0; j<W; j++)
					a.at(ii).at(j)=a.at(i).at(j);
		}
	}
	for (int i=0; i<H; i++) {
		for (int j=0; j<W; j++)
			cout <<a.at(i).at(j) <<' ';
		cout <<endl;
	}
	return 0;
}



Measured memory_bytes: 1280
import java.util.*;

class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        sc.close();
        String ret = "No";
        if (n % 2 == 0) {
            String t1 = s.substring(0, n / 2);
            String t2 = s.substring(n / 2, s.length());
            if (t1.equals(t2))
                ret = "Yes";
        }
        System.out.println(ret);
    }
}


Measured memory_bytes: 23892
n=int(input())
data=[]
t=[[0 for x in range(4)] for w in range(n+1)]
for _ in range(n):
    temp=[int(x) for x in input().split()]
    data.append(temp)
for i in range(1,n+1):
    for j in range(1,4):
        large=0
        for w in range(1,4):
            if(w==j):
                continue
            else:
                if(t[i-1][w]>large):
                    large=t[i-1][w]
        t[i][j]=data[i-1][j-1]+large
print(max(t[-1]))

Measured memory_bytes: 45712
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,m:usize,
        uv:[(Usize1,Usize1);m],
        s:Usize1,t:Usize1,
    }
    let mut g = vec![vec![]; n];
    for &(u, v) in uv.iter() {
        g[u].push(v);
    }

    let mut dist = vec![vec![!0; 3]; n];
    dist[s][0] = 0;
    let mut q = VecDeque::new();
    q.push_back((s, 0));
    while let Some(x) = q.pop_front() {
        let (v, p) = x;
        for &nx in g[v].iter() {
            let pp = (p + 1) % 3;
            if dist[nx][pp] == !0 {
                dist[nx][pp] = dist[v][p] + 1;
                q.push_back((nx, pp));
            }
        }
    }
    if dist[t][0] != !0 {
        println!("{}", dist[t][0] / 3);
    } else {
        println!("{}", -1);
    }
}


Measured memory_bytes: 15728
#include<iostream>
using namespace std;
int main(){
int n;
int a,b,ap,bp;
while(cin>>n&&n){
ap=0;
bp=0;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		if(a>b){
			ap+=a+b;
		}else if(a<b){
			bp+=a+b;
		}else{
			ap+=a;
			bp+=b;
		}
	}
	cout<<ap<<" "<<bp<<endl;
}

return 0;
}

Measured memory_bytes: 1156
<?php
  fscanf(STDIN, "%d %d", $n, $targetTime);
$array = array();
	for ($i=0;$i<$n;$i++) {
    	fscanf(STDIN, "%d %d", $cost, $time);
      	$array[$cost] = $time;
    }
$minCost = 1001;
foreach ($array as $cost => $time)  {
  	if ($time > $targetTime) {
      continue;
    } else {
      if ($minCost > $cost) {
        $minCost = $cost;
      }
    }
}
if ($minCost == 1001) {
  echo "TLE";
} else {
  echo $minCost;
}
?>

Measured memory_bytes: 3700
#include <stdio.h>
#include <math.h>
#define N 10000

int isprime(int);

int main() {

  int i, n, hantei, count=0; /*count=?´???°?????° */
  int num[N];

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &num[i]);
  }

  for(i=0; i<n; i++){
    hantei = isprime(num[i]);
    if(hantei==0) count++;
  }

  printf("%d\n", count);

  return 0;
}

int isprime(int num)
{
  int i;

  if(num==2) return 0;

    if(num < 2 || num%2==0) return 1;

    i = 3;
    while(i<=sqrt(num)){
      if(num%i==0) return 1;
      i = i+2;
    }

    return 0;
}

Measured memory_bytes: 628
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int N,m = INF,c = 0;
    cin >> N;
    vector<int> P(N);

    rep(i, N){
        cin >> P.at(i);
    }

    rep(i, N){
        if(P.at(i) < m){
            c++;
        }
        m = min(P.at(i), m);
    }

    cout << c << endl;
}

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

int main(){
  int N;
  vector<int> vec(3);
  for(int i=0;i<3;i++){
    cin >> vec[i];
  }
  cin >> N;
  
  int  cnt=0;
  for(int i=0;i<=vec[0];i++){
    for(int j=0;j<=vec[1];j++){
      for(int k=0;k<=vec[2];k++){
        if(N-500*i-100*j-50*k==0){
          cnt++;
        }
      }
    }
  }
  cout << cnt <<endl;
}

    

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FRE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define int long long
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
#define endl "\n"
const int oo = INT_MAX;
const int MOD = 1e9 + 7;
const int sz = 1e5 + 5;
const int N = 1e5 + 5;
int fact[N], invFact[N];
int power(int a, int b, int m){
    int ret = 1;
    while(b){
        if(b & 1) ret = (ret * a) % m;
        b /= 2;
        a = (a * a) % m;
    }
    return ret;
}
int modinv(int k){
    return power(k, MOD - 2, MOD);
}
void preComp(){
    fact[0] = fact[1] = 1;
    for(int i = 2; i < N; i++){
        fact[i] = i * fact[i - 1];
        fact[i] %= MOD;
    }
    invFact[N - 1] = modinv(fact[N - 1]);
    for(int i = N - 2; i > -1; i--){
        invFact[i] = invFact[i + 1] * (i + 1);
        invFact[i] %= MOD;
    }
}
int nCr(int x, int y){
    if(y > x) return 0;
    int ret = fact[x];
    ret *= invFact[y];
    ret %= MOD;
    ret *= invFact[x - y];
    ret %= MOD;
    return ret;
}
int32_t main() {
    IOS;
    
    int tc = 1;
    //cin >> tc;
    preComp();
    while(tc--) {
        int n; cin >> n;
        int ans = 0;
        for(int i = 1; i < n + 1; ++i) {
            int k = n - i * 3;
            if(k >= 0) {
                ans += nCr(i + k - 1, k);
                ans %= MOD;
            }
        }
        cout << ans % MOD;

    }
}

Measured memory_bytes: 5220
#include <cstdio>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a == 1){
        a = 14;
    }
    if(b == 1){
        b = 14;
    }
    if(a > b){
        printf("Alice\n");
    }else if(a < b){
        printf("Bob\n");
    }else{
        printf("Draw\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;
typedef pair<ll,ll> pairs;
typedef vector<pairs> p;


ll gcd(ll A,ll B){
    if (A%B==0)return(B);
    else return(gcd(B,A%B));
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}

bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    for(ll i=0;i<n;++i){
        if(s[i] == s[k-1]){
            cout<<s[i];
        }else{
            cout<<'*';
        }
    }
    cout<<endl;

    return 0;
}

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



int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> sub(n,-1);
    rep(i,n){
        cin >> a[i];
        decltype(sub)::iterator temp = lower_bound(sub.begin(),sub.end(),a[i]);
        int idx;
        idx = distance(sub.begin(),temp);
        if (idx>=n) sub[n-1]=a[i];
        else sub[idx-1]=a[i];
        //cout << a[i] << endl;
        //for(auto s:sub) cout << s << " ";
    }

    int res = 0;
    for(auto s:sub) if(s>=0) res++;

    cout << res << endl;


}

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

int main(){
  int N,K,s=0;
  cin >> N >> K;
  vector<int> p(N);
  for (int i=0;i<N;i++){
    cin >> p.at(i);
  }
  sort(p.begin(),p.end());
  for (int i=0;i<K;i++){
    s += p.at(i);
  }
  cout << s << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


// import here

void output(vector<int>& res){
    for(int j = 0; j < res.size(); ++j){
        cout << res[j];
        if(j + 1 >= res.size()){
            cout << endl;
        }else{
            cout << " ";
        }
    }
}

bool solve(int n, int a, int b, vector<int>& res){
    if(n == 1 && a == 1 && b == 1){
        res.clear();
        res.push_back(1);
        return true;
    }
    for(int n_block = 1; b * n_block <= n; ++n_block){
        LL rest = n - n_block * b;
        //cerr << n_block + max<LL>(1, rest + 1 - b) << ", " << a << ", " << n_block + rest << endl;
        if(n_block + max<LL>(1, rest + 1 - b) <= a && a <= n_block + rest){
            LL rest_up = a - n_block - 1;
            LL rest_down = rest - rest_up;
            res.clear();
            for(int i = 0; i < n_block; ++i){
                for(int j = 0; j < b; ++j){
                    res.push_back(b-j + i*b);
                }
            }
            for(int i = 0; i < rest_down; ++i){
                //cerr << "down: " << n - rest_up - i << endl;
                res.push_back(n - rest_up - i);
            }
            for(int i = 0; i < rest_up; ++i){
                //cerr << "up: " << n - rest_up + i + 1 << endl;
                res.push_back(n - rest_up + i + 1);
            }
            return true;
        }
    }
    return false;
}

int main(){
    LL n, a, b;
    cin >> n >> a >> b;
    vector<int> res;
    if(solve(n, a, b, res)){
        output(res);
        return 0;
    }
    if(solve(n, b, a, res)){
        for(int i = 0; i < n; ++i){
            res[i] = n+1 - res[i];
        }
        output(res);
        return 0;
    }
    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define ll long long
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
#define dbg3(x) cerr<<#x<<"\n"
using namespace std;
#define reg register
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
const int MN=25005,MK=405,P=1e9+7;
int Mul(int x,int y){return 1ll*x*y%P;}
int Add(int x,int y){return (x+y)%P;}
int fp(int x,int y){int r=1;for(;y;y>>=1,x=Mul(x,x))if(y&1)r=Mul(r,x);return r;}
int N,K,M,ans,a[MN],fac[MN],inv[MN],fi[MN];
int sf[MN][MK],f[MN][MK],sg[MN][MK],g[MN][MK];
bool chk1()
{
	static int ton[MK],num;
	reg int i;
	if(M<=K)return false;
	num=0;
	for(i=1;i<=K;++i)num+=!ton[a[i]]++;
	if(num==K) return true;
	for(i=K+1;i<=M;++i)
	{
		num-=!--ton[a[i-K]];
		num+=!ton[a[i]]++;
		if(num==K) return true;
	}
	return false;
}
int chk2()
{
	static int ton[MK],num;
	memset(ton,0,sizeof ton);
	reg int i;num=0;
	for(i=1;!ton[a[i]]&&i<=M;++i)num+=!ton[a[i]]++;
	return num;
}
int main()
{
	N=read(),K=read(),M=read();
	reg int i,j,Z=max(N,K);
	for(fac[0]=i=1;i<=Z;++i)fac[i]=Mul(fac[i-1],i);
	for(inv[0]=inv[1]=1,i=2;i<=Z;++i)inv[i]=Mul(inv[P%i],(P-P/i));
	for(fi[0]=i=1;i<=Z;++i)fi[i]=Mul(fi[i-1],inv[i]);
	for(i=1;i<=M;++i) a[i]=read();
	ans=Mul(N-M+1,fp(K,N-M));
	if(chk1()){return 0*printf("%d\n",ans);}
	f[0][0]=1;
	for(i=1;i<=N;++i)for(j=1;j<K;++j)
	{
		f[i][j]=Add(Mul(f[i-1][j-1],K-j+1),Add(sf[i-1][K-1],P-sf[i-1][j-1]));
		g[i][j]=Add(Mul(g[i-1][j-1],K-j+1),Add(sg[i-1][K-1],P-sg[i-1][j-1]));
		if(j>=M)g[i][j]=Add(g[i][j],f[i][j]);
		sf[i][j]=Add(sf[i][j-1],f[i][j]);
		sg[i][j]=Add(sg[i][j-1],g[i][j]);
	}
	if(chk2()==M)
	{
		int tmp=Mul(sg[N][K-1],Mul(fac[K-M],fi[K]));
		ans=Add(ans,P-tmp);
		printf("%d\n",ans);
		return 0;
	}
	else
	{
		int tmp=0,Mi,Ma,lm=chk2(),rm;
		reverse(a+1,a+M+1);rm=chk2();
		for(i=1;i<=N-M+1;++i)
		{
			int ii=i+lm-1,jj=N-i-M+1+rm,_1=0,_2=0;bool fl=ii==lm;
			for(j=lm;j<K;++j) _1=Add(_1,Mul(Mul(f[ii][j],Mul(fac[K-j],fi[K])),Mul(fac[K-lm],fi[K-j])));
			for(j=rm;j<K;++j) _2=Add(_2,Mul(Mul(f[jj][j],Mul(fac[K-j],fi[K])),Mul(fac[K-rm],fi[K-j])));
			tmp=Add(tmp,Mul(_1,_2));
		}
		ans=Add(ans,P-tmp);
		printf("%d\n",ans);
		return 0;
	}
}

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

typedef long long ll;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007

int main() {
    int n;cin>>n;
    string a,b,c;
    cin>>a>>b>>c;

    int ans=0;

    rep(i,n){
        set<char>ss;
        ss.insert(a[i]);
        ss.insert(b[i]);
        ss.insert(c[i]);
        ans+=ss.size()-1;
    }
    cout<<ans<<endl;
}


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

int main()
{
    int n, m, a[100][100], b[100];
    cin >> n >> m;
    for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> a[i][j];
    for (int i = 0; i < m; i++) cin >> b[i];

    for (int i = 0; i < n; i++) {
        int sum = 0;
        for (int j = 0; j < m; j++) {
            sum += a[i][j] * b[j];
        }
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 3112
N = int(input())
test = []
name = {}

## gather all word to test ##
for i in range(N):
  add = str(input())
  test.append(add)

## count appear time ## 
for i in test:
  if i in name:
    name[i] += 1
  if i not in name:
    name[i] =1
#print(name)


max_num = max(name.values())
#print(max_num)

word = []
for i in name:
  if name[i] == max_num:
    word.append(i)

word.sort()
for i in word:
  print(i)

Measured memory_bytes: 35220
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/
bool check(int *a, int n)
{
    for (int i=0;i<n;i++)
    {
        if (a[i]%2!=0)
        {
            return false;
        }
    }
    return true;
}
int main()
{
    start();
    int n;
    cin>>n;
    int a[n];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int c=0;
    while (check(a, n))
    {
        c++;
        for (int i=0;i<n;i++)
        {
            a[i]/=2;
        }
    }
    cout<<c;

    return 0;
}

Measured memory_bytes: 3572
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	A := ReadInts(N)
	for i := 0; i < N; i++ {
		m[A[i]]++
	}
	var even, odd int
	for _, c := range m {
		if c%2 == 0 {
			even++
		} else {
			odd++
		}
	}
	if even%2 == 0 {
		fmt.Println(odd + even)
	} else {
		fmt.Println(odd + even - 1)
	}
}

var m = make(map[int]int)

type State = int
type Heapq []State

func (q Heapq) Less(i, j int) bool    { return m[q[i]] < m[q[j]] }
func (q Heapq) Len() int              { return len(q) }
func (q Heapq) Swap(i, j int)         { q[i], q[j] = q[j], q[i] }
func (q *Heapq) Push(x interface{})   { *q = append(*q, x.(State)) }
func (q *Heapq) Pop() (x interface{}) { *q, x = (*q)[:len(*q)-1], (*q)[len(*q)-1]; return }
func (q *Heapq) push(v State)         { heap.Push(q, v) }
func (q *Heapq) pop() State           { return heap.Pop(q).(State) }

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 8748
#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>;

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

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

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

    int MAX = 102;
    vector<bool> tbl(MAX, false);
    for(int t : p)
        tbl[t] = true;
    int MIN = MAX;
    int ans = 0;
    for(int i = 0; i < MAX; i++){
        if(tbl[i]) continue;
        if(MIN > abs(x-i)){
            ans = i;
            MIN = abs(x-i);
        }
    }

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

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

int main() {
    int N;
    int rating, cont = 0, resp = 0;
    cin >> N;
    int Color[8] = {0, 0, 0, 0, 0, 0, 0, 0};


    for(int i=0; i<N; i++) {
        cin >> rating;

        if(rating < 400) {
            Color[0] = 1;
        }else if(rating < 800) {
            Color[1] = 1;
        }else if(rating < 1200) {
            Color[2] = 1;
        }else if(rating < 1600) {
            Color[3] = 1;
        }else if(rating < 2000) {
            Color[4] = 1;
        }else if(rating < 2400) {
            Color[5] = 1;
        }else if(rating < 2800) {
            Color[6] = 1;
        }else if(rating < 3200) {
            Color[7] = 1;
        }else{
            cont++;
        }
    }



    for(int i=0; i<8; i++) {

        if(Color[i]) {
            resp++;
        }
    }


    if(resp > 0)
        cout << resp << " " << resp + cont << endl;
    else{
        cout << 1 << " " << resp + cont << endl;
    }

    return 0;
}


Measured memory_bytes: 256
def main():
    a1, a2, a3 = map(int, input().split())

    c1 = abs(a3 - a1) + abs(a1 - a2)
    c2 = abs(a1 - a2) + abs(a2 - a3)
    c3 = abs(a2 - a3) + abs(a3 - a1)

    ans = min([c1, c2, c3])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	int w, d;

	void run(){
		for(;;){
			w=sc.nextInt();
			d=sc.nextInt();
			if((w|d)==0){
				break;
			}
			LinkedList<Integer> a=new LinkedList<Integer>();
			LinkedList<Integer> b=new LinkedList<Integer>();
			for(int i=0; i<w; i++){
				a.add(sc.nextInt());
			}
			for(int i=0; i<d; i++){
				b.add(sc.nextInt());
			}
			for(int e : a){
				if(b.contains(e)){
					b.remove((Integer)e);
				}
			}
			int ans=0;
			for(int e : a){
				ans+=e;
			}
			for(int e : b){
				ans+=e;
			}
			println(""+ans);
		}
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();

	}
}

Measured memory_bytes: 12000
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <bits/stdc++.h>

#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define mod 1000000007
#define pii pair <int, int>
#define all(x) x.begin(), x.end()
#define FOR(i, x, y) for (int i = x; i <= y; i++)
//#define tr(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

//using namespace __gnu_pbds;

using namespace std;

//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n;

int main()
{
	cin >> n;
	
	cout << (n >= 1200? "ARC" : "ABC");
}


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

using namespace std;

struct DATA{
  int Number;
  double Time;
};

bool compare(const DATA&, const DATA&);

int main(){
  int i, j, number;
  double time;
  DATA person;
  vector<DATA> data, win, lose;

  for(i=0; i<3; ++i){
    for(j=0; j<8; ++j){
      cin >> number >> time;
      person.Number = number;
      person.Time = time;
      data.push_back(person);
    }

    sort(data.begin(), data.end(), compare);
    win.push_back(data[0]);
    win.push_back(data[1]);

    for(j=2; j<8; ++j)
      lose.push_back(data[j]);

    data.clear();
  }

  sort(lose.begin(), lose.end(), compare);

  win.push_back(lose[0]);
  win.push_back(lose[1]);

  for(i=0; i<win.size(); ++i){
    cout << win[i].Number << " ";
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(2);
    cout << win[i].Time << endl;
  }

  return 0;
}

bool compare(const DATA& x, const DATA& y){
  return x.Time < y.Time;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=1e5+50,P=1e9+7;

int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }

struct BIT{
	int n,c[N],res;
	void init(int _n){
		n=_n+1;
		mem(c,0); 
	}
	void upd(int p,int x){
		for(++p;p<=n;p+=p&-p)c[p]=add(c[p],x); 
	}
	int qry(int p){
		for(res=0,++p;p>=1;p-=p&-p)res=add(res,c[p]); 
		return res;
	}	
} fx,fy;

int n;
ll A,B,a[N]; 

struct S{
	BIT* bit;
	bool in[N]; 
	int s[N],top;
	S(BIT *b):bit(b){ 
		top=0; 
		mem(in,0); 
	}
	void chk(int x){ 
		if(!in[x]){
			in[x]=true;
			s[++top]=x;
		}
	}
	void clr(){
		while(top){
			int x=s[top--];
			int w=sub(bit->qry(x),bit->qry(x-1));
			bit->upd(x,sub(P,w)); 
		}
	}
} sx(&fx),sy(&fy);

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	read(n),read(A),read(B); 	
	rep(i,1,n)read(a[i]); 
	fx.init(n); 
	fy.init(n); 
	fx.upd(0,1); 
	sx.chk(0); 
	fy.upd(0,1); 
	sy.chk(0);
	rep(i,1,n-1){
		int p,wx,wy;
		p=upper_bound(a+1,a+n+1,a[i+1]-B)-a-1;
		wy=fx.qry(p);
		if(a[i+1]-a[i]<A){
			sx.clr(); 
		}
		p=upper_bound(a+1,a+n+1,a[i+1]-A)-a-1;
		wx=fy.qry(p); 
		if(a[i+1]-a[i]<B){
			sy.clr(); 
		}
		fx.upd(i,wx); 
		sx.chk(i); 
		fy.upd(i,wy);
		sy.chk(i); 
	}
	int ans=add(fx.qry(n-1),fy.qry(n-1));
	printf("%d\n", ans);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> k(N);
  for(int i=0;i<N;i++){
    cin >> k.at(i);
  }
  sort(k.begin(),k.end());
  k.erase(unique(k.begin(),k.end()),k.end());
  cout<<k.size()<<endl;
}

Measured memory_bytes: 9484
while(1):
    try:
        xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2 = [float(i) for i in input().split()]
        if xa2 < xb1 or xb2 < xa1 or ya2 < yb1 or yb2 < ya1:
            print("NO")
        else:
            print("YES")
    except EOFError:
        break


Measured memory_bytes: 5584
def gen_d_prim(n):
    D = [0] * (n+1)
    for i in range(2, n+1):
        if D[i] > 0: continue
        for j in range(i, n+1, i): D[j] = i
    return D

def is_pairwise(A):
    D = gen_d_prim(10**6)
    past = set()
    for a in A:
        now = set()
        while a != 1:
            # 素数 D[a]: 今回は未済 & 過去で済
            if not D[a] in now and D[a] in past: return False
            now.add(D[a])
            past.add(D[a])
            a //= D[a]
    return True

def gcd_all(A):
    from math import gcd
    g = 0
    for a in A: g = gcd(g, a)
    return g

def solve():
    if is_pairwise(A): return 0
    if gcd_all(A) == 1: return 1
    return 2

n = int(input())
A = [*map(int, input().split())]
print(['pairwise','setwise','not'][solve()], 'coprime')


Measured memory_bytes: 126980
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
  string s,u;
  ll x,a=100,ans=0;
  cin >> x;
  while(a < x){
    a *= 1.01;
    ans++;
  }
        
  cout << ans << endl; 
  
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,X;
  cin>>N>>X;
   vector<int> L(N);
   for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
   vector<int> D(N+1);
  D[0] =0;
  int count=0;
     for (int i = 0; i < N; i++) {
              D[i+1] =D[i]+L[i];
}     
  for (int i = 0; i <= N; i++) {
if(D[i]<=X){
  count++;
}
     }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=1e9+7;
const double pi=3.1415926535;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r;
    cin>>r;
    r*=r;
    cout<<r<<'\n';



}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vi idx(n);
    rep(i, n){
        int x; cin >> x;
        x--;
        idx[x] = i;
    }

    set<int> s1 = {idx.back(), n};
    set<int> s2 = {-idx.back(), 1};

    ll res = 0LL;
    rrep(x, n-1){
        int i = idx[x];

        // left
        int p2 = -(*s2.lower_bound(-i));
        int p1 = (p2 == -1 ? -1 : (-(*s2.upper_bound(-p2))));

        // right
        int p3 = *s1.lower_bound(i);
        int p4 = (p3 == n ? n : (*s1.upper_bound(p3)));

        ll cur = 0LL;

        // including p2
        if(p2 != -1){
            cur += 1LL * (p2 - p1) * (p3 - i);
        }

        // including p3
        if(p3 != n){
            cur += 1LL * (i - p2) * (p4 - p3);
        }

        res += (x + 1) * cur;

        s1.insert(i);
        s2.insert(-i);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 9984
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        out.println((char)(in.nextChar()+1));
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 21204
#import <Foundation/Foundation.h>
#include <stdio.h>
int main() {
  
  int i, j;
  scanf("%d %d", &i, &j);
  
  int sum = i + j;
  int sub = i - j;
  int mul = i * j;
  int result = MAX(sum, sub);
  result = MAX(result, mul);
  
  printf("%d", result);
  
  return 0;
}

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

int flag[505][505];
int a[505][505];
int N, H, W;
int x[505];
int sum1, sum2;
struct Map{
	int x, y;
	Map(int i, int j) : x(i), y(j) {}
};
int main(){
	cin >> H >> W;
	for(int i = 1; i <= H; i++){
		
		for(int j = 1; j <= W; j++){
			cin >> a[i][j];	
			if(a[i][j] % 2 != 0)
			{
				x[i]++;
				sum1++;
			}
	    }
	}
	sum2 = sum1;
    int tmp = 0;
    stack<Map> sta;
    int j = 0;
    for(int i = 1; i <= H; i++){
    	//int flag = 0;
        if(tmp)
            break;
    	if(j == 0){
    		for(j; j <= W; j++){
//    			if(sum1 % 2 && sum2 <= 1){
//    				tmp = 1;
//    				break;
//				}
				if(a[i][j] % 2){
					//sum2--;
					a[i][j]--;
					if(j+1 <= W)
					{
						a[i][j+1]++;
						sta.push(Map(i, j+1));
						sta.push(Map(i, j));
					}
					else if(i+1 <= H){
						a[i+1][j]++;
						sta.push(Map(i+1, j));
						sta.push(Map(i, j));
					}
				}
			}
		}
		else{
			for(j = W; j >= 1; j--){
//    			if(sum1 % 2 && sum2 <= 1){
//    				tmp = 1;
//    				break;
//				}
				if(a[i][j] % 2){
					//sum2--;
					a[i][j]--;
					if(j-1 >= 1)
					{
						a[i][j-1]++;
						sta.push(Map(i, j-1));
						sta.push(Map(i, j));
					}
					else if(i+1 <= H){
						a[i+1][j]++;
						sta.push(Map(i+1, j));
						sta.push(Map(i, j));
					}
				}
			}
		}
	}
	cout << sta.size()/2 << endl;
	while(!sta.empty()){
		cout << sta.top().x << " " << sta.top().y << " ";
		sta.pop();
		cout << sta.top().x << " " << sta.top().y << "\n";
		sta.pop();
	}
	return 0;
}

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

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  ll MOD=1000000007;
  ll n,k;
  cin>>n>>k;
  ll a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  ll factorial[n+1];
  factorial[0]=1;
  for(int i=1;i<=n;i++){
    factorial[i]=mod(factorial[i-1]*i,MOD);   
  }
  ll pow[n+1];
  pow[n]=modpow(factorial[n],MOD-2,MOD);
  for(int i=n-1;i>=0;i--){
    pow[i]=mod(pow[i+1]*(i+1),MOD);
  }
  ll ans=0;
  for(int i=k-1;i<=n-1;i++){
    ans+=mod(a[i]*mod(factorial[i]*mod(pow[k-1]*pow[i-k+1],MOD),MOD),MOD);
  }
  for(int i=0;i<=n-k;i++){
    ans-=mod(a[i]*mod(factorial[n-1-i]*mod(pow[k-1]*pow[n-k-i],MOD),MOD),MOD);
  }
  ans=mod(ans,MOD);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,k;
    cin >> n >> k;
    int x[n];
    int answer=0;
    REP(i,n){
        cin >> x[i];
        answer += min(x[i],abs(k-x[i]));
    }
    cout << answer * 2 << endl;

    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

bool in(int64 f, int64 t, int64 x) {
	t = t - 60*(f/60); f = f%60; x = x%60;
	if (f > t) f -= 60;
	return f <= x && x <= t;
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 a, b, c;
	cin >> a >> b >> c;
	int64 now = 0;
	bool ok = 0;
	REP(i, 3600) {
		if (in(now, now+a, c)) {
			ok = 1;
			if (now%60 <= c) {
				cout << now + c-now%60 << endl;
			} else {
				cout << now + c-(now%60-60) << endl;
			}
			break;
		}
		now += a+b;
	}
	if (!ok)
		cout << -1 << endl;
}



Measured memory_bytes: 3196
#include <stdio.h>
#include <math.h>
#include <string.h>
typedef long long ll;
ll memo[105][100005], wt[100005], v[100005], vis[105][100005];

ll max(ll a, ll b)
{
    return a>b ? a : b;
}

ll solve(ll n, ll w)
{
    if(n==0 && w>=wt[0])
        return memo[n][w] = v[0];
    else if(n==0)
        return memo[n][w] = 0;
    if(vis[n][w])
        return memo[n][w];
    vis[n][w]=1;
    if(w>=wt[n])
        return memo[n][w] = max(solve(n-1, w), solve(n-1, w-wt[n])+v[n]);
    else
        return memo[n][w] = solve(n-1, w);
}

int main()
{
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    memset(memo, 0, sizeof(memo));
    memset(wt, 0, sizeof(wt));
    memset(v, 0, sizeof(v));
    memset(vis, 0, sizeof(vis));
    ll n, w;   scanf("%lld %lld", &n, &w);
    for(ll i=0; i<n; i++)
        scanf("%lld %lld", &wt[i], &v[i]);
    printf("%lld\n", solve(n-1, w));
    return 0;
}

Measured memory_bytes: 165760
#include <iostream> 
#include <vector> 
#include <algorithm> 
#include <bits/stdc++.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <functional> 
#include<math.h> 
#include<cstring>

using namespace std;
int main(void){
    // Your code here!
 int a,b,c,d;
 cin >> a >> b >> c >> d;
 int t;
 t = min(b,d) - max(a,c);
 if(t >= 0){
     cout << t << endl;
 }
 else{
     cout << 0 << endl;
 }
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=1001001001;

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> hol(n,vector<int>());
  for(int i=0; i<m; ++i){
    int a, b;
    cin >> a >> b;
    --a; --b;
    hol[a].push_back(b);
    hol[b].push_back(a);
  }
  vector<int> ans(n,INF);
  vector<bool> bef(n,false);
  queue<int> que;
  que.push(0);
  ans[0] = -1;
  while(!que.empty()){
    int x = que.front();
    que.pop();
    if(bef[x]) continue;
    bef[x] = true;
    for(int a:hol[x]){
      if(ans[a]==INF){
        //cout << a+1 << " " << x+1 << endl;
        ans[a] = x+1;
        que.push(a);
      }
    }
  }
  for(int i=0; i<n; ++i){
    if(ans[i] == INF){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for(int i=1; i<n; ++i){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 10124
#include<bits/stdc++.h>
#define F first
#define S second
#define REP(i, a, b, c) for(int i = a; i <= b; i+=c)
#define pb push_back
#define int long long int
#define MOD 1000000007
using namespace std;

/*class Graph {

  map<int, list<pair<int, int> > > l;

public:
  void addEdge(int x, int y, int cost) {
    l[x].pb(make_pair(y, cost));
    l[y].pb(make_pair(x, cost));
  }

  int dfs_helper(int n, int node, map<int, int> &vis, map<int, int> &count, int &ans) {
    //cout << node << " " ;
    vis[node] = 1;
    count[node] = 1;
    for (auto m : l[node]) {
      if (!vis[m.F]) {
        vis[m.F] = 1;
        count[node] += dfs_helper(m.F, vis, count, ans);
        ans += 2 * min(count[node], n - count[node]) * m.S.S;
      }
    }
    return count[node];
  }

  void dfs() {
    map<int, int> vis;
    map<int, int> count;
    int ans = 0;
    dfs_helper(0, vis, count, ans);
    cout << ans << endl;
  }

};*/

int dp[100005];

int f(int a[], int i, int n)
{
  //cout << i << endl;
  if (i == (n - 1))
    return 0;
  if (i >= n)
    return INT_MAX;
  if (dp[i] != -1)
    return dp[i];
  int ans1, ans2;
  ans1 = ans2 = INT_MAX;
  if (i + 1 <= n - 1)
    ans1 = abs(a[i] - a[i + 1]) + f(a, i + 1, n);
  if (i + 2 <= n - 1)
    ans2 = abs(a[i] - a[i + 2]) + f(a, i + 2, n);
  return dp[i] = min(ans1, ans2);

}


int32_t main()
{
  ios :: sync_with_stdio(false); cin.tie(0);
  int t = 1;
  //cin >> t;
  for (int i9 = 1; i9 <= t; i9++)
  {
    /* Graph G;
     int n, x, y, cost;
     cin >> n;
     while (n--) {
       cin >> x >> y >> cost;
       G.addEdge(x, y, cost);
     }
     G.dfs();*/
    //freopen("ouputnew.txt", "w", stdout);
    //flclose(stdout);
    memset(dp, -1 , sizeof (dp));
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
      cin >> a[i];
    cout << f(a, 0, n);
  }
}



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

int main(){
  int a,b,c,d;cin>>a>>b>>c;
  d=max({a,b,c});
  if(d==a)d=a*10+b+c;
  else if(d==b)d=b*10+a+c;
  else d=c*10+a+b;
  cout<<d;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

    public static void main(String[] args) throws IOException {
        // write your code here

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        String s = reader.readLine();
        String[] inp = s.split(" ");

        int a,b;
        a=Integer.parseInt(inp[0]);
        b=Integer.parseInt(inp[1]);

        if((a>=1 && a<=9) && (b>=1 && b<=9))
        {
            System.out.println(a*b);
        }
        else
        {
            System.out.println("-1");
        }
    }
}


Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).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; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

typedef std::pair<ll,ll> P;

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N, M; std::cin >> N >> M;
  std::vector<P> student(N), point(M);
  rep(i,N) std::cin >> student[i].first >> student[i].second;
  rep(i,M) std::cin >> point[i].first >> point[i].second;

  for(int i=0; i<N; i++) {
    int index = 0;
    ll smin = 1e15;
    for(int j=0; j<M; j++) {
      ll dis = std::abs(student[i].first-point[j].first)+std::abs(student[i].second-point[j].second);
      if ( smin > dis ) {
        smin = dis;
        index = j;
      }
    }
    std::cout << index+1 << std::endl;
  }

  return 0;
}


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

int main()
{
    int N; cin >> N;
    auto sizes = vector<int>(N);
    for (auto& x : sizes) cin >> x;
    sort(begin(sizes), end(sizes));

    auto prefix_sum = accumulate(begin(sizes), end(sizes), 0LL);

    auto result = 1;
    for (auto i = N-2; i >= 0; i--)
    {
        prefix_sum -= sizes[i+1];
        if (2*prefix_sum < sizes[i+1]) break;
        else result++;
    }
    cout << result << endl;
}


Measured memory_bytes: 640
n,m = map(int,input().split())
mod = 10**9 + 7
import math
def perm(n, r):
    return (math.factorial(n) // math.factorial(n - r))%mod

if abs(n-m) >= 2:
    print(0)
else:
    mx = max(n,m)
    mn = min(n,m)
    p = math.factorial(mn)%mod
    k = (mn-1)*math.factorial(mx)%mod if mn == mx else 0
    print(p*(perm(mn+1,mx) - k)%mod)


Measured memory_bytes: 51056
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
const int INF = 1e9;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
//typedef pair<int, int> P;

/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */


/** 幾何ライブラリ **/
#include <complex>

#define X real()
#define Y imag()

const double EPS = 1e-11;
const double PI = acos(-1.0);

typedef double D;
typedef complex<D> P; // Point


/** Problem1136 : Polygonal Line Search **/
typedef vector<P> PS;

bool eq(PS a, PS b)
{
	if (a.size() != b.size()) return false;
	
	bool res1=true, res2=true;
	
	for (int i=0; i<a.size(); i++) {
		if (a[i] != b[i])
			res1 = false;
	}
	
	reverse(ALL(b));
	
	for (int i=0; i<a.size(); i++) {
		if (a[i] != b[i])
			res2 = false;
	}
	
	return res1 | res2;
}


int main()
{
	int N;
	while (cin>>N, N) {
		vector<PS> poly(N+1);
		
		rep(i, N+1) {
			int M; cin>>M;
			rep(j, M) {
				P p; cin>>p.X>>p.Y;
				poly[i].push_back(p);
			}
		}
		
		PS target;
		for (int i=1; i<poly[0].size(); i++) {
			target.push_back(poly[0][i]-poly[0][i-1]);
		}
		
		for (int i=1; i<=N; i++) {
			PS tmp;
			for (int j=1; j<poly[i].size(); j++) {
				tmp.push_back(poly[i][j]-poly[i][j-1]);
			}
			
			rep(j, 4) {
				if (eq(target, tmp)) {
					cout << i << endl;
					goto next;
				}
				
				rep(k, tmp.size()) {
					tmp[k] *= P(0, 1);
				}
			}
					
			next:;
		}
		cout << "+++++" << endl;
	}
}

Measured memory_bytes: 1252