akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args)
	{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		MyScanner in = new MyScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Solver solver = new A();
		solver.solve(1, in, out);
		out.close();
	}
	
	static class A implements Solver
	{
		public void solve(int testNumber, MyScanner in, PrintWriter out)
		{
			int x = in.nextInt();
			out.println(1 - x);
		}
	}

	static class UnionFind
	{
		int[] par;
		int[] n_nodes;
		int max = 1;
		
		public UnionFind(int n)
		{
			par = new int[n];
			n_nodes = new int[n];
			for( int i=0; i<n; i++ )
			{
				par[i] = i;
				n_nodes[i] = 1;
			}
		}
		
		int root(int x)
		{
			if( par[x] == x ) return x;
			return par[x] = root(par[x]);
		}
		
		void unite(int x, int y)
		{
			int rx = root(x);
			int ry = root(y);
			if( rx == ry ) return;
			par[rx] = ry;
			n_nodes[ry] += n_nodes[rx];
			max = Math.max(max, n_nodes[ry]);
		}
		
		boolean same(int x, int y)
		{
			int rx = root(x);
			int ry = root(y);
			return rx == ry;
		}
	}
	
	static class MyScanner
	{
		private BufferedReader in;
		private StringTokenizer st;
		
		public MyScanner(InputStream stream)
		{
			in = new BufferedReader(new InputStreamReader(stream));
		}
		
		public String next()
		{
			while( st == null || !st.hasMoreTokens() )
			{
				try
				{
					String rl = in.readLine();
					if( rl == null )
					{
						return null;
					}
					st = new StringTokenizer(rl);
				}
				catch( IOException e )
				{
					return null;
				}
			}
			return st.nextToken();
		}
		
		public int nextInt()
		{
			return Integer.parseInt(next());
		}
	}
	
	static interface Solver
	{
		public void solve(int testNumber, MyScanner in, PrintWriter out);
	}
}


Measured memory_bytes: 32648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll memo[105][100005];
ll value[105];
ll weight[105];
int main()
{
    ll n,w;
    cin>>n>>w;
    for(int i=0;i<n;i++)
    {
        cin>>weight[i]>>value[i];
    }
    ll tot=0;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=100000;j++)
        {
            if(i==0 || j==0) memo[i][j]=1e18;
            else
            {
                if(j<=value[i-1])
                {
                    memo[i][j]=min(memo[i-1][j],weight[i-1]);
                }
                
                else if(j<=tot+value[i-1])
                {
                    memo[i][j]=min(memo[i-1][j],memo[i-1][j-value[i-1]]+weight[i-1]);
                }
                else
                {
                    memo[i][j]=1e18;
                }
                tot+=value[i-1];
            }
        }
    }
    
    ll ans=-1;
    
    for(int i=100000;i>=0;i--)
    {
        if(memo[n][i]<=w)
        {
            ans=i;
            break;
        }
    }
    printf("%lld\n",ans);
    
    
    
}


Measured memory_bytes: 80128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<ll> A(N);
  for(int i=0; i<N; i++) cin >> A[i];
  ll now = 1000;
  for(int i=1; i<N; i++){
    if(A[i-1] < A[i]){
      now = now/A[i-1]*A[i] + now%A[i-1];
    }
  }
  cout << now << "\n";
  return 0;
}


Measured memory_bytes: 3652
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, k; cin >> n >> k;
  int ans = k;
  FOR(i, 1, n) ans *= k - 1;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int coin[]={10,50,100,500};
int main(){
	int a[4],b[4];
	int pay;
	bool fir=true;
	while(cin>>pay,pay){
		if(!fir)cout<<endl;
		fir=false;
		int s=0;
		for(int i=0;i<4;i++){
			cin>>a[i];
			s+=a[i]*coin[i];
		}
		s-=pay;
		for(int i=4;i--;){
			b[i] = s/coin[i];
			s%=coin[i];
		}
		for(int i=0;i<4;i++){
			int t = a[i]-b[i];
			if(0<t)cout<<coin[i]<<' '<<t<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int judge (int x, int y, int z) {
  // calc max;
  if (x > y && x > z) {
    return x*x == y*y + z*z;
  } else if (y > z && y > x) {
    return y * y == x * x + z * z;
  } else if (z > y && z > x) {
    return z * z == y*y + x * x;
  } else {
    return 0;
  }  
}
int main (int ac, char **av) {
  
  while (feof(stdin) == 0) {
    int n = 0;
    fscanf(stdin, "%d\n", &n);
    int i = 0;
    for (i = 0; i < n; i++) {
      int x,y,z = 0;
      fscanf(stdin, "%d %d %d\n", &x, &y, &z);
      int b = judge(x,y,z);
      if (b) fprintf(stdout, "YES\n"); 
      else fprintf(stdout,"NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= int(b); i++)
#define per(i, a, b) for (int i = (a); i >= int(b); i--)
#define fi first
#define se second
using namespace std;

typedef long long ll;
const int maxn = 2e5, mod = 998244353;
int n, f[maxn + 3], mx[maxn + 3], se[maxn + 3], g[maxn + 3];
int far[maxn + 3], h[maxn + 3][3][3], t[3][3];
vector<int> G[maxn + 3];

void dfs(int u, int p = 0) {
	rep(i, 0, G[u].size() - 1) {
		int v = G[u][i];
		if (v == p) continue;
		dfs(v, u);
		f[u] = max(f[u], f[v] + 1);
		if (!mx[u] || f[v] >= f[mx[u]]) {
			se[u] = mx[u], mx[u] = v;
		} else if (!se[u] || f[v] >= f[se[u]]) {
			se[u] = v;
		}
	}
}

void down(int u, int p = 0) {
	rep(i, 0, G[u].size() - 1) {
		int v = G[u][i];
		if (v == p) continue;
		if (v == mx[u]) {
			g[v] = max(g[u], f[se[u]] + 1) + 1;
		} else {
			g[v] = max(g[u], f[mx[u]] + 1) + 1;
		}
		down(v, u);
	}
	g[u] = max(f[u], g[u]);
}

void work(int u, int p = 0) {
	rep(i, 0, G[u].size() - 1) {
		int v = G[u][i];
		if (v == p) continue;
		work(v, u);
		far[u] = max(far[u], far[v] + 1);
	}
	if (!far[u]) { h[u][1][1] = 1; return; }
	h[u][0][0] = 1;
	rep(i, 0, G[u].size() - 1) {
		int v = G[u][i];
		if (v == p) continue;
		memset(t, 0, sizeof(t));
		rep(a, 0, 2) rep(b, 0, 2) if (h[u][a][b]) {
			rep(c, 0, 2) rep(d, 0, 2) if (h[v][c][d]) {
				int x = 1ll * h[u][a][b] * h[v][c][d] % mod;
				rep(e, -1, 1) {
					int t1 = min(2, (far[v] + e == far[u]) ? a + c : a);
					int t2 = min(2, (far[v] - e == far[u]) ? b + d : b);
					t[t1][t2] += x, t[t1][t2] >= mod ? t[t1][t2] -= mod : 0;
				}
			}
		}
		memcpy(h[u], t, sizeof(h[u]));
	}
}

int main() {
	scanf("%d", &n);
	rep(i, 1, n - 1) {
		int u, v; scanf("%d %d", &u, &v);
		G[u].push_back(v), G[v].push_back(u);
	}
	f[0] = -1;
	dfs(1);
	down(1);
	int mn = n;
	rep(i, 1, n) mn = min(mn, g[i]);
	int a = 0, b = 0, c = 0;
	rep(i, 1, n) if (g[i] == mn) {
		if (++c == 1) a = i;
		else if (c == 2) b = i;
		else exit(1);
	}
	if (c == 1) {
		work(a);
		printf("%d\n", int(1ll * (mod + 1) / 2 * h[a][1][1] % mod));
	} else {
		work(a, b), work(b, a);
		printf("%d\n", int(((ll)h[a][1][0] + h[a][1][1] + h[a][1][2]) * ((ll)h[b][1][0] + h[b][1][1] + h[b][1][2]) % mod));
	}
	return 0;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(12)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}



int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<pair<ld,pair<ld,ld>>>k(n);
  rep(i,0,n){
    cin>>k[i].se.fi>>k[i].se.se;
    ld x=k[i].se.fi;
    ld y=k[i].se.se;
    if(x==0&&y==0)k[i].fi=0;
    else k[i].fi=atan2(y,x);
  }
  ld PI=3.1415926535897;
  ld eps=1e-14;
  ld ret=0;
  sort(ALL(k));
  rep(i,0,n){
    ld x=0,y=0;
    rep(j,0,n){
      ld p=k[(i+j)%n].fi;
      ld z=k[(i+j)%n].se.fi;ld zz=k[(i+j)%n].se.se;
      x+=z;
      y+=zz;
      chmax(ret,sqrt(x*x+y*y));
    }
  }
  cout lfs ret<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <bits/stdc++.h> 

using namespace std;

int main(){
    int N;
    cin>>N;
    string S;
    cin>>S;
    int ans=0;
    for (int i=0;i<N-2;i++){
        if (S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // 入力処理
        Scanner sc = new Scanner(System.in);
        
        String str = sc.nextLine();

        String[] words = {"eraser", "erase", "dreamer", "dream"};

        for (String word : words) {
            if (str.matches(".*" + word + ".*")) {
                str = str.replaceAll(word, "");
            }
        }

        if (str.length() == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int IINF = 2002002002;
constexpr ll LINF = 9009009009009009009LL;

//===


ll MOD = 1000000007LL;
ll dp[110][11] = {};


int main()
{
	int H, W, K;
	cin >> H >> W >> K;

	dp[0][0] = 1;
	int nc = 1 << (W  - 1);
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			ll x = 0, y = 0, z = 0;
			for (int k = 0; k < nc; ++k) {
				if (k & (k << 1)) continue;
				if (j > 0) {
					if ((k >> (j - 1)) & 1) {
						++x;
						continue;
					}
				}
				if (j < W - 1) {
					if ((k >> j) & 1) {
						++z;
						continue;
					}
				}
				++y;
			}

			if (j > 0) {
				dp[i + 1][j - 1] += dp[i][j] * x % MOD;
				dp[i + 1][j - 1] %= MOD;
			}
			if (j < W - 1) {
				dp[i + 1][j + 1] += dp[i][j] * z % MOD;
				dp[i + 1][j + 1] %= MOD;
			}
			dp[i + 1][j] += dp[i][j] * y % MOD;
			dp[i + 1][j] %= MOD;
		}
	}

	cout << dp[H][K - 1] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
typedef unsigned long long ull;
const ull B = 1e9+7;
char s[1111111];
int len;
ull a[1111111];
ull h[1111111];
ull Bh[1111111];
int main(void) {
	int res = -1;
	 int i,al,bl;
  scanf("%s", s);
  len = strlen(s);
  Bh[0] = 1;

   for (i = 0; i < len; i++) {
     h[i+1] = h[i]*B + s[i];
     Bh[i+1] = Bh[i]*B;
   }

   for (i = 1; i*3 < len; i++) {
     if ((len - i*3)%2 != 0 || len - i*3 <= 0) continue;
     al = i;
     bl = (len - i*3)/2;
     if (h[al] == h[al+bl + al]-h[al+bl]*Bh[al] &&
         h[al+bl + al]-h[al+bl]*Bh[al] == h[al*2+bl*2+al]-h[al*2+bl*2]*Bh[al] &&
         h[al+bl]-h[al]*Bh[bl] == h[al*2+bl + bl]-h[al*2+bl]*Bh[bl]) {
       if (res == -1 || res > al+bl) {
         res = al+bl;
       }
     }
      }

      if (res < 0) {
        puts("mitomerarenaiWA");
      } else {
        printf("Love ");
        for (int i = 0; i < res; i++) {
          printf("%c", s[i]);
        }
        puts("!");
      }
      return 0;
}

Measured memory_bytes: 18452
N = int(input())

c = [[0 for _ in range(10)] for _ in range(10)]

for i in range(1, N+1):
  c[int(str(i)[0])][int(str(i)[-1])] += 1

cnt = 0
for i in range(10):
  for j in range(10):
    cnt += c[i][j] * c[j][i]
print(cnt)

Measured memory_bytes: 3064
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt

from sys import exit

from copy import deepcopy
import numpy as np

import bisect
import re
import heapq


from copy import deepcopy
import itertools

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))






def main():
    r = ii()
    print(r**2)





main()


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

const int N = 1e5 + 8;



int32_t main(){
  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);  

    int n , m;
    cin >> n >> m;
    priority_queue < int > Q; 
    for(int i = 0 ; i < n ; i++){
        int x ; cin >> x;
        Q.push(x);
    }
    while(m--){
        int x = Q.top() ; Q.pop();
        Q.push(x >> 1);
    }
    int s = 0;
    while(Q.size() > 0){
        s += Q.top();
        Q.pop();
    }
    
    cout << s << "\n";

  return 0;
}




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

int main(){
  int n,t,e,time,ans = -1;
  cin >> n >> t >> e;
  for(int i=1;i<=n;i++){
    cin >> time;
    for(int j=1;time*j<=t+e;j++){
      if(time*j >= t-e){
	ans = i;
	break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1164
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;

int a[10][10];
int rem, n;
bool big(int x, int y, int r){
    bool res = true;
    if(x - 2 < 0 || x + 2 >= 10 || y - 2 < 0 || y + 2 >= 10)return false;
    for(int i = x - 2;i <= x + 2;i++)
	for(int j = y - 2;j <= y + 2;j++)
	    if(abs(x - i) + abs(y - j) <= 2){		
		a[i][j] += r;
		rem += r;
		if(a[i][j] < 0)res = false;
	    }
    if(!res)big(x, y, -r);
    return res;
}

bool small(int x, int y, int r){
    bool res = true;
    if(x - 1 < 0 || x + 1 >= 10 || y - 1 < 0 || y + 1 >= 10)return false;
    for(int i = x - 1;i <= x + 1;i++)
	for(int j = y - 1;j <= y + 1;j++)
	    if(abs(x - i) + abs(y - j) <= 1){
		a[i][j] += r;
		rem += r;
		if(a[i][j] < 0)res = false;
	    }
    if(!res)small(x, y, -r);
    return res;
}

bool middle(int x, int y, int r){
    bool res = true;
    if(x - 1 < 0 || x + 1 >= 10 || y - 1 < 0 || y + 1 >= 10)return false;
    for(int i = x - 1;i <= x + 1;i++)
	for(int j = y - 1;j <= y + 1;j++){
	    a[i][j] += r;
	    rem += r;
	    if(a[i][j] < 0)res = false;
	}
    if(!res)middle(x, y, -r);
    return res;
}

typedef pair<int, int> P;
typedef pair<P, int> T;

vector<T> ans;

bool solve(int n,int p = 0, int q = 0){
    if(rem > 13 * n)return false;
    if(p - 2 >= 0 && q - 1 >= 0 && a[p - 2][q - 1])return false;
    for(int i = p;i < 10;i++){
	for(int j = 0;j < 10;j++){
	    if(a[i][j] == 0)continue;
	    if(big(i, j, -1)){
		ans.push_back(T(P(i, j), 3));
		if(solve(n - 1, i, j))return true;
		ans.pop_back();
		big(i, j, 1);
	    }
	    if(middle(i, j, -1)){
		ans.push_back(T(P(i, j), 2));
		if(solve(n - 1, i, j))return true;
		ans.pop_back();
		middle(i, j, 1);
	    }
	    if(small(i, j, -1)){
		ans.push_back(T(P(i, j), 1));
		if(solve(n - 1, i, j))return true;
		ans.pop_back();
		small(i, j, 1);
	    }
	}
    }
    return (n == 0);
}

int main(){
    cin >> n;
    for(int i = 0;i < 10;i++)
	for(int j = 0;j < 10;j++){
	    cin >> a[i][j];
	    rem += a[i][j];
	}
    
    solve(n);
    for(int i = 0;i < ans.size();i++){
	cout << ans[i].first.second << " "<< ans[i].first.first << " "<<ans[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 1200
def main():
    k = int(input().strip())
    x = 7 % k
    ans = -1
    for n in range(1, k + 1):
        if x == 0:
            ans = n
            break
        x = (10 * x + 7) % k

    print(ans)
    return


if __name__ == "__main__":
    main()


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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a + b) % 2 == 0) {
    cout << (a + b) / 2 << endl;
  } else {
    cout << (a + b) / 2 + 1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
int f(int num) {
    if(num == 0) return 0;
    string S;
    while(num > 0) {
        S += (char)(num % 2 + '0');
        num /= 2;
    }
    reverse(S.begin(), S.end());
    int N = S.length();
    int cnt = 0;
    rep(i, N) {
        if(S[i] % 2) cnt++;
    }
    if(cnt == 0) return 0;
    int ret = 0;
    int times = 1;
    rep(i, N) {
        int num = S[N - i - 1] - '0';
        ret = (ret + (times * num)) % cnt;
        times = (times * 2) % cnt;
    }
    return ret;
}

int f2(int num) {
    int ret = 0;
    while(num > 0) {
        num = f(num);
        ret++;
    }
    return ret;
}

int ans[200010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string X; cin >> X;

    int cnt = 0;
    rep(i, N) {
        if(X[i] == '1') cnt++;
    }
    int times = 1;
    int cnt1 = cnt + 1, cnt0 = cnt - 1;
    int ans1 = 0, ans0 = 0;
    rep(i, N) {
        int num = X[N - i - 1] - '0';
        ans1 = (ans1 + (times * num)) % cnt1;
        times = (times * 2) % cnt1;
    }
    times = 1;
    rep(i, N) {
        if(cnt0 == 0) break;
        int num = X[N - i - 1] - '0';
        ans0 = (ans0 + (times * num)) % cnt0;
        times = (times * 2) % cnt0;
    }
    int times0 = 1, times1 = 1;
    //cerr << "*" << ans0 << " " << ans1 << endl;
    rep(i, N) {
        if(X[N - i - 1] == '0') {
            int tmp = ans1;
            tmp = (tmp + times1) % cnt1;
            ans[N - i - 1] = f2(tmp) + 1;
        } else {
            int tmp = ans0;
            if(cnt0 == 0) {
                ans[N - i - 1] = 0;
            } else {
                tmp = (tmp - times0 + cnt0) % cnt0;
                ans[N - i - 1] = f2(tmp) + 1;
            }
        }
        times1 = (times1 * 2) % cnt1;
        if(cnt0 != 0)
        times0 = (times0 * 2) % cnt0;
    }
    rep(i, N) {
        cout << ans[i] << endl;
    }
    






    return 0;
}


Measured memory_bytes: 4548
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;

#ifdef DEBUG
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
ld p[2][6];
ld go(ld d0) {
	ld d1=1-d0;
	ld ans=0;
	for (ll i=0;i<6;i++) {
		ld f0=d0*p[0][i];
		ld f1=d1*p[1][i];
		ld adder=max(f0,f1);
		ans+=adder;
	}
	return ans;
}
int main() 
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	cout<<fixed<<setprecision(10);
	for (ll k=0;k<2;k++) for (ll i=0;i<6;i++) {
		ll x; scanf("%lld",&x);
		p[k][i]=(ld)x/(ld)100.0;
	}
	//cout<<go(0.5)<<endl;
	//return 0;
	ld imin=0,imax=1;
	for (ll k=0;k<300;k++) {
		ld imid=(imin+imax)/2;
		if (go(imid)>go(imid+1e-12)) {
			imin=imid;
		}
		else imax=imid;
	}
	//cout<<"imin"<<imin<<endl;
	cout<<go(imin)<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;
using mat2d_t = std::vector<std::vector<int64_t>>;




int main(int argc, char **argv) {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<i64> as(a), bs(b), cs(c);
    for (int i=0; i<a; ++i) cin >>as[i];
    for (int i=0; i<b; ++i) cin >>bs[i];
    for (int i=0; i<c; ++i) cin >>cs[i];

    sort(as.begin(), as.end(), std::greater<int>());
    sort(bs.begin(), bs.end(), std::greater<int>());
    sort(cs.begin(), cs.end(), std::greater<int>());

    priority_queue<i64, std::vector<i64>, std::greater<i64>> q;

    for (int i=0; i < x; ++i) {
        q.push(as[i]);
    }
    for (int i=0; i< y; ++i) {
        q.push(bs[i]);
    }

    for (int i=0; i<c; ++i) {
        int t = q.top();
        if (t < cs[i]) {
            q.pop();
            q.push(cs[i]);
        }
    }
    i64 ans{0};
    while (!q.empty()) {
        ans += q.top();
        //cout << "  " << q.top()<< endl;
        q.pop();
    }
    cout << ans<< endl;

    return 0;
}

Measured memory_bytes: 4724
#include <stdio.h>
#define max_r 110000

int main(void) {
  int i, j, k, q, l, r, num[max_r];
  bool p[max_r];
  for(i = 0; i < max_r; ++i) p[i] = true, num[i] = 0;
  p[0] = p[1] = false;
  for(i = 2; i < 332; ++i) {
    if(p[i]) for(j = i * 2; j < max_r; j += i) p[j] = false;
  }
  for(i = 1; i < max_r; ++i) {
    num[i] = num[i - 1];
    if(i % 2 && p[i] && p[(i + 1) / 2])  num[i]++;
  }
  scanf("%d", &q);
  for(i = 0; i < q; ++i) {
    scanf("%d%d", &l, &r);
    printf("%d\n", num[r] - num[l - 1]);
  }
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long

using namespace std;
int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   
   int n;
   cin>>n;
   
   string str;
   
   int s1=0,s2=0,s3=0,s4=0;
  
   
   for(int i=0;i<n;i++)
   {
      cin>>str;
      
      if(str=="AC")
      s1++;
      else if(str=="WA")
      s2++;
      else if(str=="TLE")
      s3++;
      else if(str=="RE")
      s4++;
   }
   
   cout<<"AC"<<" x "<<s1<<endl;
   cout<<"WA"<<" x "<<s2<<endl;
   cout<<"TLE"<<" x "<<s3<<endl;
   cout<<"RE"<<" x "<<s4<<endl;
   return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#include<map>
#define INF 1000000000
#define LM 55555
#define LL long long
using namespace::std;

struct edge {
	LL to, cost;
};
vector<edge> G[2000000];
LL d[1000000];
long long now,L,R,D, A[2][100],AA[2][100],num, N, K, M, ans,sosu[100000];
string S, T;
bool h[1000000];
char cc;

bool dfs(int n, int dd) {
	if (h[n]) {
		if (d[n] == dd)return true;
		else return false;
	}
	h[n] = true;
	d[n] = dd;
	for (int i = 0; i < G[n].size(); i++) {
		if (dfs(G[n][i].to, d[n] + G[n][i].cost)==false) {
			return false;
		}
	}
	return true;
}

int main() {

	cin >> N>>M;
	for (int i = 0; i < N; i++)h[i] = false;
	for (int i = 0; i < M; i++) {
		cin >> L >> R >> D;
		L--;
		R--;
		G[L].push_back({ R,D });
		G[R].push_back({ L,-D });
	}
	for (int i = 0; i < N; i++) {
		if (h[i]==false) {
			if (dfs(i, 0)==false) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout <<"Yes" << endl;
	return 0;

}

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

int main(){
    int N, D;
	cin >> N >> D;
    vector<long long> X(N), Y(N);
    for(int i=0; i<N; i++){
        cin >> X.at(i) >> Y.at(i);
    }

    long double sum=0;
    int cnt=0;
    for(int i=0; i<N; i++){
        sum = pow(X.at(i),2) + pow(Y.at(i),2);
        sum = pow(sum,0.5);
        if( sum <= D ){
            cnt++;
        }
    }
    cout << cnt << endl;


}


Measured memory_bytes: 6488
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;

bool sortbysec(const pair<lli,lli> &a,
              const pair<lli,lli> &b)
{
    return (a.second < b.second);
}

lli modulo(string num, lli a)
{
    lli res = 0;
    for (lli i = 0; i < num.length(); i++)
         res = (res*10 + (int)num[i] - '0') %a;

    return res;
}

lli SieveOfEratosthenes(lli n,vector<lli> &v)
{
    lli ans=0,p1,p2,p3;
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (lli p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (lli i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (lli p=2; p<=n; p++)
    {
       if (prime[p])
          v.pb(p);
    }
}

int main()
{
//cout.precision(9);
//cout.setf(ios::fixed,ios::floatfield);
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
	lli T=1;
    //cin>>T;
	while(T--)
	{
        lli n,z,i,j,k,l,d,ans=0;
        cin>>n>>d;
        double sum=0;
        vector<lli> v[n];
        vector<lli>::iterator itr;
        for(i=0;i<n;i++)
        {
            for(j=0;j<d;j++)
            {
                cin>>z;
                v[i].pb(z);
            }
        }
        for(i=0;i<n-1;i++)
        {
            for(k=i+1;k<n;k++)
            {
                sum=0;
                for(j=0;j<d;j++)
                {
                    sum+=(v[i][j]-v[k][j])*(v[i][j]-v[k][j]);
                }
                //what_is(sum);
                sum=pow(sum,0.5);
                //what_is(sum);
                if(sum-floor(sum)==0)
                ans++;
            }
        }
        cout<<ans<<endl;
    }
}
/*
5 4
1 2 3 4 5
1 2 10 5
*/


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9 + 7;

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


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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    rep(i, m) cin >> x.at(i);
    sort(x.begin(), x.end());

    vector<int> diff(m - 1);
    rep(i, m - 1) diff.at(i) = x.at(i + 1) - x.at(i);

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

    int answer = 0;
    rep(i, m - n)
    {
        answer += diff.at(i);
    }

    cout << answer << endl;
}

Measured memory_bytes: 1024
n;g[9][9];b;z;f(x,y){*g[x]=b--;for(y=n;y;--y)g[x][y]&&!*g[y]&&f(y);*g[x]=0,z+=!b++;}main(a){for(;~scanf("%d%d",&a,&b);n=b=n?:a)g[a][b]=g[b][a]=n;f(1);printf("%d",z);}

Measured memory_bytes: 1716
#include <stdio.h>

int main(void){
  long int N;
  long int sum = 0;
  scanf("%ld",&N);
  for(int i = 1;i <= N;i++){
    if(i % 3 !=0 && i % 5 !=0){
      sum += i;
    }
  }
  printf("%ld",sum);
  return 0;
}


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

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
typedef long long ll;
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
// online submission
#endif
	ll n;
	cin>>n;
	vector<ll> v(n+1);
	for(ll i=1;i<=n;i++){
		cin>>v[i];
	}
	ll sum=0;
	sort(v.begin(),v.end());
	for(int k=1;k<=n-1;k++){
		sum+=v[n-(k/2)];
	}
	cout<<sum;
}

Measured memory_bytes: 4752
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <climits>
#include <numeric> 
#include <cmath>
#include <stdio.h>

using namespace std;

int main()
{
    int n; cin >> n;
    long long ans = 0; 
    for (int i = 1; i <= n; i++)
    {
        long long count = n/i;
        ans += i * (count * (count + 1))/2;
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 3616
# 適当に1~6くらいまでの数列でやると法則がみえてくるのでそうする
# nが偶数 -> 後ろから偶数番目を降順で、のちに頭から奇数を昇順で
# nが奇数 -> 後ろから奇数番目を降順で、のちに頭から偶数を昇順で

n = int(input())
arr = input().split()
pre, epi = [], []
if n % 2 == 0:
    pre = arr[::-2]
    epi = arr[::2]
else:
    pre = arr[-1::-2]
    epi = arr[1::2]
print(" ".join(pre), end=" ")
print(" ".join(epi))


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

const int MAX = 1e5+1;
vector<vector<int>> parent(MAX);
int dp[MAX];

int find(int node){
	if(parent[node].size()==0) return 0;

	if(dp[node]!=-1) return dp[node];

	int maxi = 0;
	for(int p : parent[node]){
		maxi = max(maxi, 1+find(p));
	}
	dp[node] = maxi;
	return maxi;
}

signed main(){
	
	int n,m;
	cin >> n >> m;

	for(int i=0;i<m;i++){
		int a,b;
		cin >> a >> b;
		parent[b].emplace_back(a);
	}

	for(int i=0;i<MAX;i++) dp[i] = -1;

	// dp[i] ---> length of longest path ending in i

	for(int i=1;i<=n;i++){
		if(dp[i]==-1) dp[i] = find(i);
	}

	// cout << "dp array : \n";
	// for(int i=1;i<=n;i++) cout << "i:" << i << " dp[i]=" << dp[i] << endl;
	cout << *max_element(dp+1, dp+n+1) << endl;
	return 0;
}

Measured memory_bytes: 14036
#include <iostream>
#include <cmath>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;

int N, W[300];
int dp[301][3001];

bool ok(int i, int j) {
  return abs(W[i] - W[j]) <= 1;
}

int dfs(int l, int r) {
  if(r - l <= 1) return 0;
  if(r - l == 2) return ok(l, l + 1) ? 2 : 0;
  if(dp[l][r] >= 0) return dp[l][r];

  int ret = 0;
  REP(i, l + 1, r) ret = max(ret, dfs(l, i) + dfs(i, r));
  if(ok(l, r - 1) && dfs(l + 1, r - 1) == r - l - 2) ret = max(ret, r - l);

  return dp[l][r] = ret;
}

int main(void) {
  while(cin >> N, N) {
    REP(i, 0, N) cin >> W[i];
    REP(i, 0, 301) REP(j, 0, 301) dp[i][j] = -1;
    cout << dfs(0, N) << endl;
  }
}

Measured memory_bytes: 4684
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int n, s;
int ans;

void dfs (int curr, int depth, int sum )
{
	if (sum > s ) return;

	if (depth == n ){
		if (sum == s ) ans++;
		return;
	} // end if

	if (curr >= 10 ) return;

	dfs (curr+1, depth, sum );
	dfs (curr+1, depth+1, sum + curr );
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.sum_of_integers", "r", stdin );
	while (scanf ("%d %d", &n, &s ) ){
		if (n == 0 && s == 0 ) break;
		ans = 0;
		dfs (0, 0, 0 );
		printf ("%d\n", ans );
	} // end loop
		
	return 0;
}

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

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

const int N = 100005;
const int LGN = 18;

vector<int> g[N];
int a[N], b[N], c[N];
ll d[N];

void dfs(int v, int par = 0, ll __dist = 0){
	d[v] = __dist;
	for(auto ind : g[v]){
		int u = a[ind]^b[ind]^v;
		if(u != par){
			dfs(u, v, __dist + c[ind]);
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	for(int i = 1; i < n; i++){
		cin>>a[i]>>b[i]>>c[i];
		g[a[i]].push_back(i);
		g[b[i]].push_back(i);
	}
	int q, k;
	cin>>q>>k;
	dfs(k);
	while(q--){
		int u, v;
		cin>>u>>v;
		cout<<d[u] + d[v]<<'\n';
	}

	return 0;
}

Measured memory_bytes: 13952
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <climits>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main()
{
	int N, ans = 0;
	string msg, str;
	cin >> msg >> N;
	REP(i, N) {
		cin >> str;
		str += str;
		if(str.find(msg) != string::npos) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int n;
cin >> n;
int d[n];
int ans=0;
REP(i,n) cin >> d[i];
REP(i,n-1) {
  for(int j=i+1;j<n;j++) {
    ans += d[i]*d[j];
  }
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
args = input()

list_str = args.split(" ")

W = int(list_str[0])
H = int(list_str[1])
x = int(list_str[2])
y = int(list_str[3])
r = int(list_str[4])

flg1 = False
flg2 = False

if 0 <= (x - r) and (x + r) <= W:
    flg1 = True

    if 0 <= (y - r) and (y + r) <= H:
        flg2 = True

if flg1 and flg2:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n, in,ans=0;
	vi v;
	cin >> n;
	rep(i, n) {
		cin >> in;
		v.push_back(in - 1);
	}
	rep(i, n) {
		if (v[v[i]]==i)ans++;
	}
	cout << ans / 2 << endl;

}

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

using namespace std;

int main(){
    string s,c;
    int n,i,j,k;
    cin>>n>>s;
    int len=s.size();
    for(i=0;i<len;i++){
        if(s[i]+n>'Z'){cout<<char(s[i]+n-26);}
        else {cout<<char(s[i]+n);}
    }

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
using namespace std;

int main(){
  int n, m, c;
  cin >> n >> m >> c;
  int b[m];
  for(int i=0; i<m; i++){
    cin >> b[i];
  }
  int count = 0;
  for(int i=0; i<n; i++){
    int code = 0;
    int a[m];
    for(int j=0; j<m; j++){
      cin >> a[j];
      code += a[j] * b[j];
    }
    if(code + c > 0) count++;
  }
  cout << count << endl;

return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char a[60];
char b[60];
int main(){
	scanf("%s",a);
	getchar();
	scanf("%s",b);
	int t = strlen(a) + strlen(b);
	//printf("%d\n",t);
	int n = 0,m = 0;
	for(int i = 1;i <= t;i++){
		if(i%2==0){
			printf("%c",b[n]);
			n++;
		}
		if(i%2!=0){
			printf("%c",a[m]);
			m++;
		}
	}
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
const int MOD=1000000007;
const int INF=LLONG_MAX/2;
const int Maxa=200000;


signed main() {cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int k,x;
    cin>>k>>x;
    for(int i=-k+1; i<k; i++){
        cout<<x+i<<" ";
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n, k, h[100100], ans;
int main(void){
    // Your code here!
    ans = 10000000000;
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> h[i];
    sort(h, h + n);
    for (int i = 0; i < n - k + 1; i++){
        ans = min(h[i + k - 1] - h[i], ans);
    }
    cout << ans << endl;
}


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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    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) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

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

    ll r1, c1, r2, c2;
    cin>>r1>>c1>>r2>>c2;

    combination cmb(2001001);
    mint ans = cmb.operator()(r2 + c2 + 2, c2 + 1) - cmb.operator()(r1 + c2 + 1, r1)
        - cmb.operator()(r2 + c1 + 1, c1) + cmb.operator()(r1 + c1, r1);
    cout<<ans.x<<endl;
}

Measured memory_bytes: 31488
s = int(input())
S = list(map(int, input().split()))
t= int(input())
T = list(map(int, input().split()))
cnt = 0
for i in T:
	a=0
	b=s-1
	while b >= a:
		mid=int((a+b)/2)
		if S[mid]==i:
			cnt+= 1
			break
		elif S[mid]>i:
			b=mid-1
			continue
		else:
			a=mid+1
			continue
print(cnt)


Measured memory_bytes: 16704
from math import sqrt

def standard_deviate(numbers):
    m = sum(numbers) / len(numbers)
    d = sqrt(sum([(n - m)**2 for n in numbers]) / len(numbers))
    return d

if __name__ == '__main__':
    while input() != '0':
        students = list(map(int, input().split()))
        print(standard_deviate(students))



Measured memory_bytes: 5708
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,m,i,j,ans,viz[51],x[51],y[51];
vector<int>a[51];
void dfs(int x)
{
    viz[x]=1;
    for(int i=0;i<a[x].size();i++)if(!viz[a[x][i]])dfs(a[x][i]);
}
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n>>m;
    for(i=1;i<=m;i++)cin>>x[i]>>y[i];
    for(i=1;i<=m;i++)
    {
        for(j=1;j<=n;j++)viz[j]=0;
        for(j=1;j<=n;j++)a[j].clear();
        for(j=1;j<=m;j++)if(j!=i)a[x[j]].pb(y[j]),a[y[j]].pb(x[j]);
        dfs(1);
        for(j=1;j<=n;j++)
         if(!viz[j])
         {
             ans++;
             break;
         }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
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 dp[3010][3010];

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

    for(int len=1;len<=N;len++){
        for(int i=0;i+len<=N;i++){
            int j=i+len;
            if((N-len)%2==0){
                dp[i][j]=max(dp[i+1][j]+a[i],dp[i][j-1]+a[j-1]);
            }else{
                dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j-1]);
            }
        }
    }
    cout<<dp[0][N]<<endl;
}


Measured memory_bytes: 70016
#include<bits/stdc++.h>
const int N=1e5+7;
int n,m,x[N],id[N],ss[N],sp;
bool ed[N];
long long k,ans[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",x+i),id[i]=i;
	ans[1]=x[1];
	scanf("%d%lld",&m,&k);
	for(int i=1,a;i<=m;++i){
		scanf("%d",&a);
		std::swap(id[a],id[a-1]);
	}
	for(int i=1;i<n;++i)if(!ed[i]){
		sp=0;
		for(int w=i;!ed[w];ed[w]=1,w=id[w])ss[sp++]=w;
		int p=k%sp;
		for(int t=0;t<sp;++t){
			int w=ss[t],u=ss[(t+p)%sp];
			ans[w+1]=x[u+1]-x[u];
		}
	}
	for(int i=1;i<=n;++i)printf("%lld.0\n",ans[i]+=ans[i-1]);
	return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;

    cin >> N;

    multiset<ll> maxes;

    REP(i, N){
        ll A;
        cin >> A;
        auto it = maxes.lower_bound(A);
        if( maxes.empty() || it == maxes.begin() ){
        }else{
            it--;
            maxes.erase(it);
        }
        maxes.insert(A);
    }


    cout << maxes.size() << endl;
}


Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<algorithm>
#include<array>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i].first >> a[i].second;
    a[i].first += a[i].second;
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  long long ans=0;
  for(int i=0;i<n;i++){
    ans += (i+1)%2*a[i].first - a[i].second;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i > n; --i)
const int MOD = 1000000007;

int main() {
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    rep(i, 0, N) rep(j, 0, D) cin >> X[i][j];
    int ans = 0;
    rep(i, 0, N-1) rep(j, i+1, N) {
        int sum = 0;
        rep(k, 0, D) {
            int dif = X[i][k] - X[j][k];
            sum += dif * dif;
        }
        double r = sqrt(sum);
        int n = r;
        if(n == r) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
A, B = map(int, input().split())
# https://atcoder.jp/contests/abc090/tasks/abc090_b
# 全探索でよくね？


def is_cycle(x):
    x = str(x)
    return x == x[::-1]


ans = 0
for x in range(A, B + 1):
    ans += is_cycle(x)
print(ans)


Measured memory_bytes: 73616
#include<iostream>
using namespace std;
int a;
int b;
int c;
int d;
int main(){
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	if (a == b&&c == d){
		cout << "yes" << endl;
	}
	else if (a == c&&b == d){
		cout << "yes" << endl;
	}
	else if (a == d&&b == c){
		cout << "yes" << endl;
	}
	else cout << "no" << endl;

	return 0;
}

Measured memory_bytes: 3092