akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        string a, b, c;
        cin >> a >> b >> c;
        Int A = a.size();
        Int B = b.size();
        Int C = c.size();

        const int zero = 10000;
        vector<bool> ab(zero * 2 + 5, true);
        vector<bool> ac(zero * 2 + 5, true);
        vector<bool> bc(zero * 2 + 5, true);

        auto eq = [](char x, char y) -> bool {
            return x == '?' || y == '?' || x == y;
        };

        auto flag_downer = [&](const string &s, const string &t, vector<bool> &st) {
            Int S = s.size();
            Int T = t.size();
            for (int i = 0; i < S; ++i) {
                for (int j = 0; j < T; ++j) {
                    if (!eq(s[i], t[j])) {
                        st[i - j + zero] = false;
                    }
                }
            }
        };

        flag_downer(a, b, ab);
        flag_downer(a, c, ac);
        flag_downer(b, c, bc);


        Int ans = INFl;
        for (Int i = -B - C; i <= A + C; ++i) {
            for (Int j = -B - C; j <= A + B; ++j) {
                if (ab[zero + i] && ac[zero + j] && bc[zero - i + j]) {
                    Int L = min({0ll, i, j});
                    Int R = max({A, i + B, j + C});
                    Int tmp = R - L;
                    if (ans > tmp) {
                        chmin(ans, tmp);
                    }
                }
            }
        }
        cout << ans << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i=0;i<N;i++)cin >> h[i];
  int cnt=0;
  for(int i=0;i<N;i++){if(h[i]>=K)cnt++;}
  cout << cnt << endl;
}

Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Taskb solver = new Taskb();
        solver.solve(1, in, out);
        out.close();
    }

    static class Taskb {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long a = in.nextLong();
            long b = in.nextLong();
            long ans = Maths.xor(b);
            if (a > 0) {
                ans = ans ^ Maths.xor(a - 1);
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }

    static class Maths {
        static long xor(long n) {
            if (n % 4 == 0) return n;
            if (n % 4 == 1) return 1;
            if (n % 4 == 2) return n + 1;
            if (n % 4 == 3) return 0;

            return 0;
        }

    }
}



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

const int mod = (1e9) + 7;

void solve()
{
    string s; cin >> s;
    int n = s.size();
    map<char, vector<int>> ind;
    for(int i = 0; i < n; i ++) {
        ind[s[i]].push_back(i);
    }
    int st = -1, e = -1, pos = 0;
    for(auto i : ind) {
        for(int j = 1; j < i.second.size(); j ++) {
            if ((i.second[j] == (i.second[j - 1] + 1)) || (i.second[j] == (i.second[j - 1] + 2)))
                {
                    st = i.second[j - 1] + 1;
                    e = i.second[j] + 1;
                    pos = 1;
                    break;
                }
        }
        if(pos)break;
    }
    cout << st << " " << e << endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


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

int main() {
  int K, S;
  cin >> K >> S;
  
  int cnt = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      if ((x + y <= S) and (S - x - y <= K)){
        cnt++;
      }
    }
  }
  
  cout << cnt << endl;
}


Measured memory_bytes: 3660
S = input()
K = int(input())
ListS = list(S)

def OneString(a):
    seq = 0
    seqit = 0
    for i in range(len(a)):
        if i == len(a) - 1:
            seq += (seqit+1)//2
        elif a[i]!=a[i+1]:
            seq += (seqit+1)//2
            seqit = 0
        else:
            seqit += 1
    return seq

def TBodd(a):
    seqnumT = 1
    seqnumB = 1
    if a[0] != a[-1]:
        return False
    for i in range(len(a)-1):
        if a[i]==a[i+1]:
            seqnumT += 1
        else: break
    for i in range(len(a)-2):
        if a[-(i+1)]==a[-(i+2)]:
            seqnumB += 1
        else: break
    if seqnumT%2 != 0 and seqnumB%2 != 0:
        return True
    else: return False
            

if len(set(ListS)) == 1:
    ans = (len(S)*K)//2
elif TBodd(S):
    ans = (OneString(S) + 1)*K - 1
else: ans = OneString(S)*K
    
print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<double> x(N);
  vector<string> u(N);
  rep(i, N) { cin >> x[i] >> u[i]; }

  double ans = 0;
  rep(i, N) {
    if (u[i] == "JPY")
      ans += x[i];
    else
      ans += x[i] * 380000;
  }
  printf("%0.5f", ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN 2*int(1e5)+7
#define endl '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define max3(x, y, z) max(x, max(y, z))
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<unsigned ll, pair<int, int> > piii;
typedef pair<pair<int, int>, int> piii2;
typedef pair<char, pair<int, int>> pcii;
typedef tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;


int main() {
    int n;
    cin >> n;
    getchar();
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        string aux = "";
        for(int j = i; j < i+3 && j < n; j++)
            aux.pb(s[j]);
        if(aux == "ABC") ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/*
 * @Author: AsilenceBTF
 * @Buff: ︿(￣︶￣)︿  芜湖塔台 起飞
 * @Date: 2019-06-20 09:22:24
 * @LastEditTime: 2020-08-30 15:22:35
 */
// #include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
using namespace std;

#define sz(x) int(x.size())
#define ALL(x) x.begin(), x.end()
#define INF 0x3f3f3f3f
typedef long long ll;

const int MOD = 1e9 + 7;
const int N = 1e6 + 105;

int vis[N], a[N];
int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    int n; cin >> n;
    int Gcd;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
        vis[a[i]]++;
        if(i == 1) Gcd = a[i];
        else Gcd = __gcd(Gcd, a[i]);
    }
    int f = 1;
    for(int i = 2; i < N; ++i){
        int s = 0;
        for(int j = i; j < N; j += i){
            if(vis[j]) s += vis[j];
        }
        if(s > 1) f = 0;
    }
    if(f) cout << "pairwise coprime" << endl;
    else if(Gcd == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
    // system("pause");    
}

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

int main() {
  string T;
  cin>>T;
  rep(i,T.size()){
    if(T.at(i)=='?'){
      T.at(i)='D';
    }
  }
  cout<<T<<endl;

}

Measured memory_bytes: 3752
N, A = map(int, input().split())
x = list(map(int, input().split()))

x.sort()
x = [v - A for v in x]

dp = [0] * 5001
for v in x:
    for i in range(2501) if v < 0 else range(5000, -1, -1):
        if dp[i] == 0:
            continue
        dp[i + v] += dp[i]
    dp[2500 + v] += 1
print(dp[2500])


Measured memory_bytes: 3060
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1LL;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

ll mod_inv(ll x, ll mod) {
	return mod_pow(x, mod - 2, mod);
}
class Combination {
public:
	Array fact;//n！
	Array inv;//n!の逆元
	ll mod;
	Combination(ll n, ll _mod) {
		mod = _mod;
		fact.resize(n + 1);
		fact[0] = 1;
		REP(i, n) {
			fact[i + 1] = (fact[i] * (i + 1LL)) % mod;
		}
		inv.resize(n + 1);
		inv[n] = mod_inv(fact[n]);
		for (int i = n; i > 0; i--) {
			inv[i - 1] = inv[i] * i % mod;
		}
	}
	//modの逆元
	ll mod_inv(ll x) {
		ll n = mod - 2;
		ll res = 1LL;
		while (n > 0) {
			if (n & 1) res = res * x % mod;
			x = x * x % mod;
			n >>= 1;
		}
		return res;
	}
	ll nCr(ll n, ll r) {
		return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod;
	}
	ll nPr(ll n, ll r) {
		return (fact[n] * inv[n - r]) % mod;
	}
	ll nHr(ll n, ll r) {
		//重複組み合わせ：n種類のものからr個取り出す組み合わせ
		return nCr(r + n - 1, r);
	}
};

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

	ll n, k;
	cin >> n >> k;
	Array a(n, 0);
	REP(i, n) cin >> a[i];
	sort(all(a));

	Combination com(n, MOD);

	ll ans = 0;

	REP(i, n) {
		a[i] += MOD;
		a[i] %= MOD;
		if (i >= k - 1)(ans += (a[i] * com.nCr(i, k - 1)) % MOD) %= MOD;
		if (n - 1 - i >= k - 1)(ans += MOD - (a[i] * com.nCr(n - 1 - i, k - 1)) % MOD) %= MOD;
	}

	cout << ans << endl;

	return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        public static int GetInt()
        {
            int a = int.Parse(Console.ReadLine());
            return a;
        }

        public static int[] GetIntArray()
        {
            var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            return a;
        }

        static void Main(string[] args)
        {
            var a = GetIntArray();
            int N = a[0];
            int Q = a[1];

            string S = Console.ReadLine();

            Dictionary<int, int> d = new Dictionary<int, int>();
            d.Add(1, 0);
            int count = 0; //?文字目までにいくつＡＣがあるか

            for (int i = 1; i < S.Length; i++)
            {
                if(S[i] == 'C' && S[i - 1] == 'A')
                {
                    count = count + 1;
                }
                d.Add(i + 1, count); //i+1文字目までにcount回ACが存在する
            }

            for (int i = 0; i < Q; i++)
            {
                var b = GetIntArray();
                int l = b[0];
                int r = b[1];

                Console.WriteLine(d[r] - d[l]);
            }


        }
    }
}


Measured memory_bytes: 23360
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scan = new Scanner (System.in);
		final int n = scan.nextInt();
		final int[] sequence = new int[n];
		
		for (int i = 0; i < n; i++) {
			sequence[i] = scan.nextInt();
		}
		
		final int q = scan.nextInt();
		
		for ( int i = 0; i < q; i++) {
			final int m = scan.nextInt();
			makeCombination(m, sequence);
		}
		scan.close();
	}
	
	static void makeCombination(int m, int[] data) {
		int count = 0;
		int sum = 0;
		
		count += rec (data, 0, m, sum, false);
		count += rec (data, 0, m, sum, true);
		
		if (count > 0) System.out.println("yes");
		else System.out.println("no");
		
		
	}
	
	static int rec (int[] data, int i, int m, int sum, boolean flg) {
		
		int n = data.length;
		int count = 0;
		
		if (flg == true) {
			sum += data[i];
		}
		
		if ( i == n - 1) {
			if ( m == sum) {
				return 1;
			} else {
				return 0;
			}
		}
		
		i++;
		count += rec(data, i, m, sum, false);
		if (count > 0) {
			return 1;
		}
		count += rec(data, i, m, sum, true);
		if (count > 0) {
			return 1;
		} 
		
		
		return 0;
		
	}
}



Measured memory_bytes: 26684
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<ctime>
#include<complex>
#include<list>
#include<limits.h>
#include<iomanip>
using namespace std;

const int MOD=1e9+7;
int n,m,ans;
int d[1505];
vector<int> v;

int Pow(int x,int y){
	int ret=1,mt=x;
	while(y){
		if(y&1) ret=1ll*ret*mt%MOD;
		mt=1ll*mt*mt%MOD;
		y>>=1;
	}
	return ret;
}

void add(int &x,int y){
	x+=y;
	if(x>=MOD) x-=MOD;
	if(x<0) x+=MOD;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i*i<=n;i++) if(n%i==0){
		v.push_back(i);
		if(i!=n/i) v.push_back(n/i);
	}
	if(n==1){
		printf("%d\n",m);
		return 0;
	}
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++){
		int x=v[i];
		d[i]=Pow(m,(x+1)/2);
		for(int j=0;j<i;j++) if(x%v[j]==0) add(d[i],-d[j]);
		if(x%2==0) add(ans,1ll*d[i]*x/2%MOD);
		else add(ans,1ll*d[i]*x%MOD);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace _1_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long ret = x[0];
            for (int i = 1; i < n; i++)
            {
                long a = Math.Min(ret, x[i]);
                long b = Math.Max(ret, x[i]);
                while (a != 0)
                {
                    long xy = b % a;
                    b = a; a = xy;
                }
                ret = ret / b * x[i];
            }
            Console.WriteLine(ret);
        }
    }
}

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

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll s = n / (a + b);
    ll r = n % (a + b);
    ll ans = 0;
    ans += a * s;
    if(r >= a) ans += a;
    else ans += r;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int check[101];
int main(){
	long long  n,m;
	cin>>n>>m;
	int arr[n];
	for(int i = 0;i<n;i++)cin>>arr[i];
	sort(arr,arr+n);
	int cnt = 0;
	int mark = -1;
	for(int i = 0;i<n;i++){
		if(m-arr[i]>=0){
			cnt++;
			check[i]=1;
		}
		else {
			mark = i;
			check[i]=0;
		}
		m-=arr[i];
	}
	if(m>0&&cnt==n)cnt-=1;
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int w,h;
	int a[10001];
	int b[10001];
	cin>>w>>h;
	int i,j;
	for(i=0;i<w;i++){
		cin>>a[i];
	}
	for(i=0;i<h;i++){
		cin>>b[i];
	}
	bool flg=false;
	sort(b,b+h,greater<int>());
	for(i=0;i<h;i++){
		sort(a,a+w,greater<int>());
		//cout<<"B[i]1"<<b[i]<<endl;
		for(j=0;j<w;j++){
			if(a[j]==0)	break;
			if(b[i]==0)	break;
			if(b[i]>0)	b[i]--;
			if(a[j]>0)	a[j]--;
		}
		if(b[i]>0)	{
			flg=true;
			break;
		}
	}
	cout<<((flg)?"0":"1")<<endl;
	return 0;
}


Measured memory_bytes: 3160
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        _l: usize,
        w: [String; n],
    }

    let mut ws = w;
    ws.sort();

    for e in ws {
        print!("{}", e);
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int vector_finder(vector<int> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance(vec.begin(), itr);
  if (index != vec.size()) {  // 発見できたとき
    return 1;
  } else {  // 発見できなかったとき
    return 0;
  }
}
int main() {
  int n;
  cin >> n;
  vector<int> a;
  int d;
  for (int i = 0; i < n; i++) {
    cin >> d;
    a.push_back(d);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  ll ans = a[0];
  int count = 0;
  a.erase(a.begin());
  int j = 0;
  while (count < n - 2) {
    ans = ans + a[j];
    // cout << "ans=" << ans << endl;
    // cout << "count=" << count << endl;
    count++;
    if (count % 2 == 0) {
      j++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 4312
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;


int main() {  
  ll W, H, n; cin >> W >> H >> n;
  ll w = 0, h = 0;
  rep(i, 0, n){
    ll x, y, a; cin >> x >> y >> a;
    if(a == 1){ 
      w = max(w, x);
    }else if(a == 2){
      W = min(W, x);
    }else if(a == 3){
      h = max(h, y);
    }else {
      H = min(H, y);
    }
  }

  ll ans = (H-h)*(W-w);
  if(ans < 0 || (H-h < 0 && W-w < 0)) ans = 0;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
def prime_sieve(N):
    if N < 2:
        return []
    search_list = list(range(2, N + 1))
    prime_list = []
    while search_list[0] <= N ** 0.5:
        prime_list.append(search_list[0])
        tmp = search_list[0]
        search_list = [i for i in search_list if i % tmp != 0]
    prime_list.extend(search_list)
    return prime_list


A = prime_sieve(100005)
X = int(input())
for p in A:
    if p >= X:
        print(p)
        break

Measured memory_bytes: 7448
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class E { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		var A = GetLongs(N);

		long xor = A.Aggregate((a, e) => a ^ e);
		var ans = A.Select(x => x ^ xor);
		WriteLine(string.Join(" ", ans));
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N, M;
    cin >> N >> M;

    vector<vector<pair<int, int>>> adj(N);
    for (int e = 0, l, r, d; e < M; e++) {
        cin >> l >> r >> d;
        adj[l-1].push_back({ r-1, d });
        adj[r-1].push_back({ l-1, -d });
    }

    vb visit(N);
    vi loc(N);
    for (int i = 0; i < N; i++) if (!visit[i]) {
        visit[i] = true;
        loc[i] = 0;
        for (queue<int> bfs({i}); !bfs.empty(); bfs.pop()) {
            for (auto e : adj[bfs.front()]) {
                if (visit[e.first]) {
                    if (loc[e.first] != loc[bfs.front()] + e.second) {
                        cout << "No\n";
                        return 0;
                    }
                } else {
                    visit[e.first] = true;
                    loc[e.first] = loc[bfs.front()] + e.second;
                    bfs.push(e.first);
                }
            }
        }
    }

    cout << "Yes\n";
    return 0;
}



Measured memory_bytes: 9344
ABC = list(map(int, input().split()))
max_num = max(ABC)
abs_list = [abs(max_num-i) for i in ABC]
if sum(abs_list) % 2 == 0:
        res = int(sum(abs_list) / 2)
else:
        res = int((sum(abs_list)) / 2) + 2

print(res)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <iomanip>
#include <sstream>
using namespace std;

int sum_digit(int n){
  if( n == 0 ) return 0;
  else return n%10 + sum_digit(n/10);
}

int main()
{
  int i,j,N; cin >> N;
  vector<int> d(N);
  for(i = 0; i < N; i++){
  	cin >> d.at(i);
  }
  
  sort(d.begin(),d.end());
  
  int count = 1;
  int temp = 0;
  for(i = 0; i < N; i++){
  	if(d.at(0) != d.at(i) && temp != d.at(i)){
      temp = d.at(i);
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+5,mod=998244353;
int n,inv[N],f[N],u[N],vis[N];
bool vv[N];
int tot,p[N];
ll g[N];
void init()
{
    inv[1]=1;
    for(int i=2;i<N;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
    u[1]=1;
    for(int i=2;i<N;i++)
    {
        if(!vv[i]) p[++tot]=i,u[i]=-1;
        for(int j=1;j<=tot&&i*p[j]<N;j++)
        {
            vv[i*p[j]]=true;
            if(i%p[j]==0)
            {
                u[i*p[j]]=0;
                break;
            }
            u[i*p[j]]=-u[i];
        }
    }
    for(int i=1;i<N;i++)
        for(int j=i;j<N;j+=i)
        f[j]=(f[j]+u[j/i]*inv[i])%mod;
}
int main()
{
    init();
    scanf("%d",&n);
    ll ans=0;
    while(n--)
    {
        int x;scanf("%d",&x);vis[x]++;
        ans=(ans-x)%mod;
    }
    for(int i=1;i<N;i++)
        for(int j=i;j<N;j+=i)
        g[i]=(g[i]+1ll*vis[j]*j)%mod;
    for(int t=1;t<N;t++)
        ans=(ans+1ll*f[t]*g[t]%mod*g[t]%mod)%mod;
    ans=ans*inv[2]%mod;
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 28532
#include <bits/stdc++.h> // Tomasz Nowak
using namespace std;     // XIII LO Szczecin
using L = long long;

#define FOR(i, l, r) for(int i = l; i <= r; ++i)
#define REP(i, n) FOR(i, 0, n - 1)
constexpr int inf = 0x3f3f3f3f;

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

	int n, W;
	cin >> n >> W;
	const int mx_val = n * int(1e3) + 1;
	vector<int> dp(mx_val, inf);
	dp[0] = 0;
	while(n --> 0) {
		int w, v;
		cin >> w >> v;
		for(int val = mx_val - 1; val >= v; --val)
			dp[val] = min(dp[val], dp[val - v] + w);
	}
	int best = -1;
	for(int val = 0; val < mx_val; ++val)
		if(dp[val] <= W)
			best = val;
	cout << best << '\n';
}



Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#define ll long long
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

ll d[10000];
int cnt;
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int i;
	for(i=1;i*i<m;i++)if(m%i==0){
		d[cnt++]=i;
		d[cnt++]=m/i;
	}
	if(i*i==m)d[cnt++]=m;
	sortup(d,cnt);
	int ans;
	for(int i=0;i<cnt;i++)if(d[i]<=m/n)ans=d[i];
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
int fg(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
signed main(){
  string a;
  cin>>a;
  rep(i,3){
   if(a.at(i)=='7'){
     cout<<"Yes";
     break;
   }
    else if(i==2){
     cout<<"No";
    }
    else{
      continue;
    }
  }
}


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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  vector<int> V(N);
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'R') V.at(i) = i + 1;
    if (S.at(i) == 'L') V.at(i) = i - 1;
  }
  int cnt = 20;
  while (cnt--) {
    vector<int> tmp(N);
    for (int i = 0; i < N; i++) tmp.at(i) = V.at(V.at(i));
    V = tmp;
  }
  vector<int> ans(N);
  for (int i = 0; i < N; i++) ans.at(V.at(i))++;
  for (auto a : ans) cout << a << "\n"; 
}

Measured memory_bytes: 1400
#include <iostream>
#include <bitset>
#include <cstdio>

using namespace std;


#define MaxC 10000
#define MaxR 10
//bitset<MaxC> pan[MaxR];
int pan[MaxR][MaxC];
int R,C;
int result = 0;

void dfs(int index){//sum表示已经得到的最大1的数目，dfs搜索当前行是否反转，得到最大的1的数
    if (index == R){
        int sum = 0;
        for (int i = 0; i < C; ++i) {// 列
            int num = 0;
            for (int j = 0; j < R; ++j) {//行
                if (pan[j][i] == 1)
                    num++;
            }

            sum+=max(num, R - num);
        }
        result = max(result, sum);
    }else{
        dfs(index + 1);
        for (int i = 0; i < C; ++i) {
            if (pan[index][i] == 1)
                pan[index][i] = 0;
            else
                pan[index][i] = 1;
        }
        dfs(index + 1);
    }

}
int main(){
    while(cin>>R>>C && C != 0 && R != 0){
//    cin>>R>>C;
        for (int i = 0; i < R; ++i) {
            for (int j = 0; j < C; ++j) {
                cin>>pan[i][j];
            }
        }
        dfs(0);
        cout<<result<<endl;
    }
    return 0;
}


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

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

  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  
  vector<int> xx(x);
  sort(xx.begin(), xx.end());
  
  int m = xx[n/2];
  for (int i = 0; i < n; i++) {
    if(x[i]<m){
      cout << m << endl;
    } else {
      cout << xx[n/2-1] << endl;
    }
  }
    
  return 0;
}


Measured memory_bytes: 3712
import java.util.*;
class Main{
    static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int A = sc.nextInt();
        int B = sc.nextInt();
        int ans = -1;
        for(int i=12;i<=1000;i++){
            if(i*8/100==A&&i/10==B){
                ans = i;
                break;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <iostream>

using namespace std;

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

    int dd = 1;
    for (int i = 0; i < d; ++i)
        dd *= 100;

    if (n != 100)
        cout << dd * n << '\n';
    else
        cout << dd * (n + 1) << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,i,ans;//10的10次方超int。 
int s;
int main(){
    cin>>n;
    for(i=sqrt(n);i>0;i--) //从平方根开始搜索，用n除以搜到的第一个数，计算出它的位数就是答案。 
        if(n%i==0){   //找到第一个刚好整除n的因子i
            ans=n/i;
            break;}
    while(ans>0){ //算出i的位数即可
        s++;
        ans/=10;}
    cout<<s;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;

//  last common ancestor
class LCA
{
    int n;
    vector<vector<int>> P;

public:
    vector<int> D;

    //  a in E[b] <=> b in E[a]
    LCA(vector<vector<int>> E, int root)
    {
        n = (int)E.size();
        P = vector<vector<int>>(n);
        D = vector<int>(n);

        function<void (int, int, int)> f = [&](int c, int p, int d)
        {
            D[c] = d;

            if (d>0)
                P[c].push_back(p);
            for (int i=1; 1<<i<=d; i++)
                P[c].push_back(P[P[c][i-1]][i-1]);

            for (int e: E[c])
                if (e != p)
                    f(e, c, d+1);
        };
        f(root, -1, 0);
    }

    int query(int a, int b)
    {
        if (D[a]>D[b])
            swap(a, b);

        int d = D[b]-D[a];
        for (int i=0; d>0; i++)
        {
            if (d&1)
                b = P[b][i];
            d >>= 1;
        }

        if (a==b)
            return a;

        int i = 0;
        while (1<<(i+1)<=D[a])
            i++;
        for (; i>=0; i--)
            if (1<<i<=D[a] && P[a][i]!=P[b][i])
            {
                a = P[a][i];
                b = P[b][i];
            }

        if (D[a]>0)
            a = P[a][0];
        return a;
    }
};


#include <iostream>
using namespace std;

int main()
{
    int N, u, v;
    cin>>N>>u>>v;
    u--, v--;
    vector<vector<int>> E(N);
    for (int i=0; i<N-1; i++)
    {
        int A, B;
        cin>>A>>B;
        E[A-1].push_back(B-1);
        E[B-1].push_back(A-1);
    }

    LCA lca(E, v);
    vector<int> D = lca.D;
    int ans = 0;
    for (int i=0; i<N; i++)
    {
        int a = lca.query(i, u);
        if (D[u]-D[a] < D[a])
            ans = max(ans, D[i]-1);
    }
    cout<<ans<<endl;
}


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

vector<ll> get_divisors(ll num)
{
    vector<ll> divisor_s;
    vector<ll> divisor_l;
    for (ll i = 1; i * i <= num; i++) {
        if (num % i == 0) {
            divisor_s.push_back(i);
            if (i * i < num) {
                divisor_l.push_back(num / i);
            }
        }
    }
    divisor_s.insert(end(divisor_s), rbegin(divisor_l), rend(divisor_l));
    return divisor_s;
}

void main_()
{
    ll N;
    cin >> N;

    auto divisors = get_divisors(N);

    auto sqrtN = static_cast<ll>(sqrt(N));
    ll ans = 0;
    for (auto div : divisors) {
        if (div > sqrtN && N % (div - 1) != 0) { // div*divはオーバーフローする可能性
            ans += div - 1;
        }
    }
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int n, m;
vector<vector<pair<int, int>>> g;
const int INF = 1<<30;

void dijkstra(){
    vector<int> d(n), visited(n);
    priority_queue< pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>> > pq;
    rep(i,n) d[i] = INF;

    pq.push(make_pair(0,0));
    d[0] = 0;
    visited[0] = 1;

    while(!pq.empty()){
        pair<int, int> p = pq.top(); pq.pop();
        int u = p.second;

        if (d[u] < p.first) continue;
        visited[u] = 1;

        for(auto pp : g[u]){
            int v = pp.first;
            if (visited[v]) continue;
            if (d[v] > d[u] + pp.second){
                d[v] = d[u] + pp.second;
                pq.push(make_pair(d[v], v));
            }
        }
    }

    if (d[n-1] == 2){
        cout << "POSSIBLE" << endl; 
    }else {
        cout << "IMPOSSIBLE" << endl; 
    }
}

int main(){
    cin >> n >> m;
    g.resize(n);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(make_pair(b, 1));
    }
    dijkstra();
}

Measured memory_bytes: 14716
from sys import stdin
import math
import bisect
import heapq
import numpy as np
from math import factorial
inf = 10**9

n,k = [int(x) for x in stdin.readline().rstrip().split()]

li = list(map(int,stdin.readline().rstrip().split()))
mi = 10**10
for i in range(n-k+1):
    mi2 = min(abs(li[i+k-1])+abs(li[i+k-1]-li[i]),abs(li[i])+abs(li[i+k-1]-li[i]))
    mi = min(mi,mi2)

print(mi)

Measured memory_bytes: 23116
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<string> v;
    string s;
    for(int i=0;i<n;i++){
        cin>>s;
        v.push_back(s);
    }
    int a_g[26];
    fill(a_g,a_g+26,9999);
    int a_l[26];
    for(int i=0;i<n;i++){
         fill(a_l,a_l+26,0);
        for(int j=0;j<v[i].size();j++){
            a_l[int(v[i][j])-int('a')]++;
        }
        for(int k=0;k<26;k++){
            a_g[k]=min(a_g[k],a_l[k]);
        }
    }
    for(int k=0;k<26;k++){
        //cout<<k<<" "<<a_g[k]<<endl;
        for(int i=0;i<a_g[k];i++){
            cout<<char(int('a')+k);
        }
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

const ll MOD = 1e9+7;
const int MAX = 1001001;
const ll INF =  1e18;
signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n; cin >> n;
    ll sum=0,res=INF;;
    bool ok=0;
    rep(i,n){
        ll a,b; cin >> a >> b;
        if(a!=b)ok=1;
        sum+=a;
        if(a>b) chmin(res,b);
    }
    if(!ok) cout << 0  << endl;
    if(res==INF) res=0;
    else cout << sum-res << endl;
    return 0;
}


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

int H,W;
string s[110];



int main()
{
	cin >> H >> W;
	for(int i=0;i<H;++i) cin >> s[i];
	
	for(int i=0;i<H;++i){
		cout << s[i] << endl;
		cout << s[i] << endl;
	}
	return 0;
}

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

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  string s;
  cin >> s;
  ll a;
  if(s=="SUN")a=7;
  else if(s=="MON")a=6;
  else if(s=="TUE")a=5;
  else if(s=="WED")a=4;
  else if(s=="THU")a=3;
  else if(s=="FRI")a=2;
  else a=1;
  cout << a << endl;

}

Measured memory_bytes: 3608
// Volume0-0002	Digit Number
// 2018.3.10

#include <stdio.h>

int main (void)
{
  unsigned long a;
  unsigned long b;
  unsigned long c;
  
  while (-1 != scanf("%ld %ld\n", &a, &b))
    {
      c = a + b;
      
      if (c < 10)
	printf ("1\n");
      else if (c >= 10 && c < 100)
	printf ("2\n");
      else if (c >= 100 && c < 1000)
	printf ("3\n");
      else if (c >= 1000 && c < 10000)
	printf ("4\n");
      else if (c >= 10000 && c < 100000)
	printf ("5\n");
      else if (c >= 100000 && c < 1000000)
	printf ("6\n");
      else if (c >= 1000000 && c < 10000000)
	printf ("7\n");
    }
  return 0;
}



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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

int main(){
	ll N; cin>>N;
	vector<ll> V(5);
	ll mini = LLONG_MAX;
	rp(i,5){
		cin>>V[i];
		mini = min(mini, V[i]);
	}

	// ll x = N/mini;
	ll x = N/mini + (N%mini? 0:-1);
	ll ans = x+5;
	ote(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

int main() {
	string S,T;
    cin >> S >> T;
    T.pop_back();
    if(S == T) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

using namespace std;
using ll = long long;

template<class M> class SegmentTree {
public:
	using T = typename M::value_type;
private:
	int m;
	int n;
	vector<T> data;
 
	T rec(int l, int r, int node, int node_l, int node_r) {
		if(node_r <= l || node_l >= r)return M::id;
		if(node_l >= l && node_r <= r)return data[node];
		int mid = (node_l + node_r) / 2;
		return M::op(
			rec(l, r, node * 2, node_l, mid),
			rec(l, r, node * 2 + 1, mid, node_r)
		);
	}
 
public:
	SegmentTree(const vector<T>& a) {
		m = a.size();
		for(n = 1; n < (int)a.size(); n <<= 1);
		data.resize(n<<1, M::id);
		for(int i = 0; i < (int)a.size(); i++)data[i + n] = a[i];
		for(int i = n - 1; i >= 1; i--) data[i] = M::op(data[i<<1], data[(i<<1) + 1]);
	}
 
	T get(int l, int r) {
		return rec(l, r, 1, 0, n);
	}
 
	void assign(int index, T val) {
		index += n;
		data[index] = val;
		while(index != 1){
			index >>= 1;
			data[index] = M::op(data[index<<1], data[(index<<1) + 1]);
		}
	}
 
	T operator[] (int i){
		return data[i + n];
	}
 
};

template<class T> class RSQ { public:
using value_type = T;
	static T op(T l, T r){ return l + r; }
	static constexpr T id = 0;
};template <class T> constexpr T RSQ<T>::id;

template<class T> class RMQ {
public:
	using value_type = T;
	static T op(T l, T r){return min(l, r);}
	static constexpr T id = 1e9;
};template <class T> constexpr T RMQ<T>::id;




int main()
{
	int n, q; cin >> n >> q;
	vector<ll> a(n);
	for(int i = 0; i < n; i++)cin >> a[i];
	SegmentTree<RSQ<ll>> tree(a);
	while(q--) {
		int t; cin >> t;
		int x, y; cin >> x >> y;

		if(t == 0) {
			tree.assign(x, y + tree[x]);
		} else {
			cout << tree.get(x, y) << endl;
		}
	}
}


Measured memory_bytes: 16440
//  LINK ZADATKA: http://abc073.contest.atcoder.jp/tasks/abc073_c

#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <complex>
#include <fstream>
#include <cstring>
#include <string>
#include <climits>

using namespace std;

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;


#define FOR(k,a,b) for(int k=(a); k<=(b); ++k)
#define REP(k,a) for(int k=0; k<(a);++k)
#define SZ(a) int((a).size())
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define INF 999999999
#define INFLONG 1000000000000000000
#define MOD 1000000007
#define MAX 100
#define ITERS 100
#define MAXM 200000
#define MAXN 1000000
#define _gcd __gcd
#define eps 1e-9


ll n, sol; 
ll broj; map<ll, ll>polje;
int main(){
	
	scanf("%lld", &n);
	pair<map<ll, ll>::iterator, bool> ret;
	REP(i, n){
		scanf("%lld", &broj);
		ret = polje.insert(pair<ll,ll>(broj, 1));
		if(ret.second == false){
			(ret.first -> second)++;
		}
	}
	for(map<ll, ll>::iterator it = polje.begin(); it != polje.end(); it++) if((it -> second) % 2 == 1) sol++;
		//for(map<ll, ll>::iterator it = polje.begin(); it != polje.end(); it++) printf("%lld %lld\n", (it -> first), (it -> second));

	printf("%lld\n", sol);
 
	
	return 0;
}

Measured memory_bytes: 6528
import sys
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
box,box2,ans = [],[],0
acnt = dict(Counter(a))
acnt = sorted(acnt.items(), key=lambda x:x[0],reverse=True)
a_val = [acnt[x][1] for x in range(len(acnt))]
a_key = [acnt[y][0] for y in range(len(acnt))]
for i in range(len(a_val)):
	if a_val[i] >= 4:
		box2.append(a_key[i]**2)
	if 2 <= a_val[i]:
		box.append(a_key[i])
box.sort(reverse=True)
if len(box2) >= 2:	
	ans = max(box2)
if len(box) >= 2:
    print(max(ans,(box[0]*box[1])))
    sys.exit()
print(0)

Measured memory_bytes: 27176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;


int main(){	
	long long K;
	scanf("%lld",&K);
	vector<long long> A(K-1+1);
	for(int i = 0 ; i <= K-1 ; i++){
		scanf("%lld",&A[i]);
	}
	vector<long long> L(K+1), R(K+1);
	for (ll i = K; i >= 0; --i) {
		if (i == K) {
			L[i] = 2;
			R[i] = 2;
		} else {
			L[i] = (L[i+1]+A[i]-1)/A[i]*A[i];
			R[i] = R[i+1]/A[i]*A[i]+A[i]-1;
		}
		// cout << i+1 << " " << L[i] << " " << R[i] << endl;
		if (i != 0 && (R[i] < (L[i]+A[i-1]-1)/A[i-1]*A[i-1] || L[i] > R[i]/A[i-1]*A[i-1])) {
			cout << "-1\n";
			return 0;
		}
	}
	cout << L[0] << " " << R[0] << endl;
	return 0;
}



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

typedef long long ll;
ll mod = 1000000007;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    ll h, n;
    cin >> h >> n;
    ll ans=0;
    ll x;
    for(int i=0; i<n; i++){
        cin >> x;
        ans+=x;
    }

    if(ans>=h) cout << "Yes\n";
    else cout << "No\n";    

    return 0;
}


Measured memory_bytes: 256