akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		long []A = new long[3*100000+5];
		for(int i=0;i<N;i++) {
			A[i] = nextLong();
		}
		long res = 0;
		for(int k=0;k<60;k++) {
			long t = 1L << k;
			int x=0,y=0;
			for(int i=0;i<N;i++) {
				if((A[i]&t)==t)x++;
				else y++;
			}
			res += t % Mod * x % Mod * y % Mod;
			res %= Mod;
		}
		out.println(res);


	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

Measured memory_bytes: 63872
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<utility>
#include<vector>
using namespace std;

const long mod = 1000000007;
const long indlim = 5368709119;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
long fact(long x) { if (x == 0) return 1; else return((fact(x - 1) * x) % mod); }
long mybase(long N, long B) { if (N == 0) return 0; string S = ""; while (N != 0) { string M = to_string(N % B); N -= N % B; N /= B; S = M + S; }return stol(S); }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long res = 1;
	long N; cin >> N;
	long A[100009]; for (int i = 0; i < N; i++) cin >> A[i];
	long pool[100009] = {}; for (int i = 0; i < N; i++) pool[A[i]]++;
    if (N % 2 == 1) if(pool[0] != 1){ cout << 0 << endl; return 0; }
    
	if (N % 2 == 0) for (int i = 1; i < N; i = i + 2) if (pool[i] != 2) { cout << 0 << endl; return 0; }
	if (N % 2 == 1) for (int i = 2; i < N; i = i + 2) if (pool[i] != 2) { cout << 0 << endl; return 0; }
    
	for(int i = 1; i <= N / 2; i++) {res *= 2; res %= mod;}

	cout << res << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};


int main()
{
    int N;
    cin >> N;
    string n = to_string(N);
    int sum = 0;
    int a = 0;
    for(int i = 0;i < n.size();i++){
        a = n[i] - 48;
        sum += a;
    }
    if(ceil(N/sum) == (double)N/sum){
        cout <<"Yes" << endl;
    }
    else{
        cout <<"No" << endl;
    }
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
const int N = 200030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
int n,q;
vector<int> g[N];
int arr[N];
bool b[N];
void dfs(int x,int ind)
{
arr[ind]+=x;
x=arr[ind];
b[ind]=true;
for(int i=0;i<g[ind].size();i++)
{
	if(!b[g[ind][i]])
	{
		dfs(x,g[ind][i]);
	}
}
}
int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n>>q;
rep(i,0,n-1)
{
	int x,y;
	cin>>x>>y;
	g[x].push_back(y);
	g[y].push_back(x);
	
	
}
rep(i,0,q)
{
	int x,y;
	cin>>x>>y;
	arr[x]+=y;
}
dfs(0,1);
rep(i,1,n+1)
cout<<arr[i]<<" ";
}

Measured memory_bytes: 23680
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int count = 0;
		int even = 0, odd = 0;
		if(k%2==1) {
			for (int i = 1; i <= n; i++) {
				if(i%k==0) count++;
			}
			System.out.println(Math.round(Math.pow(count,3)));
		}else {
			k /= 2;
			for (int i = 1; i <= n; i++) {
				if(i%k==0) {
					if((i/k)%2==0)even++;
					else odd++;
				}
			}
			System.out.println(Math.round(Math.pow(even,3)+Math.pow(odd,3)));
		}
		sc.close();
	}
}

Measured memory_bytes: 22868
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        HashSet<String> hs = new HashSet<>();
        int n = sc.nextInt();
        for(int i = 0; i < n; i++){
            hs.add(sc.next());
        }
        System.out.println(hs.size());
    }
}

Measured memory_bytes: 66028
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define sqr(x) (x)*(x)
#define endl "\n"
#define mod 1000000007

int main()
{
    ll k,ans=0;
    cin>>k;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                ll gcd=__gcd(__gcd(i,j),l);
                ans+=gcd;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
typedef long long lint;
const int offset = 2500;

lint dp[55][5005];
int n, a[55];

int main(){
	int x;
	cin >> n >> x;
	for(int i=0; i<n; i++) cin >> a[i], a[i] -= x;
	dp[0][offset] = 1;
	for(int i=0; i<n; i++){
		for(int j=0; j<=2*offset; j++){
			if(j >= a[i]) dp[i+1][j - a[i]] += dp[i][j];
			dp[i+1][j] += dp[i][j];
		}
	}
	cout << dp[n][offset] - 1 << endl;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans,cnt;

ll fac[MAX]; // n!
ll finv[MAX]; // n!の逆元
ll inv[MAX]; // nの逆元

// n!(fac)とその逆元(finv)を先に計算しておく
void comInit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// nCrを計算(先にcomInit()が必須)
ll com(ll n, ll r) {
	if (n < r) return 0;
	if (n < 0 || r < 0) return 0;
	return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

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

	comInit();

	ll n,k;
	cin >> n >> k;
	k = min(k, n - 1); // k=n-1以上は変わらない
	rep(i, k + 1) {
		ans += com(n, i) * com(n - 1, i) % MOD;
		ans %= MOD;
	}
	
	cout << ans << endl;

	return 0;
}

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

int main() {
    int k;
    string s;
    cin >> k >> s;
    if (s.size() <= k) cout << s << endl;
    else cout << s.substr(0, k) << "..." << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,a,b;
  cin>>n>>a>>b;
  string s;
  cin>>s;

  int x = 0, y= 0;
  rep(i,n){
    if(s[i] == 'a'){
      if((x+y)<(a+b)){
        print("Yes");
        x++;
      }else{
        print("No");
      }
    }
    if(s[i] == 'b'){
      if((x+y) < (a+b) && y < b){
        print("Yes");
        y++;
      }
      else{
        print("No");
      }
    }
    if(s[i] == 'c'){
      print("No");
    }
  }
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
#define mx 1000000000000000000

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t;
    }
    return n*rep_jijo(n,x-1);
}

int main(){
    int n;
    cin >> n;
    ll ans=1;
    bool zero=false;
    bool flag=true;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n){
        if(a[i]==0) {
            zero = true;
        }
        else if(mx/a[i]>=ans) ans*=a[i];
        else{
            flag=false;
        }

    }

    if(zero) {
        cout << 0 << endl;
    }
    else if(flag){
        cout << ans << endl;
    }
    else{
        cout << -1 << endl;
    }

    return 0;

}

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

int main(){
    double a, b, t;
    cin >> a >> b >> t;
    int ans = 0;
    double i = 1;
    while(i*a < t + 0.5){
        ans += b;
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var q = int.Parse(Console.ReadLine());
        for (int i = 0; i < q; i++)
        {
            var abcd = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var y1 = abcd[0] - 1;
            var x1 = abcd[1] - 1;
            var y2 = abcd[2] - 1;
            var x2 = abcd[3] - 1;
            var y = Abs(y1 - y2);
            var x = Abs(x1 - x2);
            if (y < x)
            {
                var tmp1 = x1;
                x1 = y1;
                y1 = tmp1;
                var tmp2 = x2;
                x2 = y2;
                y2 = tmp2;
                var tmp = y;
                y = x;
                x = tmp;
            }
            long maxSize = 0;
            for (long size = 1; ; size *= 3)
            {
                if (size > y) break;
                //y軸の間に黒列を含む
                if (Abs(y1 / size - y2 / size) <= 1) continue;
                //同じ列に居て、黒列である 違う列にいる場合は黒マスを完全に迂回可能
                if (x1 / size != x2 / size || (x1 / size) % 3 != 1) continue;
                maxSize = size;
            }
            if (maxSize == 0)
            {
                Console.WriteLine(y + x);
                continue;
            }
            var edgeA = (x1 / maxSize) * maxSize;
            var edgeB = (x1 / maxSize + 1) * maxSize - 1;
            Console.WriteLine(y + Min(Abs(x1 - edgeA) + Abs(x2 - edgeA), Abs(x1 - edgeB) + Abs(x2 - edgeB)) + 2);
        }
    }
}


Measured memory_bytes: 17612
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }

    vector<int> dp(n, INF);
    dp[0] = 0;

    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k && j < n - i; j++){
            int gap = abs(h[i] - h[i + j]);
            dp[i + j] = min(dp[i+j],dp[i] + gap);
        }
    }

    cout << dp[n-1] << endl;

}


Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
// xi^2 - 2S^P + P^2 
const int N = 100 + 5; 
double a, b, c;
double cor[N];
int n;
double f(double x) {
  return a * x * x + b * x + c;;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> cor[i], c += cor[i] * cor[i], b -= 2 * cor[i];
  a = n; 
  double middle = -b / (2 * a);
  middle = (int) middle;
  int aa = middle + 1, bb = middle;
  cout << min(f(aa), f(bb)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("test.in");ofstream coutt("test.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Use __builtin_popcountll for ll;
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

int w,h,x,y;

signed main(){
    FASTER;
    cin>>w>>h>>x>>y;
    cout<<fixed<<setprecision(10)<<(h*w)/2.0<<" "<<(x*2==w && y*2==h);
}



Measured memory_bytes: 3772
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time

def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True

def main():
    N, M = MI()
    edges = []

    for i in range(N-1+M):
        a, b = MI()
        edges.append((a-1, b-1))

    in_cnt = defaultdict(int)
    outs = defaultdict(list)
    for a, b in edges:
        in_cnt[b] += 1
        outs[a].append(b)

    res = [0] * N
    queue = deque([i for i in range(N) if in_cnt[i] == 0])
    while len(queue) > 0:
        v = queue.popleft()
        # print(v + 1)
        # res.append(v)
        for nxt_v in outs[v]:
            # print('v', v + 1, 'nxt_v', nxt_v + 1)
            in_cnt[nxt_v] -= 1
            if in_cnt[nxt_v] == 0:
                res[nxt_v] = v + 1
                # print(res, nxt_v + 1, 'p', v + 1)
                queue.append(nxt_v)
    print(*res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 81364
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    map<string, int> mp;
    int x = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        x = max(x, ++mp[s]);
    }

    for (auto &p : mp) {
        if (p.second == x) cout << p.first << '\n';
    }

    return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b == c + d) {
    cout << "Balanced";
  } else if (a + b > c + d) {
    cout << "Left";
  } else {
    cout << "Right";
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[600000];
int b[600000];

int u[2000000];
//0
//今までのuの総和
int v[2000000];
//今までのvの総和
int k[2000000];
bool r[2000000];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i + 1] = b[i] ^ a[i];
	}
	int ans = 0, sum = 0;
	if (b[n] == 0) {
		ans = 1;
		for (int i = 1; i < n; i++) {
			if (b[i] == 0) {
				ans = ans * 2 % Mod;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		u[b[i]] = 1;
	}
	//今までにu[i]+=v[i]をした回数
	for (int i = 1; i <= n; i++) {
		if (b[i] == 0) {
			sum++;
		}
		else {
			u[b[i]] = (u[b[i]] + (v[b[i]] * (sum - k[b[i]]) % Mod)) % Mod;
			v[b[i]] += u[b[i]];
			v[b[i]] %= Mod;
			k[b[i]] = sum;
		}
	}
	if (b[n] == 0) {
		for (int i = 1; i < n; i++) {
			if (b[i] > 0 && !r[b[i]]) {
				ans += v[b[i]];
				ans %= Mod;
				r[b[i]] = 1;
			}
		}
	}
	else {
		ans = u[b[n]];
	}
	ans += Mod;
	ans %= Mod;
	cout << ans << endl;
}


Measured memory_bytes: 40320
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;








void next(vector<int> &ans, int& n, int& m){
    rep(i,n) cout << ans[i];
    cout << endl;
    int i = n-1;
    while(i>=0){
        if (ans[i] < m){
            ans[i]++;
            return;
        }
        i--;
    }
    ans = vector<int>();
}




ll ans;


ll cost(vector<int>& cur, vector<vector<int>>& abc,int q){

    ll ret = 0;
    rep(i,q){
        if (cur[abc[i][1]] - cur[abc[i][0]] == abc[i][2]) {
            ret+=abc[i][3];
        }
    }
    return ret;
}


void dfs(vector<int> cur, int n, int m, int q, vector<vector<int>>& abc,int mx){
    
    if (cur.size()==n){
        
        ll cand = cost(cur,abc,q);
        ans = max(cand,ans);
        return;
    }
    
    vector<int> tr;
    int begin = 1;
    if (cur.size() > 1){
        begin = cur[cur.size()-1];
    }
    begin = max(begin,mx);
    
    for(int i = begin; i <= m; i++){
        tr = cur;
        tr.pb(i);
        dfs(tr,n,m,q,abc,max(mx,i));
    }
    
}


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

    vector<vector<int>> abc;
    rep(i,q){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        abc.pb({a-1,b-1,c,d});
    }
    
    vector<int> cur;
    
    ans = 0LL;
    dfs(cur,n,m,q,abc,1);
    
    cout << ans;
//    ll ret = 0;
//    while (ans.size()){
//        ll cand = cost(ans,abc,q);
//        ret = max(cand,ret);
//        next(ans,n,m);
//    }
//    cout << ret;

}


Measured memory_bytes: 3512
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>

using namespace std;

const int MaxN = 100005;
#define two(i) (1<<(i))
double r;
int w[10],n,sz[two(6)],cnt[two(6)],sum[two(6)];
double x[two(6)][MaxN],y[two(6)][MaxN];

int main() 
{

	for(int i = 0; i < two(6); i++)
	{
		cnt[i] = 0;
		for(int t = i; t; t-=t&(-t))cnt[i]++;
	}
	int T;scanf("%d",&T);
	while(T--)
	{
		scanf("%lf%d",&r,&n);
		for(int i = 0; i < n; i++)
			scanf("%d",&w[i]);
		for(int i = 0; i < two(n); i++)
		{
			sum[i] = 0;
			for(int j = 0; j < n; j++)
				if(i&two(j))
					sum[i] += w[j];
		}
		for(int i = 1; i < two(n); i++)
		{
			if(cnt[i]==1)
			{
				for(int j = 0; j < n; j++)
					if((i>>j)&1)
					{
						x[i][0] = 0;
						y[i][0] = 0;
						sz[i] = 1;
						break;
					}
				continue;
			}
			int m = 0;
			for(int j = (i-1)&i; j>0; j = (j-1)&i)
			{
				double L = 1.0*sum[j^i]/sum[i];
				double R = 1.0*sum[j]/sum[i];
				for(int k = 0; k < sz[j]; k++)
					for(int p = 0; p < sz[i^j]; p++)
					{
						x[i][m] = max(L+x[j][k],x[i^j][p]-R);
						y[i][m] = max(R+y[i^j][p],y[j][k]-L);
						m++;
					}
			}
			sz[i] = m;
		}
		int ok = 0;
		double ret = -1;
		for(int i = 0; i < sz[two(n)-1]; i++)
		{
			// printf("%lf %lf\n",x[two(n)-1][i],y[two(n)-1][i]);
			if(x[two(n)-1][i]+y[two(n)-1][i] < r)
			{
				ok = 1;
				ret = max(ret,x[two(n)-1][i]+y[two(n)-1][i]);
			}
		}
		if(!ok)puts("-1");
		else printf("%.8f\n",ret);
	}

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
 
int A[20];
int M[200];
int flag=0,n;
 
void saiki(int p,int t){
  if(t==0)flag=1;
  if(p<n && t>0){
    p++;
    saiki(p,t); 
    t-=A[p];
    saiki(p,t);
  }
}
 
 
 
main(){
  int i,q;

  scanf("%d",&n);

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

  for(i=0;i<q;i++){
    scanf("%d",&M[i]);
  }
 
  for(i=0;i<q;i++){
    saiki(-1,M[i]);
    if(flag==1) printf("yes\n");
    else printf("no\n");
    flag=0;
  } 
  return 0;
}

Measured memory_bytes: 580
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

"""
・部分木の中で操作を行った場合の、残りdepth和の最小値と最大値を持ってdp
・補助的にコマの個数も持つ
・最大値：ただのdepthの和
・最小値：一番負担の大きな木から他の部分木を引いていった場合だが…
・最小値＋最大値から全部の最大値の和を引く形で更新
"""

N = int(readline())
S = readline().rstrip()
m = map(int,read().split())
AB = zip(m,m)

INF = 10**18

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

def solve_rooted(root):
    parent = [0] * (N+1)
    ts = []
    stack = [root]
    while stack:
        x = stack.pop()
        ts.append(x)
        for y in graph[x]:
            if y == parent[x]:
                continue
            parent[y] = x
            stack.append(y)
    max_dep = [0]*(N+1)
    min_dep = [0]*(N+1)
    cnt = [0] * (N+1)
    for i,x in enumerate(S,1):
        cnt[i]=x-ord('0')
    for v in ts[::-1]:
        p = parent[v]
        max_dep_sum = 0
        x = 0
        for c in graph[v]:
            if c==p:
                continue
            cnt[v] += cnt[c]
            d1 = max_dep[c]; d2 = min_dep[c]
            d1 += cnt[c]; d2 += cnt[c]
            max_dep_sum += d1
            if x<d1+d2:
                x=d1+d2
        max_dep[v] = max_dep_sum
        x -= max_dep_sum
        if x<0:
            x=max_dep_sum&1
        min_dep[v] = x
    if min_dep[root]:
        return INF
    return max_dep[root]//2

answer = min(solve_rooted(v) for v in range(1,N+1))
if answer == INF:
    answer = -1
print(answer)

Measured memory_bytes: 56412
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b - 1) / b << endl;
  return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
  
    string a;
    string b;
    string c;
    cin >> a >> b >> c;
  
  char d = b[0];
    
   cout << "A" << d << 'C' << endl;
  

  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define reps(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) reps(i,0,n)
int main(){
  string s;
  cin>>s;
  vector<ll> a(s.size()+1,0LL);
  for(int i=0;i<s.size();i++){
    if(s[i]=='<'){
      a[i+1]=a[i]+1;
    }
  }
  for(int i=s.size()-1;i>=0;i--){
    if(s[i]=='>'){
      if(i==s.size()-1)a[i+1]=0;
        a[i]=max(a[i+1]+1,a[i]);
     
    }
  }
  ll c=0LL;
  for(int i=0;i<s.size()+1;i++)c+=a[i];
  cout<<c;
}

Measured memory_bytes: 4740
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
//repマクロ定義
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
//allマクロ定義
#define all(v) v.begin(),v.end()
using namespace std;

int nCr(int n,int r){
  int con=1;
  for(int i=n;i>n-r;i--){
    con*=i;
  }
  for(int i=1;i<=r;i++){
    con/=i;
  }
  return con;
}

int main(){
  int n,m,ans=1,con_n,con_m;
  cin >> n >> m;

  con_n=nCr(n,2);
  con_m=nCr(m,2);

  cout << con_n + con_m << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<ll,ll>;
const ll M = 1e9+7;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}

int main() {
  int n,a,b; cin>>n>>a>>b;
  string s; cin>>s;
  for(int i=0;i<n;i++) {
    if (s[i] == 'a' && a+b > 0) {
      cout<<"Yes"<<endl;
      a--;
    } else if (s[i] == 'b' && a+b>0 && b>0) {
      cout<<"Yes"<<endl;
      b--;
    } else {
      cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(){

  string S;
  cin >> S;
  
  if(S.size() == 2){

    cout << S;
  }else if(S.size() == 3){

    cout << S[2] << S[1] << S[0];
  }
  
  return 0;
}


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

int main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int n, mn = 1e9; cin >> n;
        int ar[1001];
        ll sm = 0;
        for (int i = 0; i < n; i++) {
                cin >> ar[i];
                sm += ar[i];
        }
        ll sm1 = 0;
        for (int i = 0; i < n; i++) {
                sm -= ar[i];
                sm1 += ar[i];
                mn = min(mn*1ll, abs(sm - sm1));
        }
        cout << mn;
return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 998244353
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


vector<ll> fact, fact_inv, inv;
/*  comre :二項係数のための前処理
    計算量:O(n)
*/
void comre(int SIZE) {
    fact.resize(SIZE + 5);
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}
/*  com :modでの二項係数を求める(前処理 comre が必要)
    計算量:O(1)
*/
ll com(ll n, ll k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}


int main() {
  ll n,m,k;
  cin>>n>>m>>k;
  
  if(m==1) {
    if(k==n-1) cout << 1 << endl;
    else cout << 0 << endl;
  return 0;
  }
  
  ll ans = 0;
  comre(n-1);
  
  rep(i,k+1) {
  ll x=com(n-1,i);
  
  x*=jou(m-1,n-1-i);
    
  ans+=x;
  ans%=mod;
  }
  
  cout << (ans*m)%mod << endl;
  
}


Measured memory_bytes: 7908
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=1e9+7;

int main(){
    ll a,b,n;
    cin>>a>>b>>n;
    ll x=n/b;
    x=(x-1)*b+b-1;
    ll ans=max(a*x/b-a*(x/b),a*n/b-a*(n/b));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>

int main(void){

  int x1, x2, x3, x4, x5;

  scanf("%d %d %d %d %d",&x1,&x2,&x3,&x4,&x5);

  if(x1 == 0){
    printf("1\n");
  }if(x2 == 0){
    printf("2\n");
  }if(x3 == 0){
    printf("3\n");
  }if(x4 == 0){
    printf("4\n");
  }if(x5 == 0){
    printf("5\n");
  }


  return 0;
}


Measured memory_bytes: 1640
#include <iostream>
#include <stdio.h>
#define MAX 100000000

int n, q;
int S[MAX],T[MAX];

int sum;

int linearSearch(int key) {
    S[n] = key;
    int i = 0;
    while( i != n ) {
        if ( S[i] == key ) {
            return 1;
        }
        i++;
    }
    return 0;
}

int main() {
    sum = 0;
    
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &S[i]);
    }
    
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &T[i]);
    }
    
    for (int i = 0; i < q; i++) {
        sum += linearSearch(T[i]);
    }
    printf("%d\n", sum);
    
    
    return 0;
}

Measured memory_bytes: 3224
//
//  main.cpp
//  20190810lesson
//
//  Created by Priscilla Leang on 8/10/19.
//  Copyright © 2019 Priscilla Leang. All rights reserved.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int x, m, a, b, c, n;
    int f;
    bool b1 = false;
    string s;
    m = 753;
    cin>> s;
    for (int i = 0; i< s.length() - 2; i++){
        a = s[i] -48;
        b = s[i+1] - 48;
        c = s[i+2] - 48;
        n = a*100 + b*10+ c;
        f = 753 - n;
        if (f< 0){
            f*= -1;
        }
        if (f<m){
            m = f;
        }
    }
    if (s.length()<3){
        a = s[0] - 48;
        b = s[1] - 48;
        n =a*10 + b;
        m = 753 - n;
    }
    
    
    
    cout << m;
    return 0;
}


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

using namespace std;

typedef long long int ll;

const int N = 1e5 + 5;
const int mod = 1e9 + 7;

ll dp[N][3] = {};

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

  string s;
  cin >> s;
  int n = s.length();

  ll p = 1;
  if (s[0] == 'A' || s[0] == '?') dp[0][0] = 1;
  if (s[0] == '?') p = 3;
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      dp[i][j] = dp[i - 1][j] * (s[i] == '?' ? 3 : 1);
      if ("ABC"[j] == s[i] || s[i] == '?') {
        if (j == 0) dp[i][j] += p;
        else dp[i][j] += dp[i - 1][j - 1];
      }
      dp[i][j] %= mod;
    }
    if (s[i] == '?') p = (p * 3) % mod;
  }

  cout << dp[n - 1][2] << '\n';
}


Measured memory_bytes: 2768
N,X = list(map(int, input().split()))

DonutGram = []
totalConsume = 0
number_of_donuts = 0
for i in range(N):
    DonutGram.append(int(input()))

DonutGram.sort()
totalConsume += sum(DonutGram[:])
remainder = X - totalConsume
number_of_donuts = N

def makeDonut(gram_per_donut):
    global remainder
    while remainder >= gram_per_donut:
        remainder = remainder - gram_per_donut
        global number_of_donuts
        number_of_donuts += 1
    return remainder

for gram_per_donut in DonutGram:
    makeDonut(gram_per_donut)

print(number_of_donuts)

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

using namespace std;
int main(){
    int a;
    cin>>a;
    string s="";
    cin>>s;
    int c=1;
    for(int i=0;i<(a-1);++i)
    {
        if(s[i]!=s[i+1])++c;
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 512
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL K,A,B;

string ans = "NG";

void solve(){
	for(LL i=A;i<=B;i++){
		if(i%K==0) ans = "OK";
	}
}
 
int main(){
    cin >> K;
    cin >> A >> B;

    solve();

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

Measured memory_bytes: 3128
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

string flag[51];
int n, m;
int res = 1 << 29;
int cnt(int from, int to, char color){
	int res = 0;
	
	for(int i = from;i < to;i++){
		for(int j = 0;j < m;j++){
			if(flag[i][j] == color)res++;
		}
	}
	
	return res;
}

int main(){								 
	cin >> n >> m;
	for(int i = 0;i < n;i++){
		cin >> flag[i];
	}

	for(int i = 1;i < n;i++){
		for(int j = i + 1;j < n;j++){
			int tmp = 0;
			tmp += cnt(0, i, 'W');
			tmp += cnt(i, j, 'B');
			tmp += cnt(j, n, 'R');
			res = min(res, n * m - tmp);
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3212
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
using namespace std;

int a[300000];
priority_queue<int, vector<int>, greater<int> > v1;
vector<int> v2;
bool flg[200000] = { 0 };

signed main()
{
	int N;
	cin >> N;
	for (int i = 0; i < 3 * N; i++) cin >> a[i];

	int n1 = 0;
	for (int i = 0; i < N; i++)
	{
		v1.push(a[i]);
		n1 += a[i];
	}

	for (int i = N; i < 3 * N; i++)
	{
		v2.push_back(a[i]);
	}
	SORT(v2);
	int n2 = 0;
	for (int i = 0; i < N; i++) n2 += v2[i];

	int ans = n1 - n2;

	int n2_index = N - 1;
	for (int i = N; i < N * 2; i++)
	{
		int b = a[i];
		auto it = lower_bound(v2.begin(), v2.end(), b);
		int index = (int)(it - v2.begin());

		if (v1.top() < b)
		{
			n1 -= v1.top();
			n1 += b;
			v1.pop();
			v1.push(b);
		}

		flg[index] = true;
		if (index <= n2_index)
		{
			n2 -= b;
			while(true)
			{
				n2_index++;
				if (!flg[n2_index]) break;
			}
			n2 += v2[n2_index];
		}

		int k = n1 - n2;
		if (k > ans)
		{
			ans = k;
		}
	}

	cout << ans << endl;
}

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


ll ara[sz];
ll num[sz];

int main()
{


    ll i,j,a,b,x,y,n;

    cin>>n>>x;

    for(i=1;i<=n;i++)
    {
        cin>>ara[i];
    }
    ll c=1;
    num[1]=0;


    for(i=2;i<=n+1;i++)
    {
        a=num[i-1]+ara[i-1];
        num[i]=a;

        if(a<=x)c++;
    }

    cout<<c<<endl;


    return 0;
}


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

int main() {
  string s;
  	cin>>s;
  
  int count=0;
  for(int i=0;i<3;i++){
    if(s.at(i)=='1'){
	count+=1;
    }    
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double a, b, c, d, e, f;
    while (cin >> a >> b >> c >> d >> e >> f) {
        double x = (e * c - b * f) / (e * a - b * d);
        double y = (c - a * x) / b;
        if (x == 0) x = 0;
        if (y == 0) y = 0;
        cout << fixed << setprecision(3) << x << " " << y << "\n";
    }
}

Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
//ONLINE_JUDGE   LOCAL
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}
 


 
int main(){
	//in_o();
	int64 a,b;
	cin>>a>>b;
	int u=0;
	FOR(i,a,b+1){
		int c,d,y,z;
		c=i/10000%10,d=i/1000%10,y=i/10%10,z=i%10;
		if(c==z && d==y)
			u++;
	}
	cout<<u<<endl;
	return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce


def gcd(*numbers):
    return reduce(my_gcd, numbers)


def my_gcd(i, j):
    if i > j:
        a = i
        b = j
    elif i == j:
        return i
    else:
        a = j
        b = i
    r = a % b

    if r == 0:
        return b
    return my_gcd(b, r)


K = int(input()) + 1
sum = 0
for i in range(1, K):
    for j in range(1, K):
        for k in range(1, K):
            sum += gcd(i, j, k)

print(sum)


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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll t,x; cin >> t >> x; 
  cout << double(t)/x << endl;
}

Measured memory_bytes: 256
#![allow(dead_code)]
macro_rules! debug {
    ($($arg:tt)*) => (if cfg!(debug_assertions) {print!("[DEBUG] "); println!($($arg)*)});
}

fn main() {
    let mut rd = reader::Reader::new();

    let n = rd.next();
    let mut a = vec![vec![0i32; n]; n];
    for i in 0..n {
        for j in 0..n {
            a[i][j] = rd.next();
        }
    }
    let a = a;

    let mut d = a.clone();
    for i in 0..n {
        for j in 0..n {
            for k in 0..n {
                d[j][k] = std::cmp::min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
    for i in 0..n {
        for j in 0..n {
            if a[i][j] != d[i][j] {
                println!("-1");
                return;
            }
        }
    }

    let mut ans: i64 = 0;
    for i in 0..n {
        for j in 0..i {
            let mut b = true;
            for k in 0..n {
                if i != k && j != k && d[i][k] + d[k][j] == d[i][j] {
                    b = false;
                }
            }
            if b {
                ans += d[i][j] as i64;
            }
        }
    }
    println!("{}", ans);
}

mod reader {
    use std::fmt::Debug;
    use std::str::FromStr;
    use std::collections::VecDeque;
    use std::io::{self, Read};

    fn _read_line() -> String {
        let mut buf = String::new();
        let _ = io::stdin().read_to_string(&mut buf);
        buf
    }

    fn _read_vec_deque_string() -> VecDeque<String> {
        _read_line()
            .split_whitespace()
            .map(|s| s.to_string())
            .collect()
    }

    pub struct Reader {
        buf: VecDeque<String>,
    }

    impl Reader {
        pub fn new() -> Reader {
            Reader { buf: VecDeque::new() }
        }

        fn update_buf(&mut self) {
            if self.buf.is_empty() {
                self.buf = _read_vec_deque_string();
            }
        }

        pub fn next<T>(&mut self) -> T
            where
                T: FromStr,
                T::Err: Debug,
        {
            self.update_buf();
            self.buf.pop_front().unwrap().parse::<T>().unwrap()
        }

        pub fn next_n<T>(&mut self, n: usize) -> Vec<T>
            where
                T: FromStr,
                T::Err: Debug,
        {
            let mut vec: Vec<T> = Vec::with_capacity(n);

            for _ in 0..n {
                vec.push(self.next());
            }
            vec
        }
    }
}


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

int INF = 1001001001;
int n;
vector<int> abc(3);
vector<int> l(8);

int cost(vector<int> v, int c, int j) {
  if (j == n) {
    for (int i = 0; i < 3; i++) {
      if (!v[i]) return INF;
    }
    int ans = 10 * (c - 3);
    for (int i = 0; i < 3; i++) ans += abs(abc[i] - v[i]);
    return ans;
  }
  int ans = cost(v, c, j+1);
  for (int i = 0; i < 3; i++) {
    vector<int> nv = v;
    nv[i] += l[j];
    ans = min(ans, cost(nv, c+1, j+1));
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < 3; i++) cin >> abc[i];
  for (int i = 0; i < n; i++) cin >> l[i];
  cout << cost({0, 0, 0}, 0, 0) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
 
#define NL '\n'
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define sz(x) x.size()
#define pi  acos(-1.0)
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(), (x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;++i)
#define fastIO() ios_base::sync_with_stdio(0),cin.tie(NULL)
 
template<class T>void read(T &x){int q=1;char ch;x=0;for(ch=getchar();(ch<'0'||ch>'9')&&ch!='-';ch=getchar()); 
if(ch == '-')ch=getchar(),q =-1;for(;'0'<=ch&&ch<='9';ch=getchar()) x=x*10 + ch-'0'; x*=q;} template<class T>  
void write(T x){if(x<0)putchar('-'),write(-x);else if(x<10)putchar(x+'0');else write(x/10),putchar(x%10+'0');}

#define faye_valentine 
void dbg(){cerr<<NL;}template<typename H,typename... T> void dbg(H h,T... t){cerr<<' '<<h;dbg(t... );}
#ifdef  faye_valentine
#define debug(...) cerr<<"("<<#__VA_ARGS__<<"):",dbg(__VA_ARGS__)
#else
#define debug(...) 
#endif
 
 
 
void absinthe(){
    int a[5];
    rep(i,1,6) {
        cin >> a[i];
        if(!a[i]) {cout << i << NL; exit(0);}
    }
}
 
int main(){
    int Tx = 1; //read(Tx);  
    //fastIO(); cin >> Tx;
    while(Tx--) absinthe();
}

Measured memory_bytes: 3636
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	string s;
	cin >> s;
	cout << count(all(s), '1') << endl;

	return 0;
}

Measured memory_bytes: 888