akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 10005
#define MAX_E 30005
#define NIL -1
#define WHITE 0
#define BLACK 1
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

int main(void) {
    ll N, M, X, Y;
    cin >> N >> M >> X >> Y;
    ll i, x[100], y[100];
    
    for(i=0; i<N; i++)
        cin >> x[i];
    for(i=0; i<M; i++)
        cin >> y[i];
    
    sort(x, x+N);
    sort(y, y+M);
    
    ll maxX=max(x[N-1], X);
    ll minY=min(y[0], Y);
    
    if(maxX<minY) {
        cout << "No War" << endl;
    }else
        cout << "War" << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define each(i, c) for (auto& (i) : (c))

using namespace std;
typedef long long int ll;
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }

int main() {
    string a, b;
    cin >> a >> b;
    if (a.size() > b.size()) {
        cout << "GREATER" << endl;
    } else if (a.size() < b.size()) {
        cout << "LESS" << endl;
    } else {
        for (int i = 0; i < a.size(); i++) {
            int an = a[i] - '0';
            int bn = b[i] - '0';
            if (an > bn) {
                cout << "GREATER" << endl;
                return 0;
            } else if (an < bn) {
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
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;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF 1000000007 //4000000000000000037
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int N;
  cin>>N;
  vector<int> a,b,c;
  rep(i,N){
    int aa; cin>>aa;
    a.emplace_back(aa);
  }
  rep(i,N){
    int aa; cin>>aa;
    b.emplace_back(aa);
  }
  rep(i,N){
    int aa; cin>>aa;
    c.emplace_back(aa);
  }

  SORT(a);
  SORT(b);
  SORT(c);

  int bamatch[N];
  //int cbmatch[N];

  int nowa=0;
  int nowb=0;

  rep(i,N){ //b
    while(1){
      if(nowa==N or a[nowa]>=b[i]){
        bamatch[i]=nowa;
        break;
      }
      ++nowa;
    }
  }
  ll ans=0;
  ll now=0;
  rep(i,N){ //c
    while(1){
      if(nowb==N or b[nowb]>=c[i]){
        ans+=now;
        break;
      }
      now+=bamatch[nowb];
      ++nowb;
    }
  }
  cout<< ans<<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 1912
var n,m,x,y:longint;
    i:longint;
    a:array[0..10000]of longint;
begin
  read(n,m,x);
  for i:=1 to m do
  begin
    read(y);
    a[y]:=1;
  end;
  for i:=1 to n do
  a[i]:=a[i]+a[i-1];
  if a[x-1]>a[n]-a[x-1] then writeln(a[n]-a[x-1]) else writeln(a[x-1]);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rep1(i,n) for(int i=1; (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
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; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
int main(){
    int a, b, t; cin >> a >> b >> t;
    cout << (int)(((double)t+0.5) / a ) * b;
    return 0;
}

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

using namespace std;

struct UnionFind {
    vector<int> parent; // parent[root] is the negative of the size.

    explicit UnionFind(int n) : parent(n, -1) {
    };                                       //初期化

    bool unite(int u, int v) {//ノードx,yが属する木を併合
        u = root(u);
        v = root(v);
        if (u == v) return false;
        if (parent[u] > parent[v]) swap(u, v);
        parent[u] += parent[v];
        parent[v] = u;
        return true;
    }

    bool same(int u, int v) {//ノードx,yが同じ木に属するかどうか
        return root(u) == root(v);
    }

    int root(int u) {//ノードuが属する木の根
        return parent[u] < 0 ? u : parent[u] = root(parent[u]);
    }

    int size(int u) {//ノードiを含む木の大きさ
        return -parent[root(u)];
    }
};

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

    vector<int> a(m), b(m);
    for (int i = 0; i < m; ++i) {
        int aa, bb;
        cin >> aa >> bb;
        a[i] = aa - 1;
        b[i] = bb - 1;
    }

    vector<long long> res(m);
    long long ans = n * (n - 1) / 2;
    res[m - 1] = ans;
    auto uf = UnionFind(n);
    for (int i = m - 1; i >= 1; --i) {
        int p1 = a[i];
        int p2 = b[i];
        if (!uf.same(p1, p2)) {
            ans -= uf.size(p1) * uf.size(p2);
        }
        uf.unite(p1, p2);
        res[i - 1] = ans;
    }

    for (auto i:res) {
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>s;
    rep(i,2){
        if(s[i]==s[i+1]&&s[i+1]==s[i+2])ans=1;
    }
    if(ans==1)Cout("Yes");
    else Cout("No");
    return 0;
}


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

int main(){
    while(1){
        typedef pair<int, int> P;
        int n, m;
        cin >> n >> m;
        if (!n) break;
        int ans = 0;
        if (n < m){
            vector<vector<int>> lunch(n, vector<int>(m));
            for (int i = 0; i < n; i++){
                for (int j = 0; j < m; j++){
                    char x;
                    cin >> x;
                    lunch[i][j] = x - '0';
                }
            }
            for (int i = 0; i < (1 << n); i++){
                vector<int> tmp(m, 0);
                int cnt = 0;
                for (int j = 0; j < n; j++){
                    if ((i >> j) & 1){
                        cnt++;
                        for (int k = 0; k < m; k++) tmp[k] ^= lunch[j][k];
                    }
                }
                if (accumulate(tmp.begin(), tmp.end(), 0) == 0) ans = max(ans, cnt);
            }
        }
        else{
            vector<int> lunch(n);
            string s;
            int x;
            for (int i = 0; i < n; i++){
                cin >> s;
                reverse(s.begin(), s.end());
                int k = (int)s.size();
                x = 0;
                for (int j = 0; j < k; j++){
                    if (s[j] == '1') x += (int)pow(2, j);
                }
                lunch[i] = x;
            }
            vector<int> check((1 << m), 0);
            queue<P> q;
            for (int i = 0; i < n; i++){
                q.push({lunch[i], 1});
                for (int j = 0; j < (1<<m); j++){
                    if (check[j]) q.push({j^lunch[i], check[j] + 1});
                }
                while (q.size()){
                    int v = q.front().first;
                    int w = q.front().second; q.pop();
                    check[v] = max(check[v], w);
                }
            }
            ans = check[0];
        }
        cout << ans << endl;    
    }
}


Measured memory_bytes: 27684
mod = 10**9+7

n = int(input())
S = input()

alp = [chr(i) for i in range(97, 97+26)]

cnt = []
for a in alp:
    cnt.append(S.count(a))

ans = 1
for c in cnt:
    if c:
        ans *= (c+1)

print((ans-1)%mod)

Measured memory_bytes: 9292
N=int(raw_input())
a=[-1]
for _ in range(N):
    a.append(int(raw_input()))
 
 
i=1
c=0
while(1):
    if i==2:
        print c
        break
    elif c>=N:
        print -1
        break
    c+=1
    i=a[i]
            

Measured memory_bytes: 8964
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

constexpr int64_t DIV = 1000000007LL;



/** 累乗
    O(log n)
*/
template<typename T, T M>
T power(T x, T y)
{
    T ret = 1;
    for (; y != 0; y /= 2) {
        if (y % 2 != 0) {
            ret = (ret * x) % M;
        }
        x = (x * x) % M;
    }
    return ret;
}

/** 素数P を法とする逆元

    O(log n)
*/
template<typename T, T P>
T mod_inv(T x) {
    return power<T, P>(x, P-2);
}

/** 素数Pを法とする  static なメモ付きべき乗
 */
template<typename T, T P>
std::pair<T, T> memo_flactional(T val)
{
    static std::vector<T> memo{1};
    static std::vector<T> inv_memo{1};

    if (memo.size() <= val) {
        memo.reserve(val+1);
        inv_memo.reserve(val+1);
        for (T i = memo.size(); i <= val; ++i) {
            memo.push_back((memo[i-1] * i) % P);
            inv_memo.push_back((inv_memo[i-1] * mod_inv<T, P>(i)) % P);
        }
    }

    return std::make_pair(memo[val], inv_memo[val]);
}

// http://hos.ac/slides/20130319_enumeration.pdf

/** 素数P を法とする組み合わせ

    予め最大パターン計算しておく
    ex. memo_flactional<uint64_t, P>(MAX_N_OR_R);
*/
template<typename T, T P = 1000000007ULL>
T choose(T n, T r)
{
    T ret = memo_flactional<T, P>(n).first;
    ret *= memo_flactional<T, P>(r).second;
    ret %= P;
    ret *= memo_flactional<T, P>(n - r).second;
    ret %= P;

    return ret;
}



int main()
{
    int64_t H, W, A, B;
    std::cin >> H >> W >> A >> B;

    memo_flactional<int64_t, DIV>(H+W+1);

    int64_t ret = 0;
    for (int64_t i = 0; i < W - B; ++i) {
        ret += choose((B+1-1+i) + (H-A-1), H-A-1) * choose((W-B-1 - i) + (A-1), (A-1));
        ret %= DIV;
    }
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
int main() {
  int n, i;
  double a[20], sum = 0;
  char s[4];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%lf %s", &a[i], s);
    if(s[0] == 'B')
    a[i] = a[i] * 380000;
    sum = sum + a[i];
  }
  printf("%f\n", sum);
}


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

void printArray(int a[], int n) {
  for (int i = 0; i < n - 1; i++) {
    cout << a[i] << ' ';
  }
  cout << a[n - 1] << endl;
}

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

  printArray(a, n);
  for (int i = 1; i < n; i++) {
    int v = a[i];
    int j = i - 1;
    while (j >= 0 && a[j] > v) {
      a[j + 1] = a[j];
      j--;
    }
    a[j + 1] = v;
    printArray(a, n);
  }
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>

using namespace std;

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

    if (N == "A"){
        cout << "T" << endl;
    }
    if (N == "C"){
        cout << "G" << endl;
    }
    if (N == "G"){
        cout << "C" << endl;
    }
    if (N == "T"){
        cout << "A" << endl;
    }
    return 0;
}

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



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll n,a,b,c;
    cin>>n>>a>>b>>c;
    bool pos = 1;
    char ans[n]={};
    string s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    int con[n]={};
    int na=-1,nb=-1,nc=-1;
    for(int i=n-1;i>=0;i--){
        if(s[i]=="AB")na=i,nb=i,con[i]=nc;
        if(s[i]=="AC")na=i,nc=i,con[i]=nb;
        if(s[i]=="BC")nb=i,nc=i,con[i]=na;
    }
    for(int i=0;i<n;i++){
        if(s[i]=="AB"){
            if(a>b){
                a--, b++;
                ans[i] = 'B';
            }
            else if(a<b){
                a++, b--;
                ans[i] = 'A';
            }
            else{
                if(con[i]!=-1){
                    int nx = con[i];
                    if(s[nx]=="AC"){
                        a++,b--;
                        ans[i] = 'A';
                    }
                    if(s[nx]=="BC"){
                        b++,a--;
                        ans[i] = 'B';
                    }
                }
                else{
                    a++,b--;
                    ans[i] = 'A';
                }
            }
        }
        if(s[i]=="AC"){
            if(a>c){
                a--, c++;
                ans[i] = 'C';
            }
            else if(a<c){
                a++, c--;
                ans[i] = 'A';
            }
            else{
                if(con[i]!=-1){
                    int nx = con[i];
                    if(s[nx]=="AB"){
                        a++,c--;
                        ans[i] = 'A';
                    }
                    if(s[nx]=="BC"){
                        c++,a--;
                        ans[i] = 'C';
                    }
                }
                else{
                    a++,c--;
                    ans[i] = 'A';
                }
            }
        }
        if(s[i]=="BC"){
            if(c>b){
                c--, b++;
                ans[i] = 'B';
            }
            else if(c<b){
                c++, b--;
                ans[i] = 'C';
            }
            else{
                if(con[i]!=-1){
                    int nx = con[i];
                    if(s[nx]=="AB"){
                        b++,c--;
                        ans[i] = 'B';
                    }
                    if(s[nx]=="AC"){
                        c++,b--;
                        ans[i] = 'C';
                    }
                }
                else{
                    b++,c--;
                    ans[i] = 'B';
                }
            }
        }
        if(a<0 || b<0 || c<0)pos=false;
    }
    if(!pos){
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    for(int i=0;i<n;i++){
        cout << ans[i] << "\n";
    }
    

}

Measured memory_bytes: 7280
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long a=sc.nextLong();
		long b=sc.nextLong();
		long c=sc.nextLong();
		long d=sc.nextLong();
		long ac=a*c;
		long ad=a*d;
		long bc=b*c;
		long bd=b*d;
		System.out.println(Math.max(Math.max(ac, bd),Math.max(ad, bc)));
	}

}


Measured memory_bytes: 27012
import collections
n=int(input())
a=list(map(int,input().split()))
a1=collections.Counter(a[0::2]).most_common()
a2=collections.Counter(a[1::2]).most_common()
a1.append((0,0))
a2.append((0,0))
if a1[0]!=a2[0]:print(n-a1[0][1]-a2[0][1])
else:print(min(n-a1[0][1]-a2[1][1],n-a1[1][1]-a2[0][1]))

Measured memory_bytes: 20700
let powers =
  let rec pow b k =
    if k > 1000 then[]
    else k :: pow b (k*b)
  in
  let rec loop b =
    if b > 1000 then []
    else (pow b (b*b)) @ loop (b+1)
  in
  1 :: loop 2

let () =
    let x =
    Scanf.scanf "%d" (fun x -> x) in
    List.filter ((>=) x) powers
    |> List.fold_left max 1
    |> Printf.printf "%d\n"
         
  


Measured memory_bytes: 384
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;


class Program {

	//static long mod = 1000000007;
	static long mod =998244353;
	static int[] ans;
	static void Main(string[] args) {

		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res = "";
		int res=0;

		int[] vals = parseAry(Console.ReadLine().Split(cs));




		for ( int i = 1; i <= vals[0]; i++ ) {
			for ( int k = 1; k <= vals[1]; k++ ) {

				int d1 = k % 10;
				int d10 = k / 10;
				if ( (d10 < 2) || (d1 < 2) ) { continue; }
				if ( d1 * d10 == i ) { 
					res++; }
			}	
		}



			Console.WriteLine(res);

			return;

	}



	//	int配列をスペース区切りの文字列に変換
	static string stringBuilderArrayInt(int[] a) {
		StringBuilder sb = new StringBuilder();

		for ( int i = 0; i < a.Length; i++ ) {
			if ( a[i] == 1 ) { sb.Append(i + " "); }
		}
		if ( sb.Length > 1 ) {
			sb = sb.Remove(sb.Length - 1, 1);
		}
		return sb.ToString(); ;
	}


	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}


	
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false) ; cin.tie(NULL) ; cout.tie(NULL);
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define N 100000

int32_t main(){
    IOS;

int n,W;
cin>>n>>W;

vector<int > dp(N+1 , INT_MAX);
dp[0] = 0;
for(int i=0;i<n;i++)
{
    
    int w,v;
    cin>>w>>v;
    
    for(int j=N-v;j>=0;j--)
    {
        dp[j+v] = min(dp[j+v] , dp[j] + w);
    }

}

int i;
for(i=N;i>=0;i--)
if(dp[i] <= W)
break;

cout<<i<<endl;

}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')

const int N_MAX = 5000;
const int K_MAX = 5000;

int N, K;
int a[N_MAX];

bool dp[K_MAX];

bool C(int k) {
  if (k < 0) return false;
  if (k >= N) return true;
  if (a[k] >= K) return true;
  fill(dp, dp + K, false);
  dp[0] = true;
  REP(i, N) {
    if (i == k) continue;
    for (int j = K - 1; j >= a[i]; j--) {
      dp[j] |= dp[j - a[i]];
    }
  }
  FOR(j, K - a[k], K - 1) {
    if (dp[j]) return true;
  }
  return false;
}

void solve() {
  sort(a, a + N);
  int lo = -1;
  int hi = N;
  while (hi - lo > 1) {
    int mi = (lo + hi) / 2;
    if (C(mi)) hi = mi;
    else lo = mi;
  }
  printf("%d\n", hi);
}

void input() {
  scanf("%d%d", &N, &K);
  REP(i, N) scanf("%d", a + i);
}

int main() {
  input();
  solve();
  return 0;
}


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

int main(void)
{
    int k;
    cin >> k;
    string s;
    getline(cin, s);
    getline(cin, s);
    
    if( s.length() <= k)
    {
        cout << s;
    }
    else
    {
        cout << s.substr(0, k) << "...";
    }
    
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l1,l2,l;
    string s1,s2;
    cin>>s1>>s2;
    l1=s1.size();
    l2=s2.size();
    if(l1>l2)
    {
        for(int i=0;i<l2;i++)
            cout<<s1[i]<<s2[i];
        cout<<s1[l1-1];
    }
    else if(l1<l2)
    {
        for(int i=0;i<l1;i++)
            cout<<s1[i]<<s2[i];
        cout<<s2[l2-1];
    }
    else
    {
        for(int i=0;i<l2;i++)
            cout<<s1[i]<<s2[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int n; cin >> n;
  vector<double> v(n);
  for(int i=0;i<n;++i)cin >> v[i];
  double iout = 0.0d;
  for(int i=0;i<n;++i)iout += 1.0d/v[i];

  cout << setprecision(12) << 1.0d/iout << endl;

  return 0;
}


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

int main(){
  int n;
  int64_t count = 0;
  cin >> n;
  std::vector<int> a(n - 1);
  for (int i = 0; i < n - 1; i++) {
    std::cin >> a.at(i);
  }
  std::map<int, int> mp;
  for (int i = 0; i < n; i++) {
    mp[i] = 0;
  }
  for (int i = 0; i < n - 1; i++) {
    mp[a.at(i)]++;
  }
  for (int i = 1; i < n + 1; i++) {
    cout << mp[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 13560
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int n;
	string s, t,u;
	cin >> n >> s >> t;
	for (int i = 0; i < 2 * n;i++) {
		if (i%2==0) {
			u+= s[i / 2];
		}
		else {
			u+= t[i / 2];
		}
	}
	cout << u << endl;
}

Measured memory_bytes: 256
def main():
    N, K = list(map(int, input().split()))
    P = list(map(int, input().split()))
    result = solve(N, K, P)
    print(result)


def solve(N, K, P) -> int:
    sorted_p = sorted(P)
    return sum(sorted_p[:K])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int N = 3e5 + 10;
int r[N], c[N];

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int h, w, m; cin >> h >> w >> m;
  vector<PII> bs;
  int rmx = 0, cmx = 0;
  for (int i = 0; i < m; i++) {
    int x, y; cin >> x >> y;
    r[x]++;
    rmx = max(rmx, r[x]);
    c[y]++;
    cmx = max(cmx, c[y]);
    bs.emplace_back(x, y);
  }

  int cnt = 0;
  for (auto [x, y]: bs) {
    if (rmx == r[x] && cmx == c[y]) cnt++;
  }

  int rc = 0, cc = 0;
  for (int x = 1; x <= h; x++) {
    if (r[x] == rmx) rc++;
  }
  for (int y = 1; y <= w; y++) {
    if (c[y] == cmx) cc++;
  }

  int ans = rmx + cmx - (cnt == rc * 1ll * cc);
  cout << ans << endl;

  return 0;
}


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

std::vector<std::tuple<int, int, int>> edges;

int main()
{
    int m = 1000000;
    scanf("%d", &m);
    int n = 0;
    std::vector<int> ways { 1 };
    while (ways.back() * 3 <= m) {
        edges.emplace_back(n, n + 1, 0);
        edges.emplace_back(n, n + 1, ways.back());
        edges.emplace_back(n, n + 1, ways.back() * 2);
        n ++;
        ways.push_back(ways.back() * 3);
    }
    int cur = 0;
    for (int i = n; i >= 0; -- i) {
        if (cur + ways[i] <= m) {
            edges.emplace_back(i, n + 1, cur);
            cur += ways[i];
        }
        if (cur + ways[i] <= m) {
            edges.emplace_back(i, n + 1, cur);
            cur += ways[i];
        }
    }
    std::vector<int> dp(n + 2, 0);
    dp[0] = 1;
    for (int i = 1; i < n + 2; ++ i) {
        for (auto&& e : edges) {
            if (std::get<1>(e) == i) {
                dp[i] += dp[std::get<0>(e)];
            }
        }
    }
    // printf("ways = %d\n", dp[n + 1]);
    assert(dp[n + 1] == m);
    printf("%d %d\n", n + 2, static_cast<int>(edges.size()));
    for (auto&& e : edges) {
        printf("%d %d %d\n", std::get<0>(e) + 1, std::get<1>(e) + 1, std::get<2>(e));
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

typedef pair<int,int> pii;
struct cookie{
  int x, y, n;
};
const int dx[] = {1, 1, 1, 0, 0, -1, -1, -1}, dy[] = {1, 0, -1, 1, -1, 1, 0, -1};
const char C[] = {'x', 'o'};
  
bool comp1(const cookie &a, const cookie &b)
{
  if(a.n != b.n)
    return a.n > b.n;
  else if(a.x != b.x)
    return a.x < b.x;
  else
    return a.y < b.y;
}

bool comp2(const cookie &a, const cookie &b)
{
  if(a.n != b.n)
    return a.n > b.n;
  else if(a.x != b.x)
    return a.x > b.x;
  else
    return a.y > b.y;
}

int main()
{
  char table[8][8];
  REP(i,8) cin >> table[i];

  bool t = false;
  int pass = 0;
  while(1){
    set<pii> s;
    REP(i,8){
      REP(j,8){
        if(table[i][j] == C[t]){
          REP(k,8){
            int x = i+dx[k], y = j+dy[k];
            if(x >= 0 && x < 8 && y >= 0 && y < 8 && table[x][y] == '.')
              s.insert(pii(x,y));
          }
        }
      }
    }
    vector<cookie> v;
    for(set<pii>::iterator i = s.begin(); i != s.end(); i++){
      int r = 0;
      REP(j,8){
        int x = (*i).first+dx[j], y = (*i).second+dy[j];
        if(x >= 0 && x < 8 && y >= 0 && y < 8 && table[x][y] == C[t]){
          int n = 0;
          bool flag = false;
          while(x >= 0 && x < 8 && y >= 0 && y < 8){
            if(table[x][y] == C[t]){
              n++;
            }else if(table[x][y] == '.'){
              break;
            }else{
              flag = true;
              break;
            }
            x += dx[j];
            y += dy[j];
          }
          if(flag)
            r += n;
        }
      }
      if(r != 0){
        struct cookie a;
        a.x = (*i).first;
        a.y = (*i).second;
        a.n = r;
        v.push_back(a);
      }
    }
    if(v.empty()){
      if(pass == 1){
        REP(i,8){
          REP(j,8){
            cout << table[i][j];
          }
          cout << endl;
        }
        break;
      }else{
        pass++;
        t = !t;
        continue;
      }
    }
    pass = 0;

    if(t) sort(v.begin(),v.end(),comp2);
    else sort(v.begin(),v.end(),comp1);
    
    struct cookie a = v[0];
    table[v[0].x][v[0].y] = C[!t];
    REP(i,8){
      int x = a.x+dx[i], y = a.y+dy[i];
      while(x >= 0 && x < 8 && y >= 0 && y < 8 && table[x][y] == C[t]){
        x += dx[i];
        y += dy[i];
      }
      if(x >= 0 && x < 8 && y >= 0 && y < 8 && table[x][y] == C[!t]){
        x -= dx[i];
        y -= dy[i];
        while(x != a.x || y != a.y){
          table[x][y] = C[!t];
          x -= dx[i];
          y -= dy[i];
        }
      }
    }
    t = !t;
  }
}

Measured memory_bytes: 3156
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<iomanip>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  string n;
  cin>>n;
  rep(i,0,3){
    if(n.at(i)=='1'){
      n.at(i)='9';
      continue;
    }
    if(n.at(i)=='9'){
      n.at(i)='1';
      continue;
    }
  }
  ou(n);
}

Measured memory_bytes: 256
def examC():
    A, B, C, X, Y = LI()
    ans = 0
    if A+B<=C*2:
        ans = A*X + B*Y
    else:
        Z = min(X,Y)
        ans = min(A,C*2)*max(X-Z,0) + min(B,C*2)*max(Y-Z,0) + C*Z*2
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()


Measured memory_bytes: 3444
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(str(input()))

for i in range(N - K):
    if T[K + i] == T[i]:
        T[K + i] = 'x'

#print(T)

Rc = T.count('r')
Sc = T.count('s')
Pc = T.count('p')
#print(Rc, Sc, Pc)
count = P * Rc + S * Pc + R * Sc
print(count)

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

long double logn(int base, long double antilog) {
    return log(antilog) / log((long double)base);
}

void solve(long long N, long long K){
    int ans = 0;
    ll uku = 1;
    N++;
    for(int i = 0;;i++){
        if(N <= uku){
        //    ans++;
            break;
        }
        uku *= K;
        ans++;
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


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

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

    int n, a; cin >> n >> a;

    if ((n%500)<=a) cout << "Yes";
    else cout << "No";

    cout << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i, n) for(int i=((int)(n));i>0;i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	int N, X;
	cin >> N >> X;
	vector<int> L(N);
	rep(i, N)cin >> L[i];
	int now = 0;
	bool JD = true;
	for(int i = 0; i < N; i++){
		now += L[i];
		if(now > X){
			JD = false;
			cout << i + 1 << endl;
			break;
		}
	}
	if(JD)cout << N + 1 << endl;
}

Measured memory_bytes: 256
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
// 12/11/2016
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

int h, w, n, a[MAXN], c[210][210];

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("inp.txt", "r", stdin);
////    freopen("out.txt", "w", stdout);
//#endif

	cin >> h >> w;
	cin >> n;
	for (int i=0; i<n; i++) cin >> a[i];
	
	int cur = 1;
	for (int i=0; i<h; i++) {
		if (i % 2) {
			for (int j=0; j<w; j++) {
				while (!a[cur - 1]) cur++;
				c[i][j] = cur;
				a[cur - 1]--;
			}
		}
		else {
			for (int j=w-1; j>=0; j--) {
				while (!a[cur - 1]) cur++;
				c[i][j] = cur;
				a[cur - 1]--;
			}
		}
	}
	
	for (int i=0; i<h; i++) {
		for (int j=0; j<w; j++) cout << c[i][j] << " ";
		cout << endl;
	}


}


Measured memory_bytes: 384
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;



int main() {
	
	map<char, int>mp;
	int N;
	string s[50];
	cin >> N;
	
	FOR(i, 'a', 'z' + 1) {
		mp[i] = 100;
	}

	FOR(i, 0, N) {
		map<char, int> cur;
		cin >> s[i];
		FOR(j, 0, s[i].length()) {
			cur[s[i][j]]++;
		}
		FOR(i, 'a', 'z' + 1) {
			mp[i] = min(mp[i], cur[i]);
		}
	}
	FOR(i, 'a', 'z' + 1) {
		FOR(j, 0, mp[i]) {
			cout << char(i);
		}
	}
	cout << endl;



	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
p,s=[],[]
for i in range(m):
    a,b=map(str,input().split())
    p.append(int(a))
    s.append(b)
c,e=0,0
l=[0]*n
for i in range(m):
    if s[i]=="WA" and l[p[i]-1]==0:
        e+=1
    elif s[i]=="AC" and l[p[i]-1]==0:
        c+=1
        l[p[i]-1]=1
for i in range(m):
    if s[i]=="WA" and l[p[i]-1]==0:
        e-=1
print(str(c)+" "+str(e))

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    sort(rall(a));
    ll ans=0;
    rep(i,k){
        ans+=a[i];
    }
    cout<<ans<<endl;
}


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


int main() {
	int h,w;
    int x=0;
  	cin >> h >> w;
	string kari[h];
  	int tate[h+2][w+2];
    int yoko[h+2][w+2];
    int max=0;
    int r=0;
  	fr(i,h+2){
      fr(j,w+2){
        tate[i][j]=-1;
        yoko[i][j]=-1;
      }
    }
    fr(i,h){
		cin >> kari[i];
    }
  	fr(i,h){
      fr(j,w){
        if(kari[i].substr(j, 1) == "#"){tate[i+1][j+1] = -1;yoko[i+1][j+1] = -1;}
        if(kari[i].substr(j, 1) == "."){tate[i+1][j+1] = 0;yoko[i+1][j+1] = 0;}
      }
    }
  	for(int x=1;x<w+1;x++){
      for(int y=1;y<h+1;y++){
        if(tate[y][x]==-1){}
        else if(tate[y-1][x]==-1)tate[y][x]=1;
        else tate[y][x] = tate[y-1][x]+1;
      }
    }
    for(int x=w;x>0;x--){
      for(int y=h;y>0;y--){
        if(tate[y][x]==-1){}
        else if(tate[y+1][x]==-1){}
        else tate[y][x] = tate[y+1][x];
      }
    }
    for(int y=1;y<h+1;y++){
      for(int x=1;x<w+1;x++){
        if(yoko[y][x]==-1){}
        else if(yoko[y][x-1]==-1)yoko[y][x]=1;
        else yoko[y][x] = yoko[y][x-1]+1;
      }
    }
     for(int y=h;y>0;y--){
       for(int x=w;x>0;x--){
        if(yoko[y][x]==-1){}
        else if(yoko[y][x+1]==-1){}
        else yoko[y][x] = yoko[y][x+1];
      }
    }
    for(int x=1;x<w+1;x++){
      for(int y=1;y<h+1;y++){
        if(tate[y][x]+yoko[y][x]>max)max=tate[y][x]+yoko[y][x];
      }
    }
    cout << max-1 << endl;
}


Measured memory_bytes: 35712
#include<bits/stdc++.h>
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n, m;
	
	cin>>n>>m;
	++m;
	vector<vector<int>> v(m+1);
	for(int i=0;i<n;++i){
		int a,b;
		cin>>a>>b;
		if(a<m) v[m-a].push_back(b);
	}
	
	ll ans = 0;
	
	multiset<int> q;
	for(int i=m;i>0;--i){
		q.insert(ALL(v[i]));
		if(q.size()){
			auto it = q.end();
			--it;
			ans+=*it;
			q.erase(it);
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}


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

using int_ = int;
#define int int_least64_t

int_ main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);

  int n, m; cin >> n >> m;
  vector<bool> done(m);
  vector<tuple<int, bool, int> > events;
  for (int i=0; i<m; ++i) {
    int a, b; cin >> a >> b;
    events.emplace_back(a, true, i);
    events.emplace_back(b, false, i);
  }
  sort(events.begin(), events.end());
  vector<int> cur;
  int num_bridges = 0;
  for (auto& ev : events) {
    int t, i; bool enter;
    tie(t, enter, i) = ev;
    if (enter) {
      cur.push_back(i);
    } else if (!done[i]) {
      ++num_bridges;
      for (auto x : cur)
        done[x] = true;
      cur.clear();
    }
  }
  cout << num_bridges << '\n';
}

/*
 * Local variables:
 * compile-command:"g++ -D_GLIBCXX_DEBUG -g3 -ggdb3 -O0 -Wall -Wextra -std=c++14 d.cc -o d && for f in *.in; do echo \"--- $f -------------\"; ./d <$f; done"
 * end:
 */


Measured memory_bytes: 8560
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N, A, B;
	cin >> N >> A >> B;
	int res = 0;
	for (int i = 1;i <= N;i++) {
		int j = i;
		int sum = 0;
		while (j) {
			sum += j % 10;
			j /= 10;
		}
		if (sum >= A && sum <= B) res += i;
	}

	cout << res << "\n";

	return 0;
}

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

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        char al[]=new char[27];
        int i;
        for(i=1;i<=26;i++)
            al[i]=(char)('a'+i-1);
        al[0]='z';
        long n=Long.parseLong(bu.readLine());
        while(n>0)
        {
            int last=(int)(n%26);
            sb.append(al[last]);
            if(last==0) n--;
            n/=26;
        }
        System.out.print(sb.reverse());
    }
}


Measured memory_bytes: 32516
import java.util.*;

//ｘの３乗を計算し、結果を出力するプログラム
public class Main {
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();
		int x = Integer.parseInt(input);
		x = x*x*x;
		System.out.println(x);
		
		sc.close();
	}
}



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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;
    bool tacno=true;
    cin >> s;
    for (int i=0;i<s.size();i++)
        if(s[i]=='L' && i%2==0 || s[i]=='R' && i%2==1)
            tacno=false;
    if(tacno)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 256
#include<stdio.h>
    
int main(){
    
	int a,b,c,tmp,i,N,k[2048]={0};

	scanf("%d",&N);

	for(i=0;i<N;i++){


		scanf("%d%d%d",&a,&b,&c);

		if(a<b){tmp=b;
		b=a;
		a=tmp;
		}
		if(a<c){tmp=c;
		c=a;
		a=tmp;
		}


		if(a*a==b*b+c*c)k[i]++;

	}

	for(i=0;i<N;i++){
		if(k[i]==0)printf("NO\n");
		else printf("YES\n");
	}

    return 0;
}

Measured memory_bytes: 588
#include <iostream>

//#include <algorithm>
//#include <vector>
//#include <cmath>
//#include <cstring>
//include <queue>
//#include <map>
//cout<<*itr<<endl;
//#define ll long long //data types used often, but you don't want to type them time by time
//#define ALL(c) (c).begin(),(c).end() //handy for function lisziee "sort()"
//#define FOREACH(itr,cont) for (auto itr=cont.begin(); itr!=cont.end(); itr++) // traverse an STL data structure
#define F(i,R) for (int i = 0; i < R; i++) //next four are for "for loops"

using namespace std;
int main()
{
    ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
    int n, x,size;
    cin>>n>>x;
    int arr[n+1],s=0;
    arr[0]=0;
    for(int i=1; i<=n; i++) {
        cin>>size;
        s+=size;
        arr[i]=s;
    }
    int c=0;
    for(int i=0; i<=n; i++) if(arr[i]<=x)
    c++;
    if(c==0)
    cout<<1;
    cout<<c;
}

Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let m: usize = sc.read();
    if m % 2 == 1 {
        println!("-1");
        return;
    }
    let mut graph = vec![vec![]; n];
    for i in 0..m {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        graph[a].push((b, i));
        graph[b].push((a, i));
    }

    let mut tree = vec![vec![]; n];
    let mut used = vec![false; m];
    let mut visit = vec![false; n];
    dfs(0, &mut visit, &graph, &mut tree, &mut used);

    let mut ans = vec![vec![]; n];
    for u in 0..n {
        for &(v, i) in graph[u].iter() {
            if !used[i] {
                ans[u].push(v);
                used[i] = true;
            }
        }
    }

    answer_dfs(0, 0, &mut ans, &tree);
    for i in 0..n {
        for &next in ans[i].iter() {
            println!("{} {}", i + 1, next + 1);
        }
    }
}

fn answer_dfs(v: usize, p: usize, graph: &mut Vec<Vec<usize>>, tree: &Vec<Vec<usize>>) {
    for &next in tree[v].iter() {
        answer_dfs(next, v, graph, tree);
    }
    if v == p {
        return;
    }
    if graph[v].len() % 2 == 0 {
        graph[p].push(v);
    } else {
        graph[v].push(p);
    }
}

fn dfs(
    v: usize,
    visit: &mut Vec<bool>,
    graph: &Vec<Vec<(usize, usize)>>,
    tree: &mut Vec<Vec<usize>>,
    used: &mut Vec<bool>,
) {
    visit[v] = true;
    for &(next, i) in graph[v].iter() {
        if !visit[next] {
            tree[v].push(next);
            dfs(next, visit, graph, tree, used);
            used[i] = true;
        }
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 37372
N = int(input())
List = [list(map(str, input().split())) for i in range(0,N)]
X = str(input())

yoroshiosu = 0
samu = 0

for i in range (0, N):
	if X == List[i][0]:
		yoroshiosu =1
	elif yoroshiosu == 0:
		continue
	else:
		samu+=int(List[i][1])
        
print(samu)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int sx,sy,tx,ty,x,y;
    cin >> sx >> sy >> tx >> ty;
    x=sx;y=sy;

    while(y < ty){
        cout << 'U';
        y++;
    }
    while(x<tx){
        cout << 'R';
        x++;
    }
    while(sy<y){
        cout << 'D';
        y--;
    }
    while(sx-1<x){
        cout << 'L';
        x--;
    }
    
    while(y<ty+1){
        cout << 'U';
        y++;
    }
    while(x<tx){
        cout << 'R';
        x++;
    }
    y--;cout<<'D';
    x++;cout<<'R';

    while(sy-1<y){
        cout << 'D';
        y--;
    }
    while(sx<x){
        cout << 'L';
        x--;
    }
    y++;cout << 'U'<<endl;
}

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

int main()
{
	int c,n,a;
	cin >>n>>c;
	int sum=0;
	for (int i = 1; i <= c; i++) {
		cin >> a;
		sum += a;
	}
	int ans = sum / (n + 1);
	if (sum - ans * (n + 1) > 0)ans++;
	cout << ans << endl;
	
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll H, W, K;
    cin >> H >> W >> K;
    VS s(H);
    rep(i, 0, H) cin >> s[i];
    ll ans = 0;
    for(int hbit = 0; hbit < (1<<H); hbit++){
        for(int wbit = 0; wbit < (1<<W); wbit++){
            ll cnt = 0;
            rep(h, 0, H){
                rep(w, 0, W){
                    if((hbit & (1<<(int)h)) || (wbit & (1<<(int)w))) continue;
                    if(s[h][w] == '#') cnt++;
                }
            }
            // cerr << cnt << endl;
            if(cnt == K){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define FOR(i, l, r) for(int i=int(l); i<=int(r); ++i)
#define FORD(i, l, r) for(int i=int(l); i>=int(r); --i)
#define REP(i, r) for(int i=0; i<int(r); ++i)
#define REPD(i, l) for(int i=int(l)-1; i>=0; --i)
#define X first
#define Y second
#define mk make_pair
#define sz size
#define DEBUG(x) {cerr << #x << " = " << x << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
#define Nmax int(1e5 + 100)

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef pair<ii, int> iii;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x >> (pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1 << (pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1 << (pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n, lab[Nmax], ans;
iii a[Nmax];
vector< pair<int , ii> > p;

bool cmpf(iii a, iii b) { return a.X.X < b.X.X; }
bool cmps(iii a, iii b) { return a.X.Y < b.X.Y; }
bool cmpw(pair<int, ii> a, pair<int, ii> b) { return a.X < b.X; }

int findset(int u) {return lab[u] <= 0 ? u : lab[u] = findset(lab[u]);}
void uni(int s, int t) {
    if (lab[s] < lab[t]) lab[t] = s;
    else if (lab[s] > lab[t]) lab[s] = t;
    else {lab[t] = s; lab[s]--;}
}

int main() {
    //freopen("in.INP", "r", stdin);
    scanf("%d", &n);
    FOR(i, 1, n) {
        scanf("%d %d", &a[i].X.X, &a[i].X.Y);
        a[i].Y = i;
    }
    sort(a+1, a+n+1, cmpf);
    FOR(i, 1, n-1)
        p.push_back(mk(a[i+1].X.X - a[i].X.X, ii(a[i].Y, a[i+1].Y)));
    sort(a+1, a+n+1, cmps);
    FOR(i, 1, n-1)
        p.push_back(mk(a[i+1].X.Y - a[i].X.Y, ii(a[i].Y, a[i+1].Y)));
    sort(p.begin(), p.end(), cmpw);
    REP(i, p.size()) {
        int s = findset(p[i].Y.X), t = findset(p[i].Y.Y);
        if (s !=  t) {
            uni(s, t);
            ans += p[i].X;
        }
    }
    cout << ans;
    return 0;
}




Measured memory_bytes: 5876
#include<stdio.h>

int main(){
	int k;
	char word[100];
	scanf("%d", &k);
	scanf("%s", &word);
	
	int len = 0;
	
	for(int i = 0; word[i] != '\0'; i++){
		len++;
	}
	
	if(len <= k){
		printf("%s\n", word);
	}
	else{
		for(int i = 0; i < k; i++){
			printf("%c", word[i]);
		}
		printf("...\n");
	}
	return 0;
}

Measured memory_bytes: 1656