akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    val (n, x) = readLine()!!.split(" ").map(String::toInt)
    val ln = readLine()!!.split(" ").map(String::toInt)

    val dn = mutableListOf(0)
    for (i in 1..n) {
        dn.add(dn[i - 1] + ln[i - 1])
    }
    println(dn.count { it <= x })
}


Measured memory_bytes: 36152
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int AB = 26;
	public static void main(String[] args) {
		int i=0,j=0,k=0;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[][] s = new int[n][AB];
		for (i = 0; i < n; i++) {
			char[] c = sc.next().toCharArray();
			for (j = 0; j < c.length; j++) {
				s[i][c[j]-'a']++;
			}
		}
		int[] ss = new int[AB];
		for (i = 0; i < AB; i++) {
			int mn = s[0][i];
			for (j = 1; j < n; j++) {
				mn = Math.min(mn, s[j][i]);
			}
			ss[i] = mn;
		}
		PrintWriter pw = new PrintWriter(out);
		for (i = 0; i < AB; i++) {
			if(ss[i]>0) {
				for (j = 0; j < ss[i]; j++) {
					pw.print((char)('a'+i));
				}
			}
		}
		pw.println();
		pw.flush();
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}


int main(){
    int n,m,r;
    cin>>n>>m>>r;
    vector<int> t(r);
    rep(i,r) {
        cin>>t[i];
        t[i]--;
    }
    sort(all(t));
    
    vector<vector<int>> d(n,vector<int>(n,INF));
    rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        a--;
        b--;
        d[a][b]=c;
        d[b][a]=c;
    }
    
    rep(k,n) {
        rep(i,n) {
            rep(j,n) {
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    
    int ans=INF;
    do{
        int tmp=0;
        rep(i,r-1){
            tmp+=d[t[i]][t[i+1]];
        }
        ans=min(ans,tmp);
    }while(next_permutation(all(t)));
    
    cout<<ans<<endl;
    
}


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

int main() {
  int N;
  cin >> N;
  vector<vector<int>>data(N,vector<int>(30));
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    for(int j=0;j<30;j++){
      data.at(i).at(j)=a%2;
      a/=2;
    }
  }
  vector<int>sum(30);
  for(int j=0;j<30;j++){
    for(int i=0;i<N;i++){
      sum.at(j)=(sum.at(j)+data.at(i).at(j))%2;
    }
  }
  for(int i=0;i<N;i++){
    int ans=0;
    int beki=1;
    for(int j=0;j<30;j++){
      ans+=((sum.at(j)+data.at(i).at(j))%2)*beki;
      beki*=2;
    }
    cout << ans << " ";
  }
}

Measured memory_bytes: 32732
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long[] line = Stream.of(sc.nextLine().split(" ", 0)).mapToLong(Long::parseLong).toArray();
		if (line[1] == 0) {
			System.out.println(0);
		}else if (line[2] == 0) {
			System.out.println(line[0]);
		}else {
			long div = line[0] / (line[1] + line[2]);
			long mod = line[0] % (line[1] + line[2]);
			long add = 0;
			if (mod > line[1]) {
				add += line[1];
			}else {
				add += mod;
			}
			System.out.println(line[1] * div + add);
		}

	}



}

Measured memory_bytes: 35956
from itertools import accumulate

N,M,Q=map(int,input().split())

a=[[0]*(N+1) for i in range(N+1)]
for i in range(M):
    L,R=map(int,input().split())
    a[L][R]+=1


b=[list(accumulate(a[i])) for i in range(N+1)]
k=[[b[j][i] for j in range(i+1) ] for i in range(N+1)]

ans=[list(accumulate(reversed(k[i])))[::-1] for i in range(N+1)]


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

Measured memory_bytes: 15732
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{
    int A,B;
    cin>>A>>B;

    if(A==B){
        cout << "Draw"<<endl;
        return 0;
    }

    if(A==1||B==1){
        if(A==1){
            cout<<"Alice"<<endl;
        }else{
            cout<<"Bob"<<endl;
        }
    }else{

        if(A>B){
            cout<<"Alice"<<endl;
        }else{
            cout<<"Bob"<<endl;
        }
    }

    return 0;
}


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

int main() {
	string s;
	cin >> s;
	int sl = s.size();
	for(int i = 1;i < s.size()/2;i++)
	{
		sl -= 2;
		if(s.substr(0,sl/2) == s.substr(sl/2,sl/2))
		{
			break;
		}
	}
    cout << sl << endl;
	return 0;
}


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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define YN(a, b, c) ((c)? a : b)
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) (i64)(a / (f64)__gcd(a, b) * b) /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i64 N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    cout << 4 + (i64)ceil((f64)N / min({A, B, C, D, E})) << endl;
}


Measured memory_bytes: 3684
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;

void swap(int a,int b) {
	int tmp = a;
	a = b;
	b = tmp;
}

int main(void) {
	ll k,n;
	cin >> k >> n;
	vector<ll>a(n + 5);

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

	ll b = 0;
	ll ans = 0;

	for (int i = 0; i < n-1; i++) {
		b = max(b,a[i+1]-a[i]);
		ans += a[i + 1] - a[i];
	}

	b= max(b, k-a[n - 1]+a[0]);
	ans += k - a[n - 1] + a[0];

	ans -= b;

	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 4844
n, m = map(int, input().split())
ba = []

for i in range(m):
    ba.append(list(map(int, input().split())))
    ba[i][0], ba[i][1] = ba[i][1] - 1, ba[i][0] - 1

ba.sort()
bridge = [ba[0][0] - 1]


for i in range(1, m):
    if ba[i][1] > bridge[-1]:
        bridge.append(ba[i][0] - 1)

print(len(bridge))


Measured memory_bytes: 60888
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  ll n,k; cin >> n >> k;
  if((n+1)/2 >= k) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  
}

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

int main()
{
    int n;
    int a[N], b[N], c[N];
    cin >> n;
    a[0] = -1;
    for(int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }
    for(int i = 1; i <= n; ++i)
    {
        cin >> b[i];
    }
    for(int i = 1; i != n; ++i)
    {
        cin >> c[i];
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        ans += b[i];
        if(a[i] == a[i - 1] + 1)
        {
            ans += c[a[i- 1]];
        }
    }
    cout << ans << '\n';
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    string s;
    li n;
    cin >> n;
    cin >> s;

    li cnt_r = 0;
    rin{
        if (s[i] == 'R')cnt_r++;
    }
    li res = 0;
    rep(i, cnt_r) {
        if (s[i] != 'R')res++;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3752
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long mod = (b-a+1)%4;
        if(a%2==0){
            if(mod==0){
                System.out.println(0);
            }else if(mod==1){
                System.out.println(b);
            }else if(mod ==2){
                System.out.println(1);
            }else{
                System.out.println(1^b);
            }
        }else{
            if(mod==0){
                System.out.println(a^1^b);
            }else if(mod==1){
                System.out.println(a);
            }else if(mod ==2){
                System.out.println(a^b);
            }else{
                System.out.println(a^1);
            }
        }
    }
    
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
bool sv[maxx]={0};    // returns 0 if a num is prime
int sp[maxx]={0};     // gives smallest prime factor of the number
void Sieve() {for(int i= 2; i< maxx; i+= 2) sv[i]=1,sp[i] = 2;sv[2]=0;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll fact[maxx]={0}; // returns factorial of that number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<maxx;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncrm(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
ll inv[maxx];   // returns the modular inverse of number
void inversify( ll m){inv[1]=1;for(int i=2;i<maxx;i++){inv[i]= m- m/i*inv[m%i]%m;}}
ll ncr(ll n,ll r,ll m){int ans=1;for (int i = 0; i < r; i++){ans=ans*(n-i)%m*inv[i+1]%m;}return ans;}
*/
signed main(){
  fast;
  //usefile;
  //test
  {
    int t,f;
    int x;
    cin>>x;
    t=x/500;
    x=x%500;
    f=x/5;
    int ans=1000*t+5*f;
    cout<<ans;

  }
  //time("");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
/*
time:26m09s
wa:0
反省:一回問題を読み違えていた
考察:
• 北方向に進む移動があり、南方向に進む移動がない場合
• 南方向に進む移動があり、北方向に進む移動がない場合
• 西方向に進む移動があり、東方向に進む移動がない場合
• 東方向に進む移動があり、西方向に進む移動がない場合
は NO を出力し、それ以外の場合は YES を出力すればよい。
排他的論理和(^)を使って実装できる
少なくとも→排他的論理和
*/
int main() {
    string S;
    cin >> S;
    int n = 0;
    int w = 0;
    int s = 0;
    int e = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'N') n=1;
        else if(S[i] == 'W') w=1;
        else if(S[i] == 'S') s=1;
        else e=1;
    }
    if(!(n^s) && !(w^e)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
#define dbg(x...) do { cout << "\033[32;1m" << #x <<" -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<class T, class... Ts> void err(const T& arg,const Ts&... args) { cout << arg << " "; err(args...); }
typedef long double db;
const db eps = 1e-12;
const db pi = acosl(-1.0);
inline int sgn(db x) {if(fabs(x) < eps) return 0; return x < 0 ? -1 : 1;}

struct Point{
    db x, y;
    Point(){}
    Point(db x, db y):x(x), y(y){}
    void input(){
        cin >> x >> y;
    }
    Point operator - (const Point &b) const{
        return Point(x - b.x, y - b.y);
    }
    db operator ^ (const Point &b)const {
        return x * b.y - y * b.x;
    }
    db operator * (const Point &b) const{
        return x * b.x + y * b.y;
    }
}p0, p1, p2;


int main(){
#ifndef ONLINE_JUDGE
// freopen("i.in","r",stdin);
//  freopen("o.out","w",stdout);
#endif
    p0.input(); p1.input();
    int q;scanf("%d", &q);
    while(q--){
        p2.input();
        int d1 = sgn((p2 - p0) ^ (p1 - p0));
        if(d1 < 0) puts("COUNTER_CLOCKWISE");
        else if(d1 > 0) puts("CLOCKWISE");
        else {
            int d2 = sgn((p2 - p0) * (p1 - p0));
            if(d2 < 0) puts("ONLINE_BACK");
            else if(sgn((p2 - p1) * (p1 - p0)) > 0) puts("ONLINE_FRONT");
            else puts("ON_SEGMENT");
        }
        
    }

    return 0;
}


Measured memory_bytes: 3276
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;

int main()
{
    int i,sum,a,b;
    string s;
     sum=0;
     scanf("%d %d",&a,&b);
     for(i=a;i<=b;i++){
        s=to_string(i);
            if (s[0] == s[4] && s[1] == s[3])
    {
      sum++;
    }
     }
     cout<<sum<<endl;
    return 0;
}

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


const ll INF = 1e18;
const int MAX_N = 2e3 + 10;

int N;
vector<vector<int> > G, rG;
int used[MAX_N], dist[MAX_N];

int bfs(int s){
    for(int i = 0; i < N; i++) dist[i] = 1e9;

    queue<int> Q;
    Q.push(s);
    dist[s] = 0;

    while(!Q.empty()){
        int v = Q.front(); Q.pop();
        used[v] = 1;
        for(auto nv:G[v]){
            if(used[nv] == 0){
                dist[nv] = dist[v] + 1;
                Q.push(nv);
            }/* else{
                cout << v << endl;
                return (dist[v] + 1);
            } */
        }
    }
    int ans = 1e9;
    for(auto e: rG[s]){
        if(dist[e] != 1e9){
            ans = min(ans, dist[e] + 1);
        }
    }
    return ans;
}

/* int bfs2(int s){
    for(int i = 0; i < N; i++) dist[i] = 1e9;

    queue<int> Q;
    Q.push(s);
    dist[s] = 0;

    while(!Q.empty()){
        int v = Q.front(); Q.pop();
        used[v] = 1;
        for(auto nv:rG[v]){
            if(used[nv] == 0){
                dist[nv] = dist[v] + 1;
                Q.push(nv);
            }else{
                return dist[v];
            }
        }
    }
    return 1e9;
} */

int main(){
    int M;cin >> N >> M;
    G.resize(N);
    rG.resize(N);
    rep(i, 0, M){
        int a, b; cin >> a >> b;a--,b--;
        G[a].emplace_back(b);
        rG[b].emplace_back(a);
    }
    int ans_index = 0, K = 1e5;
    rep(i, 0, N){
        rep(j, 0, N) {used[j] = 0;}
        int t = bfs(i);
        if(t < K){
            ans_index = i;
            K = t;
        }
    }
    rep(j, 0, N) {used[j] = 0;}
    vector<int> ans;
    if(K == 1e5) cout << -1 << endl;
    else{
        cout << K << endl;
        bfs(ans_index);
        ans.push_back(ans_index);
        int t = ans_index;
        K--;
        //rep(i, 0, N) cerr << dist[i] << endl;
        while(K > 0){
            //cout << "K " <<  K << endl;
            //cout << t << endl;
            for(auto e: rG[t]){
                //cout << "e " << e << endl;
                //cerr << dist[e] << endl;
                if(dist[e] == K){
                    t = e;
                    K--;
                    ans.push_back(t);
                    break;
                }
            }
        }
        /* for(auto e: rG[t]){
            if(dist[e] == K){
                t = e;
                K--;
                ans.push_back(t);
            }
        }
        while(t != ans_index){
            for(auto e: rG[t]){
                if(dist[e] == K){
                    t = e;
                    K--;
                }
            }
        } */
        sort(ans.begin(), ans.end());
        for(auto e: ans){
            cout << e + 1 << endl;
        }
        return 0;
    }
    

}

Measured memory_bytes: 384
N = int(input())
A = list(map(int,input().split()))
A1 = {}
judge = 1

if(N%2 == 1):
  for i in range(N):
    if(A[i] in A1): A1[A[i]] += 1
    else: A1[A[i]] = 1
  count = -1
  for k, v in sorted(A1.items()):
    count += 1
    if(count == 0):
      if((k == 0)and(v == 1)):
        continue
      else: 
        judge = 0
        break
    else:
      if((k == 2*count)and(v == 2)):
        continue
      else:
        judge = 0
        break
    
 
else:
  for i in range(N):
    if(A[i] in A1): A1[A[i]] += 1
    else: A1[A[i]] = 1
  count = -1
  for k, v in sorted(A1.items()):
    count += 1
    if((k == 2*count+1)and(v == 2)):
       continue
    else:
        judge = 0
        break
    count += 1

ans = 0
if(judge == 0):
  print(ans)
else:
  ans = (2**(N//2))%(10**9 + 7)
  print(ans)

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

int main(void){
  string s;
  cin >> s;
  bool ans=true;
  for(int i=0;i<s.length();i++){
  	if(i%2==0 && s[i]!='h')   ans = false;
    if(i%2==1 && s[i]!='i')   ans = false;
  }
  if(s.length()%2==1) ans = false;
  if(ans)cout << "Yes";
  else cout << "No";
return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <vector>
#include <iomanip>
using namespace std;
using ll = long long;

int main(){
    // input
    int N; cin >> N;
    vector<int> p(N);
    for (int i = 0; i < N; ++i){
        cin >> p.at(i);
    }

    // compute
    bool can = false;
    int cnt = 0;
    for (int i = 0; i < N; ++i){
        if(p.at(i) != i + 1){
            cnt++;
        }
    }
    if (cnt == 2 || cnt == 0){
        can = true;
    }

    // output
    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;

}




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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int cnt=0;
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++){
        for(int j=n-1; j>i; j--){
            if(a[j]<a[j-1]){
                swap(a[j],a[j-1]);
                cnt++;
            }
        }
    }
    for(int i=0; i<n; i++){
        if(i!=n-1) cout << a[i] << " ";
        else cout << a[i] << endl;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3132
N = gets.to_i
hs = gets.split(' ').map(&:to_i)

cnt = 0
while !hs.all?(&:zero?) do
  chunks = hs.slice_before(&:zero?).map { |a| a.reject(&:zero?) }.select { |a| a.size > 0 }
  cnt += chunks.size

  chunks.each_with_index do |chunk, i|
    chunk = chunk.each_with_index do |k, j|
      chunks[i][j] -= 1
    end
  end

  hs = chunks.inject([]) { |ar, a| ar += a + [0] }
end

puts cnt

Measured memory_bytes: 2044
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int N, W; cin >> N >> W;
  vector<int> w(N), v(N); REP(i, N) cin >> w[i] >> v[i];
  vector<vector<long long> > dp(N+1, vector<long long>(W+1, 0));
  REP(i, N) REP(j, W+1) {
    if (j - w[i] >= 0) dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
    else dp[i+1][j] = dp[i][j];
  }
  cout << dp[N][W] << '\n';
  return 0;
}


Measured memory_bytes: 80256
N = int(input())
A = list(map(int, input().split()))

# N が 2 で何回割れるか
def how_many_times(N):
    exp = 0
    while N % 2 == 0:
        N //= 2
        exp += 1
    return exp

result = min(map(how_many_times, A))
print(result)

Measured memory_bytes: 9176
#include <stdio.h>
int main ()
{
	int n,a,b,a1;
	scanf("%i%i%i",&n,&a,&b);
	a1=n*a;
	if(a1<=b)
	{
		printf("%i",a1);
	}
	else
	{
		printf("%i",b);
	}
	return 0;
}


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

using ll = long long;

int main() {
    ll H, W;
    cin >> H >> W;
    if (H == 1 || W == 1) {
        cout << "1\n";
        return 0;
    }
    cout << (H * W + 1) / 2 << "\n";
}

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

ans = 0
right = n-1
for i in range(n):
    if c[i] == "W":
        for j in range(right,-1,-1):
            if j <= i:
                print(ans)
                exit()
            if c[j] == "R":
                ans += 1
                right = j-1
                break
print(ans)

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

int main(){
    int n;
    cin >> n;
    bool isp = true;
    ll s = 0;
    vector<pair<ll,ll>> task(n);
    for(int i = 0;i < n;i ++){
        cin >> task[i].second >> task[i].first;
    }
    sort(task.begin(),task.end());
    for(int i = 0;i < n;i ++){
        s += task[i].second;
        if(s>task[i].first) {isp=0;break;}
    }
    if(isp) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define ll long long
#define int long long
#define FOR(i, x, y) for(int i = x; i <= y; ++i)
#define pb push_back
#define eb emplace_back
#define Size(v) (int)v.size()

using namespace std;
// using namespace __gnu_pbds;

const int INF = 1e16;

struct Obj {
	int v, a, b;

	Obj(int x, int y, int z) {
		v = x, a = y, b = z;
	}

	Obj() {
		v = 0, a = 0, b = 0;
	}
};

int n, m, s, c[55], d[55];
vector<Obj> adj[55];
int dist[56 * 2600];
vector<pair<int, int>> graph[56 * 2600];

int encode(int i, int j) {
	return (i * 2501 + j);
}

bool visited[56 * 2600];

void build(int i, int j) {
	int yeet = encode(i, j);
		
	if (j < 2500) {
		graph[yeet].eb(encode(i, min(2500LL, j + c[i])), d[i]);
	}

	for (auto &p : adj[i]) {
		int c = p.v, cost = p.a, w = p.b;
		if (j >= cost) {
			graph[yeet].eb(encode(c, j - cost), w);
		}
	}
}

void dijkstra(int v) {
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;

	pq.push({0, v});
	dist[v] = 0;

	while (!pq.empty()) {
		int u = pq.top().second; pq.pop();

		if (visited[u]) continue;

		visited[u] = true;

		for (auto &p : graph[u]) {
			int c = p.first, w = p.second;
			if (dist[c] > dist[u] + w) {
				dist[c] = dist[u] + w;
				pq.push({dist[c], c});
			}
		}
	}
}

void solve() {
	cin >> n >> m >> s;

	FOR (i, 1, m) {
		int u, v, a, b; cin >> u >> v >> a >> b;

		adj[u].eb(v, a, b);
		adj[v].eb(u, a, b);
	}

	FOR (i, 1, n) cin >> c[i] >> d[i];

	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= 2500; ++j) {
			build(i, j);
		}
	}

	// cerr << "here\n";

	fill(dist, dist + 56 * 2600, INF);

	dijkstra(encode(1, min(2500LL, s)));

	for (int i = 2; i <= n; ++i) {
		int ans = 1e15;
		for (int j = 0; j <= 2500; ++j) {
			ans = min(ans, dist[encode(i, j)]);
		}
		cout << ans << '\n';
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	int t = 1;
	while (t--) 
		solve();
	return 0;
}

Measured memory_bytes: 24288
#![allow(unused_imports)]
#![allow(unused_macros)]
use itertools::Itertools;
use std::cmp::{max, min};
use std::collections::*;
use std::i64;
use std::io::{stdin, Read};
use std::usize;

trait ChMinMax {
    fn chmin(&mut self, other: Self);
    fn chmax(&mut self, other: Self);
}
impl<T> ChMinMax for T
where
    T: PartialOrd,
{
    fn chmin(&mut self, other: Self) {
        if *self > other {
            *self = other
        }
    }
    fn chmax(&mut self, other: Self) {
        if *self < other {
            *self = other
        }
    }
}

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, a: usize, b: usize, c: usize, x: usize, y: usize);
    let f = |x, y| {
        if x < y {
            0
        } else {
            x - y
        }
    };
    let mut ret = std::usize::MAX;
    for r in 0..=(max(x, y)) {
        let p = f(x, r);
        let q = f(y, r);
        ret.chmin(a * p + b * q + 2 * c * r);
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2076
#include<stdio.h>

int main(void){
	int N;
	scanf("%d",&N);
	int D[N][2];
	int ans=0;

	for(int i=0;i<N;i++){
      scanf("%d %d",&D[i][0],&D[i][1]);
	  if(D[i][0]==D[i][1]) ans+=1;
	  else ans=0;

	  if (ans==3) {
		  printf("Yes\n");
		  return 0;
	  }
	}

 printf("No\n");
	return 0;
}

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

int panjang;
string abjad="abcdefghijklmnopqrstuvwxyz", input;

int main (){
	cin>>input;
	for (int i=0; i<=26; i++){
		if (abjad [i] == input [0]){
			cout<<abjad [i+1];
		}
	}
}

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

using namespace std;

int wa[100000 +  1];


int main(void){
    
    int n,m,k;
    int answ=0,ansa=0;
    
    memset(wa,0,sizeof(wa));
    
    scanf("%d%d",&n,&m);
    
    for(int i=0;i<m;i++){
        
        char tmp[3];
        
        scanf("%d%s",&k,tmp);
        
        if(wa[k]!=-1 && tmp[0]=='W' && tmp[1]=='A'){
            wa[k]++;
        }
        else if(wa[k]!=-1 && tmp[0]=='A' && tmp[1]=='C'){
            answ+=wa[k];
            wa[k]=-1;
            ansa++;
        }
    }
    
    printf("%d %d\n",ansa,answ);
    
    return 0;
    
}


Measured memory_bytes: 512
// #define CPP_IO

#pragma region

#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
template <typename T>
using minheap = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using maxheap = priority_queue<T>;

#define f first
#define s second

#ifdef LOCAL
#define debug cout
#define debugf(format, ...) printf(format, ##__VA_ARGS__)
#else
#define debug \
    if (0) cout
#define debugf(format, ...) 42
#endif

#define DUMP(a) debug << #a " = " << (a) << "\n";
#define DUMP2(a, b) debug << #a " = " << (a) << " " #b " = " << (b) << "\n";
#define DUMP3(a, b, c) debug << #a " = " << (a) << " " #b " = " << (b) << " " #c " = " << (c) << "\n";
#define DUMP4(a, b, c, d) debug << #a " = " << (a) << " " #b " = " << (b) << " " #c " = " << (c) << " " #d " = " << (d) << "\n";

template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[ ";
    for (auto e : v) os << e << " ";
    return os << "]";
}

template <typename T, typename V>
ostream& operator<<(ostream& os, set<T, V> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V, typename S>
ostream& operator<<(ostream& os, map<T, V, S> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V>
ostream& operator<<(ostream& os, pair<T, V> x) {
    return os << "( " << x.first << ", " << x.second << " )";
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& e : v) is >> e;
    return is;
}

template <typename T, typename V>
istream& operator>>(istream& is, pair<T, V>& x) {
    return is >> x.first >> x.second;
}

void solve();

int main() {
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#else
#ifdef CPP_IO
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
#endif
    solve();
}

#pragma endregion

int n, s[1 << 18];
void solve() {
    scanf("%d", &n);
    int m = 1 << n;
    for (int i = 0; i < m; ++i) {
        scanf("%d", s + i);
    }
    sort(s, s + m);

    set<ii> used, unused;
    used.insert({ s[m - 1], m - 1 });
    for (int i = 0; i < m - 1; ++i) {
        unused.insert({ s[i], i });
    }

    while (!unused.empty()) {
        // DUMP2(used, unused);
        vector<ii> tmp;
        for (auto it = used.rbegin(); it != used.rend(); ++it) {
            int v = it->f;
            auto it2 = unused.upper_bound({ v, -1 });
            if (it2 == unused.begin()) {
                printf("No\n");
                return;
            }
            --it2;
            tmp.push_back(*it2);
            unused.erase(it2);
        }
        for (auto x : tmp) {
            used.insert(x);
        }
    }
    printf("Yes\n");
}

Measured memory_bytes: 14592
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////

int main()
{
    int K;
    io >> K;

    int a = 7 % K;
    int ans = -1;
    for (int i = 1; i <= K + 10; ++i)
    {
        if (a == 0)
        {
            ans = i;
            break;
        } 
        a = (10 * a + 7) % K;
    }

    cout << ans << BR;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
ii a[1000005];
bool cmp(ii a, ii b){
    int A = a.second - a.first;
    int B = b.second - b.first;
    if ( (A < 0) != (B < 0) ) return (A >= 0);
    if (A < 0 && B < 0){
        if (a.first != b.first) return a.second > b.second;
        else return -A < -B;
    }
    else {
        if (a.first != b.first) return a.first < b.first;
        else return A > B;
    }
}
int main(){
    int n;
    scanf("%d",&n);
    for (int i = 0; i < n; i++){
        string s;
        cin >> s;
        int cur = 0;
        for (int j = 0; j < s.size(); j++){
            if (s[j] == '(') cur++;
            else{
                if (cur == 0) a[i].first++;
                else cur--;
            }
        }
        a[i].second = cur;
    }
    sort(a,a+n,cmp);
    int X = 0;
    int l;
    for (l = 0; l < n; l++){
        //printf("L %d %d\n",a[l].first,a[l].second);
        if (a[l].second - a[l].first < 0) break;
        if (a[l].first > X){
            printf("No");
            return 0;
        }
        X += a[l].second - a[l].first;
    }
    int Y = 0;
    for (int r = n-1; r >= l; r--){
        //printf("R %d %d\n",a[r].first,a[r].second);
        if (a[r].second > Y){
            printf("No");
            return 0;
        }
        Y += a[r].first - a[r].second;
    }
    printf("%s\n",(X == Y) ? "Yes":"No");
}


Measured memory_bytes: 11468
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;
int n,m,k,ans,tmp;
int H,W,h,w;

int main()
{
    scanf("%d %d",&H,&W);
    scanf("%d %d",&h,&w);
    ans = H - h;
    tmp = W - w;
    ans *= tmp;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cassert>
#include <map>
#include <set>
#include <algorithm>
#include <queue>

using namespace std;

#define forsn(i,s,n) for (int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
#define F first
#define C second

typedef long long int tint;

bool edges[201][201];
int colores[201];

bool isBipartite(int n) {
	forn(i,n) colores[i] = -1;
	
	colores[0] = 0;
	queue<int> q({0});
	
	while (!q.empty()) {
		int cur = q.front(); q.pop();
		
		forn(j, n) if (edges[cur][j]) {
			if (colores[j] == -1) {
				colores[j] = 1 - colores[cur];
				q.push(j);
			} else if (colores[j] == colores[cur]) {
				return false;
			}
		} 
	}
	
	return true;
}

int best(int from, int n) {
	forn(i,n) colores[i] = -1;
	
	int biggest = 1;
	
	colores[from] = 1;
	queue<int> q({from});
	
	while (!q.empty()) {
		int cur = q.front(); q.pop();
		
		forn(j, n) if (edges[cur][j]) {
			if (colores[j] == -1) {
				colores[j] = colores[cur] + 1;
				biggest = max(biggest, colores[j]);
				q.push(j);
			}
		} 
	}
	
	return biggest;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	
	forn(i,n) {
		string s; cin >> s;
		forn(j,n) edges[i][j] = s[j] == '1';
	}
	
	if (!isBipartite(n)) {
		cout << -1 << endl;
	} else {
		int biggest = 2;
		forn(i, n) biggest = max(biggest, best(i, n));
		
		cout << biggest << endl;
	}
}



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

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

int main(void){
  char buf[32] = { 0 };
  int num[128] = { 0 };
  int N = 0;

  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%d", &N);
  
  for(int i = 0; i < N; i++){
  	fgets(buf, sizeof(buf), stdin);
  	sscanf(buf, "%d", &num[i]);
  }
  
  qsort(num, N, sizeof(int), compare_int);
  int count = 1;
  for(int i = 1; i < N; i++){
    if(num[i - 1] < num[i]) count++;
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 1736
def is_same(A,B):
    for rot in range(2):
        for i in range(4):
            if A == B: return True
            B = [[y,-x] for x,y in B]
        B = [[x-B[-1][0],y-B[-1][-1]] for x,y in B][::-1]
    return False
    
while 1:
    n = int(raw_input())
    if n == 0: break
    poly = []
    for i in xrange(n+1):
        m = int(raw_input())
        xy = [map(int,raw_input().split()) for _ in xrange(m)]
        poly.append([[x-xy[0][0],y-xy[0][1]] for x,y in xy])
    for i in xrange(1,n+1):
        if is_same(poly[0],poly[i]):
            print i
    print "+++++"

Measured memory_bytes: 4264
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  string S;
  cin >> S;

  const int N = S.size();
  int ans = 0;
  for (int i = 0; i < (int)N - 1; ++i) ans += (S[i] != S[i + 1]);
  cout << ans << endl;

  return 0;
}


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

int main() {
    int n, l;

    cin >> n >> l;

    vector<string> a(n);

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

    sort(a.begin(), a.end());

    for (string s : a) cout << s;

    return 0;
}


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

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

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

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

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main(void){
    ll n;
    ll ans =0;
    cin >> n;
    for(ll i=1; i<=n; i++){
        if( (i%3) ==0 || (i%5)==0 ){
            continue;
        }
        ans += i;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
'use strict';
function Main(inputs) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  const input = inputs.split("\n");
  const n = Number(input[0].split(' ')[0]);
  const k = Number(input[0].split(' ')[1]);
  const kitaichi = input[1].split(' ').map(Number).map((i) => (1 + i) / 2);
  let max = 0;
  let sum = 0
  for (let i = 0; i < n; i++){
    sum += kitaichi[i];
    if (i >= k) sum -= kitaichi[i - k];
    if (max < sum) max = sum;
  }
  console.log(max);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 35544
#include <bits/stdc++.h>
#define il inline
#define RG register
#define ll long long

using namespace std;

int a[200005],n;
ll ans;

il int gi(){
  RG int x=0,q=1; RG char ch=getchar();
  while ((ch<'0' || ch>'9') && ch!='-') ch=getchar();
  if (ch=='-') q=-1,ch=getchar();
  while (ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q*x;
}

int main(){
  n=gi();
  for (RG int i=1;i<=n;++i)
    if ((a[i]=gi())>=i) puts("-1"),exit(0);
  for (RG int i=2;i<=n;++i)
    if (a[i]>=a[i-1]+2) puts("-1"),exit(0);
  ans+=a[n];
  for (RG int i=n-1;i;--i)
    if (a[i]>=a[i+1]) ans+=a[i];
  cout<<ans; return 0;
}


Measured memory_bytes: 1024
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
//#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    set<int>s;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        s.insert(x);
    }
    if(s.size()==n)cout<<"YES";
    else cout<<"NO";
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    int ans = INF;
    REP(i, sz(s) - 2) {
        int x = stoi(s.substr(i, 3));
        chmin(ans, abs(x - 753));
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<functional>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef queue<P> Q;
int N;
int a[100010];
int main(){
    cin >>N;
    int fourCount=0;
    int twoCount=0;
    int oddCount=0;
    for(int i=0;i<N;i++){
        cin>>a[i];
        if(a[i]%4==0){
            fourCount++;
        }else if(a[i]%2==0){
            twoCount++;
        }else if(a[i]%2==1){
            oddCount++;
        }
    }
        if(twoCount>=1){
            oddCount++;
        }

        if(oddCount<=fourCount+1){
            cout<< "Yes";
        }else{
            cout<<"No";
        }
    
    
    
    return 0;
}

Measured memory_bytes: 640