akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class DColoringEdgesOnTree {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        vc<int> deg(N), ans(N-1);
        vvc<pii> G(N);
        REP(i, N-1){
            int a, b;
            in>>a>>b;
            a--, b--;
            G[a].eb(b, i);
            G[b].eb(a, i);
            deg[a]++, deg[b]++;
        }
        int K = *max_element(ALL(deg));

        function<void(int, int , int)> dfs = [&](int s, int p, int col){
            int nxt = (col+1) % K;
            for(auto& e : G[s]){
                if(e.first==p) continue;
                ans[e.second] = nxt + 1;
                dfs(e.first, s, nxt);
                nxt = (nxt+1) % K;
            }
        };

        dfs(0, -1, -1);

        out<<K<<'\n';
        for(auto& a : ans) out<<a<<'\n';
    }
};


int main() {
	DColoringEdgesOnTree solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 13076
l, r = list(map(int, input().split()))
# A = list(map(int, input().split()))
#a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# q = int(input())
#a = list(map(int, input().split()))
# b = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
#x = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
# for i in range(1, int(n**0.5)+1):

mod = 2019
a = l//mod
b = r//mod

if b-a > 0:
    print(0)
else:
    m = 2020
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            a = (i*j) % mod
            if a < m:
                m = a

    print(m)


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

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

	int n,m,k,x;
	cin>>n>>m;
	vector<int> a[m];
	int p[m];
	for(int i=0;i<m;i++){
		cin>>k;
		for(int j=0;j<k;j++){
			cin>>x;
			x--;
			a[i].push_back(x);
		}
	}
	for(int i=0;i<m;i++) cin>>p[i];

	int temp,cnt,flag,ans=0;
	int on[n];
	for(int mask=0;mask<(1<<n);mask++){
		temp=mask;
		for(int i=0;i<n;i++){
			if(temp&1) on[i]=1;
			else on[i]=0;
			temp>>=1;
		}
		flag=1;
		for(int i=0;i<m;i++){
			cnt=0;
			for(int j:a[i]){
				cnt+=on[j];
			}
			if((cnt&1)!=p[i]) flag=0;
		}
		if(flag) ans++;
	}
	cout<<ans<<"\n";
	
	return 0;
}

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

int main(){
	int a, b, c, d;
  
  	cin >> a;
  	cin >> b;
  
  	if(b<10){
    	c = a*10 + b;
    }else if(b>=10 && b<100){
    	c = a*100 + b;
    }else{
    	c = a*1000 + b;
    }
 
	d = sqrt(c);
  
  	if(d*d == c){
      cout << "Yes";
    }else{
    	cout << "No";
    }
  
  return 0;
}



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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	string s;
	cin >> s;
	int w;
	cin >> w;
	for(int i = 0; i < s.size(); i++) {
		if(i % w == 0) cout << s[i];
	}
	cout << endl;
	return 0;	
}


Measured memory_bytes: 256
R,C,K=map(int,input().split())

Value=[[0]*(C+1) for _ in range(R+1)]
for _ in range(K):
    r,c,v=map(int,input().split())
    Value[r][c]=v

DP=[[0,0,0,0] for _ in range(C+1) ]

for y in range(1,R+1):
    #下に移動
    for x in range(1,C+1):
        DP[x][0]=max(DP[x])
        DP[x][1]=DP[x][0]+Value[y][x]
        DP[x][2]=DP[x][3]=0

    #右に移動
    for x in range(1,C+1):
        for k in range(0,3+1):
            DP[x][k]=max(DP[x][k],DP[x-1][k])

        for k in range(1,3+1):
            DP[x][k]=max(DP[x][k],DP[x-1][k-1]+Value[y][x])

print(max(DP[-1]))

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

int main(){
    int K;
    cin >> K;
    string S;
    cin >> S;
    int wordlength;
    wordlength = (int)(S.length());
    if (wordlength <= K){
	cout << S << endl;
    }else {
	S = S.substr(0,K);
	string T;
	T = "...";
	S = S + T;
	cout << S << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>

void funcA() {
  std::string n;
  std::cin >> n;
  int c = (int)(n[n.size() - 1] - '0');
  if (c == 3) std::cout << "bon";
  else if (c == 0 || c == 1 || c == 6 || c == 8)std::cout << "pon";
  else std::cout << "hon";
}

int main(void) {
  funcA();
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<tuple<int, int, int, int>> abcd(Q);
  for (int i=0; i<Q; i++) cin >> get<0>(abcd[i]) >> get<1>(abcd[i]) >> get<2>(abcd[i]) >> get<3>(abcd[i]);
  vector<int> ans;
  for (int A1=1; A1<=M; A1++) {
    for (int A2=A1; A2<=M; A2++) {
      for (int A3=A2; A3<=M; A3++) {
        for (int A4=A3; A4<=M; A4++) {
          for (int A5=A4; A5<=M; A5++) {
            for (int A6=A5; A6<=M; A6++) {
              for (int A7=A6; A7<=M; A7++) {
                for (int A8=A7; A8<=M; A8++) {
                  for (int A9=A8; A9<=M; A9++) {
                    for (int A10=A9; A10<=M; A10++) {
                      vector<int> A = {A1, A2, A3, A4, A5, A6, A7, A8, A9, A10};
                      int num = 0;
                      for (int i=0; i<Q; i++) {
                        if (A[get<1>(abcd[i])-1]-A[get<0>(abcd[i])-1]==get<2>(abcd[i])) num += get<3>(abcd[i]);
                        ans.push_back(num);
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  sort(ans.begin(), ans.end());
  reverse(ans.begin(), ans.end());
  cout << ans[0] << endl;
}


Measured memory_bytes: 36192
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int X = int.Parse(str[0]);
		int N = int.Parse(str[1]);
		int[]A = new int[N];
		if(N==0){
			Console.WriteLine(X);
		} else {
		string[] str2 = Console.ReadLine().Split();
		int[]B = new int[102];
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str2[i]);
			B[A[i]]++;
		}
		int ans = 99999999;
		int min = 99999999;
		for(var i=0;i<102;i++){
			if(B[i]==0){
				int m = Math.Abs(X-i);
				if(m<min){
					ans = i;
					min = m;
				}
			}
		}
		Console.WriteLine(ans);
		}
	}
}

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

int main(){
    vector <int> in(5,0);
    int k,i,j;

    for(i =0;i<5;i++){
        cin >> in.at(i);
    }
    cin >> k;
    bool ans = false;
    for(i = 0;i<5;i++){
        for(j = 0;j<i;j++){
            if(abs(in[i] - in[j]) >k ){
                ans = true;
            }
        }
    }
    if(ans){
        cout << ":(" << endl;
    }
    else{
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long H, W, N;
  cin >> H >> W >> N;
  vector<pair<long, long>> ta(H), yo(W);
  map<pair<long, long>, long> mp;
  for(int i = 0; i < H; i++)ta.at(i).second = i;
  for(int i = 0; i < W; i++)yo.at(i).second = i;
  long h, w;
  for(int i = 0; i < N; i++){
    cin >> h >> w;
    h--;
    w--;
    ta.at(h).first++;
    yo.at(w).first++;
    mp[make_pair(h, w)]++;
  }
  sort(ta.begin(), ta.end());
  sort(yo.begin(), yo.end());
  long ans = 0, flag = 0, maxt = ta.at(H - 1).first, maxy = yo.at(W - 1).first;
  for(int i = H - 1; i >= 0; i--){
    if(maxt - ta.at(i).first >= 1)break;
    for(int j = W - 1; j >= 0; j--){
      if(maxy - yo.at(j).first >= 1)break;
      if(mp.count(make_pair(ta.at(i).second, yo.at(j).second)) == 0){
        ans = max(ans, ta.at(i).first + yo.at(j).first);
        flag = 1;
        break;
      }else ans = max(ans, ta.at(i).first + yo.at(j).first - 1);
    }
    if(flag == 1)break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 31500
N=int(input())
ans=N
for i in range(N+1):
    cnt=0
    t = i
    while t>0:
        cnt+=t%6
        t//=6
    t=N-i
    while t>0:
        cnt+=t%9
        t//=9
    ans=min(ans,cnt)
print(ans)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int[] antennas = new int[5];
        for(int i = 0;i<5;i++){
            antennas[i] = scanner.nextInt();
        }

        final int distance = scanner.nextInt();

        for(int i = 0;i<5;i++){
            for(int j = i+1;j<5;j++){
                if(antennas[j]-antennas[i] > distance){
                    System.out.println(":(");
                    return;
                }
            }
        }
        System.out.println("Yay!");
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
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; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int a, b; cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3632
import math

X = int(input())
prime = False
primecheck = True

if X <= 2:
    prime_num = X

else:
    while prime == False:

        for i in range(2, int(math.sqrt(X))):
            if X % i == 0:
                X += 1
                primecheck = False
                break

        if primecheck == False:
            primecheck = True
        else:
            prime = True
            prime_num = X

print(prime_num)

Measured memory_bytes: 3060
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int l = sc.nextInt();

		int sum = 0;
		int min = Integer.MAX_VALUE;
		int mini = 0;
		for (int i = 0; i < n; i++) {
			sum += l + i;
			if (Math.abs(l + i) < min) {
				min = Math.abs(l + i);
				mini = i;
			}
		}
		
		pr.println(sum - (l + mini));
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 22100
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;
long long t[100005];
int main()
{
	long long n,a,b;
	cin>>n>>a>>b;
	long long x=0;
	for(int i=0;i<n;i++)
	{
		cin>>t[i];
	}
	for(int i=0;i<n-1;i++)
	{
		if((t[i+1]-t[i])*a>=b)
		{
			x+=b;
		}
		else
		{
			x=x+(t[i+1]-t[i])*a;
		}
	}
	cout<<x<<endl;
	return 0;
} 

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int ans = 0;
		for (int i = 1; i < n - 1; i++) {
			int count = 0;
			for (char c = 'a'; c <= 'z'; c++) {
				if (s.substring(0, i).contains(String.valueOf(c)) && s.substring(i).contains(String.valueOf(c))) {
					count++;
				}
			}
			ans = Math.max(ans, count);
		}
		System.out.println(ans);

	}
}

Measured memory_bytes: 24020
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<numeric>
#include<map>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
 
using namespace std;
 
int main(){
    int N;  cin >> N;
    vector<int> A(N), c(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
        c[i] = A[i] - (i+1);
    }
    sort(all(c));
    int m;
    ll ans = 0, ans1 = 0;
    if(N%2==1){
        m = c[N/2];
        for(int i=0; i<N; i++)  ans += abs(c[i]-m);
    }else{
        m = c[N/2];
        for(int i=0; i<N; i++)  ans += abs(c[i]-m);
        m = c[N/2-1];
        for(int i=0; i<N; i++)  ans1 += abs(c[i]-m);
        ans = min(ans, ans1);      
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int a,b;
	cin >> a >> b;
	if(a==1){
		a=14;
	}
	if (b==1){
		b=14;
	}
	if (a>b){
		cout << "Alice" << endl;
	}
	if (a<b){
		cout << "Bob" << endl;
	}
	if (a==b){
		cout << "Draw" << endl;
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

int n, a[55];
vector<II> res;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    int Max = -1, vt = 0;
    bool pos = false, neg = false;
    FOR(i,1,n)
        if (a[i] >= 0) {
            if (a[i] > Max) {
                vt = i;
                Max = a[i];
            }
            pos = true;
        }
        else {
            if (-a[i] > Max) {
                vt = i;
                Max = -a[i];
            }
            neg = true;
        }
    if (pos && neg) {
        if (a[vt] >= 0) {
            FOR(i,1,n)
                if (a[i] < 0) res.emplace_back(II(vt, i));
        }
        else {
            FOR(i,1,n)
                if (a[i] >= 0) res.emplace_back(II(vt, i));
        }
    }
    if (a[vt] >= 0) {
        FOR(i,1,n-1) res.emplace_back(II(i, i+1));
    }
    else {
        FORE(i,n,2) res.emplace_back(II(i, i-1));
    }
    cout << SZ(res) << "\n";
    FOR(i,0,SZ(res)-1) cout << res[i].FI << ' ' << res[i].SE << "\n";
    return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

const long long MAX = 1100000;  // 最大を決めておく
// fac…階乗、inv…逆数、finv…逆数の累積積
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理、先にやっておく
void nCr_init() {
  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を計算する (前処理は忘れないように)
long long nCr(int n, int 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() {
  nCr_init();
  ll x, y;
  cin >> x >> y;

  // 気合い
  ll nowx = 0, nowy = 0, countx = 0, county = 0;
  while ((y - nowy) != (x - nowx) * 2) {
    if (x < nowx) {
      cout << 0 << endl;
      return 0;
    }
    nowx += 2;
    nowy += 1;
    countx++;
  }
  while (!((y == nowy) && (x == nowx))) {
    if (y < nowy) {
      cout << 0 << endl;
      return 0;
    }
    nowx += 1;
    nowy += 2;
    county++;
  }

  cout << nCr(countx + county, countx) << endl;
}


Measured memory_bytes: 26112
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

int main() {
    int n, q, sum=0;
    int A[2001]={}, m[2001]={};
    std::cin >> n;
    for (int i=0; i<n; i++) {
        std::cin >> A[i];
        sum+=A[i];
    }
    std::cin >> q;
    for (int i=0; i<q; i++) {
        std::cin >> m[i];
    }

    for (int j=0; j<q; j++) {
        int C;
        bool no=true;
        if (m[j]>sum) {
            std::cout << "no" << std::endl;
            continue;
        }
        for (int i=0; i < std::pow(2,n); i++) {
            C=0;
            for (int j=0; j<n; j++) {
                if ((i >> j) & 1) {
                    C+= A[j];
                }
            }
            if(C==m[j]) {
                std::cout << "yes" << std::endl;
                no=false;
                break;
            }
        }
        if (no) {
            std::cout << "no" << std::endl;
        }
    }

    return 0;
}


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

typedef long long ll;

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

    ll x,y,ans=0;
    cin >> x >> y;
    for(ll i=x;i<=y;i*=2) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int N;
    cin >> N;
    vector<vector<ll>> A(N, vector<ll>(N));
    auto dist = A;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
            cin >> A[i][j];
            dist[i][j] = A[i][j];
        }
    }

    for(int k = 0; k < N; ++k){
        for(int i = 0; i < N; ++i){
            for(int j = 0; j < N; ++j){
                chmin(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    for(int i = 0; i < N; ++i){
        for(int j = 0; j < i; ++j){
            if(dist[i][j] != A[i][j]){
                cout << -1 << endl;
                return 0;
            }
        }
    }

    ll ans = 0;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < i; ++j){
            ans += dist[i][j];
            for(int k = 0; k < N; ++k){
                if(k == i || k == j)    continue;
                if(dist[i][j] == dist[i][k] + dist[k][j]){
                    ans -= dist[i][j];
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4764
import sys
input = sys.stdin.readline


N = int(input())
A = [int(input()) for _ in range(N)]

w = 0
for a in A:
    w ^= a

canuse = [True]*N

ans = 0
while w != 0:
    l = w.bit_length()-1
    use = -1
    for i, a in enumerate(A):
        if (1<<l)&a and canuse[i] and not (1<<l)&(a-1):
            canuse[i] = False
            use = a
            break
    if use == -1:
        ans = -1
        break
    ans += 1
    w = w ^ use ^ (use-1)
print(ans)

Measured memory_bytes: 7840
maximam = 2**31 - 1

class Segment_Tree:
    def __init__(self,n):
        self.n = n
        self.tree = [maximam]*(2*self.n - 1)
    def update(self,i,x):
        i += self.n-1
        self.tree[i] = x
        while i>0:
            i = int((i-1)/2)
            self.tree[i] = min(self.tree[2*i+1],self.tree[2*i+2])
    def find(self,a,b,k,l,r):
        if r <= a or b <= l:
            return maximam
        if a <= l and r <= b:
            return self.tree[k]
        vl = self.find(a,b,k*2+1,l,int((l+r)/2))
        vr = self.find(a,b,k*2+2,int((l+r)/2),r)
        return min(vl, vr)

n, q = map(int, input().split())
N = 1
while N < n:
    N *= 2

segtre = Segment_Tree(N)

for _ in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        segtre.update(x,y)
    else:
        print(segtre.find(x,y+1,0,0,N))



Measured memory_bytes: 8692
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
int main()
{
    string s;
    cin>>s;
    int64_t su=0;
    for(int i=0;i<s.size();i++)
    {
        su+=s[i]-'0';
    }
    if(su%9) cout<<"No\n";
    else cout<<"Yes\n";
    return 0;
}

Measured memory_bytes: 3716
/*for better*/
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(i=a;i<b;i++)
#define fr(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define M 998244353
#define inf 1e9+10
using namespace std;

ll dp[1005][1005];

int main()
{
    fast; 
    int n,m,i,j;
    cin>>n>>m;
    char ar[n+1][m+1];
    f(i,1,n+1)
    	f(j,1,m+1)
    		cin>>ar[i][j];

    dp[1][1]=1;

    f(i,1,n+1)
    	f(j,1,m+1)
    		if(ar[i][j]=='.')
    			dp[i][j]+=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;

    cout<<dp[n][m];
}


Measured memory_bytes: 9088
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    
    int cnt = 0;

    for(int i = 1; i <= n; i++){
      int num = sc.nextInt();
      
      if(i % 2 == 1 && num % 2 == 1){cnt++;}
    }
    
    System.out.println(cnt);
  }
}

Measured memory_bytes: 35772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
    int n; cin>>n;
    ll ans = 0;
    vector <int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]--;
    }
    for(int i=0;i<n-1;i++){
        if(a[i]==i) {
            int tmp = a[i+1];
            a[i+1] = a[i];
            a[i] = tmp;
            ans++;
        }
    }
    for(int i=n-1;i>0;i--){
        if(a[i]==i) {
            int tmp= a[i];
            a[i] = a[i-1];
            a[i-1] = tmp;
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 768
#include<iostream>
#include<cmath>
using namespace std;
struct infor
{
	int x;
	int y;
	int h;
};

infor in[101], in1[101], in2[101];
int main()
{
	int N;
	int i, j = 0, k = 0;
	int Xc, Yc;
	cin >> N;
	for (i = 0; i < N; i++)
	{
		cin >> in[i].x >> in[i].y >> in[i].h;
		if (in[i].h > 0)
			in1[j++] = in[i];
		else
			in2[k++] = in[i];
	}

	int m;
	for (Xc = 0; Xc < 101; Xc++)
	{
		for (Yc = 0; Yc < 101; Yc++)
		{
			int H;
			H = in1[0].h + abs(Xc - in1[0].x) + abs(Yc - in1[0].y);
			int flag1, flag2;
			flag1 = flag2 = 1;
			for (m = 1; m < j; m++)
			{
				if (H == in1[m].h + abs(Xc - in1[m].x) + abs(Yc - in1[m].y));
				else
				{
					flag1 = 0;
					break;
				}
			}

			if (flag1)
			{
				for (m = 0; m < k; m++)
					if (H - abs(in2[m].x - Xc) - abs(in2[m].y - Yc) > 0)
					{
						flag2 = 0;
						break;
					}
				if (flag2)
				{
					cout << Xc << ' ' << Yc << ' ' << H;
					return 0;
				}
			}
			else continue;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,INF=mod*mod*3;//M_PI
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

string T;

int main(){

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

cin>>T;
ll N=T.size();
rep(i,N) if(T[i]=='?') T[i]='D';
cout<<T<<endl;

}
    


Measured memory_bytes: 3740
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
typedef  long long ll;
const int maxn=2e5+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;

int a[maxn];
int main()
{
    ll n;
    cin>>n;
    string s;
    while(n--)
    {
        s=(char)('a'+n%26)+s;
        n/=26;
    }
    cout<<s<<endl;
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

#define ll long long

using namespace std;

bool f(int a, int b, int c, int k) {
    if (k == 0) return a < b && b < c;
    if (a < b && b < c) return true;
    bool case1 = f(a * 2, b, c, k - 1);
    bool case2 = f(a, b * 2, c, k - 1);
    bool case3 = f(a, b, c * 2, k - 1);
    if (case1 || case2 || case3) return true;
    return false;
}

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    if (f(a, b, c, k)) cout << "Yes";
    else cout << "No";
}


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

using namespace std;
typedef long long LL;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  LL r=0, g=0, b=0;
  rep(i,N){
    if(S[i]=='R') r++;
    if(S[i]=='G') g++;
    if(S[i]=='B') b++;
  }
  LL ans=r*g*b;
  rep(i,N){
    for(int j=i+1; j<N; j++){
      if(j*2-i<N&&S[i]!=S[j]&&S[j]!=S[j*2-i]&&S[i]!=S[j*2-i]) ans--;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3612
while True:
    n = int(input())
    if n == 0:
        break
    p = [10, 10]
    l = [list(map(int,input().split())) for _ in range(n)]
    for d,s in [input().split() for _ in range(int(input()))]:
        for _ in range(int(s)):
            if d == 'N':
                p[1] += 1
            elif d == 'E':
                p[0] += 1
            elif d == 'W':
                p[0] -= 1
            elif d == 'S':
                p[1] -= 1
            if p in l:
                l.remove(p)
    if len(l) == 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 7712
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	_ = sc.NextInt()
	A := []byte(sc.Next())

	Rcount := 0
	WCount := 0
	for _, v := range A {
		if v == 'R' {
			Rcount++
		} else {
			WCount++
		}
	}
	RtoW := 0
	WtoR := 0
	for i, v := range A {
		if v == 'R' {
			if i < Rcount {

			} else {
				RtoW++
			}
		} else {
			if i < Rcount {
				WtoR++
			} else {
			}
		}
	}
	S := min(RtoW, WtoR)
	R := max(RtoW-S, WtoR-S)
	fmt.Println(S + R)
}

func max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 3308
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e9+7;
ll INF=1e10;

int main(){
      ll n,m; cin>>n>>m;
  if(n==1){
    cout<<m<<endl;
    return 0;
  }
  ll ans=0;
  for(ll i=1;i<=sqrt(m);i++){
      if(m%i==0){
          if((m/i)*n<=m){
              ans=max(ans,m/i);
          }
          else if(i*n<=m){
              ans=max(ans,i);
          }
      }
  }
  cout<<ans<<endl;
}



























































































Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
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;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int l, r, d;
    scanf("%d%d%d", &l, &r, &d);
    printf("%d\n", r/d - (l-1)/d);
}

Measured memory_bytes: 3760
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)

from collections import Counter


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    # N, D = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    a_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([]))

    counts = Counter(a_list)

    retval = 0
    for a, c in counts.items():
        retval += int(c * (c - 1) / 2)

    for k in range(N):
        to_remove = a_list[k]
        c = counts[to_remove]
        print(retval - c * (c - 1) // 2 + (c - 1) * (c - 2) // 2)


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5
1 1 2 1 2"""
        output = """2
2
3
2
3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4
1 2 3 4"""
        output = """0
0
0
0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5
3 3 3 3 3"""
        output = """6
6
6
6
6"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """8
1 2 1 4 2 1 4 1"""
        output = """5
7
5
7
7
5
7
5"""
        self.assertIO(input, output)


Measured memory_bytes: 26120
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 r;
int main() {
  cin >> r;
  cout << r * r << endl;
  return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    string t;
    map<string, int> s;
    for(int i =0; i < n ;i++){
        cin >> t;
        s[t]++;
    }
    int maxv = 0;
    for(const auto& x: s){
        int v = x.second;
        if(v > maxv) maxv = v;
    }
    for(auto it = s.begin(); it != s.end(); it++){
        if(it->second == maxv){
            cout << it->first << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 25216
rows, columns = map(int, (input().split()))

matrixA = list()
matrixB = list()

# create matrixA
for _ in range(rows):
    row = list(map(int, input().split()))
    matrixA.append(row)

# create matrixB    
for _ in range(columns):
    num = int(input())
    matrixB.append(num)

# calculation part
result = list()
for ir in range(rows):
    sum = 0
    for ic in range(columns):
        sum += matrixA[ir][ic] * matrixB[ic]
    result.append(sum)
    
# output result
for num in result:
    print(num)



Measured memory_bytes: 6012
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N; 
	bool ans = 0; 
	for(int i = 1; i <= 9; i++){
		for(int j = 1; j <= 9; j++){
			if(i * j == N) ans = 1; 
		}
	}
	cout << (ans ? "Yes" : "No") << endl; 
}

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

int main()
{
    long long a, b, x;
    cin >> a >> b >> x;

    if (a % x != 0)
    {
        a += x - a % x;
    }
    long long ans = a <= b;
    ans += (b - a) / x;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int ans=0;
  for(int i=1;i<=c;i++) {
    if(b>=a*i){
      ans++;
    }
    else{
      break;
    }
    
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    int A[M], pivot = M;
    for (int i = 0; i < M; ++i) {
        cin >> A[i];
        if (A[i] > X) {
            pivot = i;
            break;
        }
    }

    cout << min(M - pivot, pivot) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main() {
    ll n;
    cin >> n;
    vector<ll> a(n+1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    map<ll, ll> m;
    m[a[0]]++;
    for (int i = 1; i <= n; i++) {
       a[i] += a[i-1];
       m[a[i]]++;
    }
    ll ans = 0;
    for (auto& e : m) {
        ans += e.second * (e.second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin>>h[i];
    }
    vector<int> ans(n,0);
    int mans=-1;
    ans[n-1]=0;
    for (int i = n-2; i >= 0; --i) {
        if(h[i]>=h[i+1])ans[i]=ans[i+1]+1;
        else ans[i]=0;
        mans=max(mans,ans[i]);
    }
    mans=max(mans,0);
    cout<<mans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
	int a;long long b;
	cin>>a>>b;
	while(a!=0&&b!=0){
		int i=0;
		long long su[1001];
		static long long su2[1000000];
		for(i=0;i<a;i++){
			cin>>su[i];
		}
		int o=0;
		for(i=0;i<a;i++){
			int k=0;
			for(k=0;k<a;k++){
				su2[o]=su[i]+su[k];
				o++;
			}
		}
		sort(su,su+a,greater<long long>());
		sort(su2,su2+a*a,greater<long long>());
		long long sum=0;
		long long max=0;
		int p=lower_bound(su,su+a,b,greater<long long>())-su;
		if(p!=0&&su[p]==b){
			max=b;
			goto todo;
		}else{
			int v=0;
			for(v=0;v<a;v++){
				p=lower_bound(su2,su2+a*a,b-su[v],greater<long long>())-su2;
				if(su2[p]+su[v]>max&&p!=a*a){
					max=su2[p]+su[v];
				}
			}
			if(max){
				sum=max;
			}else{
				p=lower_bound(su,su+a,b,greater<long long>())-su;
				if(p!=a){
					max=su[p];
					goto todo;
				}
			}
			p=lower_bound(su2,su2+a*a,b,greater<long long>())-su2;
			if(su2[p]>max&&p!=a*a){
				max=su2[p];
			}
			for(v=0;v<a*a;v++){
				p=lower_bound(su2,su2+a*a,b-su2[v],greater<long long>())-su2;
				if(su2[v]+su2[p]>max&&p!=a*a){
					max=su2[v]+su2[p];
				}
			}
			
		}
		todo:
		cout<<max<<"\n";
		cin>>a>>b;
	}
	return 0;
} 


Measured memory_bytes: 10896
def main():
    n,p=map(int,input().split())
    s=list(map(int,list(input())))
    cnt,ans=0,0
    m=[0]*p
    m[0]=1

    if p in [2, 5]:
        for i, x in enumerate(s):
            if x % p == 0:
                ans += i + 1
        print(ans)
        exit()

    sm=0
    d=1
    for i in range(n):
        sm=(sm+s[n-1-i]*d)%p
        m[sm]+=1
        d=(d*10)%p
    
    for i in m:
        ans+=i*(i-1)//2

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 6560
#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;

// ?????¬???????????¬??????
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i, x, n) for(int i=x; i<=(int)n; i++)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), c.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<double> vd;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<long, long> pil;

// ??°?????????????????¬??????
typedef int Weight;

struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) {}
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;


int main() {
  int a, b, c;
  int cnt = 0;
  scanf("%d %d %d", &a, &b, &c);
  REP(i, a, b) {
    if (c%i==0) cnt++;
  }
  printf("%d\n", cnt);

  return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define retunr return
#define pb push_back
#define mp make_pair
#define null NULL
#define sc(x) scanf("%d", &x)
#define sc64(x) scanf("%I64d", &x)
#define pr(x) printf("%d", (x))
#define sp putchar(' ')
#define ln putchar('\n')
#define pr64(x) printf("%I64d", (x))
#define rep(i,l,r) for (int i = l, lim = r;i <= lim; ++i)
#define repr(i,l,r) for (int i = r, lim = l;i >= lim; --i)
#define fi first
#define se second
#define SET(__set, val) memset(__set, val, sizeof __set)
#define prf(x) printf("%.20f", x)
typedef unsigned int uint;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define N 100010
#define M 1024
#define MOD 1000000007
void _add(int &a, int b){a = (a+b)%MOD;}
void _sub(int &a, int b){a = (a+MOD-b)%MOD;}
void _mul(int &a, int b){a = (ll)a*b%MOD;}
void _max(int &a, int b){a = max(a,b);}
void _min(int &a, int b){a = min(a,b);}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b,a%b);}
ll pw(ll a, ll b){ll res(1);while(b){if(b&1)res=res*a%MOD;a=a*a%MOD;b>>=1;}return res;}
ll pwM(ll a, ll b, ll mod){ll res(1);while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

const int infi = 2147483647;
const ll infl = 9223372036854775807ll;
const db PI = 3.14159265358979323846;

/*
struct E{
	int v, w, n;
}G[N];
int cnt, point[N];
void adde(int u, int v, int w = 0){
	G[++cnt]=(E){v,w,point[u]},point[u]=cnt;
	G[++cnt]=(E){u,w,point[v]},point[v]=cnt;
}
void Ginit(){
	cnt = 0;
	SET(point,0);
}
*/
/*
struct hh{
	int a, b;
	bool operator < (const hh &x) const{
		if(a==x.a)return b<x.b;
		return a<x.a;
	}
}a[N];
*/
int n, m, k,q;
int main(){
//	freopen("1", "r", stdin);
	ll a,b,c,d;
	int Case;
	
	cin>>(Case);
	rep(ca, 1, Case){
		int ok = 1;
		cin>>a>>b>>c>>d;
		if(a < b){
			ok = 0;
		}else
		if(b>d){
			ok = 0;
		}else
		if(c>=b-1){
			ok = 1;
		}else{
			if(c < b-gcd(b,d)+a%(gcd(b,d))){
				ok = 0;
			}else{
				ok = 1;
			}
		}
		puts(ok?"Yes":"No");
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())
ABC = []
for i in range(N):
    ABC.append(list(map(int,input().split())))
dp = [[0]*3 for i in range(N)]
dp[0] = ABC[0]
if N>1:
    for i in range(1,N):
        dp[i][0] = max(dp[i-1][1]+ABC[i][0],dp[i-1][2]+ABC[i][0])
        dp[i][1] = max(dp[i-1][0]+ABC[i][1],dp[i-1][2]+ABC[i][1])
        dp[i][2] = max(dp[i-1][0]+ABC[i][2],dp[i-1][1]+ABC[i][2])
print(max(dp[-1]))

Measured memory_bytes: 74900
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;



int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while(cin >> n){
    TSTART();
    int ans = 1;
    while(ans*2 <= n){
      ans *= 2;
    }
    cout << ans << endl;
    TSTOP();
  }
  return 0;
}



Measured memory_bytes: 256
MOD = 10 ** 9 + 7

H, W, A, B = map(int, input().split())

# inv[k]: kの逆元
N = H - 1
inv = [0] * (N + 1)
inv[1] = 1
for k in range(2, N + 1):
    inv[k] = (-(MOD // k) * inv[MOD % k]) % MOD

# C1s[i]: 左上のマス目から、「左からB個目・上からi個目のマス目」まで移動する場合の数
n1 = B - 1
C1s = [0] * (H - A)
C1s[0] = 1
for r in range(1, H - A):
    C1s[r] = (C1s[r - 1] * (n1 + r) * inv[r]) % MOD

# C2s[i]: 「左から(B+1)個目・下からi個目のマス目」から、右下のマス目まで移動する場合の数
n2 = W - B - 1
C2s = [0] * H
C2s[0] = 1
for r in range(1, H):
    C2s[r] = (C2s[r - 1] * (n2 + r) * inv[r]) % MOD

ans = 0
for i in range(H - A):
    ans += (C1s[i] * C2s[- 1 - i]) % MOD
    ans %= MOD

print(ans)


Measured memory_bytes: 14484
n, *a = map(int, open(0).read().split())
a.sort()
cnt = -1
prev = a[0]
b = []
for i in a:
    if prev==i: cnt+=1
    else:
        b.append(cnt)
        cnt = 0
    prev = i
b.append(cnt)
print(n-(sum(b)+1)//2*2)

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

int main(){
    int n;
    cin >> n;
    vector<double> a(n);

    for (int i = 0; i < n; i++){
        cin >> a.at(i);
    }

    double sum = 0;
    double x = 1;
    
    for (int i = 0; i < n; i++){
        sum += x/a[i];
    }

    cout << x / sum << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int p = sc.nextInt();
		String s = sc.next();
		
		// 計算
		long result = 0;
		if(p == 2 || p == 5){
		    for(int i = 0; i < n; i++){
		        if((s.charAt(i)-'0')%p == 0) result += i+1;
		    }
		    System.out.println(result);
		    return;
		}
		
		int[] sum = new int[n+1];
		int pow = 1;
		for(int i = 0; i < n; i++){
		    sum[i+1] = (sum[i] + (s.charAt(n-1-i)-'0')*pow)%p;
		    pow *= 10;
		    pow %= p;
		}
		int[] cnt = new int[p];
		for(int i = 0; i < n+1; i++){
		    result += cnt[sum[i]];
		    cnt[sum[i]]++;
		}
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 26564
#include <iostream>

int main(){
    int a,b,c;
    std::cin>>a>>b>>c;
    long long ans=0ll;
    while(a%2==0&&b%2==0&&c%2==0){
        int q,w,e;
        q=a/2+b/2;w=b/2+c/2;e=c/2+a/2;
        c=q;a=w;b=e;
        ++ans;
        if(ans>10000000){
            ans=-1;
            break;
        }
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
let pow x y =
  let rec f m n odd b = match n with
      0 -> 1
    | 1 -> m * odd
    | _ -> let t = if n mod 2 = 1 then odd * b else odd in
           f (m * m) (n/2) t (b * b)
  in f x y 1 x;;

let rec read () =
  let n = read_int () in
  if n != 0 then
    begin
      let rec f ct i =
        let d = n / (pow 5 i) in
        if d > 0 then f (d+ct) (i+1) else ct
      in
      Printf.printf "%d\n" (f 0 1);
      read ()
    end
;;
let () = read ();;

Measured memory_bytes: 2268
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  ll l,r,i,j;
  cin >> l >> r;
  if(r-l>=2019){
    cout << 0 << endl;
    return 0;
  }
  ll ans=2000000000;
  for(i=l;i<=r;i++){
    for(j=i+1;j<=r;j++){
      ans=min(ans,i*j%2019);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3560