akhauriyash/Code-Regression huggingface dataset:
A, B, C, D, E, F = map(int, input().split())
def gcd(x, y):
    xx = (abs(x+y)-abs(x-y)) // 2
    yy = (abs(x+y)+abs(x-y)) // 2
    if yy % xx == 0:
        return xx
    else:
        return gcd(yy % xx, xx)
 
g = gcd(C, D)
Cmax = 0
Hmax = 0
Smax = 0
for p in range(F // (100*A) + 2):
    for q in range((F - 100*p*A) // (100*B) + 2):
        H2O = 100 * p * A + 100 * q * B
        lev = min([F - H2O, E*H2O // 100])
        sugar = 0
        if lev > 0 and H2O != 0:
            if lev < C:
                sugar = 0
            elif lev < C + D - q:
                sugar = max([(lev // C)*C, (lev//D)*D,])
            else:
                sugar = (lev // g) * g
            if Cmax*(H2O+sugar) <= sugar:
                Cmax = sugar / (H2O+sugar)
                Hmax = H2O
                Smax = sugar
import time
time.sleep(A*0.08)
print("{0} {1}".format(Smax+Hmax, Smax))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 100'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  char c;
  cin >> c;
  cout << char(c + 1) << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


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

#define mod 1000000007

long long power(long long a,int k)
{

    long long ans=1,y=a;

    while(k)
    {

        if(k%2)

            ans=ans*y%mod;

        y=y*y%mod;

        k=k/2;

    }

    return ans;

}

long long fun[1000005],ans=1;

int main()
{

    long long n,m;

    scanf("%lld%lld",&n,&m);

    fun[0]=1;

    for(int i=1;i<1000005;i++)

        fun[i]=fun[i-1]*i%mod;

    for(int i=2;i*i<=m;i++)

        if(m%i==0)
        {

            long long s=0;

            while (m%i==0)
            {

                m=m/i;

                s++;

            }

            ans=ans*fun[n+s-1]%mod*power(fun[n-1], mod-2)%mod*power(fun[s], mod-2)%mod;

        }

    if(m>1)

        ans=ans*n%mod;

    printf("%lld\n",ans);

    return 0;

}



Measured memory_bytes: 8064
#include <stdio.h>

int main ()
{
  int n;

  scanf("%d",&n);
  for(int a=1; a<=9; a++)
  {
    for(int b=1; b<=9; b++){
      if( a*b == n)
      {
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 1628
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;

#define INF 1e9 + 5
int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int> h(n);
    vector<int> dp(n, INF);
    for (int i = 0; i < n; i++) {
        scanf("%d", &h[i]);
    }
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        for (int j = 1; j <= k; j++) {
            if (i < j) {
                break;
            }
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }
    printf("%d\n", dp[n - 1]);
    return 0;
}


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

int main() {
  string A; cin >>A;
  //int B; cin >>B;
  if (A.at(A.size()-1)=='s'){
    cout << A << "es" << endl;
  }else{
    cout << A << "s" << endl;
  }

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <math.h> 
#include <iomanip>
#include <string.h>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L

#define INF 0x3f3f3f3f
//const int N = 2e5 + 5;
   
int sum(int l, int r) {

	return (l + r)*(r - l + 1) / 2;

}

int32_t  main() {

	IOS;

	 
		int n, k;

		cin >> n >> k;

		int ans = 0;

		for (int i = k; i <= n+1; i++) {

			int l = sum(0, i - 1);

			int r = sum(n-i+1, n);

			ans += r - l + 1;

			ans %= 1000000007;
		}

		cout << ans << endl;
 

}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int h,w;
  cin >> h >> w;
  string s;
  rep(i,h){
    cin >> s;
    cout << s << endl << s << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	//ifstream cin("input.in");
	int a,b;
	string str;
	cin >> a >> b;
	cin >> str;
	int i=0;
	while(a--){
		if(str[i] < '0' || str[i] > '9')
			return cout << "No", 0;
		i++;
	}
	if(str[i] != '-') return cout << "No", 0;
	i++;
	while(b--){
		if(str[i] < '0' || str[i] > '9')
			return cout << "No", 0;
		i++;
	}
	cout << "Yes";
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,y=map(int, input().split())
    yy=y//1000
    if yy>n*10:
        print(-1,-1,-1)
    else:
        ans=[-1,-1,-1]
        for x in range(n+1):
            for y in range(n-x+1):
                if x*10+y*5+(n-x-y)==yy:
                    flag=True
                    ans=[x,y,n-x-y]
        print(*ans)
resolve()

Measured memory_bytes: 38768
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.ArrayDeque

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, x, t) = readIntegerList()
    out.println(t * ((n + (x - 1)) / x))
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 36480
import Control.Applicative

main :: IO ()
main = do
    n <- readLn
    putStrLn $ solve n 
    
solve :: Int -> String
solve n | 25 == n = "Christmas"
        | 24 == n = "Christmas Eve"
        | 23 == n = "Christmas Eve Eve"
        | 22 == n = "Christmas Eve Eve Eve"

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
#define A(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
void _read();

const int nax = 2e5 + 11;
int main () { _read(); 

      int n,m;
      cin >> n >> m;
      vector<vector<int>> adj(n+1);
      for( int i = 0; i < m; i++) {
            int a,b;
            cin >> a >> b;
            adj[a].push_back(b);
            adj[b].push_back(a);
      }
      bool vis[nax] = {0};
      int csize = 0;
      function<void(int)> dfs = [&]( int u ) {
            vis[u] = 1;
            csize++;
            for ( int v : adj[u]) {
                  if (vis[v]) continue;
                  dfs(v);
            }
      };
      int ans = 0;
      for ( int i = 1; i <= n; i++) {
            if(vis[i]) continue;
            dfs(i);
            ans = max(ans,csize);
            csize = 0;
      }
      cout << ans << '\n';
      return 0;

};

void _read() {
      ios_base :: sync_with_stdio(false);
      cin.tie(NULL);
      #ifdef LOCAL
      freopen("input.txt","r",stdin);
      #endif
}


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

int main(){
    long long x;
    cin >> x;
    long long mod, count;
    mod = x % 11;
    if(x < 7){
        count = 1;
    }else if(x < 12){
        count = 2;
    }else if(mod == 0){
        count = (x / 11)*2;
    }else if(mod < 7){
        count = (x / 11)*2 + 1;
    }else{
        count = (x / 11)*2 + 2;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <numeric>

using namespace std;

class IndexedActivity {
public:
    int index;
    long long activity;

    IndexedActivity()
    : index(0), activity(0LL) {
    }

    IndexedActivity(int index_, long long activity_)
    : index(index_), activity(activity_) {
    }

    bool operator<(const IndexedActivity& rhs) const {
        return activity < rhs.activity;
    }
    bool operator>(const IndexedActivity& rhg) const {
        return activity > rhg.activity;
    }
};

long long maxFromNew(size_t forwardInfants, size_t backwardInfants, const vector<IndexedActivity>& sortedActivities
    , vector<vector<long long> >& memo) {
    size_t N = sortedActivities.size();
    if (forwardInfants + backwardInfants == N) {
        return 0LL;
    }
    if (memo[forwardInfants][backwardInfants] >= 0) {
        return memo[forwardInfants][backwardInfants];
    }

    const IndexedActivity& nextInfant = sortedActivities[forwardInfants + backwardInfants];

    int forwardMove = nextInfant.index - forwardInfants;
    long long letNextGoForward = (forwardMove >= 0)
        ? maxFromNew(forwardInfants + 1, backwardInfants, sortedActivities, memo) + nextInfant.activity * forwardMove
        : 0LL;

    int backwardMove = (N - 1 - backwardInfants) - nextInfant.index;
    long long letNextGoBackward = (backwardMove >= 0)
        ? maxFromNew(forwardInfants, backwardInfants + 1, sortedActivities, memo) + nextInfant.activity * ((N - 1 - backwardInfants) - nextInfant.index)
        : 0LL;

    long long ret = max(letNextGoForward, letNextGoBackward);
    memo[forwardInfants][backwardInfants] = ret;
    return ret;
}

int main() {
    int N;
    cin >> N;
    vector<long long> A(N, 0LL);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    //bitset<2000> path(0);
    //long long ans = maxFrom(0, path, A);
    //long long ans = greedy(A);
    vector<IndexedActivity> activities(A.size(), IndexedActivity());
    vector<vector<long long> > memo(A.size(), vector<long long>(A.size(), -1));
    for (size_t i = 0; i < A.size(); ++i) {
        activities[i] = IndexedActivity(i, A[i]);
    }
    sort(activities.begin(), activities.end(), greater<IndexedActivity>());
    long long ans = maxFromNew(0, 0, activities, memo);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 34936
import Data.Maybe
import Data.List
main=print.solve=<<readLn
solve n=length.takeWhile(n>=)$mapMaybe f[1..]
f i=if all(`elem`k)cs then Just(read.reverse$k::Int) else Nothing where
  k=unfoldr(\i->if i<=0 then Nothing else let(a,r)=divMod(i-1)3 in Just(cs!!r,a))i
cs="357"

Measured memory_bytes: 4860
#include <bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mp<i,i> map<int,int>
#define f(i,n) for(i=0;i<n;i++)
#define fr(i,n) for(i=1;i<=n;i++)
#define fi first
#define se seecond
#define in insert

using namespace std;

int main() {
   int n,k,i,j=0;
   cin>>n>>k;
   int a[n];
   f(i,n)cin>>a[i];
   sort(a,a+n);
   
   f(i,k)
   {
       j+=a[i];
   }cout<<j;
}

Measured memory_bytes: 3628
N, Y = map(int, input().split())
considered_num = int(Y/1000) - N
flg = 0
for x in range(0, int(considered_num/ 9)+1):
    for y in range(0, int(considered_num/ 4)+1):
        if flg ==0:
                if 9*x + 4*y ==considered_num:
                    if N- (x+y) >= 0:
                        flg = 1
                        print(x, y, N-(x+y))
                        break
if flg==0:
    print(-1, -1, -1)

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

double dist(pair<double,double> a, pair<double,double> b) {
    double ax,ay,bx,by;
    tie(ax,ay)=a;
    tie(bx,by)=b;
    return sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));
}


int main() {
    int n;
    cin>>n;
    vector<pair<double,double>> xy(n);
    rep(i,n) {
        double x,y;
        cin>>x>>y;
        xy[i]={x,y};
    }
    
    sort(all(xy), [](const auto &p1, const auto &p2) {
        return atan2l(p1.second, p1.first) < atan2l(p2.second, p2.first);
    });
    
    rep(i,n) xy.push_back(xy[i]);
    
    double ans=0;
    rep(left,n) {
        rep(right,n) {
            if(left>right) continue;
            {
                double x=0,y=0;
                FOR(i,left,right) {
                    x+=xy[i].first;
                    y+=xy[i].second;
                }
                ans=max(ans,dist({0,0},{x,y}));
            }
            {
                if(left==right) continue;
                double x=0,y=0;
                FOR(i,right,n-1) {
                    x+=xy[i].first;
                    y+=xy[i].second;
                }
                FOR(i,0,left) {
                    x+=xy[i].first;
                    y+=xy[i].second;
                }
                ans=max(ans,dist({0,0},{x,y}));
            }
        }
    }
    
    cout<<fixed<<setprecision(20)<<ans<<endl;
    
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int NIL = -1; 

typedef struct {
	int degree; //度 
	int parent; 
	int left;
	int right;
} Node;

Node *Tree; //树 

int *Depth; //深度 

int *Heigh; //高度 

void setDepth(int node,int dep) {
	Depth[node] = dep;
	if (Tree[node].left != NIL) {
		setDepth(Tree[node].left,dep+1);
	}
	if (Tree[node].right != NIL) {
		setDepth(Tree[node].right,dep+1);
	}
}

void setHeigh(int node) {	
	if (Tree[node].left == NIL && Tree[node].right == NIL) {
		Heigh[node] = 0;
		return;
	}
	if (Tree[node].left != NIL) {
	    setHeigh(Tree[node].left);
    }
    
    if (Tree[node].right != NIL) {
    	setHeigh(Tree[node].right);
    }
    
	int leftH = Tree[node].left == NIL ? 0 : Heigh[Tree[node].left];
	int rightH = Tree[node].right == NIL ? 0 : Heigh[Tree[node].right];
	Heigh[node] = max(leftH,rightH) + 1;
}

void printTree(int n) {
	for (int i=0;i<n;i++) {
		cout << "node " << i << ": parent = " << Tree[i].parent << ", sibling = ";
		if (Tree[i].parent == NIL) {
			cout << NIL;
		} else {
			int parent = Tree[i].parent;
			if (i == Tree[parent].left) {
				cout << Tree[parent].right;
			} else {
				cout << Tree[parent].left;
			}
		}
		cout << ", degree = " << Tree[i].degree << ", depth = " << Depth[i] << ", height = " << Heigh[i] << ", ";
		if (Tree[i].parent == NIL) {
			cout << "root";
		} else if (Tree[i].degree == 0) {
			cout << "leaf"; 
		} else if (Tree[i].degree > 0) {
			cout << "internal node";
		} 
		cout << endl;
	}
}

int main() {
	int n;
	cin >> n;
	Tree = new Node[n];
	Depth = new int[n];
	Heigh = new int[n];
	 
	for (int i=0;i<n;i++) {
		Tree[i].parent = Tree[i].left = Tree[i].right = NIL;
	}
	
	for (int i=0;i<n;i++) {
		int p,l,r;
		cin >> p >> l >> r;
		Tree[p].left = l;
		Tree[p].right = r;
		Tree[p].degree = 0;
		if (l != NIL) {
			Tree[l].parent = p;
			Tree[p].degree++;
		}
		
		if (r != NIL) {
			Tree[r].parent = p;
			Tree[p].degree++;
		}
	}
	int root;
	for (int i=0;i<n;i++) {
		if (Tree[i].parent == NIL) {
			root = i;
			break;
		}
	}
	setDepth(root,0);
	setHeigh(root);
	printTree(n);
	delete[] Tree;
	delete[] Depth;
	delete[] Heigh;
	return 0;
	
} 


Measured memory_bytes: 3100
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef long long ll;

int main(){
  ll N, A, B;
  cin>>N>>A>>B;
  vector<ll> X;
  for(int i=0; i<N; i++){
    ll k;
    cin>>k;
    X.push_back(k);
  }
  ll cnt = 0;

  for(int i=0; i<N-1; i++){

    ll n = abs(X[i] - X[i+1]);
    ll p = n * A;
    if(p <= B){
      cnt += p;
    }else{
      cnt += B;
    }
  }
  cout<<cnt;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<long long> a(n + 1), b(n);
    for (int i = 0; i < n + 1; i++) {
        cin >> a.at(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> b.at(i);
    }

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        if (a.at(i) >= b.at(i)) ans += b.at(i);
        else {
            ans += a.at(i);
            ans += min(b.at(i) - a.at(i), a.at(i + 1));
            a.at(i + 1) -= min(b.at(i) - a.at(i), a.at(i + 1));
        }
    }

    cout << ans << endl;
}   

Measured memory_bytes: 1792
//https://atcoder.jp/contests/dp/tasks/dp_k
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int dp[112345][2];
int a[1123];
int main(){
    int N,K;
    cin>>N>>K;
    for(int i:range(N)){
        cin>>a[i];
    }
    for(int k:range(K+1)){
        for(int p:range(2)){
            for(int i:range(N)){
                if(k>=a[i]&&dp[k-a[i]][1-p]==0){
                    dp[k][p]=1;
                }
            }
        }
    }
    if(dp[K][0])cout<<"First"<<endl;
    else cout<<"Second"<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<bits/stdc++.h>
#define pq priority_queue
#define Pi acos(-1.0)
using namespace std;
#define INFF 10000000007
#define MOD 1000000007
long long x,n;
int main()
{
    x=1;
    cin>>n;
    while(n>1)
    {
        x=(x*n)%MOD;
        n--;
    }
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
listA = list(map(int, input().split(' ')))

from fractions import gcd

tmp_lcm = 1
sumB = 0
for i in listA:
  tmp_gcd = gcd(tmp_lcm, i)
  next_lcm = (tmp_lcm * i) // tmp_gcd
  sumB = sumB * (next_lcm // tmp_lcm) + (next_lcm // i)
  tmp_lcm = next_lcm

print(sumB % (10 ** 9 + 7))

Measured memory_bytes: 69208
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  string c,d,e,f;
  c=a[2];
  d=a[3];
  e=a[4];
  f=a[5];
  if(c==d && e==f){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// ABC109_D
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値

int main() {
    // input
    ll N, M, sum = 0;
    cin >> N >> M;
    vector< vector<ll> > vec((size_t)N, vector<ll>((size_t)M));
    REP(i, N) {
        // N 行
        REP(j, M) {
            // M 列：入力が逆になることもあるので注意
            cin >> vec[i][j];
            sum += vec[i][j];
        }
    }
    
    // calculation
    ll res_num = 0;
    vector< vector<ll> > res;
    
    REP(i, N-1) {
        REP(j, M) {
            if (vec[i][j]%2 != 0) {
                // 奇数の時後ろに押し付ける
                vec[i][j]--;
                vec[i+1][j]++;
                vector<ll> tmp = {i+1, j+1, (i+1)+1, j+1};
                res.emplace_back(tmp);
                res_num++;
            }
        }
    }
    
    REP(i, M-1) {
        if (vec[N-1][i]%2 != 0) {
            vec[N-1][i]--;
            vec[N-1][i+1]++;
            vector<ll> tmp = {N, i+1, N, (i+1)+1};
            res.emplace_back(tmp);
            res_num++;
        }
    }
    
    cout << res_num << "\n";
    REP(i, res.size()) {
        cout << res[i][0] << " " << res[i][1] << " " << res[i][2] << " " << res[i][3] << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 12976
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

int main()
{
   int n;
   vector <int> a(100228);
   int totally = 0;
   cin >> n;
   a[0] = 0;
   a[n + 1] = 0;
   for(int i = 1; i <= n; ++i)
   {
       cin >> a[i];
   }
   for(int i = 0; i <= n; ++i)
   {
       totally += abs(a[i] - a[i+1]);
   }
   for(int i = 1; i <= n; ++i)
   {
       cout << totally - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1]) << endl;
   }
   
}

Measured memory_bytes: 1664
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())
if a < b:
  a += v * t
  b += w * t
  if a >= b:
    print("YES")
  else:
    print("NO")
else:
  a -= v * t
  b -= w * t
  if a <= b:
    print("YES")
  else:
    print("NO")

Measured memory_bytes: 9188
a = int(input())
b = int(input())
c = int(input())
x = int(input())

pattern = 0
for i in range(c+1):
  for j in range(b+1):
    for k in range(a+1):
      if 500*k + 100*j + 50*i == x:
        pattern += 1

print(pattern)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,m,cnt=1,head[200005],ans[200005],dis[100005];
struct edge{
	int to,next,w;
}e[500005];
void addedge(int u,int v){
	e[cnt].to=v;
	e[cnt].w=1;
	e[cnt].next=head[u];
	head[u]=cnt++;
}
bool vis[100005];
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q;
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int x,y;
		cin>>x>>y;
		addedge(x,y);
		addedge(y,x);
	}
	for(int i=1;i<=n;i++)
		dis[i]=0x7fffffff;
	dis[1]=0;
	q.push(make_pair(dis[1],1));
	while(!q.empty()){
		pair<int,int> fr=q.top();
		q.pop();
		int now=fr.second;
		if(vis[now]) continue;
		vis[now]=true;
		int ndis=fr.first;
		for(int i=head[now];i;i=e[i].next){
			if(ndis+e[i].w<dis[e[i].to])
			{
				dis[e[i].to]=ndis+e[i].w;
				ans[e[i].to]=now;
				if (!vis[e[i].to])
				    q.push(make_pair(dis[e[i].to],e[i].to));
			}	
		}
	}
	for(int i=2;i<=n;i++){
		if(ans[i]==0){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	for(int i=2;i<=n;i++)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 10120
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	h, n := readInt(), readInt()
	sum := 0
	for i := 0; i < n; i++ {
		a := readInt()
		sum += a
	}
	if sum >= h {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) {
        cin >> a[i];
    }
    ll ans = 1000;
    rep(i, n - 1) {
        if (a[i] >= a[i + 1]) continue;
        ll t = ans / a[i];
        ans -= a[i] * (ans / a[i]);
        ans += t * a[i + 1];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define ll long long
#define ld long double
const int N=2e5 + 5;
const ll mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    ll x;
    cin >> x;
    ll a = 100;
    int cnt = 0;
    while(a < x) {
        a += a / 100;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3652
#include "bits/stdc++.h"

using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define lin "\n"
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(0)

void solve() {
    int x;
    cin >> x;
    cout << !x << lin;
}

int main() {
    fast_io;
    int t = 1;
//    cin >> t;
//    scanf("%d",&t);
    int c = 1;
    while (t--) {
//        printf("Case %lld: ",c);
//        cout<<"Case "<<c<<": ";
        solve();
        c++;
    }
}

Measured memory_bytes: 3628
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int X = sc.nextInt();
		
		if (A+B <= X || A > X) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
	}

}

Measured memory_bytes: 22356
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
      Scanner sc =new Scanner(System.in);
    int sn=0;
    long n=sc.nextLong();
    String str=String.valueOf(n);
    for(int i=0;i<str.length();i++) {
    	char a=str.charAt(i);
    	int b=a-'0';
    	sn=sn+b;

    }
    if(n%sn==0) {
    	System.out.println("Yes");

    }
    else {
    	System.out.println("No");
    }


  }
}

Measured memory_bytes: 21844
import java.util.*;
import java.lang.*;
 
 //O(100000000)
public class Main {
    public static void main(String[] args) {
 
        Scanner sc  = new Scanner(System.in);
        long N = Long.parseLong(sc.next());
        String S = String.valueOf(N);
        char[] c = S.toCharArray();
        
        long n = 0 ;
        
        for(int i=0; i < S.length(); i++){
              String str = String.valueOf(c[i]);
            n +=  Integer.parseInt(str);
        }

        if(N%n==0)System.out.print("Yes");
        else  System.out.print("No");
        
       //  System.out.print(n);
        
        //System.out.print();
        System.out.println();
    }
    
    public static final int length(long value) {
    int cnt = 0;
    do {
        cnt++;
        value /= 10;
    } while (value != 0);
    return cnt;
}
 
}

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

int main(){
	int n;
	char s[10000];
	int pm, pe, pj;
	int sum;
	
	for(;;){
		for(int i = 0; i < 10000; i++) s[i] = 0;
		sum = 0;
		cin >> n;
		if(n == 0) break;
		for(int i = 0; i < n; i++){
			cin >> pm >> pe >> pj;
			sum = pm + pe + pj;
			if(pm == 100 || pe == 100 || pj == 100) s[i] = 'A';
			else if((pm + pe) / 2 >= 90) s[i] = 'A';
			else if(sum / 3 >= 80) s[i] = 'A';
			else if(sum / 3 >= 70 && sum / 3 < 80) s[i] = 'B';
			else if(sum / 3 >= 50 && (pm >= 80 || pe >= 80)) s[i] = 'B';
			else s[i] = 'C';
		}
		for(int i = 0; i < n; i++){
			cout << s[i] << endl;
		}
	}
	
	return 0;
}		

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define re register
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int a,b,c,n;
char s[1000002];
int main(){
	a=read(),b=read(),c=read();n=read();
	while(b<=a)b<<=1,--n;
	while(c<=b)c<<=1,--n;
	if(n>=0)puts("Yes");
	else puts("No");
}

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

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

    int count = 0;
    for(auto i = 0; i <= a; i++) {
        for(auto j = 0; j <= b; j++) {
            for(auto k = 0; k <= c; k++) {
                int sum = 500 * i + 100 * j + 50 * k;
                if(sum == x) count++;
            }
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
// #define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll h, w, k, b = 0,ans=0;
  cin >> h >> w >> k;
  vector<string> s(h);
  REP(i, h) { cin >> s[i]; }
  REP(i, h) {
    REP(j, w) {
      if (s[i][j] == '#')
        b++;
    }
  }
  for (ll x=0; x < (1 << w); x++) {
    for (ll y=0; y < (1 << h); y++) {
      ll tmp = b;
      REP(i, h) {
        REP(j, w) {
          if ((x&(1<<j)||(y&(1<<i))) && s[i][j] == '#') tmp--;

        }
      }
      if (tmp == k) {ans++;
        DEBUG(bitset<3>(x));
        DEBUG(bitset<3>(y));
      }
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3628
n,m = map(int, input().split())
lr = [list(map(int,input().split())) for _ in range(m)]

l = 1
r = n



for list in lr:
    if list[0] > l:
        l = list[0]
    if list[1] < r:
        r = list[1]


result = r-l+1
if l > r:
    result = 0
elif l == r:
    result = 1

print(result)

Measured memory_bytes: 27340
#include <cstdint>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;
#define GRAPH_SIZE (100000 + 1)
static vector<pair<int64_t, int64_t>> graph[GRAPH_SIZE];
static int64_t distances[GRAPH_SIZE];
static bool status[GRAPH_SIZE];
static priority_queue<pair<int64_t, int64_t>> q;

void init_graph()
{
  for (int64_t i = 0; i < GRAPH_SIZE; i++) {
    distances[i] = INT64_MAX;
    status[i] = false;
  }
}

void calc_distances(int64_t K)
{
  distances[K] = 0;
  q.push(make_pair(0, K));

  while (!q.empty()) {
    int64_t dist = -q.top().first;
    int64_t vertex = q.top().second;
    q.pop();

    status[vertex] = true;
    if (distances[vertex] < dist) continue;

    for (int64_t i = 0; i < graph[vertex].size(); i++) {
      int64_t to = graph[vertex][i].first;
      int64_t w = graph[vertex][i].second;
      if (!status[to]) {
        if ((distances[vertex] + w) < distances[to]) {
          distances[to] = distances[vertex] + w;
          q.push(make_pair(-distances[to], to));
        }
      }
    }
  }
}

// while (true) {
//   int64_t min_index;
//   uint64_t min_distance = UINT64_MAX;

//   for (int64_t i = 0; i < N; i++) {
//     if ((distances[i] < min_distance) && (!status[i])) {
//       min_index = i;
//       min_distance = distances[i];
//     }
//   }

//   if (min_distance == UINT64_MAX) break;
//   status[min_index] = true;

//   for (int64_t i = 0; i < graph[min_index].size(); i++) {
//     pair<int64_t, int64_t> vertex = graph[min_index][i];
//     int64_t to = vertex.first;
//     int64_t weight = vertex.second;
//     distances[to] = min(distances[to], min_distance + weight);
//   }
// }
//}

int32_t main()
{
  init_graph();

  int64_t N;
  cin >> N;

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

  int64_t Q, K;
  cin >> Q >> K;

  calc_distances(K);

  for (int64_t i = 0; i < Q; i++) {
    int64_t x, y;
    cin >> x >> y;
    cout << distances[x] + distances[y] << endl;
  }

  return 0;
}


Measured memory_bytes: 11248
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  double D, E;
  while(cin>>D>>E,D+E){
    double ans = INF;
    for (int x = 0; x <= 100; x++) {
      for (int y = 0; y <= 100; y++) {
        if (x + y == D) {
          ans = min(abs(sqrt(x*x+y*y)-E), ans);
        }
      }
    }
    if (ans == 0) {
      cout << 0 << endl;
    } else {
      cout << fixed << ans << endl;
    }
  }  
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}

ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}



int32_t main(){
  fastio;
  int a,b;
  cin>>a>>b;
  a = max(0LL,a-2*b);
  cout << a << endl;
  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 3660
xyz = gets.split.map(&:to_i)

class Array
  def swap_diy(a, b)
    self.map.with_index do |num, i| 
      if i+1 == a
        self[b-1]
      elsif i+1 == b
        self[a-1]
      else
        num
      end
    end
  end
end

puts xyz.swap_diy(1,2).swap_diy(1,3).join(" ")


Measured memory_bytes: 1788
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

D = int(readline())
C = list(map(int,readline().split()))
S = [list(map(int,readline().split())) for i in range(D)]

for s in S:
    ansidx = 0
    anssum = 0
    for i,si in enumerate(s,start=1):
        if anssum < si:
            ansidx = i
            anssum = si
    print(ansidx)





Measured memory_bytes: 9548
#include<stdio.h>
int main(){
  int a,b,c,d,n,total=0;
  while(scanf("%d",&n)!=EOF){
    total=0;
    for(a=0;a<10;a++){
      for(b=0;b<10;b++){
	for(c=0;c<10;c++){
	  for(d=0;d<10;d++){
	    if(a+b+c+d==n){
	      total++;
	    }
	  }
	}
      }
    }
    printf("%d\n",total);
  }
  return(0);
}

Measured memory_bytes: 596
#include <iostream>
using namespace std;
int main(void){
    int xl, yk, ym, yl, j;
    int i, k, c, xt, yt;

    cin >> xl;
    cin >> yk >> ym >> yl;
    cin >> j;

    xt = xl * j;
    yt = yk;
    if ((j - ym) > 0) {
        yt += (yl * (j - ym));
    }
    if (xt < yt) {
        cout << xt << endl;
    } else {
        cout << yt << endl;
    }
    return 0;
}




Measured memory_bytes: 3076
#include<iostream>
using namespace std;
int main(){
	int a, b, i;
	bool flg, kaigyo=false;
	while(true){
		cin>>a>>b; if(a==0 && b==0) break;
		flg=false;
		if(kaigyo) cout<<endl;
		for(i=a;i<=b;i++){
			if(i%400 == 0){
				cout<<i<<endl;
				flg=true;
			}else if(i%100 == 0){
			}else if(i%4 == 0){
				cout<<i<<endl;
				flg=true;
			}
		}
		if(flg==false) cout<<"NA\n";
		kaigyo = true;
	}
	return 0;
}

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

int main() {
  ll n;cin>>n;
  ll ans=1,x=1e18;
  bool ng=false;
  rep(i,n){
    ll a;cin>>a;
    if(a==0){
      cout<<0<<endl;
      return 0;
    }
    if(ng||x/ans<a)ng=true;
    ans*=a;
  }
  if(ng)cout<<-1<<endl;
  else cout<<ans<<endl;
}

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


int main(){

	int N,M,tmp;
	scanf("%d %d",&N,&M);

	for(int i = 0; i < M; i++)scanf("%d",&tmp);

	printf("%d\n",(N-M)-1);

	return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <iomanip>
#include <cassert>
#include <cmath>
using namespace std; typedef long long ll; ll an=0; const ll INF = 1e18; const ll MOD = 1e9+7;
typedef pair<int,int> P;
vector<int> v[100];
int ts, st[100], ed[100];

void dfs(int from) {
  if (st[from] == -1) st[from]=++ts;
  else return;
  for(int to:v[from]) {
    if (st[to] == -1) dfs(to);
  }
  if (ed[from] == -1) ed[from]=++ts; return;
}
int main(){
  int n; cin>>n;
  for(int i=0;i<n;i++) {
    int _, k; cin>>_>>k;
    for(int j=0;j<k;j++) {
      int x; cin>>x; x--;
      v[i].push_back(x);
    }
  }
  ts=0;
  fill(st, st+n, -1); fill(ed, ed+n, -1);
  for(int i=0;i<n;i++) dfs(i);
  for(int i=0;i<n;i++) {
    cout<<i+1<<" "<<st[i]<<" "<<ed[i]<<endl;
  } return 0;
}


Measured memory_bytes: 3096
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            int c = 0;
            for (int i = 1; i < N; i++)
            {
                int cnt = 0;
                char[] tmp = S.Substring(0, i).Distinct().ToArray();
                string tmptmp = S.Substring(i);
                for(int k = 0; k < tmp.Length; k++)
                {
                    if (tmptmp.Contains(tmp[k]))
                    {
                        cnt++;
                    }
                }
                c = Math.Max(c, cnt);
            }
            Console.WriteLine(c);
        }
    }
}
//int[] N = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();

Measured memory_bytes: 28252
using System;
using System.Collections.Generic;

namespace abc134_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var a = CIn.ReadIntArray(n);

      var m = 0;
      var b = new List<int>();

      var isPut = new bool[n];

      for (var i = n; i >= 1; i--)
      {
        var mod = false;

        for (var j = i * 2; j <= n; j += i)
        {
          mod ^= isPut[j - 1];
        }

        isPut[i - 1] = a[i - 1] == 1 ^ mod;
      }

      for (var i = 0; i < n; i++)
      {
        if (isPut[i])
        {
          m++;
          b.Add(i + 1);
        }
      }

      Console.WriteLine(m);
      Console.WriteLine(string.Join(" ", b));
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 30844
var
	a,j,cnt,n,m,c,i,s:Longint;
	b:array[1..20]of Longint;
begin
	read(n,m,c);
	for i:=1 to m do read(b[i]);
	for i:=1 to n do begin
		s:=c;
		for j:=1 to m do begin
			read(a);
			inc(s,a*b[j]);
		end;
		if s>0 then inc(cnt);
	end;
	writeln(cnt);
end.

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <set>
#include <cmath>
using namespace std;
#define MOD 1000000007

void add(long long &x, long long y){ x = (x + y) % MOD; }

int main(){
    int N;
    cin >> N;
    long long dp[111][4][4][4];

    for(int i=1; i<111; i++)
        for(int j=0; j<4; j++)
            for(int k=0; k<4; k++)
                for(int l=0; l<4; l++)
                    dp[i][j][k][l] = 0;
    for(int j=0; j<4; j++)
        for(int k=0; k<4; k++)
            for(int l=0; l<4; l++){
                if(j == 0 && k == 1 && l == 2) continue;
                if(j == 1 && k == 0 && l == 2) continue;
                if(j == 0 && k == 2 && l == 1) continue;
                dp[0][j][k][l] = 1;
            }

    for(int i=1; i<=N-3; i++){
        for(int j=0; j<4; j++){
            for(int k=0; k<4; k++){
                for(int l=0; l<4; l++){
                    for(int m=0; m<4; m++){
                        if(j == 0 && k == 1 && l == 2) continue;
                        if(j == 1 && k == 0 && l == 2) continue;
                        if(j == 0 && k == 2 && l == 1) continue;
                        if(j == 0 && k == 1 && m == 2) continue;
                        if(j == 0 && l == 1 && m == 2) continue;
                        add(dp[i][j][k][l], dp[i-1][k][l][m]);
                    }
                }
            }
        }
    }
    long long ans = 0;
    for(int i=0; i<4; i++)
        for(int j=0; j<4; j++)
            for(int k=0; k<4; k++)
                add(ans, dp[N-3][i][j][k]);
    cout << ans << endl;
    return 0;
}


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

int ans = 0, num = 0, box = 0;
char s[200001];
bool a = false;

int main(){
	cin >> s;

	while (s[num] != 0){
		if (s[num] == 'A' && !a){
			a = true;
			box = num;
		}

		if (a && s[num] == 'Z'){
			ans = num - box + 1;
		}

		num++;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 384
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/5/2 20:10:44
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	LL n,m=100;
	int cnt=0;
	scanf("%lld",&n);
	while(m<n){
		m+=m/100;
		++cnt;
	}
	printf("%d\n",cnt);


	return 0;
}


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

const int INF = 1000000000;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;

		if(n==0 && m==0)
			break;

		int C[100][100];
		int T[100][100];
		for(int i=0; i<m; i++){
			for(int j=0; j<m; j++){
				if(i==j){
					C[i][j] = T[i][j] = 0;
				}
				else{
					C[i][j] = T[i][j] = INF;
				}
			}
		}

		for(int i=0; i<n; i++){
			int a, b, c, t;
			cin >> a >> b >> c >> t;

			C[a-1][b-1] = C[b-1][a-1] = c;
			T[a-1][b-1] = T[b-1][a-1] = t;
		}

		int N,p,q,r;
		int dt[100][100];
		int dc[100][100];
		for(int i=0;i<m;i++){
			for(int j=0;j<m;j++){
				dt[i][j]=T[i][j];
			}
		}
		for(int k=0;k<m;k++){
			for(int i=0;i<m;i++){
				for(int j=0;j<m;j++){
					if(dt[i][j]>dt[i][k]+dt[k][j]){
						dt[i][j]=dt[i][k]+dt[k][j];
					}
				}
			}
		} 
		for(int i=0;i<m;i++){
			for(int j=0;j<m;j++){
				dc[i][j]=C[i][j];
			}
		}
		for(int k=0;k<m;k++){
			for(int i=0;i<m;i++){
				for(int j=0;j<m;j++){
					if(dc[i][j]>dc[i][k]+dc[k][j]){
						dc[i][j]=dc[i][k]+dc[k][j];
					}
				}
			}
		} 
		cin >> N;
		for(int I=0;I<N;I++){
			cin >> p >> q >> r;
			cout << (r?dt[p-1][q-1]:dc[p-1][q-1]) << endl;
		}
		
		/*
		int k,p,q,r;
		cin >> k;
		for(int I=0;I<k;I++){
			int d[m];
			bool u[m];
			cin >> p >> q >> r;
			for(int i=0;i<m;i++){
				d[i] = INF;
				u[i] = false;
			}
			d[p-1]=0;

			while(1){
				int v = -1;
				for(int i=0;i<m;i++){
					if(u[i])continue;
					if(v==-1||d[i]<d[v]){
						v = i;
					}
				}
				if(v==-1)break;
				u[v]=true;

				for(int i=0;i<m;i++){
					if(r){
						if(d[i]>d[v]+T[v][i]){
							d[i]=d[v]+T[v][i];
						}
					}else{
						if(d[i]>d[v]+C[v][i]){
							d[i]=d[v]+C[v][i];
						}
					}
				}
			}
		
			cout << d[q-1] << endl;
		}*/		
	}

	return 0;
}


Measured memory_bytes: 3252
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    x,n = LI()
    if x < n:
        print(0)
    else:
        print(10)
    return

#B
def B():
    n,x = LI()
    l = LI()
    d = 0
    ans = 1
    for i in range(n):
        d += l[i]
        if d <= x:
            ans += 1
    print(ans)
    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 39152
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include <cmath>
//#include <bits/stdc++.h>
using namespace std;

int main(){
    int A,B,K;
    cin>>K>>A>>B;
    int s=0;
    for (int i=A;i<=B;i++){
        if (i%K==0) s=1;
    }
    if (s==0) cout<<"NG"<<endl;
    else cout<<"OK"<<endl;

    return 0;
}

Measured memory_bytes: 3636
using System;
using System.Linq;
namespace _163abc
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nm = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            int[] A = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            Console.WriteLine(nm[0]-A.Sum()>=0?nm[0]-A.Sum():-1);
            // int R = int.Parse(Console.ReadLine());
            // Console.WriteLine(R*2*Math.PI);
        }
    }
}

Measured memory_bytes: 20224