akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_Poor_155
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long a = inputLongArray[0];
            long b = inputLongArray[1];
            long c = inputLongArray[2];

            string result = "";

            if (a == b && b == c || a != b && b != c && c != a)
            {
                result = "No";
            }
            else
            {
                result = "Yes";
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27912
use proconio::{fastout, input, marker::Chars};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        n: usize,
        s: Chars
    }
    let mut res = 0;
    for i in 0..1000 {
        let t = digit(i);

        let mut now = 0;
        for j in 0..n {
            if s[j] == t[now] {
                now += 1;
                if now == 3 {
                    break;
                }
            }
        }

        if now == 3 {
            res += 1;
        }
    }
    println!("{}", res);
}

fn digit(i: usize) -> Vec<char> {
    let mut res = vec![];
    let i = i.to_string();
    let len = 3 - i.len();
    for _ in 0..len {
        res.push('0');
    }
    i.chars().for_each(|c| res.push(c));
    res
}


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

int main() {
  
  int N;
  cin >> N;
  int n = N;
  int x = 0;
  
  for (int i = 0; i < N; i++) {
    x += n%10;
    n /= 10;
    
    if (n == 0) {
      break;
    }
  }
  if (N%x == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#define MAXSIZE 100
#define PI 3.141592653589
using namespace std;
int main(){

  while (1) {
    int m,f,r;
    std::cin >> m>>f>>r;
    if(-1==m&&-1==f&&-1==r){
      break;
    }else if(-1==m||-1==f){
      std::cout << "F" << '\n';
    }else if(80<=m+f){
      std::cout << "A" << '\n';
    }else if(65<=m+f){
      std::cout << "B" << '\n';
    }else if(50<=m+f){
      std::cout << "C" << '\n';
    }else if(30<=m+f&&50>r){
      std::cout << "D" << '\n';
    }else if(30<=m+f){
      std::cout << "C" << '\n';
    }else {
      std::cout << "F" << '\n';
    }
  }
}

Measured memory_bytes: 3080
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> b(n);
    rep(i,n) cin >> b[i];
    map<int,int> mp;
    rep(i,n){
        mp[a[i]]++;
        mp[b[i]]++;
    }
    for(auto x:mp){
        if(x.second >= n+1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    map<int,int> sss;
    map<int,vector<int> > p;
    rep(i,n){
        if(a[i]==b[i]){
            sss[a[i]]++;
            p[a[i]].push_back(i);
        }
    }
    int mx = 0;
    int mxid = -1;
    for(auto x:sss){
        if(chmax(mx,x.second)){
            mxid = x.first;
        }
    }
    if(mxid!=-1){
        int id = 0;
        for(auto x:p){
            if(x.first==mxid)continue;
            auto A = x.second;
            rep(i,A.size()){
                swap(b[A[i]],b[p[mxid][id%mx]]);
                id++;
            }
        }
        if(id < mx){
            vector<int> tmp;
            rep(i,n){
                if(a[i]!=mxid&&b[i]!=mxid){
                    tmp.push_back(i);
                }
            }
            rep(i,tmp.size()){
                if(id==mx)break;
                swap(b[p[mxid][id]],b[tmp[i]]);
                id++;
            }
        }
    }
    rep(i,n){
        cout << b[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 45300
N=int(input())
A=list(map(int,input().split()))
abc=[0,0,0]#1,2,3個の寿司が載っている皿の枚数
for i in A:
    abc[i-1]+=1
    
total=sum(A)

#1,2,3個の寿司が載っている皿の枚数がi,j,kから全てを取るのに必要な期待値
dp=[[[0.0]*(N+1) for _ in range(N+1)] for i in range(N+1)]



for k in range(abc[2]+1):#3枚の皿は初期枚数から増えない
    for j in range(abc[2]+abc[1]+1-k):#2枚の皿の枚数は，3枚の皿が減った枚数に依存
        for i in range(sum(abc)+1-j-k):
            if i==0 and j==0 and k==0:
                continue
            if i-1>=0:
                dp[i][j][k]+=dp[i-1][j][k]*i
            if j-1>=0:
                dp[i][j][k]+=dp[i+1][j-1][k]*j
            if k-1>=0:
                dp[i][j][k]+=dp[i][j+1][k-1]*k
            dp[i][j][k]+=N
            dp[i][j][k]/=(i+j+k)

print(dp[abc[0]][abc[1]][abc[2]])




Measured memory_bytes: 254472
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;

const int N=117;

int n,ans,cnt,f[N],ss[N];

char s[N];

int main()
{
	scanf("%s",s);
	n=strlen(s);
	int all=(1<<26)-1;
	for(int i=0;i<n;i++)
		ss[i]=1<<(s[i]-'a');
	for(int i=0;i<n-1;++i)
	if(s[i]!=s[i+1])
		goto dsf;
		cout<<0;
	return 0;
	dsf:;
	int i;
	for(i=0;i<n;i++)
	{
		int k=all,flag=false;
		for(int j=1;j<=24;++j)
		{
			bool flag=1;
			for(int t=0;t<=n-i-1;++t)
			if((ss[t]&(1<<(j-1)))==0)
			{
				flag=0;break;
			}
			if(flag)goto a;
		}
		for(int j=0;j<n-i+1;j++)
			ss[j]=ss[j]|ss[j+1];
	}
	a:;
	cout<<i;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 101

int main(){

  int n,Adj[N][N],i,j,s,t,u;
  int G[N][N];

  scanf("%d",&n);

 for(i=1 ; i<=n ; i++){
    for(j=1 ; j<=n ; j++){
      G[i][j]=0;
    }
  }

 for(i=1 ; i<=n ; i++){
   scanf("%d %d",&s, &t);
   for(j=0 ; j<t ; j++){
     scanf("%d",&u);
     G[i][u]=1;
   }
 }



  for(i=1 ; i<=n ; i++){
    for(j=1 ; j<=n ; j++){
      printf("%d",G[i][j]);
      if(j<n)printf(" ");
    }
    printf("\n");
  }

  return 0;

}

Measured memory_bytes: 640
h, w = map(int, input().split())
if h == 1 or w == 1:
    print(1)
    exit()

if h % 2 == 0 or w % 2 == 0:
    print(h*w//2)
else:
    if h <= w:
        a = (w-1)*h//2
        b = (h+1)//2
    else:
        a = (h-1)*w//2
        b = (w+1)//2
    print(a+b)


Measured memory_bytes: 38384
import java.util.*;
class Main{
	public static void main(String args[]){
		int n = 3;
		int i;
		Scanner scan = new Scanner(System.in);
		StringBuffer sb = new StringBuffer();
		i = scan.nextInt();
		while(true){
			if(i < n){
		        break;
			}
			if(n % 3 == 0 || Integer.toString(n).contains("3")){
				System.out.printf(" " + n);
			}
			n++;
		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 31080
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define ws(x) scanf("%d",&x);getchar();while(x--)
#define rep(i,b) for(i=0;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

long long  mod=1e9+9;
const int N=1e6+2;
int t,j,cs=0,n,a,b,i;
string s;

int main()
{
    cin>>a>>n;
    int ar[n];
    bool bl[103]={};
    for(i=0;i<n;i++){
        cin>>ar[i];
        bl[ar[i]]=1;
    }
    i=a,j=a;
    while(bl[i]&&bl[j]){
        i++;j--;
    }
    if(bl[j]==false){
        cout<<j<<endl;
    }
    else
        cout<<i<<endl;
}




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

#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define inf (long long int) 1e18
#define vl vector<ll> 
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define mod 1000000007
ll gcd(ll a,ll b);
ll palindrome(string s);
ll modexp(ll a,ll b,ll m);

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

    ll n;
    cin>>n;
    ll i;
    cin>>i;
    cout<<n-i+1<<endl;

}

ll gcd(ll a, ll b){
    if (a == 0)   return b;
    if(b==0)      return a;
    if (a == b)   return a;
    if (a > b)    return gcd(a%b, b);
    return gcd(a, b%a);
}

ll palindrome(string s){
    ll l = 0;
    ll h = s.length() - 1;
    while (h > l){
        if (s[l++] != s[h--]){
            return 0;
        }
    }
    return 1;
}

ll modexp(ll a, ll b, ll m){
    if (b==0)
        return 1;
    ll temp = modexp(a,b/2,m);
    temp = (temp*temp)%m;
    if (b&1)
        return (temp*(a%m))%m; // if b is odd a^b = a^(b/2)*a^(b/2)*a
    return temp;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int arr[1000];
int main(){
  fastIO
 int n,k,a,sn,ans=0;
  cin>>n>>k;
  
  for(int i=0;i<k;i++)
  {
    cin>>sn;
    for(int j=0;j<sn;j++)
    {
      cin>>a;
      arr[a]++;
    }
  }
  for(int i=1;i<=n;i++)
  {
    if(arr[i]==0)
      ans++;
  }
  cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (int) __builtin_popcount(x);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

const ll MAX = 2e5+6;
const ll inf = 5e18;


ll dp[22][(1<<21) + 5],a[22][22],mod=1e9+7;
int main(){
    fastio;
    ll n;
    cin>>n;
    f(i,1,n+1) f(j,1,n+1) cin>>a[i][j];
    ll x=(1<<n);
    dp[0][0]=1;
 //   cout<<(1<<21)<<endl;
    f(i,1,n+1){
        f(j,1,x){
            ll x=1,y=j;
            f(k,0,n){
                if(__builtin_popcount(j)==i && y&1 && a[n-k][i]){

                    dp[i][j] += a[n-k][i]*(dp[i-1][j-x]);
                    dp[i][j] = dp[i][j]%mod;
                }
                x<<=1,y>>=1;
             //   cout<<j<<" "<<(j>>k)<<" "<<((j>>k)&1)<<endl;
            }
        }
    }
  //  cout<<dp[1][2]<<dp[1][1]<<endl;
    cout<<dp[n][x-1]<<endl;
}

Measured memory_bytes: 309504
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int w;
    while(cin >> w, w != -1){
        int bill = 0, ans = 4280;
        if(w < 10){
            bill += 1150;
        }
        else if(w >= 10 && w < 20){
            bill += 1150;
            bill += (125 * (w - 10));
        }
        else if(w >= 20 && w < 30){
            bill += 1150;
            bill += (125 * 10);
            bill += (140 * (w - 20));
        }
        else if(w >= 30){
            bill += 1150;
            bill += (125 * 10);
            bill += (140 * 10);
            bill += (160 * (w - 30));
        }
        cout << ans - bill  << endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int h, w, n;
	cin >> h >> w >> n;
	vector<int> a;
	vector<int> b;
	a.resize(n);
	b.resize(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i] >> b[i];
	}
	map<pair<int, int>, int> cnt;
	for(int i = 0; i < n; ++i) {
		int x = a[i], y = b[i];
		for(int dx = -1; dx < 2; ++dx) {
			for(int dy = -1; dy < 2; ++dy) {
				++cnt[{x + dx, y + dy}];
			}
		}
	}
	vector<long long> ans;
	ans.resize(10);
	for(auto it : cnt) {
		auto x = it.first.first;
      	auto y = it.first.second;
		auto grid = it.second;
		if(x > 1 && x < h && y > 1 && y < w) {
			++ans[grid];
		}
	}
	ans[0] = 1LL * (h - 2) * (w - 2);
	for(int i = 1; i < 10; ++i) {
		ans[0] -= ans[i];
	}
	for(int i = 0; i < 10; ++i) {
		cout << ans[i] << '\n';
	}
	return 0;
}


Measured memory_bytes: 57344
#include <bits/stdc++.h>
using namespace std;
#define maxn 650
const int mod= 1e9+7;
int a[maxn], b[maxn], act[maxn], cnt, mark[maxn];
long long int dp[maxn][maxn/2][maxn/2];
long long int add (long long int x, long long int y){
	long long int z= x+y;
	z%=mod;
	if (z<0) z+=mod;
	return z;
}
set <int> s;
long long int fact[maxn];
int main(){
	int n;
	cin>>n;
	for (int i=1; i<=2*n; i++) {
		cin>>a[i];
		s.insert(i);
	}
	for (int i=1; i<=n; i++){
		if (a[2*i]!=-1 and a[2*i-1]!=-1) {
			s.erase(s.find(a[2*i]));
			s.erase(s.find(a[2*i-1]));
		}
	}
	if (s.empty()){
		cout<<1<<endl;
		return 0;
	}
	fact[0]=1;
	for (int i=1; i<maxn; i++){
		fact[i]= (1LL*i*fact[i-1])%mod;
	}
	int cur=1;
	for (set<int>::iterator it= s.begin(); it!=s.end(); it++){
		int t= *it;
		b[t]= cur;
		cur++;
	}
	int ind=1;
	for (int i=1; i<=n; i++){
		if (a[2*i]!=-1 and a[2*i-1]!=-1) continue;
		if (a[2*i-1]==-1) act[ind]= -1;
		else act[ind]= b[a[2*i-1]];
		ind++;
		if (a[2*i]==-1) act[ind]= -1;
		else act[ind]= b[a[2*i]];
		ind++;
	}
	n= ind/2;
	for (int i=1; i<=2*n; i++){
		if (act[i]!=-1){
			mark[act[i]]=1;
			cnt++;
		}
	}	
	if (mark[1]){
		dp[1][0][1]=1;
	}
	else{
		dp[1][1][0]=1;
		dp[1][0][1]=1;
	}
	for (int i=1; i<=2*n; i++){
		for (int j=0; j<=n; j++){
			for (int k=0; k<=n; k++){
				if (!mark[i+1]){
					dp[i+1][j][k+1]= add(dp[i][j][k], dp[i+1][j][k+1]);
					dp[i+1][j+1][k]= add(dp[i][j][k], dp[i+1][j+1][k]);
					if (k>0) dp[i+1][j][k-1]= add(dp[i][j][k], dp[i+1][j][k-1]);
				}
				else{
					dp[i+1][j][k+1]= add(dp[i][j][k], dp[i+1][j][k+1]);
					if (j>0) dp[i+1][j-1][k]= add(dp[i+1][j-1][k], (1LL*j*dp[i][j][k])%mod);	
				}

			}
		}
	}
	long long int ans= dp[2*n][0][0]*fact[n-cnt]%mod;
	if (ans<0) ans+=mod;
	cout<<ans<<endl;
	return 0;




}

Measured memory_bytes: 496256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, t;
    cin >> a >> b >> t;
    int f = t / a;

    cout << f * b << endl;
}

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

using namespace std;

#define INF 1e9

int n,m;
int d[100010];

struct edge{int to,cost;};

vector<edge> G[100010];

void dfs(int pos1,int pos2){
    for(int i=0;i<G[pos1].size();i++){
        int next=G[pos1][i].to;
        if(d[next]!=INF || next==pos2)continue;
        d[next]=d[pos1]+G[pos1][i].cost;
        dfs(next,pos1);
    }
}

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

    cin>>n>>m;

    vector<int> l(m),r(m),c(m);

    for(int i=0;i<m;i++){
        cin>>l[i]>>r[i]>>c[i];
        l[i]--;r[i]--;
        G[l[i]].push_back(edge{r[i],c[i]});
        G[r[i]].push_back(edge{l[i],-c[i]});
    }
    
    for(int i=0;i<n;i++)d[i]=INF;

    for(int i=0;i<n;i++){
        if(d[i]!=INF)continue;
        d[i]=0;
        dfs(i,-1);
    }

    bool ans=true;

    for(int i=0;i<m;i++){
        if(d[r[i]]-d[l[i]]!=c[i])ans=false;
    }

    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 16256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

int main(){
  ll n, k;
  cin >> n >> k;
  vector<ll> vec(n);

  rep(i, n)cin >> vec[i];

  sort(vec.begin(), vec.end(), greater<ll>()); // 降順ソート

  rep(i, min(n, k)) vec[i] = 0;

  ll ans = accumulate(vec.begin(), vec.end(), 0LL);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
my $N = glob <>;
my $t0 = $N/1.08;
my $t1 = ($N+1)/1.08;
my $tmp0 = int($t0);
my $tmp1 = $tmp0 + 1;
if ( $tmp0 == $t0 ) {
  print $tmp0;
} elsif ( $tmp1 < $t1 ) {
  print $tmp1;
} else {
  print ':(';
}

Measured memory_bytes: 768
<?php
list($n, $m, $v, $p) = ints();
$a = ints();
rsort($a);
//o($a);
$min = 0;
$max = $n-1;
while($max > $min){
    $mid = floor(($min + $max+1) / 2);
//    o($min, $max, $mid);
    if(isOK($mid)){
        $min = $mid;
//        o("ok");
    }else{
        $max = $mid-1;
//        o("ng");
    }
}

echo $max+1;
function isOK($k){
    global $a, $m, $v, $n, $p;
//    o($k,$a[$k]);
    $minusable = ($n-$v) * $m;
    $over = 0;
//    o($minusable);
    for($i = $k-1; $i >= $p-1; $i--){
        $o = $a[$i] - $a[$k];
        if($o > $m){
            return false;
        }
        $over += $o; 
//        o("over=".$over);
        if($over>$minusable){
            return false;
        }
    }
    return true;
}


function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

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

using lli = long long int;

using namespace std;

int main() {
    lli N, W;
    cin >> N >> W;

    std::vector<lli> w(N), v(N);
    lli max_v = 0;
    for (lli i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
        max_v += v[i];
    }

    const lli inf = 1ll << 60;

    std::vector<std::vector<lli>> dp(N + 1, std::vector<lli>(max_v + 1, inf));

    dp[0][0] = 0;

    for (lli i = 0; i < N; ++i) {
        for (lli dpv = 0; dpv <= max_v; ++dpv) {
            if (dpv - v[i] >= 0) {
                dp[i + 1][dpv] = std::min(dp[i + 1][dpv], dp[i][dpv - v[i]] + w[i]);
            }
            dp[i + 1][dpv] = std::min(dp[i + 1][dpv], dp[i][dpv]);
        }
    }

    lli ans = 0;
    for (lli dpv = 0; dpv <= max_v; ++dpv) {
        if (dp[N][dpv] <= W) { ans = dpv; }
    }
    cout << ans << endl;

    return 0;
}


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

int gcd(int x, int y){
    if (y == 0)
        return x;
    x = x % y;
    gcd(y, x);
}

main(){
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    rep(i,n) cout<<s[i]<<t[i];
    cout<<endl;
}

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

const ll INF = 1LL << 60;

ll N, T;
// vector<ll> A, B;

vector<P> v;

// i: 何個目
// j: 注文した時間

ll dp[3010][6020];
int main() {
    cin >> N >> T;
    v.resize(N);

    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        v[i] = P(a, b);
    }

    sort(v.begin(), v.end());

    ll ans = 0;

    // i 番目を最後とする
    for (int i = 0; i < N; i++) {

        // T 未満だったら、次の料理が選べる
        for (int j = 0; j < T; j++) {
            // 選ばない
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);

            // 選ぶ
            dp[i + 1][j + v[i].first] = max(dp[i + 1][j], dp[i][j] + v[i].second); 
        }

        ans = max(ans, dp[i][T - 1] + v[i].second);
    }

    cout << ans << endl;
}

Measured memory_bytes: 144748
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

class UnionFind
{
    vector<int> par;

public:
    UnionFind(int n) : par(n, -1) {}

    int root(int x)
    {
        if (par[x] < 0)
            return x;
        else
            return par[x] = root(par[x]);
    }

    inline bool same(int u, int v)
    {
        return root(u) == root(v);
    }

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

    int size(int x) { return -par[root(x)]; }
};

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    akari<pair<int, int>> as(n), bs(n);
    for (int i = 0; i < n; i++)
    {
        cin >> as[i].first;
        as[i].second = i;
    }
    for (int i = 0; i < n; i++)
    {
        cin >> bs[i].first;
        bs[i].second = i;
    }
    sort(as.begin(), as.end());
    sort(bs.begin(), bs.end());
    UnionFind uf(n);
    for (int i = 0; i < n; i++)
    {
        if (as[i].first > bs[i].first)
        {
            cout << "No" << endl;
            return;
        }
        uf.merge(as[i].second, bs[i].second);
    }
    for (int i = 0; i < n - 1; i++)
    {
        if (as[i].first <= bs[i + 1].first && as[i + 1].first <= bs[i].first)
        {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << (uf.size(0) != n ? "Yes" : "No") << endl;
}

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


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int h, w;
    cin >> h >> w;
    vvint c(10, vint(10));
    vvint a(h, vint(w));
    rep(i, 10) rep(j, 10) cin >> c[i][j];
    rep(i, h) rep(j, w) cin >> a[i][j];


    rep(k, 10) rep(i, 10) rep(j, 10) {
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    }

    ll ans = 0;
    rep(i, h) rep(j, w) {
        if (a[i][j] == -1) continue;
        ans += c[a[i][j]][1];
    }


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

Measured memory_bytes: 384
import numpy as np
n=int(input())
x=list(map(int,input().split(' ')))
x1=x[:]
x.sort()
m1=x[int(n/2)-1]
m2=x[int(n/2)]
for i in range(n):
    now=x1[i]
    if x1[i]<=m1:
        print(m2)
    else:
        print(m1)


Measured memory_bytes: 34188
#include <bits/stdc++.h>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値));
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2));  // 初期値を省略


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string ts="test";
	
	int n; cin >> n;
	
	vector<int> a(n); rep(i,n) cin >>a[i];

	int mn=200001;
	
	
	int c=0;
	
	rep(i,n) if(chmin(mn,a[i])) c++;
	
	
	cout << c << endl;
	
	return 0;
}



Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string a[10000];
    int n,t;
    cin >> n >> t;
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    sort(a,a+n);
    for(int i = 0;i < n;i++)
    {
        cout << a[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
let cnt = ref 0

let insertion_sort (a : int array) n g =
  for i = g to n - 1 do
    let v = a.(i) in
    let j = ref (i - g) in
    while !j >= 0 && a.(!j) > v do
      a.(!j+g) <- a.(!j);
      j := !j - g;
      incr cnt;
    done;
    a.(!j+g) <- v;
  done

let generate_g n =
  let rec doit i g acc =
    if g > n then acc
    else doit (i + 1) (int_of_float (4.**(float_of_int i) +. 3.*.2.**(float_of_int (i - 1)) +. 1.)) (g :: acc) in
  doit 1 1 []

let shell_sort (a : int array) n =
  cnt := 0;
  let g = generate_g n in
  List.iter (fun g -> insertion_sort a n g) g;
  g

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> read_int ()) in
  let g = shell_sort a n in
  Printf.printf "%d\n" (List.length g);
  List.iteri (fun i n -> (if i = 0 then Printf.printf "%d" else Printf.printf " %d") n) g;
  print_newline ();
  Printf.printf "%d\n" !cnt;
  Array.iter (fun n -> Printf.printf "%d\n" n) a

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

using std::pair;
using std::vector;
using std::string;

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

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

const int N = 200000;

int fa[N + 5];
int find(int x) {
    return (fa[x] == x) ? x : fa[x] = find(fa[x]);
}

int a[N + 5], n, m;
vector<int> v[N + 5], all;

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    read(n), read(m);
    for(int i = 0; i < n; ++i) fa[i] = i;
    for(int i = 0; i < n; ++i) read(a[i]);
    for(int i = 0; i < m; ++i) {
        static int x, y;
        read(x), read(y);
        fa[find(x)] = find(y);
    }

    int c = 0;
    ll ans = 0;

    for(int i = 0; i < n; ++i) {
        v[find(i)].pb(a[i]);
        if(find(i) == i) ++ c;
    }
    if(c == 1) return !puts("0");

    for(int i = 0; i < n; ++i) if(find(i) == i) {
        std::sort(v[i].begin(), v[i].end());

        ans += v[i][0];
        for(int j = 1; j < (int) v[i].size(); ++j) { all.pb(v[i][j]); }
    }

    if((int) all.size() < c - 2) {
        puts("Impossible");
    } else {
        std::sort(all.begin(), all.end());
        for(int i = 0; i < c - 2; ++i) ans += all[i];
        printf("%lld\n", ans);
    }

    return 0;
}


Measured memory_bytes: 9472
from collections import deque
N = int(input())
X = [list(map(int, input().split())) for _ in range(N - 1)]

tree = [[] for _ in range(N)]
for n, (i, j) in enumerate(X):
    tree[i - 1].append((n, j - 1))

q = deque()
q.append((0, 0))
ans = [0] * (N - 1)

while len(q) > 0:
    # u: node number, c: color
    u, c = q.popleft()
    
    cnt = 1
    for i, (n, v) in enumerate(tree[u]):
        if cnt == c:
            cnt += 1

        ans[n] = cnt
        q.append((v, cnt))
        cnt += 1
        
print(max(ans))
print(*ans, sep="\n")


Measured memory_bytes: 83160
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;

int main(){
    ll n,a,b,c;
    cin>>n>>a>>b>>c;
    cout<<n-a-b+c<<endl;
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s; cin >> s;
	if(s[0] != 'A') cout << "WA" << endl;
	else {
		bool ok = false;
		for (int i = 2; i < s.size()-1; i++)
		{
			if(s[i] == 'C') ok = true;
		}
		if(!ok) cout << "WA" << endl;
		else {
			int c = 0;
			for (int j = 0; j < s.size(); j++)
			{
				if(s[j] >= 'A' && s[j] <= 'Z')
					c++;
			}
			if(c != 2) cout << "WA" << endl;
			else cout << "AC" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

	int S;
	
	scanf("%4d", &S);
	
	if((S/100 <= 12 && S/100 >= 1)&&(S % 100 < 1  || S % 100 > 12))
	{
		printf("MMYY");
	} else if((S/100 < 1 || S/100 > 12)&&(S % 100 <= 12  && S % 100 >= 1))
	{
		printf("YYMM");
	} else if( S/100 <=12  && S/100 >= 1 && S % 100 <= 12  && S % 100 >= 1)
	{
		printf("AMBIGUOUS");
	} else {
		printf("NA");
	}


	return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

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

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);


  string s;
  cin >> s;

  int m = 0;
  for (auto c: s) {
    int x = c-'0';
    m += x;
    m %= 9;
  }

  if (m%9==0) {
    cout<< "Yes\n";
  } else cout << "No\n";
}

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

int main(){
  string s;
  cin >> s;
  int ans=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='o'){
      ans++;
    }
  }
  if((15-s.size())+ans>=8){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll x, y;
  cin >> x >> y;
  ll ans;
  if(y > 0) {
    if(x <= -y)
      ans = -y - x + 1;
    else if(x < 0)
      ans = y + x + 1;
    else if(x <= y)
      ans = y - x;
    else
      ans = -y + x + 2;
  } else if(y == 0) {
    if(x < 0)
      ans = -x;
    else
      ans = x + 1;
  } else {
    if(x <= y)
      ans = y - x;
    else if(x < 0)
      ans = -y + x + 2;
    else if(x <= -y)
      ans = -y - x + 1;
    else
      ans = y + x + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b; 
cin >> a >> b; 
if(a < b)
  cout << "a < b" << endl; 
else if(a > b)
  cout << "a > b" << endl;
else if(a == b)
  cout << "a == b" << endl;
}


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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) ( ((x)&1)==0?0:1 )
#define SIGN(x) ( ((x) > 0) - ((x) < 0)  )
#define dbg(x) cerr << #x"= " << x << endl

std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}
const int N=2E5+1;
ll f[N];

ll cr(int a,int b){
    if (a==b || b==0) return 1;
    if (b==1 || b+1==a) return a;
    return (f[a] * powmod(f[a-b]*f[b],MOD-2,MOD)) %MOD;
}
int main() {
    READ(0);
    int n,k;cin>>n>>k;
    f[0]=f[1]=1;
    for(int i=2;i<=n;++i) f[i] = (f[i-1]*i)%MOD;
    ll ret=1;
    for(int m=1;m<min(k+1,n);++m){
        ret += (cr(n,m)*cr(n-1,m))%MOD;
        if (ret>=MOD) ret -= MOD;
    }
    cout << ret;

    return 0;
}



Measured memory_bytes: 1792
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

int a[M+5];
vector<int>adj[M+7];
bool dfs(int u,int par)
{
    int sum=0;
    int big=0;
    for(auto v:adj[u])
    {
        if(v==par)continue;
        if(!dfs(v,u))return false;
        sum+=a[v];
        big=max(big,a[v]);
    }
    if(adj[u].size()==1)return true;
    int gap=2*a[u]-sum;
    big=max(big,gap);
    if(gap>=0 && big<=a[u])
    {
        a[u]=gap;
        return true;
    }
    else return false;
}
 main()

{
    fast
    int n;
    cin>>n;
    f(i,1,n)
    {
        cin>>a[i];
    }
    if(n==2)
    {
        if(a[1]==a[2])
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
        return 0;
    }
    f(i,1,n-1)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    for(int i=1;i<=n;i++)
    {
        if(adj[i].size()<=1)continue;
        if(dfs(i,-1) && a[i]==0)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
        return 0;
    }

}













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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

int main(){
  int n, ans;
  cin >> n;

  if(n < 105){
    ans = 0;
  }else if(n< 135){
    ans = 1;
  }else if(n< 165){
    ans = 2;
  }else if(n< 189){
    ans = 3;
  }else if(n< 195){
    ans = 4;
  }else{
    ans = 5;
  }

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


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <unordered_set>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

using namespace std;

int main(void) {
  ll a, b, k;
  cin >> a >> b >> k;
  ll t = min(a, k);
  cout << a-t << " " << max(0LL, b-(k-t)) << endl;
  return 0;
}


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

#define ll long long
#define ull unsigned long long 

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

    int ans = 0;
    ans = max(ans, a[0]+a[1]);
    ans = max(ans, a[1e5]+a[1e5-1]+a[1e5+1]);
    for(int i=1; i<1e5; ++i){
        ans = max(ans, a[i]+a[i-1]+a[i+1]);
    }
    cout << ans;
}

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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pint;
typedef tuple<int, int, int> tint;

const int N = 3000 + 5;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

int g[N][N];
ll f[N][N][4];

int main() {
	ios::sync_with_stdio(0);

	int n, m, lim;
	cin >> n >> m >> lim;
	for (int i = 1; i <= lim; i++) {
		int x, y, w;
		cin >> x >> y >> w;
		g[x][y] = w;
	}

	for (int i = 0; i <= n + 1; i++)
		for (int j = 1; j <= m; j++)
			for (int c = 0; c <= 3; c++) {
				if (j < m) {
					f[i][j + 1][c] = max(f[i][j + 1][c], f[i][j][c]);
					if (c < 3)
						f[i][j + 1][c + 1] = max(f[i][j + 1][c + 1], f[i][j][c] + g[i][j + 1]);
				}
				if (i <= n) {
					f[i + 1][j][0] = max(f[i + 1][j][0], f[i][j][c]);
					f[i + 1][j][1] = max(f[i + 1][j][1], f[i][j][c] + g[i + 1][j]);
				}
			}

	ll ans = 0;
	for (int c = 0; c <= 3; c++)
		ans = max(ans, f[n + 1][m][c]);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 320608
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=9e18;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

//ここまでライブラリ

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  lin(N);
  vector<P> rob(N);
  rep(i,N){
    lin(x); lin(l);
    rob[i].second = x - l;
    rob[i].first = x + l;
  }
  sort(all(rob));
  ll now = -INF;
  ll res = N;
  rep(i,N){
    if(now <= rob[i].second)
      now = rob[i].first;
    else
      res--;
  }
  
  cout << res << endl;
}

Measured memory_bytes: 1792
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
b = []
m = 2
x = a[0]
for i in range(1,n):
    if a[i] == x:
        b.append(x)
        m -= 1
        if m == 0:
            break
        x = -1
    else:
        x = a[i]
if len(b) < 2:
    print(0)
else:
    print(b[0]*b[1])


Measured memory_bytes: 14672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 2e18
#define h_p 1110111110111;
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//_______________________________________________________________________________
const int N = five;
vector<int> dp[N];
int h[N];
int main()
{
       int n,m;
       cin>>n>>m;
       arrin(h,n);
       fri(i,0,m)
       {
              int x,y;
              cin>>x>>y;
              --x;--y;
              dp[x].pb(y);
              dp[y].pb(x);
       }
       int ans = 0;
       fri(i,0,n)
       {
              bool ff = true;
              for(int j : dp[i])
              {
                     if(h[j] >= h[i])
                     {
                            ff = false;
                     }
              }
              ans += (ff == true);
       }
       cout<<ans<<endl;
}


Measured memory_bytes: 9144
#include <cstdio>
#include <algorithm>

using namespace std;

int a[109];

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


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 510
using namespace std;
const double eps=1e-10;
int n; 
struct Poi{
	double x,y;
}a[maxn];
double dist(Poi p1,Poi p2)
{
	return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}
Poi o;
double r;
void cir(Poi p1,Poi p2,Poi p3)
{
	double a=2*(p2.x-p1.x),b=2*(p2.y-p1.y);
	double c=p2.x*p2.x+p2.y*p2.y-p1.x*p1.x-p1.y*p1.y;
	double d=2*(p3.x-p1.x),e=2*(p3.y-p1.y);
	double f=p3.x*p3.x+p3.y*p3.y-p1.x*p1.x-p1.y*p1.y;
	o.x=(b*f-e*c)/(b*d-e*a);
	o.y=(d*c-a*f)/(b*d-e*a);
	r=dist(o,p1);
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)   scanf("%lf%lf",&a[i].x,&a[i].y);
	o=a[1];
	r=0;
	for(int i=2;i<=n;i++)
	{
		if(dist(o,a[i])>r+eps)
		{
			o=a[i];r=0;
			for(int j=1;j<=i-1;j++)
			{
				if(dist(o,a[j])>r+eps)
				{
					o.x=(a[i].x+a[j].x)/(double)2;
					o.y=(a[i].y+a[j].y)/(double)2;
					r=dist(o,a[i]);
					for(int k=1;k<=j-1;k++)
					{
						if(dist(o,a[k])>r+eps)  cir(a[i],a[j],a[k]);
					}
				}
			}
		}
	}
	printf("%.7lf\n",r);
	return 0;
}


Measured memory_bytes: 256