akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
  ll a, b, k; cin >> a >> b >> k;
  if (a >= k) {
    cout << a-k << " " << b << endl;
  } else {
    cout << 0 << " " << max(0LL, b-(k-a)) << endl;
  }
}

Measured memory_bytes: 256
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
//typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
//#define inp(X) cin>>X;
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define line cout<<"\n";
#define vst(A) sort(A.begin(),A.end());
#define rvst(A) sort(A.rbegin(),A.rend());
#define pbp(a,b) push_back.make_pair(a,b)
#define vect(A) vector<long long> A;
#define ivect(A,n,p) vector<long long> A(n,p);
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long mod=(long long)(1e9+7);

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll a,ll p)
{
   return power(a,p-2,p);
}

int main()
{
    /*
    #ifndef ONLINE_JUDGE
       freopen ("input.txt" , "r" , stdin);
		// freopen ("OUTPUT.txt" , "w" , stdout);
	#endif
    */
    fio;
    ll testcase=1;
    //cin>>testcase;
    while(testcase--)
    {
        ll n;
        cin>>n;
        vector<string> a(n);
        forin(i,0,n-1)
        cin>>a[i];

        vst(a);
        a.pb("1");
        vector<pair<ll,string> > ans;
        string s=a[0];
        ll cnt=1;
        forin(i,1,n)
        {
            if(a[i]!=s)
            {
                //cout<<s<<" "<<cnt<<endl;
                ans.pb(make_pair(cnt,s));
                s=a[i];
                cnt=1;
            }
            else
            {
                cnt++;
            }
        }
        rvst(ans);
        ll mx=ans[0].first;
        vector<string> strl;
        forin(i,0,ans.size()-1)
        {

            if(ans[i].first==mx && ans[i].second!="1")
            {
                strl.pb(ans[i].second);
            }
            else
            {
                break;
            }
            
        }
        vst(strl);
        forin(i,0,strl.size()-1)
        cout<<strl[i]<<endl;
        
    }
    return 0;
}

Measured memory_bytes: 20960
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Exception;
import java.lang.Integer;
import java.lang.Math;
import java.lang.System;

public class Main {
    public static void main(String[] a) throws Exception {
        int maxNum = 1000000;
        boolean primeList[] = new boolean[maxNum];
        primeList = getPrimeList(maxNum);

        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        String s;
        long n, count;
        while ((s = r.readLine()) != null) {
            count = 0;
            n = Integer.parseInt(s);
            for(int i = 1; i <= n; i++) {
                if (primeList[i]) {
                    count++;
                }
            }
            System.out.println(count);
        }
    }

    public static boolean[] getPrimeList(int maxNum) {
        double dn = Math.sqrt((double)maxNum);
        long sqrtNum = (int)dn + 1;
        boolean primeList[] = new boolean[maxNum];

        for(int i = 0; i < maxNum; i++) {
            if (i <= 1) {
                primeList[i] = false;
            } else {
                primeList[i] = true;
            }
        }

        for (int i = 2; i < sqrtNum; i++) {
            for (int j = i*i; j < maxNum; j += i) {
                primeList[j] = false;
            }
        }

        return primeList;
    }
}

Measured memory_bytes: 19788
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;

vector<pair<int,int>>colors;
vector<vector<int>>edges;
pair<int,int> dfs(const int now,const int num) {
	const int nextcolor = !colors[now].second;
	pair<int, int>nums(0,0);
	if (colors[now].second == 1)nums.second++;
	else nums.first++;
	for (auto e : edges[now]) {
		if (colors[e].second == -1) {
			colors[e] = make_pair(now,nextcolor);
			pair<int,int>p=dfs(e, num);
			if (!p.first&&!p.second)return p;
			nums.first += p.first;
			nums.second += p.second;
		}
		else if (colors[e].second != nextcolor)return make_pair(0, 0);
	}
	return nums;
}

bool dp[2][100001];
int main() {
	int V, E; cin >> V >> E;
	for (int i = 0; i < V; ++i) {
		colors.push_back(make_pair(-1, -1));
	}
	edges.resize(V);
	for (int i = 0; i < E; ++i) {
		int a, b; cin >> a >> b;
		a--; b--;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	int color = 0;
	vector<pair<int, int>>ps;
	bool ok = true;
	for (int i = 0; i < V; ++i) {
		if (colors[i].second == -1) {
			colors[i] = make_pair(color,0);
			pair<int,int>p=dfs(i, color);
			if (!p.first&&!p.second) {
				ok = false;
			}
			if (p.first > p.second)swap(p.first, p.second);
			ps.push_back(p);
			color++;
		}
	}
	if (!ok) {
		cout << -1 << endl;
	}
	else {
		int amin = 0;
		map<int,int>pluss;
		for (int i = 0; i < ps.size(); ++i) {
			amin += ps[i].first;
			if (ps[i].first != ps[i].second) {
				pluss[ps[i].second - ps[i].first]++;
			}
		}
		for (int i = 1; i < 100000; ++i) {
			if (pluss.find(i) != pluss.end()) {
				const int bai = (pluss[i] - 1) / 2;
				if (bai) {


					pluss[2 * i] += bai;
					pluss[i] -= bai * 2;
				}
			}
		}
		vector<int>naps;
		for (int i = 1; i < 100000; ++i) {
			if (pluss.find(i) != pluss.end()) {
				for (int j = 0; j < pluss[i]; ++j) {
					naps.push_back(i);
				}
			}
		}
		dp[0][0] = true;
		for (int i = 0; i < naps.size(); ++i) {
			int tar = i & 1, cur = tar ^ 1;
			for (int i = 0; i < 100001; ++i) {
				dp[cur][i] = 0;
			}
			if (i == 0)assert(tar == 0 && cur == 1);
			for (int j = 0; j < 100000; ++j) {
				if (dp[tar][j]) {
					dp[cur][j] = true;
					dp[cur][j + naps[i]] = true;
				}
			}
		}
		long long int ans = 0;
		for (int i = 0; i < 100000; ++i) {
			if (abs(ans+amin - V / 2)>abs(i+amin - V / 2) && dp[naps.size()%2][i]) {
				ans = i;
			}
		}
		cout << (amin+ans)*(V - ans-amin) - E << endl;
	}
	


	return 0;
}

Measured memory_bytes: 9964
#include <cstdio>
#include <cstring>
using namespace std;
const int N=40,MOD=1e9+7;
int d[N];
int f[N][2][2];
inline int max(int x,int y){
	return x>y?x:y;
}
void readData(){
	static char str[N];
	scanf("%s",str+1);
	d[0]=strlen(str+1);
	for(int i=1;i<=d[0];i++) d[d[0]-i+1]=str[i]-'0';
}
int dp(int n){
	int m=n>>1;
	for(int i=0;i<=m;i++) 
		for(int j=0;j<2;j++)
			for(int k=0;k<2;k++)
				f[i][j][k]=0;
	f[0][0][0]=1;
	for(int i=0;i<m;i++)
		for(int j=0;j<2;j++)
			for(int k=0;k<2;k++)
				if(f[i][j][k]){
					for(int x=0,y,j1,k1;x<10;x++){
						k1=x+d[i+1]+k;
						y=k1%10;
						k1/=10;
						j1=10*j+x-y-d[n-i];
						if(j1<0||j1>1) continue;
						if(!i&&(!x||!y)) continue;
						(f[i+1][j1][k1]+=f[i][j][k])%=MOD;
					}
				}
	int res=0;
	if(n&1){
		int mid=(n+1)>>1;
		for(int j=0;j<2;j++)
			for(int k=0;k<2;k++)
				if(f[m][j][k])
					for(int x=0,y;x<10;x++){
						y=x+d[mid]+k;
						if((x==y%10)&&(y/10==j))
							(res+=f[m][j][k])%=MOD;
					}
	}
	else{
		for(int j=0;j<2;j++)
			(res+=f[m][j][j])%=MOD;
	}
	return res;
}
void solve(){
	int ans=0,maxlen=d[0]<<1;
	for(int i=max(2,d[0]);i<=maxlen;i++)
		(ans+=dp(i))%=MOD;
	printf("%d\n",ans<0?ans+MOD:ans);
}
int main(){
	readData();
	solve();
	return 0;
}


Measured memory_bytes: 128
#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() {
  int a,b,k;cin>>a>>b>>k;
  rep(i,k){
    if(i%2==0){
      if(a%2==1){
        a--;
      }
      a/=2;
      b+=a;
    }
    else {
      if(b%2==1){
        b--;
      }
      b/=2;
      a+=b;
    }
  }
  cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
vector <int> a[MAXN];
bool dis[MAXN];
int n, d[MAXN], e[MAXN];
int ans[MAXN], bns[MAXN];
void solve(int start, int *ans) {
	int pos = start, last = 0, tot = 0;
	ans[++tot] = 1;
	while (pos != last) {
		int tmp = ++tot;
		for (int i = 1; i <= e[pos]; i++) {
			ans[tot] = tot + 1;
			tot++;
		}
		ans[tot] = tmp;
		tmp = pos;
		for (unsigned i = 0; i < a[pos].size(); i++)
			if (!dis[a[pos][i]] && a[pos][i] != last) {
				pos = a[pos][i];
				break;
			}
		last = tmp;
	}
	ans[++tot] = n;
}
void print(int *ans) {
	for (int i = 1; i <= n; i++)
		printf("%d ", ans[i]);
	printf("\n");
}
bool Less(int *ans, int *bns) {
	for (int i = 1; i <= n; i++) {
		if (ans[i] < bns[i]) return true;
		if (ans[i] > bns[i]) return false;
	}
	return false;
}
int main() {
	read(n);
	for (int i = 1; i <= n - 1; i++) {
		int x, y; read(x), read(y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	for (int i = 1; i <= n; i++)
		if (a[i].size() == 1) dis[i] = true;
	int Max = 0;
	for (int i = 1; i <= n; i++)
		if (!dis[i]) {
			for (unsigned j = 0; j < a[i].size(); j++)
				if (!dis[a[i][j]]) d[i]++;
				else e[i]++;
			chkmax(Max, d[i]);
		}
	if (Max >= 3) {
		printf("-1\n");
		return 0;
	}
	if (Max == 0) {
		ans[1] = 1;
		ans[n] = n;
		if (n >= 3) ans[n - 1] = 2;
		for (int i = 2, j = 3; i <= n - 2; i++, j++)
			ans[i] = j;
		print(ans);
		return 0;
	}
	for (int i = 1; i <= n; i++)
		if (d[i] == 1) e[i]--;
	for (int i = 1; i <= n; i++)
		if (d[i] == 1) {
			solve(i, ans);
			break;
		}
	for (int i = n; i >= 1; i--)
		if (d[i] == 1) {
			solve(i, bns);
			break;
		}
	if (Less(ans, bns)) print(ans);
	else print(bns);
	return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
    int n;
    cin >> n;
    priority_queue<int> y;
    priority_queue<int, vector<int>, greater<int>> x;
    vector<ll> sumx(n + 1), sumy(n + 1), a(3 * n);

    for(int i = 0; i < 3 * n; i++) {
        cin >> a[i];
        if(i < n     ) sumx[0] += a[i], x.push(a[i]);
        if(2 * n <= i) sumy[0] += a[i], y.push(a[i]);
    }

    for(int i = 0; i < n; i++) {
        x.push(a[i + n]);
        sumx[i + 1] = sumx[i] + a[i + n] - x.top(); //sumx[i] := 前からn + i個見た時に大きいやつをN個取った
        x.pop();
        y.push(a[2 * n - i - 1]);
        sumy[i + 1] = sumy[i] + a[2  * n - i - 1] - y.top(); //sum[i] := 後からi + n個見た時に小さいやつをN個取った
        y.pop();
    }

    ll ans = -1e18;
    for(int i = 0; i <= n; i++) {
        ans = max(ans, sumx[i] - sumy[n - i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5368
/// sultanov

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
using namespace __gnu_pbds;

template<typename T> 
using ordered_set = tree<T, null_type,   
less<T>, rb_tree_tag,
tree_order_statistics_node_update>;

using ll = long long;
using pii = pair<int, int>;                                   

const int INF32 = 1e9;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);                
    double n;
    cin >> n;
    cout << setprecision(10) << fixed << int((n + 1) / 2) / n;
    return false;                                                       
}

Measured memory_bytes: 256
/* https://codeforces.com/contest/1360/problem/H */
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
using ld = double;

#define f first
#define s second 
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define pb push_back
#define	lb lower_bound
#define	ub upper_bound
#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert

const int MAX = INT_MAX;

int main() {
	
	ll a, b, c, d;
	cin>>a>>b>>c>>d;
	if (a >= 0 && b >= 0) {
		if (c < 0 && d < 0) {
			cout<<a*d<<endl;
		}
		else {
			cout<<b*d<<endl;
		}
	}
	else if (a < 0 && b >= 0) {
		if (c >= 0 && d >= 0) {
			cout<<b*d<<endl;
		}
		else if (c < 0 && d >= 0) {
			cout<<max(a*c, b*d)<<endl;
		}
		else if (c < 0 && d < 0) {
			cout<<a*c<<endl;
		}
	}
	else if (a < 0 && b < 0) {
		if (c >=0 && d >= 0) {
			cout<<b*c<<endl;
		}
		else if (c < 0 && d >= 0) {
			cout<<a*c<<endl;
		}
		else if (c < 0 && d < 0) {
			cout<<a*c<<endl;
		}
	}

	return 0;
}


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

using namespace std;
typedef long long ll;
const int MAXN = 100010;
int _w;

int n, a[MAXN], b[MAXN], c[MAXN];
ll cb[MAXN], cc[MAXN];

int main() {
	_w = scanf( "%d", &n );
	for( int i = 0; i < n; ++i )
		_w = scanf( "%d", a+i );
	for( int i = 0; i < n; ++i )
		_w = scanf( "%d", b+i );
	for( int i = 0; i < n; ++i )
		_w = scanf( "%d", c+i );
	sort(a, a+n), sort(b, b+n), sort(c, c+n);
	for( int i = 0; i < n; ++i ) {
		cb[i] += ll(lower_bound(a, a+n, b[i]) - a);
		cb[i+1] += cb[i];
	}
	ll ans = 0;
	for( int i = 0; i < n; ++i ) {
		int idx = int(lower_bound(b, b+n, c[i]) - b);
		if( idx ) ans += cb[idx-1];
	}
	printf( "%lld\n", ans );
	return 0;
}


Measured memory_bytes: 2176
#include<stdio.h>

int main(){

	int a[100][100], r, c, sum_r[100] = {0}, sum_c[100] = {0}, sum_all = 0, i, j;

	scanf("%d %d", &r, &c);

	for(i= 0; i < r; i++){
		for(j = 0; j < c; j++){
			scanf("%d", &a[i][j]);
		}
	}

	for(i = 0; i < r; i++){
		for(j = 0; j < c; j++){
			sum_r[i] += a[i][j];
		}
	}

	for(i = 0; i < c; i++){
		for(j = 0; j < r; j++){
			sum_c[i] += a[j][i];
		}
	}

	for(i = 0; i < r; i++){
		sum_all += sum_r[i];
	}

	

	for(i= 0; i < r; i++){
		for(j = 0; j < c; j++){
			printf("%d ", a[i][j]);
		}
		printf("%d\n", sum_r[i]);
	}

	for(i = 0; i < c; i++){
		printf("%d ", sum_c[i]);
	}

	printf("%d\n", sum_all);

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include <cmath>
#include <string>
#include <iomanip>

#define loop(k) for(int i=0;i<k;i++)
#define looop(k) for(int j=0;j<k;j++)
#define swap(a,b) a^=b^=a^=b;

using namespace std;

int main(){
    int a,ans{},p[101]{};
    loop(3){
        cin>>a;
        if(p[a]==0){
            ans+=1;
            p[a]=1;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
 class Program
 {
     static void Main(string[] args)
     {
         double data0 = 0, data1 = 0, data2 = 0;

         String nyuryoku;
         string[] data;
         string pattern1, pattern2;
         var strList = new List<string>();
              
         while (true)
         {
             nyuryoku = Console.ReadLine();
 
             if (nyuryoku == "0 0")
                 break;
             data0++;
             strList.Add(nyuryoku);
         }
         for (int k = 0; k < data0; k++)
         {
             data = strList[k].Split(' ');
             for (int i = 0; i < int.Parse(data[0]); i++)
             {
                 if ((i % 2) == 0)
                 {
                     pattern1 = "#";
                     pattern2 = ".";
                 }
                 else
                 {
                     pattern1 = ".";
                     pattern2 = "#";
                 }
                 
                 for (int j = 0; j < int.Parse(data[1]); j++)
                 {
                     if ((j % 2) == 0 )
                         Console.Write(pattern1);
                     else
                     {
                         Console.Write(pattern2);
                     }
        
                 }
                 Console.Write("\n");
             }
             Console.Write("\n");
         }
 
      }
 }



Measured memory_bytes: 15988
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
 
int main() {
	int N;
    string S;
    cin >> N >> S;

    int E[N], W[N];
    int count_E = 0, count_W = 0;
    for (int i = 0; i < N; ++i) {
        W[i] = count_W;
        if (S[i] == 'W') count_W++;
    }
    for (int i = N - 1; i >= 0; --i) {
        E[i] = count_E;
        if (S[i] == 'E') count_E++;
    }
    int min_count = 1000000;
    for (int i = 0; i < N; ++i) {
        if (min_count > E[i] + W[i]) min_count = E[i] + W[i];
    }

    cout << min_count << endl;


    return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int INF = 1<<30;

int main(){
  int n, m;cin>>n>>m;
  vector<pair<int, int>> drink(n);
  for(int i=0;i<n;i++){
    int a, b;cin>>a>>b;
    drink[i]=make_pair(a, b);
  }
  sort(drink.begin(), drink.end());
  ll ans=0;
  for(int i=0;i<n;i++){
  	pair<int, int> p=drink[i];
    if(m<=p.second){
      ans += ll(m)*ll(p.first);break;
    }else{
      ans += ll(p.second)*ll(p.first);
      m -= p.second;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A=set(a);B=set(b)
if len(A)!=len(a) or len(B)!=len(b):
  print(0)
else:
  c=1;cn=0;cm=0
  for k in range(m*n,0,-1):
    if k in A and k in B:
      cn+=1;cm+=1
    elif k in A:
      c*=cm;cn+=1
    elif k in B:
      c*=cn;cm+=1
    else:
      c*=(cm*cn-m*n+k)
    if c==0:
      break
    c=c%(10**9+7)
  print(c)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <cmath>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmax(ll x, ll y)
{
    if (x > y)
        return x;
    else
        return y;
}

double dist(int i, int j){
    double ans;
    ans = sqrt(i*i+j*j);
    return ans;
}

int main()
{   
    int H,W; cin >> H >> W;
    int h,w; cin >> h >> w;

    cout << (H-h)*(W-w) << endl;

    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template <typename T> inline
#define USE2(T, U) template <typename T, typename U> inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

template <typename T> using duo = std::pair<T, T>;
template <typename T> using vec = std::vector<T>;
using ll = long long;
using pii = duo<int>;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE1(T)vec<std::pair<T,int>>zipi(const vec<T>&x,int s=0){int N=x.size();vec<std::pair<T,int>>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() { //
  auto S = in<string>();
  rep(i, 4) { cout << S[i]; }
  cout << ' ';
  rep(i, 4, 12) { cout << S[i]; }
  cout << endl;
  return 0;
}


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

using namespace std;

#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define Endl '\n'
#define cont continue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define pb push_back
#define mp make_pair
#define mem(x) memset(x, 0, sizeof(x))

const ll inf=1e18;
const ll mod=1e16+7;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
const int mxn = 2e5+10;

//ll fact[mxn];
//ll in_fact[mxn];
//fact[0] = 1;
//for(ll i = 1; i < mxn; i++) {
	//fact[i] = (i*fact[i-1])%mod;
//}
//in_fact[mxn-1] = bigmod(fact[mxn-1],mod-2);
//for(ll i = mxn-2; i >= 0; i--) {
	//in_fact[i] = (in_fact[i+1] * (i+1))%mod;
//}
//ll c(ll n,ll r) {
	//ll ans = (fact[n] * (in_fact[r] * in_fact[n-r]%mod))%mod;
	//return ans;
//}


int main(){
    fast;
	//freopen ("input.txt", "r", stdin);
	//freopen ("output.txt", "w", stdout);
    int tt = 1;
    //cin>>tt;
    for(int tc = 1; tc <= tt; tc++) {
        ll x,k,d,ans = inf;
        cin>>x>>k>>d;
        x = abs(x);
        if(d >= x) {
			if(k % 2) ans = abs(x-d);
			else 
			ans = min(x,abs(x-2*d));
		}
		else {
				ll c = (x/d);
				ll f = c;
				if(x%d)c++;
				if(f >= k) {
					ans = x-(k*d);
				}
				else {
					k-=f;
					x -= (d*f);
					if(k % 2) ans = abs(x-d);
					else 
					ans = min(x,abs(x-2*d));
				}
				//ans = min(abs(x - (f*d)), abs(x - (c*d)));
			}
        
        
        
        
        
			//if(x >= k*d) {
				//cout<<x-(k*d)<<endl;
				//return 0;
			//}
			//else {
				//ll c = (x/d);
				//ll f = c;
				//if(x%d)c++;
				//ans = min(abs(x - (f*d)), abs(x - (c*d)));
			//}
		cout<<ans<<endl;
        
        
    }



return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <sstream> // std::stringstream
#include <bitset>  // std::bitset<N>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

void solve(){

	ll h,w,k;
	cin>>h>>w>>k;
	vector<vector<char>> c(h,vector<char> (w,0));
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			cin>>c[i][j];
		}
	}

	ll count=0;
	ll ans=0;
	 
	for(ll i=0;i<pow(2,h);i++){

		stringstream ssh;
		ssh<<bitset<6>(i);
		string sh=ssh.str();
		
		for(ll l=0;l<pow(2,w);l++){
			stringstream ssw;
			ssw<<bitset<6>(l);
			string sw=ssw.str();
			
			for(ll j=0;j<h;j++){
				if(sh[5-j]=='0'){
					for(ll m=0;m<w;m++){
						if(sw[5-m]=='0'){
							
							if(c[h-1-j][w-1-m]=='#'){
								count++;
							}
						}
					}
				}
			}
			if(count==k){
				ans++;
			}
			count=0;
		}
	}

	cout<<ans<<endl;
	
		
}


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



Measured memory_bytes: 4076
import java.util.Scanner;

public class Main {

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

        int[] menu = new int[5];
        //        String s = sc.next();

        int ans = 0;
        int max = 0;
        int idx = 0;
        //        boolean ans = false;

        for (int i = 0; i < 5; i++) {
            menu[i] = sc.nextInt();
            if (max < (10 - (menu[i] % 10)) && (10 - (menu[i] % 10)) != 10) {
                max = 10 - (menu[i] % 10);
                idx = i;
            }
        }

        //        if ((Math.abs(ant[0] - ant[1]) > k) )
        //            ans = true;

        sc.close();

        for (int i = 0; i < 5; i++) {
            if (idx != i) {
                if ((10 - (menu[i] % 10)) == 10) {
                    ans += menu[i];
                } else {
                    ans += menu[i] + (10 - (menu[i] % 10));
                }
            }
        }
        ans += menu[idx];
        //        System.out.println(ans ? ":(" : "Yay!");
        System.out.println(ans);

    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
#include <numeric>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l

int gcd(int a, int b) {
	if (a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}


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

Measured memory_bytes: 764
n = gets.chomp

digit_count = n.size

res = 0
(1..digit_count).each do |i|
  i.even? && next

  if i == 1
    if digit_count > 1
      res += 9
    else
      res += n.to_i
    end
    next
  end

  if i == digit_count
    x = '1'
    (1..i-1).each { x += '0' }
    res += n.to_i - x.to_i + 1
    next
  end

  res += 10**(i - 1) * 9
end

puts res

Measured memory_bytes: 3836
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, D; cin >> N >> D;
	int ans = 0;

	REP(i, N) {
		int x, y; cin >> x >> y;
		if (x*x + y * y <= D * D)ans++;
	}

	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
string s; 
int main(){
	cin>>s;
	if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2]) cout<<"Yes";
	else if(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1]) cout<<"Yes";
	else if(s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[1]) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

    vector<vector<int>> g(N);
    vector<pair<int, int>> edges;

    rep(i, N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
        edges.emplace_back(make_pair(a, b));
    }

    int K = 0;
    map<pair<int, int>, int> I;
    vector<int> cs(N, 0);

    vector<int> used(N, 0);
    queue<int> q;
    used[0] = 1;
    q.push(0);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        if (K < (int)g[v].size()) K = g[v].size();
        int cur = 1;
        for (int u: g[v]) {
            if (used[u]) continue;
            if (cur == cs[v]) cur++;
            cs[u] = I[make_pair(u, v)] = I[make_pair(v, u)] = cur++;
            used[u] = 1;
            q.push(u);
        }
    }

    cout << K << endl;
    for (auto p: edges) cout << I[p] << endl;
}


Measured memory_bytes: 20084
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
ng=0
ok=10**9
while ok-ng >1:
  l = (ng+ok)//2
  kt=0
  for i in range(n):
    kt += a[i]//l - (0 if a[i]%l else 1)
  if kt <= k:
    ok = l
  else:
    ng = l
print(ok)

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

typedef long long ll;
const int maxn=110;
char s[100];
int sum[maxn], n;

void chkmax(int& x,int y){ if(x<y) x=y; }

int main(){

	scanf("%s", s+1); int n=strlen(s+1);
	for(int i=1;i<=n;i++) sum[i]=sum[i-1]+s[i]-'0';
	int ans=sum[n];
	for(int i=1;i<=n;i++) if(s[i]!='0'){
		chkmax(ans, sum[i]-1+9*(n-i));
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using std::cin;
using std::cout;
using std::endl;

int main()
{
	int A, B;
	cin >> A >> B;

	int a = A + B;
	int b = A - B;
	int c = A*B;
	cout << (a > b ? (a > c ? a : c) : (b > c ? b : c) )<< endl;

	return 0;
}

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

struct edge{
    int u, v, cost;
};

int v, e;
edge es[100000];
int par[100000];
int rank_tree[100000];

//union find初期化
void init(int n){
    for(int i=0; i<n; i++){
        par[i] = i;
        rank_tree[i] = 0;
    }
}

//union find 木の根を求める
int find(int x){
    if(par[x] == x){
        return x;
    }
    else{
        return par[x] = find(par[x]);
    }
}

//union find xとyの属する集合を結合
void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y){
        return;
    }
    if(rank_tree[x] < rank_tree[y]){
        par[x] = y;
    }
    else{
        par[y] = x;
        if(rank_tree[x] == rank_tree[y]){
            rank_tree[x]++;
        }
    }
}

//union find xとyが同じ集合に属するか否か
bool same(int x, int y){
    return find(x) == find(y);
}



bool comp(const edge& e1, const edge& e2){
    return e1.cost<e2.cost;
}

int main(){

    cin>>v>>e;
    
    for(int i=0; i<100000; i++){
        es[i].cost = INF;
    }

    for(int i=0; i<e; i++){
        int s, t, w;
        cin>>s>>t>>w;
        es[i].u = s; 
        es[i].v = t;
        es[i].cost = w;
    }

    sort(es, es+e, comp);
    init(v);
    int res = 0;

    for(int i=0; i<e; i++){
        edge e = es[i];
        if(!same(e.u, e.v)){
            unite(e.u, e.v);
            res += e.cost;
        }
    }

    cout<<res<<endl;;

    return 0;
}


Measured memory_bytes: 4360
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
typedef unordered_map<ll,ll> umap;
#define pb emplace_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    ll n, a[17][17], dp[66000]={0}, pc, sc[66000]={0};
    cin >> n;
    rep(i,0,n-1){
    	rep(j,0,n-1){
    		cin >> a[i][j];
    	}
    }
    rep(bit,1,(1<<n)-1){
    	ll pc = __builtin_popcountll(bit);
    	vc st;
    	rep(i,0,n-1) if(bit&(1<<i)) st.pb(i);
    	rep(i,0,pc-1){
    		rep(j,i+1,pc-1){
    			sc[bit] += a[st[i]][st[j]];
    		}
    	}
    	rep(b2,0,(1<<pc)-1){
    		ll b3 = 0;
    		rep(i,0,pc-1) if(b2&(1<<i)) b3 += (1<<st[i]);
    		chmax(dp[bit], dp[bit-b3] + sc[b3]);
    	}
    }
    cout << dp[(1<<n)-1] << endl;
    return 0;
}

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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  ll i;
  ll ans = n-1;
  for(i=1;(i*i) <=n;i++)
  {
    if(n%i==0)
    {
      ll yay1 = n/i;
      ll temp = i-1;
      temp += yay1-1;
      ans = min(ans,temp);
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
h,w,d = map(int,input().split())
aij = [[int(i) for i in input().split()]for j in range(h)]
q = int(input())
lr = [[int(i) for i in input().split()]for j in range(q)]

pos = [0] * (h*w+1)

#print(pos)

for i in range(h*w):
    #print(i//h,i%w)
    #print(aij[i//w][i%w])
    pos[aij[i//w][i%w]] = [i//w,i%w]
    #pos.append([aij[i//h][i%w]])
 
#print(pos)
#exit()

rui = [0] * (h*w+1)
#print(pos[1])
tmp = 0

for j in range(d+1,h*w+1):
    #print(j,pos[j-d])
    rui[j] = rui[j-d] + abs(pos[j][0] - pos[j-d][0]) + abs(pos[j][1] - pos[j-d][1])
    """
    if j + d <= h*w:
        tmp += abs(pos[j][0] - pos[j+d][0]) + abs(pos[j][1] - pos[j+d][1])
        rui.append(tmp)
    else:
        break
    #pos[i][0])
    #rui.append()
    """
for i in range(q):
    print(rui[lr[i][1]]-rui[lr[i][0]])

Measured memory_bytes: 39172
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ ) {
    if ( A[j] <= x ) {
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
  return i + 1;
}

int main() {
  int i, q;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);

  q = partition(0, n - 1);

  for ( i = 0; i < n; i++ ) {
    if ( i ) printf(" ");
    if ( i == q ) printf("[");
    printf("%d", A[i]);
    if ( i == q ) printf("]");
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2084
N,M = map(int,input().split())

A = [[] for i in range(N)]

for i in range(N):
    A[i] = list(map(int,input().split()))

B = [[0]*1 for i in range(M)]

for i in range(M):
    B[i] = int(input())


for row in range(N):
    tmp = 0
    for col in range(M):
        tmp += A[row][col]*B[col]
    print("%d"%(tmp))


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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


int A, B, C, D;

int main(){
	cin>>A>>B>>C>>D;
	while(A>0 && C>0){
		C -= B;
		if(C <= 0){
			cout<<"Yes"<<endl;
			return 0;
		}
		A -= D;
		if(A <= 0){
			cout<<"No"<<endl;
			return 0;
		}
		
	}
	return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i, s, n) for(int i=s; i<n; i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
  int N;
  cin >> N;
  cout << dup(N, 2) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.math.BigInteger;
 
public class Main implements Runnable {
	
	//static int mod = 1000000007;

    public static void main(String[] args) {
    	new Thread(null, new Main(), "", 1024 * 1024 * 1024).start();
    }
    
    public void run() {
        FastScanner sc = new FastScanner();

        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] l = sc.nextIntArray(n);
        
        System.out.println(solve(x,l));

    }
    
    int solve(int x, int[] l){
    	int now = 0;
    	int num = 1;
    	for(int i=0;i<l.length;i++){
    		now += l[i];
    		if(now>x){
    			return num;
    		}
    		num++;
    	}
    	return num;
    }

}


class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public int[] nextIntArray(int n){
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public Integer[] nextIntegerArray(int n){
		Integer[] a = new Integer[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 23252
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstring>
#include <cctype>
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <complex>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
const double PI = 3.141592653589793238462643383279502884L;
const int LARGE_PRIME = 1000000007;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define repfn(i,a,cont,next) \
  for(auto i = (a); [=](){return(cont);}(); i = [=](){return(next);}())
#define repby(i,a,b,s) repfn(i,a,i<b,i+s)
#define repab(i,a,b) repby(i,a,b,1)
#define rep(i,b) repab(i,0,b)
#define pb push_back
#define sz(c) int((c).size())

int main(int argc, char **argv)
{
  for (;;) {
    int n;
    vi v;

    cin >> n;
    if (!n)
      break;

    while (n--) {
      int tmp;
      cin >> tmp;
      v.pb(tmp);
    }

    vi w(v);
    for (int i = 1; i < sz(v); i++) {
      v[i] = max(v[i-1] + v[i], v[i]);
    }
    cout << *max_element(all(v)) << endl;
  }
  return 0;
}

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

vector<string> visited;//ここ
vector<int> num;

int main(){
  int N,M;
  string s;
  cin >> N;

  cin >> s;
  visited.push_back(s);
  num.push_back(1);
  for (int i = 0; i < N-1; i++){
      int flag = 0;
    cin >> s;
    for (int j = 0; j < (int)visited.size(); j++){
      if (s == visited[j]){
        num[j]++;
        flag = 1;
      }
    }
    if(flag == 0){ //ここ
        visited.push_back(s);
        num.push_back(1);
    }
  }


  cin >> M;
  for (int i = 0; i < M ; i++){
    cin >>s;
    for (int j = 0; j < (int)visited.size(); j++) if (s == visited[j]) num[j]--;
  }

  int ma = 0; //ここ
  for (int i = 0; i <(int)num.size(); i++) ma = max(ma, num[i]);

  cout << ma << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	vector<long long> a(n),b(n);
	rep(i,n){ cin >> a[i]; }
	rep(i,n){ cin >> b[i]; }

	long long up = 0, down = 0;
	rep(i,n){
		if(a[i] <= b[i]) up+= (b[i] - a[i]) / 2;
		else down += a[i] - b[i];
	}
	if(up >= down) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

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

		int A = sc.nextInt();

		int[] con_bra = new int[A + 1];

		for (int i = 1; i < A; i++) {
			int let = sc.nextInt();
			con_bra[let]++;
		}

		for (int i = 1; i <= A; i++) {
			System.out.println(con_bra[i]);
		}

	}
}

Measured memory_bytes: 62120
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
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;}
const ll INF = 1LL << 60;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool f;
    f = (s[2]==s[3])&&(s[4]==s[5]);
    if(f) cout << "Yes" <<endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>

using namespace std;

bool testcase_ends() {
    vector<int> a(4);
    for (size_t i=0; i<4; ++i)
        if (scanf("%d", &a[i]) == EOF)
            return 1;

    vector<int> b(4);
    for (size_t i=0; i<4; ++i)
        scanf("%d", &b[i]);

    int hit=0, blow=0;
    for (size_t i=0; i<4; ++i)
        for (size_t j=0; j<4; ++j)
            if (a[i] == b[j])
                ++(i==j? hit:blow);

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

int main() {
    int solved=0;
    while (!testcase_ends())
        ++solved;

    return !solved;
}

Measured memory_bytes: 2608
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);}


bool solve() {
    int n;
    cin >> n;
    if (n == 0) return false;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    using P = array<int, 2>;
    vector<P> res;
    int l = 0;
    while (l < n) {
        int r = l+1;
        while (r < n and a[r-1]+1 == a[r]) r++;
        res.push_back(P{a[l], a[r-1]});
        l = r;
    }
    int m = (int)res.size();
    for (int i = 0; i < m; i++) {
        if (res[i][0] == res[i][1]) {
            printf("%d", res[i][0]);
        } else {
            printf("%d-%d", res[i][0], res[i][1]);
        }
        if (i < m-1) {
            printf(" ");
        } else {
            printf("\n");
        }
    }

    return true;
}

int main() {
    while (true) {
        if (!solve()) break;
    }
    return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using ul = uint32_t;
using ull = uint64_t;
using l = int32_t;
using ll = int64_t;
using namespace std;

int main() {
    fastIO;
    size_t k;
    cin >> k;

    string s;
    cin >> s;

    if (s.size() <= k) {
        cout << s;

    } else {
        rep(i, k) cout << s.at(i);
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3572
from fractions import gcd
lcm = lambda a,b: a*b//gcd(a,b)
A, B, C, D = map(int, input().split())
E = (A-1)//C+(A-1)//D-(A-1)//lcm(C,D)
F = B//C+B//D-B//lcm(C,D)
print(B-A+1-(F-E))

Measured memory_bytes: 5600
import numpy as np


N, M, C = map(int, input().split())

B = list(map(int, input().split()))
A = [None] * N

for n in range(N):
    A[n] = list(map(int, input().split()))

A = np.array(A)
B = np.array(B)

print(len([i for i in (np.sum(A * B, axis=1) + C).tolist() if i > 0]))


Measured memory_bytes: 21120