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

    // for debug
    void show_vector( vector<ll> A ){
            for(int i=0; i<A.size(); i++){
                cout<< A.at(i) << endl; 
            }
    }
            int main(){
                ll N, K;
                cin >> N >> K ;
                ll S_zero=0 ; 
                vector<ll> c(41);  
                
                for(int i=0; i<N; i++){
                    ll A; 
                    cin >> A;
                    S_zero += A; 
                    bitset<41> bin(A);
                    for(int j=0; j<41; j++){
                        if( bin.test(j)==1 ) c.at(j)++; 
                    }
                }
                
                vector<ll> pot(42);
                pot.at(0)=1; 
                for(int i=1; i<42; i++){
                    pot.at(i)=2*pot.at(i-1); 
                }
                
                
                bitset<41> s(K); 
                
                ll M=0; 
                
                for(int i=40; i>=0; i--){
                    ll S=0; 
                        if(s.test(i)==1){
                            
                                for(int j=0; j<41; j++){
                                    
                                    if(j<i){
                                            if( c.at(j) > N-c.at(j) ) S = S + c.at(j) * pot.at(j); 
                                            if( c.at(j) <= N-c.at(j) ) S = S + (N - c.at(j)) * pot.at(j);  //なぜかmaxが使えない
                                            
                                    }else if(j>i){
                                        
                                        if(s.test(j)==1){
                                            S = S + (N - c.at(j)) * pot.at(j);   
                                        }else{
                                            S = S + c.at(j) * pot.at(j);  
                                        }
                                        
                                    }else{
                                        S = S + c.at(j) * pot.at(j); 
                                    }
                                    
                                }
                        }
                    M = max(M,S); 
                }
                
                
                ll T=0; 
                for(int j=0; j<41; j++){
                    
                                        if(s.test(j)==1){
                                            T = T + (N - c.at(j)) * pot.at(j);   
                                        }else{
                                            T = T + c.at(j) * pot.at(j);  
                                        }                    
                    
                }
                M=max(M,T); 
                
                cout<< max(M,S_zero) << endl; 
                
                /* for check 
                bitset<5> A("00101"); 
                cout<< ((A>>2)<<2) << endl;
                */
            
                
            }

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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int check(int a[3])
{
    qsort(a, 3, sizeof(int), compare_int);
    return a[0] * a[0] + a[1] * a[1] - a[2] * a[2];
}

int main(void)
{
    int t;
    scanf("%d", &t);
    for (int i = 0; i < t; i++) {
        int sides[3];
        for (int j = 0; j < 3; j++) {
            scanf("%d", &sides[j]);
        }
        if (check(sides) == 0) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1012
using System;

class BitterAlchemy{
    static void Main(string[] args){
        var nx = Console.ReadLine();
        int n = int.Parse(nx.Split(' ')[0]);
        int x = int.Parse(nx.Split(' ')[1]);

        var sum = 0;
        var smallest = x;
        for(int i=0; i<n; i++){
            var mn = int.Parse(Console.ReadLine());
            sum = sum + mn;
            if(smallest > mn){
                smallest = mn;
            }
        }

        var nokori = x - sum;
        var max = nokori/smallest;

        Console.WriteLine(n + max);
    }
}

Measured memory_bytes: 13140
n,k,q = map(int, input().split())
A = [int(input()) for i in range(q)]
S = [k] * n
for i in range(q):
  S[A[i]-1] += 1
  
ANS = [S[i]- q for i in range(n)]
for i in range(n):
  if ANS[i] <= 0:
    print("No")
  else:
    print("Yes")

Measured memory_bytes: 14440
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[105]; 
int main()
{
	cin>>n;
	a[0]=2;
	for(int i=0;i<=n;i++)
	{
		a[i]=a[i-1]*2+2;
	}
	cout<<a[n]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 100010
using namespace std;
typedef long long ll;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
int a[maxn];
int head[maxn],nxt[maxn*2],to[maxn*2],tot;
void add(int u,int v)
{
    tot++;
    nxt[tot]=head[u];
    head[u]=tot;
    to[tot]=v;
}
int deg[maxn],rt;
ll solve(int x,int las)
{
    if(deg[x]==1)  return a[x];
    int rem=2*a[x];
    for(int i=head[x];i;i=nxt[i])
    {
        if(to[i]==las)  continue;
        ll tmp=solve(to[i],x);
        if(tmp>a[x])
        {
            puts("NO");
            exit(0);
        }
        rem-=tmp;
    }
    if(rem<0||rem>a[x])
    {
        puts("NO");
        exit(0);
    }
    return rem;
}
int main()
{
    n=read();
    for(int i=1;i<=n;i++)  a[i]=read();
    for(int i=1;i<n;i++)
    {
        int q=read(),w=read();
        add(q,w);
        add(w,q);
        deg[w]++;deg[q]++;
    }
    if(n==2)
    {
        if(a[1]!=a[2])  puts("NO");
        else            puts("YES");
        return 0;
    }
    for(int i=1;i<=n;i++)
    {
        if(deg[i]>1)
        {
            rt=i;
            break;
        }
    }
    if(solve(rt,0))  puts("NO");
    else             puts("YES");
    return 0;
}

Measured memory_bytes: 7040
///////////////////////////////////////////
//                                       //
//      Gagan_Sharma : DTU               // 
//                                       //                   
///////////////////////////////////////////
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int        long long
// #define mp      make_pair
#define eb         emplace_back
#define pb         push_back
#define ss         second
#define ff         first
#define IOS        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod        998244353
#define MOD        (1000*1000*1000+7)
#define MN         LLONG_MIN
#define MX         LLONG_MAX
#define v1d        vector<int>
#define v2d        vector<vector<int>>
#define vip        vector<pair<int,int> >
#define v1s        vector<string>
#define pa         pair<int,int>
#define mxpq(T)    priority_queue <T>
#define mnpq(T)    priority_queue<T,vector<T>,greater<T>>
#define print(v)   for(auto i:v)cout<<i<<" ";cout<<"\n";
#define p2d(v)     for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)     for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)     for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define endl       '\n'
#define input(b,n) for(int i=0;i<n;i++)cin>>b[i];
#define Sort(v)    sort(v.begin(),v.end())
#define RSort(v)   sort(v.rbegin(),v.rend())
#define all(v)     v.begin(),v.end()
int gcd(int a,int b){return b?gcd(b,a%b):a;}
//string s = bitset<64>(a).to_string();

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define fbo find_by_order // iterator to the kth element
#define ook order_of_key  //number of items that are strictly smaller than our item k
// #define T pair<int, int>
// #define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>

void read(int n=12){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<setprecision(n)<<fixed;
    // #ifndef ONLINE_JUDGE
    //      freopen("input.txt",  "r",  stdin);
    //      freopen("output.txt", "w", stdout);
    // #endif
}

//____________________________________________________________________________________


void solve(){
    int a,b;
    cin>>a>>b;
    if(a <= b){
        cout<<"unsafe";
    }
    else cout<<"safe";
    
}
 
int32_t main(){
    read();
    int t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
    


    return 0;
}                                                                                         


Measured memory_bytes: 3636
main=do
 n<-readLn;a<-map read.words<$>getLine
 print(min(f n a 1 0 0)(f n a (-1) 0 0))
  where f n a b s i |n==0 =i
                    |b==1&&(s+(head a))<=0    =f (n-1) (tail a) (-1) 1 (i+1-(s+(head a)))
                    |b==(-1)&&(s+(head a))>=0 =f (n-1) (tail a) 1 (-1) (i+1+(s+(head a)))
                    |otherwise                =f (n-1) (tail a) (-1*b) (s+(head a)) i

Measured memory_bytes: 52604
import java.util.*;
import java.lang.*;
import java.io.*;
 
/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
 
		int A = sc.nextInt();
		int P = sc.nextInt();
		int B;
 
		System.out.println((A*3 + P)/2);
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAX = 10000002;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void init_combination(){
    fac[0] =  fac[1] = 1;
    inv[1] = 1;
    finv[0] = finv[1] = 1;
    for(ll i=2;i<MAX;i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

ll combination(ll n, ll k){
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main(){
    ll x, y; cin >> x >> y;
    ll a, b;
    if((x+y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    }
    if((x > 2 * y) || (y > 2 * x)){
        cout << 0 << endl;
        return 0;
    }
    a = (2 * y - x) / 3;
    b = (2 * x - y) / 3;
    init_combination();
    ll res = combination(a+b, a);
    cout << res << endl;
}


Measured memory_bytes: 234624
#include <bits/stdc++.h>
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n;
    cin>>n;
    vector<int> vec(n);
    int ans=0;
    for(i=0;i<n;i++){
        cin>>vec[i];
        while(vec[i]%2==0){
            ans++;
            vec[i]/=2;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b,c,d,e,g=0;cin>>a>>b;
  c=a+b;
  if(a%3==0||b%3==0||c%3==0){
    cout<<"Possible";
  }
  else cout<<"Impossible";
  }


Measured memory_bytes: 23680
#include <cstdio>
using namespace std;
int k,n;
double ans;
int p[200005];
double sum[200005];
int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++){
		scanf("%d",&p[i]);
		sum[i]=sum[i-1]+1.0*(p[i]+1)/2.0;
	}
	for (int i=1;i+k-1<=n;i++){
		int j=i+k-1;
		double now=sum[j]-sum[i-1];
		ans=now>ans?now:ans;
	}
	printf("%lf",ans);
	return 0;
}


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

int cnt_bouding(int N,int X){
    int position=0;
    int cnt=1;
    int L;
    for(int i=0;i<N;i++){
        cin >> L;
        position+=L;
        if(position<=X){
            cnt++;
        }
        else{
            break;
        }
    }
    return cnt;
}

int main(){
    int N,X; cin >> N >> X;
    cout << cnt_bouding(N,X) << endl;
    return 0;
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//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();}


int main(){
  ll n;
  cin >> n;
  VLL a(3*n);
  rep(i,3*n) cin >> a[i];

  sort(all(a));
  ll ans = 0;
  rep(i,n) ans += a[3*n-2 - i*2];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cmath>

using namespace std;

bool isprime(int n)	{
  for (int i = 2; i * i <= n; i++)	{
    if (n % i == 0)
      return false;
  }
  return true;
}

int log(int base, int num)	{
  int temp = 0;
  int base1 = base;
  while (num / base1 > 0)	{
	temp += num / base1;
    base1 *= base;
  }
  return temp;
}

int main()	{
  int n;
  cin >> n;
  long long result = 1;
  for (int i = 2; i <= n; i++)	{
    if (isprime(i))	{
	  result = (result * (log(i, n) + 1)) % 1000000007;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main()
{
	long long n,m;
	int s;
	s=0;
	scanf("%lld",&n);
	m=n;
	while(n)
	{
		s+=n%10;
		n=n/10;
	}
	if(m%s==0) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

using namespace std;

int main (){
    int P, Q, R;
    cin >> P >> Q >> R;

    int flight_time;

    flight_time = min(P+Q,min(P+R,Q+R));
    cout << flight_time << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000000000000
#define nmax_def 22000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	ll H, N;
	cin >> H >> N;
	vl A(N);
	vl B(N);
	rep(i, N) {
		cin >> A[i] >> B[i];
	}
	vl DP(nmax_def, Inf);
	DP[0] = 0;
	rep(i, nmax_def - 1) {
		if (i == 0)
			continue;
		rep(j, N) {
			if (i - A[j] >= 0) {
				DP[i] = min(DP[i], DP[i - A[j]] + B[j]);
			}
		}
	}
	ll ans = Inf;
	rep(i, nmax_def) {
		if (i < H)
			continue;
		ans = min(ans, DP[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace  std;
#define f(i,n) 		for(i=0;i<n;i++)
#define fr(i,n,a) 	for(i=n;i>=a;i--)
#define fa(i,a,n) 	for(i=a;i<n;i++)
#define deb(x)		cout<<#x<<" "<<x<<endl;
#define deb2(x,y)	cout<<#x<<","<<#y<<" "<<x<<","<<y<<endl;
#define buf(x)		cout<<"Check"<<x<<endl;
#define ll			long long int 
#define ft			first
#define s			second
#define pb			push_back
#define mp			make_pair
#define do			double
#define all(v)		v.begin(),v.end()	
#define et(v)		for(auto itr:v)
#define mod			1000000007
inline void p(int x[],int n)	{	int i;f(i,n)cout<<x[i]<<" ";cout<<endl; }

void solve()
{  	
	ll N,M,K,i,j,sum=0;
	cin>>N>>M>>K;

	ll res=N/M;
	if(N%M)
		res++;
	cout<<res*K;



}
int main()
{	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
	ll t=1,c=1;
	//cin>>t;
	while(t--)
	{
		

		//cout<<"Case #"<<c++<<": "<<endl;
		solve();
		cout<<"\n";
		
	}
	return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<vector>
using namespace std;
typedef long long ll;
bool search(int i, int j, vector<vector<int>>& c, vector<vector<bool>> &gone) {
	if (gone[i][j])return false;
	if (c[i][j] == 0)return false;
	gone[i][j] = true;
	for (int I = -1; I < 2; I++) {
		for (int J = -1; J < 2; J++) {
			if(i+I>=0&&j+J>=0&&i+I<c.size()&&j+J<c[0].size())
			search(i + I, j + J, c, gone);
		}
	}
	return true;
}
int main() {
	int w, h;
	while (true) {
		cin >> w >> h;
		if (w == 0 && h == 0) {
			return 0;
		}
		vector<vector<int>> c(h, vector<int>(w, 0));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> c[i][j];
				//cout << c[i][j] << " ";
			}
			//cout << endl;
		}
		vector<vector<bool>> gone(h, vector<bool>(w, false));
		int ans=0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (search(i, j, c, gone)) {
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
}



Measured memory_bytes: 3288
#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if (c > a) {
      a=c;
    }
    if (b > d) {
      b=d;
    }
    if (b > a) {
      printf("%d",b-a);
    }
    else {
      printf("0");
    }
    return 0;
}

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

int main(){

  int N;
    cin>>N;
    vector<int> C(N-1),S(N-1),F(N-1);
    for(int i=0;i<N-1;i++){
        cin>>C[i]>>S[i]>>F[i];
    }
    for(int i=0;i<N-1;i++){
        int sum=C[i]+S[i];
        for(int j=i+1;j<N-1;j++){
            if(sum<=S[j]){
                sum=S[j]+C[j];
            }
            else{
                if((sum-S[j])%F[j]==0) sum+=C[j];
                else sum=sum+F[j]-(sum-S[j])%F[j]+C[j];
            }
        }
            cout<<sum<<endl;
    }
    cout<<0<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include<bits/stdc++.h>
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define pb push_back
#include <x86intrin.h>
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<ll>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 1e5 + 55, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string a, b;
	cin >> a >> b;
	int cnt = 0;
	for(int i = 0; i < 3; i++) cnt += a[i]==b[i];
	cout << cnt;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
const int N=3010;
vector<int> e[N];
int n,w[N],g[N];bool b[N];
void dfs(int x){
	if(b[x])return;b[x]=1;
	ref(i,0,(int)e[x].size()-1){
		int y=e[x][i];
		if(w[y]<w[x])dfs(y),g[x]|=(!g[y]);
	}
}
int main(){
	cin>>n;
	ref(i,1,n)cin>>w[i];
	ref(i,2,n){int x,y;cin>>x>>y;e[x].push_back(y);e[y].push_back(x);}
	ref(i,1,n)dfs(i),g[i]?printf("%d ",i):0;puts("");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	ll n, k;
	scanf("%lld %lld", &n, &k);
	n %= k;
	ll ans = min(n, abs(k - n));
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<pair<int, int>> cost(N);
	rep(i, N) {
		cin >> cost[i].first >> cost[i].second;
	}
	sort(cost.begin(), cost.end());
	int64_t ans = 0;
	rep(i, N) {
		if (cost[i].second < M) {
			ans += (int64_t)cost[i].first * cost[i].second;
			M -= cost[i].second;
		}
		else {
			ans += (int64_t)cost[i].first * M;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
 
int main()
{
  int n,i,j,l,d,c;
  while(1){  
    c=0;
    scanf("%d",&n);
    if(n==0)break;
    if(n==1)printf("1\n");
    else{
        for(i=n+1;i<=n*2;i++){
	 d=0;
	 for(j=2;j*j<=i;j++){
	   if(i%j==0){d++;break;}
	 }
	 if(d==0)c++;
	}
      printf("%d\n",c);}
  }

  return 0;
}
 

Measured memory_bytes: 612
from collections import Counter
import bisect

s = input()
t = input()
"""
TLE問題なのは間違いないが、工夫も結構厳しい必要がありそう
二分探索を用いれば, O(|t| log|s|)の定数倍で解ける？
"""

# 絶対に作れないやつは-1を出す、それ以外は絶対に作れる.
sc = Counter(s)
tc = Counter(t)
for i, j in tc.most_common():
	if sc[i] == 0:
		print(-1)
		exit()

"""
O(|t| |s|)で解けるが、TLE確実.
bisectを使う。
"""

target = ord("a")
ordl = [[] for _ in range(26)]
for i, j in enumerate(s):
	ordl[ord(j)-target].append(i)
ordllen = [len(ordl[i]) for i in range(26)]

# ordl := 各文字のindex番号.

times = 0
cnt = -1
ans = 0
for i in t:
	k = ord(i)-target
	m = bisect.bisect_right(ordl[k], cnt)
	if m == ordllen[k]:
		times += 1
		cnt = ordl[k][0]
	else:
		cnt = ordl[k][m]

ans = times * len(s) + cnt + 1
print(ans)

Measured memory_bytes: 7892
import java.util.*;
    public class Main {
        public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
         int i = sc.nextInt();
     
  
            if(i ==1){
            System.out.println("Hello World");
           }
          else if (i==2){
 int j = sc.nextInt();
      int k = sc.nextInt();
              System.out.println(j+k);
     
         }
        }
    }

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int n,a[222222];
long long ans;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int now=0,r=0;
	for(int i=0;i<n;i++)
	{
		while(r<n && (now&a[r])==0)
		{
			now^=a[r];
			r++;
		}
		ans+=r-i;
		now^=a[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner
import scala.math._

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n,k = sc.nextBigInteger()
  val nmodk=n mod k
  println(if (nmodk.compareTo(k.subtract(nmodk)) < 0) nmodk else (k.subtract(nmodk)))
}

Measured memory_bytes: 27328
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
using namespace std;

int main(){
	string s;
	cin >> s;
	int n = s.size();
	if (s[n-1] != 's')
		s += "s";
	else
		s += "es";
	cout << s << endl;
	return 0;

}

Measured memory_bytes: 3620
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb(t) push_back(t)
#define pt(num) cout << num << "\n"
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;





int main(void) {
    ll H, W, h, w;
    cin >> H >> W >> h >> w;
    
    pt((H-h)*(W-w));
    
    
    
}





Measured memory_bytes: 256
//Harjot Singh Student NIT JALANDHAR	

#include<bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long int ll;
struct item
{
	int wt,val;
};
int main()
{
    

    int n,w;
    cin>>n>>w;
      item arr[n];
      for(int i=0;i<n;i++)
      	cin>>arr[i].wt>>arr[i].val;
    
    ll dp[n+1][w+1];

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

    for(int j=0;j<=n;j++)
    	dp[j][0]=0;

    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=w;j++)
    	{
    		dp[i][j]=dp[i-1][j];
    		if(j>=arr[i-1].wt)
    			dp[i][j]=max(dp[i][j],dp[i-1][j-arr[i-1].wt]+arr[i-1].val);
    	}
    }

     ll ma=INT_MIN;
     for(int i=1;i<=w;i++)
         ma=max(ma,dp[n][i]);

     cout<<ma<<endl;
	return 0;
}

Measured memory_bytes: 79104
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long int lli;
const long long int MaxN=300005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	void solve(){
		lli A,B,C,res=0;
		cin>>A>>B>>C;
		if(A+B+1>=C){
			cout<<B+C;
		}
		else {
			cout<<A+B+B+1;
		}
	}	
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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 argc, char const *argv[]) {
  int n,m;
  cin >> n >> m;
  priority_queue<ll> pq;
  rep(i,n){
    ll a;
    cin >> a;
    pq.push(a);
  }
  rep(i,m){
    ll x=pq.top();
    pq.pop();
    pq.push(x/2);
  }

  ll ans=0;
  while (!pq.empty()) {
    ans+=pq.top();
    pq.pop();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
B = [0] + LI()

A = [0]
for i in range(N):  # 要らないものを消す
    if B[i] != B[i+1]:
        A.append(B[i+1])

N = len(A)-1
MAX = [0,1000] + [0]*N  # MAX[i] = i日目開始時点の所持金の最大値

from functools import lru_cache

@lru_cache(maxsize=None)
def dfs(n,money):
    if n == N+1:
        return money
    else:
        res = money
        for i in range(n,N):  # 購入
            for j in range(i+1,N+1):  # 売却
                if A[i] == min(A[i:j+1]) and A[j] == max(A[i:j+1]) and A[i] < A[j]:
                    a = money+(A[j]-A[i])*(money//A[i])
                    if a > MAX[j+1]:
                        res = max(res,dfs(j+1,a))
                        MAX[j+1] = a
        return res

print(dfs(1,1000))


Measured memory_bytes: 72004
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(1,0); }
	V<V<pin>> qab(2);
  int sz=ab.size();
  qab[0].reserve(sz);
  qab[1].reserve(sz);
	for (pin &x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2,x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2,(x.second + 1) / 2)); }
	}
  vel c(2);
	rep(i, 2) {
		for (pin &x : qab[1-i]) {
			int qc = (2 * x.first + x.second)%3;
          c[1-i]^=(qc+1);
		}
	}
	rep(i, 2) {
		if (!c[1 - i]) {
			pin ans = solve(qab[i], ex - 1);
			ans.first *= 2; ans.second *= 2; ans.second += i;
			return ans;
		}
	}
	for(pin &v:ab) { v.first++; }
	pin ans = solve(ab, ex); ans.first--;
	return ans;
}
signed main() {
	long long inf = 2e17;
	int n; scanf("%lld", &n);
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; scanf("%lld", &a); scanf("%lld", &b);
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 70);
	cout << ret.first - inf << " " << ret.second - inf << "\n";
}


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

int main()
{
    int N, M;
    cin >> N >> M;
    int array[M] = {0};
    for(int i = 0; i < N; i++)
    {
        int K;
        cin >> K;
        for(int j = 0; j < K; j++)
        {
            int a;
            cin >> a;
            array[a-1] += 1;
        }
    }

    int count = 0;
    for(int i = 0; i < M; i++)
    {
        if(array[i] == N) count += 1;
    }

    cout << count;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> d(N);
    vector<int> dc(N);
    for (int i = 0; i < N; i++)
    {
        cin >> d[i];
        dc[i] = d[i];
    }
    sort(dc.begin(), dc.end());
    int mid = 0;
    mid = dc[N/2]-dc[N/2-1];
    cout << mid << endl;
}


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

long long const inf = 1e18;
int const mxn = 4e3+10;

 
 
long long l[mxn],par[mxn],dp[mxn][mxn];


int main(){
	int n;
	cin>>n;
	for (int i = 1;i<=n;i++)
		cin>>l[i];
	par[1]=l[1];
	for (int i = 1;i<=n;i++)
		par[i] = par[i-1] + l[i];
		
	for (int i =0;i<mxn;i++)
		for (int j =0;j<mxn;j++)	
			dp[i][j]=1e18;
			
	for (int i = 1;i<=n;i++)
		dp[i][i]=0;
		
		
		
		
	for (int t = 1;t<=n;t++){
		
		for (long long  i =1 ;i+t<=n;i++){
			
			long long  k  = i + t;
			
			for (long long  j = i;j<=k;j++){
				
				dp[i][k] = min(dp[i][k], dp[i][j]+dp[j+1][k]+par[k]-par[i-1]);
				
			}
		}
	}
	cout<<dp[1][n];
	return 0;
}

Measured memory_bytes: 126456
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			String[] s = sc.next().split(",");
			double w = Double.parseDouble(s[1]);
			double h = Double.parseDouble(s[2]);
			if(w / (h * h) >= 25.0) {
				System.out.println(s[0]);
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 26064
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <deque>
#include <map>
#include <set>

#define ll long long
#define inf 0x3f3f3f3f
#define il inline

namespace io {

    #define in(a) a=read()
    #define out(a) write(a)
    #define outn(a) out(a),putchar('\n')

    #define I_int ll
    inline I_int read() {
        I_int x = 0 , f = 1 ; char c = getchar() ;
        while( c < '0' || c > '9' ) { if( c == '-' ) f = -1 ; c = getchar() ; }
        while( c >= '0' && c <= '9' ) { x = x * 10 + c - '0' ; c = getchar() ; }
        return x * f ;
    }
    char F[ 200 ] ;
    inline void write( I_int x ) {
        if( x == 0 ) { putchar( '0' ) ; return ; }
        I_int tmp = x > 0 ? x : -x ;
        if( x < 0 ) putchar( '-' ) ;
        int cnt = 0 ;
        while( tmp > 0 ) {
            F[ cnt ++ ] = tmp % 10 + '0' ;
            tmp /= 10 ;
        }
        while( cnt > 0 ) putchar( F[ -- cnt ] ) ;
    }
    #undef I_int

}
using namespace io ;

using namespace std ;

#define N 100010

ll n = read(), K = read();
ll a[N], cnt[2];

bool cmp(int a, int b) {
	return a > b;
}

int main() {
	for(int i = 1; i <= n; ++i) a[i] = read();
	ll ans = 0;
	for(ll k = 42; k >= 0; --k) {
		cnt[0] = cnt[1] = 0; 
		for(int i = 1; i <= n; ++i) {
			cnt[(a[i]>>k)&1ll]++;
		}
		if(cnt[0] > cnt[1] && ans + (1ll << k) <= K) ans += (1ll << k);
	}
	ll sum = 0;
	for(int i = 1; i <= n; ++i) {
		sum += ans ^ a[i];
	}
	printf("%lld\n", sum);
	return 0;
}

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

int main()
{
    string n;
    cin >> n;
    ll ans = 0;
    rep(i, n.size()){
        ans += n[i] - '0';
    }
    if(ans%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3676
x,k,d = map(int,input().split())

ab = abs(x)//d
ab_1 = ab +1

koho1 = abs(x) - abs(d*ab)
koho2 = abs(abs(x) -abs(d*ab_1))

tmp = k-ab

koho_s = []

if(tmp > 0):
    if(tmp%2 == 0):
        ans = koho1
    else:
        ans = koho2
elif(tmp == 0):
    ans = koho1
else:
    ans = abs(x) - abs(d*k)

print(ans)


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()  
#define sz(x) int(x.size()) 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=63;
const int mxn=3e5+5;
bool DEBUG=0;

int h,w,m;
int r[mxn],c[mxn];
set<ii>st;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    cin>>h>>w>>m;
	for(int i=0; i<m; i++){
		int u,v;
		cin>>u>>v;
		st.emplace(u,v);
		r[u]++; c[v]++;
	}
	vi mr,mc;
	int mxr=0,mxc=0;
	for(int i=1; i<=h; i++){
		if(r[i]>mxr){
			mxr=r[i];
			mr=vi();
			mr.eb(i);
		}else if(r[i]==mxr){
			mr.eb(i);
		}
	}
	for(int i=1; i<=w; i++){
		if(c[i]>mxc){
			mxc=c[i];
			mc=vi();
			mc.eb(i);
		}else if(c[i]==mxc){
			mc.eb(i);
		}
	}
	ll ans = mxr+mxc;
	for(int rr:mr){
		for(int cc:mc){
			if(!st.count({rr,cc})){
				cout<<ans<<"\n";
				return 0;
			}
		}
	}
	cout<<ans-1<<"\n";
	return 0;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 23832
#include<iostream>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
using namespace std;
int a,b; 
int main(){
	cin>>a>>b;
	a--;
	int x=(b-1)/a;
	if(x*a!=b-1) x++;
	cout<<x;
system ("pause");
return 0;
}

Measured memory_bytes: 504
#include<stdio.h>

int main(){
	int IA,IB,IC;
	int T,H;
	int A,B,C;
	T=H=0;
	while(scanf("%d,%d,%d",&IA,&IB,&IC)!=EOF){
		B=(IA==IB);
		C=(IA*IA+IB*IB==IC*IC);
		if(B && !C)
			H++;
		if(!B && C)
			T++;
	}
	printf("%d\n%d\n",T,H);
 	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
int main(void)
{
	int a, b, c, i, x;
	scanf("%d %d %d", &a, &b, &c);
	i=0;
	x=0;
	for(i=a;i<=b;i++)
	{
		if(c%i==0)
		{
			x++;
		}
	}
	printf("%d\n", x);
	return 0;
}


Measured memory_bytes: 2712
#include <iostream>
using namespace std;
int main(){
	int a,b,k;
	cin>>a>>b;
	k=(a+b)/2;
	if((a+b)%2==0&&a!=b){
		cout<<k<<endl;
	}
	if((a+b)%2==1||a==b){
		cout<<"IMPOSSIBLE"<<endl;
	}
}


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

int main(){
 int n;
 cin >> n;
 //9行目は可変長配列
 vector<int> a(n);
 rep(i,n) cin >> a[i];
 bool ok = true;
 rep(i,n){
   //14行目の解説　奇数ならcontinue
  if(a[i] % 2 == 1) continue;
  if(a[i] % 3 != 0 && a[i] % 5 != 0) ok = false;
}
  if(ok) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int a1 = sc.nextInt();
		int a2 = sc.nextInt();
		int a3 = sc.nextInt();
		if(a1+a2+a3 >=22) {
			System.out.println("bust");
		} else {
			System.out.println("win");
		}
		sc.close();
	}
}


Measured memory_bytes: 21844
#include<stdio.h>

int main(void){
  int X;
  
  scanf("%d",&X);
  if(400<=X && X<=599){
    printf("%d",8);
  }else if(600<=X && X<=799){
    printf("%d",7);
  }else if(800<=X && X<=999){
    printf("%d",6);
  }else if(1000<=X && X<=1199){
    printf("%d",5);
  }else if(1200<=X && X<=1399){
    printf("%d",4);
  }else if(1400<=X && X<=1599){
    printf("%d",3);
  }else if(1600<=X && X<=1799){
    printf("%d",2);
  }else if(1800<=X && X<=1999){
    printf("%d",1);
  }
  return 0;
}

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

int main(void){
    string s;
    cin >> s;
    
    int a, b;
    a = (s[0] - '0') * 10 + (s[1] - '0');
    b = (s[2] - '0') * 10 + (s[3] - '0');
    
    if(a >= 1 && a <= 12){
        if(b >= 1 && b <= 12){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else{
        if(b >= 1 && b <= 12){
            cout << "YYMM" << endl;
        }else{
            cout << "NA" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.List
import Data.Maybe
import Data.Bits
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as B

query :: Int -> [Int] -> Int
query m = sum . map ((\n -> (n * (n-1)) `div` 2)) . M.elems
  . foldl (\m i -> M.insertWith (+) i 1 m) M.empty
  . scanl' (\x y -> (x + y) `mod` m) 0 

main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine
  ais <- map read . words <$> getLine
  putStrLn $ show $ query m ais


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353
#define Graph vector<vector<int>>

int main() {
    int N; cin >> N;
    vector<int> a(N);
    int ans = 0, cnt;
    for (int i = 0; i < N; i++) {
        cnt = 0;
        cin >> a.at(i);
        while (a.at(i) % 2 == 0) {
            cnt++;
            a.at(i) /= 2;
        }
        ans += cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/


int main(void) {
  ll i, j, k;
  ll N;
  cin >> N;
  ll d[55];
  
  for(i=0; i<N; i++) cin >> d[i];
  sort(d, d+N);
  
  
  vector<ll> v; v.push_back(0);
  for(i=0; i<N; i++) {
    if(i&1) v.push_back(d[i]);
    else v.push_back(24-d[i]);
  }
  v.push_back(24);
  sort(v.begin(), v.end());
  
  ll ans=INF;
  for(i=0; i<(ll)v.size()-1; i++) chmin(ans, v[i+1]-v[i]);
  
  pt(ans);
}



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

using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

signed main(void)
{
  string s;
  int a, b, c, d, e;
  cin >> s;
  REP(i, s.size()-1) {
    if(s.substr(i, 2) == "AC") {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 764
#include <cstdio>
#include <cmath>
#define rep( i, n, m ) for(long long int  i = ( n ); i < ( m ); i++)
int main( void ){
	long long int  n;
	if (!scanf( "%lld", &n )){
		return 1;
	}
	long long int  n_sqrt = (long long int )std::sqrt(n);
	for(long long int  i = n_sqrt+1; i > 0; i--){
		if (n%i == 0){
			printf("%lld\n", i + n/i - 2);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

	string s;
	vector<pair<int, int>> so, sc;
	int now, mn;
	for (int i = 0; i < n; i++) {
		cin >> s;

		now = 0; mn = 0;
		for (int j = 0; j < s.length(); j++) {
			if (s[j] == '(') {
				now++;
			} else {
				now--;
			}

			mn = min(mn, now);
		}
		
		if (now >= 0) {
			so.emplace_back(make_pair(mn, now));
		} else {
			now = 0; mn = 0;
			for (int j = s.length() - 1; j >= 0; j--) {
				if (s[j] == ')') {
					now++;
				} else {
					now--;
				}
				mn = min(mn, now);
			}

			sc.emplace_back(make_pair(mn, now));
		}
	}

	sort(so.rbegin(), so.rend());
	sort(sc.rbegin(), sc.rend());

	int suml = 0, sumr = 0;
	for (int i = 0; i < so.size(); i++) {
		if (suml + so[i].first < 0) {
			cout << "No" << endl;
			return 0;
		}

		suml += so[i].second;
	}

	for (int i = 0; i < sc.size(); i++) {
		if (sumr + sc[i].first < 0) {
			cout << "No" << endl;
			return 0;
		}

		sumr += sc[i].second;
	}

	if (suml == sumr) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 11148
x, y=map(int, input().split())
A=set([1, 3, 5, 7, 8, 10, 12])
B=set([4, 6, 9, 11])
if x in A and y in A:
  print('Yes')
elif x in B and y in B:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9152
def resolve():
    D = int(input())
    C = [int(x) for x in input().split()]
    S = []
    for i in range(D):
        S.append(list(map(int, input().split())))
    t = [int(input()) for _ in range(D)]
    last_d = []
    score = 0

    for d in range(D):
        score += S[d][t[d] - 1]
        last_d.append(t[d] - 1)
        for i in range(len(C)):
            if i in last_d:
                score -= C[i] * last_d[::-1].index(i)
            else:
                score -= C[i] * (d + 1)
        print(score)


if __name__ == "__main__":
    resolve()

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

long long INF = 1e18;

struct Edge{
    int from;
    int to;
    int cost;
};

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

    long long data[N+100][W+100];
    int v[1100],w[1100];

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

    for(int j = 0; j <= W; j++){
        data[0][j] = 0;
    }

    for(int i=0; i < N ; i++){
        for(int j=0; j <= W; j++){
            if(j < w[i]){
                data[i+1][j] = data[i][j];
            }else{
                data[i+1][j] = max(data[i][j],data[i][j-w[i]] + v[i]);
            }
        }
    }
    cout<<data[N][W]<<endl;
     return 0;
}


Measured memory_bytes: 11068
import math
a,b,x=map(int,input().split())

if 2*x<=(a**2)*b:
        a=math.degrees(math.atan((b**2)*a/(2*x)))
        print(a)
else:
        a=math.degrees(math.atan((2*(a**2*b-x))/a**3))   
        print(a)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double t = (double)6*m - (double)30*h-(0.5)*m;
  if(t>=180.0) t = (360.0-t);
  if(-360.0<=t && t<=-180.0) {
    t = -t;
    t = (360.0-t);
  }
  if(t<0 && t>-180.0) t = -t;
  double pi = acos(-1);
  t = t/(180.0)*pi;
  double ans = a*a + b*b - 2*a*b*cos(t);
  ans = sqrt(ans);
  cout << fixed << setprecision(12) << ans << endl;
  return 0;
}

Measured memory_bytes: 4224
k = 26
D = gets.to_i
c = gets.split.map(&:to_i)
s = D.times.map { gets.split.map(&:to_i) }
max_satis = -1000000000
max_t = []
1.times do |r|
  t = []
  D.times do |d|
    if (d / k) % 2 == 1
      t[d] = d % k + 1
    else
      max_s = -1
      max_i = -1
      k.times do |i|
        if s[d][i] > max_s
          max_s = s[d][i]
          max_i = i
        end
      end
      t[d] = max_i + 1
    end
  end
  
  last = Array.new(k, 0)
  satis = 0
  D.times do |d|
    satis += s[d][t[d] - 1]
    last[t[d] - 1] = d + 1
    k.times do |i|
      satis -= c[i] * ((d + 1) - last[i])
    end
  end
  if max_satis < satis
    max_satis = satis
    max_t = t
  end
end

D.times do |d|
  puts max_t[d]
end


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<set<int>> s(N+1);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        if (a == 1) s[a].insert(b);
        if (b == N) s[b].insert(a);
    }

    for (auto i : s[1]) {
        if (s[N].find(i) != s[N].end()) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 19072
s = gets.chomp
s1 = s[0..1].to_i
s2 = s[2..3].to_i
def search(x)
  (1..12).include?(x)
end
if search(s1) && search(s2)
  puts 'AMBIGUOUS'
elsif search(s1)
  puts 'MMYY'
elsif search(s2)
  puts 'YYMM'
else
  puts 'NA'
end


Measured memory_bytes: 1788
from sys import stdin, stdout,stderr
import time,math
from collections import defaultdict as dd
 
def pn(ob):stdout.write(str(ob))
def inp():return stdin.readline()

def process():
	n, k = map(int, inp().split())
	arr = list(map(int, inp().split()));
	pref = [0]
	pref[0] = arr[0]

	
	for i in range(k, n, 1):
		if(arr[i] > arr[i-k]):
			pn("Yes\n")
		else:
			pn("No\n");
		
 
def main():
	t=1
	#t=int(inp())
	start = time.time()
 
	while (t>0):
		t-=1
		process()
	end = time.time()
	#stderr.write('\nelapsed time'+str(end - start))
  
if __name__ == '__main__':
	main()
	
#n,m=map(int,input().split()) 
# for i in range(n):
#     t=int(stdin.readline()) # input using fast i/p method 
#     if t%m == 0:
#         stdout.write(str(t)+'\n') #input using fast o/p method
 
# take line of integers as input
# 	arr = list(map(int, inp().split()))

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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

signed main() {
  int h, w; cin >> h >> w;
  char c[h+1][w+1];
  for(int i=1; i<h+1; ++i) {
    for(int j=1; j<w+1; ++j) {
      cin >> c[i][j];
    }
  }
  h*=2;
  for(int i=1; i<h+1; ++i) {
    for(int j=1; j<w+1; ++j) {
      cout << c[(i+1)/2][j];
    }
    cout << endl;
  }

  return 0;
}


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


int main(){

    int n;
    cin >> n;

    if(((n % 10) == 9) || ((n / 10) == 9)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }




    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = Integer.parseInt(sc.next());
			long l0 = 2;
			long l1 = 1;
			for (int i = 2; i <= n; i++) {
				long tmp = l1;
				l1 += l0;
				l0 = tmp;
			}
			System.out.println(l1);
		}
	}
}

Measured memory_bytes: 26928
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 200010
#define mod (ll)1000000007
const int inv2=(mod+1)/2;
struct Edge{
	int next,to;
}edges[maxn<<1];
struct Q{
	ll a,b,c;
};
int head[maxn<<1],b_cnt,N,fa[maxn];
deque<Q> dp[maxn];
inline void addedge(int u,int v)
{
	edges[++b_cnt].next=head[u];
	edges[b_cnt].to=v;
	head[u]=b_cnt;
}
inline ll qpow(ll x,ll n)
{
	if (n==1) return x%mod;
	ll ans=qpow(x,n>>1);
	ans=ans*ans%mod;
	if (n&1) ans=ans*x%mod;
	return ans;
}
inline void dfs(int u,int fa)
{
	int maxsum=0,second_max=0;
	for (int i=head[u];i;i=edges[i].next)
	{
		int v=edges[i].to;
		if (v!=fa)
		{
			dfs(v,u);
			int cur=dp[v].size();
			if (cur>maxsum)
			{
				second_max=maxsum;
				maxsum=cur;
			}
			else if (cur>second_max) second_max=cur;
			if (dp[v].size()>dp[u].size()) swap(dp[v],dp[u]);
			for (int j=0;j<dp[v].size();j++)
			{
				Q x;
				x.a=(ll)(dp[v][j].a*dp[u][j].a)%mod;
				x.b=(ll)(dp[v][j].b*dp[u][j].a%mod+dp[v][j].a*dp[u][j].b%mod)%mod;
				x.c=(ll)(dp[u][j].a*(dp[v][j].c)%mod+dp[u][j].b*(dp[v][j].b+dp[v][j].c)%mod+dp[u][j].c*(dp[v][j].a+dp[v][j].b+dp[v][j].c)%mod)%mod;
				dp[u][j]=x;
			}
		}
	}
	for (int i=0;i<second_max;i++) {dp[u][i].a=(dp[u][i].a+dp[u][i].c)%mod;dp[u][i].c=0;}
	dp[u].push_front((Q){inv2,inv2,0});
}
int main()
{
	cin>>N;
	for (int i=1;i<=N;i++)
	{
		cin>>fa[i];
		addedge(fa[i],i);
		addedge(i,fa[i]);
	}
	dfs(0,-1);
	ll ans=0;
	for (int i=0;i<dp[0].size();i++)
	{
		ans=(ans+dp[0][i].b)%mod;
	}
	ans=(ll)ans*qpow(2,N+1)%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 236928