akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solveA();
		// new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			numK = scanner.nextInt();

			if (numN % numK == 0) {
				System.out.println(0);
			} else {
				System.out.println(1);
			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    int x;
    x = r * 100 + g * 10 + b;
    if(x % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())

a = [[0] * 3 for i in range(n+1)]
dp = [[0] * 3 for i in range(n+1)]

for i in range(n):
  a[i] = list(map(int,input().strip().split()))

for i in range(n):
  for j in range(3):
    for k in range(3):
      if j == k:
        continue
      else:
        dp[i+1][k] = max(dp[i+1][k] ,dp[i][j]+ a[i][k])
print(max(dp[n]))

Measured memory_bytes: 77420
# include <bits/stdc++.h>
# define  ll unsigned long long 
using namespace std;
int main(){
  string s;
  ll sum=0;
  cin>>s;
  for(ll i=0;i<s.length();i++)
    	sum+=(s[i]-48);
  sum%9 ? cout<<"No" : cout<<"Yes";  
}

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

static const int MAX = 100005;
static const int NIL = -1;

struct Node{
    int p, l, r;
};

Node T[MAX];
int n, D[MAX];

void print(int u) {
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if(T[u].p == NIL) cout << "root, ";
    else if(T[u].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";

    for(int i=0, c=T[u].l; c!=NIL; ++i, c=T[c].r){
        if(i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

void rec(int u, int p){
    D[u] = p;
    if(T[u].r != NIL) rec(T[u].r, p);
    if(T[u].l != NIL) rec(T[u].l, p+1);
}

int main(){
    cin >> n;
    for(int i=0; i<n; ++i) T[i].p = T[i].l = T[i].r = NIL;

    int c, v, d, l;
    for(int i=0; i<n; ++i){
        cin >> v >> d;
        for(int j=0; j<d; ++j){
            cin >> c;
            if(j == 0) l = T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }

    int r;
    for(int i=0; i<n; ++i){
        if(T[i].p == NIL) r=i;
    }

    rec(r, 0);

    for(int i=0; i<n; ++i) print(i);
}



Measured memory_bytes: 7676
#include <stdio.h>
#include <stdbool.h>
int main()
{
  int X,Y;
  bool ToF =false;
  scanf("%d%d",&X,&Y);

  for (int i = 0; i<100; ++i)
  {
  	for (int j = 0;j<100 ; ++j)
  	{
  		if(((i*2 +j*4) == Y )&&(i+j) ==X){
  			printf("Yes\n");
  			ToF = 1;
  		}
  	}
  }
  if(!ToF)printf("No\n");
}

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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 1000000000

int main(){

    ll n,k;
    cin >> n >> k;

    ll a1,i;

    vector<ll> a;

    for(i=0;i<n;i++){
        cin >> a1;
        a.push_back(a1);
    }

    ll dp[n];

    for(i=0;i<n;i++){
        dp[i] = MAX;
    }
    dp[0]=0;

    for(i=1;i<n;i++){
        for(ll j=1;j<=k;j++){
            if(i>=j){
                dp[i] = min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
            }
        }
    }

    cout << dp[n-1] << endl;

}


Measured memory_bytes: 1908
#include <iostream>

using namespace std;
int n,a,b,c,d;
long long fac[1010],f[1010][1010],rev[1010],mod=1e9+7;

long long exp(long long v,int k)
{
    long long ret=1;
    while (k)
    {
        if (k%2)
            ret*=v,ret%=mod;
        k/=2;
        v*=v;
        v%=mod;
    }
    return ret;
}

int main()
{
    cin >> n >> a >>b >> c >>d;
    fac[0]=rev[0]=1;
    for (long long i=1;i<1010;i++)
        fac[i]=fac[i-1]*i,fac[i]%=mod,rev[i]=rev[i-1]*exp(i,mod-2),rev[i]%=mod;
    f[0][0]=1;
    for (int i=0;i<=b-a;i++)
    {
        for (int j=0;j<=n;j++)
        {
            f[i+1][j]+=f[i][j];
            f[i+1][j]%=mod;
            int cur=c*(a+i),ti=c;
            while (j+cur<=n and cur<=d*(a+i))
            {
                f[i+1][j+cur]+=((((f[i][j]*fac[j+cur])%mod*rev[j])%mod*exp(rev[a+i],ti))%mod*rev[ti])%mod;
                f[i+1][j+cur]%=mod;
                cur+=a+i,ti++;
            }
        }
    }
    cout << f[b-a+1][n] << "\n";
}


Measured memory_bytes: 8192
# A, B = gets.split(" ").map(&:to_i)
S = gets.chomp.split(//)
# N = gets.to_i

ok = true
prev = nil
S.each do |c|
  if prev == c
    ok = false
    break
  end
  prev = c
end
puts ok ? 'Good' : 'Bad'


Measured memory_bytes: 3836
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
double dp[3005][3005];
double p[3005];
int n;

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
	}
	dp[0][0]=1-p[0];
	dp[0][1]=p[0];
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<=i+1;j++)
		{
			dp[i][j]+=dp[i-1][j]*(1-p[i]);
			if(j-1>=0) dp[i][j]+=dp[i-1][j-1]*p[i];
		}
	}
	double res=0;
	for(int i=ceil(n,2);i<=n;i++)
	{
		res+=dp[n-1][i];
	}
	cout.precision(10);
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 68992
H, W = list(map(int, input().split()))
A = []
for i in range(H):
    a = input()
    if set(a) != set('.'):
        A.append(a)

H = len(A)
A2 = []
for i in range(W):
    a = ''
    for j in range(H):
        a += A[j][i]
    if set(a) != set('.'):
        A2.append(a)

H = len(A2)
W = len(A2[0])
A = []
for i in range(W):
    a = ''
    for j in range(H):
        a += A2[j][i]
    A.append(a)

for a in A:
    print(a)

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

int main(){
    
    int N;
    cin >> N;
    
    unsigned long long res;
    
    if(N&1){
        res = N-1;
        res >>= 1;
        res *= N;
    }else{
        res = N;
        res >>= 1;
        res *= N-1;
    }
    
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 3600
import sys
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())

    A = [0]*N
    A[0] = 1
    B = [1]*N
    for q in range(M):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        if A[x] == 1:
            A[y] = 1
        B[x] -= 1
        B[y] += 1
        if B[x] == 0:
            A[x] = 0

    ans = 0
    for i in range(N):
        if A[i] == 1 and B[i] != 0:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4596
n=int(input())
s=[100]*26
for i in range(n):
    a=[0]*26
    for j in list(input()):
        a[ord(j)-97]+=1
    for j in range(26):
        s[j]=min(s[j],a[j])
ans=''
for i in range(26):
    for j in range(s[i]):
        ans=ans+chr(i+97)
print(ans)

Measured memory_bytes: 9096
#include<bits/stdc++.h>
using namespace std;
/*
alias g='g++ -std=c++17 -O2 pra.cpp'
alias a='./a.out'
cd programming
cd cpp
cd practice

*/
/*
clock_t start = clock();
処理
cout<<"cpu時間: "<<(double)(end-start)/CLOCKS_PER_SEC<<"秒"<< endl;
clock_t end = clock();
*/
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
//if (i) cout << " "; で最初のみ空白文字を出力することができる
#define Sort(v) sort((v).begin(), (v).end())
#define pb push_back
using veci = vector<int>;
using vecs = vector<string>;
using vecd = vector<double>;
using vecl = vector<long long>;
using G = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
double PI = acos(-1);
ll lINF = LLONG_MAX; ll lmINF = LLONG_MIN;
int INF = INT_MAX; int mINF = INT_MIN;
struct point{
    double x;
    double y;
};
int main(){
    int k, s; cin >> k >> s;
    int x =0;
    int y = 0;
    int z = 0;
    ll cnt=0;
    for (z=0; z<=k; z++){
        for (y=0; y<=z; y++){
            for (x=0; x<=y; x++){
                if (x + y + z == s){
                    if (x == y && y == z){
                        cnt++;
                    }
                    else if (x != y && y != z && z != x){
                        cnt += 6;

                    }
                    else{
                        cnt += 3;
                    }
                }
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007
#define INF 1000000000000
#define EPS 0.00000000001
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    int n;
    cin>>n;
    vector<ll> a(n);
    ll x=INF;
    ll countm=0;
    ll count=0;
    ll y=0;

    rep(i,n){
        cin>>a[i];
        y+=abs(a[i]);
        x=min(x,abs(a[i]));
        if(a[i]<0){
            countm++;
        }
        if(a[i]==0){
            count++;
        }
    }

    if(count>0){
        cout<<y<<endl;
    }
    else if(countm%2==0){
        cout<<y<<endl;
    }
    else{
        cout<<y-x-x<<endl;
    }

}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
using namespace std;
 
int main(void){
  int count = 0, A, B, num;
  cin >> A >> B;
  if(B > 1){
  num = A;
  count++;
  if(num < B){
  while (1){
    count++;
    num += A - 1;
    if(num >= B){
      break;
    }
  }
  }
  }
  
  cout << count << endl;
 
  return 0;
}

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

struct edge{long long int from,to,cost;};
long long int inf=2000000000000;

edge es[2000];

long long int d[1000];
long long int V,E;

void shortest_path(long long int s){
	for(long long int i=0;i<V;i++)d[i]=inf;
	d[s]=0;
	for(long long int j=0;j<=V;j++){
		bool up=false;
		for(long long int i=0;i<E;i++){
			edge e=es[i];
			if(d[e.from]!=inf&&d[e.to]>d[e.from]+e.cost){
				d[e.to]=d[e.from]+e.cost;
				up=true;
			}
		}
		if(!up)break;
	}
}

void shortest_path2(long long int s){
	for(long long int i=0;i<V;i++)d[i]=inf;
	d[s]=0;
	for(long long int j=0;j<2*V;j++){
		bool up=false;
		for(long long int i=0;i<E;i++){
			edge e=es[i];
			if(d[e.from]!=inf&&d[e.to]>d[e.from]+e.cost){
				d[e.to]=d[e.from]+e.cost;
				up=true;
			}
		}
		if(!up)break;
	}
}


bool find_negative_loop(){
	memset(d,0,sizeof(d));
	
	for(long long int i=0;i<V;i++){
		for(long long int j=0;j<E;j++){
			edge e=es[j];
			if(d[e.to]>d[e.from]+e.cost){
				d[e.to]=d[e.from]+e.cost;
				
				if(i==V-1)return true;
			}
		}
	}
	return false;
}

int main(){
	cin>>V>>E;
	long long int a,b,c;
	for(long long int i=0;i<E;i++){
		cin>>a>>b>>c;
		a--;
		b--;
		c*=-1;
		es[i].from=a;
		es[i].to=b;
		es[i].cost=c;
	}
	
	shortest_path(0);
	long long int ans=-1*d[V-1];
	shortest_path2(0);
	if(ans!=-1*d[V-1]){
		cout<<"inf"<<endl;
	}else{
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define YES cout << "Yes" << endl;
#define NO cout << "No" << endl;
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    int n;
    cin >> n;
    vector<long> a(n);
    vector<long> cnt(n,0);
    rep(i,n){
        long p;
        cin >> p;
        p--;
        a.at(i) = p;
        cnt.at(p)++;
    }
    //vector<int> nc2(n);
    long sum = 0;
    rep(i,n){
        long t = cnt.at(i);
        sum += t*(t-1)/2;
    }
    rep(i,n){
        int j = a.at(i);
        cout << sum - (cnt.at(j) - 1) << endl;
    }
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(ll i=vv;i<n;i++)
#define FORR(i,n,vv) for(ll i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v))-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)




int main(){

	#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	

    FAST
//	PRECISE

ll n,d;
cin>>n>>d;
ll ans=0;
d=d*d;
FOR(i,0,n){
	ll x,y;
	cin>>x>>y;
	ll k=x*x+y*y;
	if(k<=d)ans++;
}
cout<<ans;

return 0;
 }



Measured memory_bytes: 3648
S = input()
L = int(S[:2])
R = int(S[2:])

if 1<=L<=12 and 1<=R<=12:
  print("AMBIGUOUS")
elif 1<=L<=12:
  print("MMYY")
elif 1<=R<=12:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 9128
#include<stdio.h>

#define M 100000
#define INF 1000000001

typedef struct{
  char C;
  int A;
}str;

int partition(str array[],int p,int r){
  int i,j;
  str temp;

  i = p-1;
  for(j=p; j<r; j++){
    if(array[j].A <= array[r].A){
      i++;
      temp = array[i];
      array[i] = array[j];
      array[j] = temp;
    }
  }
  temp = array[i+1];
  array[i+1] = array[r];
  array[r] = temp;

  return i+1;
}

void quicksort(str array[],int p,int r){
  int q;

  if(p < r){
    q = partition(array,p,r);
    quicksort(array,p,q-1);
    quicksort(array,q+1,r);
  }
}

void merge(str marray[],int l,int m,int r){
  int n1 = m-l,n2 = r-m;
  str L[n1+2],R[n2+2];
  int i,j,k;

  for(i=0; i<n1; i++){
    L[i] = marray[l+i];
  }
  for(i=0; i<n2; i++){
    R[i] = marray[m+i];
  }
  L[n1].A = INF;
  R[n2].A = INF;

  i=0;
  j=0;
  for(k=l; k<r; k++){
    if(L[i].A <= R[j].A){
      marray[k] = L[i];
      i++;
    }
    else{
      marray[k] = R[j];
      j++;
    }
  }
}

void mergesort(str marray[],int l,int r){
  int m;

  if(l+1 < r){
    m = (l+r)/2;
    mergesort(marray,l,m);
    mergesort(marray,m,r);
    merge(marray,l,m,r);
  }
}

int main(){
  int i;
  int n;
  char c[3];
  int t;
  str array[M],marray[M];
  int jud = 0;

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%s %d",c,&t);
    array[i].C = marray[i].C = c[0];
    array[i].A = marray[i].A = t;
  }

  mergesort(marray,0,n);
  quicksort(array,0,n-1);

  for(i=0; i<n; i++){
    if(marray[i].C != array[i].C){
      jud = 1;
    }
  }

  if(jud == 1)printf("Not stable\n");
  else printf("Stable\n");
  for(i=0; i<n; i++){
    printf("%c %d\n",array[i].C,array[i].A);
  }

  return 0;
}


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

int main() {
	int a;
	cin >> a;
	if (a < 1000) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ABD" << endl;
	}
}

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

  int n,m,t;
  char a[N][N];
  int f[N][N];
int main()
{
  cin>>n>>m;
  for (int i=0;++i<=n;)
    scanf("%s",a[i]+1);
  f[1][1]=1;
	for (int i=0;++i<=n;)
    for (int j=0;++j<=m;)
      if (a[i][j]=='#')
        ++t,f[i][j]|=f[i-1][j]|f[i][j-1];
  if (t==n+m-1&&f[n][m])
    puts("Possible");
  else
    puts("Impossible");
  exit(0);
} 

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

int main() {
  string s;
  int count = 0, temp = 0;
  cin >> s;
  for (int i=0; i<s.size(); i++) {
    if (s[i]=='C' || s[i]=='G' || s[i]=='A' || s[i]=='T') temp++;
    else {
      if (temp>count) count=temp;
      temp = 0;
    }
  }
  if (temp>count) count=temp;
  cout << count;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX = 1000;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L

int main() {
	ll X, K, D; cin >> X >> K >> D;
	X = abs(X);

	ll tmp1 = X % D;
	ll tmp2 = D - tmp1;
	ll tmp3 = min(tmp1, tmp2);

	if ((K > X/D) && (K - X/D) % 2 == 1) cout << tmp2 << endl;
	else if ((K > X/D) && (K - X/D) % 2 == 0) cout << tmp1 << endl;
	else if (K == X/D) cout << tmp1 << endl;
	else cout << X - K*D << endl;
}

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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }


ll dp[100002][2];

ll solve(string &s){
    int L = s.size();
    vi a(L);
    rep(i,L) a[i] = s[i] - '0';
    reverse(ALL(a));

    int carry = 1;
    for (int i=0; i<L; ++i) {
        a[i] += carry;
        if (a[i] == 2) {
            a[i] = 0; carry = 1;
        } else {
            carry = 0;
        }
    }
    if (carry) { a.pb(carry); ++L; }
    reverse(ALL(a));

    mset(dp, 0);
    dp[0][0] = 1;
    rep(i,L){
        rep(j,2){
            int lim = j ? 1 : a[i];

            rep(d, lim+1) {
                int p = d ? 2 : 1;
                (dp[i+1][j || d<lim] += dp[i][j]*p) %= MOD;
            }
        }
    }

    return dp[L][1];
}

int naive(string& s){
    int L=s.size();
    int x = 0;
    rep(i,L) x = x*2 + (s[i]-'0');
    if (x > 100) return 0;

    int ans = 0;
    for (int a=0; a<=x; ++a) {
        for (int b=0; b<=x-a; ++b) {
            if (a+b == (a^b))
                ++ans;
        }
    }
    return ans;
}


int main() {
    string s; cin >> s;
    ll ans = solve(s);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2432
n,m = map(int,input().split())

a = [0 for i in range(n)] 
b = [0 for i in range(m)]

for i in range(n):
    a[i] = list(map(int,input().split()))

for i in range(m):
    b[i] = int(input())


for i in range(n):  
    c=0
    for j in range(m):
        c += a[i][j]*b[j]
    print(c)    


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

int main () {
  int N , K ;
  cin >> N >> K ;
  
  int line[N] ;
  
  for(int i = 0 ; i < N ; i++ ) {
    cin >> line[i] ;
  }
  
  sort(line,line+N,greater<int>()) ;
  
  int ans = 0 ;
  
  for(int i = 0 ; i < K ; i++ ) {
    ans += line[i] ;
  }
  
  cout << ans << endl ;
  
}

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

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")

using namespace std;

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

const int N = 5000 + 10;
const int MOD = 1000000007;
const int LOG = 20;
const int INF = 1000000010;
const int delta = 11353;

int n, m, DP[N][N], T2[N];

inline int mul(int a, int b){
	return a * 1ll * b % MOD;
}

inline int add(int a, int b){
	a += b;
	if (a >= MOD)a -= MOD;
	return a;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	T2[0] = 1;
	for (int i = 1; i < N; i++) T2[i] = T2[i - 1] * 2ll % MOD;
	for (int i = 1; i <= m; i++) DP[1][i] = T2[i];
	for (int i = 2; i <= n; i++){
		int sm = 0;
		for (int j = 1; j <= m; j++){
			DP[i][j] = mul(DP[i - 1][j], j + 1);
			if (j > 1){
				sm = mul(sm, 2);
				sm = add(sm, mul(j - 1, DP[i - 1][j - 1]));
				DP[i][j] = add(DP[i][j], sm);
			}
//			cout << i << ' ' << j << ' ' << DP[i][j] << '\n';
		}
	}
	cout << DP[n][m];
	return 0;
}


Measured memory_bytes: 101460
# coding: utf-8
#import numpy as np
import sys
n = int(input())
h = list(map(int, input().split()))

tmp = 0

for i in range(1, n):
    if (h[i-1]-h[i]) >= 2:
        print("No")
        sys.exit()
    elif (h[i-1]-h[i]) == 1:
        if tmp == 1:
            print("No")
            sys.exit()
        else:
            tmp = 1
    elif (h[i-1]-h[i]) < 0:
        tmp = 0
print("Yes")

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

int main() {
	
	int n, m;
	cin >> n >> m;
	cout << (n-1)*(m-1) << endl;
	
	return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

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

// A: 0, C: 1, G: 2, T: 3
int dp[110][4][4][4];
int main()
{
  int N; cin >> N;
  REP(i, 4) REP(j, 4) REP(k, 4) dp[2][i][j][k] = 1;
  for (int i = 1; i < N; i++) {
    REP(j, 4) {
      REP(k, 4) {
        REP(l, 4) {
          if (   (j == 0 && k == 1 && l == 2)
              || (j == 2 && k == 0 && l == 1)
              || (j == 0 && k == 2 && l == 1)) continue;

          if (   (j == 0           && l == 2)
              || (j == 0 && k == 2          )
              || (          k == 0 && l == 2)
              || (          k == 2 && l == 0)) {
            (dp[i + 1][k][l][0] += dp[i][j][k][l]) %= MOD;
            (dp[i + 1][k][l][2] += dp[i][j][k][l]) %= MOD;
            (dp[i + 1][k][l][3] += dp[i][j][k][l]) %= MOD;
          } else if (k == 2 && l == 0) {
            (dp[i + 1][k][l][0] += dp[i][j][k][l]) %= MOD;
            (dp[i + 1][k][l][1] += dp[i][j][k][l]) %= MOD;
            (dp[i + 1][k][l][3] += dp[i][j][k][l]) %= MOD;
          } else {
            (dp[i + 1][k][l][0] += dp[i][j][k][l]) %= MOD;
            (dp[i + 1][k][l][1] += dp[i][j][k][l]) %= MOD;
            (dp[i + 1][k][l][2] += dp[i][j][k][l]) %= MOD;
            (dp[i + 1][k][l][3] += dp[i][j][k][l]) %= MOD;
          }
        }
      }
    }
  }
  int ans = 0;
  REP(i, 4) {
    REP(j, 4) {
      REP(k, 4) {
        if (   (i == 0 && j == 1 && k == 2)
            || (i == 2 && j == 0 && k == 1)
            || (i == 0 && j == 2 && k == 1)) continue;
        (ans += dp[N - 1][i][j][k]) %= MOD;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	int N, M;
  	cin >> N >> M;
  	for(int i=0;i<M;i++){
  		int tmp;
  		cin >> tmp;
  		N -= tmp;
  	}
  	cout << max(-1, N) <<endl;

    
  	return 0;
}



Measured memory_bytes: 3560
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
        solve();
    }

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] v = new int[n];
        HashMap<Integer, Integer> oddlist = new HashMap<Integer, Integer>();
        HashMap<Integer, Integer> evenlist = new HashMap<Integer, Integer>();
        for(int i=0;i<n;i++){
        	v[i] = sc.nextInt();
        	if(i%2==0){
	        	if(oddlist.containsKey(v[i])){
    	    		int x = oddlist.get(v[i]);
        			oddlist.put(v[i], x+1);
        		}
        		else{
        			oddlist.put(v[i], 1);
        		}
        	}
        	else{
        		if(evenlist.containsKey(v[i])){
    	    		int x = evenlist.get(v[i]);
        			evenlist.put(v[i], x+1);
        		}
        		else{
        			evenlist.put(v[i], 1);
        		}	
        	}
        }
        if(evenlist.size()==1 && oddlist.size()==1 && v[0]==v[1]){
        	System.out.println(n/2);
        }
        else{
        	int[] oddn = new int[2];
        	int[] oddm = new int[2];
        	int[] evenn = new int[2];
        	int[] evenm = new int[2];
        	for(int x : oddlist.keySet()){
        		if(oddm[0]<oddlist.get(x)){
        			oddn[1] = oddn[0];
        			oddm[1] = oddm[0];
        			oddn[0] = x;
        			oddm[0] = oddlist.get(x);
        		}
        		else if(oddm[1]<oddlist.get(x)){
        			oddn[1] = x;
        			oddm[1] = oddlist.get(x);
        		}
        	}
        	for(int x : evenlist.keySet()){
        		if(evenm[0]<evenlist.get(x)){
        			evenn[1] = evenn[0];
        			evenm[1] = evenm[0];
        			evenn[0] = x;
        			evenm[0] = evenlist.get(x);
        		}
        		else if(evenm[1]<evenlist.get(x)){
        			evenn[1] = x;
        			evenm[1] = evenlist.get(x);
        		}
        	}
        	int ans = n;
        	for(int i=0;i<2;i++){
        		for(int j=0;j<2;j++){
        			if(oddn[i]!=evenn[j]){
        				ans = Math.min(ans, ((n+1)/2-oddm[i]) + (n/2-evenm[j]));
        			}
        		}
        	}
        	System.out.println(ans);
        }
    }
}

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

int main() {
	int N, T;
	cin >> N >> T;
	int MIN = 1001;
	for (int i = 0; i < N; i++) {
		int c, t;
		cin >> c >> t;
		if (t <= T) MIN = min(MIN, c);
	}
	if (MIN == 1001) cout << "TLE" << endl;
	else cout << MIN << endl;
}


Measured memory_bytes: 256
#include<iostream>
#define INF 100000000
using namespace std;
int main(){
  int n,m,sumt,sumh,min_s,t0,t1;
  int ta[100],ha[100];
  cin >> n >> m;
  while(!(n==0&&m==0)){
    sumt=0;
    sumh=0;
    min_s=INF;
    for(int i=0;i<n;i++){
      cin >> ta[i];
      sumt+=ta[i];
    }
    for(int i=0;i<m;i++){
      cin >> ha[i];
      sumh+=ha[i];
    }
    bool f=false;
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        if(sumt+ha[j]-ta[i]==sumh+ta[i]-ha[j]){
          if(min_s>ha[j]+ta[i]){
            min_s=ha[j]+ta[i];
            t0 = ta[i];
            t1 = ha[j];
          }
        }
      }
    }
    if(min_s==INF){
      cout << "-1\n";
     }else{
       cout << t0 <<" "<<t1 << endl;
     }
    cin >> n >> m;
  }
}



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

using namespace std;

bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

int main() {

	int q;
	cin >> q;
	int l, r;
	vector<int> pp(100010);
	for (int i = 1; i <= 100000; i++) {
		pp[i] = IsPrime(i) & IsPrime((i+1)/2);
	}
	vector<int> ppp(100010);
	for (int i = 1; i <= 100000; i++) {
		ppp[i] = ppp[i - 1] + pp[i];
	}

	for (int j = 0; j < q; j++) {
		cin >> l >> r;

		cout << ppp[r]-ppp[l-1] << endl;
	}
}

Measured memory_bytes: 1408
# 素数を３からN個
N = int(input())

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i] and i%5 == 1]

A = primes(5000) # Aの長さは55を超える
print(*A[:N])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<string>S(N);
    for(int i = 0; i < N; i++) {
        cin >> S[i];
    }
    int A = 0,B = 0,C = 0;
    int ans = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 1; j < (int)S[i].size(); j++) {
            if(S[i][j] == 'B' && S[i][j-1] == 'A') {
                ans++;
                j++;
            }
        }
        if(S[i][0] == 'B') {
            if(S[i][(int)S[i].size()-1] == 'A') {
                C++;
            }
            else {
                B++;
            }
        }
        if(S[i][S[i].size()-1] == 'A' && S[i][0] != 'B') {
            A++;
        }
    }
    if(A+B == 0 && C > 0) {
        C--;
    }
    cout << ans+min(A,B)+C << endl;
}

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

#define _GLIBCXX_DEBUG

//vector<int> A(M), B(M);
//vector<vector<char>> answer(N, vector<char>(N, '-'));

int main() {
  long long a;
  double b;

  cin >> a >> b;
  long long c;
  c = b*100+0.1;
  long long ans = a*c/100;
  cout << ans << endl;
}

Measured memory_bytes: 3712
#include<iostream>
using  namespace std;
int main() {
    int i,x,n;
    while(cin>>x) {
        n=0;
        for(i=0; i<=x; i++) {
            n+=i;
            if(n>=x) {
                cout<<i<<endl;
                break;
            }
        }
    }
    return 0;
}




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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int K;
    cin >> K;
    cout << (K / 2) * (K - K / 2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    long long int n, ans=0;
    cin>>n;
    
    unordered_map<long long int, int> mp;
    
    while(n%2==0)
    {
        mp[2]++;
        n=n/2;
    }
    
    for (long long int i=3; i<=sqrt(n); i=i+2)  
    {  
        while(n%i == 0)  
        {  
            mp[i]++;
            n = n/i;  
        }  
    }
    
    if(n>2)
    {
        mp[n]++;
    }
    
    for(auto it=mp.begin(); it!=mp.end(); it++)
    {
        long long int l=1, r=it->second, temp=it->second;
        while(l<=r)
        {
            long long int mid=l+(r-l)/2;
            if((mid*(mid+1))/2 <= temp && ((mid+2)*(mid+1))/2 <= temp)
            {
                l=mid+1;
            }
            else if((mid*(mid+1))/2 <= temp && ((mid+2)*(mid+1))/2 > temp)
            {
                ans=ans+mid;
                break;
            }
            else if(((mid)*(mid+1))/2 > temp)
            {
                r=mid-1;
            }
        }
    }
    
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3676
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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(){ 
    int antena[5], k; rep(i, 5) cin >> antena[i]; cin >> k;
    bool fg = true;

    rep(i, 4){
        for(int j=i+1; j<5; j++){
            if(antena[j] - antena[i] > k) fg = false;
        }
    }
    if(fg) cout << "Yay!" << ln;
    else cout << ":(" << ln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll = long long int
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define REP3(i,x,n) for(int i=x; i>(n); i--)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    long long n,cmt=0;
    scanf("%lld",&n);
    REP(i,n+1){
        if(i%3!=0&&i%5!=0)cmt += i;
    }
    printf("%lld",cmt);
    
    return 0;
}

Measured memory_bytes: 3852
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N=ri()
F=[rl() for _ in range(N)]
P=[rl() for _ in range(N)]
ans = -INF

import itertools
for d in itertools.product(range(2),repeat=10):
    if sum(d) == 0: continue
    res = 0
    for i in range(N):
        res += P[i][sum(map(lambda x,y:x&y, F[i], d))]
    ans = max(ans,res)

print(ans)

Measured memory_bytes: 3064
/* title: Party
 * source: JOI2009-2010 Yosen No.3
 * hint:
 * 多頂点最短路を探索して自分からの距離が2以下のものを列挙すればよい
 * 最短路探索はDijkstra, Bellman-Ford, Warshall-Floydなどのアルゴリズムが有名
 * Warshall-Floyd が一番簡単なのでこれだけでも覚えておこう
 * でも実際、予選は全ての資料を持込可能なので覚えている必要もない
 * 蟻本のどこに載っているかぐらいは覚えておこう
 */



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


const int INF = 1 << 30;


int main()
{
	while(true) {
		int N, M;
		cin >> N >> M;

		if(!(N || M)) break;

		vector<vector<int> > G(N, vector<int>(N, INF));
		for(int i = 0; i < M; i++) {
			int a, b;
			cin >> a >> b;
			G[a-1][b-1] = G[b-1][a-1] = 1;
		}

		for(int i = 0; i < N; i++)
			for(int j = 0; j < N; j++)
				for(int k = 0; k < N; k++)
					if(G[i][k] != INF && G[k][j] != INF)
						G[i][j] = min(G[i][j], G[i][k] + G[k][j]);

		cout << count_if(G[0].begin()+1, G[0].end(), [](int l){ return l <= 2; }) << endl;
	}
}

Measured memory_bytes: 2124
import sys
from functools import lru_cache
def input(): return sys.stdin.readline().rstrip()

sys.setrecursionlimit(10 ** 9)

@lru_cache(maxsize=None)
def calc(n):
    if n == 1:
        return 1
    else:
        return n + calc(n - 1)

def main():
    N, K = map(int, input().split())
    P = tuple(map(int, input().split()))

    l = 0
    sum_v = 0
    max_v = 0
    max_i = 0
    ind = 0
    for i in range(N-K+1):
        while l < K:
            sum_v += P[ind]
            ind += 1
            l += 1
        if sum_v > max_v:
            max_v = sum_v
            max_i = i
        l -= 1
        sum_v -= P[i]
    print(sum([calc(p) / p for p in P[max_i:max_i+K]]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 26068
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int X,Y,Z,K;
  cin>>X>>Y>>Z>>K;
  lint A[X],B[Y],C[Z],D[Y*Z],E[X*min(K,Y*Z)];
  REP(i,X)cin>>A[i];
  REP(i,Y)cin>>B[i];
  REP(i,Z)cin>>C[i];
  int k=0;
  REP(i,Y)REP(j,Z){
    D[k]=B[i]+C[j];
    k++;
  }
  sort(A,A+X,greater<lint>());
  sort(D,D+Y*Z,greater<lint>());
  k=0;
  REP(i,X)REP(j,min(K,Y*Z)){
    E[k]=A[i]+D[j];
    k++;
  }
  sort(E,E+X*min(Y*Z,K),greater<lint>());
  REP(i,K)cout<<E[i]<<endl;
  return 0;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;
ll n, T, res, t[(int)3e6];
int main() {
  cin >> n >> T;
  rep(i, n) cin >> t[i];
  rep(i, n - 1) {
    if (t[i + 1] - t[i] < T) res -= (t[i] + T - t[i + 1]);
  }
  res += T * n;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

long long int n,step;

int main(){
	while(scanf("%d",&n)!=EOF && n>0){
		step=0;
		while(n>1){
			step++;
			if(n%2)n=3*n+1; else n=n/2;
		}
		printf("%d\n",step);
	}
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define yes "Yes\n"
#define no "No\n"
//int m,n;
//int i,j,k,l;
int a,b,c,d,e,f,g;
int x,y,z;
//int sum,total;
//long long int ;
//float ;
//double ;
//char a[101],b[101],s[101],t[101],u[101];
int main(void){
    scanf("%d %d %d",&x,&y,&z);
    printf("%d %d %d\n",z,x,y);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

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

        int N = scanner.nextInt();
        int Y = scanner.nextInt();

        for (int i = 0; i <= N; i++) {
            for (int j = 0; j <= N - i; j++) {
                int remaining = Y - 10000 * i - 5000 * j;
                if (remaining / 1000 == N - i - j) {
                    System.out.println(i + " " + j + " " + (N - i - j));
                    return;
                }
            }
        }

        System.out.println("-1 -1 -1");
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
//#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int k,t;

int mm=0;

int main(){
	cin>>k>>t;
	REP(i,t){
		int a;
		cin>>a;
		mm=max(a,mm);
	}
	int ans=mm-(k-mm)-1;
	if(ans<0)
		ans=0;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
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 a[] = new int[n];
		
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		
		long result = Long.MAX_VALUE;
		
		for(int i = -100; i <= 100; i++) {
			long tmp = 0;
			
			for(int j = 0; j < n; j++) {
				tmp += Math.pow(a[j] - i, 2);
			}
			
			result = Math.min(tmp, result);
		}
		
		System.out.println(result);
	}	
}


Measured memory_bytes: 23124
#include<cstdio>
#include<algorithm>
int main(){
    int n,a,b,p,pcnt[3]={};
    scanf("%d%d%d",&n,&a,&b);
    for(int i=0;i<n;i++){
        scanf("%d",&p);
        if(p<=a)pcnt[0]++;
        else if(p<=b)pcnt[1]++;
        else pcnt[2]++;
    }
    std::sort(pcnt,pcnt+3);
    printf("%d",pcnt[0]);
    return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, k;
  cin >> n >> k;
  double ans = 0;
  for (int i = 1; i <= n; i++) {
    int score = i;
    double prob = 1;
    while (score < k) {
      score *= 2;
      prob /= 2;
    }
    ans += prob / n;
  }
  cout << setprecision(20) << fixed << ans << endl;
  return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  long long sum = 0;
  int ans = 0;
  for(int i = 0; i < N; ++i) {
    if(2 * sum < A[i]) {
      ans = i;
    }
    sum += A[i];
  }
  std::cout << N - ans << std::endl;
  return 0;
}


Measured memory_bytes: 640
a = input()
l = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
s = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
if a in l:
    print("A")
elif a in s:
    print("a")

Measured memory_bytes: 9012
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n;
  cin >> n;
  double v[n];
  rep(i,n)cin>>v[i];
  sort(v,v+n);
  for(int i=1;i<n;i++){
    v[i]=(v[i]+v[i-1])/2;
  }
  cout<< setprecision(20) << v[n-1] << endl;
}


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


int main() {
  int N, A;
  cin >> N >> A;
  vector<int> x(60);
  vector<vector<vector<long long>>> dp(60, vector<vector<long long>>(60, vector<long long>(5100)));

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

  dp.at(0).at(0).at(0) = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k <= 5000; k++) {
        dp.at(i+1).at(j).at(k) += dp.at(i).at(j).at(k);
        if (k >= x.at(i)) {
          dp.at(i+1).at(j+1).at(k) += dp.at(i).at(j).at(k-x.at(i));
        }
      }
    }
  }

  long long ans = 0;
  for (int j = 1; j <= N; j++) {
    ans += dp.at(N).at(j).at(j*A);
  }
  cout << ans << endl;
}


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

//ll gcd(int a, int b){ return b? gcd(b,a%b) : a ; } 

int main(){
    int n ;
    cin >> n ;
    ll ans = 1e18 ;
    ll sum = 0 ;
    ll count = 0 ;
    int a[n] ;
    rep(i,n) cin >> a[i] ;
    rep(i,n) sum += a[i] ;
    sum = sum / n ;
    rep(i,n) count += pow( sum - a[i] ,2) ;
    ans = min(ans,count) ;
    count = 0 ;
    rep(i,n) count += pow( sum-1 - a[i] ,2) ;
    ans = min(ans,count) ;
    count = 0 ;
    rep(i,n) count += pow( sum+1 - a[i] ,2) ;
    ans = min(ans,count) ;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
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(){
	int k;cin>>k;
	for(int i = 0; i < k; i++) {
		cout << "ACL";
	}	
	cout << endl;
	return 0;
}

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

int Rect[100][100];
int W, H, N;
int x, y, a;

void paint(int x, int y, int a){
    if(a == 1){
        for(int i = 0; i < H; i++){
            for(int j = 0; j < x; j++) Rect[i][j] = 1;
        }
    }else if(a == 3){
        for(int i = 0; i < y; i++){
            for(int j = 0; j < W; j++) Rect[i][j] = 1;
        }
    }else if(a == 2){
        for(int i = 0; i < H; i++){
            for(int j = x; j < W; j++) Rect[i][j] = 1;
        }
    }else{
        for(int i = y; i < H; i++){
            for(int j = 0; j < W; j++) Rect[i][j] = 1;
        }
    }
}

int main(){
    cin >> W >> H >> N;
    for(int i = 0; i < N; i++){
        cin >> x >> y >> a;
        paint(x, y, a);
    }

    int ans = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(Rect[i][j] == 0) ans++;
        }
    }
    cout << ans;
    return 0;
}

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

#define rep(i, c) for(long long i=0; i<(long long)c; i++)
int main() {
	long long n;

	cin>>n;
	vector<pair<long long,int>> fs;
	for(long long i=2;i*i<=n;++i){
		int x=0;
		while(n%i==0){
			n/=i;
			++x;
		}
		fs.emplace_back(i,x);
	}
	if (n!=1) fs.emplace_back(n,1);
	int ans=0;
	for(auto p:fs){
		int x =p.second;
		int b=1;
		while(b<=x){
			x-=b;
			b++;
			++ans;
		}
	}
	cout << ans<<endl;

	return 0;
}


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

int main() {

  int n;
  cin >> n ;
  vector<int> C(n); 

  for (int i=0;i<n;i++){
    cin >> C.at(i) ;
  }

  sort(C.begin(),C.end());
  reverse(C.begin(),C.end());

  int A=0,B=0;

  for (int j=0;j<n;j=j+2){
    A=A+C.at(j);
    
    if (j+1<n){
      B=B+C.at(j+1);
    }
   
  }

  cout << A-B << endl;
  
}


Measured memory_bytes: 3640