akhauriyash/Code-Regression huggingface dataset:
mod=1e9+7,dp[1<<21];
n,a,I,x,y,i,j;
main()
{
	for(*dp=scanf("%d",&n);~scanf("%d",&a);j=++j%n)
	{
		i+=!j;
		for(I=(1<<i)-1;I<1<<n;)
		{
			x=I&a<<j;
			dp[I]=(dp[I]+!!x*dp[I&~x])%mod;
			x=I&-I,y=I+x;
			I=(I&~y)/x/2|y;
		}
	}
	printf("%d",dp[I-y/2]);
}

Measured memory_bytes: 8448
#include<iostream>
#include<string>

using namespace std;

typedef long long ll;

int main() {
	ll A, B, C, K;
	cin >> A >> B >> C >> K;
	if (A >= K)cout << K << endl;
	else if (A + B >= K)cout << A << endl;
	else cout << A - (K - A - B) << endl;
	return 0;
}

Measured memory_bytes: 3636
n,m,c = gets.split().map(&:to_i)
b = gets.split()

num = 0
for i in 1..n do
    a = gets.split()
    sum = 0
    for j in 1..m do
       sum = sum + a[j-1].to_i*b[j-1].to_i 
    end
    num = num + 1 if sum + c > 0
end

p num


Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int n, cnt;
int a[200002], c[200002];
bool b[200002];

int main(){

	cin >> n;
	REP(i, 1, n + 1)cin >> a[i];

	REP(i, 1, n + 1)b[i] = false;

	for (int i = n; i > 0; i--) {
		int j = i;
		int k = 0;
		j *= 2;
		while (j <= n) {
			k += c[j];
			j += i;
		}
		if (k % 2 != a[i])c[i] = 1, cnt++;
	}

	cout << cnt << endl;
	REP(i, 1, n + 1) {
		if (c[i])cout << i << endl;
	}

	return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main{
 public static void main(String[] args){
  Scanner sc= new Scanner(System.in);
  int n = sc.nextInt();
  int i= 1;
  do{
   int x = i;
   if(x % 3 == 0){
    System.out.print(" " + i);
   }
   else{
    do{
     if(x % 10 == 3){
      System.out.print(" " + i);
      break;
     }
     x /= 10;
    } while(x != 0);
   }
  } while(++i <= n);
  System.out.println();
 }
}

Measured memory_bytes: 28748
//***Wherever you are, and whatever you do, be in love.***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
   ll k,n;
   cin>>k;
   string s;
   cin>>s;
   n=s.length();
   if(n<=k) cout<<s;
   else{
       forn(i,k) cout<<s[i];
       cout<<"...";
   }
}

Measured memory_bytes: 3576
import sys
sys.setrecursionlimit(10**8)

def cmb(n,r):
    if (r<0 or r>n):
        return 0
    r=min(r,n-r)
    return g1[n]*g2[r]*g2[n-r]%mod

mod=998244353
N=2*10**5+100
g1=[1,1]
g2=[1,1]
inverse=[0,1]

for i in range(2,N+1):
    g1.append((g1[-1]*i)%mod)
    inverse.append((-inverse[mod%i]*(mod//i))%mod)
    g2.append((g2[-1]*inverse[-1])%mod)


n,m,k=map(int,input().split())
P=[1] #m-1のi乗

for i in range(n):
    P.append(P[-1]*(m-1)%mod)

ans=0
for i in range(k+1):
    cnt=cmb(n-1,i)*m%mod
    cnt=cnt*P[n-i-1]%mod
    ans=(ans+cnt)%mod
print(ans)

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

int main() {
	vector <long int >vec;
	long int i=0,x,sum;
	for(i=0;;)
	  {		sum=((i)*(i+1))/2;
	  	 if(sum>1e9)
	  	    break;
	  	 else
	  		vec.push_back(sum);
	  		++i;
	  }
	cin>>x;
	cout<<lower_bound(vec.begin(),vec.end(),x)-vec.begin();
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define mod 1000000007ll
using namespace std;
struct edge
{
	int to;
	int nxt;
}e[3000010];
int color[200010],head[200010],pos[200010];
int cnt[200010],tot;
long long w[200010],minn[200010];
long long fac[200010],rfac[200010];
int v[200010];
int n,minnum,minnum2;
long long X,Y,min1,min2,ans;
long long qpow(long long a,long long b)
{
	long long ans = 1,res = a;
	while(b)
	{
		if(b&1)ans = (ans * res) % mod;
		res *= res;
		res %= mod;
		b >>= 1;
	}
	return ans;
}
long long C(long long n,long long k)
{
	return  fac[n] * rfac[k] % mod * rfac[n - k] % mod;
}
void addedge(int x,int y)
{
	e[++tot].nxt = head[x];
	e[tot].to = y;
	head[x] = tot;
}
void add(int x,int y)
{
	addedge(x,y);
	addedge(y,x);
}
void dfs(int x)
{
	v[x] = 1;
	for(int i = head[x]; i; i = e[i].nxt)
	{
		if(!v[e[i].to])
			dfs(e[i].to);
	}
}
int main()
{
	scanf("%d%lld%lld",&n,&X,&Y);
	fac[0] = 1;
	for(int i = 1; i <= n;i++)scanf("%d%lld",&color[i],&w[i]);
	for(int i = 1;i <= n;i++)fac[i] = (i * fac[i - 1]) % mod,minn[i] = 2147483647ll;
	rfac[n] = qpow(fac[n],mod - 2);
	for(int i = n; i > 0; i--)rfac[i - 1] = (i * rfac[i]) % mod;
	for(int i = 1; i <= n; i++)
	{
		if(w[i] < minn[color[i]])
		{
			minn[color[i]] = w[i];
			pos[color[i]] = i;
		}
	}
	for(int i = 1; i <= n; i++)
	{
		if(i != pos[color[i]] && w[i] + minn[color[i]] <= X)
		{
			add(i,pos[color[i]]);
		}
	}
	min1 = min2 = 2147483647ll;
	for(int i = 1; i <= n; i++)
	{
		if(w[i] < min1)
		{
			min1 = w[i];
			minnum = i;
		}
	}
	for(int i = 1; i <= n; i++)
	{
		if(w[i] <= min2 && color[i] != color[minnum])
		{
			min2 = w[i];
			minnum2 = i;
		}
	}
	for(int i = 1; i <= n; i++)
	{
		if(i == minnum)continue;
		if(color[i] != color[minnum] && w[i] + w[minnum] <= Y)
		{
			add(i,minnum);
		}
		if(minnum2 && color[i] != color[minnum2] && w[i] + w[minnum2] <= Y)
		{
			add(i,minnum2);
		}
	}
	dfs(minnum);
	long long tot = 0;
	for(int i = 1; i <= n; i++)
	{
		if(v[i])
		{
			++tot;
			cnt[color[i]]++;
		}
	}
	ans = 1;
	for(int i = 1; i <= n; i++)
	{
		if(cnt[i])
		{
			ans = (ans * C(tot,cnt[i])) % mod;
			tot -= cnt[i];
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 18688
def insertionSort(A):
    print " ".join(map(str, A))
    for i in range(1, len(A)):
        temp = A[i]
        j = i-1
        while j >= 0 and A[j] > temp:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = temp
        print " ".join(map(str, A))

N = int(raw_input())
A = map(int, raw_input().split())

insertionSort(A)

Measured memory_bytes: 6420
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  string a, b, c;
  cin >> a >> b >> c;

  int pa = 0;
  int pb = 0;
  int pc = 0;
  char now = 'a';
  while (true) {
    if (now == 'a') {
      if (pa == a.length()) {
        cout << "A" << endl;
        return 0;
      }
      now = a[pa];
      pa++;
    }
    if (now == 'b') {
      if (pb == b.length()) {
        cout << "B" << endl;
        return 0;
      }
      now = b[pb];
      pb++;
    }
    if (now == 'c') {
      if (pc == c.length()) {
        cout << "C" << endl;
        return 0;
      }
      now = c[pc];
      pc++;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  int ans = 0;
  rep(i, N) ans += min(a[i], K-a[i])*2;
  cout << ans << endl;
}

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

#define INF 1001001001
#define MAX 200005

int main() {
  int t;
  cin >> t;
  vector<ll> ans;
  rep(i,t) {
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    ans.push_back(floor_sum(n,m,a,b));
  }
  for (auto a : ans) cout << a << endl;

  return 0;
}


Measured memory_bytes: 4132
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll x,t;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>x>>t;
	cout<<max(0ll,x-t);
	return 0;
}


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

namespace agc004_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = x[0];
            long[,] time = new long[n,n];
            for (int i = 0; i < n; i++)//スライム決め
            {
                int min = a[i];
                for (int j = 0; j < n; j++)//魔法使用回数
                {
                    min = Math.Min(min,a[(i - j + n) % n]);
                    time[i,j] = min;
                }
            }
            long ret = long.MaxValue;
            for (long i = 0; i < n; i++)
            {
                long now = 0;
                for (int j = 0; j < n; j++)
                {
                    now += time[j,i];
                }
                ret = Math.Min(ret,now + x[1] * i);
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 44512
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
using namespace std;
typedef long long int lli;
int main(void)
{
    int X, N;
    cin >> X >> N;
    vector<int> p;
    int tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        p.push_back(tmp);
    }
    int a = 0;
    for (int i = 0; i < X + 1; i++)
    {
        for (int j = -1; j <= 1; j++)
        {
            if (j != 0)
            {
                a = X + j * i;
            }
            if (count(p.begin(), p.end(), a) == 0)
            {
                cout << a << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  map<int, int> freqs;
  int val;
  for (int i = 0; i < N; ++i) {
    scanf("%d", &val);
    ++freqs[val];
  }
  vector<pair<int, int>> B(freqs.begin(), freqs.end());
  sort(B.begin(), B.end(), greater<pair<int, int>>());
  ll a = 0, b = 0;
  for (int i = 0; i < (int)B.size(); ++i) {
    if (B[i].second >= 4) {
      if (a == 0) {
        a = b = B[i].first;
        break;
      }
      else {
        b = B[i].first;
        break;
      }
    }
    else if (B[i].second >= 2) {
      if (a == 0) { a = B[i].first; }
      else {
        b = B[i].first;
        break;
      }
    }
  }
  ll ans = a * b;
  printf("%lld\n", ans);
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int cnt = 0;
  for(int i=0; i<N-2; i++){
    for(int j=i+1; j<N-1; j++){
      int x = vec.at(i) + vec.at(j);
      for(int k=j+1; k<N; k++){
        if(x <= vec.at(k)){
          break;
        }
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
N,A,B=map(int,input().split())
a=list(map(int,input().split()))
border=B//A+1
ans=0
for i in range(N-1):
  d=a[i+1]-a[i]
  if d>=border:
    ans+=B
  else:
    ans+=(A*d)
print(ans)

Measured memory_bytes: 15020
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<math.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < n; i++)


signed main() {
	
	ll n, k;
	cin >> n >> k;

	vector<ll>x(n + 1);

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

	int ans = 0;
	rep(i, n) {
		if (x[i] >= k)ans++;
	}

	cout << ans;


	return 0;
}


Measured memory_bytes: 1024
N, T = map(lambda x: int(x), input().split(' '))

hit = False
cur_cheapest = 1000

for n in range(N):
    c, t = map(lambda x: int(x), input().split(' '))
    if t > T:
        continue
    hit = True
    if c < cur_cheapest:
        cur_cheapest = c

if hit is False:
    print('TLE')
else:
    print(cur_cheapest)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int main() {

    int n, t, m, p, x;
    scanf("%d", &n);
    int arr[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &t);
        arr[i] = t;
    }
    scanf("%d", &m);
    
    int mysum;
    for (int j = 0; j < m; j++) {
        scanf("%d %d", &p, &x);
        mysum = 0;
        for(int k=0; k<n;k++){
            if(k==p-1){
                mysum += x;                
            }else{
                mysum+=arr[k];                
            }
            
        }
        printf("%d\n", mysum);

    }

    return 0;
} 

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

class Input
{
  public:
    int height;
    int width;
    Input(int a,int b);
};

Input::Input(int a, int b)
{
  height = a;
  width = b;
}

int main(int argc,char* argv[])
{
  int height, width;
  vector<Input> inputs;
  int i=0;
  int j=0;
  while(1)
  {
    cin >> height >> width;
    if(height==0 && width==0) break;
    inputs.push_back(Input(height,width));
  }
  for(auto input: inputs)
  {
    j = 0;
    while(j<input.height)
    {
      i=0;
      while(i<input.width)
      {
        cout << '#';
        i++;
        if(i==input.width) break;
        cout << '.';
        i++;
      }
      cout << endl;
      j++;
      if(j==input.height) break;
      i = 0;
      while(i<input.width)
      {
        cout << '.';
        i++;
        if(i==input.width) break;
        cout << '#';
        i++;
      }
      cout << endl;
      j++;
    }
    cout << endl;
  }
}

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

int main(){
  int n, m;
  cin >> n >> m;
  
  int st[n][2], po[m][2];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 2; j++){
      cin >> st[i][j];
    }
  }
  for(int i = 0; i < m; i++){
    for(int j = 0; j < 2; j++){
      cin >> po[i][j];
    }
  }
  
  for(int i = 0; i < n; i++){
    int cnt = 200000001, pla = 0, dis = 0;
    
    for(int j = 0; j < m; j++){
      dis = abs(st[i][0] - po[j][0]) + abs(st[i][1] - po[j][1]);
  
      if(cnt > dis){
        cnt = dis;
        pla = j;
      }
    }
    pla++;
    cout << pla << endl;
  }
}
      
      
      
      
      
      
      
    
    
  

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    int flag = 0;
    
    std::cin >> n;
    
    for(int i = 0; i < 27; i++)
    {
        for(int j = 0; j < 16; j++)
        {
            if(i != 0 || j != 0)
            {
                if(n % (i * 4 + j * 7) == 0 ) flag = 1;
            }
            
        }
    }
    
    if(flag) std::cout <<  "Yes" << std::endl;
    else std::cout << "No" << std::endl;
   
    return 0;
}


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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  ll a[7];
  for(int i = 0 ; i < 7; i ++ ){
    cin >> a[i];
  }
  ll res = a[1];
  ll A = a[0], B = a[3], C = a[4];
  ll bes = 0;
  ll fa, fb, fc;
  for(ll x = min({A,B,C}); x >= max(0ll, min({A,B,C}) - 500); x -- ){
    fa = A - x;
    fb = B - x;
    fc = C - x;
    fa -= fa % 2;
    fb -= fb % 2;
    fc -= fc % 2;
    bes = max(bes, fa + fb + fc + x * 3ll);
  }
  cout << res + bes << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
	int n, m;
	cin >> n;
	vector<string> vec;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		vec.emplace_back(s);
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		string s;
		cin >> s;
		if (!vec.empty()) {
			for (int i = 0; i < vec.size(); i++) {
				if (s == vec[i]) {
					vec.erase(vec.begin() + i);
					break;
				}
			}
		}
	}
	if (vec.empty()) {
		cout << "0" << endl;
		return 0;
	}
	sort(vec.begin(), vec.end());
	int co = 1, ma = 0;
	for (int i = 0; i < vec.size() - 1; i++) {
		if (vec[i] != vec[i + 1]) {
			if (ma < co) {
				ma = co;
			}
			co = 1;
		}
		else {
			co++;
		}
	}
	if (ma < co) {
		ma = co;
	}
	cout << ma << endl;
	return 0;
}


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

using namespace std;
int p[100005];
int main(){
	int n;
	cin>>n;
	int ans=0;
	for(int i=0;i<n;i++)cin>>p[i];
	for(int i=1;i<n-1;i++){
		if((p[i]>p[i-1]&&p[i]<p[i+1])||(p[i]<p[i-1]&&p[i]>p[i+1]))ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int myabs(int i){
  if(i > 0){return i;}
  else{return -i;}
}

int main(void){
  while(1){
    int n;
    cin >> n;
    if(n == 0) {return 0;}

    int a[n];

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

    long int diff;
    long int ans = 500000000;

    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ; j < n ; j++){
        diff = myabs(a[i] - a[j]);
        if(i != j && ans > diff){
          ans = diff;
        }
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 3028
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    string s;
    cin >> s;
    int count_0 = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (i % 2 == 0) {
            if (s[i] != '0') ++count_0;
        } else {
            if (s[i] != '1') ++count_0;
        }
    }

    int count_1 = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (i % 2 == 0) {
            if (s[i] != '1') ++count_1;
        } else {
            if (s[i] != '0') ++count_1;
        }
    }

    if (count_0 > count_1) {
        cout << count_1 << endl;
    } else {
        cout << count_0 << endl;
    }
    return 0;
}

Measured memory_bytes: 512
// inputに入力データ全体が入る
function Main(input) {
  // input = input.split(" ");
  N = input.split('\n')[0].split(" ");
  A = N[0]
  B = N[1]
  C = N[2]
  f = false
  if(A == B && B != C)f =true
  if(B == C && C != A)f =true
  if(C == A && A != B)f =true
  if(f){
    console.log('Yes')
  }else{
    console.log('No')
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,m;
    cin >> n;
    map<ll, ll> candidate, needs;
    for (ll i = 0; i < n;i++){
        ll d;
        cin >> d;
        candidate[d]++;
    }
    cin >> m;
    for (ll i = 0; i < m;i++){
        ll t;
        cin >> t;
        needs[t]++;
    }
    bool flag = true;
    for(auto i:needs){
        if (i.second > candidate[i.first]) flag = false;
    }
    cout << (flag ? "YES" : "NO") << endl;
}

Measured memory_bytes: 28632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
int N, M;
map<int, vector<int>> mp;
int D[205000];
int ans[205000];
bool ok[205000];
vector<i_i> paths[205000];
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1;
    }

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

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

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        //if (rank[x] < rank[y]) swap(x, y);
        if((x - 1) % N > (y - 1) % N) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }

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


int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 1; i <= M; i++) {
        ans[i] = 1e9;
    }
    for(int i = 1; i <= N; i++) {
        cin >> D[i];
        mp[D[i]].push_back(i);
    }
    for(int i = 1; i <= M; i++) {
        int u, v;
        cin >> u >> v;
        paths[u].emplace_back(v, i);
        paths[v].emplace_back(u, i);
    }
    UnionFind uni(2 * (N + 1));
    for(auto tmp : mp) {
        int val = tmp.first;
        for(auto now : tmp.second) {
            if(ok[now]) continue;
            for(auto e : paths[now]) {
                int to = e.first;
                int edge = e.second;
                if(D[to] == D[now]) {
                    ans[edge] = D[now];
                    ok[now] = true;
                    ok[to] = true;
                    uni.merge(now, to + N);
                    uni.merge(now + N, to);
                    break;
                }
                if(D[to] < D[now]) {
                    ans[edge] = D[now] - D[to];
                    ok[now] = true;
                    uni.merge(now, to);
                    uni.merge(now + N, to + N);
                    break;
                }
            }
            if(!ok[now]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    for(int i = 1; i <= N; i++) {
        if(uni.root(i) <= N) cout << "B";
        else cout << "W";
    }
    cout << endl;
    for(int i = 1; i <= M; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 27392
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(string, s);

  vector<string> wether = {"Sunny", "Cloudy", "Rainy"};
  for (int i = 0; i < 3; ++i) {
    if (wether.at(i) == s) {
      puts(wether.at((i + 1) % 3).c_str());
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <sstream>
#include <cmath>

using namespace std;

#define JPY_PER_BTC 380000.0

int main(int argc, const char * argv[]) {
    int N; cin >> N;
    double jpy = 0;
    double btc = 0;
    for (int i = 0; i < N; i++) {
        double x; cin >> x;
        string u; cin >> u;
        if (u == "JPY") {
            jpy += x;
        } else {
            btc += x;
        }
    }
    
    cout << (jpy + btc * JPY_PER_BTC) << endl;
    
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  map<string, int> S;
  string a;
  int max = 0;
  int tmp;
  for(int i=0; i<N; i++){
    cin >> a;
    S[a] += 1;
    tmp = S[a];
    if(max < tmp) max = tmp;
  }
  for(auto p : S){
    if(p.second == max){
      cout << p.first << endl;
    }
  }
}

Measured memory_bytes: 25600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,x,y,sum;
  long long min,max;

  
  cin >> N;
  vector<int> li(N);
  for (int i = 0; i < N; i++) {
    cin >> li.at(i);
  } 
  
  for (int i = N-1; i >= 0; i--) {
    cout << li.at(i);
    if(i != 0)cout << " ";
  } 
  cout << endl;
}


Measured memory_bytes: 3092
N = int(input())
*A, = map(int, input().split())

C = [0]*(N+1)
ans = []
for i in range(N, 0, -1):
    c = 0
    for j in range(2*i-1, N, i):
        if C[j]:
            c += 1
    if c % 2 != A[i-1]:
        ans.append(i)
        C[i-1] = 1
ans.reverse()
print(len(ans))
if ans:
    print(*ans)

Measured memory_bytes: 14132
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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; }

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

    int n, a, b; cin >> n >> a >> b;
    if(b - a & 1) cout << "Borys" << endl;
    else cout << "Alice" << endl;
}


Measured memory_bytes: 256
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


X,Y = map(int,input().split())

x = X % 3
y = Y % 3

sa = X - Y
to = ( X + Y ) // 3
aa = ( sa + ( X + Y ) // 3 ) // 2

ans = 1

if x == 0 and y == 0:
  print(cmb(to, aa, p))

elif x == 1 and y == 2:
  print(cmb(to, aa, p))
        
elif x == 2 and y == 1:
  print(cmb(to, aa, p))
  
else:
  print(0)


Measured memory_bytes: 122128
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, q;
    std::string s;
    std::cin >> n >> q >> s;
    std::vector<i64> v(n + 10);
    for (int i = 1; i < n; i++) {
        if (s[i - 1] == 'A' && s[i] == 'C') v[i - 1]++;
    }
    for (int i = 1; i <= n; i++) v[i] += v[i - 1];

    while (q--) {
        int l, r;
        std::cin >> l >> r;
        l--; r--;
        std::cout << v[r - 1] - (l ? v[l - 1] : 0) << std::endl;
    }

    return 0;
}


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

int main(){
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for(int x=0; x<=k; ++x){
    for(int y=x; y<=k; ++y){
      for(int z=y; z<=k; ++z){
        if(x+y+z == s){
          if(x!=y && y!=z && z!=x) ans += 6;
          else if(x == y && y == z) ans += 1;
          else ans += 3;
        }
      }
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
using System;

namespace CF2016CA{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var S = sr.Next<string>();
            var c = S.IndexOf('C');
            var f = S.LastIndexOf('F');
            var res = c != -1 && f != -1 && c < f;
            Console.WriteLine(res ? "Yes" : "No");
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];
        private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = _sr.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

Measured memory_bytes: 2904
function main(arg) {
    var args = arg.split(' ').map(function(n){ return +n })
    if((args[0] <= args[2] && args[2] <= args[1]) || (args[1] <= args[2] && args[2] <= args[0])){
        console.log('Yes')
    }else{
        console.log('No')
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> count(N+1, 0);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        count.at(A.at(i))++;
    }

    ll sum = 0;
    for (int i = 0; i < N + 1; i++) {
        ll c = count.at(i);
        sum += c*(c-1)/2;
    }

    for (int i = 0; i < N; i++) {
        cout << sum - (count.at(A.at(i))-1) << endl;
    }
}

Measured memory_bytes: 4096
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner cin = new Scanner(System.in);
		int N = 0;
		N = cin.nextInt();
		
		while(N>0) {
			if(N%10==7) {
				System.out.println("Yes");
				return;
			}
			N/=10;
		}
		System.out.println("No");
	}

}


Measured memory_bytes: 35760
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,C,K;
  cin >> N >> C >> K;
  vector<int> T(N);
  for(int i=0;i<N;i++)cin >> T[i];
  sort(T.begin(),T.end());
  int ans=1; int count=1; int time=T[0];
  for(int i=1;i<N;i++){
    if(count==C){ans++; count=1; time=T[i];}
    else if(time+K<T[i]){ans++; count=1; time=T[i];}
    else{count++;}
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
  int num;
  cin >> num;
  if(! num%2){
    cout << 0.5 << endl;
  }else{
    float res = num/2;
    float a = res/num;
    cout << 1 - a << endl;
  }
  return 0;
}
  

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,s,ss;
	cin>>a>>b>>c;
	if(c%a==0)
	s=c/a;
	else
	s=c/a+1;
	if(c%b==0)
	ss=c/b;
	else
	ss=c/b+1;
	cout<<min(s,ss);
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i ) {
            ret.pb( i );
            if( i * i != n ) ret.pb( n / i );

        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n, k;
    cin >> n >> k;
    int h[SIZE];
    for( int i = 0; i < n; ++i ) cin >> h[i];

    int dp[SIZE];
    for( int i = 0; i < SIZE; ++i ) dp[i] = INF;

    dp[0] = 0;
    for( int i = 0; i < n; ++i ) {
        for( int j = i - 1; j >= max( i - k, 0 ); --j ) {
            dp[i] = min( dp[i], dp[j] + abs( h[j] - h[i] ) );

        }
    }

    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 1024
A = input().split(" ")
a = int(A[0])
b = int(A[1])
c = int(A[2])
d = int(A[3])
if abs(a-c) <= d:
    print("Yes")
else:
    if abs(a-b) <= d and abs(b-c) <= d:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	c := nextInt()
	m := map[int]int{}

	var i int
	m[c]++ // 初期値登録
	for i = 2; i < 10000000; i++ {
		//fmt.Println(i, c, cl(c))
		if _, ok := m[cl(c)]; ok {
			break
		}
		m[cl(c)]++
		c = cl(c)
	}

	fmt.Println(i)

}
func cl(a int) int {
	if a%2 == 0 {
		return a / 2
	}
	return 3*a + 1

}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1832
#include<bits/stdc++.h>
using namespace std;
int ans=0,n,store[200];
signed main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>store[i];
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(store[i]==store[j])continue;
			for(int k=j+1;k<n;k++){
				if(store[i]==store[k]||store[j]==store[k]){
					continue;
				}
				int num1,num2,num3;
				num1=min(store[i],store[j]);num2=max(store[i],store[j]);
				num3=max(num2,store[k]);
				num2=min(num2,store[k]);
				if(num1+num2<=num3)continue;
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3620
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

vector<pair<ll,ll>> prime_pow;
void sieveOfEratosthenes(ll N, ll s[]){ 
    vector <bool> prime(N+1, false); 
    for (ll i=2; i<=N; i+=2) 
        s[i] = 2;  
    for (ll i=3; i<=N; i+=2) { 
        if (prime[i] == false) {  
            s[i] = i;  
            for (ll j=i; j*i<=N; j+=2) { 
                if (prime[i*j] == false) { 
                    prime[i*j] = true; 
                    s[i*j] = i; 
                } 
            } 
        } 
    } 
} 
void primefactor(ll N){ 
    ll s[N+1];  
    sieveOfEratosthenes(N, s); 
    ll curr = s[N], cnt = 1;    
    while (N > 1){ 
        N /= s[N];  
        if (curr == s[N]) { 
            cnt++; 
            continue; 
        } 
        prime_pow.push_back({curr,cnt});  
        curr = s[N], cnt = 1; 
    } 
}

void virus(){
    string a,b;
    cin>>a>>b;
    ll cnt = 0;
    for(auto i=0; i<a.size(); i++){
        if(a[i] != b[i]) cnt+=1;
    }
    cout<<cnt;
}


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

    ll t=1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 3820
class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=998244353):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

def power_func(a,n,p):
  bi=str(format(n,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res


n,m,k = map(int, input().split())
MOD = 998244353
ans = 0
comb = Combination(n)
for i in range(k + 1):
    tmp = m*power_func(m - 1, n - i - 1,MOD)%MOD
    tmp *= comb(n - 1,i)
    ans += tmp%MOD
print(ans%MOD)

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

signed main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> r;
    vector<int> g;
    vector<int> b;
    rep(i,s.length()){
        if(s[i]=='R') r.push_back(i);
        else if(s[i]=='G') g.push_back(i);
        else b.push_back(i);
    }
    ll ans = r.size()*g.size()*b.size();

    int temp=s.length();
    if(temp%2==0) temp--;
    if(s.length()<3){
        cout << ans << endl;
        return 0;
    }
    for(int i=1;i<=((temp-3)/2)+1;i++){
       for(int j=0;j+2*i<s.length();j++){
           if(s[j]!=s[j+i] && s[j]!=s[j+2*i] && s[j+i]!=s[j+2*i]) ans--;
       } 
    }
    cout << ans << endl;


}

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define SUM(a) accumulate(all(a),0)
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int n,m; cin >> n >> m;
  int a,b;
  vector<bool> c(n),d(n);
  rep(i,m){
    cin >> a >> b;
    if(a == 1) c[b]=true;
    if(b == n) d[a]=true;
  }
  rep(i,n) if(c[i]&d[i]){
    cout << "POSSIBLE\n";
    return 0;
  }
  cout << "IMPOSSIBLE\n";
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define R cin>>
#define C cout<<
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int n;
  R n;
  rep(i,10000000)vector<string>s;
  vector<int>v(n),c(n);
  rep(i,n)cin >> v[i];
  rep(i,n)cin >> c[i];
  int ans = -1 * INF;
  rep(i,(1 << n)){
    int a = 0,b = 0;
    rep(j,n){
      if(i & (1 << j)){
        a += v[j];
        b += c[j];
      }
    }
    ans = max(ans,a - b);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n, k, a[5001];
bool dp1[5001][5001], dp2[5001][5001];
signed main() {
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	dp1[0][0] = true;
	rep(i, n - 1) {
		rep(j, k) {
			if (dp1[i][j])dp1[i + 1][j] = true;
			if (dp1[i][j] && j + a[i] <= k) {
				dp1[i + 1][j + a[i]] = true;
			}
		}
	}
	dp2[n - 1][0] = true;
	for (int i = n - 1; i > 0; i--) {
		rep(j, k) {
			if (dp2[i][j])dp2[i - 1][j] = true;
			if (dp2[i][j] && j + a[i] <= k) {
				dp2[i - 1][j + a[i]] = true;
			}
		}
	}
	int ans = 0;
	rep(i, n) {
		vector<int>ans1, ans2;
		rep(j, k + 1) {
			if (dp1[i][j])ans1.push_back(j);
			if (dp2[i][j])ans2.push_back(j);
		}
		bool b = false;
		for (int p : ans1) {
			if (upper_bound(all(ans2), k - p - 1) - lower_bound(all(ans2), k - p - a[i])) {
				b = true;
			}
		}
		if (!b)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 49152
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        x: isize
    };
    // n*(n+1)/2 >= x
    // nn + n + 1 >= 2x
    let n = (1..std::isize::MAX).find(|&i| i * (i + 1) >= 2 * x).unwrap();
    println!("{}", n);
}


Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int[][][] p = new int[4][3][10];

		int n = sc.nextInt();

		int house;
		int floor;
		int room;
		int num;

		for (int i = 0; i < n; i++) {
			house = sc.nextInt();
			floor = sc.nextInt();
			room = sc.nextInt();
			num = sc.nextInt();

			p[house - 1][floor - 1][room - 1] += num;
			
		}

		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 3; k++) {
				for (int l = 0; l < 10; l++) {
					System.out.print(" ");
					System.out.print(p[j][k][l]);
				}
				System.out.println();
			}
			if (j != 3) {
				for (int m = 0; m < 20; m++) {
					System.out.print("#");
				}
				System.out.println();
			}
		}

	}
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  ll N, A, B; cin >> N >> A >> B;
  ll result;
  if ((B-A)%2==0) result = (B-A)/2;
  else result = min(A,N-B+1) + (B-A)/2;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define array(N, t) (t*)calloc(N, sizeof(t))
#define ll long long
#define INF ((1LL << 62) - (1LL << 31))
#define max(p, q)((p) > (q) ? (p) : (q))
#define min(p, q)((p) < (q) ? (p) : (q))

int main() {
  int N, X, T;
  scanf("%d%d%d", &N, &X, &T);

  int mod = N % X;
  int ans = 0;
  if (mod == 0) {
    ans = (int)(N / X) * T;
  } else {
    ans = ((int)(N / X) + 1) * T;
  }

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

  return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int MAXN=1e5+5;
int n,m,cnt;
int f[MAXN];
int find(int x){
	if(x==f[x])
	    return x;
	else
	    return f[x] = find(f[x]);
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	    f[i]=i;
	while(m--){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		int fx=find(x);
		int fy=find(y);
		if(fx!=fy){
			f[fx]=fy;
			cnt++;
		}
	}
	printf("%d\n",n-cnt);
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

void maximum_profit(int *C, int *V, int N, int index, int profit, int *max_profit) {
  if (index < N) {
    maximum_profit(C,V,N,index+1,profit+V[index]-C[index],max_profit);
    maximum_profit(C,V,N,index+1,profit,max_profit);
  } else if (profit > (*max_profit)) {
    (*max_profit) = profit;
  }
}

void Resale(int N) {
  int C[N], V[N], i, max_profit;
  for (i = 0; i < N && scanf("%d",&V[i]); i++);
  for (i = 0, max_profit = 0; i < N && scanf("%d",&C[i]); i++);
  maximum_profit(C,V,N,0,0,&max_profit);
  printf("%d",max_profit);
}

int main(void) {
  int N;
  scanf("%d",&N);
  Resale(N);
  return 0;
}

Measured memory_bytes: 128
import numpy as np
ans = 0

n = int(input())
half_n = n//2
V = list(map(int, input().split()))

odd = V[0::2]
even = V[1::2]

odd_count = np.bincount(odd)
odd_argmax = np.argmax(odd_count)
odd_count_num = odd_count[odd_argmax]
odd_count[odd_argmax] = -1
odd_argmax_second = np.argmax(odd_count)
odd_count_num_second = odd_count[odd_argmax_second]
# print("odd_argmax", odd_argmax)
# print("odd_count_num", odd_count_num)
# print("odd_argmax_second", odd_argmax_second)
# print("odd_count_num_second", odd_count_num_second)

even_count = np.bincount(even)
even_argmax = np.argmax(even_count)
even_count_num = even_count[even_argmax]
# print(even_count)
even_count[even_argmax] = 0
even_argmax_second = np.argmax(even_count)
even_count_num_second = even_count[even_argmax_second]
# print(even_count)
# print("even_argmax", even_argmax)
# print("even_count_num", even_count_num)
# print("even_argmax_second", even_argmax_second)
# print("even_count_num_second", even_count_num_second)

if odd_argmax == even_argmax:
    ans = min(half_n - odd_count_num + half_n - even_count_num_second, half_n - odd_count_num_second + half_n - even_count_num)
else:
    ans += half_n - odd_count_num
    ans += half_n - even_count_num
print(ans)


Measured memory_bytes: 23404