akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const int mod=1e9+9;
const double eps=1e-6;
const int inf=0x3f3f3f3f;
const double pi=acos(-1.0);
//LL powmod(LL a,LL b) {LL res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
deque<int>q;
VI ans;
int main(){
//    freopen("C-small-attempt1.in","r",stdin);
//    freopen("output.txt","w",stdout);
    int n,a;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(i&1) q.push_back(a);
        else q.push_front(a);
    }
    while(!q.empty()){
        ans.pb(q.back());
        q.pop_back();
    }
    if(n&1) reverse(all(ans));
    for(auto i:ans) cout<<i<<" ";
	return 0;
}
/*
*/


Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    int a, b, c, d, e, k, min, max;
    cin >> a >> b >> c >> d >> e >> k;
    if (e - a > k){
        cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





int main() {
    int n;
    cin >> n;
  
  int ans=0;
  bool tobi=false;
  rep(i,n){
    int a;
    cin>>a;
    if(tobi){
      tobi=false;
      continue;
    }
    if(i+1==a) {
      ans+=1;
      tobi=true;
    }
  }



  cout << ans << endl;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "internationalization" ].parse.expand.solve == "i18n" );
	assert( [ "smiles" ].parse.expand.solve == "s4s" );
	assert( [ "xyz" ].parse.expand.solve == "x1z" );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.strip;
	return tuple( s );
}

auto solve( string s )
{
	return s[ 0 ] ~ ( s.length - 2 ).to!string ~ s[ $ - 1 ];
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
 
public class Main{
  public static void main(String[] args){//方針としては、階乗求めてからその階乗分あるルートを全部求めて足して、それを階乗の数値で割る
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();//配列の数
    int[] a = new int[N];
    int jun = 1;
    int stopper = 0;
    int kosu = 0;
    for (int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
    }
    for (int i = 0; i < N; i++) {
      for (int j = 0; i < N; i++) {
        if (a[stopper + i] == jun) {
          kosu += 1;
          stopper = j;
          jun+=1;
          break;
        }
      }
    }
    if (kosu != 0) {
      out.print(N - kosu);
    } else {
      out.print("-1");
    }




  }
}


Measured memory_bytes: 87692
#include <iostream>
#include <array>
#include <algorithm>

int main()
{
    int n, m, x;
    std::cin >> n >> m >> x;
    std::array<int, 100> a{};
    for (uint i = 1; i <= m; i++) {
        int j = 0;
        std::cin >> j;
        a[j] = 1;
    }

    int c1 = 0;
    for (int i = x; i != 0; i--) {
        c1 += a.at(i);
    }

    int c2 = 0;
    for (int i = x; i != n; i++) {
        c2 += a.at(i);
    }

    std::cout << std::min(c1, c2) << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
int main(){
int a,b,ans,res,sum,prod,sub;
cin>>a>>b;
sum=a+b;
prod=a*b;
sub=a-b;
ans=max(sum,prod);
res=max(ans,sub);
cout<<res<<endl;
return 0;
	}

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


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

	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> v, u;
	v.push_back(x);
	u.push_back(y);
	for(int i = 0; i < n; i++) {
		int s;
		cin >> s;
		v.push_back(s);
	}
	for(int i = 0; i < m; i++) {
		int s;
		cin >> s;
		u.push_back(s);
	}
	sort(v.begin(), v.end());
	sort(u.begin(), u.end());
	if(v.back() < u.front()) {
		cout << "No War" << endl;
	} else {
		cout << "War" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def m2p(ai):
    aii=ai
    k=0
    ra=aii%2
    while ra==0 and aii>0:
        k=k+1
        aii=aii//2
        ra=aii%2
    return k        

n=int(input())
a=list(map(int,input().split()))

m=0
for i in range(n):
    m=m+m2p(a[i])
#    print(a[i],m2p(a[i]))
print(m)


Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1 << 29;
const int MOD = 1000000007;

int main() {
    string s;
    int q;

    cin >> s;
    cin >> q;

    // dequeで文字列を持つ
    deque<string> dq;
    dq.push_front(s);

    // 反転していなければfalse 反転していたらtrue
    bool inversion = false;

    rep(i, q) {
        int t;
        cin >> t;

        if (t == 1) {
            // 文字列反転
            inversion = !inversion;
        } else if (t == 2) {
            int f;
            string c;

            cin >> f >> c;

            if (f == 1) {
                if (inversion == false) {
                    // 反転してないので先頭に追加
                    dq.push_front(c);
                } else if (inversion == true) {
                    // 反転しているので末尾に追加
                    dq.push_back(c);
                }
            } else if (f == 2) {
                if (inversion == false) {
                    // 反転してないので末尾に追加
                    dq.push_back(c);
                } else if (inversion == true) {
                    // 反転しているので先頭に追加
                    dq.push_front(c);
                }
            }
        }
    }

    string ans;

    for (auto itr = dq.begin(); itr != dq.end(); ++itr) {
        ans += *itr;
    }

    // 反転
    if (inversion == true) {
        reverse(ans.begin(), ans.end());
    }

    cout << ans << endl;
}


Measured memory_bytes: 10564
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const i64 P = 1000000000 + 7;
i64 dp[41][2][1 << 18];

void add(i64 &x, i64 y) {
    x += y;
    if (x >= P) x -= P;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n, x, y, z;
    cin >> n >> x >> y >> z;
    int S = x + y + z + 1;
    int tm = (1 << z) | (1 << (y + z)) | (1 << (x + y + z));
    dp[0][0][1] = 1;
    forn(i, n) forn(j, 2) forn(m, 1 << S) {
        if (!dp[i][j][m]) continue;
        for1(t, 10) {
            int mm = ((m << t) | 1) & ((1 << S) - 1);
            int jj = j | ((mm & tm) == tm);
            add(dp[i + 1][jj][mm], dp[i][j][m]);
        }
    }
    i64 ans = 0;
    forn(m, 1 << S) add(ans, dp[n][1][m]);
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 145024
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> city(N);
  int a, b;
  for(int i = 0; i < M; i++){
    cin >> a >> b;
    city.at(a - 1) += 1;
    city.at(b - 1) += 1;
  }
  for(int i = 0; i < N; i++){
    cout << city.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s;
	while(getline(cin, s)){
		for(int i = 0; i < 26; i++){
			for(int i = 0; s[i] != '\0'; i++){
				if(s[i] >= 97 && s[i] <= 122) s[i] = (s[i] - 97 + 1) % 26 + 97;
			}
			if(s.find("th", 0) != -1){
				cout << s << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N; cin>>N;
    int n,ans;n=ans=0;
    vector<int> A(N);
    for(int i=0;i<=N-1;i++){
        cin>>A[i];
    }
    while(A[n]%2==0) {
        for (int n = 0; n <= N - 1; n++) {
            if (A[n] % 2 == 0) {
                A[n] = A[n] / 2;
            }
            else{
                cout<<ans;
                return 0;
            }
        }
            ans++;
        }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long int llint;

llint solve(llint a, llint b) {
	llint x = a, y = b;
	while (a != 0 && b != 0) {
		if (a > b) {
			a %= b;
		}
		else {
			b %= a;
		}
	}
	if (a == 0) {
		a = b;
	}
	return x / a*y;
}

int main() {
	int n;
	cin >> n;
	llint ans = 1;
	llint x;
	for (int i = 0;i < n;i++) {
		cin >> x;
		ans = solve(x, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<lld> vll;
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define srt(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define mod 1000000007
#define pi 3.1415926535
lld a,b,c,d,e,f,g,h,i,j,k=0,l=0,m=1,n=1,o,q=0,r=0,u,v,w,x,y,z,s,t,p=0;
lld temp=0,ans=0;
double f1,f2,f3,f4,f5,f6;
char c2,c3,c4,c5,c6;
vll v11;
pair<lld,lld>p1,p2,p3;
map<lld,lld>mv;lld a12[200005],a13[200005];
bool b11[500006],c11[500006];lld a11[500006];
lld gcd(lld a, lld b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
}
void dfs(lld i,vector<lld>vg[],lld m)
{
    if(b11[i]==true)    return;
    b11[i]=true;
    for(auto x11:vg[i])
    {
        if(b11[x11]==false)
        {
            dfs(x11,vg,m);
        }
    }
}
int main()
{
  ios::sync_with_stdio(false);cin.tie(0);
  t=1;
  //cin>>t;
  while(t--)
  {
    string s3,s1,s2;
    cin>>n;lld bn,a11,p1,n1,c11,cn;
    lld a1[n+1][n+1],b1[n],c1[n+1];vector<lld>vg[n+1];
    map<char,lld>m1,m2;queue<lld>q2;vll v1,v2;r=0;temp=0;
    //llda1[n+1][n+1];
    for(i=1;i<=n;i++)
    {
        if(i<3)
        {
            a1[1][i]=0;
        }
        else
        {
            a1[1][i]=1;
        }
    }
    for(i=2;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(j<(3*i))
            {
                a1[i][j]=0;
            }
            else if(j==3*i)
            {
                a1[i][j]=1;
            }
            else
            {
                a1[i][j]=(a1[i][j-1]+a1[i-1][j-3])%mod;
            }
        }
    }p=0;
    for(i=1;i<n+1;i++)
    {
        p=(p+a1[i][n])%mod;
    }
    cout<<p;
    cout<<endl;
  }
  return 0;
}

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

int dice[6];
int i,t;
char mei[100];

int ue=1;
int hid=4;
int mig=3;
int mae=2;
int usi=5;
int sit=6;

void eMove();
void nMove();
void sMove();
void wMove();

int main(){
	for(i=0;i<6;i++)scanf("%d",&dice[i]);
	scanf("%s",mei);
	for(i=0;i<strlen(mei);i++){
		if(mei[i]=='E'){
			eMove();
		}else if(mei[i]=='N'){
			nMove();
		}else if(mei[i]=='S'){
			sMove();
		}else if(mei[i]=='W'){
			wMove();
		}
	}
		printf("%d\n",dice[ue-1]);
		
	return 0;
}

void eMove(){
	t=ue;
	ue=hid;
	hid=sit;
	sit=mig;
	mig=t;
	return;
}

void nMove(){
	t=ue;
	ue=mae;
	mae=sit;
	sit=usi;
	usi=t;
	return;
}

void sMove(){
	t=ue;
	ue=usi;
	usi=sit;
	sit=mae;
	mae=t;
	return;
}

void wMove(){
	t=ue;
	ue=mig;
	mig=sit;
	sit=hid;
	hid=t;
	return;
}


Measured memory_bytes: 2108
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	double a,b,c,d,e,f;
	while (cin >> a >> b >> c >> d >> e >> f) {
		// ???????????????(???????????????????????????????????????)
		// ?¬¬?????????x????????°???1?????????
		b /= a;
		c /= a;
		a = 1;
		// ????????¶?????§???????¨???? (e-bd)y = f-cd ?????????????????????
		double y = (f - c*d) / (e - b*d);
		double x = c - b * y;
		printf ("%1.3f %1.3f",x,y);
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1260
#include <stdio.h>

int main()
{
    int N,i,max=0,maxf;
    int L[100],sum=0;

    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&L[i]);
        if(L[i]>max){
            max = L[i];
            maxf=i;
        }
    }

    for(i=0;i<N;i++){
        if(i != maxf){
            sum += L[i];
        }
    }


    if(sum > max){
        printf("Yes");
    }else{
        printf("No");
    }

return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
template<class T> class RB_LIS{
	public:
		void add(T x){
			if(lowest.empty() || lowest.back()<x){
				lowest.push_back(x);
				moves.push_back({-1,x});
			}
			else{
				int i=lower_bound(lowest.begin(),lowest.end(),x)-lowest.begin();
				moves.push_back({i,lowest[i]});
				lowest[moves.back().first]=x;
			}
		}
		int size(){ return (int) lowest.size(); } 
		void rollback(){
			if(moves.back().first==-1)	lowest.pop_back();
			else lowest[moves.back().first]=moves.back().second;
			moves.pop_back();
		}
	private:
		vector<T> lowest;
		vector<pair<int,T>> moves;
};
int const MAXN=200100;
int N, v[MAXN], ans[MAXN];
vector<int> g[MAXN];
RB_LIS<int> lis;
void dfs(int node, int parent){
	lis.add(v[node]);
	ans[node]=lis.size();
	for(int child:g[node])
		if(child!=parent)
			dfs(child,node);
	lis.rollback();
}
int main(){
	cin>>N;
	for(int i=1;i<=N;i++)
		cin>>v[i];
	for(int i=0;i<N-1;i++){
		int a, b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(1,0);
	for(int i=1;i<=N;i++)
		cout<<ans[i]<<"\n";
}


Measured memory_bytes: 31600
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  string s;
  cin>>s;
  if(s[s.length()-1]=='s') cout<<s<<"es"<<endl;
  else cout<<s<<"s"<<endl;
  return 0;
}

Measured memory_bytes: 3652
use proconio::{fastout, input};

const M: i128 = 1e+9 as i128 + 7;

#[fastout]
fn main() {
    input! {in_n: usize, in_k: usize};
    let mut cnt = vec![1i128; in_k + 1];

    for k in 1..=in_k {
        let mut p = (in_k / k) as i128;
        let mut n = in_n as i128;

        while n > 0 {
            if n % 2 == 1 {
                cnt[k] = (cnt[k] * p) % M;
            }

            p = (p * p) % M;
            n /= 2;
        }
    }

    for k in (1..=in_k).rev() {
        for j in ((k * 2)..=in_k).step_by(k) {
            cnt[k] = (cnt[k] - cnt[j] + M) % M;
        }
    }

    let mut count = 0i128;

    for k in 1..=in_k {
        count = (count + cnt[k] * k as i128) % M;
    }

    println!("{}", count);
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();

		String nextTern = "a";
		while (a.length() > 0 || b.length() > 0 || c.length() > 0) {
			if (nextTern.equals("a")) {
				if (a.length() == 0) {
					System.out.println("A");
					break;
				}
				nextTern = a.substring(0, 1);
				if (a.length() > 1) {
					a = a.substring(1);
				} else {
					a = "";
				}

			} else if (nextTern.equals("b")) {
				if (b.length() == 0) {
					System.out.println("B");
					break;
				}
				nextTern = b.substring(0, 1);
				if (b.length() > 1) {
					b = b.substring(1);
				} else {
					b = "";
				}
			} else {
				if (c.length() == 0) {
					System.out.println("C");
					break;
				}
				nextTern = c.substring(0, 1);
				if (c.length() > 1) {
					c = c.substring(1);
				} else {
					c = "";
				}
			}
		}

	}

}

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

using namespace std;
#define INF 1000007
#define MOD 1000000007
#define maxn 101
#define maxh 1001
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
const int dx[4] = {0, 1, -1, 0}, dy[4] = {1, 0, 0, -1};
typedef std::pair<int, int> P;

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

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

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

int lcm(int a, int b) { return a / gcd(a, b) * b; }

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

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

int a, b;

void f(int x) {
    while (x) {
        a++;
        b = x;
        x /= 10;
    }
}

signed main() {
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i, N) {
        cin >> X[i];
    }
    int ans = 1000000;
    rep(p, 101) {
        int check = 0;
        rep(j, N) {
            check += (int) pow(abs(X[j] - p), 2);
        }
        ans = min(ans, check);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
import sys
N, Y = map(int, input().split())
 
for x in range(N + 1):
    if 10000 * x > Y:
        break
    for y in range(N - x + 1):
        if 10000 * x + 5000 * y > Y:
            break
        z = N - x - y
        if 10000 * x + 5000 * y + 1000 * z == Y:
            print(x, y, z)
            sys.exit()
 
print('-1 -1 -1')

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int s,w;
   cin>>s>>w;
   if(w>=s)
    cout<<"unsafe"<<endl;
   else
    cout<<"safe"<<endl;
}


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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  int sum=0;
  for(int i=0;i<K;i++){
    sum+=A.at(i);
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3600
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

temp=array(20,1,"#")
info=Array.new(4).map{Array.new(3){Array.new(10){0}}}
n=gets.to_i
n.times do|i|
  b,f,r,v=get_i
  info[b-1][f-1][r-1]+=v
end
4.times do|i|
  3.times do|j|
    print " " 
    puts info[i][j].join(" ")
  end
  puts temp.join("") unless i==3
end


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

struct card {
    char mark;
    int value;
    bool operator==(const card &other) {
        return (mark == other.mark  &&  value == other.value);
    }
};

bool isStable(card in[], card out[], int N){
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            for(int a=0; a<N; a++){
                for(int b=a+1; b<N; b++){
                    if(in[i].value == in[j].value  &&  in[i] == out[b]  &&  in[j] == out[a]){
                        return false;
                    }
                }
            }
        }
    }
    return true;
}

void BubbleSort(card C[], int N){
    for(int i=0; i<N; i++){
        for(int j=N-1; j>=i+1; j--){
            if(C[j].value < C[j-1].value){
                swap(C[j], C[j-1]);
            }
        }
    }
}

void SelectionSort(card C[], int N){
    for(int i=0; i<N; i++){
        int minj = i;
        for(int j=i; j<N; j++){
            if(C[j].value < C[minj].value){
                minj = j;
            }
        }
        swap(C[i], C[minj]);
    }
}

int main(){
    int n;
    cin >> n;
    card card[100], card2[100], card3[100];
    for(int i=0; i<n; i++){
        string str;
        cin >> str;
        card[i].mark = str[0];
        card[i].value = str[1] - '0';
        card2[i].mark = str[0];
        card2[i].value = str[1] - '0';
        card3[i].mark = str[0];
        card3[i].value = str[1] - '0';
    }

    BubbleSort(card, n);
    for(int i=0; i<n-1; i++){
        cout << card[i].mark << card[i].value << " ";
    }
    cout << card[n-1].mark << card[n-1].value << endl;
    if(isStable(card, card3, n)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }

    SelectionSort(card2, n);
    for(int i=0; i<n-1; i++){
        cout << card2[i].mark << card2[i].value << " ";
    }
    cout << card2[n-1].mark << card2[n-1].value << endl;
    if(isStable(card2, card3, n)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }

    return 0;
}


Measured memory_bytes: 3160
from fractions import gcd
def f(n):
    tmp = n
    cnt = 0
    i = 2
    while i <= n**0.5 + 1:
        if tmp < i:
            break
        if tmp % i == 0:
            cnt += 1
            while tmp % i == 0:
                tmp //= i
        i += 1
    if tmp != 1:
        cnt += 1
    return cnt

A, B = map(int, input().split())
g = gcd(A, B)
ans = f(g) + 1
print(ans)

Measured memory_bytes: 5688
import sys
input = sys.stdin.readline
from itertools import accumulate
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

def main():
    cumsum = accumulate(A)
    counter = Counter(cumsum)
    yield counter[0]
    for v in counter.values():
        if v > 1:
            yield v*(v-1)//2


print(sum(main()))

Measured memory_bytes: 38888
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int V, E;
int dist[20][20];
int bitdp[1 << 15];
int deg[20];
signed main() {
    cin >> V >> E;
    memset(deg, 0, sizeof(deg));
    rep(i,0,V) rep(j,0,V) {
        if(i != j) dist[i][j] = INF;
        else dist[i][j] = 0;
    }

    int sum = 0;
    rep(i,0,E) {
        int s, t, d; cin >> s >> t >> d;
        sum += d;
        dist[s][t] = min(dist[s][t], d);
        dist[t][s] = min(dist[t][s], d);
        deg[s]++; deg[t]++;
    }
    rep(k,0,V) rep(i,0,V) rep(j,0,V) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }
    vector<int> oddvertices;
    rep(i,0,V) if(deg[i] % 2) oddvertices.pb(i);
    int n = (int)oddvertices.size();
    rep(i,0,1<<n) bitdp[i] = INF;
    bitdp[0] = 0;
    rep(bit,0,1<<n) {
        rep(i,0,n) rep(j,i+1,n) {
            if(bit >> i & 1) continue;
            if(bit >> j & 1) continue;
            int nbit = bit | (1 << i) | (1 << j);
            int x = oddvertices[i];
            int y = oddvertices[j];
            bitdp[nbit] = min(bitdp[nbit], bitdp[bit] + dist[x][y]);
        }
    }
    cout << sum + bitdp[(1 << n) - 1] << endl;
    return 0;
}

Measured memory_bytes: 3104
#include<stdio.h>

int main(void){
  int n, m, ans;
  int t[100], p[100], x[100];
  scanf("%d", &n);
  for(int i=0; i<n; i++){
    scanf("%d", &t[i]);
  }
  scanf("%d", &m);
  for(int i=0; i<m; i++){
    scanf("%d", &p[i]);
    scanf("%d", &x[i]);
  }

  for(int i=0; i<m; i++){
    ans = 0;
    for(int j=0; j<n; j++){
      ans += t[j];
    }
    ans -= t[p[i]-1]-x[i];
    printf("%d\n", ans);
  }

  return 0;
}


Measured memory_bytes: 1724
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef pair<long long,long long> P;
//typedef pair<long long,P> P1;
//typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define se second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define rrep(i,x) for(long long i=x-1;i>=0;i--)
#define rrepn(i,x) for(long long i=x;i>1;i--)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())


#define ALL(v)  (v).begin(),(v).end()
//#define MAX(a,b) if(a>b)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))


const string MINUSINF = "-";


long long A,B,C,D,E,F,H,I,J,L,N,M,K,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long sum,sum1,sum2,sum3,sum4;
long long flg,flg1,flg2,flg3,cnt,cnt1,cnt2,cnt3,cnt4;
long long wk,wk1,wk2,wk3,wk4;
long long ans;

bool f;

long long n,h[100005];
vector<long long> p, c;
int vis[200001];

vector<string> fi;
int Left[2100][2100], Right[2100][2100], Up[2100][2100], Down[2100][2100];

long long match[10] = {2,5,5,4,5,6,3,7,6};

ll dp[3][10000010];
ll hap[3][10000010];


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

	long long max,max1;
	long long min,min1;

	sum=sum1=sum2=sum3=sum4=0;
	flg=flg1=flg2=flg3=cnt=cnt1=cnt2=cnt3=cnt4=0;
	max=max1=0;
	wk=wk1=wk2=wk3=wk4=0;
	ans=0;
	min=min1=INF;

	
	//**************************ここからスタート******************************************
	std::cin >> N;
	//std::cin >> N >> M;
	//std::cin >> N >> M >> K;
	//std::cin >> N >> K;
	//std::cin >> A >> B;
	//std::cin >> A >> B >> C;
    
	//std::vector<long long> v(N);
	//std::vector<long long> w(N);
	//std::vector<long long> x(N);
	//std::vector<int> v(100, 0);
	//int a[26]={0};
	//vector<long long> flagment(N, 0);
	
	//vec.push_back(i);
	//accumulate(vec.begin(), vec.end(), 0)
    //v.resize
    
	// 配列入力1
	
	for(long long i=0; i<N; i++){
		for(long long j=0; j<3; j++){
			std::cin >> hap[j][i];
		}
	}
	
	
	//std::sort(v.begin(),v.end());//昇順ソート
	//std::sort(v.begin(),v.end(),std::greater<long long>());//降順ソート
	
	dp[0][0]=hap[0][0];
	dp[1][0]=hap[1][0];
	dp[2][0]=hap[2][0];
	
	//通常
	for(long long i=1; i<N; i++){
		for(long long j=0; j<3; j++){
			for(long long k=0; k<3; k++){
				if(j==k){
					continue;
				}
				else{
					//dp[j][i]=MAX(dp[j][i],dp[k][i-1]+hap[k][i-1]);
					dp[j][i]=MAX(dp[j][i],dp[k][i-1]+hap[j][i]);
				}
			}
		}
	}
	max=0;
	for(long long j=0; j<3; j++){
		max=MAX(max,dp[j][N-1]);
	}
		
	printf("%lld",max);
	return 0;
}


Measured memory_bytes: 15360
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        sc.nextLine();
        String s[]=new String[n];
        for(int i=0;i<n;i++)
        {
            s[i]=sc.nextLine();
        }
        HashSet<String> h=new HashSet<>();
        for(int i=0;i<n;i++)
        {
            if(!h.contains(s[i]))
                h.add(s[i]);
        }
        System.out.println(h.size());
    }
}



Measured memory_bytes: 72592
#define DEBUG(...)
/*                        Strip me down and go to town                        */
/*                          Lick me over upside down                          */
/*                     Pound and pound and pound and pound                    */
/*                        Baby make me make that sound                        */
/*                Aaah, aaah, aaah, aaah, aaaaaaaaaaaaaaaaaah!                */
#include<stdio.h>

typedef long long int LL;

const int maxN = 2005;
const int MOD = 1000000007;

int ar[maxN], br[maxN];
LL dp[maxN][maxN];
int n, m;

LL serc(int a, int b) {
  if (a == n || b == m) {
    return 0;
  }
  if (dp[a][b] != -1) {
    return dp[a][b];
  }
  dp[a][b] = (ar[a] == br[b]) + serc(a + 1, b) + serc(a, b + 1) -
              ( serc(a + 1, b + 1) * ( 1 - (ar[a] == br[b]) ) );
  dp[a][b] = (dp[a][b] + MOD) % MOD;
  DEBUG(printf("dp %d,%d is %lld\n", a, b, dp[a][b]);)
  return dp[a][b];
}

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &ar[i]);
    for (int j = 0; j < m; j++) {
      dp[i][j] = -1;
    }
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &br[i]);
  }
  printf("%lld\n", (1 + serc(0, 0)) % MOD);
  return 0;
}

Measured memory_bytes: 31872
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int A, B, C;

int main(void)
{
  cin >> A >> B >> C;
  int ma = max({A, B, C});
  int ans = ma * 10 + (A + B + C - ma);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
a,b,x=map(int,input().split())
import math
if a*a*b==x:
  c=math.pi/2
elif a*a*b/2>=x:
  c=math.atan((2*x)/(a*b*b))
else:
  c=math.atan(a**3/(2*a*a*b-2*x))
d=math.degrees(c)
print(90-d)

Measured memory_bytes: 3064
n = int(input())
a = [int(i) for i in input().split()]

def count(number):
    count = 0
    while True:
        if number % 2 == 0:
            number //= 2
            count += 1
        else:
            break
    return count
  
a_2 = [int(i) for i in a if i % 2 == 0]

ans = 0
for i in a_2:
    ans += count(i)
print(ans)

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

int h, w;
char ca[1000][1001];
char cpy[1000][1001];
int cnt[1000][1000];
bool b = 0;
queue<P> que[2];

int main(){
	scanf("%d%d", &h, &w);
	rep(i, h)
		scanf("%s", ca[i]);
	rep(i, h){
		rep(j, w){
			if (ca[i][j] == '.')continue;
			for (int t = -1; t <= 1; t++)
				for (int k = -1; k <= 1; k++)
					if (ca[i + t][j + k] == '.')
						cnt[i][j]++;
			if (cpy[i][j] != '.'&&ca[i][j] - '0' <= cnt[i][j]){
				cpy[i][j] = '.';
				que[b].push(P(i, j));
			}
		}
	}
	int res = 0;
	while (!que[b].empty()){
		res++;
		while (!que[b].empty()){
			P p = que[b].front(); que[b].pop();
			int f = p.first, s = p.second;
			for (int i = -1; i <= 1; i++){
				for (int j = -1; j <= 1; j++){
					int t = f + i, k = s + j;
					if (ca[t][k] == '.')continue;
					cnt[t][k]++;
					if (cpy[t][k] != '.'&&ca[t][k] - '0' <= cnt[t][k]){
						cpy[t][k] = '.';
						que[!b].push(P(t, k));
					}
			 	}
			}
		}
		b = !b;
	}
	printf("%d\n", res );
	return 0;
}

Measured memory_bytes: 9100
#include <iostream> // cout, endl, cin
#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
using namespace std;

long long MAX = 1e18;

int main() {
long long a, b, v, w, t;
cin >> a >> v >> b >> w >> t;
for(int i = 1; i <= t; i++){
    if(a > b){
        a = a - v;
        b = b - w;
        if(a <= b){
            cout << "YES" << endl;
            return 0;
        }
    }else{
        a = a + v;
        b = b + w;
        if(a >= b){
            cout << "YES" << endl;
            return 0;
        }
    }
}

cout << "NO" << endl;

return 0;
}


Measured memory_bytes: 3656
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e15)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int n; cin>>n;
	vector<int> v(n);
	for(auto &i:v)
		cin>>i;
	sort(all(v));
	int ans=0;
	For(i,0,n-3) For(j,i+1,n-2){
		int tot=upper_bound(v.begin(),v.end(),v[i]+v[j]-1)-v.begin();
		ans+=tot-j-1;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W, i, j;
  cin >> H >> W;
  vector<char> pic(H*W);
  for(i=0; i<H; i++){
    for(j=0; j<W; j++){
      cin >> pic[W*i+j];
    }
  }
  for(i=0; i<H+2; i++){
    for(j=0; j<W+2; j++){
      if(i == 0 || i == H +1 || j == 0 || j == W+1){
        cout << '#';
      }
      else{
        cout << pic[W*(i-1)+(j-1)];
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
from math import factorial

N = factorial(int(input()))

i = 2
check = 1
ans = 1
while N != 1:
    if N % i == 0:
        N //= i
        check += 1
    else:
        ans *= check
        check = 1
        i += 1
print((ans*check)%(10**9+7))

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include <iomanip>
#include <cmath>
#include <math.h>
#include <algorithm> 
#include <bits/stdc++.h> 
#include<map>
using namespace std;
int main()
{
        vector<long int>::iterator it;
         // std::vector<long int>::iterator upper; 
 //long long long int l,r,m,i,t,a,b,n;
long long int n,t{0},l,i,d,k,x,sum{0},a,y,j,r,b,z,m{0},cnto{0},cnte{0};//diff{0};
string s,s1,s3;
long long int ans{0};
// cin>>t;
// while(t>0)
{
   cin>>x>>y;
   if(y%2!=0)cout<<"No";
   else
   {
       ans=y/2-x;
       if(ans<=x && (x-ans)<=x)cout<<"Yes";
       else cout<<"No";
   }
t--;
}
return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
	char a[4];
	int i;
	int sum;
	scanf("%s", a);
	sum = 0;
	for (i = 0; i < 3; i++)
	{
		if (a[i] == 'a')sum = sum + 1;
		if (a[i] == 'b')sum = sum + 2;
		if (a[i] == 'a')sum = sum + 3;
	}
	if (sum == 6)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
x,y,a,b,c = map(int,input().split())
p = sorted(list(map(int,input().split())), reverse=True)
q = sorted(list(map(int,input().split())), reverse=True)
r = sorted(list(map(int,input().split())), reverse=True)
pq = sorted(p[:x] + q[:y])
ans = sum(pq)
i = 0
while i < min(a+b, c):
  if r[i] <= pq[i]:
    break
  ans += r[i] - pq[i]
  i += 1
print(ans)

Measured memory_bytes: 29320
package main

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

var s = bufio.NewScanner(os.Stdin)

func getInt() int {
	s.Scan()
	a, _ := strconv.Atoi(s.Text())
	return a
}

func main() {
	s.Split(bufio.ScanWords)
	n := getInt()
	v, c := make([]int, n), make([]int, n)

	for i := range v {
		v[i] = getInt()
	}
	for i := range c {
		c[i] = getInt()
	}
	ans := 0
	for i := range v {
		if v[i] > c[i] {
			ans += v[i] - c[i]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	/*string s;
	cin >> s;
	if (s == "SUN") {
		cout << 7;
		return 0;
	}
	if (s == "MON") {
		cout << 6;
		return 0;
	}
	if (s == "TUE") {
		cout << 5;
		return 0;
	}
	if (s == "WED") {
		cout << 4;
		return 0;
	}
	if (s == "THU") {
		cout << 3;
		return 0;
	}
	if (s == "FRI") {
		cout << 2;
		return 0;
	}
	if (s == "SAT") {
		cout << 1;
		return 0;
	}*/


	int n;
	string s;
	cin >> n >> s;
	rep(i, s.size()) {
		if ((char)(s[i] + n) <= 'Z') {
			s[i] = (char)(s[i] + n);
		}
		else s[i] = (char)(s[i] + n - 26);
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 256
from copy import copy

N,K=map(int,input().split())
A=list(map(int,input().split()))

X=[0]*((N*(N+1))//2)
I=0

for i in range(N):
    S=0
    for j in range(i,N):
        S+=A[j]
        X[I]=S
        I+=1

alpha=max(X)
B=1
while alpha>B:
    B<<=1

P=0
while B>0:
    C=0
    Y=[]
    for a in X:
        if a&B:
            C+=1
            Y.append(a)

    if C>=K:
        P+=B
        X=copy(Y)

    B>>=1

print(P)

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

int main()
{
    double T, X;
    cin >> T >> X;
    cout << fixed << setprecision(15) << T / X;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long int gcd(long long int a, long long int b)  {
    if(a<b) {
        long long int tmp=a;
        a = b;
        b = tmp;
    }

    if(b==0) {
        return a;
    }
    
    long long int r = a%b;
    return gcd(b, r);
}

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

    long long int A[N];
    long long int L[N], R[N];
    L[0] = 0;
    R[N-1] = 0;
    for(int i=0; i<N; i++) {
        cin >> A[i];
        if(i==N-1) break;
        // cout << "GCD of " << L[i] << " & " << A[i] << " : " << gcd(L[i], A[i]) << endl;
        L[i+1] = gcd(L[i], A[i]);
    }
    
    long long int max=0;
    for(int i=N-1; i>=0; i--) {
        long long int t=gcd(L[i], R[i]);
        if(max<t) max = t;
        if(i==0) continue;
        // cout << "GCD of " << R[i] << " & " << A[i] << " : " << gcd(R[i], A[i]) << endl;
        R[i-1] = gcd(R[i], A[i]);
    }
    
    cout << max << endl;

    return 0;
    
}

Measured memory_bytes: 2560
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
    }

    println!("{}", 800*n-n/15*200);

}


Measured memory_bytes: 2164
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX=200001;
int p=998244353;
int log2_p_MAX=32;
typedef long long ll;
ll felmer(ll a)
{
  // a^(2^i) mod p
  ll rem[log2_p_MAX];
  rem[0] = a%p;
  for(int i=1;i<log2_p_MAX;i++)
    rem[i] = (rem[i-1]*rem[i-1])%p;
  ll res = 1;
  ll expo = p-2;
  for(int i=0;i<log2_p_MAX;i++){
	if(expo%2==1){
      res *= rem[i];
      res = res%p;
    }
  	expo /= 2;
  }
  return res;
}
int main()
{
  ll n,m,k,i,res=0;
  ll com[N_MAX],col[N_MAX];
  cin >> n >> m >> k;
  com[0]=1;
  col[1]=m;
  for(i=1;i<n;i++){
    com[i]=(com[i-1]*(n-i))%p;
    com[i]*=felmer(i);
    com[i]%=p;
    col[i+1]=(col[i]*(m-1))%p;
  }
  for(i=0;i<=k;i++){
    res+=com[i]*col[n-i];
    res%=p;
  }
  cout << res << endl;
  return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

int pownew(int m, int n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

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

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

const int inf=100000000;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
   int n; cin>>n;
   vector<int> ans(26,inf);
   REP(i,n)
   {
       vector<int> cnt(26,0);
       string s; cin>>s;
       REP(j,s.size())
       {
           ++cnt[s[j]-'a'];
       }
       REP(k,26)
       {
           if(cnt[k]<=ans[k]) ans[k]=cnt[k];
       }
   }

    REP(i,26)
    {
       if(ans[i]!=0) {
           for(int j=0; j<ans[i]; j++) {
               cout << (char) (i + 'a');
           }
       }
    }
    cout<<endl;
    return  0;
}


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

using namespace std;

int n;
vector<vector<int> > adj;
long long MOD = 1e9+7;

map<pair<int, bool>, long long> memo;
long long dp(int curr, bool is_black, int p) {
  if(memo.find(make_pair(curr, is_black)) != memo.end()) {
    return memo[make_pair(curr, is_black)];
  }
  long long ret = 1;
  for(int i = 0; i<adj[curr].size(); ++i) {
    int next = adj[curr][i];
    if(next == p) continue;
    if(is_black) {
      ret = (ret * dp(next, false, curr)) % MOD;
    }
    else {
      ret = (ret * (dp(next, false, curr) + dp(next, true, curr))) % MOD;
    }
  }
  memo[make_pair(curr, is_black)] = ret;
  return ret;
}

int main() {
  // P: a classic! tree DP 

  cin.tie(0);
  cin.sync_with_stdio(0);
  cin >> n;
  adj.resize(n);
  for(int i = 0; i<n-1; ++i) {
    int u, v; cin >> u >> v;
    u--; v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  cout << (dp(0, false, -1) + dp(0, true, -1)) % MOD << endl;
}


Measured memory_bytes: 29312