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

#define ll long long int
#define Mod 1000000007

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,a,b,c,d; cin>>n>>a>>b>>c>>d;
    string s; cin>>s;
    for(int i=a;i<c-1;i++)
    {
        if(s[i]==s[i-1] && s[i]=='#')
        {
            cout<<"No";
            return 0;
        }
    }
    for(int i=b;i<d-1;i++)
    {
        if(s[i]==s[i-1] && s[i]=='#')
        {
            cout<<"No";
            return 0;
        }
    }
    int mx=1;
    if(c>d)
    {
        for(int i=max(a,b)-1;i<d;i++)
        {
            if(s[i]=='.' && s[i+1]=='.' && s[i-1]=='.')
            {
                mx=0;
            }
        }
        //cout<<mx<<" ";
        if(mx) 
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define pb push_back
#define mp make_pair
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int A,B,C;cin>>A>>B>>C;
    bool ok=false;
    REP(i,B+1){
        if(A*i%B==C)ok=true;
    }
    if(ok)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
using System;
class Program
{
  static void Main(string[] args)
	{
      	// スペース区切りの整数の入力
        string B = Console.ReadLine();
        if (B[0] == B[1] && B[1] == B[2])
        {
            Console.Write("No");
        }
        else
        {
            Console.Write("Yes");
        }
	}
}

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

int main () {
     long  long a, b, c, d, e, f, g;
     while (cin >> a >> b >> c >> d >> e >> f >> g) {
         long  long res = 0 ;
         long  long m = min (a, min (d, e));
         for ( long  long i = max (m- 2 , 0LL ); i <= m; ++ i) {
             long  long tmp = i * 3 ;
             long  long na = a-i, nd = d-i, ne = e-i;
            tmp += na / 2 * 2 ;
            tmp += nd / 2 * 2 ;
            tmp += ne / 2 * 2 ;
            res = max (res, tmp);
        }
        cout << res + b << endl;
    }
}

Measured memory_bytes: 256
W,H,x,y = map(int,input().split())

  
if (x == W/2 or y == H/2 or y == -(H*x/W)+H or y == (H*x)/W):
  if x == W/2 and y == H/2:
    print(W*H/2,1)
  else:
    print(W*H/2,0)
elif (x == 0 or x == W) and (y == 0 or y == H):
  print(W*H/2,0) 
else:
  print(W*H/2,0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const ll INF = 1000000000000000000LL;

int N, M, L;
ll G[305][305];
ll F[305][305];

int main(){
  rep(i,305) rep(j,305){
    G[i][j] = INF;
    F[i][j] = INF;
  }
  
  cin >> N >> M >> L;
  rep(i,M){
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    if(c<=L){
      G[a][b] = c;
      G[b][a] = c;
    }
  }
  rep(k,N) rep(i,N) rep(j,N) G[i][j] = min(G[i][j], G[i][k]+G[k][j]);
  rep(i,N){
    rep(j,N){
      if(G[i][j]<=L) F[i][j] = 1;
    }
  }
  rep(k,N) rep(i,N) rep(j,N) F[i][j] = min(F[i][j], F[i][k]+F[k][j]);

  int Q;
  cin >> Q;
  rep(i,Q){
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    if(F[s][t] == INF) cout << -1 << endl;
    else cout << F[s][t]-1 << endl;
  }

  
  return 0;
}



Measured memory_bytes: 2048
#include<iostream>
#include<vector>
#include<string>

int main(){
    int n;
    std::cin >> n;
    std::string S;
    std::cin >> S;
    if(n % 2 != 0){
        std::cout << "No" << std::endl;
    }else{
        if(S.substr(0, n / 2) == S.substr(n / 2)){
            std::cout << "Yes" << std::endl;
        }else{
            std::cout << "No" << std::endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation
#include <cmath>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 

int main() {
  int N;
  cin >> N;
  vector<int> x(N),y(N),v(N);
  rep(i,N){
	cin >> x.at(i) >> y.at(i);
    v.at(i) = i;
  }
  double dist = 0, x_dist, y_dist;
  int N_kaijo = 0;
  do{
    N_kaijo++;
	rep(i,N-1){
      x_dist = x.at(v.at(i))-x.at(v.at(i+1));
      y_dist = y.at(v.at(i))-y.at(v.at(i+1));
      dist += sqrt(x_dist*x_dist + y_dist*y_dist);
    }
  }while(next_permutation(v.begin(),v.end()));
     
  cout << setprecision(12) << dist/N_kaijo << endl; // 標準出力
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<ll,ll>
#define endl "\n"
#define MAXN 100005
using namespace std;

ll a,b,c,k;

void solve()
{
	cin>>a>>b>>c>>k;
	ll sum=0;
	if(k>a)
	{
		k-=a;sum+=a;
	}
	else
	{
		cout<<k<<endl;return;
	}
	if(k>b)
	{
		k-=b;
	}
	else
	{
		cout<<sum<<endl;return;
	}
	cout<<sum-k<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
}


Measured memory_bytes: 3648
def gcd(n,m):
    if n<m:
        return gcd(m,n)
    if n%m==0:
        return m
    else:
        return gcd(m,n%m)

a,b,c,d=map(int,input().split())
ans=b-a+1
ans-=b//c-(a-1)//c
ans-=b//d-(a-1)//d
e=c*d//(gcd(c,d))
ans+=b//e-(a-1)//e
print(ans)

Measured memory_bytes: 3064
def sub():
    A, B = [int(e) for e in input().split(" ")]
    N = 0
    for _ in range(2):
        if A > B:
            N = N + A
            A = A -1
        else:
            N = N + B
            B = B - 1
    print("{}".format(N))

sub()


Measured memory_bytes: 2940
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();
void solve(long long N);

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

long double len(P a, P b){
    return sqrt(pow(a.fi - b.fi, 2) + pow(a.se - b.se, 2));
}

void Main(){
    ll K, S;
    cin >> K >> S;
    ll cnt = 0;
    REP(X, K+1){
        FOR(Y, K+1, 0){
            ll Z = S - (X + Y);
            if(0 <= Z && Z <= K){
                cnt++;
            }
        }
    }
    cout << cnt << el;
}


Measured memory_bytes: 3648
N, A, B = list(map(int, input().split()))
S = input()
a_cnt = 0
b_cnt = 0
ab_cnt = 0

for c in S:
    if c == 'a':
        if ab_cnt < A+B:
            print('Yes')
            a_cnt += 1
            ab_cnt += 1
        else:
            print('No')
    elif c == 'b':
        if ab_cnt < A+B and b_cnt < B:
            print('Yes')
            b_cnt += 1
            ab_cnt += 1
        else:
            print('No')
    else:
        print('No')


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

using namespace std;

void change(int n, vector<int> &V){
 int i = 0;
  if(n == 0){
    V.push_back(0);
  }
  while(n != 0){
    int x;
    x = n%(-2);
    if(x==-1) x = 1;
    V.push_back(x);
    n = (n-x)/(-2);
   
   i++;
  }
}

int main(){
  int N;
  cin >> N;
  vector<int> ans(0);
  change(N, ans);
  for(int i = ans.size()-1; i >= 0; i--){
    cout << ans[i];
  }
  cout << endl;
}

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

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

  int c = 0;
  bool f = true;
  while (f) {
    for (int i = 0; i < N; i++) {
      if (A[i] % 2 == 0) {
        A[i] = A[i] / 2;
      } else {
        f = false;
        break;
      }
    }
    if (f) c++;
  }
  cout << c << endl;
}

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

using namespace std;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  for (int i = 0; i + 1 < n; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<int> grundy(n);
  function<void(int, int)> dfs = [&](int v, int pv) {
    for (int to : g[v]) {
      if (to == pv) {
        continue;
      }
      dfs(to, v);
      grundy[v] ^= (grundy[to] + 1);
    }
  };
  dfs(0, -1);
  if (grundy[0] > 0) {
    cout << "Alice\n";
  } else {
    cout << "Bob\n";
  }
  return 0;
}

Measured memory_bytes: 15488
// Problem : B - Distance 
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define sz(x)             (int)x.size()
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*(b/gcd(a,b)))
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
#define watch(x)         cout << #x << " = " << x << endl
#define trace(x)         cerr << #x << " = " << x << endl
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){
    
	int n, cnt = 0;
	double d;
	cin>>n>>d;
	while(n--){
		int x, y; cin>>x>>y;
		double dist = sqrt(x*x + y*y);
		if(dist <= d) cnt++;
	}
	cout<<cnt;
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

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

using ll = long long;

const ll mod = 1e9+7;

using vl = vector<ll>;
using mat = vector<ll>;

mat mul(const mat &a, const mat &b)
{
    int n = a.size();
    mat c(n);

    rep(i,n)
    {
        c[i] = 0;
        rep(j,n) c[i] = (a[j]*b[(i-j+n)%n] + c[i]) %mod;
    }
    return c;
}

vl mul_v(const mat &a, const vl &b)
{
    int n = a.size();
    vl ret(n);
    rep(i,n)
    {
        rep(j,n)
        {
            ret[i] += (a[(j+i)%n]*b[j])%mod;
            ret[i] %= mod;
        }
    }

    return ret;
}


mat pow(const mat &a, int n)
{
    int N = a.size();
    mat r(N);
    // ??????
    r[0]=1;

    mat p(a);
    while(n)
    {
        if(n&1) r = mul(r,p);
        p = mul(p,p);
        n>>=1;
    }

    return r;
}

int main()
{
    int n,m,k;
    scanf(" %d %d %d", &n, &m, &k);

    mat A(n);
    A[0] = 1;

    rep(i,m)
    {
        int p;
        scanf(" %d", &p);

        ++A[p%n];
    }

    mat P = pow(A,k);
    vl b(n);
    b[0]=1;

    vl ans = mul_v(P,b);

    rep(i,n) printf("%lld\n", ans[i]);
    return 0;
}

Measured memory_bytes: 3252
#include <vector>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <queue>
#include <climits>
using namespace std;
typedef long long ll;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> b(n);
  for (int i = 0; i < n; ++i) scanf("%d", &b[i]);
  vector<int> ans(n);
  for (int i = 0; i < n; ++i) {
    int ma_idx = -1;
    for (int j = 0; j < (int)b.size(); ++j) {
      if (j + 1 == b[j]) {
	ma_idx = max(ma_idx, j);
      }
    }
    if (ma_idx == -1) {
      puts("-1");
      return 0;
    }
    b.erase(b.begin() + ma_idx);
    ans[i] = ma_idx + 1;
  }

  for (int i = n - 1; i >= 0; --i) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{

	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
    int twoPowMemo = 1;
    bool answer = true;
    for(int i = 0; i < 26; i++)
    {
      if(n == twoPowMemo) answer = false;
      twoPowMemo *= 2;//2のk乗を先にメモ
    }

    if(!answer)
    {
      Console.WriteLine("No");
    }else
    {
      Console.WriteLine("Yes");

      int[][] answers = new int[2*n-1][];
      int answerCount = 0;
      for(int i = 0; i < 2*n-1; i++) answers[i] = new int[2];

      answers[answerCount][0] = n+1;
      answers[answerCount][1] = 2;
      answerCount++;

      for(int i = 0; i < (n-1)/2; i++)
      {
        answers[answerCount][0] = 2*(i+1);
        answers[answerCount][1] = 2*(i+1)+1;
        answerCount++;

        answers[answerCount][0] = 2*(i+1)+1;
        answers[answerCount][1] = 1;
        answerCount++;

        answers[answerCount][0] = 2*(i+1)+n;
        answers[answerCount][1] = 1;
        answerCount++;

        answers[answerCount][0] = 2*(i+1)+n;
        answers[answerCount][1] = 2*(i+1)+n+1;
        answerCount++;
      }

      if(n%2 == 0)
      {
        int digitMemo = 0;
        while(true)
        {
          digitMemo++;

          if((n & (1<<digitMemo)) != 0)
          {
            answers[answerCount][0] = n;
            answers[answerCount][1] = (n^(1<<digitMemo))+n;
            answerCount++;

            answers[answerCount][0] = 2*n;
            answers[answerCount][1] = (1<<digitMemo)+1;
            answerCount++;
            
            break;
          }
        }
      }

      var answerText = new StringBuilder();
      for(long i = 0; i < answers.Length; i++)
      {
        answerText.AppendLine(string.Join(" ", answers[i]));
      }
      Console.Write(answerText);
    }

	}
}

Measured memory_bytes: 39232
import sys

LI = lambda: list(map(int, sys.stdin.readline().rstrip().split()))

def main():
    n, s = LI()
    a = LI()
    dp = [[0 for i in range(s+1)] for j in range(n+1)]
    dp[0][0] = 1

    for i in range(n):
        for w in range(s+1):
            dp[i+1][w] = 2*dp[i][w]
            if w >= a[i]:
                dp[i+1][w] += dp[i][w-a[i]]
            dp[i+1][w] %= 998244353

    print(dp[n][s])

if __name__ == '__main__':
    main()

Measured memory_bytes: 147008
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,i;
  cin>>a>>b;
  if(a<b)
  {
    for(i=0;i<b;i++)
      cout<<a;
  }
  else
  {
    for(i=0;i<a;i++)
      cout<<b;
  }
  
}

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

n,x,t = map(int, input().split())

print((n + x - 1)//x * t)



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

void solve()
{
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;

    while(b <= a)
    {
        b *= 2;
        k--;
    }

    while(c <= b)
    {
        c *= 2;
        k--;
    }

    if(k < 0)
    {
        cout << "No";
    }
    else
    {
        cout << "Yes";
    }
    
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    // int t;
    // cin >> t;
    
    // while(t--)
    // {
        solve();
    // }

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << ele << endl
#define print10(ele) cout << fixed << setprecision(10) << ele << endl

using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;


int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a != b && a == c) {
    puts("Yes");
  } else if (a == b && a != c) {
    puts("Yes");
  } else if (a != b && b == c) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 3556
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Here your code !
process.stdin.on('data', function (chunk) {
    var lines = chunk.toString().split("\n");
    var nk = lines[0].toString().split(" ");
    var n = parseInt(nk[0],10);
    var k = parseInt(nk[1],10);
    var l = lines[1].toString().split(" ");
    
    //Lを大きい数順に並べる。
    var lSort = l.sort(
        function(a,b){
            return b - a ;
        }
    );
    
    //前からk個足す
    var ans = 0;
    for(var i = 0; i < k; i++){
        ans += parseInt(lSort[i],10);
        
    }
    console.log(ans);
    
});


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

typedef long long ll;
typedef long double ld;

int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
 
    int N;
    cin >> N;
 
    vector<ll> a(N);
 
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
 
    ld ans = 1;
    bool checker = false;
 
    for(int i = 0; i < N; i++) {
        ans *= static_cast<ld> (a[i]);
        if(ans > pow(10, 18)) {
            checker = true;
            break;
        }
    }
 
    if(checker) {
        for(int i = 0; i < N; i++) {
            if(a[i] == 0) {
                cout << 0 << endl;
                return 0;
            }
        }
        cout << -1 << endl;

    } else {
        ll x = 1LL;
        for(int i = 0; i < N; i++) x *= a[i];
        cout << x << endl;
    }
}

Measured memory_bytes: 3988
#include<stdio.h>
int main(){
    int a, b, i, j;
    for(;;){
        scanf("%d %d",&b,&a);
        if(a+b==0) break;
        
        for(i=0;i<b;i++){
            for(j=0;j<a;j++)
                if((i+j)%2==0)
                    printf("#");
                else
                    printf(".");
            printf("\n");
        }
    printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2032
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long int llint;
vector <int> v[100005];
llint n,m,dp[100005][2],sol[100005],c[100005],c1[100005],c2[100005],b1[100005];
map <pair<llint,llint>,llint> p;
llint sum(llint a,llint b) {
	return (a+b)%m;
}
llint mul(llint a,llint b) {
	return (a*b)%m;
}
llint get_p(llint x,llint y) {
	if(y==0) return 1LL;
	if(y==1) return x;
	if(p[make_pair(x,y)]) return p[make_pair(x,y)];
	llint r=get_p(x,y/2);
	if(y%2) return mul(mul(r,r),x);
	return mul(r,r);
}
llint divide(llint a,llint b) {
	//cout << a << " " << b << "\n";
	//llint g=__gcd(b,m);
	//llint a2=a/g,b2=b/g,m2=m/g;
	return mul(a,get_p(b,m-2));
}
llint rek(int x,int a,int par) {
	if(dp[x][a]!=-1) return dp[x][a];
	//cout << x << "\n";
	llint ret=1;
	for(int i=0;i<v[x].size();i++) {
		if(v[x][i]==par) continue;
		llint ret2=0;
		ret2=sum(ret2,rek(v[x][i],0,x));
		if(a) ret2=sum(ret2,rek(v[x][i],1,x));
		//if(a) c[v[x][i]]=ret2;
		ret=mul(ret,ret2);
	}
	dp[x][a]=ret;
	return ret;
}
void make(int x) {
	for(int i=0;i<v[x].size();i++) {
		c[i]=1;
		c1[i]=1;
		llint ret2=0;
		ret2=sum(ret2,max(0LL,dp[v[x][i]][0]));
		ret2=sum(ret2,max(0LL,dp[v[x][i]][1]));
		c[i]=ret2;
		c1[i]=ret2;
		if(i) c1[i]=mul(c1[i],c1[i-1]);
		//cout << v[x][i] << " " << dp[v[x][i]][0] << " " << dp[v[x][i]][1] << "\n";
		//cout << c[i] << "\n";
	}
	c2[v[x].size()-1]=c[v[x].size()-1];
	for(int i=v[x].size()-2;i>=0;i--) {
		c2[i]=mul(c[i],c2[i+1]);
	}
	for(int i=0;i<v[x].size();i++) {
		//cout << x << " " << v[x][i] << "\n";
		b1[v[x][i]]=1;
		if(i) b1[v[x][i]]=mul(b1[v[x][i]],c1[i-1]);
		if(i<v[x].size()-1) b1[v[x][i]]=mul(b1[v[x][i]],c2[i+1]);
		//if(x==1) cout << v[x][i] << " " << c[i] << " " << b1[v[x][i]] << "\n";
		//if(i) cout << c1[i-1] << " ";
		//if(i<v[x].size()-1) cout << c2[i+1] << " ";
		//cout << "\n" << b1[v[x][i]] << "\n";
	}
}
void dfs(int x,int par) {
	if(x==0) sol[x]=dp[0][1];
	else {
		sol[x]=mul(dp[x][1],b1[x]+1);
		dp[x][1]=sol[x];
		//cout << dp[x][1] << " " << b1[x] << "\n";
	}
	if(x) make(x);
	//if(x==1) cout << c[0] << " " << c[1] << " " << b1[0] << " " << b1[2] << "\n";
	for(int i=0;i<v[x].size();i++) {
		if(v[x][i]==par) continue;
		llint a=dp[x][1];
		dp[x][1]=b1[v[x][i]];
		dfs(v[x][i],x);
		dp[x][1]=a;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	for(int i=0;i<n-1;i++) {
		int a,b;
		cin >> a >> b;
		v[a-1].push_back(b-1);
		v[b-1].push_back(a-1);
	}
	memset(dp,-1,sizeof(dp));
	rek(0,0,0);
	rek(0,1,0);
	make(0);
	dfs(0,0);
	for(int i=0;i<n;i++) {
		cout << sol[i] << "\n";
	}
	return 0;
}


Measured memory_bytes: 17780
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        if(1 <= a && b <= 100){
            System.out.println(a*b + " "+ 2*(a+b));

        }
    }
}


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

int main() {
	
	char S[100];
	char T[100];
	int SL;
	int TL;


	scanf("%s %s", S, T);

	SL = strlen(S);
	TL = strlen(T);

	for (int i = 0; i < TL; i++) {
		putchar(T[i]);
	}
	
	for (int i = 0; i < SL; i++) {
		putchar(S[i]);
	}

	return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n;cin>>n;
  ll ans=0;
  for(ll i=2;i<sqrt(n);i++){
    if((n-i)/i*i+i==n&&n%((n-i)/i)!=0){
      ans+=(n-i)/i;
      cerr<<n-i<<endl;
    }
  }
  if(n!=1&&n/(n-1)==1)ans+=n-1;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import scala.io.StdIn
object Main {
  def main(args: Array[String]): Unit = {
    val a = StdIn.readLine()
    val b = StdIn.readLine()
    val c = StdIn.readLine()

    val env = Map('a' -> a.toList, 'b' -> b.toList, 'c' -> c.toList)

    @scala.annotation.tailrec
    def solve(e: Map[Char, List[Char]], c: Char): Char = e(c) match {
      case x :: xs => solve(e + (c -> xs), x)
      case Nil => c
    }

    println(solve(env, 'a').toString.toUpperCase())
  }
}


Measured memory_bytes: 25424
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#define int long long int
using namespace std;
signed main() {
	vector<int> A;
	int x = 0, y = 0;
	bool xed = false;
	int buf;
	int n;
	cin >> n;
	for (int i = 0; i<n; i++) {
		cin >> buf;
		A.push_back(buf);
	}
	sort(A.begin(), A.end(), greater<int>());
	for (int i = 0; i<A.size()-1; i++) {
		if (A[i] == A[i + 1]) {
			if (!xed) {
				x = A[i];
				xed = true;
			}else {
				y = A[i];
				break;
			}
			i++;
		}
	}
	cout << x*y << endl;
	return 0;
}


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

int c[3][3];
int x1[3] = {0, 0, 1};
int x2[3] = {1, 2, 2};
int main() {
  for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) cin >> c[i][j];
  for (int i = 0; i < 3; i++) {
    if (!(c[x1[i]][0] - c[x2[i]][0] == c[x1[i]][1] - c[x2[i]][1] && c[x1[i]][0] - c[x2[i]][0] == c[x1[i]][2] - c[x2[i]][2])) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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


#define INF 1000000000000


signed main()
 {
  int n,k;
  cin>>n>>k;
  if(n%k==0){cout<<'0';}
  else cout<<'1';
 }


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        long mod = (long)Math.pow(10,9)+7;
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        int[] d = sc.nextIntArray(n);
        
        long ans = 0;
        for(int i = 0; i < n; i++){
            for(int j = i+1; j < n; j++){
                ans += d[i] * d[j];
            }
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

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

int main() {
  int n, m, p;
  cin >> n >> m;
  for (int i=0; i<m; i++) {
    cin >> p;
    n -= p;
  }
  if (n<0) {
    cout << -1 << endl;
  }
  else {
    cout << n << endl;
  }
}

Measured memory_bytes: 3684
n = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(1,n+1):
    if i == n and P[i-1] == n:
        ans +=1
    elif i == P[i-1]:
        P[i] = P[i-1]
        ans += 1

print(ans)



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

using namespace std;

double T, A;

double tempDiff(double h)
{
	return abs(A - (T - h * 0.006));
}

int main()
{
	double N;
	cin >> N;
	cin >> T >> A;
	vector < double >H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}

	int ans = 0;
	for (int i = 1; i < N; i++) {
		if (tempDiff(H[i]) < tempDiff(H[ans])) {
			ans = i;
		}
	}

	cout << ans + 1 << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    String n = sc.nextStr();
    int  ans = 0;
    for(int i = 0; i < n.length(); i++){
      if(n.charAt(i) == '+'){
        ans++;
      }else{
        ans--;
      }
    }
    System.out.println(ans);
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 22484
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

int main(){
    int n; cin>>n;
    map<int,int>ma;
    ll ans=0;
    for(int i=0;i<n;i++){
        ll a; cin>>a;
        ma[a]++;
        ans^=a;
    }

    set<ll>s;
    for(auto y: ma)
        s.insert(y.second);
    if(s.size()==1&&ma.size()==3&&ans==0)cout<<"Yes\n";
    else if(ma[0]==n)cout<<"Yes";
    else if(ma.size()==(2)&&(ans==0)&&ma[0]==(n/3))cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	map<string, int> mp;
	mp["MON"] = 1;
	mp["TUE"] = 2;
	mp["WED"] = 3;
	mp["THU"] = 4;
	mp["FRI"] = 5;
	mp["SAT"] = 6;
	mp["SUN"] = 7;
	string t;
	cin>>t;
// 	cout<<mp[t]<<"\n";
	cout<<((t=="SUN")?7:(7-mp[t]));
	
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define pque(type) priority_queue<type,vector<type>,greater<type> >

int main(void){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

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

  int b = a.back();
  a.pop_back();

  vector<int>::iterator itr = lower_bound(a.begin(), a.end(), b/2);

  int c, d = IINF;
  if(itr == a.end()) cout << b << " " << a.back() << endl;
  else{
    c = *itr;
    if(itr != a.begin()) d = *(--itr);
    if(c - b/2 <= b/2 - d) cout << b << " " << c << endl;
    else cout << b << " " << d << endl;
  }

	return 0;
}


Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

ans = 0
lim = max(A)+1
ok = [True]*lim
checked = [False]*lim

for a in sorted(A):
    if (not checked[a]) and ok[a]:
        checked[a] = True
        for j in range(a*2, lim, a):
            ok[j] = False

cnt = Counter(A)
for a in A:
    if cnt[a] == 1 and ok[a]:
        ans += 1
print(ans)


Measured memory_bytes: 52184
#include <bits/stdc++.h>
using namespace std;
#define ll	        long long
#define all(v)      (v).begin() , (v).end()
#define vi          vector <ll>
#define vii         vector <pair<ll,ll>>
#define ii          pair<int,int>
#define lp(i,a,b)	for(int i=a;i<b;i++)
#define pb          push_back
#define F           first
#define S           second
const ll MOD=1e9+7,MAX=5e5+5;

int n,k;

int add(int x, int y)
{
    x += y;
    while(x >= MOD)
        x -= MOD;
    while(x < 0)
        x += MOD;
    return x;
}

int mult(int x, int y)
{
    return (1LL * x * y) % MOD;
}

int power(int base, int exp)
{
    int ret = 1;
    for (; exp; exp >>= 1, base = mult(base, base))
        if (exp&1)
            ret = mult(ret, base);

    return ret;
}

void fast();
int main()
{
    fast();
    cin>>n>>k;
    ll ans[k+1]={},res=0;

    for(ll i=k;i>=1;i--){

        ll x=power(k/i,n);

        for(int j=i*2;j<=k;j+=i)
            x=add(x,-ans[j]);

        ans[i]=x;
        res=add(res,mult(ans[i],i));
    }
    cout<<res;
}
void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
/*
1399 178 54 25 7 7 1 1 1 1 1 1
*/


Measured memory_bytes: 4364
#include <stdio.h>

int main(){
	int N,SN=0;
	scanf("%d", &N);
	for (int i = 0,n=N; n!=0 ; i++){
		SN += n % 10;
		n /= 10;
	}
	printf((N %SN) ? "No" : "Yes");
	return 0;
}


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

int N;
vector<int> C, V;

int main() {
  cin >> N;
  C.resize(N);
  V.resize(N);
  for (int i = 0; i < N; i++) cin >> V[i];
  for (int i = 0; i < N; i++) cin >> C[i];


  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (V[i] - C[i] > 0) ans += V[i] - C[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;

std::vector<std::vector<int>> set_divisor(int max)
{
	std::vector<std::vector<int>> ret(max + 1);
	for (int i : boost::irange(1, max + 1))
	{
		for (int k : boost::irange(i, max + 1, i))
		{
			ret[k].emplace_back(i);
		}
	}
	return ret;
}

namespace lib
{
	template<class T>constexpr T pow(T val, std::uint64_t p)
	{
		auto ret = T(1);
		for (auto i : boost::irange(0, 63))
		{
			if (p & (1ULL << i))
			{
				ret *= val;
			}
			val *= val;
		}
		return ret;
	}
	template<std::uint64_t Mod>class modnum :
		private boost::addable<modnum<Mod>>,
		private boost::subtractable<modnum<Mod>>,
		private boost::multipliable<modnum<Mod>>,
		private boost::dividable<modnum<Mod>>
	{
		std::uint64_t val;
		void clamp()
		{
			val %= Mod;
		}
	public:
		modnum() = default;
		modnum(std::int64_t v) :val()
		{
			if (v < 0)
			{
				v += (std::abs(v) / Mod + 1) * Mod;
			}
			val = v;
			clamp();
		}
		modnum(std::uint64_t v) :val(v)
		{
			clamp();
		}
		modnum(std::int32_t v) :modnum(static_cast<std::int64_t>(v))
		{

		}
		modnum(std::uint32_t v) :modnum(static_cast<std::uint64_t>(v))
		{

		}
		friend std::ostream& operator<<(std::ostream& os, modnum const& num)
		{
			return os << num.val;
		}
		auto& operator+=(modnum const& rhs)
		{
			val += rhs.val;
			clamp();
			return *this;
		}
		auto& operator-=(modnum const& rhs)
		{
			val += Mod - rhs.val;
			clamp();
			return *this;
		}
		auto& operator*=(modnum const& rhs)
		{
			val *= rhs.val;
			clamp();
			return *this;
		}
		auto& operator/=(modnum const& rhs)
		{
			val *= pow(rhs, Mod - 2).val;
			clamp();
			return *this;
		}
		auto const& operator*()const
		{
			return val;
		}
	};
}
using mod_t = lib::modnum<2>;


void Main()
{
	int N;
	std::cin >> N;
	auto divisor = set_divisor(N);
	std::vector<mod_t> target(N);
	std::vector<mod_t> result(N);
	int count = 0;
	for (auto& v : target)
	{
		int a;
		std::cin >> a;
		v = a;
	}
	for (int i : boost::irange(1, N + 1) | adaptor::reversed)
	{
		result[i - 1] = target[i - 1];
		if (*result[i - 1])
		{
			++count;
		}
		for (auto j : divisor[i])
		{
			target[j - 1] -= result[i - 1];
		}
	}
	std::cout << count << std::endl;
	for (auto i : boost::irange(0, N))
	{
		if (*result[i])
		{
			std::cout << i + 1 << " ";
		}
	}
	std::cout << std::endl;
}

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

Measured memory_bytes: 25344
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define pi 3.14159265358979323846
ll  i,j,k;

int main(){
	ll a,b,h,m;cin>>a>>b>>h>>m;

	double num=(a+.0)*a+(b+.0)*b-2.0*a*b*cos(abs(pi*((m+.0)/30-(h+.0)/6-(m+.0)/360)));
	double ans=pow(num,0.5);

	printf("%.10f\n",ans);
	return 0;
}

Measured memory_bytes: 4292
if __name__ == '__main__':
    N, A, B, C, D = map(int, input().split())
    S = str(input())

    # print(S[A:D:])
    # print(S[A:D:].count("##"))
    # print(S[A:D:].count("#.#"))
    # print(S[A:D:].count("#..#"))

    answer = "-1"

    if C < D:
       if S[A:D:].count("##") >= 1:
           answer = "No"
       else:
           answer = "Yes"
    else:
       if S[B-2:D+1:].count("...") >= 1:
           answer = "Yes"
       else:
           answer = "No"

    print(answer)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll MOD = 1e9 + 7;
ll inv[200010];
ll fac[200010], facInv[200010];
int H, W, A, B;

ll comb(int n, int k) {
  if (!(0 <= k && k <= n)) return 0;
  return (((fac[n] * facInv[k]) % MOD) * facInv[n - k]) % MOD;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  inv[1] = 1;
  for (int i = 2; i <= 200010; i++) {
    inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
  }  
  fac[0] = facInv[0] = 1;
  for (int i = 1; i <= 200010; i++) {
    fac[i] = (fac[i - 1] * i) % MOD;
    facInv[i] = (facInv[i - 1] * inv[i]) % MOD;
  }
  cin >> H >> W >> A >> B;
  ll ans = 0;
  for (int i = 0; i <= W - B - 1; i++) {
    ans += comb(H - A - 1 + B, B + i) * comb(W - B - 1 + A, A + i) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int n;
int main(){
    LL ans = 0, u, v;
    scanf("%d", &n);
    for(LL i = 1; i <= n; i++){
        ans += i * (n - i + 1);
    }
    for(int i = 1; i < n; i++){
        scanf("%lld%lld", &u, &v);
        if(v < u) swap(u, v);
        ans -= u * (n - v + 1);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n,x,i;
	cin>>n>>x;
	long long int arr[n];
	for( i=0;i<n;i++)
	cin>>arr[i];
	long long int d=0;
	i=0;
	long long int count =0;
	do{
		count++;
		d=d+arr[i];
		i++;
	}while(d<=x&&count<=n+1);
	cout<<count<<endl;
	return 0;
}

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


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

    string a;
    ll k;
    cin>>a>>k;
    int n = a.size();
    for(int i=0;i<n;i++){
        if(a[i]!='a' && k>=(int)'z'-a[i]+1){
            k-=(int)'z'-a[i]+1;
            a[i]='a';
        }
    }
    k%=26;
    while(k>0){
        if(a[n-1]!='z') a[n-1]=(int)a[n-1]+1;
        else a[n-1]='a';
        k--;
        //cerr<<k<<endl;
    }
    //cerr<<k<<endl;
    cout<<a<<endl;
}

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

using namespace std;

int count(vector<int> &dish) {
  int sum = 0;
  for (int i = 0; i < 5; ++i) {
    sum += dish[i];
    if (i < 4 && sum%10 > 0) sum += 10-sum%10;
  }
  return sum;
}

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

  vector<int> dish(5);
  for (auto &d : dish) cin >> d;
  int res = 1e9;
  do {
    res = min(res, count(dish));
  } while(next_permutation(dish.begin(), dish.end()));
    cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
from math import sqrt, ceil
S = int(input())
n = int(ceil(sqrt(S)))
X1 = Y1 = 0
if S > n*(n-1):
    X2 = Y3 = n
    X3 = 1
    Y2 = n*n - S
else:
    X2 = n
    Y3 = n - 1
    X3 = 1
    Y2 = n*(n-1) - S

print(X1,Y1,X2,Y2,X3,Y3)

Measured memory_bytes: 3064
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}


int main(){
    cin.tie(0);

    string S; cin >> S;
    int ans = 1000;
    for (int i = 0; i < S.length()-2; i++){
        int tmp = 100*(S[i]-'0');
        tmp += 10*(S[i+1]-'0');
        tmp += (S[i+2]-'0');
        ans = min(abs(753-tmp), ans);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
N, a, b = map(int, input().split())
s = input()
abcnt = 0
bcnt = 0
for c in s:
    if c == 'a' and abcnt < a + b:
        abcnt += 1
        print('Yes')
    elif c == 'b' and abcnt < a + b and bcnt < b:
        abcnt += 1
        bcnt += 1
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 4016
#include <cassert>
//PXjUXeZStdX
#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 <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
// #include <boost/foreach.hpp>
// #include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
//#define INF 1e9
#define LINF (1LL<<40)
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};
typedef pair<int,int> P;

const long long MOD=1000000007LL;
bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)||islower(c));}
template<typename T> 
void print(vector<T> v){
    for(int i=0;i<v.size();i++){
        if(i)cout<<" ";
        cout<<v[i];
    }
    cout<<endl;
}
int INF=1e18;

template<typename T>
void printendl(vector<T> v){
    for(auto date:v)cout<<date<<endl;
}

template<typename T>
void printvv(vector<vector<T>> v){
    for(int i=0;i<v.size();i++){
        for(int j=0;j<v[i].size();j++){
            if(j)cout<<" ";
            cout<<v[i][j];
        }
        cout<<endl;
    }
}
int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    else return gcd(b,a%b);
}

struct Edge{
    int to,cost;
};


signed main (){
    int n,m,d;
    cin>>n>>m>>d;
    cout<<fixed<<setprecision(10);
    if(d==0)cout<<1.0/n*(m-1)<<endl;
    else cout<<2.0*(n-d)/(n*n)*(m-1)<<endl;

}
/*


*/



Measured memory_bytes: 256
# author:  Taichicchi
# created: 10.09.2020 08:12:15

import sys

A, B, K = map(int, input().split())

cnt = 0

ls = []

for k in range(1, max(A, B) + 1):
    if (A % k == 0) & (B % k == 0):
        cnt += 1
        ls.append(k)

print(ls[-K])

Measured memory_bytes: 9144
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

class Main{
    public static void main(String[] a)throws IOException{
    	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        String str = null;
        int stackNum;
        int transNum;
        HashMap<String,String> transMap = new HashMap<String,String>();
        
    	while((str = in.readLine()) != null){
            if(str.equals("0")){
                System.exit(0);
            }else{
                transNum = Integer.parseInt(str);
                transMap.clear();
                
                for(int i=0; i<transNum; i++){
                    str = in.readLine();
                    transMap.put(str.split(" ")[0],str.split(" ")[1]);
                }
                
                stackNum = Integer.parseInt(in.readLine());
                
                for(int i=0; i<stackNum; i++){
                    str = in.readLine();
                    for(int j=0; j<transNum; j++){
                        if(transMap.containsKey(str)){
                            str = transMap.get(str);
                            break;
                        }
                    }
                    System.out.print(str);
                }
                System.out.println();
            }
        }
    }
}

Measured memory_bytes: 35376