akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

struct Node {
    shared_ptr<Node> left, right;
    ll height, child_num;
    Node() : left(nullptr), right(nullptr), height(0), child_num(0) {}
};

int main() {
    ll N, L;
    cin >> N >> L;

    shared_ptr<Node> root = make_shared<Node>();

    for (ll i = 0; i < N; i++) {
        string s;
        cin >> s;
        shared_ptr<Node> curr = root;

        for (char c : s) {
            if (c == '0') {
                if (curr->left == nullptr) {
                    //作る
                    curr->left = make_shared<Node>();
                    curr->left->height = curr->height + 1;
                    curr->child_num++;
                }
                curr = curr->left;
            } else {
                if (curr->right == nullptr) {
                    //作る
                    curr->right = make_shared<Node>();
                    curr->right->height = curr->height + 1;
                    curr->child_num++;
                }
                curr = curr->right;
            }
        }
    }

    vector<ll> levels;

    stack<shared_ptr<Node>> st;
    st.push(root);

    while (!st.empty()) {
        auto t = st.top();
        st.pop();

        if (t->child_num == 1) {
            levels.push_back(L - t->height);
        }

        if (t->left != nullptr) {
            st.push(t->left);
        }

        if (t->right != nullptr) {
            st.push(t->right);
        }
    }

    ll grundy = 0;
    for (ll level : levels) {
        ll g = 1;
        while (level % g == 0) {
            g *= 2;
        }
        g /= 2;

        grundy ^= g;
    }

    cout << (grundy != 0 ? "Alice" : "Bob") << endl;
}

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


int main(){
    string S;
    ll vec[4] = {0,0,0,0};
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'N') vec[0] = 1;
        if(S[i] == 'S') vec[1] = 1;
        if(S[i] == 'W') vec[2] = 1;
        if(S[i] == 'E') vec[3] = 1;
    }
    if(vec[0] != vec[1] || vec[2] != vec[3]){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

// dp[i] - TRUE if the first player wins if there are i stones remaining

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int> a(n);
    for(int& x : a) {
        scanf("%d", &x);
    }
    vector<bool> dp(k + 1);
  	dp[0] = false; // do not have stones so you loose
    for(int stones = 0; stones <= k; ++stones) {
        for(int x : a) {
            if(stones >= x && !dp[stones-x]) {
                dp[stones] = true;
            }
        }
    }
    
    puts(dp[k] ? "First" : "Second");
}

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


int main() {
   int  Q;
   cin >> Q;
   int a[100001];
   a[1]=0;
   bool b;
   for (int i=1; i<100001; i++) {
       b=false;
       if (i==1) continue;
       if (i%2==0) {
           a[i]=a[i-1];continue;
       }
       for (int j=2; j<=sqrt(i); j++) {
           if (i%j==0) {
               a[i]=a[i-1];b=true;break;
           }
       }
       if (b) continue;
       for (int j=2; j<=sqrt((i+1)/2); j++) {
           if (((i+1)/2)%j==0) {
               a[i]=a[i-1]; b=true;break;
           }
       }
       if (b) continue;
       a[i]=a[i-1]+1;
   }
   for (int i=0; i<Q; i++) {
       int l,r;
       cin >> l >> r;
       cout << a[r]-a[l-1] << endl;
   }
}

Measured memory_bytes: 4064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
//---------------------------------------------------------------------------------------------------
typedef pair<int,int> P;

int main(void){
    // Your code here!
    int n; cin >> n;
    ll k; cin >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i],a[i]--;
    int x = 0;
    vector<int> ord(n,-1);
    ord[0] = 0;
    int first = 0;
    int cnt = 0;
    int roop;
    while(true) {
        cnt++;
        x = a[x];
        if (ord[x] != -1) {
            roop = cnt - ord[x];
            first = ord[x];
            break;
        }
        ord[x] = cnt;
    }
    if (k <= first) {
        rep(i,n) if (k == ord[i]) cout << i+1 << endl;return 0;
    } else {
        k -= first;
        k %= roop;
        rep(i,n) if (k == ord[i] - first) cout << i+1 << endl;return 0;
    }
}


Measured memory_bytes: 4816
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

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

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

    const int slen = (int) S.size();

    string cand1, cand2;
    for (int i = 0; i < slen; i++) {
        cand1 += (i % 2 == 0) ? "1" : "0";
        cand2 += (i % 2 == 0) ? "0" : "1";
    }

    int diff1 = 0;
    for (int i = 0; i < slen; i++) {
        if (cand1[i] != S[i]) {
            diff1++;
        }
    }

    int diff2 = 0;
    for (int i = 0; i < slen; i++) {
        if (cand2[i] != S[i]) {
            diff2++;
        }
    }

    cout << min(diff1, diff2) << endl;

    return 0;
}


Measured memory_bytes: 768
from sys import exit, stdin
W, H, M = [int(_) for _ in stdin.readline().rstrip().split()]
maxX, minX, maxY, minY = W, 0, H ,0
for i in range(M):
    x, y, a = [int(_) for _ in stdin.readline().rstrip().split()]
    if a == 1 and x > minX:
        minX = x
    elif a == 2 and x < maxX:
        maxX = x
    elif a == 3 and y > minY:
        minY = y
    elif a == 4 and y < maxY:
        maxY = y
  
x_diff = maxX - minX
y_diff = maxY - minY
if x_diff > 0 and y_diff > 0:
  print(x_diff * y_diff)
else:
  print(0)

Measured memory_bytes: 38256
while True:
    n,r = map(int,raw_input().split())
    if(n == 0 and r == 0):
        break
    n_list = []
    for i in xrange(n):
        n_list.append(i+1)
    for i in xrange(r):
        p,c = map(int, raw_input().split())
        n_list =  n_list[0:n-(p-1)-c] + n_list[n-(p-1):n] + n_list[n-(p-1)-c:n-(p-1)]
    print n_list[n-1]

Measured memory_bytes: 6276
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e18 + 7LL;
constexpr ll MOD = 1e9 + 7;

template <typename T>
istream& operator>>(istream& is, vector<T> &v)
{
    for (int i = 0; i < v.size(); ++i)
    {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    for (int i = 0; i < v.size()-1; ++i)
    {
        os << v[i] << " ";
    }
    if (v.size() > 0){
        os << v[v.size() - 1] << endl;
    }
    return os;
}

int main()
{
    int n, k;
    cin >> n >> k;
    vector<pll> sushi(n);
    REP(i,n){
        cin >> sushi[i].SE >> sushi[i].FI;
    }
    sort(sushi.begin(), sushi.end());
    reverse(sushi.begin(), sushi.end());
    ll ans = 0;
    unordered_map<int,int> kind;
    priority_queue<int> pque2;
    priority_queue<int, vint, greater<int>> pque;
    ll kindval = 0;
    REP(i, k)
    {
        ans += sushi[i].FI;
        ++kind[sushi[i].SE];
        if (kind[sushi[i].SE] > 1){
            pque.push(sushi[i].FI);
        }else{
            ++kindval;
        }
    }
    FOR(i,k,n)
    {
        ++kind[sushi[i].SE];
        if (kind[sushi[i].SE] == 1)
        {
            pque2.push(sushi[i].FI);
        }
    }
    ans += kindval * kindval;
    ll now = ans;
    while (pque.size() > 0 && pque2.size() > 0)
    {
        now -= pque.top();
        pque.pop();
        now += pque2.top();
        pque2.pop();
        ++kindval;
        now += kindval * kindval - (kindval - 1) * (kindval - 1);
        ans = max(now, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6180
H, W = gets.split.map(&:to_i)

results = []
if H == 2

elsif H % 3 == 0
  results.push(0)
else
  results.push(((H / 3 + 1) * W) - ((H / 3) * W))
end

if W == 2

elsif W % 3 == 0
  results.push(0)
else
  results.push(((W / 3 + 1) * H) - ((W / 3) * H))
end

(((H + 1) / 4)..((H + 1) / 2)).each do |h|
  pieces = [h * W]
  pieces.push (H - h) * (W / 2)
  pieces.push (H - h) * ((W + 1) / 2)
  results.push pieces.max - pieces.min
end

(((W + 1) / 4)..((W + 1) / 2)).each do |h|
  pieces = [h * H]
  pieces.push (W - h) * (H / 2)
  pieces.push (W - h) * ((H + 1) / 2)
  results.push pieces.max - pieces.min
end


puts results.min

Measured memory_bytes: 2300
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main()
{
	int n;
	double sum = 0.0;
	string x, u;
	cin >> n;

	for (auto i = 0; i < n; ++i) {
		cin >> x >> u;
		if (u == "BTC") sum += stod(x);
		else sum += stoi(x) / 380000.0;
	}

	cout << sum * 380000.0 << endl;
	return 0;
}

Measured memory_bytes: 764
/*
      author : nishi5451
      created: 11.08.2020 22:32:08
*/

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


int main(){
    int r;
    cin >> r;
    cout << r*r << endl;
    return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <cstdio>
#include <set>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;
#define INF 0x3f3f3f3f
int dis[50][50];
int main()
{
    int m,a,ans,b,oop,n,op;
    while(~scanf("%d",&n)&&n)
    {
        m = 0;
        for(int i = 0 ;i < 20; i++)
        {
            for(int j = 0 ; j <20 ;j++)
                dis[i][j] = INF;
        }
        for(int i = 0; i < n; i++)
        {
            scanf("%d%d",&a,&b);
            scanf("%d",&dis[a][b]);
            dis[b][a] = dis[a][b];
            if(m < a||m < b)
            {
                if(a<b)  m = b;
                else    m = a;
            }
        }
        for(int i = 0; i <= m; i++)  dis[i][i] = 0;
        for(int k = 0; k <= m; k++)
            for(int i = 0; i <= m; i++)
                for(int j = 0; j <= m; j++)
                {
                    if(dis[i][j] > dis[i][k] + dis[k][j])
                   {
                       dis[i][j] = dis[i][k] + dis[k][j];
                       dis[j][i] = dis[i][k] + dis[k][j];
                   }
                }
        oop = INF;
        for(int i = 0 ; i <= m;i++)
        {
            ans = 0;
            for(int u = 0 ; u <= m; u++)
            {
                if(dis[i][u] != INF)
                    ans += dis[i][u];
            }
            if(ans<oop)
            {
                op = i;
                oop = ans;
            }
        }
        printf("%d %d\n",op,oop);
    }
    return 0;
}



Measured memory_bytes: 3112
N,M = map(int,input().split())
L = [list(map(int,input().split())) for i in range(N)]

L = sorted(L,key=lambda x: x[0])

ans = 0
for i in range(len(L)) :
    if L[i][1] < M :
        M -= L[i][1]
        ans += L[i][0] * L[i][1]
    else :
        ans += L[i][0] * M
        break
print(ans)

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

template <typename T>
class BIT {
 public:
  BIT(int n) : v_(n + 1) {}
  T Sum(int i) const {
    T ret = 0;
    while (i) {
      ret += v_[i];
      i -= i & -i;
    }
    return ret;
  }
  T Get(int i) const { return Sum(i) - Sum(i - 1); }
  void Add(int i, T v) {
    while (i < v_.size()) {
      v_[i] += v;
      i += i & -i;
    }
  }

 private:
  std::vector<T> v_;
};

struct Q {
  int l, r, i, v;
};

int main() {
  in(int, n, q);
  V<int> c(n);
  rep(i, n) cin >> c[i];
  V<Q> qs;
  rep(i, q) {
    in(int, l, r);
    qs.push_back({l, r, i, 0});
  }
  sort(all(qs), [](const Q& a, const Q& b) { return a.r < b.r; });
  map<int, int> seen;
  BIT<int> bit(n);
  auto qit = qs.begin();
  rep(i, n) {
    auto it = seen.find(c[i]);
    if (it != seen.end()) {
      bit.Add(it->second + 1, -1);
    }
    seen[c[i]] = i;
    bit.Add(i + 1, 1);
    while (qit != qs.end() && qit->r == i + 1) {
      qit->v = seen.size() - bit.Sum(qit->l - 1);
      ++qit;
    }
  }
  sort(all(qs), [](const Q& a, const Q& b) { return a.i < b.i; });
  for (auto& qi : qs) {
    out(qi.v);
  }
}

Measured memory_bytes: 38896
#include<iostream>
using namespace std;
int main()
{
	long long int A,B;
	cin>>A>>B;
	if((A==B)||((A+B)%2==1))
	{
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	cout<<(A+B)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

int calc(int x,int y){
	if(y == 0){
		return x;
	}else{
		return calc(y,x%y);
	}
}

int main(){

	int W,H,C,common;
	scanf("%d %d %d",&W,&H,&C);

	if(W >= H)common = calc(W,H);
	else{
		common = calc(H,W);
	}

	printf("%d\n",W*H*C/(common*common));

    return 0;
}

Measured memory_bytes: 2736
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

int main() {
	int n,m;
	cin >> n;
	vector<int> t(n+1);
	for (int i = 1; i <= n; i++)cin >> t[i];
	cin >> m;
	vector<int>p(m+1);
	vector<int>x(m+1);
	for (int i = 1; i <=m; i++) {
		cin >> p[i] >> x[i];
	}
	
	int sum;
	for (int i = 1; i <= m; i++) {
		sum = 0;
		for (int j = 1; j <= n; j++) {
			if (p[i] == j) {
				sum += x[i];
			}else{
				sum += t[j];
			}
		}
		cout << sum << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<vector>
#include<cstring>
#include<stack>
#include<cstdlib>
#include<cmath>
using namespace std;

int main()
{
	int n, t;
	int cnt = 0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t;
		if (t % 2 == 0)
			cnt++;
	}
	if (cnt == n)
		cout << "second" << endl;
	else
		cout << "first" << endl;
}

Measured memory_bytes: 256
import std;

auto input()
{
    return readln().chomp();
}

void main()
{
    long x, y;
    scan(x, y);
    if (x % y == 0)
    {
        writeln(-1);
    }
    else
    {
        writeln(x);
    }

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}


Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder st = new StringBuilder();
        
        String[] ary = new String[2];
        int[] num = new int[2];
        
        while(true){
            ary = br.readLine().split(" ");
            //ary = inputStr.split(" ");
            num[0] = Integer.parseInt(ary[0]);
            num[1] = Integer.parseInt(ary[1]);
            
            if(num[0] == 0 && num[1] == 0){
                break;
            }
            
            if(num[0] > num[1]){
                System.out.println(num[1] + " " + num[0]);
            }else{
                System.out.println(num[0] + " " + num[1]);
            }
        }
        
    }
}

Measured memory_bytes: 27356
A, B, C = map(int, input().split())

a = abs(B-A) + abs(C-B)
b = abs(C-A) + abs(B-C)
c = abs(A-B) + abs(C-A)
d = abs(C-B) + abs(A-C)
e = abs(A-C) + abs(B-A)
f = abs(C-B) + abs(A-C)

print(min(a,b,c,d,e,f))

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

public class Main {

    public static void main(String[] argv) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String s = in.readLine();
            if (s == null) {
                break;
            }
            System.out.println(f(s));
        }
    }

    public static String f(String s){
        int a = Integer.parseInt(s);
        int sum = 0;
        for (int i = a; i < 600; i+=a) {
            int y = (int)Math.pow(i, 2);
            sum += a * y;
        }
        return String.valueOf(sum);
    }
}

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

int main()
{
	int x[2020];
	for (int i = 0; i < 2020; i++) {
		x[i] = 2020;
	}
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int xx;
		cin >> xx;
		x[i] = xx;
	}
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		int yy;
		cin >> yy;
		if (x[yy + 1] != x[yy] + 1) {
			x[yy]++;
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << x[i] << endl;
	}
}


Measured memory_bytes: 3124
//Author: AnandRaj anand873
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 
 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test(t) int t;cin>>t;while(t--)
#define forn(i,f,n) for(int i=f;i<f+n;i++)
#define rforn(i,l,n) for(int i=l;i>l-n;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i]
 
const int MOD = 1e9+7,MAX = 1e5+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p,ll mod)
{
	if(p==0) return 1;
	ll z=powN(a,p/2,mod);
	z=(z*z)%mod;
	if(p%2) z=(z*a)%mod;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
//////////////////Sieve////////////////////

int main()
{		
	string s,t;
	cin>>s>>t;
	cout<<t<<s<<endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
i = -2
for j in range(n):
    if a[j]-1 == i+1:
        ans += c[i]
    i = a[j] - 1
    ans += b[i]
print(ans)


Measured memory_bytes: 9124
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, X, Y;
    scan(N, X, Y);
    X--, Y--;
    auto ans = new long[](N);
    foreach (i; 0 .. N)
    {
        foreach (j; i + 1 .. N)
        {
            long a = j - i;
            long b = abs(i - X) + abs(j - Y) + 1;
            long c = abs(j - X) + abs(i - Y) + 1;
            ans[min(a, b, c)]++;
        }
    }
    foreach (i; 1 .. N)
        writeln(ans[i]);
}


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

template <typename TYPE>
void print_vec(const vector<TYPE>& v, int num=0){
  if(num == 0) num = (int)v.size();
	for(int i=0; i<num; i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

template<typename T>
struct BIT{
  int n;
  vector<T> d;
  BIT(int n=0): n(n), d(n+1){}

  void add(int i, T x=1){
    for(i++; i<=n; i+=i&(-i)){
      d[i] += x;
    }
  }
  
  T sum(int i){
    T x = 0;
    for(i++; i; i-=i&(-i)){
      x += d[i];
    } 
    return x;
  }
};

int main(){

  int INF = 100000;
  vector<int> num_divisor(INF+1, 0);
  for(int i=2; i<=INF; i++){
    if(num_divisor[i] > 1) continue;//これ入れるとエラトステネスの計算量O(Nlog(logN))になるかね
    for(int j=i; j<=INF; j+=i){
      num_divisor[j]++;
    }
  }

  //BITでも累積和でも解ける てか累積和のほうが知識レベル的に簡単だね
  BIT<int> bi(INF+1);
  // vector<int> wa(INF+1, 0);//累積和
  for(int i=2; i<=INF; i++){
    if(num_divisor[i] == 1){
      if(num_divisor[(i+1)/2] == 1) bi.add(i);
    }
    // bool like_2017 = false;
    // if(num_divisor[i] == 1){
    //   if(num_divisor[(i+1)/2] == 1) like_2017 = true;
    // }
    // wa[i] = wa[i-1] + like_2017;
  }
  int Q;
  cin >> Q;
  for(int i=0; i<Q; i++){
    int l, r;
    cin >> l >> r;
    cout << bi.sum(r) - bi.sum(l-1) << endl;
    // cout << wa[r] - wa[l-1] << endl;
  }

	return 0;
}



Measured memory_bytes: 3872
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

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

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

const size_t N = 5e3 + 5;
const int MOD = 1e9 + 7;

struct Z {
    uint v;

    Z(uint v = 0) : v(v) {}

    Z& operator += (const Z &z) {
        v += z.v;
        if (v >= MOD) v -= MOD;
        return *this;
    }

    Z& operator -= (const Z &z) {
        if (v < z.v) v += MOD;
        v -= z.v;
        return *this;
    }

    Z& operator *= (const Z &z) {
        v = static_cast<uint64_t>(v) * z.v % MOD;
        return *this;
    }
};

ostream& operator << (ostream &os, const Z &z) {
    return os << z.v;
}

Z operator + (const Z &x, const Z &y) {
    return Z(x.v + y.v >= MOD ? x.v + y.v - MOD : x.v + y.v);
}

Z operator - (const Z &x, const Z &y) {
    return Z(x.v < y.v ? x.v + MOD - y.v : x.v - y.v);
}

Z operator * (const Z &x, const Z &y) {
    return Z(static_cast<uint64_t>(x.v) * y.v % MOD);
}

Z qpow(Z base, uint e) {
    Z ret(1);
    for (; e; e >>= 1) {
        if (e & 1) {
            ret *= base;
        }
        base *= base;
    }
    return ret;
}

vector<int> g[N];
int siz[N];
Z mul[N], f[N][N];

void combine(int u, int v) {
    static Z g[N];
    memset(g, 0, sizeof g);
    for (int i = 1; i <= siz[u]; ++i) {
        for (int j = 1; j <= siz[v]; ++j) {
            g[i + j] += f[u][i] * f[v][j];
        }
    }
    for (int i = 1; i <= siz[u]; ++i) {
        for (int j = 2; j <= siz[v]; j += 2) {
            g[i] -= f[u][i] * f[v][j] * mul[j];
        }
    }
    siz[u] += siz[v];
    copy(g, g + siz[u] + 1, f[u]);
}

void dfs(int u = 1, int p = 0) {
    f[u][1] = siz[u] = 1;
    for (int v : g[u]) {
        if (v != p) {
            dfs(v, u);
            combine(u, v);
        }
    }
}

int main() {
    int n = read();
    for (int i = 1; i < n; ++i) {
        int u = read(), v = read();
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }
    mul[2] = 1;
    for (int i = 4; i <= n; i += 2) {
        mul[i] = mul[i - 2] * (i - 1);
    }
    dfs();
    Z ans = 0;
    for (int i = 2; i <= n; i += 2) {
        ans += f[1][i] * mul[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 98944
#include<iostream>
using namespace std;
int main(){
	int r, g, d;
	cin >> r >> g >> d;
	if ((g * 10 + d) % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;

}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    for(int i = 0;i < num;i++){
      String line = sc.next();
      if(line.equals("AC")){
        ac++;
      }
      else if(line.equals("WA")){
        wa++;
      }
      else if(line.equals("TLE")){
        tle++;
      }
      else{
        re++;
      }
    }
    System.out.println("AC x " + ac + "\nWA x " + wa + "\nTLE x " + tle + "\nRE x " + re);
  }
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int number = 0;
    for(int i = a; i <= b; i++) {
        if(c % i == 0) number++;
    }

    cout << number << endl;

    return 0;
}


Measured memory_bytes: 3096
n = int(input())
a = list(map(int, input().split()))

while True:
    min_num = min(a)
    min_ind = a.index(min_num) 
    a = [n % min_num for n in (a[:min_ind] + a[min_ind+1:]) if n % min_num != 0]
    if a == []:
        print(min_num)
        exit()
    a.append(min_num)

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

int main(){
  string s;
  cin>>s;
  int K;
  cin>>K;
  map<char,int> X;
  for(int i=0;i<s.size();++i){
    ++X[s.at(i)];
  }

  set<string> Y;
  for(auto p:X){
    int index=0;
    int count=0;
    while(count<p.second){

    while(s.at(index)!=p.first){
      ++index;
    }

    string t;
    for(int i=index;i<min(index+5,int(s.size()));++i){
      t += s.at(i);
      Y.insert(t);
    }
    ++index;
    ++count;
  }

  if(Y.size()>=K){
    break;
  }

  }

  int count=0;
  for(auto p:Y){
  if(count==K-1){
  cout<<p<<endl;
  break;
  }
  Y.erase(p);
  ++count;
  }

}

Measured memory_bytes: 256
const Main = (input) => {
  const tmp = input.split(' ')
  const sheeps = parseInt(tmp[0])
  const wolves = parseInt(tmp[1])
  let result
  if (sheeps > wolves) {
    result = 'safe'
  } else {
    result = 'unsafe'
  }

  console.log(result)
  return result
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


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

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

int n;
vi es[100000];
int dp[100000][2];
bool vis[100000];

void dfs(int v, int p){
  if(vis[v]) return;
  vis[v] = true;

  dp[v][0] = dp[v][1] = 1;
  for(int to : es[v]) if(to != p){
    dfs(to, v);
    (dp[v][0] *= dp[to][0]+dp[to][1]) %= mod;
    (dp[v][1] *= dp[to][0]) %= mod;
  }
}

signed main(){
  cin >> n;

  rep(i, 0, n-1){
    int x, y;
    cin >> x >> y;
    x--; y--;
    es[x].emplace_back(y);
    es[y].emplace_back(x);
  }

  dfs(0, -1);
  cout << (dp[0][0] + dp[0][1])%mod << endl;

  return 0;
}



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

int main() {
  char a, b;
  cin >> a >> b;

  if (a == 'H') {
    cout << b << endl;
  } else {
    if (b == 'H') {
      cout << 'D' << endl;
    } else {
      cout << 'H' << endl;
    }
  }

  return 0;
}


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

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

const ll INF = 1LL<<60;

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

    int n = s.size();

    int ans = 0;
    rep(i, n / 2) {
        if(s[i] != s[n - i - 1]) ans++;
    }

    cout << ans << endl;

    return 0;
}



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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a+b) % 2) {
    cout << (a + b) / 2 + 1 << endl;
  } else {
    cout << (a + b) / 2 << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;

#define ll long long
int main(){

string s;
cin>>s;

int start=-1, end=-1;
bool flag=false;
for(int i=1;i<s.length();i++){
    
    if(flag)
    break;
    
    if(s[i-1]==s[i]){
        start=i-1+1;
        end=i+1;
        flag=true;
    }
    if(i-2 >=0 && s[i-2]==s[i]){
         start=i-2+1;
        end=i+1;
        flag=true;
    }
    
}

cout<<start<<" "<<end;
  
}

Measured memory_bytes: 3312
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int dp[1110][10]={};

signed main(){
	int n,s;
	while(1){
		cin>>n>>s;
		if(n+s==0) break;
		rep(j,0,s+1) rep(k,0,n+1) dp[j][k]=0;
		dp[0][0]=1;
		dp[0][1]=1;

		rep(i,1,101){
			repb(j,s,0){
				rep(k,0,10){
					//dp[i][j][k]+=dp[i-1][j][k];
					if(j+i<=1000 && k+1<=n){
						dp[j+i][k+1]+=dp[j][k];
					}
				}
			}
		}
		o(dp[s][n]);
	}
}

Measured memory_bytes: 1232
import java.util.Scanner;

public class Main {

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

		int A = sc.nextInt();
		int B = sc.nextInt();
		int sum = A + B;
		int ans = 0;

		if ( sum < 24) {
			ans = sum;
		} else {
			ans = sum - 24;
		}
		System.out.println( ans );
	}
}

Measured memory_bytes: 21844
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] chars={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
        String str=sc.next();
        for(int i=0;i<26;i++){
            if((str.length()-str.replaceAll(chars[i],"").length())%2==1){
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");

    }
    
 
}

Measured memory_bytes: 22740
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include<iomanip>

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int rem = a % b;
	ff(i, 0, b) {
		if ((rem * i) % b == c) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int sum_digits = 0;
  for (int i = 1; ; i *= 10) {
    if (N / i == 0)
      break;
    sum_digits += (N / i % 10);
  }
  if (N % sum_digits == 0)
    cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
void go();
int main() {
#ifdef tokitsukaze
    freopen("TEST.txt", "r", stdin);
#endif
    go();
    return 0;
}

/*********************************  head  *********************************/
struct node{
    int x,y,step;
    node(int xx,int yy,int st):x(xx),y(yy),step(st){}
};
queue<node> que;
int n,m;
int vis[22][22];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
string strs[40];
int ans;
int check(int x,int y){
    return (x>=0&&x<n&&y>=0&&y<m)&&(!vis[x][y])&&(strs[x][y]=='.');
}
void bfs(int i,int j){
    memset(vis,0,sizeof(vis));
    node st=node(i,j,0);
    vis[i][j]=1;
    que.push(st);
    while(!que.empty()){
        st=que.front();
        que.pop();
        ans=max(ans,st.step);
        for(int i=0;i<4;++i){
            int tx=st.x+dx[i];
            int ty=st.y+dy[i];
            if(check(tx,ty)){
                que.push(node(tx,ty,st.step+1));
                vis[tx][ty]=1;
            }
        }
    }
}
void go() {
    ios::sync_with_stdio(0);
    cin>>n>>m;
    for(int i=0;i<n;++i)cin>>strs[i];
    int f=0;
    for(int i=0;i<n;++i){
       for(int j=0;j<m;++j){
           if(strs[i][j]=='.')
               bfs(i,j);
       }
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

int N, dist, limit;

int t[100010];
int x[100010];
int y[100010];

int main()
{
    cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    cin >> N;
    for(int i=1; i<=N; ++i) cin >> t[i] >> x[i] >> y[i];
    
    for(int i=1; i<=N; ++i)
    {
        dist = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
        limit = t[i] - t[i - 1];

        if( dist > t[i] || limit % 2 != dist % 2 )
        {
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";
    return 0;
}

Measured memory_bytes: 1408
#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>

#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>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a, b, c;
  cin >> a >> b >> c;
  cout << (char)(a[0] - 'a' + 'A') << (char)(b[0] - 'a' + 'A') << (char)(c[0] - 'a' + 'A') << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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 dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;




int main(int argc, const char * argv[]) {
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s; cin >> s;
    int k; cin >> k;
    
    map<string,int> submap{};
    priority_queue<string,vector<string>,greater<string>> que{};
    
    for (int i = 0; i < (int)s.size(); i++) {
        for (int j = 1; j <= (int)s.size() - i; j++) {
            if(s.substr(i,j).size() > 5) continue;
            if(  !submap.count(    s.substr(i,j)   )    ) {
                submap.insert(make_pair(s.substr(i,j), 0));
                que.push(s.substr(i,j));
            }
            
            
            
        }
    }
    
    
    
    rep(i,k){
        if(i==k-1) cout << que.top() << endl;
        que.pop();
    }
    
}



Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
using namespace std;

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

	int N, X, temp, Csum = 0, Cb = 1;

	cin >> N >> X;

	REP(i, N)
	{
		cin >> temp;
		Csum += temp;
		if (Csum <= X)
		{
			Cb++;
		}
		else
		{
			break;
		}
	}

	cout << Cb << endl;

	return 0;
}

Measured memory_bytes: 256
//  Created by conan1024hao in 2020.
//  Copyright © 2020 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    vector<string>s(n);
    map<string,int>m;
    int maxm=0;
    for(int i=0;i<n;i++){
        cin>>s[i];
        m[s[i]]++;
        chmax(maxm,m[s[i]]);
    }
    vector<string>ans;
    for(int i=0;i<n;i++){
        if(m[s[i]]==maxm){
            ans.pb(s[i]);
        }
    }
    map<string,int>m2;
    sort(all(ans));
    for(int i=0;i<ans.size();i++){
        if(m2[ans[i]]==0){
            cout<<ans[i]<<endl;
            m2[ans[i]]++;
        }
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------








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

using namespace std;

int main() {
  int A, B, C;

  cin>>A>>B>>C;

  int ans;
  if(C-(A+B)>=2) {
    ans = B + C - (C-(A+B)-1);
  } else {
    ans = B + C;
  }

  cout<<ans<<endl;

  return 0;
}

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

int main(void)
{
	int n;
	scanf("%d", &n);
	long long i, m = 1, l = pow(10, 9) + 7;
	for(i = 1; i <= n; i++) {
		m = (m * i) % l;
	}
	printf("%lld", m);
	return 0;
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

bool dp_x[8001][2 * 8000 + 1], dp_y[8001][2 * 8001 + 1]; //1-indexed

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;

    s += 'T'; // sentinel
    int cnt_F = 0, cnt_T = 0, cnt_X = 0, cnt_Y = 1;
    dp_y[0][8000] = true;
    rep(i, s.size()) {
        if (s[i] == 'F') {
            ++cnt_F;
        } else {
            ++cnt_T;
            if (cnt_T % 2) {
                if (cnt_T == 1) {
                    dp_x[cnt_X][8000 + cnt_F] = true;
                    ++cnt_X;
                } else {
                    for (int j = -8000; j < 8000; ++j) {
                        if (! dp_x[cnt_X - 1][j + 8000]) continue;
                        if ((j - cnt_F + 8000) >= 0) {
                            dp_x[cnt_X][j - cnt_F + 8000] |= dp_x[cnt_X - 1][j + 8000];
                        }
                        if (j + cnt_F + 8000 <= 16001) {
                            dp_x[cnt_X][j + cnt_F + 8000] |= dp_x[cnt_X - 1][j + 8000];
                        }
                    }

                    ++cnt_X;
                }
            } else {
                for (int j = -8000; j < 8000; ++j) {
                    if (! dp_y[cnt_Y - 1][j + 8000]) continue;
                    if (j - cnt_F + 8000 >= 0) {
                        dp_y[cnt_Y][j - cnt_F + 8000] |= dp_y[cnt_Y - 1][j + 8000];
                    }
                    if (j + cnt_F <= 16000) {
                        dp_y[cnt_Y][j + cnt_F + 8000] |= dp_y[cnt_Y - 1][j +  8000];
                    }
                }

                ++cnt_Y;
            }

            cnt_F = 0;
        }
    }

    if (dp_x[cnt_X - 1][8000 + x] && dp_y[cnt_Y - 1][8000 + y]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 125696
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int A, B, C, X;
  while (cin >> A >> B >> C >> X) {
    int res = 0;
    for (int a = 0; a <= A; a++) {
      for (int b = 0; b <= B; b++) {
        for (int c = 0; c <= C; c++) {
          if (500 * a + 100 * b + 50 * c == X) {
            ++res;
          }
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}


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

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

    bool hasOdd = false;
    rep(i, n) {
        int a;
        cin >> a;
        if (a % 2 == 1) hasOdd = true;
    }

    ll ans = hasOdd ? pow(2, n - 1) : p == 1 ? 0 : pow(2, n);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256