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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
string S[21];

int cnt[21][1<<21];
int R[21][2];

int ID(int L,int x) {
	return (1<<L) + x;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N+1) {
		cin>>S[i];
		FOR(x,1<<i) cnt[0][ID(i,x)]=S[i][x]=='1';
	}
	
	for(i=N;i>=0;i--) {
		FOR(x,1<<i) {
			R[i][0]=R[i][1]=i;
			for(j=i-1;j>=0;j--) {
				R[j][0]=R[j+1][0];
				R[j][1]=R[j+1][1];
				int prefix = x>>(i-1-j);
				R[j][prefix&1]=j;
			}
			
			FOR(j,i) {
				int prefix = x>>(i-j);
				cnt[j][ID(j,prefix)]+=cnt[j][ID(i,x)];
				if(R[j][0]<i) {
					int nex=(prefix<<(i-R[j][0])) | (x&((1<<(i-R[j][0]))-1));
					cnt[j+1][ID(j+i-R[j][0],nex)]+=cnt[j][ID(i,x)];
				}
				if(R[j][1]<i) {
					int nex=(prefix<<(i-R[j][1])) | (x&((1<<(i-R[j][1]))-1));
					cnt[j+1][ID(j+i-R[j][1],nex)]+=cnt[j][ID(i,x)];
				}
			}
			
			if(cnt[i][ID(i,x)]>=K) {
				FOR(j,i) cout<<((x>>(i-1-j))&1);
				cout<<endl;
				return;
			}
		}
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 172672
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<string>
#include<sstream>
using namespace std;
int inf = 1000000000;

vector<bool> isPrime(long long int n){
  vector<bool> prime(n+1, true);
  prime[0] = false;
  prime[1] = false;
  for(long long int i=2; i<=sqrt(n); i++){
    if( !prime[i] ) continue;
    for(long long int j=i*2; j<=n; j+=i){
      prime[j] = false;
    }
  }
  return prime;
}


int main(){

  int n; cin >> n;

  vector<bool> p = isPrime(300000);

  vector<int> a;
  for(int i=0; i<=55555; i++){
    if(p[i] && i%5 == 1) a.push_back(i);
  }

  for(int i=0; i<n; i++){
    if(i != n-1) cout << a[i] << " ";
    else cout << a[i] << endl;
  }

  return 0;
}





//


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define si(x) (ll)((x).size())
#define pb push_back
#define F first
#define S second
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>=1;i--)
#define all(x) (x).begin(), (x).end()
#define make_unique(x) (x).resize(unique(all(x))-(x).begin())
const ll inf = 1e18;
void file()
{

#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);

#endif
}

void solve()
{
    ll n;
    cin >> n;
    std::vector<string> v(n);
    ll x[n];
    x[0] = 0;

    rep(i, n) cin >> v[i] >> x[i];
    string s;
    cin >> s;
    rep(i, n)
    {
    	if(i)
        x[i] += x[i-1];
    }
    if(v[0] == s)
    {
        cout << x[n-1]-x[0];
    }
    else
    rep(i, n)
    if(v[i] == s)
        cout << x[n-1]-x[i];

}

int main()
{



    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;

    while(t--)
    {
        solve();
        // cout << endl;
    }


}




Measured memory_bytes: 256
#include<iostream>	// 入出力
#include<stdio.h>	// printf()が使える 小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

using ll = long long;

int main()
{
	int N; cin >> N;

	int num4 = 0;
	int num2 = 0;

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

		if (a % 4 == 0) { ++num4; continue; }
		else if (a % 2 == 0) { ++num2; }
	}

	if (num2 <= 1) {
		if (N / 2 <= num4)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}

	else
	{
		int num = num2 + num4 * 2;

		if (num >= N)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

using namespace std;

#define ll long long
#define db double
#define clr(a, b) memset(a, b, sizeof(a))
#define vi vector<int>


const int maxn = 2e7 + 10;
const ll mod =  1000000007;

int n, t;
ll sum;
ll fac[maxn];
ll a, b, x, y;
void init()
{
    fac[0] = 1;
    for (int i = 1; i <= maxn;i++)
        fac[i] = fac[i - 1] * i % mod;
    return;
}
ll Pow(ll a, ll b, ll mod){ ll ret(1); for (; b; b >>= 1, (a *= a) %= mod) if (b & 1) (ret *= a) %= mod; return ret;}    

ll C(ll n, ll m){ return m > n ? 0 : fac[n] * Pow(fac[m] * fac[n - m] % mod, mod - 2, mod) % mod; }



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    init();
    cin >> x >> y;
    b = 2 * x - y;
    b /= 3;
    a = 2 * y - x;
    a /= 3;
    if (3 * a != 2 * y - x || 3 * b != 2 * x - y || a<0 || b<0)
    {
        cout << "0" << endl;
    }
    else
    {
        cout << C(a + b, a) << endl;
    }
    return 0;
}

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

using namespace std;

const int nmax=100000;
int n,v[nmax+5];
map<int,int>ap;
int v2[nmax+5],y=0;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
        ap[v[i]]++;
    }
    sort(v+1,v+n+1);
    for(int i=1;i<=n;i++)
    {
        if(v[i]==v[i-1])
            continue;
        int x=v[i];
        if(ap[x]>=2)
            v2[++y]=x;
        if(ap[x]>=4)
            v2[++y]=x;
    }
    sort(v2+1,v2+y+1);
    if(y>=2)
        cout<<1ll*v2[y]*v2[y-1];
    else
        cout<<0;
    cout<<"\n";
    return 0;
}
/**

ma1>ma2>0

**/


Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 0;
		for(int i=0;i<N;i++){
			int l = sc.nextInt();
			int r = sc.nextInt();
			ans += r - l  + 1;
		}
		System.out.println(ans);
	}

}


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

using namespace std;

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


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

int main(){
    int N, L[11], maxl, maxi;
    maxl = 0;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> L[i];
        if(maxl < L[i]) {
            maxl = L[i];
            maxi = i;
        }
    }
    int sum = 0;
    for(int i = 0; i < N; i++){
        if(i != maxi) sum += L[i];
    }
    if(maxl < sum) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
a = list(map(int, input().split()))

if K == 2:
    print(N-1)
else:
    if N == K:
        print(1)
    elif (N-K) % (K-1) != 0:
        print(int((N-K)/(K-1))+2)
    else:
        print(int((N-K)/(K-1))+1)
        


Measured memory_bytes: 20544
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;
typedef long long ll;

int d;

ll pow10[19], maxnum[19][19], minnum[19][19];
void prelude() {
	pow10[0] = 1;
	for( int i = 1; i <= 18; ++i )
		pow10[i] = pow10[i-1] * 10;
	for( int low = 0; low <= 18; ++low )
		for( int high = low+1; high <= 18; ++high ) {
			for( int i = high, j = low; i > j; --i, ++j ) {
				maxnum[low][high] += 9*pow10[i] - 9*pow10[j];
				minnum[low][high] -= 9*pow10[i] + 9*pow10[j];
			}
			// printf( "maxnum[%d][%d] = %lld\n", low, high, maxnum[low][high] );
		}
}

ll ans = 0;
void dfs( int low, int high, ll d, ll mul ) {
	if( low >= high && !d ) {
		ans += mul*(low == high ? 10 : 1);
		return;
	}
	if( high >= 15 ) {
		dfs( low+1, high-1, d, mul*(low ? 10 : 9) );
		return;
	}
	if( d > maxnum[low][high] || d < minnum[low][high] )
		return;
	dfs( low+1, high-1, d, mul*(low ? 10 : 9) );
	for( int i = 0; i <= 9; ++i )
		for( int j = 0; j <= 9; ++j )
			if( i != j && (low || i) ) {
				ll d2 = d - (j-i)*pow10[high] - (i-j)*pow10[low];
				dfs(low+1, high-1, d2, mul);
			}
}

int main() {
	prelude();
	scanf( "%d", &d );
	for( int digit = 1; digit <= 25; ++digit )
		dfs(0, digit, d, 1);
	printf( "%lld\n", ans );
	return 0;
}


Measured memory_bytes: 128
N,A,B=[int(i) for i in input().split()]
sum=0

def getTotal(num):
    tmp=0
    for s in str(num):
        tmp+=int(s)
    return tmp

for i in range(1, N+1):
    total=getTotal(i)
    if(A<=total and total<=B):
        sum+=i

print(sum)


Measured memory_bytes: 2940
if __name__ == "__main__":
    N = int(input())
    abc=[]
    for i in range(N):
        abc.append(list(map(int, input().split())))

    dp=[[abc[0][0],abc[0][1],abc[0][2]]]
    for i in range(N-1):
        dp.append([-1,-1,-1])

    for i in range(1,N):
        dp[i][0]=abc[i][0]+max(dp[i-1][1],dp[i-1][2])
        dp[i][1]=abc[i][1]+max(dp[i-1][2],dp[i-1][0])
        dp[i][2]=abc[i][2]+max(dp[i-1][0],dp[i-1][1])
        None
    
    print(max(
        dp[-1][0],
        dp[-1][1],
        dp[-1][2]
    ))

Measured memory_bytes: 76888
import java.util.*;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		String s = sc.next();
		
		int cnt = 0;
		for (int i = 0; i <= n - 3; i++) {
			if (s.substring(i, i + 3).equals("ABC")) {
				cnt++;
			}
		}
		
		
		
		System.out.println(cnt);
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[10005];
int main()
{
    /*int l,r,d;
    cin >> l >> r>> d;
    int ans=0;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
            ans++;
    }
    cout << ans << endl;*/
    /*int ans=0;
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin >> x;
        if(x%2&&i%2)
            ans++;
    }
    cout << ans << endl;*/
    ll n;
    cin >> n;
    for(ll i=1;i<=n;i++)
    {
        ll x= i*i;
        if(x>n) break;
        for(ll j=1;j<=n;j++)
        {
            ll y = j*j;
            if(x+y>n) break;
            for(ll k=1;k<=n;k++)
            {
                ll z = k*k;
                if(z+x+y+i*j+j*k+i*k>n) break;
                a[z+x+y+i*j+j*k+i*k]++;
            }
        }
    }

    for(ll i=1;i<=n;i++)
        printf("%lld\n",a[i]);
}


Measured memory_bytes: 3836
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define N 100005
#define mod 1000000007
#define rep(i,j,k) for (ll i=j;i<=k;++i)
#define per(i,j,k) for (ll i=j;i>=k;--i)
using namespace std;
inline ll read(){
	char ch=getchar(); ll x=0,f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}
ll n,x,x0,x1,x2;
int main(){
	n=read();
	rep(i,1,n){
		x=read();
		if (x%2) ++x0;
		else if (!(x%4)) ++x2;
		else ++x1;
	}
	if (!x1) puts(x2>=x0-1?"Yes":"No");
	else puts(x2>=x0?"Yes":"No");
}

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

/*
code credits : ਜ਼ੈਲਦਾਰ
dashan jot singh
*/
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define inf LLONG_MAX
#define p pair<ll,ll>
ll n,w;
// ll arr[110][2];
ll dp[100010];

int main(){
	fast;
	// while(true){
		cin>>n>>w;
		// if(n==0||w==0){
		// 	break;
		// }
		for(ll i=0;i<100010;i++){
			dp[i]=1e11;
		}
		dp[0]=0;
		for(ll i=0;i<n;i++){
			ll wi,vi;
			cin>>wi>>vi;
			for(ll j=100005;j>=vi;j--){
				dp[j]=min(dp[j],dp[j-vi]+wi);
			}
		}
		for(ll i=100005;i>=0;i--){
			if(dp[i]<=w){
				cout<<i<<endl;
				break;
			}
		}
	// }
	return 0;
}

Measured memory_bytes: 1024
import math

class Point:
    def __init__(self,x,y):
        self.x = x
        self.y = y

    def __add__(self,a):
        return self.__class__(self.x+a.x,self.y+a.y)

    def __sub__(self,a):
        return self.__class__(self.x-a.x,self.y-a.y)

    def __mul__(self,d):
        return self.__class__(self.x*d,self.y*d)

    def __truediv__(self,d):
        return self.__class__(self.x/d,self.y/d)

    def __str__(self):
        return '%.10f %.10f'%(self.x,self.y)

    def abs(self):
        return self.norm()**(1.0/2.0)

    def norm(self):
        return (self.x*self.x+self.y*self.y)

    def rotate(self,d):
        r = math.pi*d/180.0
        return self.__class__( self.x*math.cos(r)-self.y*math.sin(r),
                               self.x*math.sin(r)+self.y*math.cos(r))

    def dot(self,p):
        return (self.x*p.x+self.y*p.y)

class Segment:
    def __init__(self,p1,p2):
        self.p1 = p1
        self.p2 = p2

def project(s,p):
    v = s.p2-s.p1
    r = v.dot(p-s.p1)/v.norm()
    return s.p1+v*r

def reflect(s,p):
    return p+(project(s,p)-p)*2.0

def main():
    a,b,c,d = map(float,input().split())
    s = Segment(Point(a,b),Point(c,d))
    q = int(input())
    for _ in range(q):
        e,f = map(float,input().split())
        p = Point(e,f)
        print (reflect(s,p))


if __name__ == '__main__':
    main()




Measured memory_bytes: 5700
#include <bits/stdc++.h>
using namespace std;
//Exhaustive Search (Tim kiem vet can)
int n,m,a[30],q;
bool f;
//---------------------
void solve(int p,int q)
{
   if (q == 0) { f = true; return;}
   if (p == n) return;
   else
   {
     solve(p+1,q - a[p]);//chon pt thu p
     solve(p+1,q);//khong chon pt thu p
   }
}
//---------------------
void process()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    scanf("%d",&a[i]);

    scanf("%d",&m);
    for(int i=0;i<m;i++){
        scanf("%d",&q);
        f=false;//khoi tao lai co
        solve(0,q);
        if(f)printf("yes\n");
        else printf("no\n");
  }
}
int main(){
    process();
    return 0;
}



Measured memory_bytes: 3152
io = STDIN
n,m=io.gets.split.map(&:to_i)
connected_sw=m.times.map do 
  k,*s=io.gets.split.map(&:to_i)
  s.map(&:pred)
end
on_cond=io.gets.split.map(&:to_i)
ar=[0,1].repeated_permutation(n).map do |ptn|  #on/off全組み合わせ
  connected_sw.map.with_index do |sw_no,lamp_no|
    sw_no.map{|i|ptn[i]}.count(1)%2==on_cond[lamp_no]
  end.all?
end
p ar.count(true)


Measured memory_bytes: 2044
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
using namespace std;
#define ll long long

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define scn(var)         cin >> var;
#define pYes()           prt("Yes")
#define pNo()            prt("No")
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

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

int main(){
    int n, k;
    cin >> n >> k;
    vec a(n, 0);
    rep(i ,k){
        int d;
        cin >> d;
        rep(j, d){
            int tmp; cin >> tmp;
            tmp--;
            a[tmp]++;
        }
    }
    int ans = 0;
    rep(i, n){
        if(a[i] == 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
/**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 200002;
const int mod = 1000000000007ll;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b;
    int pwur = qpow(b,e>>1);
    return pwur * pwur;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------


int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);

    string s;
    cin >> s;
    for(int i=0; i<s.size(); i++){
        if( s[i] == '?' ) cout << 'D';
            else cout << s[i];
    }

    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}



int main(){
    char b;
    cin >> b;

    switch(b){
        case 'A':
            cout << (char) 'T' << endl;
            break;

        case 'T':
            cout << (char) 'A' << endl;
            break;
            
        case 'G':
            cout << (char) 'C' << endl;
            break;
            
        case 'C':
            cout << (char) 'G' << endl;
            break;

    }

    return 0;
}


Measured memory_bytes: 3548
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;

using namespace std;

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int num = min(a, k),
        score = num;
    k -= num;
    num = min(b, k);
    k -= num;
    num = min(c, k);
    score -= num;

    cout << score << endl;

    return 0;
}



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

int main(){
    int i,j;
    int a[3][3];
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            scanf("%d",&a[i][j]);
        }
    }
    int N;
    scanf("%d",&N);
    int tmp;
    for(int l=0;l<N;++l){
        scanf("%d",&tmp);
        for(i=0;i<3;i++){
            for(j=0;j<3;j++){
            if(tmp==a[i][j]){a[i][j]=0;}
            }
        }
    }
    if(a[0][0]+a[0][1]+a[0][2]==0||a[1][0]+a[1][1]+a[1][2]==0||a[2][0]+a[2][1]+a[2][2]==0||a[0][0]+a[1][0]+a[2][0]==0||a[0][1]+a[1][1]+a[2][1]==0||a[0][2]+a[1][2]+a[2][2]==0||a[0][0]+a[1][1]+a[2][2]==0||a[2][0]+a[1][1]+a[0][2]==0){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

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

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

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


ll gcd(ll a, ll b){
    if(a < b) return gcd(b, a);
    ll r;
    while((r = a%b)){
        a = b;
        b = r;
    }
    return b;
}

int main(){
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a,b);
    int cnt = 1;
    ll i = 2LL;
    while(g >= i*i){
        if(g%i == 0){
            cnt++;
            while(g%i == 0 && g >= i) g /= i;
        }
        i++;
    }

    cout << (g == 1LL ? cnt : cnt+1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
typedef long long ll;
ll N[maxn];
int main()
{
	int n;cin>>n;int cnt=0;ll sum=0;ll minn=1e9+1;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&N[i]);sum+=abs(N[i]);
		if(N[i]<0) cnt++;
		minn=min(minn,abs(N[i]));
	}
	if(cnt%2==0) cout<<sum<<endl;
	else cout<<sum-2*minn<<endl;
 } 

Measured memory_bytes: 1024
let solve h w c =
  let s = Array.make w 0 in
  let t = Array.make w 0 in
  let r = ref 0 in
  for i = 0 to h - 1 do
    if c.(i).(0) = 0 then r := 1
  done;
  for j = 0 to w - 1 do
    if c.(0).(j) = 0 then begin
      s.(j) <- 1;
      r := 1
    end
  done;
  for i = 1 to h - 1 do
    if c.(i).(0) = 0 then t.(0) <- 1;
    for j = 1 to w - 1 do
      if c.(i).(j) = 1 then t.(j) <- 0
      else begin
        let d = if s.(j) < t.(j-1) then s.(j) else t.(j-1) in
        t.(j) <- 1 + if s.(j-1) < d then s.(j-1) else d;
        if t.(j) > !r then r := t.(j)
      end
    done;
    Array.iteri (fun i e -> s.(i) <- e) t
  done;
  !r * !r

let () =
  let (h, w) = Scanf.scanf "%d %d " (fun h w -> h, w) in
  let c = Array.make_matrix h w 0 in
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do
      c.(i).(j) <- Scanf.scanf "%d " (fun c -> c);
    done
  done;
  solve h w c |> Printf.printf "%d\n"

Measured memory_bytes: 20084
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define itoc(c)               ((char)(((int)'0')+c))
#define vl                    vector<ll>
#define SZ(x)                 (x).size()
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define sv()                  ll t,n; scanf("%lld",&t);n=t; while(t--)
#define tcase()               ll t,n; cin>>t;n=t; while(t--)
#define iscn(num)             scanf("%d",&num);
#define scn(num)              scanf("%lld",&num);
#define scn2(num,num2)        scanf("%lld%lld",&num,&num2);
#define dbg(x)                cerr <<"( "<<#x << " = " << x << " )"<<endl
using namespace std;
const ll INF = 2e18 + 99;
typedef pair<ll,ll> Pair;
typedef vector<ll> vec;;
void FAST_IO();
void ara_read(vec &v,ll n);
////////////////////////

int main()
{
	ll n; 
	scanf("%lld",&n);
	vector<vector<ll> >holiday(n,vector<ll>(3,0));
	vector<vector<ll> >dp(n,vector<ll>(3,0));
	for(int i=0; i< n; ++i){
		scanf("%lld%lld%lld",&holiday[i][0],&holiday[i][1], &holiday[i][2]);
		assert(i!=n);
	}
	for(auto x : {0,1,2}){
		dp[0][x]=holiday[0][x];
	}
	// let's do dp operations...
	for(int i=1 ; i< n; ++i){
		for(int j=0; j< 3 ; ++j){
			for(int x : {0,1,2}){
				if(x==j)
					continue ;
				else {
					dp[i][j]=max(dp[i][j], holiday[i][j]+dp[i-1][x]);
				}
			}
		}
	}
	// printing the ans ...
	printf("%lld\n",max({dp[n-1][0] ,dp[n-1][1] ,dp[n-1][2]}));
    return 0;
}

void FAST_IO()
{
    // ios_base::sync_with_stdio(0);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //cout.setf(ios::fixed);
    //cout.precision(2);

}
void ara_read(vec &v,ll n){
	ll temp;
	for(ll i=0; i<n; i++){
		scanf("%lld",&temp);
		v.emplace_back(temp);
	}
	
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define ll long long int 
#define endl '\n'
#define INF 1000000000
#define MOD 1000000007
#define MAX 200001 
#define pb push_back
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w,m,x,y;
    cin>>h>>w>>m;
    map<int,int> a,b;
    vector<set<int>> v1(h+1);
    h=0;w=0;
    for(int i=0;i<m;i++)
    {
    	cin>>x>>y;
    	v1[x].insert(y);
    	a[x]++;
    	h=max(h,a[x]);
    	b[y]++;
    	w=max(w,b[y]);
    }
    x=h;y=w;
    vector<int> c1,c2;
    for(auto it=a.begin();it!=a.end();it++)
    {
    	if(it->second==x)
    	{
    		c1.pb(it->first);
    	}
    }
    for(auto it=b.begin();it!=b.end();it++)
    {
    	if(it->second==y)
    	{
    		c2.pb(it->first);
    	}
    }
    x=h+w-1;
    bool f=0;
    for(int i=0;i<c1.size();i++)
    {
    	for(int j=0;j<c2.size();j++)
    	{
    		if(v1[c1[i]].find(c2[j])==v1[c1[i]].end())
    		{
    			x++;
    			f=1;
    			break;
    		}
    	}
    	if(f==1)
    	break;
    }
    cout<<x<<endl;
}

Measured memory_bytes: 63488
import java.io.*;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next(), b = sc.next();
        if(a.equals(b))System.out.print('H');
        else System.out.print('D');
    }
}


Measured memory_bytes: 21716
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        char[] s = scan.next().toCharArray();

        List<SegTree> stList = new ArrayList<SegTree>();
        for (int i = 0; i < 26; i++) {
            stList.add(new SegTree(s, i));
        }

        int q = Integer.parseInt(scan.next());
        for (int i = 0; i < q; i++) {
            int a = Integer.parseInt(scan.next());
            if (a == 1) {
                int x = Integer.parseInt(scan.next());
                x--;
                char[] y = scan.next().toCharArray();

                char curChar = s[x];
                stList.get(curChar - 'a').update(x, 0);
                stList.get(y[0] - 'a').update(x, 1);
                s[x] = y[0];
            } else {
                int x = Integer.parseInt(scan.next());
                int y = Integer.parseInt(scan.next());
                x--;
                int ans = 0;
                for (int j = 0; j < 26; j++) {
                    ans += stList.get(j).query(x, y);
                }
                System.out.println(ans);
            }
        }
        scan.close();

    }

    static class SegTree {
        int size = 1;
        int[] node;

        public SegTree(char[] s, int c) {
            while (size < s.length) {
                size *= 2;
            }
            node = new int[2 * size];
            for (int i = 0; i < 2 * size; i++) {
                node[i] = 0;
            }

            for (int i = 0; i < s.length; i++) {
                if (s[i] - 'a' == c) {
                    update(i, 1);
                }
            }
        }

        public void update(int x, int y) {
            int i = x + size - 1;
            node[i] = y;

            while (i > 0) {
                i = (i - 1) / 2;
                node[i] = Math.max(node[2 * i + 1], node[2 * i + 2]);
            }
        }

        public int query(int x, int y) {
            return query(x, y, 0, 0, size);
        }

        private int query(int x, int y, int k, int left, int right) {
            if (y <= left || right <= x) {
                return 0;
            }
            if (x <= left && right <= y) {
                return node[k];
            }

            int l = query(x, y, 2 * k + 1, left, (left + right) / 2);
            int r = query(x, y, 2 * k + 2, (left + right) / 2, right);
            return Math.max(l, r);
        }

    }

}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,k;cin>>n>>k;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  sort(v.begin(), v.end());
  int res=1<<30;
  for(int i=0;i<n;i++){
    int high = i + k - 1;
    if (high >= n) break;
    int t = v[high] - v[i];
    res=min(res, t);
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 640
s = input()

n = list(map(int,s))

c = 0

if n[0] +n[1]+n[2]+n[3]==7:#+++
    if c==0: 
        print(s[0]+'+'+s[1]+'+'+s[2]+'+'+s[3]+'=7')
        c += 1
    
if n[0] +n[1]+n[2]-n[3]==7:#++-
    if c==0:
        print(s[0]+'+'+s[1]+'+'+s[2]+'-'+s[3]+'=7')
        c += 1
    
if n[0] +n[1]-n[2]-n[3]==7:#+--
    if c==0:
        print(s[0]+'+'+s[1]+'-'+s[2]+'-'+s[3]+'=7')
        c += 1
    
if n[0] +n[1]-n[2]+n[3]==7:#+-+
    if c==0:
        print(s[0]+'+'+s[1]+'-'+s[2]+'+'+s[3]+'=7')
        c += 1
    
if n[0] -n[1]-n[2]-n[3]==7:#---
    if c==0:
        print(s[0]+'-'+s[1]+'-'+s[2]+'-'+s[3]+'=7')
        c += 1
    
if n[0] -n[1]-n[2]+n[3]==7:#--+
    if c==0:
        print(s[0]+'-'+s[1]+'-'+s[2]+'+'+s[3]+'=7')
        c += 1
    
if n[0] -n[1]+n[2]+n[3]==7:#-++
    if c==0:
        print(s[0]+'-'+s[1]+'+'+s[2]+'+'+s[3]+'=7')
        c += 1

if n[0] -n[1]+n[2]-n[3]==7:#-+-
    if c==0:
        print(s[0]+'-'+s[1]+'+'+s[2]+'-'+s[3]+'=7')
        c += 1

Measured memory_bytes: 3192
/*************************************************************
     File Name: C.cpp
     Created Time: Sat 07 Apr 2018 08:19:14 PM CST
 ************************************************************/

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    vector<int> v{0,0,0};
    while (cin >> v[0] >> v[1] >> v[2]) {
        sort(v.begin(), v.end());
        // for (auto it : v) {
        //     cout << it << endl;
        // }
        // cout << endl;

        int ans = v[2] - v[1];
        v[0] += ans;
        int tmp = v[2] - v[0];
        // cout << "ans = " << ans << endl;
        // cout << "tmp = " << tmp << endl;;
        if (tmp&1) {
            ans += tmp/2 + 2;
        } else {
            ans += tmp/2;
        }
        // ans += (tmp/2 + tmp%2);
        // cout << "ans = ";
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
inline void read(ll &x){
    x=0;char ch;bool flag = false;
    while(ch=getchar(),ch<'!');if(ch == '-') ch=getchar(),flag = true;
    while(x=10*x+ch-'0',ch=getchar(),ch>'!');if(flag) x=-x;
}
#define rg register int
#define rep(i,a,b) for(rg i=(a);i<=(b);++i)
#define per(i,a,b) for(rg i=(a);i>=(b);--i)
int main(){
    ll A,B;read(A);read(B);
    if(A == B){
        puts("1");
        return 0;
    }
    ll r,k;
    for(r = 60;(A & (1LL << r-1)) == (B & ( 1LL << r-1));-- r);
    A &= (1LL << r) - 1;B &= (1LL << r) - 1;
    ll ans = (1LL << r) - A;
    for(k = r-1;k > 0 && (B & (1LL << (k-1))) == 0;-- k);
    if(A > (1LL << k)) ans -= A - (1LL << k);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

struct Data{
    int A;
    string S;
    
    bool operator<( const Data& right ) const {
        return A == right.A ? S < right.S : A < right.A;
        //return A < right.A;
    }
};

int Func(){
    int x = 0;
    return x;
}

int main(){
    int N;
    long long A[1000];
    float f;
    string S;
    
    cin >> S;
    
    for(int i=0;i<3;i++) {
        if (S[i]=='1') {
            cout << 9;
        }
        else cout << 1;
    }
    
    
    return 0;
}


Measured memory_bytes: 764
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
//        final FastScanner fs = new FastScanner("/Users/igorz/dev/google-prep/src/main/java/atcoder/abc100/input.txt");
        final FastScanner fs = new FastScanner();

        final int[] arr = fs.nextIntArray();
        int res = 0;
        for (int i : arr) {
            res += countDiv(i);
        }
        System.out.println(res);
    }

    static int countDiv(int n) {
        int i = 0;
        while (n != 0 && n % 2 == 0) {
            n /= 2;
            i++;
        }
        return i;
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int[] nextIntArray() {
            final int N = nextInt();
            int[] arr = new int[N];
            for (int i = 0; i < N; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


Measured memory_bytes: 35876
#include<iostream>
using namespace std;
int a[100010];
int main()
{
	int n,k=0,temp,c=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]!=i)
			k++;
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]==i)
		{
			temp=a[i];
			a[i]=a[i+1];
			a[i+1]=temp;
			c++;
		}
	}
	if(k==n)
		cout<<0<<endl;
	else
		cout<<c<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    string s; cin >> s;
    if(s == "ABC") cout << "ARC";
    else cout << "ABC";
}

Measured memory_bytes: 3596
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	while(1){
		c-=b;
		if(c<=0){
			puts("Yes");
			return 0;
		}
		a-=d;
		if(a<=0){
			puts("No");
			return 0;
		}
	}
}


Measured memory_bytes: 1644
#include<stdio.h>
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(c!=-1&&d!=-1)puts(c>d?"Alice":c<d?"Bob":"Draw");
	else puts(a<b?"Alice":a>b?"Bob":"Draw");
}


Measured memory_bytes: 2092
#include<stdio.h>
#include<stdlib.h>
int main(){
  int x,s[10000],i,j=0,num=3,check;
  s[0]=2;
  scanf("%d",&x);
  while(s[j]<x){
    check=0;
    for(i=0;i<=j;i++)
      if(num%s[i]==0){
        check=1;
        break;
      }
    if(check==0){
      s[j+1]=num;
      j++;
    }
    num++;
  }
  printf("%d\n",s[j]);
  return 0;
}


Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (sort, intercalate)

main :: IO ()
main = do
  (n : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  as <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  putStrLn . intercalate " " . map (show . snd) . sort . zip as $ [1..n]

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 29308
from sys import stdin, stdout
import numba as nb 

@nb.njit()
def solve(n,w,weights, values):
	dp = [[0 for _ in range(w+1)] for k in range(n+1)]
	for i in range(1,n+1):
		for j in range(1,w+1):
			if weights[i] <= j:
				dp[i][j] = max(dp[i-1][j],
			   	dp[i-1][j-weights[i]] + values[i])
			else:
				dp[i][j] = dp[i-1][j]
	return dp[n][w]

def main():
	n, w = map(int,stdin.readline().split())
	values = []
	weights = []

	for _ in range(n):
		v,a = map(int, stdin.readline().split())
		values.append(a)
		weights.append(v)

	values = [0] + values
	weights = [0] + weights
	print(solve(n,w,weights,values))

if __name__ == "__main__":
	main()

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

#ifdef LOCAL_PC
	#define debug(args...) cout.flush(); fflush(stdout); fprintf(stderr, args)
#else
	#define debug(args...) ; /*  */
#endif
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class num> inline void rd(num &x) {
	char c; while(isspace(c = getchar()));
	bool neg = false;
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar()))
	x = (x << 3) + (x << 1) + c - '0';
	if (neg) x = -x;
}

const int MAXN = 1e5 + 5, INF = 0x3f3f3f3f;

int main() {
	int n, x; cin >> n >> x;
	int ans = 1, cur = 0;
	for (int i = 0; i < n; i++) {
		int k; cin >> k;
		cur += k;
		ans += cur <= x;
	}
	
	cout << ans << "\n";
}

Measured memory_bytes: 256
from collections import deque
n,q = map(int,input().split())
to = [[] for _ in range(n)]
ans = [0]*n

for _ in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)

for i in range(q): 
    p,x = map(int,input().split())
    p -= 1
    ans[p] += x

stack = deque()
stack.append((0,0))
while len(stack) != 0:
    cn,pn = stack.pop()
    for nn in to[cn]:
        if nn == pn:
            continue
        ans[nn] += ans[cn]
        stack.append((nn,cn))

print(*ans)

Measured memory_bytes: 62232
n,m = map(int,input().split())
a = list()
b = list()
c = 0
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(m):
    b.append(int(input()))
for i in range(n):
    for j in range(m):
        c += a[i][j]*b[j]
    print(c)
    c = 0
    
        


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

using namespace std;

int k1, k2;
int MaxInMp(map<int, int> mp, int &k) {
    int m = 0;
    for (auto it = mp.begin(); it != mp.end(); it++) {
        if (it->second > m)
            m = it->second, k = it->first;
    }
    return m;
}

int main() {
    int n, tmp, m1, mm1, m2, mm2;
    map<int, int> mp1, mp2;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &tmp);
        if (i % 2)
            mp2[tmp]++;
        else
            mp1[tmp]++;
    }
    m1 = MaxInMp(mp1, k1);
    m2 = MaxInMp(mp2, k2);

    if (k1 != k2)
        printf("%d\n", n - (m1 + m2));
    else {
        mp1[k1] = 0, mp2[k2] = 0;
        mm1 = MaxInMp(mp1, k1), mm2 = MaxInMp(mp2, k2);
        printf("%d\n", min(n - (m1 + mm2), n - (m2 + mm1)));
    }
    return 0;
}

Measured memory_bytes: 9472
#include "bits/stdc++.h"
using namespace std;
using lli = long long int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
  int k,s,result=0;
  cin>>k>>s;

  rep(x, k+1)
    rep(y, k+1)
      if(0 <= s-x-y && s-x-y <= k) result++;
  
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

def main():
    N, C = map(int, readline().rstrip().split())
    pair = [tuple(map(int, readline().rstrip().split())) for _ in range(N)]
    x_acc_right = []  # 時計回り方向にi移動した時の最大の利得
    gain, max_gain = 0, 0
    for xi, vi in pair:
        gain += vi
        max_gain = max(max_gain, gain - xi)
        x_acc_right.append(max_gain)
        
    x_acc_left = []  # 反時計回り方向にi移動した時の最大の利得
    gain, max_gain = 0, 0
    for xi, vi in pair[::-1]:
        gain += vi
        max_gain = max(max_gain, gain - (C - xi))
        x_acc_left.append(max_gain)
        
    res = max(x_acc_right[-1], x_acc_left[-1])
    # 時計回りに進んだ後、原点に戻って反時計回りに進むパターン
    gain = 0
    for i in range(N-1):
        xi, vi = pair[i]
        gain += vi
        res = max(res, gain - 2 * xi + x_acc_left[N-i-2])

    # 反時計回りに進んだ後、原点に戻って時計回りに進むパターン
    gain = 0
    for i in range(N-1, 0, -1):
        xi, vi = pair[i]
        gain += vi
        res = max(res, gain - 2 * (C-xi) + x_acc_right[i-1])
        
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 25296
N,S=map(int,input().split())
*a,=map(int,input().split())
mod=998244353

dp=[[0]*(S+1) for _ in range(N+1)]
dp[0][0]=0
ans=0
for i in range(N):
    dp[i+1][0]+=1
    if a[i]<=S:
        dp[i+1][a[i]]+=1
    for j in range(S+1):
        dp[i+1][j]+=dp[i][j]

        if j>=a[i]:
            dp[i+1][j]+=dp[i][j-a[i]]
        
        dp[i+1][j]%=mod
    ans+=dp[i+1][S]
    ans%=mod


print(ans)

Measured memory_bytes: 135460
#include<bits/stdc++.h>
#define pi 3.141592653897932384626
//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
using namespace std;
//#define abs(a) ((a)<0?(-a):(a))
long a[200005];
pair<long,long>b[200005];
long c[200005];
int main()
{
    long n,m=0;
    cin>>n;
    for(long i=0;i<n;i++){
        scanf("%ld",&a[i]);
        if(a[i]>a[m])m=i;
    }
    cout<<a[m]<<' ';
    double f=(a[m]+0.5)/2.0;
    long k=LONG_MAX;
    for(long i=0;i<n;i++){
        if(abs(a[i]-f)<abs(k-f)&&i!=m)
            k=a[i];
    }
    cout<<k<<endl;
	return 0;
}


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

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

signed main() {
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;

    cout << ((A1 + A2 + A3 >= 22) ? "bust" : "win") << "\n";
    
    return 0;
}



Measured memory_bytes: 256
main = do
    a <- readLn :: IO Int
    b <- readLn :: IO Int
    c <- readLn :: IO Int
    d <- readLn :: IO Int
    e <- readLn :: IO Int
    let ls = [a,b,c,d,e]
    let modLs = filter (>0) $ map (`mod` 10) ls
    let last = if modLs == [] then 10 else minimum modLs
    let rounded = sum $ map ((*10). ceiling . (/10).fromIntegral) ls :: Int
    print $ rounded - (10-last)


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){
   Int A; double B; cin >> A >> B;

   Int intB = Int(1000*B)/10;

   cout << (A * intB) / 100 << endl;
}

Measured memory_bytes: 3636
S = input()
T = input()
ls = len(S)
lt = len(T)
flag = False
pos = None
ans = ''

for i in range(ls-lt+1):
  flag = True
  for j in range(lt):
    if S[i+j] != T[j] and S[i+j] != '?':
      flag = False
      break
  if flag:
    pos = i

if pos == None:
  print('UNRESTORABLE')
  exit()

ans = S[:pos] + T + S[pos+lt:]

print(ans.replace('?', 'a'))

Measured memory_bytes: 3064
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

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



int main(void){
  ll N, K; cin >> N >> K;
  vector<ll> A(N); rep(i, N) cin >> A[i];
  ll g = A[0];
  ll m = A[0];
  rep(i, N){
    g = gcd(g, A[i]);
    m = max(m, A[i]);
  }
  if(K % g == 0 && K <= m) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;


}


Measured memory_bytes: 1024