akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))
c = [0] * (n + 1)
for i in range(n):
  c[i + 1] = c[i] + a[i]
d = {}
for i in range(1, n + 1):
  if c[i] not in d:
    d[c[i]] = 0
  d[c[i]] += 1
result = 0
if 0 in d:
  result += d[0]
for k in d:
  if d[k] != 1:
    result += d[k] * (d[k] - 1) // 2
print(result)


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

int main() {
  int n;
  cin >> n;
  vector<int>a(n); 
  rep(i,n){
    cin>>a.at(i);
  }
  long ans=0;
  ans+=a.at(0)/2;
  a.at(0)%=2;
  rep2(i,1,n){
    if(a.at(i)>0&&a.at(i-1)>0){
      ans+=1;
      a.at(i)--;
    }
    ans+=a.at(i)/2;
    a.at(i)%=2;
  }
  cout<<ans<<endl;  
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char *argv[])
{
	int n,m,c;
	cin >> n >> m >> c;
	VL b(m);
	cin >> b;
	VVL a(n, VL(m));
	cin >> a;
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		int tmp = c;
		for (int j = 0; j < m; ++j) {
			tmp += a[i][j] * b[j];
		}
		if (tmp > 0) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n;
	int count[4][3][10]={0};
	int i,j,k,l,m;
	int b,f,r,v;	

	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		b=b-1;
		f=f-1;
		r=r-1;
		if(count[b][f][r]==0){
			count[b][f][r]=v;
		}
		else{
			count[b][f][r]=count[b][f][r]+v;
		}
	}	
	
	for(k=0;k<4;k++){
		for(l=0;l<3;l++){
			for(m=0;m<10;m++){
				printf(" %d",count[k][l][m]);
			}
			printf("\n");
		}
		if(k != 3)printf("####################\n");
	}
	return 0;
}


	

Measured memory_bytes: 612
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split(' ');
        int[] a = new int[n];
        int prev = -1;
        int ans = 0;
        int count = 1;

        for (int i = 0; i < n; i++) { 
            int tmp = int.Parse(input[i]);
            if (tmp == prev)
            {
                count++;
            }
            else
            {
                ans += count / 2;
                count = 1;
            }
            prev = tmp;
        }
        ans += count / 2;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>

using namespace std;

int gcd(int a, int b) {
	if (a < b) {
		int temp = a;
		a = b;
		b = temp;
	}
	if (b == 0) {
		return a;
	}

	return gcd(b, a % b);
}
int main() {

	//Q2
	
	int N;
	cin >> N;
	
	long long int total = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 3 == 0 || i % 5 == 0) {
			continue;
		}
		total += i;
	}

	cout << total << endl;
	

	//Q3
	/*
	int K;
	cin >> K;

	long long int total = 0;
	for (int i = 1; i <= K; i++) {
		for (int j = 1; j <= K; j++) {
			for (int k = 1; k <= K; k++) {
				int tempGcd = gcd(i, j);
				int trueGcd = gcd(tempGcd, k);

				total += trueGcd;
			}
		}
	}

	cout << total << endl;
	*/

	//Q4
	/*int N;
	string s;
	cin >>N >> s;
	if (N == 1 || N == 2 || N == 3) {
		cout << 0 << endl;
		return 0;
	}

	int patternCount = 0;

	for (int k = 2; k < N; k++) {
		for (int j = k - 1; j < k; j++) {
			for (int i = j - 1; i < j; i++) {
				if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k] && j - i != k - j) {
					patternCount++;
				}
			}
		}
	}

	cout << patternCount << endl;
	*/
	return 0;
}




Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<int,int>
#define pb push_back
#define INF INT_MAX
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
vector<ll>v;
vector<ll>vv,p;
int main () {
   ll k;cin>>k;
      f(i,1,10)v.pb(i);
      vv=v;
      while(v.size()<k){
        int n=vv.size();
         for(int i=0;i<n;i++)
         {
             ll k=vv[i]%10;
            // cout<<k<<"\n";
              if(k==0)p.pb(vv[i]*10),p.pb(vv[i]*10+1);
              else if(k==9)p.pb(vv[i]*10+8),p.pb(vv[i]*10+9);
              else
              for(int j=k-1;j<=k+1;j++)
                p.pb(vv[i]*10+j);
         }
         f(i,0,p.size())v.pb(p[i]);
         vv.clear();
         vv=p;
         p.clear();
      }
     sort(v.begin(),v.end());
     // f(i,0,100)cout<<v[i]<<" ";

      cout<<v[k-1];
}



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

ll N;

ll memo[100];
ll luka(ll n) {
	if(n == 0) return 2;
	else if (n == 1) return 1;
	else if (memo[n]!=0) return memo[n];
	else return memo[n] = luka(n-1) + luka(n-2);
}


int main(){
	cin >> N;
	ll ans = luka(N);
	cout << ans << endl;
	return 0;
}


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

int main()
{
	int bucket[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
	int x, y;
	cin >> x >> y;

	cout << (bucket[x] == bucket[y] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int cost,fund,lim;
    scanf("%d %d %d",&cost,&fund,&lim);
    if(fund/cost>lim){
        printf("%d\n",lim);
    }else{
        printf("%d\n",fund/cost);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int N;
    vi H;
    cin >> N;
    H.resize(N);
    REP(i, N)
    cin >> H[i];
    int tmp = 0;
    int ans = 0;
    REP(i, N)
    {
        if (tmp <= H[i])
        {
            tmp = H[i];
            ans++;
        }
    }
    cout << ans << endl;
    // system("pause");
}

Measured memory_bytes: 256
N = int(input())
X = int(input(),2)

def popcount(n):
    return bin(n).count('1')


def f(n):
    if n== 0:
        return 1
    count = 1
    while n!=0:
        n = n%popcount(n)
        count += 1
    return count


X_popcount = popcount(X)
X_mod_p = X%(X_popcount+1)
if X_popcount != 1:
    X_mod_m = X%(X_popcount-1)
for i in range(N):
    X_i = X ^ (1<<(N-i-1))
    if X_i == 0:
        ans = 0
    elif X>>(N-i-1)&1 == 1:
        if X_popcount == 1:
            ans = 1
        else:
            ans = f((X_mod_m-pow(2, N-i-1, X_popcount-1))%(X_popcount-1))
    else:
        ans = f((X_mod_p+pow(2, N-i-1, X_popcount+1))%(X_popcount+1))
    print(ans)

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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
const long long INF  = 1e18;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    long ans =0 ;
    for(int i=1;i<n;i++)
    {
        if(n%i==0)
        {
            ans += n/i - 1;
        }
        else
            ans += n/i;
    }
    cout<<ans;    
    return 0;
    
}
//https://www.youtube.com/watch?v=ZQqccia8bVo

Measured memory_bytes: 3648
#include <cstdio>
#include <cstring>
using namespace std;
#define S 200001
int deg[200007], vis[200007], Fa[200007];
inline int Find(register int o){//fprintf(stderr, "%d\n", o);
	return o == Fa[o] ? o : (Fa[o] = Find(Fa[o]));
}
int fastin(){
	register int i; register char ch;
	while (ch = getchar(), ch < '0' || ch > '9');
	i = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9') i = i * 10 + ch - '0';
	return i;
}
int main(){
	register int T, n, h, h2, i, a, b, c, d, u, v;
	T = 1;
	while (T--) {
		n = fastin(), h = fastin();
		memset(deg + 1, 0, sizeof(int) * (h << 1));
		memset(vis + 1, 0, sizeof(int) * (h << 1));
		h2 = h << 1;
		for (i = 1; i <= h2; ++i) Fa[i] = i;
		Fa[S] = S;
		for (i = 1; i <= n; ++i) {
			a = fastin(), b = fastin(), c = fastin(), d = fastin();
			u = (d ? d + h : b);
			v = (c ? c : a + h);
			++deg[u], vis[u] = 1;
			--deg[v], vis[v] = 1;
			Fa[Find(u)] = Find(v);
		}
		//for (i = 1; i <= h2; ++i) fprintf(stderr, "%d %d\n", deg[i], vis[i]);
		//fprintf(stderr, "GG");
		for (i = 1; i <= h; ++i) {
			if (vis[i]) {
				if (deg[i] < 0) break;
				if (deg[i] > 0) Fa[Find(i)] = S;
			}
		}
		if (i <= h) {
			puts("NO");
			continue;
		}
		//fprintf(stderr, "HH");
		for (i = h + 1; i <= h2; ++i) {
			if (vis[i]) {
				if (deg[i] > 0) break;
				if (deg[i] < 0) Fa[Find(i)] = S;
			}
		}
		if (i <= h2) {
			puts("NO");
			continue;
		}
		//fprintf(stderr, "II");
		for (i = 1; i <= h2; ++i) if (vis[i] && Find(i) != S) break;
		//fprintf(stderr, "%d\n", i);
		if (i <= h2) puts("NO");
		else puts("YES");
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        int[] a = new int[m];
        for (int i = 0; i < m; ++i) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int[] d = new int[m - 1];
        for (int i = 0; i < m - 1; ++i) {
            d[i] = a[i+1] - a[i];
        }
        Arrays.sort(d);

        int c = 0;
        for (int i = 0; i < m - n; ++i) {
            c += d[i];
        }

        System.out.println(c);
    }
}

Measured memory_bytes: 50316
#include <bits/stdc++.h>
 
//LIFE IS NOT A PROBLEM TO BE SOLVED
 
#define rep(i,a,b) for( int i = (int) a; i < (int) b; i++ )
#define PER(i,a,b) for( int i = (int) a; i >= (int) b; i-- )
#define F first
#define S second
#define mk make_pair
#define pb push_back
#define debug(a) cout << #a << " = " << a << endl;
#define debug2(a,b) cout << #a << " = " << a << " --- " << #b << " = " << b << endl;
#define debugP(a) cout << a.F << " " << a.S << endl;
#define debugV(v, n) { rep( i, 0, n ) { if(i) printf(" "); printf("%d", v[i]); } printf("\n"); }
#define debugM(mat,n,m) rep( i, 0, n ){ rep( j, 0, m ) { if(j) printf(" "); printf("%d", mat[i][j]); } printf("\n"); }
#define all(s) s.begin(), s.end()
 
using namespace std;
 
typedef long long int ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
 
const int MAX = 2e3+3;
const int mod = 1e9+7;



int main(){
	
	int x; cin >> x;
	cout << 1-x << '\n';
	
	
    return 0;
}

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

int ans=0;
int N;

void dfs(vector<vector<bool>> &graph,vector<bool> &visited,int V){
	for(int i=0;i<N;i++){
		if(visited.at(i))	continue;
		if(graph.at(V).at(i)==false)	continue;
		visited.at(i)=true;
		dfs(graph,visited,i);
		visited.at(i)=false;
	}

	bool flag=true;
	for(int i=0;i<N;i++)	if(visited.at(i)==false)	flag=false;
	if(flag)	ans++;
}

int main(){
	int M;
	cin >> N >> M;
	vector<vector<bool>> graph(N,vector<bool>(N,false));
	for(int i=0;i<M;i++){
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		graph.at(a).at(b)=true;
		graph.at(b).at(a)=true;
	}

	vector<bool> visited(N,false);
	visited.at(0)=true;
	dfs(graph,visited,0);
	cout << ans << endl;

	return 0;
}


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

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

    vector<int> v(n);
    for(int i = 0; i < n; ++i) cin >> v[i];
    v.push_back(v[0] + k);
    
    int j = 0;
    for(int i = 0; i < n; ++i)
    {
        j = max(j, v[i + 1] - v[i]);
    }

    cout << k - j << "\n";
    return 0;
}

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

int main(){
  int N;
  int s;
  cin>>N;
  int n;
  n=N;
  
  while(N%10>0){
    int a;
    a=N%10;
    N=N/10;
    s=s+a;
  }
  if(n%s==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

vector<int> A(MAX + 1);
vector<int> B;
int H = 0;

int parent(int i)
{
  return floor((double)i / 2.0);
}

int left(int i)
{
  return i * 2;
}

int right(int i)
{
  return i * 2 + 1;
}

void maxHeapify(int i)
{
  int l = left(i);
  int r = right(i);
  int largest;
  // 左の子、自分、右の子で値が最大のノードを選ぶ
  if (l <= H && A.at(l) > A.at(i))
  {
    largest = l;
  }
  else
  {
    largest = i;
  }
  if (r <= H && A.at(r) > A.at(largest))
  {
    largest = r;
  }

  if (largest != i)
  {
    swap(A.at(i), A.at(largest));
    maxHeapify(largest);
  }
}

void insert(int k)
{
  H++;
  A.at(H) = k;
  int i = H;
  while (i > 1 && A.at(parent(i)) < k)
  {
    swap(A.at(parent(i)), A.at(i));
    i = parent(i);
  }
}

int extract()
{
  int M = A.at(1);
  A.at(1) = A.at(H);
  H--;
  maxHeapify(1);
  return M;
}

int main()
{
  while (1)
  {
    string com;
    cin >> com;
    if (com == "end")
    {
      break;
    }
    else if (com.at(0) == 'i')
    {
      int k;
      cin >> k;
      insert(k);
    }
    else
    {
      B.push_back(extract());
    }
  }
  int m = B.size();
  for (int i = 0; i < m; i++)
  {
    cout << B.at(i) << endl;
  }
}


Measured memory_bytes: 20620
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
typedef unsigned long long ull;

int main(void) {
  string s;
  cin >> s;
  int n = s.size() + 1;
  vector<ull> left(n, 0), right(n, 0);
  for (int i = 1; i <= n - 1; i++) {
    if (s.at(i - 1) == '<') left.at(i) = left.at(i - 1) + 1;
  }
  for (int i = n - 2; i >= 0; i--) {
    if (s.at(i) == '>') right.at(i) = right.at(i + 1) + 1;
  }
  vector<ull> mx(n);
  ull ans = 0;
  rep(i, n) {
    mx.at(i) = max(left.at(i), right.at(i));
    ans += mx.at(i);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 12548
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>
#include<bitset>
using namespace std;
#define AMA (100000)
int H,W;
char fie[21][21];
char JOI[]="JOI";
int rui[20*20+1];
int dp[2][(1<<20)][2];
int hc;
int solve(){
  memset(dp,0,sizeof(dp));
  int now;
  int next=0;
  int ume = (1<<(W-1))-1;
  //  cout << bitset<20>(ume) << " " << bitset<20>(1<<(W-2)) << endl;
  dp[0][0][0]=1;
  for(int y=0;y<H;y++){
    for(int x=0;x<W;x++){
      now = next;
      next = now^1;
      memset(dp[next],0,sizeof(dp[next]));
      for(int st = 0; st<(1<<(W-1));st++ ){
	for(int i = 0; i < 2; i++ ){
	  if(!dp[now][st][i]) continue;
	  /*	  cout << "dp[" << x <<"," << y << "]["<<bitset<20>(st) <<"]["<<i<<"] = "
		  << dp[now][st][i] << " next:bit="<<bitset<20>(((st<<1)|1)&ume)<< " "<<fie[x][y]<<"\n";*/
	  if(fie[x][y]=='I' && (st&(1<<(W-2))) && x<W-1) continue;
	  if(fie[x][y]=='?'){
	    for(int j=0;j<3;j++){
	      if((st&(1<<(W-2))) && j==2 && x<W-1) continue;
	      if(j==1 && i==1)
	        dp[next][((st<<1)|1)&ume][0] += dp[now][st][i]%AMA;
	      else if(j==0)
		dp[next][(st<<1)&ume][1] += dp[now][st][i]%AMA;
	      else
		dp[next][(st<<1)&ume][0] += dp[now][st][i]%AMA;
	      }
	  } else if(fie[x][y]=='J') {
	    dp[next][(st<<1)&ume][1] += dp[now][st][i]%AMA;
	  } else if(fie[x][y]=='O' && i==1 ) {
	    dp[next][((st<<1)|1)&ume][0] += dp[now][st][i]%AMA;
	  } else {
	    dp[next][(st<<1)&ume][0] += dp[now][st][i]%AMA;
	  }
	}
      }
    }
  }
  int ret = 0;
  for(int st = 0; st<(1<<(W-1));st++ ){
    for(int i = 0; i < 2; i++ ){
      ret += dp[next][st][i]%AMA;
      ret %= AMA;
    }
  }
  //  cout << ret << endl;
  return ret;
}
int main(){
  cin >> H >> W;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> fie[j][i];
      if(fie[j][i]=='?') hc++;
    }
  }

  rui[1]=3;
  for(int i=2;i<=20*20;i++){
    rui[i]=rui[i-1]*3;
    rui[i]%=10000000;
  }
  cout << (rui[hc] - solve())%AMA << "\n" ;
}

Measured memory_bytes: 17560
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
int a[200000];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> a[i];

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

Measured memory_bytes: 27796
#pragma warning( disable:4996 )

#include <stdio.h>
#include <memory.h>
#define MAX_K 10000

int A[2000000];
int B[2000000];

void CountingSort(int A[], int B[], int n)
{
	int C[MAX_K+1];
	int i;
	memset(C, 0, sizeof(C));
	for (i = 0;i < n; i++)
	{
		C[A[i]]++;
	}
	for (i = 1; i <= MAX_K; i++)
	{
		C[i] = C[i] + C[i - 1];
	}
	for (i = n-1; i >= 0; i--)
	{
		B[C[A[i]]-1] = A[i];
		C[A[i]]--;
	}
	return;
}

int main()
{
	int i, n;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	memset(B, 0, sizeof(B));
	CountingSort(A, B, n);
	for (i = 0; i < n; i++) {
		if (i) printf(" ");
		printf("%d", B[i]);
	}
	printf("\n");
	return 0;
}



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

int main(){

    int n; cin >>n;
    vector<double> x(n), y(n);
    rep(i, n) cin >>x[i]>>y[i];

    double ans=0;
    int cnt=0;

    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            ans+=sqrt(pow(abs(x[i]-x[j]), 2)+pow(abs(y[i]-y[j]), 2));
            cnt++;
        }
    }

    cout << fixed << setprecision(9);
    cout << (ans/cnt)*(n-1) << endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int a, b, c, f=0;
	scanf("%d %d %d", &a, &b, &c);
	if (a == b&&a != c) {
		f = 1;
	}
	if (b == c&&b != a) {
		f = 1;
	}
	if (c == a&&c != b) {
		f = 1;
	}
	if (f == 1) {
		printf("Yes");
	}
	else {
		printf("No");
	}
}

Measured memory_bytes: 128
N = int(input())
S = input()
sum = 0
r = 0
g = 0
b = 0

for i in range(N):
    if S[i] == "R":
        r+=1
    elif S[i] == "G":
        g+=1
    else:
        b+=1

sum = r*g*b

for i in range(N):
    for j in range((N-i)//2 +1):
        try:
            a = S[i]
            b = S[i+j]
            c = S[i+2*j]
            if a!=b and b!=c and c!=a:
                sum -= 1
        except:
            continue

print(sum)

Measured memory_bytes: 9176
L = int(input())

k = L.bit_length()
ans = []
for i in range(1, k):
    ans.append([i,i+1,0])
    ans.append([i,i+1,1<<(k-i-1)])

for i in range(k-1):
    if L & 1<<i:
        mask = (1<<(k+1)) - (1<<(i+1))
        w = L & mask
        ans.append([1, k-i, w])

print(k, len(ans))
for i in ans:
    print(*i)

Measured memory_bytes: 38492
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;
	} else if(a>b){
		cout<<"a > b"<<endl;
	} else{
		cout<<"a == b"<<endl;
	}

	return 0;
}

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

int main(void){
	char str[20];
	char str2[20];
	int i = 0, j;

	scanf("%s", &str);

	i = strlen(str);

	for (j = 0; j < i; j++)
		str2[j] = str[i - j - 1];

	for (j = 0; j < i; j++)
		printf("%c", str2[j]);

	printf("\n");
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define mod 1000000007
#define pi 3.14159265359
#define pb push_back
using namespace std;
vector <long long int> prm;
bool prime[10000001];
int binarySearch(int arr[], int l, int r, int x)
{
    while (l <= r)
    {
        int m = l + (r - l) / 2;
        if (arr[m] == x)
            return m;
        if (arr[m] < x)
            l = m + 1;
        else
            r = m - 1;
    }
    return -1;
}
void SieveOfEratosthenes(int n)
{
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == false)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = true;
        }
    }
    for (int p=2; p<=n; p++)
        if (!prime[p])
          prm.pb(p);
}
long long int fact(int n)
{
    int res = 1;
    for (int i = 2; i <= n; i++)
        res = res * i;
    return res;
}
long long binomialCoeff(long long n, long long k)
{
    long long C[n + 1][k + 1];
    long long i, j;
    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {
            if (j == 0 || j == i)
                C[i][j] = 1;
            else
                C[i][j] = (C[i - 1][j - 1] + C[i - 1][j])%mod;
				C[i][j]%= mod;
        }
    }
    return C[n][k];
}
int countDigit(long long n)
{
    int count = 0;
    while (n != 0)
    {
        n = n / 10;
        ++count;
    }
    return count;
}
long long int power(int a, int b)
{
    long long k=1;
    for(int i=0; i<b; i++)
    {
        k*=a;
        k%=mod;
    }
    return k;
}
long long int maxSubArraySum(long long int a[],long long int size)
{
   long long int max_so_far = 0, max_ending_here = 0;
   for (int i = 0; i < size; i++)
   {
       max_ending_here = max_ending_here + a[i];
       if (max_ending_here < 0)
           max_ending_here = 0;
       else if (max_so_far < max_ending_here)
           max_so_far = max_ending_here;
   }
   return max_so_far;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long int n,a=0,b=0,c=0,d=0;
	cin>>n;
	string s;
	for(int i=0; i<n; i++)
    {
        cin>>s;
        if(s=="AC")
            a++;
        else if(s=="WA")
            b++;
        else if(s=="TLE")
            c++;
        else
            d++;
    }
    cout<<"AC x "<<a<<"\n";
    cout<<"WA x "<<b<<"\n";
    cout<<"TLE x "<<c<<"\n";
    cout<<"RE x "<<d<<"\n";
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
 
using std::cout;
using std::cin;
 
 
 
void oneCase () {
    int a;
 	cin >> a;
 
    cout <<  a * a << "\n";
}
 
 
int main() {
    int k = 1;
//    cin >> k;
    for (int i = 0; i < k; ++i) {
        oneCase();
    }
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
 	return 0;
 }


Measured memory_bytes: 768
void main() {
	auto b = rs;
	switch(b) {
		case "A": writeln("T"); break;
		case "T": writeln("A"); break;
		case "G": writeln("C"); break;
		case "C": writeln("G"); break;
		default: break;
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

// 組み合わせ (combination) を求める
ll nCr(ll n, ll r) {
  if (r > n) {
    return 0;
  }
  if (r == 0 || n == r) {
    return 1;
  }
  if (r * 2 > n) {
    r = n - r;
  }

  ll result = n;
  for (ll i = 2; i <= r; i++) {
    result *= (n - i + 1);
    result /= i;
  }
  return result;
}

ll N;
map<string, ll> mp;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }

  ll ans = 0;
  for (auto &e : mp) {
    ans += nCr(e.second, 2);
  }

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

Measured memory_bytes: 13312
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

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

    vector<ll> s(a), t(b);
    for(int i = 0; i < a; i++)  cin >> s[i];
    for(int i = 0; i < b; i++)  cin >> t[i];

    ll x;
    while(q-- > 0){
        cin >> x;
        vector<ll> shrine, temple;
        auto ls = lower_bound(s.begin(), s.end(), x);
        auto rs = ls;
        if(ls != s.begin()) ls--;
        shrine.push_back(*ls);  
        shrine.push_back(*rs);  
        
        auto lt = lower_bound(t.begin(), t.end(), x);
        auto rt = lt;
        if(lt != t.begin()) lt--;
        temple.push_back(*lt);
        temple.push_back(*rt);

        ll dist = 1ll<<60;
        for(int i = 0; i < 2; i++){
            for(int j = 0; j < 2; j++){
                if( ((x-temple[i])>0&&(x-shrine[j])>0) || ((x-temple[i])<0&&(x-shrine[j])<0)){
                    dist = min(dist, max(abs(x-temple[i]), abs(x-shrine[j])));
                }else{
                    ll tmpa = abs(x-temple[i]), tmpb = abs(x-shrine[j]);
                    if(tmpa > tmpb) swap(tmpa, tmpb);
                    dist = min(dist, 2*tmpa+tmpb);
                }
            }
        }
        cout << dist << endl;
    }

    return 0;
}


Measured memory_bytes: 2944
# include <iostream>
using namespace std;
int abs(int a)
{
	return a>=0?a:-a;
}
int main()
{
	int x=0,n=0,ls=0;
	cin>>x;
	x=abs(x);
	while(n<x)
	{
		ls++;
		n+=ls;
	}
	cout<<ls;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<long long int> A(N), cumsum(N + 1, 0), cumxor(N + 1, 0);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		cumsum[i + 1] = cumsum[i] + A[i];
		cumxor[i + 1] = cumxor[i] ^ A[i];
	}

	long long int ans = 0;
	int j = 1;
	for (int i = 0; i < N; i++) {
		while (j < N && cumsum[j + 1] - cumsum[i] == (cumxor[j + 1] ^ cumxor[i])) {
			j++;
		}
		ans += j - i;
	}

	cout << ans << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 5120
// C - Five Transportations

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	ll N, A, B, C, D, E;
	cin >> N >> A >> B >> C >> D >> E;

	ll M = min(A, min(B, min(C, min(D, E))));

	ll ans = 5 + (N-1) / M;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

ll power(ll x,ll n){
    if(n==0) return 1;
    ll res=power(x*x%mod,n/2);
    if(n&1) res=res*x%mod;
    return res;
}

int main() {
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  int b[n];
  rep(i,0,n) b[i]=a[i];
  
  vector<int> prime;
  bool is_prime[1000000+1];
  rep(i,0,1000000+1) is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  rep(i,2,1000000+1){
    if(is_prime[i]){
      prime.push_back(i);
      for(int j=2*i;j<=1000000;j+=i) is_prime[j]=false;
    }
  }
  int k=prime.size();
  
  vector<P> res[n];
  rep(i,0,n){
    for(int j=2;j*j<=a[i];j++){
      if(a[i]%j==0){
        res[i].push_back(P(j,0));
        while(a[i]%j==0){
          res[i][res[i].size()-1].second++;
          a[i]/=j;
        }
      }
    }
    if(a[i]!=1) res[i].push_back(P(a[i],1));
  }
  
  map<int,int> c;
  rep(i,0,n){
    rep(j,0,res[i].size()){
      c[res[i][j].first]=max(c[res[i][j].first],res[i][j].second);
    }
  }
  
  ll gcd=1;
  rep(i,0,k) gcd=gcd*power(prime[i],c[prime[i]])%mod;
  ll ans=0;
  rep(i,0,n) ans=(ans+power(b[i],1e9+5))%mod;
  
  cout<<gcd*ans%mod<<endl;
}


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

int main(){
  int n; cin>>n;
  if (n==0){
    cout<<0<<endl;
    return 0;
  }
  
  string ans="";
  while (n!=0){
    int r=n%(-2);
    if (r<0) r+=2;
    ans+=(char)('0'+r);
    n-=r;
    n=n/(-2);
  }
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
}

Measured memory_bytes: 256
''' Hey stalker :) '''
INF = 10**10
def main():
    print = out.append
    ''' Cook your dish here! '''
    h, n = get_list()
    print((h+n-1)//n)



''' Pythonista fLite 1.1 '''
import sys
#from collections import defaultdict, Counter
#from bisect import bisect_left, bisect_right
#from functools import reduce
#import math
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
#[main() for _ in range(int(input()))]
print(*out, sep='\n')


Measured memory_bytes: 38256
#!/usr/bin/env python
# coding: utf-8

# In[1]:


import heapq


# In[2]:


D, G = map(int, input().split())


# In[3]:


p = [0] * D
c = [0] * D
for i in range(D):
    p[i], c[i] = map(int, input().split())


# In[4]:


total = [100*(i+1)*p[i] + c[i] for i in range(D)]
total


# In[8]:


ans = []
for i in range(2 ** D):
#     print(i)
    point = 0
    mondaisu = 0
    nokori = []
    for j in range(D):
        if i % 2 == 1:
            point += total[j]
            mondaisu += p[j]
        else:
            heapq.heappush(nokori, (-100 * (j+1) * (p[j]-1), j))
        i //= 2
#     print(point, mondaisu, nokori)
    if point >= G:
        ans.append(mondaisu)
    else:
        po, ind = heapq.heappop(nokori)
        if point + (-po) >= G:
            ans.append(mondaisu + (G-point+100*(ind+1)-1)//(100*(ind+1)) )
#             print(G - point, 100 * (ind+1))
        


# In[9]:


ans


# In[10]:


print(min(ans))


# In[ ]:





# In[ ]:






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

int main(){
	string s;
	cin >> s;
	deque<char> dq;
	for(int i=0;i<s.size();i++) dq.push_back(s[i]);
	int q;
	cin >> q;
	int balik = 0;
	while(q--){
		int com;
		cin >> com;
		if(com == 1){
			balik ^= 1;
		} else {
			int f;
			char c;
			cin >> f >> c;
			f--;
			f^=balik;
			if(f == 0) dq.push_front(c);
			else dq.push_back(c);
		}
	}
	string ans="";
	while(!dq.empty()){
		ans += dq.front(); dq.pop_front();
	}
	if(balik) reverse(ans.begin(),ans.end());
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1412
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pll pair<ll,ll>
#define vll vector<ll,ll>
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define sz(x) (ll)x.size()
#define hell 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>b;i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define gcd(a,b) __gcd((a),(b))
#define EPS 1e-12
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define sqrt sqrtl
#define mod 1000000007
#define cbrt cbrtl
using namespace __gnu_pbds;
using namespace std;


int main()
{
  IOS
  string s;
  cin>>s;
  ll l=s.length();
  ll i;
  ll ans=0;
  ll last=0;
  i=0;
   ll cnt=0;
   char x=s[i];
   while(i<l && s[i]==x)
   {
      cnt++;
      i++;
   }
   if(x=='>')
    last=0;
   else
     last=cnt;
     ans+=((cnt*(cnt+1))/2);

   for(;i<l;)
   {
     cnt=0;
     char x=s[i];
     while(i<l && s[i]==x)
     {
        cnt++;
        i++;
     }
     if(x=='<')
     {
        ll f=last+cnt;
        ans+=((f*(f+1))/2);
        ans-=((last*(last+1))/2);
        last=f;
     }
     else
     {
        if(cnt<=last)       
        {
          last=0;
          ans+=((cnt*(cnt-1))/2);
        }
        else
        {
           ans+=((cnt*(cnt+1))/2);
           ans-=last;
           last=0;
        }
     }
     //cout<<ans<<" "<<last<<"\n";
   } 
    cout<<ans;
  return 0;      
}

Measured memory_bytes: 1172
#!/usr/bin/env python3
import sys


def solve(N: int):
    n = N % 10
    if n in [2, 4, 5, 7, 9]:
        return 'hon'
    if n in [0, 1, 6, 8]:
        return 'pon'
    return 'bon'

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(solve(N))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 8988
#include <iostream>

using namespace std;

int main()
{
	string s;
	cin >> s;
	int n = s.length();
	int ans = 0;
	for (int i = 0; i < n / 2; i++)
	{
		if (s[i] != s[n - i - 1])
			ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;

	if (a >= 13) {
		cout << b << endl;
	}
	else if (a <= 5) {
		cout << 0 << endl;
	}
	else {
		cout << b / 2 << endl;
	}
}



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

#define each(i, c) for (auto& i : c)

typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9+7;


int main() {
  ll n, k, s;
  cin >> n >> k >> s;

  ll dummy = 1e9;
  if (s == dummy) dummy = 1;

  for (ll i = 0; i < k; ++i) {
    cout << s << " ";
  }
  for (ll i = k; i < n; ++i) {
    cout << dummy << " ";
  }
  cout << endl;
  
  return 0;
}

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

int main() {


//long long a,b;
//int *num=new int[4];
//char *s=new char[3];
string s;
cin >> s;

//if (s.find("AC") != std::string::npos) {

int n=(int)(s.length());
int res=0;
for(int i=0;i<n;i++){
if(s[i]=='1')res++;

}
cout << res;



}


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

int main(){
  //所持金x、a円のドーナツ、b円のドーナツ
  int x, a, b;
  cin >> x >> a >> b;
  //残り金
  int ans = (x - a) % b;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


int main() {
  // √a+√b<√c ⇔ 2*√a*√b < c-a-b;
  ll a,b,c; cin >>a >>b >>c;
  if (c-a-b <= 0){
    cout <<"No" <<endl; return 0;
  }
  // 両辺正
  // 4*a*b < (c-a-b)^2
  cout <<(4*a*b < (c-a-b)*(c-a-b) ? "Yes" : "No") <<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ab = [0] * N
for i in range(N):
    ab[i] = B[i] - A[i]
m = sum(ab)
ab = sorted(ab, reverse=True)
import math
f, g = 0, 0
for c in ab:
    if c > 0:
        f += math.ceil(c/2)
    elif c < 0:
        g += -c
if max(f, g) <= m:
    result = "Yes"
else:
    result = "No"
print(result)

Measured memory_bytes: 4660
N = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

excess = 0
for i in range(N):
    dif = a[i]-b[i]
    if dif < 0:
        excess += abs(dif)//2
    elif 0 < dif:
        excess -= dif

if 0<=excess:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 4596
import sys
e=[list(map(int,e.split()))for e in sys.stdin]
n=e[0][0]+1
t=''
for c in e[1:n]:
 for l in zip(*e[n:]):t+=f'{sum(s*t for s,t in zip(c,l))} '
 t=t[:-1]+'\n'
print(t[:-1])


Measured memory_bytes: 6796
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        // check line number to insert new line
        int lineCount = 1;
        while (sc.hasNextLine()) {

            // input
            String[] line = sc.nextLine().split(" ");
            int fromYear = Integer.parseInt(line[0]);
            int toYear = Integer.parseInt(line[1]);

            // input:both fromYear and toYear are zero, process end
            if (fromYear == 0 && toYear == 0) {
                break;
            }

            // insert new line
            if (lineCount++ != 1) {
                System.out.println();
            }

            int leapCount = 0;
            // judge leap year. then print the year
            for (int year = fromYear; year <= toYear; year++) {
                if (isLeapYear(year)) {
                    System.out.println(year);
                    leapCount++;
                }
            }

            // case non leap year, print "NA"
            if (leapCount == 0) {
                System.out.println("NA");
            }

        }
        sc.close();
    }

    /**
     * check argument whether leap year
     */
    private static boolean isLeapYear(int year) {
        if (year % 400 == 0) {
            return true;
        }

        if (year % 100 == 0) {
            return false;
        }

        if (year % 4 == 0) {
            return true;
        }

        return false;

    }
}

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

template<long long mod>
struct mint {
private:
    long long x;
public:
    mint(long long x = 0) :x((mod+x)%mod) {}
    mint(std::string &s) {
        long long z = 0;
        for (int i = 0; i < s.size(); i++) {
            z *= 10;
            z += s[i] - '0';
            z %= mod;
        }
        this->x = z;
    }
    mint& operator+=(const mint &a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint &a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint &a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint& operator/=(const mint &a) {
        long long n = mod - 2;
        mint<mod> u = 1, b = a;
        while (n > 0) {
            if (n & 1) {
                u *= b;
            }
            b *= b;
            n >>= 1;
        }
        return *this *= u;
    }
    mint operator+(const mint &a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint &a) const {
        mint res(*this);
        return res *= a;
    }
    mint operator/(const mint &a) const {
        mint res(*this);
        return res /= a;
    }
    friend std::ostream& operator<<(std::ostream &os, const mint &n) {
        return os << n.x;
    }
    bool operator==(const mint &a) const {
        return this->x == a.x;
    }
};

//pow
template<typename T, typename U>
T pow(T k, U n, T unity = 1) {
    while (n > 0) {
        if (n & 1) {
            unity *= k;
        }
        k *= k;
        n >>= 1;
    }
    return unity;
}

int main() {
    constexpr int MOD = 1e9 + 7;
    int n;cin >> n;
    vector<ll> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(c.begin(), c.end());
    mint<MOD> ans = 0;
    for (int i = 0; i < n; i++) {
        ans += mint<MOD>(n-i+1) * c[i];
    }
    ans *= pow(mint<MOD>(2),2 * n - 2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
input = gets.chomp.split(" ")
wx = input[0].to_i
hy = input[1].to_i
x = input[2].to_i
y = input[3].to_i
r = input[4].to_i
right = x + r
left = x - r
top = y + r
under = y - r
if right <= wx && left >= 0 && top <= hy && under >= 0
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 8680
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>

#define INIVAL  2147483647

const int pow2[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824,};

int *a;

int x, y;

int find_min(int k, int l, int r)
{
  int u, v;
  if (r<x || y<l) return INIVAL;
  if (x<=l && r<=y) return a[k];
  else {
    int t=(l+r)>>1;
    u = find_min(k<<1, l, t);
    v = find_min((k<<1)+1, t+1, r);
    if (u>v) u = v;
    return u;
  }
}

int main()
{
  int i, k, n, z;
  char buf[32], *p;
  buf[31] = 0;
  buf[30] = '\n';
  fgets(buf, 32, stdin);
  for (n=0,p=buf; *p!=' '; n=n*10+*(p++)-'0');
  int s = 1;
  if (n>=2) s=pow2[(int)ceil(log2(n))];
  a = (int*)malloc(sizeof(int)*(s+n));
  for (i=0; i<=(s+n+1); i++)    a[i] = INIVAL;
  
  while (fgets(buf, 32, stdin)) {
    for (x=0,p=buf+2; *p!=' '; x=x*10+*(p++)-'0');
    for (y=0,p++; *p!='\n'; y=y*10+*(p++)-'0');

    if (buf[0]=='0') { // update xi, yi
      k=s+x;
      if (a[k>>1]<a[k] && a[k>>1]<y) {
	a[k]=y;
      } else {
	for (a[k]=y; k>1; a[k]=z) {
	  int j=(k>>1)<<1;
	  z = a[j];
	  if (z>a[j+1]) z=a[j+1]; 
	  k>>=1;
	}
      }
    } else { // find xi, yi
      x++;
      y++;
      z = x==y?a[s+x-1]:find_min(1, 1, s);
      if (z==0) {
	putc_unlocked('0', stdout);
	putc_unlocked('\n', stdout);
      } else {
	for (i=30; z>0; buf[--i]='0'+z%10,z/=10);
	fputs_unlocked(buf+i, stdout);
      }
    }
  }
  return 0;
}



Measured memory_bytes: 2640