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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int H,W,A,B;

string ans[1111];

signed main(){
    cin>>H>>W>>A>>B;
    rep(i,H)ans[i]=string(W,'.');

    if(2*(A+B)>H*W){
        cout<<"NO"<<endl;
        return 0;
    }

    if(H%2){
        for(int i=0;i+1<W;i+=2){
            ans[H-1][i]='<';
            ans[H-1][i+1]='>';
        }
    }

    if(W%2){
        for(int i=0;i+1<H;i+=2){
            ans[i][W-1]='^';
            ans[i+1][W-1]='v';
        }
    }

    if(H>=3&&W>=3&&H%2&&W%2&&W*(H-1)/2%2!=B%2&&2*(A+B)==H*W-1){
        ans[H-3][W-3]='<';ans[H-3][W-2]='>';ans[H-3][W-1]='^';
        ans[H-2][W-3]='^';ans[H-2][W-2]='.';ans[H-2][W-1]='v';
        ans[H-1][W-3]='v';ans[H-1][W-2]='<';ans[H-1][W-1]='>';
    }

    int cntA=0,cntB=0;
    rep(i,H)rep(j,W){
        cntA+=ans[i][j]=='<';
        cntB+=ans[i][j]=='^';
    }


    for(int i=0;i+1<H;i+=2){
        for(int j=0;j+1<W;j+=2){
            if(ans[i][j]!='.')continue;
            if(A>cntA){
                cntA+=2;
                ans[i][j]='<';ans[i][j+1]='>';
                ans[i+1][j]='<';ans[i+1][j+1]='>';
            }
            else{
                cntB+=2;
                ans[i][j]='^';ans[i][j+1]='^';
                ans[i+1][j]='v';ans[i+1][j+1]='v';
            }
        }
    }

    if(A>cntA||B>cntB){
        cout<<"NO"<<endl;
        return 0;
    }

    rep(i,H)rep(j,W){
        if(ans[i][j]=='<'){
            if(A==cntA)continue;
            ans[i][j]='.';ans[i][j+1]='.';cntA--;
        }
        else if(ans[i][j]=='^'){
            if(B==cntB)continue;
            ans[i][j]='.';ans[i+1][j]='.';cntB--;
        }
    }

    cout<<"YES"<<endl;
    rep(i,H)cout<<ans[i]<<endl;
    return 0;
}


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

long long GCD( long long a, long long b )
{
	while( true )
	{
		if( a % b == 0 ) return b;

		a %= b;
		if( b % a == 0 ) return a;

		b %= a;
	}

	return 0;
}

int main()
{
long long i;
long long iGCD;
long long N;
long long M;
long long n;
long long m;
string S;
string T;
	
	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> M;
	cin >> S;
	cin >> T;

	iGCD = GCD( N, M );

	n = N / iGCD;
	m = M / iGCD;

	for( i = 0; i < iGCD; i++ )
	{
		if( S[ i * n ] != T[ i * m ] )
		{
			cout << - 1 << endl;

			return 0;
		}
	}

	cout << n * M << endl;

	return 0;
}


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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

typedef pair<int, int> pint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000 * 1000 * 1000 + 7)

bool ok(vector<int> &A, vector<int> &F, int N, int K, int limit) {
    bool is_ok = true;

    REP(i, N) {
        int need_cost;
        if (limit == 0) {
            need_cost = 0;
        } else {
            need_cost = limit / F[i];
        }

        int loss = max(0LL, A[i] - need_cost);
        K -= loss;

        if (K < 0) {
            is_ok = false;
            break;
        }
    }

    return is_ok;
}

signed main() {
    int N, K;
    cin >> N >> K;

    vector<int> A(N);
    vector<int> F(N);

    REP(i, N) {
        cin >> A[i];
    }

    REP(i, N) {
        cin >> F[i];
    }

    sort(ALL(A));
    sort(ALL(F), greater<int>());

    // int ans = 0;
    // REP(i, N) {
    //     cout << A[i] << ", " << F[i] << endl;;
    //     if (K > 0) {
    //         int loss = min(A[i], K);
    //         A[i] -= loss;
    //         K -= loss;
    //     }

    //     cout << "+ " << A[i] << ", " << F[i] << endl;;
    //     ans += A[i] * F[i];
    // }

    // cout << ans << endl;

    int left = 0;
    int right = 10000000000000LL;

    int ans = 0;
    while (left <= right) {
        int mid = (left + right) / 2;
        // cout << mid << ":" << left << "-" << right << endl;

        bool is_ok = ok(A, F, N, K, mid);
        if (is_ok) {
            right = mid - 1;
            ans = mid;
        } else {
            left = mid + 1;
        }
    }

    cout << ans << endl;

    return 0;
}

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

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

  vector<int> L(N*2);
  for (int i = 0; i < N*2; i++) cin >> L.at(i);
  sort(L.begin(), L.end());

  int ans = 0;
  for (int i = 0; i < 2 * N - 1; i += 2) {
    ans += min(L.at(i), L.at(i + 1));
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;
#define inf 0x3f3f3f3f
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mp make_pair
#define pb push_back
#define sz(v) (int)v.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
const int N=1e5+7;
ll n,m,x,y,k,ans;

int main(){
    fast;
    char s[N];
    cin>>s>>k;
    n=strlen(s);
    //cout<<(int)'l'<<endl;
    forn(i,n){
        if('z'-s[i]+1<=k&&s[i]!='a'){
            k-='z'-s[i]+1;
            s[i]='a';
            //cout<<k<<endl;
        }
    }
    while(k--){
        s[n-1]++;
        if(s[n-1]>'z') s[n-1]='a';
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
 
        String line1 = scanner.next();
        String line3 = scanner.next();

        int a = Integer.parseInt(line1);
        int b = Integer.parseInt(line3);
        int c,num;
        if(a == b){
            c = a;
        }else if(a >= b){
            c = a % b;
        }else{
            c = b % a;
            b = a;
        }
        for(int i = c;i >= 1;i--){
            if(b % i == 0 && c % i == 0){
                System.out.println(i);
                break;
            }
        }

    }
}


Measured memory_bytes: 26248
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;
const double PI=3.141592;
int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  int A,B;
  cin >> A >> B;
  cout << A * B << endl;
  return 0;

}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

void dfs(int u, int p, vector<vector<int>> &graph, vector<int> &depth){
	for(int v: graph[u]){
		if(v == p) continue;
		depth[v] = depth[u]+1;
		dfs(v, u, graph, depth);
	}
}

int main(){
	int N;
	cin >> N;
	vector<vector<int>> graph(N);
	for(int i=0; i<N-1; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	vector<int> depth(N);
	depth[0] = 1;
	dfs(0, -1, graph, depth);

	int mx = depth[0], u = 0;
	for(int i=0; i<N; i++){
		if(depth[i]>mx){
			mx = depth[i];
			u = i;
		}
	}

	depth.assign(N, 0);
	depth[u] = 1;
	dfs(u, -1, graph, depth);

	mx = depth[0];
	for(int i=0; i<N; i++) mx = max(depth[i], mx);
	debug(mx);

	if(mx%3 == 2) {
		cout << "Second" << endl;
	} else {
		cout << "First" << endl;
	}

	return 0;
}


Measured memory_bytes: 27648
n = int(input())
bn = list(map(int,input().split()))
ans = []

while bn:
    for i in range(len(bn))[::-1]:
        if i+1 == bn[i]:
            ans.append(bn[i])
            bn.pop(i)
            break
    else:
        break
if bn:
    print(-1)
else:
    [print(i) for i in ans[::-1]]


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

string s;

void rec(int i) {
    if (s[i] == 'm') {
        if (i+1 < s.size() && s[i+1] == 'm') rec(i+1);
        if (s[i+1] != 'e') return;
        if (i+2 < s.size() && s[i+2] == 'm') rec(i+2);
        if (s[i+2] != 'w') return;
        s.erase(s.begin()+i, s.begin()+i+3);
    }
    
}

int main(void){
    cin >> s;
    rec(0);
    cout << (s=="" ? "Cat" : "Rabbit") << endl;
}

Measured memory_bytes: 3224
N = int(input())
T = [int(a) * 2 for a in input().split()]
V = [int(a) * 2 for a in input().split()]
MA = [0] * (sum(T) + 1)
a = 0
for i in range(N):
    for j in range(T[i]):
        a += 1
        MA[a] = min(MA[a-1] + 1, V[i])
MA[a] = 0
for i in range(N)[::-1]:
    for j in range(T[i]):
        a -= 1
        MA[a] = min(MA[a], MA[a+1] + 1, V[i])

print((sum(MA[1:]) + sum(MA[:-1])) / 8)

Measured memory_bytes: 3700
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin >>a>>b>>c;
    if(a>b){
        swap(a,b);
    }
    if(b>c){
        swap(b,c);
    }
    if(a>b){
        swap(a,b);
    }
cout<<a<<" "<<b<<" "<<c<<endl;
}


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

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

    int cnt = 0;
    rep(i, 3) cnt += (S[i] == 'A' ? 1 : -1);
    cout << (abs(cnt) == 3 ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
using System;
namespace AtCoder
{
  public class Program
  {
    public static void Main(string[] args)
    {
      string s = Console.ReadLine();
      int n = s.Length;
      int cnt = 1;
      string before_s = s.Substring(0,1);
      int range = 1;
      for(int i = 1; i < n; i++)
      {
        string ts = s.Substring(i-range+1,range);
        if(!ts.Equals(before_s))
        {
          before_s = ts;
          cnt++;
          range = 1;
        }
        else
        {
          range++;
        }
      }
      Console.WriteLine(cnt);
    }
  }
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

void cal(vector<int>& pat, string& s)
{
  int N = s.size();
  for (int i = 1; i < N - 1; ++i) {
    if (pat[i] == 0) {
      // sheep
      if (s[i] == 'o') {
        pat[i + 1] = pat[i - 1];
      }
      else {
        pat[i + 1] = 1 - pat[i - 1];
      }
    }
    else {
      // wolf
      if (s[i] == 'o') {
        pat[i + 1] = 1 - pat[i - 1];
      }
      else {
        pat[i + 1] = pat[i - 1];
      }
    }
  }
}

bool is_ok(string& s, vector<int>& pat)
{
  int N = s.size();
  for (int i = 0; i < N; ++i) {
    int prev = (i - 1 + N) % N;
    int next  = (i + 1) % N;
    if (s[i] == 'o') {
      if (pat[i] == 0 and pat[prev] != pat[next]) {
        return false;
      }
      else if (pat[i] == 1 and pat[prev] == pat[next]) {
        return false;
      }
    }
    else if (s[i] == 'x') {
      if (pat[i] == 0 and pat[prev] == pat[next]) {
        return false;
      }
      else if (pat[i] == 1 and pat[prev] != pat[next]) {
        return false;
      }
    }
  }
  return true;
}

int main()
{
  int N; scanf("%d", &N);
  string s; cin >> s;
  bool done = false;
  vector<int> pat(N, -1);
  for (int i = 0; not done and i <= 1; ++i) {
    pat[0] = i;
    for (int j = 0; not done and j <= 1; ++j) {
      pat[1] = j;
      cal(pat, s);
      if (is_ok(s, pat)) {
        done = true;
        break;
      }
    }
  }
  if (not done) {
    printf("-1\n");
    return 0;
  }
  for_each(pat.begin(), pat.end(), [](const int& val) -> void {
      printf("%c", (val == 0) ? 'S' : 'W');
    });
  printf("\n");
  return 0;
}


Measured memory_bytes: 896
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		 int n,i;
	        Scanner scan=new Scanner(System.in);
	        n=scan.nextInt();
	        Set<String>d=new HashSet<String>();
	        for(i=0;n>i;i++)
	        {
	        	String a=scan.next();
		        String b=scan.next();
	            if(a.equals("insert"))
	            {
	            	d.add(b);
	            }
	            else
	            {
	            	System.out.println((d.contains(b)) ? ("yes"):("no"));
	            }
	        }
	}

}

Measured memory_bytes: 268412
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 2;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregion

bool chmax(ll &a, ll b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int n;
  cin >> n;
  ll a[2010];
  rep(i, n) cin >> a[i];
  pll p[2010];
  rep(i, n)
  {
    p[i] = MP(a[i], i);
  }
  sort(p, p + n, greater<pll>());
  ll dp[2010][2010] = {};
  for (ll i = 0; i < n; i++)
  {
    for (ll x = 0; x <= i; x++)
    {
      ll y = i - x;
      auto [t, index] = p[i];
      //左
      chmax(dp[x + 1][y], dp[x][y] + t * abs(x - index));
      //右
      chmax(dp[x][y + 1], dp[x][y] + t * abs(n - 1 - y - index));
    }
  }
  ll Max = 0;
  for (ll x = 0; x <= n; x++)
  {
    chmax(Max, dp[x][n - x]);
  }
  cout << Max << endl;
  return 0;
}


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

using namespace std;
using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;

const int MOD = 1000000007;

int modpow(int x, int n, int mod) {
  int res = 1;
  while (n > 0) {
    if (n & 1) res = 1LL * res * x % mod;
    x = 1LL * x * x % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  map<int, int> primes;
  for (int i = 0; i < N; i++) {
    int x = A[i];
    for (int p = 2; p * p <= x; p++) {
      int cnt = 0;
      while (x % p == 0) {
        x /= p;
        cnt++;
      }
      primes[p] = max(primes[p], cnt);
    }
    if (x > 1) primes[x] = max(primes[x], 1);
  }

  int l = 1;
  for (auto itr : primes) {
    l = 1LL * l * modpow(itr.first, itr.second, MOD) % MOD;
  }
  i64 res = 0;
  for (int i = 0; i < N; i++) {
    res = (res + 1LL * l * modpow(A[i], MOD - 2, MOD) % MOD) % MOD;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 896
n=int(input())
s=input()
rcnt=s.count("R")
# "R"をすべて左に寄せるならば、(0 ～ "R"個数-1)分の配列範囲はすべて"R"となる。
r_expected_arr=s[:rcnt]
# "R"期待範囲に"W"が存在する場合、"R"との交換が要求される。
# その場合、文字列中に"R"個数分の"R"が存在するため、交換対象の"R"は必ず存在する。
w_exchange_needed=r_expected_arr.count("W")
print(w_exchange_needed)


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int a,b;cin>>a>>b;
  string s;cin>>s;
  bool flag=true;
  if(s[a]!='-')flag=false;
  rep(i,0,a+b+1){
    if(i==a)continue;
    //cout<<s[i]-'0'<<endl;
    if(s[i]-'0'<0 || s[i]-'0'>9){
      flag=false;
      break;
    }
  }
  flag2func(flag);
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>
#include <iomanip>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;



int main() {
	for (int h, m, s; cin >> h >> m >> s; ) {
		if (h == -1) break;
		int sec = h * 60 * 60 + m * 60 + s;
		sec = 2 * 60 * 60 - sec;
		printf("%02d:%02d:%02d\n", sec / (60 * 60), sec % (60 * 60) / 60, sec % (60 * 60) % 60);
		sec = h * 60 * 60 + m * 60 + s;
		sec = 2 * 60 * 60 - sec;
		sec *= 3;
		printf("%02d:%02d:%02d\n", sec / (60 * 60), sec % (60 * 60) / 60, sec % (60 * 60) % 60);
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int ans[1000];


int main() {

	int n,m,c = 0;
	int MAX;
	int s[1000];

	while (1) {
		MAX = 0;
		scanf("%d %d", &n, &m);
		if (n == 0 && m == 0) break;

		for (int i = 0; i < n; i++) {
			scanf("%d", &s[i]);
		}
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
					if (MAX < s[i] + s[j] && m >= s[i] + s[j]) {
						MAX = s[i] + s[j];
				}
			}
		}
		if (MAX == 0) MAX = -1;
		ans[c] = MAX;
		c++;
	}

	for (int i = 0; i < 1000; i++) {
		if (ans[i] == 0) break;
		else if (ans[i] == -1) printf("NONE\n");
		else printf("%d\n", ans[i]);
	}

	return 0;
}


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

using namespace std;

int main()
{
    string s , s1 ;
    cin>>s>>s1 ;
    string s2 = s ;
    bool t = true ;
    for(int i = 0 ; ; ++i)
    {
        if(s2 == s && i != 0)
            return cout<<"No"<<endl , 0 ;
        char c = s[s.size()-1];
        string s3 = "";
        s3 += c ;
        for(int j = 0 ; j < s.size()-1 ; ++j)
            s3 += s[j] ;
        s = s3 ;
        if(s == s1)
            return cout<<"Yes"<<endl , 0 ;
    }
    return 0 ;
}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en 


constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

void Main(){
    int n, m;
    cin >> n >> m;
    VVI sv(m);
    REP(i, m) {
        int k;
        cin >> k;
        REP(j, k) {
            int s;
            cin >> s;
            sv[i].push_back(s-1);
        }
    }
    VI pv(m);
    REP(i, m) {
        cin >> pv[i];
    }
    int ans = 0;
    for (int bit = 0; bit < (1<<n); ++bit)
    {
        VI ansv(m, 0);
        REP(i, m) {
            REP(j, sv[i].size()) {
                if (bit & (1<<sv[i][j])) { 
                    ansv[i]++;
                }
            }
        }
        int f = 1;
        REP(i, m) {
            if ((ansv[i] % 2) != pv[i]) {
                f = 0;
                break;
            }
        }
        if (f == 1) {
            ans++;
        }
    }
    cout << ans << endl;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
typedef pair<int, int> P;
vector<int> G[100000];
int deg[100000];
bool vis[100000];
int par[100000];
vector<int> child[100000];
void build(int v, int p) {
	vis[v] = 1;
	par[v] = p;
	if (p != -1) child[p].push_back(v);
	for (int to : G[v]) {
		if (!vis[to]) build(to, v);
	}
}
void solve(int v) {
	for (int to : child[v]) {
		solve(to);
	}
	if (par[v] == -1) return;
	if (deg[v] % 2 == 0) {
		deg[par[v]]++;
		cout << (par[v] + 1) << " " << (v + 1) << endl;
	}
	else {
		deg[v]++;
		cout << (v + 1) << " " << (par[v] + 1) << endl;
	}
}
int main() {
	int N, M;
	cin >> N >> M;
	if (M % 2) {
		cout << -1 << endl;
		return 0;
	}
	vector<P> edge;
	for (int i = 0; i < M; i++) {
		int A, B;
		cin >> A >> B;
		A--; B--;
		G[A].push_back(B);
		G[B].push_back(A);
		edge.emplace_back(A, B);
	}
	build(0, -1);
	for (int i = 0; i < M; i++) {
		int A = edge[i].first, B = edge[i].second;
		if (par[A] != B && par[B] != A) {
			deg[A]++;
			cout << (A + 1) << " " << (B + 1) << endl;
		}
	}
	solve(0);
}

Measured memory_bytes: 18676
#include <stdio.h>

void BubSort(int x[], int n) {
    int i, j, temp;
    for (i = 0; i < n - 1; i++)
        for (j = n - 1; j > i; j--)
            if (x[j - 1] > x[j]) {
                temp = x[j];
                x[j] = x[j - 1];
                x[j - 1]= temp;
            }
}

int main(void) {
    int x[3];
    scanf("%d %d %d", &x[0], &x[1], &x[2]);
    BubSort(x, 3);
    printf("%d\n", x[0]+x[1]);
    return 0;
}

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

int x, y;

int main(){
  ios_base::sync_with_stdio(false);

  cin >> x >> y;
  cout << x+(y/2) << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    long a, b, c, n, cnt = 0;
    cin >> a >> b >> c >> n;
    for(int aa = 0; a*aa <= n; aa++){
        for(int bb = 0; b*bb <= n; bb++){
            if(a*aa + b*bb <= n && (n - (aa*a + b*bb))%c == 0) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int h[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 
            2, 1, 5, 1, 2, 1, 14, 1, 5, 
            1, 5, 2, 2, 1, 15, 2, 2, 5, 
            4, 1, 4, 1, 51};

int main(){
    int n;
    cin >> n;
    cout << h[n-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	int h, m, s, t;
	int vh, vm, vs;

	while(cin >> h >> m >> s)  {
		if(h==-1&&m==-1&&s==-1)
			break;
		vh=0;
		vm=0;
		vs=0;
		t=h*3600+m*60+s;
		t=7200-t;
		while(t>=3600) {
			vh+=1;
			t-=3600;
		}
		while(t>=60) {
			vm+=1;
			t-=60;
		}
		while(t>0) {
			vs+=1;
			t-=1;
		}
		cout << "0" << vh << ":";
		if(vm<10)
			cout << "0" << vm << ":";
		else
			cout << vm << ":";
		if(vs<10)
			cout << "0" << vs << endl;
		else
			cout << vs << endl;

		vh=0;
		vm=0;
		vs=0;
		t=h*3600+m*60+s;
		t=7200-t;
		while(t>=3600) {
			vh+=1;
			t-=3600;
		}
		while(t>=60) {
			vm+=1;
			t-=60;
		}
		while(t>0) {
			vs+=1;
			t-=1;
		}
		vs*=3;
		vm*=3;
		vh*=3;
		while(vs>=60) {
			vm+=1;
			vs-=60;
		}
		while(vm>=60) {
			vh+=1;
			vm-=60;
		}
		cout << "0" << vh << ":";
		if(vm<10)
			cout << "0" << vm << ":";
		else
			cout << vm << ":";
		if(vs<10)
			cout << "0" << vs << endl;
		else
			cout << vs << endl;
	}

	return 0;

}

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

int main()
{
	int N;
	cin >> N;
	vector<int> s( N );
	for( int i = 0; i < N; i++ ) {
		cin >> s[i];
	}

	sort( s.begin(), s.end() );
	int ans = accumulate( s.begin(), s.end(), 0 );
	if( ans % 10 == 0 ) {
		for( int i = 0; i < N; i++ ) {
			if( s[i] % 10 ) {
				ans -= s[i];
				break;
			}
		}
	}
	if( ans % 10 == 0 ) ans = 0;

	cout << ans << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
	int a[11][11] = {0};
	int i, j;
	int n;
	
	while (1){
		scanf ("%d", &n);
		if (n == 0){
			break;
		}
		for (i = 0; i < n; i++){
			for (j = 0; j < n; j++){
				scanf("%d", &a[i][j]);
				a[i][n] += a[i][j];
				a[n][j] += a[i][j];
			}
			a[n][n] += a[i][n];
		}
		for (i = 0; i < n + 1; i++){
			for (j = 0; j < n + 1; j++){
				printf("%5d", a[i][j]);
				a[i][j] = 0;
			}
			printf("\n");
		}
	}
	return (0);
}

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

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    ll a[n+1];
    a[0] = 2;
    a[1] = 1;
    for (int i = 2; i <= n; i++) {
        a[i] = a[i-1] + a[i-2];
    }
    cout << a[n] << endl;
    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
S=input()+"*"

A=[0] if S[0]=="1" else []
cnt,fig=0,S[0]
for i in range(n+1):
    if fig!=S[i]:
        A.append(cnt)
        fig=S[i]
        cnt=1
    else:cnt +=1

if S[-2]=="0":A.append(0)
num=2*(k+1)
B=[[0,0]] if S[0]=="0" else []
for i in range(1,len(A)):
    A[i]=A[i]+A[i-1]
for i in range(0,len(A),2):
    B.append([A[i],A[i+1]])

C=[]
left=0
for i in range(max(0,len(B)-k)):
    C.append(B[k+i][1]-B[left+i][0])
print(max(C) if len(B)-k>0 else B[-1][1])

Measured memory_bytes: 47652
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string n;
	cin >> n;
	if (n == "Sunny") {
		cout << "Cloudy" << endl;

	}
	else if (n == "Cloudy") {
		cout << "Rainy" << endl;
	}
	else {
		cout << "Sunny" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int m,d,i,j,sum=0;
  
  scanf("%d%d", &m,&d);
  
  for(i=2;i<=d/10;i++)
    for(j=2;i*10+j<=d && j<10;j++)
      if(i*j <= m)
        sum++;
  
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 128
n = int(input())
s = []
for i in range(n):
    s.append(sorted(input()))

l = []
for i in range(len(s[0])):
    a = s[0][i]
    f = True
    for j in range(1, len(s)):
        if not (a in s[j]):
            f = False
            break
    if f:
        l.append(a)
        for j in range(1, len(s)):
            s[j].remove(a)
print("".join(l))

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

int main(){
//srandom((unsigned long)time(NULL));
long long x;
cin>>x;
if(x==2){
    cout<<2<<endl;
    return 0;
}
for(long long i=0;1;i++){
    int s=1;
    for(long long d=2;d<=((x+i)/2+1);d++){
        if((x+i)%d==0)s=0;
    }
    if(s==1){
        cout<<x+i<<endl;
        return 0;
    }
}

return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a[5],m=1000,i,j;
    for(i=0;i<5;i++) cin >> a[i];
    for(i=0;i<5;i++){
        int tmp=a[i];
        for(j=0;j<5;j++){
            if(i!=j){
                if(a[j]%10==0) tmp+=a[j];
                else tmp+=(a[j]+10-a[j]%10);
            }
        }
        m = min(m,tmp);
    }
    cout << m;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N;
  cin >> N;
  long long ans = 0;
  for (long long i = 1; i <= N; i++){
    ans += (N / i) * (N / i + 1) / 2 * i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
"""
author : halo2halo
date : 22, Jan, 2020
"""

import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
for i in range(111,1000,111):
    if N<=i:
        print(i)
        break


Measured memory_bytes: 12500
#include<queue>
#include<vector>
#include<iostream>

#define	mp	make_pair
#define	pb	push_back
#define	Y	first	
#define	X	second

using namespace std;

typedef	pair<int,int>	pii;

int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
char field[12][7];

bool vanish(){
	bool vanished=false;

	for(int i=0;i<12;i++)for(int j=0;j<6;j++){
		if(field[i][j]=='.' || field[i][j]=='O' || field[i][j]=='*')	continue;

		bool chk[12][6]={};
		vector<pii> puyo;
		queue<pii> qu;	qu.push(mp(i,j));
		while(!qu.empty()){	// BFS
			pii a=qu.front();	qu.pop();
			if(chk[a.Y][a.X])	continue;
			chk[a.Y][a.X]=true;
			puyo.pb(a);
			for(int k=0;k<4;k++){
				int yy=a.Y+dy[k],xx=a.X+dx[k];
				if(0<=yy && yy<12 && 0<=xx && xx<6
				&& field[yy][xx]==field[i][j] && !chk[yy][xx])
					qu.push(mp(yy,xx));
			}
		}

		if(puyo.size()>=4){
			for(int k=0;k<puyo.size();k++)	field[puyo[k].Y][puyo[k].X]='*';
			vanished=true;
		}
	}

	if(!vanished)	return false;

	for(int i=0;i<12;i++)for(int j=0;j<6;j++){
		if(field[i][j]=='O'){
			bool flg=false;
			for(int k=0;k<4;k++){
				int yy=i+dy[k],xx=j+dx[k];
				if(0<=yy && yy<12 && 0<=xx && xx<6 && field[yy][xx]=='*')
					flg=true;
			}
			if(flg)	field[i][j]='.';
		}
	}
	for(int i=0;i<12;i++)for(int j=0;j<6;j++){
		if(field[i][j]=='*')	field[i][j]='.';
	}

	return true;
}

void fall(){
	char col[12];
	for(int j=0;j<6;j++){
		for(int i=11;i>=0;i--)	col[i]=field[i][j];
		int k=11;
		for(int i=11;i>=0;i--)	if(col[i]!='.')	field[k--][j]=col[i];
		for(;k>=0;k--)	field[k][j]='.';
	}
	return;
}

int main(){
	int n;	cin>>n;
	while(n--){
		for(int i=0;i<12;i++)	cin>>field[i];
		int cnt=0;
		for(;;cnt++){
			if(!vanish())	break;
			fall();
		}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 920
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
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; }
typedef long long ll;
#define pint pair<int,int>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m; cin >> n >> m;
    map<int,int> ma;
    int wrong = 0;
    rep(i,m) {
        int p; cin >> p;
        string s; cin >> s;
        if(s=="WA") {
            if(ma[p]!=-1) ma[p]++;
        }
        else {
            if(ma[p]!=-1) wrong += ma[p];
            ma[p] = -1;

        }
    }

    int corr = 0;
    for(auto val : ma) {
        if(val.second==-1) corr++;
    }
    cout << corr << " " << wrong << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll a, b, x;
    cin >> a >> b >> x;
    cout << b / x - (a + x - 1) / x + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) (1e9)
#define mod (ll) (1e9 + 7)
#define endl "\n"
#define tt ll testcase; cin>>testcase; while(testcase--)
 
int main(){
	fast;
	ll n, W;
	cin >> n >> W;
	ll we[n], v[n];
	for(int i=0; i<n; i++){
		cin >> we[i] >> v[i];
	}
	vector<ll>dp(W+1, 0);
	// for(ll i=1; i<=W; i++){
	// 	for(ll j=0; j<n; j++){
	// 		if(i-we[j] >= 0){
	// 			dp[i] = max(dp[i], dp[i-we[j]] + v[j]);
	// 		}
	// 	}	
	// 		cout<<dp[i]<<" ";
	// }
	for(ll i = 0; i < n; i++){
		for(ll j = W - we[i]; j >= 0; j--){
			dp[j+we[i]] = max(dp[j+we[i]], dp[j] + v[i] );
		}
	}
	cout<<*max_element(dp.begin(), dp.end());
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
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;
	
	cin>>n;
	vector<string> s(n);
	for(auto &_ : s) cin>>_;
	
	vector<int> a(n), b(n), p(n);
	for(int i=0;i<n;++i){
		p[i] = i;
		int c = 0, m = 0;
		for(char ch : s[i]){
			if(ch=='(') ++c;
			else --c;
			m = min(m,c);
		}
		a[i] = c;
		b[i] = -m;
	}
	
	sort(ALL(p), [&](int i, int j){
		if(a[i]>=0){
			if(a[j]<0) return true;
			return b[i]<b[j] || b[i]==b[j]&&a[i]>a[j];
		}else{
			if(a[j]>=0) return false;
			return a[i]+b[i]>a[j]+b[j];
		}
	});
	
	
	int cur = 0;

	for(auto i : p){
		//cout<<cur<<' '<<-t.first<<' '<<t.second<<endl;
		if(cur<b[i]){
			cout<<"No";
			return 0;
		}
		cur+=a[i];
	}
	
	cout<<(cur == 0 ? "Yes" : "No")<<endl;
	
	return 0;
}


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

int main() {
  int N;
  string input;
  cin >> N;
  cin >> input;
  vector<char> res;
  int min = N > input.length() ? input.length() : N;
  for(int i = 0; i < min; i++) {
    res.push_back(input[i]);
  }
  if(input.length() > N) {
    res.push_back('.');
    res.push_back('.');
    res.push_back('.');
  }
  cout << string(res.begin(), res.end());
  return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
    long long h,w;
    cin >> h >> w;
	if(h==1 || w==1){
      cout << 1 << endl;
      return 0;
    }
  
    if(h*w%2==0){
        cout << h*w/2 << endl;
        return 0;
    }else{
        cout << (h*w)/2+1 << endl;
    }
}

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

int main() {
  int n;
  cin >> n;
  int ans;
  ans = n/1.08;
  if((int)((int)ans * 1.08) != n && (int)(((int)ans+1) * 1.08) != n){
    cout << ":(" << endl;
  }
  else{
    if((int)((int)ans * 1.08) == n){
      cout << (int)ans << endl;
    }
    else{
      cout << (int)ans + 1 << endl;
    }
  }
}


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

int main(){
    int n; cin >> n;
    int usagi[n];
    for(int i = 0; i < n; i++){
        cin >> usagi[i];
        usagi[i]--;
    }
    int c = 0;
    for(int i = 0; i < n; i++){
        if(usagi[usagi[i]] == i) c++;
    }
    cout << c/2 << endl;
    return 0;
}

Measured memory_bytes: 640
// C - Green Bin

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

string S[100001];

ll nC2(ll n) {
	return n * (n-1) / 2;
}

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

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

	for (int i=0; i<N; i++) {
		sort(S[i].begin(), S[i].end());
	}

	sort(S, S+N);

	// **** debug ****
	/*
	for (int i=0; i<N; i++) {
		cout << "  " << S[i] << endl;
	}
	*/

	ll ans = 0;
	int left = 0;
	S[N] = "END"; // 終端
	for (int i=1; i<=N; i++) {
		if (S[i] != S[i-1]) {
			ans += nC2(i - left);
			left = i;
		}

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define all(v) v.begin() , v.end()
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
const ll INF=99999999999999;
const ll MOD=1000000007;
const ll MAX_N=100010;
ll a,b,c,d,e,f,x,y,z,k,m,n,l,q,h,w,t,ans=0;
vl v,v1,v2;
vp p;
string s;
priority_queue<ll> q1;
priority_queue<ll,vector<ll>,greater<ll>> q2;
ll solve(){
   a=0;
   ans++;
   rep(i,n){
       a+=v[i];
       if(a>x){
           return ans;
       }
       ans++;
   }

   return ans;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>x;
    rep(i,n){
        cin>>a;
        v.push_back(a);
    }
    cout<<solve()<<endl;
}

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

int main(){ 
  Int N, K, now;
  cin >> N >> K;
  
  now = K;
  
  rep(i,30) {
    if (N < now) {
      cout << i + 1 << endl;
      break;
    }
    now *= K;
  }
}


Measured memory_bytes: 256
a = gets.split(" ").map{|k|k.to_i}

if a[0] >= a[1]
    x = a[0]
    y = a[1]
else
    x = a[1]
    y = a[0]
end
left = Float::INFINITY
loop do
    left = x % y
    break if left == 0
    x = y
    y = left
end

puts y


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

string divide[4]={"dream","dreamer","erase","eraser"};

int main(){
	string S;
  	cin >> S;
  
  //後ろから説く代わりにすべての文字列を左右反転する
  
  reverse(S.begin(),S.end());
  for(int i = 0; i<4;i++)reverse(divide[i].begin(),divide[i].end());
  
  //端から切っていく
  bool can = true;
  for(int i = 0; i < S.size();){
  	bool can2 = false;//4文字の文字列たちどれかでdivideできるか
    for(int j = 0; j < 4; ++j){
    string d = divide[j];
      if(S.substr(i,d.size()) == d ){
      	can2 = true;
        i += d.size();//divide出来たらiを進める。
      }
    }
    if(!can2){//divideできなかったら
    	can = false;
      	break;
    }
  }
  if(can)cout << "YES"<<endl;
  else cout <<"NO"<<endl;
      

}

Measured memory_bytes: 512
// 失敗するからこそ そこから立ち向かって行く強さがあって そんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/pavan/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
	FIO
	
	int n;cin >> n;
	cout << ceil(n / 2.0);
	return 0;
}


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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 4000000000;
constexpr auto MOD = 1000000007;

int n753[27000];
int it = 0;


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

	for (int i = 3;i <= 9;i++) {
		rep(j, pow(3, i)) {
			int k = 0, hoge = j;
			bool d3 = false, d5 = false, d7 = false;
			rep(keta, i) {
				if (hoge % 3 == 0) { d3 = true;k += 3 * pow(10, keta); }
				if (hoge % 3 == 1) { d5 = true;k += 5 * pow(10, keta); }
				if (hoge % 3 == 2) { d7 = true;k += 7 * pow(10, keta); }
				hoge /= 3;
			}

			if (d3 && d5 && d7) {
				n753[it] = k; it++;
			}
		}
	}

	int ans=0;

	rep(i, 26484) {
		if (n753[i] <= n)ans =i+1;
		else break;
	}

	cout << ans << endl;

}

Measured memory_bytes: 384
package main

import (
  "fmt"
)

func main() {
  var w string 
  fmt.Scan(&w)
  res := make(map[rune]int)
  for _, c := range w {
    res[c]++
  }
  ans := "Yes"
  for _, c := range res {
    if c & 1 == 1 {
      ans = "No"
      break
    }
  }
  fmt.Println(ans)
}

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

#define F first
#define S second
#define mp make_pair
#define pb push_back
typedef long long int ll;
const ll N = 1e6+6,inf = 1e9+7;

ll n,k,Arr[N];
int checkBit(ll pat, ll arr[], int n)
{
    int cnt = 0;
    for (int i = 0; i < n; i++)
        if ((pat & arr[i]) == pat)
            cnt++;
    return cnt;
}
ll maxAND(ll arr[], int n)
{
    ll res = 0, cnt;
    for (ll bit = 50; bit >= 0; bit--) {
        cnt = checkBit(res | (1LL << bit), arr, n);
        if (cnt >= k)
            res |= (1LL << bit);
    }
    return res;
}

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


    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>Arr[i];
    int id = 0;
    int lim = n*(n+1)/2 + 2;
    ll arr[lim+2];
    for(int i=0;i<n;i++)
    {
        ll sum = 0;
        for(int j=i;j<n;j++)
        {
            sum += Arr[j];
            arr[id++] = sum;
        }
    }
    cout<<maxAND(arr,id)<< "\n";






    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int MOD = 1000000007;
const int N = 100005;

int res, n, i, tab[N], d[N], act, act2, act3, dd, sum, s[N];

int inverse(int a, int n = MOD - 2) {
    int r = 1;
    while (n) {
        if (n % 2) r = (r * 1LL * a) % MOD;
        a = (a * 1LL * a) % MOD;
        n >>= 1;
    }
    return r;
}

int main() {
scanf("%d", &n);
for (i=0;i<n;i++) scanf("%d", &tab[i]);
for (i=1;i<n;i++) d[i] = tab[i] - tab[i - 1];
sum = 0;
for (i=1;i<n-1;i++) sum = (sum + d[i]) % MOD;
s[1] = s[n - 2] = sum;
for (i=2;i<=n - 1 - i;i++) {
	sum = (sum - d[i - 1] + MOD) % MOD;
	sum = (sum - d[n - i] + MOD) % MOD;
	s[i] = s[n - 1 - i] = (s[i - 1] + sum) % MOD;
}
act = 1;
for (i=1;i<n;i++) act = (act * 1LL * i) % MOD;
res = 0;
for (i=1;i<=n-2;i++) {
	act = (act * 1LL * inverse(i + 1)) % MOD;
	if (i > 2) act = (act * 1LL * (i - 1)) % MOD;
	res = (act * 1LL * s[i] + res) % MOD; 
	//printf("%d\n", res);
}

act = 1;
for (i=1;i<n;i++) act = (act * 1LL * i) % MOD;
dd = d[n - 1];
for (i=n-1;i>=1;i--) {
	res = (act * 1LL * dd + res) % MOD;
	if (i > 1) {
		act = (act * 1LL * inverse(n + 1 - i)) % MOD;
		act = (act * 1LL * (n - i)) % MOD;
		dd += d[i - 1];
	}
}

printf("%d\n", res);
return 0;
}





Measured memory_bytes: 1408
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD
 
int dp[11][353][1252];
 
int dfs(int cnt, int msk, int cur){
  if(cnt>10 || cur>330) return 0;
  if(cnt == 0) return (cur==0?1:0);
  if(dp[cnt][cur][msk] != -1) return dp[cnt][cur][msk];
  dp[cnt][cur][msk] = 0;
  REP(i,10){
    if(msk&(1<<i))continue;
    int nmsk = msk | (1<<i);
    int ncur = cur - i;
    if(ncur >= 0){
      dp[cnt][cur][msk] += dfs(cnt-1,nmsk,ncur);
    }
  }
  dp[cnt][cur][msk] /= cnt;
  return dp[cnt][cur][msk];
}
 
int main(){
  REP(i,11)REP(j,353)REP(k,1252)dp[i][j][k] = -1;
  int n,s;
  while(~scanf("%d%d",&n,&s)){
    if(n==0 && s==0)break;
    cout<<dfs(n,0,s)<<endl;
  }
  return 0;
}

Measured memory_bytes: 20196
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;

char a[N],b[N],A[N],B[N];

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

int main() {

	int n = read(),m = read();
	scanf("%s%s",a + 1,b + 1);

	int val = __gcd(n,m),cnta = 0,cntb = 0;
	For(i,1,n) if(i % (n / val) == 1 % (n / val)) A[++cnta] = a[i];
	For(i,1,m) if(i % (m / val) == 1 % (m / val)) B[++cntb] = b[i];
	For(i,1,cnta) if(A[i] != B[i]) return puts("-1"),0;

	printf("%lld\n",1ll * n * m / val);

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int n,m,v,u,p[1<<17];
vector<int>G[1<<17];
queue<int>q;
int main(){
	cin>>n>>m;
	rep(i,m){
		cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	q.push(1);
	p[1]=1;
	while(!q.empty()){
		u=q.front();q.pop();
		for(int e:G[u]){
			if(!p[e]){
				q.push(e);
				p[e]=u;
			}
		}
	}
	puts("Yes");
	rep(i,n-1)cout<<p[i+2]<<endl;
}


Measured memory_bytes: 11088