akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i=0;i<N;i++) cin >> L[i];

    int count=0;

    sort(L.begin(),L.end());
    for(int i=N-1;i>1;i--){
        for(int j=i-1;j>0;j--){
            for(int k=j-1;k>=0;k--){
                if(L[i]>=L[j]+L[k]){
                    continue;
                }else{
                    count++;
                    continue;
                }
            }
        }
    }

    cout << count << endl;
}

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

int main(){
  int A,B,C,X,i=0;
  cin>>A>>B>>C>>X;
  for(int a=0;a<=A;a++)
    for(int b=0;b<=B;b++)
      for(int c=0;c<=C;c++)
        if(a*500+b*100+c*50==X)
          i++;
  cout<<i<<endl;
}

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

int main ()
{
    string  s ;
    cin >> s;
    map <int,int> c;
    int  ss=0,ans=0,cur=1;
    c[0] = 1 ; 
    for (int i=s.size()-1;i>=0;i--){
        ss = (ss+(s[i]-'0')*cur)%2019;
        ans += c[ss] ; 
        c[ss]++ ; 
        cur = (cur*10)%2019; 
    }
    cout << ans << endl ; 
    return 0;
}


Measured memory_bytes: 3732
import math

N, K  = map(int, input().split())
A = list(map(int, input().split()))

B = [[0] * 2 for _ in range(40)]

for i in range(N):
  Ai = A[i]
  for j in range(40):
    if Ai % 2 == 0:
      B[j][0] += 1
    else :
      B[j][1] += 1
    Ai = Ai // 2
    #print(B)

Xmax = 0
if K != 0:

  Kd = int(math.log2(K))+1

  for i in range(Kd-1,-1,-1):
    if B[i][0] > B[i][1]:
      Xmax += 2**i
      if Xmax > K:
        Xmax -= 2**i
    
ans = 0
for i in range(N):
  ans += Xmax ^ A[i]

print(ans)

Measured memory_bytes: 14620
import java.util.Scanner;

public class Main {

	static int c = 0;

	public static void bubbleSort(int[] A, int n) {

		boolean flag = true;

		while (flag) {
			flag = false;
			for (int i = n - 1; i > 0; i--) {
				if (A[i] < A[i - 1]) {
					int tmp = A[i];
					A[i] = A[i - 1];
					A[i - 1] = tmp;
					c++;
					flag = true;
				}
			}
		}
	}

	public static void printArray(int[] A, int n) {

		for (int i = 0; i < n - 1; i++) {

			System.out.print(A[i] + " ");
		}
		System.out.println(A[n - 1]);
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int A[] = new int[n];

		for (int i = 0; i < n; i++) {
			A[i] = sc.nextInt();
		}
		sc.close();

		bubbleSort(A, n);

		printArray(A, n);

		System.out.println(c);

	}

}



Measured memory_bytes: 26424
#include<iostream>
using namespace std;
int main(){
 int x[3000][2];
 for(int i=0; i<3000; i++){
  cin >> x[i][0] >> x[i][1];
  int a;
  if(x[i][0]>x[i][1]){
   a = x[i][0];
   x[i][0] = x[i][1];
   x[i][1] = a;
  }
  if(x[i][0] == 0 && x[i][1] == 0) break;
  cout << x[i][0] << " " << x[i][1]<<endl; 
 }
}


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

int main(){
  string S;
  cin >> S;
  if(S.back() == '?') S.back() = 'D';
  for(auto i = 0; i < S.size() ; i++){
    if(S.at(i) == '?') S.at(i) = 'D';
  }
  for(auto i = 0; i < S.size(); i++){
    cout << S.at(i);
  }
  cout << endl;
}

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


vector<int64_t> divisor ( int64_t X ){
    vector<int64_t> ans_list;
    for ( int64_t i = 1; i <= sqrt(X); ++i){
        // 割り切れる場合
        if ( X % i == 0 ){
            if ( i != X/i ){
                ans_list.push_back(i);
                ans_list.push_back(X/i);
            } else {
                ans_list.push_back(i);
            }
        }
    }
    sort(ans_list.begin(),ans_list.end());
    return ans_list;
}

// N が K の倍数のときに、問題文の条件を満たすか?
bool condition (int64_t N, int64_t K){
    int64_t syo = N;
    while ( syo % K == 0 ){
        syo = syo / K;
    }
    if ( (syo - 1 ) % K == 0 ){
        return true;
    } else {
        return false;
    }
}


int main(){
    int64_t N;
    cin >> N;
    vector<int64_t> dvs, dvsN;
    dvs = divisor(N-1);
    int64_t res = dvs.size() - 1;
    
    dvsN = divisor(N);
    for ( int64_t i = 1; i < dvsN.size(); ++i){
        int64_t div = dvsN.at(i);
        bool flg = condition(N,div);
        if ( flg ) {
            //cout << div << endl;
            ++res;
        }
    }
    
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> P, C;
  for (int i = 0; i < N; i++) {
  	int X;
    cin >> X;
    P.push_back(X - 1);
  }
  for (int i = 0; i < N; i++) {
  	int X;
    cin >> X;
    C.push_back(X);
  }
  long long score = LONG_MIN;
  for (int i = 0; i < N; i++) {
    int loop = 0;
    int pos  = i;
    long long sc  = 0;
    long long max = 0;
  	for (int j = 1; j <= K; j++) {
      pos = P[pos];
      sc += C[pos];
      if (sc > max || j == 1) max = sc;
      loop++;
      if (pos == i) {
      	int x = (K - j) / loop;
        if (x > 0) {
          j += (x - 1) * loop;
          sc += (x - 1) * sc;
        }
      }
    }
    if (max > score) score = max;
  }
  cout << score << endl;
}

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

using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  int range = 2 * d + 1;
  int result = 0;
  while (true) {
    ++result;
    n -= range;
    if (n <= 0) break;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
s=input()
k=int(input())
if s[0]!='1':
  print(s[0])
else:
  pos=0
  for i in range(len(s)):
    if i!=s[:i].count('1'):
      break
    pos=i
  if k<=pos:
    print('1')
  else:
    print(s[pos])

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <cstdlib>
typedef long long ll;
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
 
using namespace std;
 
int main(){
 
    ll n,k;
    cin >> n >> k;
   
    if(k==0){
        cout << n*n;
        return 0;
    }
    
    ll ans = (n-k)*(n-k+1)/2;
  	//cout << ans << endl;
 
    for(int i = k+1;i<=n;i++){
        ans += ((n-i+1)/i)*(i-k);
        ll x = (n-i+1)%i-k;
        if(x > 0)ans += x;
      	//cout << ans << endl;
    }
  	cout << ans;
}

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


def solve(A: int, P: int):
    print((A * 3 + P) // 2)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    solve(A, P)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, l, r) for(auto i=(l); i<(r); i++)
using namespace std;
using ll = long long;
struct S{
    ll value;
    ll size;
};
using F = ll;
const ll MOD = 998244353;
const ll ID = ll(-2e9);
S op(S a, S b){ return {(a.value+b.value)%MOD, (a.size+b.size)%MOD}; }
S e(){ return {0, 1}; }
S mapping(F f, S x){
    if(f != ID) x.value = x.size * f % MOD;
    return x;
}
F composition(F f, F g){ return (f == ID ? g : f); }
F id(){ return ID; }

int main(){
    ll N, Q;
    cin >> N >> Q;
    vector<S> v;
    rep(i, 0, N) {
        ll x = pow_mod(10, N-i-1, MOD);
        v.push_back({x, x});
    }
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);
    while(Q--){
            ll s, t, x;
            cin >> s >> t >> x;
            seg.apply(s-1, t, x);
            cout << seg.prod(0, N).value << endl;
    }
}

Measured memory_bytes: 16636
import bisect

N = int(input())
S = input()

r = []
g = []
b = []
for i, s in enumerate(S):
    if s == 'R':
        r.append(i)
    if s == 'G':
        g.append(i)
    if s == 'B':
        b.append(i)

count = len(r) * len(g) * len(b)

blen = len(b)
for rr in r:
    for gg in g:
        nb = (rr + gg) / 2
        i = bisect.bisect_left(b, nb)
        if int(nb) == nb and i < blen and b[i] == nb:
            count -= 1

        nb = 2 * rr - gg
        i = bisect.bisect_left(b, nb)
        if int(nb) == nb and i < blen and b[i] == nb:
            count -= 1

        nb = 2 * gg - rr
        i = bisect.bisect_left(b, nb)
        if int(nb) == nb and i < blen and b[i] == nb:
            count -= 1

print(count)


Measured memory_bytes: 81504
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int n;
double ans;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for(Int i=0; i<n; ++i){
		Int a; cin >> a;
		ans += 1. / a;
	}
	ans = 1. / ans;
	cout << fixed << setprecision(10) << ans << "\n";
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>

int main() {
  int n;
  while (std::cin >> n) {
    if (n == 0)
      break;
    std::vector<int> score(n, 0);
    double m = 0;
    for (int i = 0; i < n; i++) {
      std::cin >> score[i];
      m += score[i];
    }
    m /= n;
    double v=0;
    for (auto s : score) {
      v += pow(s - m, 2);
    }
    std::cout << sqrt(v / n) << std::endl;
  }
}



Measured memory_bytes: 3276
N = int(input())
A = list(map(int, input().split()))
count_list = []
for i in range(len(A)):
    count = 0
    while True:
        if A[i]%2 == 0:
            A[i] /= 2
            count += 1
        else:
            break
    count_list.append(count)

print(sum(count_list))

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

using Lint=long long;
Lint func(Lint N)
{
   if(N<=1) return 0;

   if(N%2==1) return 0;
   else{
      Lint cnt2=0,cnt5=0;
      Lint M=N;
      while(M/2>0) cnt2+=M/2,M/=2;
      M=N/2;
      while(M/5>0) cnt5+=M/5,M/=5;
      return min(cnt2,cnt5);
   }
}

int main()
{
   Lint N; cin>>N;
   cout<<func(N)<<endl;
   return 0;
}


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

int N;
const int MAX_N = 1.0e5 + 100;
ll T[MAX_N], A[MAX_N];
const int MOD = 1.0e9 + 7;

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> T[i];
    for (int i = 0; i < N; i++) cin >> A[i];

    ll m[N];
    memset(m, -1, sizeof(m));

    m[0] = T[0];
    for (int i = 1; i < N; i++) {
        if (T[i-1] < T[i]) {
            m[i] = T[i];
        }
    }

    bool possible = true;

    if (m[N-1] != -1 && m[N-1] != A[N-1]) {
        possible = false;
    }
    else {
        m[N-1] = A[N-1];
    }

    for (int i = N-2; i >= 0; i--) {
        if (m[i] != -1 && A[i] < m[i]) {
            possible = false;
        }
        if (A[i] > A[i+1]) {
            if (m[i] != -1 && m[i] != A[i]) {
                possible = false;
            }
            else {
                m[i] = A[i];
            }
        }
    }

    for (int i = 0; i < N; i++) {
        if (m[i] == T[i]) {
            if (m[i] > A[i]) {
                possible = false;
            } 
        }
        else if (m[i] == A[i]) {
            if (m[i] > T[i]) {
                possible = false;
            }
        }
    }

    if (possible) {
        ll ans = 1;
        for (int i = 0; i < N; i++) {
            if (m[i] == -1) {
                ans = (ans * min(T[i], A[i]) ) % MOD;
            }
        }
        cout << ans << endl;
    }
    else {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static final FS sc = new FS();  // 封装输入类
    static final PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        int x = sc.nextInt();
        if (x >= 400 && x < 600) {
            pw.println(8);
        } else if (x >= 600 && x < 800) {
            pw.println(7);
        } else if (x >= 800 && x < 1000) {
            pw.println(6);
        } else if (x >= 1000 && x < 1200) {
            pw.println(5);
        } else if (x >= 1200 && x < 1400) {
            pw.println(4);
        } else if (x >= 1400 && x < 1600) {
            pw.println(3);
        } else if (x >= 1600 && x < 1800) {
            pw.println(2);
        } else {
            pw.println(1);
        }
        pw.flush();
    }

    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        String next() {
            while(!st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch(Exception ignored) {}
            }
            return st.nextToken();
        }
        int[] nextArray(int n) {
            int[] a = new int[n];
            for(int i = 0;i < n;i++) {
                a[i] = nextInt();
            }
            return a;
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32760
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int B[101] = {0};

int main()
{
	int N = 0, i = 0, ans = 0;
	scanf("%d", &N);
	for (i = 0; i < N-1; i++) {
		scanf("%d", &B[i]);
	}

	for (i = N-2; i >= 0; i-- ) {
		if (i == N-2) {
			ans += B[i];
		} else {
			if (B[i] > B[i+1]) {
				ans += B[i+1];
			} else {
				ans += B[i];
			}
		}
		//printf("%d\n", B[i]);
	}
	ans += B[0];
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
def main():
    N = int(input())
    X = list(map(int,input().split()))
    MOD = 10 ** 9 + 7
    goal = X[-1]
    ans = goal - X[0]
    fact = [1]
    fact_inv = [1]
    for i in range(10**5+5):
        new_fact = fact[-1]*(i+1)%MOD
        fact.append(new_fact)
    count = 1
    for i in range(1,N-1):
        count += 1
        tmp = goal - X[i]
        ans = ((ans * count) + ((fact[i] * tmp))) % MOD  
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 63384
/*
 Shahadat Hossain
 I.C.T Department
 Comilla University
 Session: 2013-2014
 */

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define valid(x,y) x>=0 && y>=0 && x<n && y<n
#define all(x) x.begin(),x.end()
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define ms(a,b) memset(a, b, sizeof(a))
#define eps 1e-5
#define input freopen("/Users/shahadat/Desktop/input.txt", "r", stdin)
#define output freopen("/Users/shahadat/Desktop/output.txt", "w", stdout)
#define d(x) cout << #x << " = " << x << endl
#define dd(x,y) cout << #x << " = " << x << "   " << #y << " = " << y << endl
#define ddd(x,y,z) cout << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << endl
//fprintf(stdout,"\nTIME: %.3lf sec\n", (double)clock()/(CLOCKS_PER_SEC));
//int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
#define bit(n,k) (((n)>>(k))&1)
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define pr(x) {cout << (x) << '\n';  }
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define mask(i) ((1LL<<(i)))
#define endl '\n'
double const PI = acos(-1);
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

int const N = 1e5 + 5;
const int INF = -1e15;

int32_t main(){
    int n, W;
    cin >> n >> W;
    
    vector<int> dp(W + 1);
    for(int i = 0; i < n; i++){
        int w, v;
        cin >> w >> v;
        
        for(int j = W - w; j >= 0; j--){
            dp[j + w] = max(dp[j + w], dp[j] + v);
        }
    }
    
    int res = 0;
    for(int i = 1; i <= W; i++) res = max(res, dp[i]);
    cout << res << endl;
}




Measured memory_bytes: 1024
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        ll n,k,q; cin >> n >> k >>  q;
        vll a(n+1,k);
        for(int i = 1; i<=q; i++){
            int v; cin >> v;
            a[v]++;
        }
        for(int i = 1; i<=n; i++){
            if(a[i]>q)cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }



return 0;
}




Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int five = 0;
  int seven = 0;
  int x;
  for(int i = 0; i < 3; i++){
    scanf("%d",&x);
    if(x == 5) five++;
    else if(x == 7) seven++;
  }
  if(five == 2 && seven == 1) printf("YES\n");
  else printf("NO\n");
  return 0;
 
}  

Measured memory_bytes: 3164
<?php
fscanf(STDIN, "%d%d", $N, $x);
$aArray = explode(" ", trim(fgets(STDIN)));
for($i = 0; $i < $N; $i++){
  $b[$i] = $aArray[$i] + @$aArray[$i+1];
}

$sum = 0;
for($i = 0; $i < $N; $i++){
  if($b[$i] > $x){
    $over = $b[$i] - $x;
    $sum+=$over;
    $b[$i] -= $over;
    if(isset($b[$i+1]))$b[$i+1] -= $over;
  }
}
echo $sum;

Measured memory_bytes: 18932
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

def FordFulkerson(S,T): #sからFord-Fulkerson
    global lines
    global cost
    global ans

    queue = deque()     #BFS用のdeque
    queue.append([S,INF])
    ed = [True]*N    #到達済み
    ed[S] = False
    route = [0 for i in range(N)]   #ルート
    route[S] = -1

    #BFS
    while queue:
        s,flow = queue.pop()
        for t in lines[s]:  #s->t
            if ed[t]:
                flow = min(cost[s][t],flow)  #flow = min(直前のflow,line容量)
                route[t] = s
                queue.append([t,flow])
                ed[t] = False
                if t == T: #ゴール到達
                    ans += flow
                    break
        else:
            continue
        break
    else:
        return False

    #ラインの更新
    t = T
    s = route[t]
    while s != -1:
        #s->tのコスト減少，ゼロになるなら辺を削除
        cost[s][t] -= flow
        if cost[s][t] == 0:
            lines[s].remove(t)

        #t->s(逆順)のコスト増加，元がゼロなら辺を作成
        if cost[t][s] == 0:
            lines[t].add(s)
        cost[t][s] += flow

        t = s
        s = route[t]
    return True

def PrimeFactoring(x):
    p = 2
    primes = []
    while x >= 2:
        if x%p == 0:
            primes.append(p)
            x //= p
            p = 2
        else:
            p += 1
    return primes

while True:
    X,Y,M = inpl()
    lines = defaultdict(set)
    N = X+Y+2
    S = X+Y
    T = X+Y+1
    cost = [[0]*N for _ in range(N)]

    for i in range(M):
        x,y = inpl()
        lines[x].add(y+X)
        cost[x][y+X] = 1
        
    for i in range(X):
        lines[S].add(i)
        cost[S][i] = 1
    for i in range(Y):
        lines[i+X].add(T)
        cost[i+X][T] = 1

    ans = 0

    while FordFulkerson(S,T):
        pass

    print(ans)

    break



Measured memory_bytes: 8368
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////


int main() {
	ll N, M;
	cin >> N >> M;
	vector<ll> s(N + 1);
	repn(i, N) {
		char c;
		cin >> c;
		s[i] = c - '0';
	}

	vector<ll> l(M + 1, 0), r(M + 1, 0);
	repn(i, M) cin >> l[i] >> r[i];

	vector<ll> rx(M + 1, 0);
	repn(i, M) rx[i] = max(rx[i - 1], r[i]);

	vector<vector<ll>> c(2, vector<ll>(N + 1, 0));
	repn(i, N) {
		rep(j, 2) {
			if (s[i] == j) { c[j][i] = c[j][i - 1] + 1; }
			else { c[j][i] = c[j][i - 1]; }
		}
	}

	vector<vector<mint>> dp(N + 1, vector<mint>(N + 1, 0));
	dp[0][0] = 1;

	rep(i, N+1)rep(j, N+1) {
		ll k = i + j;
		if (k > N) { continue; }
		if (i == 0 && j == 0) { continue; }

		auto itr = upper_bound(l.begin(), l.end(), k);
		ll t = distance(l.begin(), itr) - 1;

		ll x = max(k, rx[t]);
	
		if (c[0][x] >= i && c[1][x] >= j) {
			if (i == 0) { dp[i][j] = dp[i][j - 1]; }
			else if (j == 0) { dp[i][j] = dp[i - 1][j]; }
			else { dp[i][j] = dp[i - 1][j] + dp[i][j - 1]; }
		}
		else { dp[i][j] = 0; }

		//cout << i << j << " "<<t<<" "<<  dp[i][j] << endl;
	}

	mint ans = 0;
	
	rep(i, N + 1) {
		ans += dp[i][N - i];
	}
	cout << ans << endl;

	system("PAUSE");
}


Measured memory_bytes: 71040
#include <stdio.h>
int main() {
  int a, b, c, count = 0;
  scanf("%d %d %d", &a, &b, &c);
  for (int i = a; i <= b; i++) {
    if (c % i == 0) {
      count++;
    }
  }
  printf("%d\n", count);
  return 0;
}

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

const int INF = 1001001001;

int main() {
  string S,ad="",bc="";
  char c;
  int Q, t, f, h=1;
  cin>>S>>Q;
  for(int i=0;i<Q;i++){
    cin>>t;
    if(t==1) h*=-1;
    
    else{
      cin>>f>>c;
      if(f==1){
        if(h==1){
          ad=c+ad;
        }
        else{
          bc=bc+c;
        }
      }
      else{
        if(h==1){
          bc=bc+c;
        }
        else{
          ad=c+ad;
        }
      }
    }
  }
  S=ad+S+bc;
  if(h==1){
    for(int i=0; i<S.size(); i++){
      cout<<S.at(i);
    }
  }
  else{
    for(int i=S.size()-1; i>=0; i--){
      cout<<S.at(i);
    }
  }
}

Measured memory_bytes: 1512
#include<bits/stdc++.h>
 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1e9+7
#define hell2 1e9+9
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cout << (#x) << " is " << (x) << endl
#define INF 1e9
#define LL_MAX 1e18
// memset(array, -1, sizeof(array[0][0]) * row * count)
using namespace std;
 
ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;
}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 
bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }
 
// max({a, b, c, d})

int main()
{
	string s;
	cin >> s;
	int ok = 1;
	for(int i=0;i<s.size();i++)
	{
		if(i%2 == 0)
		{
			if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D')
			{
				ok = 0;
				break;
			}
		}
		else if(i%2)
		{
			if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D')
			{
				ok = 0;
				break;
			}
		}
	}

	if(ok) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll n,m;
vector<int> v[100000];
int c[100000];
void f(int x, int y){
    if(c[x]==0){
        c[x]=y;
        for(int i=0;i<v[x].size();i++){
            f(v[x][i], 3-y);
        }
    }else if(c[x]!=y){
        c[x]=-1;
    }
}
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    fill(c, c+n, 0);
    f(0, 1);
    ll d=0;
    for(int i=0;i<n;i++){
        if(c[i]==-1){
            d=-1;
            break;
        }else if(c[i]==1){
            d++;
        }
    }
    ll ans=-m;
    if(d==-1){
        ans+=n*(n-1)/2;
    }else{
        ans+=d*(n-d);
    }
    cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  long long ans=0;
  vector<long long>A(N+1);
  for(int i=0;i<N+1;i++){
    cin >> A[i];
  }
  for(int i=0;i<N;i++){
    long long y;
    cin >> y;
    long long x=min(y,A[i]);
    ans += x;
    y -= x;
    x=min(y,A[i+1]);
    A[i+1]-=x;
    ans += x;
  }
  cout << ans << endl;
}
    
      


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
const int mod=1e9+7;
int a[110];
long long dp[110][N];
int main(){
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
        for(int j=0;j<=k;j++){
            dp[i][j] = dp[i - 1][j];
            if(j && j<=a[i])
                dp[i][j] += dp[i][j - 1];
            else if (j)
                dp[i][j] += mod+dp[i][j-1] - dp[i-1][j-a[i]-1];
            dp[i][j]%=mod;
        }

    cout<<dp[n][k];

    return 0;
}

Measured memory_bytes: 79360
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
using namespace std;
int mod = 1e9 + 7;

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	int d, t, s;
	cin >> d >> t >> s;
	if (d > s * t)
		cout << "No";
	else
		cout << "Yes";
	cout << endl;
	return 0;
}

Measured memory_bytes: 3612
using System;

namespace abc115_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Console.Write("Christmas");
            for (int i = 0; i < 25 - n; i++) Console.Write(" Eve");
            Console.WriteLine();
        }
    }
}

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

typedef pair<int, int> Ginkgo;

int main(){
    int N; cin >> N;
    while(N--){
        set<Ginkgo> divs;
        int p, q; cin >> p >> q;
        
        int cnt = 0;
        int l = p*p + q*q;
        for(int m=-200; m<200; m++){
            if(l < m*m) continue;
            for(int n=-200; n<200; n++){
                if(l < m*m + n*n || (n == 0 && m == 0)) continue;
                
                if((m*p+n*q)%(m*m+n*n) == 0 && (m*q-n*p)%(m*m+n*n) == 0)
                    cnt++;
            }
        }
        cout << (cnt == 8? "P": "C") << endl;
    }
}

Measured memory_bytes: 3084
#include <iostream>

int main()
{
    int A, B, C, D;
    std::cin >> A >> B >> C >> D;

    const int area1 = A * B;
    const int area2 = C * D;
    const int ret = std::max(area1, area2);

    std::cout << ret << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n;
	int y,m,d;
	int i,j,k,l;
	int day;
	
	scanf("%d",&n);
	for(l=0;l<n;l++)
	{
		scanf("%d %d %d",&y,&m,&d);
		day = 0;
		j = m;
		k = d;
		for(i=y;i<1000;i++)
		{
			for(;j<=10;j++)
			{
				if(i%3==0)
				{
					for(;k<=20;k++)
					{
						day++;
					}
				}
				else
				{
					if(j%2==0)
					{
						for(;k<=19;k++)
						{
							day++;
						}
					}
					else
					{
						for(;k<=20;k++)
						{
							day++;
						}
					}
				}
				k = 1;
			}
			j = 1;
		}
	printf("%d\n",day);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main (){
    int a, b, C;
    double S, L, h, c, theta;
    cin >> a >> b >> C;
    theta = C * M_PI / 180;
    c = sqrt(a * a + b * b - 2 * b * a * cos(theta));
    L = a + b + c;
    S = a * b * sin(theta) / 2;
    h = 2 * S / a;
    cout << setprecision(8) << S << endl;
    cout <<  setprecision(8) << L << endl;
    cout <<  setprecision(8) << h << endl;

}


Measured memory_bytes: 3512
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

int h,w;
vector<string>field(h);
bool seen[100][100];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int cnt = 0;

int dfs(int y,int x,int &cnt){
    cnt++;
    seen[y][x] = true;
    rep(i,4){
        int ny = y+dy[i],nx = x+dx[i];
        if(ny<0 || ny>=h || nx<0 || nx>=w)continue;
        if(field[ny][nx] != '#')continue;
        if(seen[ny][nx])continue;
        cnt++;
        dfs(ny,nx,cnt);
    }
    return cnt;
}

int main(){
    int n,k;cin>>n>>k;
    VEC(ll,h,n);
    sort(ALL(h));
    ll res = INF+7;
    rep(i,n-k+1){
        res = min(res,h[k+i-1]-h[i]);
    }
    cout<<res;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

static const int trans[][6] = 	{
									{ 0, 1, 2, 3, 4, 5 },	// no rotation 
									{ 2, 1, 5, 0, 4, 3 },	// left rotation
									{ 3, 1, 0, 5, 4, 2 }, 	// right rotation
									{ 1, 5, 2, 3, 0, 4 },	// top rotation
									{ 4, 0, 2, 3, 5, 1 },	// bottom rotation
									{ 0, 2, 4, 1, 3, 5 }	// front and buttom fixed right 90 ratate 
								};
set <vector <char> > comb;

bool is_same (vector <char> s, int i, vector <char> & t )
{
	bool found = false;
	rep (j, 6 ){
		t[j] = s[trans[i][j]];
	} // end rep
	if (comb.count (t ) ){
		found = true;
	} // end if

	return found;
}

int main()
{
	const string color[6] = { "Red", "Cyan", "Yellow", "Blue", "Magenta", "Green" };
	map<string, char> C;
	rep (i, 6 )
		C[color[i]] = color[i][0];


	int n;
	while (cin >> n && n ){
		comb.clear();
		vector <vector <char> > c(n, vector <char> (6 ) );
		rep (i, n ){
			rep (j, 6 ){
				string in;
				cin >> in;
				c[i][j] = C[in];
			} // end rep
		} // end rep
		for (int i = 0; i < n; i++ ){
			bool found = false;
			vector <char> t(6, 0 );
			rep (j, 5 ){
				if (is_same (c[i], j, t ) ){
					found = true;  
					break;
				} // end if
				vector <char> s = t;
				vector <char> r(6, 0 );
				rep (k, 3 )
				if (is_same (s, 5, r ) ){
					found = true;
					break;
				}else{
					s = r;
				} // end if
				vector <char> tt = t;			
				if (is_same (t, j, tt ) ){
					found = true; 
					break;
				} // end if
				s = tt;
				rep (k, 3 )
				if (is_same (s, 5, r ) ){
					found = true;
					break;
				}else{
					s = r;
				} // end if
			} // end rep
			if (!found ){
				comb.insert (c[i] );
			} // end if			
		} // end for
		int res = comb.size();
		cout << n - res << endl;
	} // end loop

		
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a;
    map<int, int> mp;
    bool flg = true;
    for (int i = 0; i < n; ++i) {
      cin >> a;
      mp[a]++;
      if (mp[a] == 2) flg = false;
    }
    if (flg) cout << "YES" << endl;
    else cout << "NO" << endl; 
    return 0;
}

Measured memory_bytes: 9600
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,ans=0,a_idx=-1;
  string s="",t;
  cin >> t;
  n = t.size();
  for(int i=0;i<n;i++){
    if(t[i]=='A') s+='A';
    else if(i!=n-1&&t[i]=='B'&&t[i+1]=='C') s+='D',i++;
    else s+=t[i];
  }
  n = s.size();
  for(int i=0;i<n-1;i++){
    if(s[i]=='A'){
      if(a_idx == -1){
        a_idx = i;
      }
      if(s[i+1]=='D'){
        ans += i-a_idx+1;
        s[a_idx]='D';
        s[i+1]='A';
        a_idx++;
      }
    }else{
      a_idx = -1;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int dizi[100005];


int main(){
	int x;
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=0;i<c;i++){
		cin>>x;
		dizi[x]++;
	}
	for(int i=1;i<=a;i++){
		if(b-(c-dizi[i])<=0){
			cout<<"No"<<endl;
		}
		else{
			cout<<"Yes"<<endl;
		}
	}
	
}

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

using namespace std;


const int N = (1 << 18);

int S[N];
bool made[N];

int main(){

    vector<int> v;
    int N;

    cin >> N;

    int m = (1 << N);

    for(int i = 0; i < m; i++)
        cin >> S[i];

    sort(S, S + m);
    v.push_back(S[m - 1]);
    made[m - 1] = true;
    for(int i = 0; i < N; i++){
        int cur = 0;
        int s = v.size();

        for(int j = m - 1; j >= 0; j--){
            if(!made[j]){
                if(v[cur] > S[j]){
                    v.push_back(S[j]);
                    made[j] = 1;
                    cur++;
                }
                if(cur == s) break;
            }
            if(j == 0){
                cout << "No\n";
                return 0;
            }
        }
        sort(v.begin(), v.end(), greater<int>());
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 2676
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t H;
  cin >> H;
  int64_t ans = 0;
  int64_t cnt = 0;
  while(H > 0){
    H /= 2;
    ans += pow(2,cnt);
    cnt++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
n,k,*a=map(int,open(0).read().split())
multiple=1
#for i in range(k):
#    multiple*=a[i]
for j in range(n-k):
    if a[j+k]>a[j]:
        print('Yes')
    else:
        print('No')
#    multiple=multiple*a[j+k]/a[j]

Measured memory_bytes: 31676
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (long long i = 0; i < N; i++)
using ll = long long;
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;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> h(N);
    rep(i, N) { cin >> h[i]; }
    vector<ll> dp(N, INF);
    dp[0] = 0;
    rep(i, N) {
        for (ll j = 1; j < K + 1; j++) {
            if (i + j < N) {
                chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
            }
        }
    }
    cout << dp[N - 1] << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define long long long
signed main()
{
    long t;
    t=1;
    // cin>>t;
    while(t--)
    {
        long n,m,x,y,i,j,flag=1;
        
        cin>>n>>m;
        cout<<n*m;
        
    }
    return 0;
}

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

using namespace std;

int main(){
    string s;
    cin>>s;
    int cur=0,ans=0;
    for(int i=0;i<3;i++){
        if(s[i]=='S'){
            cur=0;
        }
        else{
            cur++;
        }
        ans=max(ans,cur);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3624
# include<bits/stdc++.h>
using namespace std;
int main(){
  long int n, k, q;
  cin >> n >> k >> q;
  long int scores[n];
  	for(long int i = 0; i < n; i++){
      scores[i] = k-q;
    }
	for(long int i = 0; i < q; i++){
    	long int temp;
      cin >> temp;
      scores[temp-1] += 1;
    }
  for(long int i = 0; i < n; i++){
  if(scores[i] < 1)
    cout << "No"<<'\n';
  else
    cout <<"Yes"<<'\n';
  }

	return 0;
}

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

using namespace std;

using ll = long long;

bool g[4][4];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m = 3;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a][b] = g[b][a] = true;
    }

    vector<int> v = {0, 1, 2, 3};
    bool ans = false;
    do {
        bool f = true;
        for (int i = 0; i <=2; i++) {
            if (!g[v[i]][v[i+1]]) {
                f = false;
                break;
            }
        }
        if (f) {
            ans = true;
            break;
        }
    } while (next_permutation(v.begin(), v.end()));
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//実行部
void Main()
{
  ll n, k; cin >> n >> k;
  fin((n % k == 0?0:1))
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


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

int main() {
    //
    int num;
    int cnt = 0;

    cin >> num;

    for (int i = 1; i <= num; i++) {
        string str = to_string(i);
        if (str.size() % 2 == 1) cnt++;
    }

    cout << cnt;
    //
}


Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
int main(){
    string n;
    cin >> n;
    int i,a,m;
  int a1,a2,a3;
    a=n.size();
    m=100000;
    for(i=0;i<=a-3;i++){
        a1=int(n[i]-'0');
      a2=int(n[i+1]-'0');
      a3=int(n[i+2]-'0');
        if(abs(100*a1+10*a2+a3-753)<m){
            m=abs(100*a1+10*a2+a3-753);
            
        }
    }
    cout <<m<<endl;
    
}

Measured memory_bytes: 764
import java.util.*;

public class Main {
	int w, h;
	int[][] map;
	int[][] cost;
	
	public void loop(int y, int x){
		cost[y][x]++;
		if(x!=0 && map[y][x-1]==0 && cost[y][x-1]==0){
			loop(y,x-1);
		}
		if(x!=w-1 && map[y][x+1]==0 && cost[y][x+1]==0){
			loop(y,x+1);
		}
		if(y!=0 && map[y-1][x]==0 && cost[y-1][x]==0){
			loop(y-1,x);
		}
		if(y!=h-1 && map[y+1][x]==0 && cost[y+1][x]==0){
			loop(y+1,x);
		}	
	}
	
	public void check(){
		int count=0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(cost[i][j]>0)count++;
			}
		}
		System.out.println(count);
	}
	

	public static void main(String[] args) {
		Main A = new Main();
		Scanner sc = new Scanner(System.in);
		
		while(true){
			A.w = sc.nextInt();
			A.h = sc.nextInt();
			if((A.w|A.h)==0)break;
			
			A.map = new int[A.h][A.w];
			A.cost = new int[A.h][A.w];
			
			String t = "";
			int x = 0;
			int y = 0;
			for(int i=0;i<A.h;i++){
				t = sc.next();
				for(int j=0;j<A.w;j++){
					if(t.codePointAt(j)==35){
						A.map[i][j] = 1;
					}else if(t.codePointAt(j)==64){
						A.map[i][j] = 2;
						x = j;
						y = i;
					}
				}
			}
			A.loop(y, x);
			A.check();
		}
	}
}

Measured memory_bytes: 32148
import java.util.*;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long costs[][] = new long[N][3];
        for(int i = 0;i < N;i++){
            for(int h = 0;h < 3;h++)
                costs[i][h] = sc.nextLong();
        }

        long dp[][] = new long[N][3];

        dp[0][0] = costs[0][0];
        dp[0][1] = costs[0][1];
        dp[0][2] = costs[0][2];
        for(int i = 1;i < N;i++){
            for(int h = 0;h < 3;h++){
               for(int j = 0;j < 3;j++)
                   if(h != j)
                       dp[i][h] = Math.max(dp[i][h],dp[i - 1][j] + costs[i][h]);
            }
        }

        System.out.println(Math.max(Math.max(dp[N - 1][0],dp[N - 1][1]),dp[N - 1][2]));
    }










    public static Integer min(List<Integer> ar){
        int min = 10000;
        int index = 0;
        for(int i = 0; i< ar.size();i++){
            if(min > ar.get(i)){
                min = ar.get(i);
                index = i;
            }
        }
        return min;
    }
}


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

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    int K;
    cin >> K;
    for(int i=min(A, B); i>=0; i--) {
        if(A%i==0 && B%i==0) {
            K--;
        }
        if(K==0) {
            cout << i << endl;
            break;
        }
    }


    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 	int N;
  	int x;
  x=3;
  string c;
  cin >> N;
  for (int i = 0; i < N; i++) {
 	cin >> c;
    if (c == "Y") {
      x=4;
      break;
    }
  }
 if(x ==3){ 
  cout << "Three" << endl;
 }
 if(x ==4){ 
  cout << "Four" << endl;
 }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>


long tmp[10];

int main(){
	long T,N,A,B,C,D;
	int x[10];
		scanf("%d%d%d%d%d",&x[0],&x[1],&x[2],&x[3],&x[4]);
	
	int i;
	for(i=0;i<5;i++){
		if(x[i]==0){
			printf("%d\n",i+1);
			return 0;
		}
		
	}



	return 0;
}


Measured memory_bytes: 1720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void io(){ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
int main()
{
    io();
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll tr=1;
    while(1)
    {
        if(tr){
            c-=b;
        }
        else{
            a-=d;
        }
        if(a<=0 || c<=0)
            break;
        tr^=1;
    }
    if(!tr)
        cout<<"No";
    else
        cout<<"Yes";
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

#ifdef WIN32
	#define LL "%I64d"
#else
	#define LL "%lld"
#endif

#ifdef CT
	#define debug(...) printf(__VA_ARGS__)
	#define setfile() 
#else
	#define debug(...)
	#define filename ""
	#define setfile() freopen(filename".in", "r", stdin); freopen(filename".out", "w", stdout)
#endif

#define R register
#define getc() (_S == _T && (_T = (_S = _B) + fread(_B, 1, 1 << 15, stdin), _S == _T) ? EOF : *_S++)
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#define cmax(_a, _b) (_a < (_b) ? _a = (_b) : 0)
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
#define cabs(_x) ((_x) < 0 ? (- (_x)) : (_x))
char _B[1 << 15], *_S = _B, *_T = _B;
inline int F()
{
	R char ch; R int cnt = 0; R bool minus = 0;
	while (ch = getc(), (ch < '0' || ch > '9') && ch != '-') ;
	ch == '-' ? minus = 1 : cnt = ch - '0';
	while (ch = getc(), ch >= '0' && ch <= '9') cnt = cnt * 10 + ch - '0';
	return minus ? -cnt : cnt;
}
#define maxn 310
char str[maxn][maxn];
int d[maxn][maxn], f[maxn][maxn], n, m, ans;
int main()
{
//	setfile();
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) scanf("%s", str[i] + 1);
	for (int i = 2; i <= m; ++i)
	{
		for (int j = 1; j <= n; ++j)
		{
			d[j][0] = 0;
			for (int k = 1; k <= n; ++k)
				d[j][k] = d[j - 1][k - 1] + (str[k][i] == str[j][i - 1]);
		}
		memset(f, 63, sizeof (f));
		f[n][n] = 0;
		for (int j = n; j >= 0; --j)
			for (int k = n; k >= 0; --k)
				(j ? cmin(f[j - 1][k], f[j][k] + d[j][k]) : 0),
				(k ? cmin(f[j][k - 1], f[j][k] + d[j][k]) : 0);
		ans += f[0][0];
	}
	printf("%d\n", ans );
	return 0;
}


Measured memory_bytes: 1024
using System;

namespace A_____x
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var a = int.Parse (input[0]);
            var b = int.Parse (input[1]);
            var max = Math.Max (a + b, a - b);
            max = Math.Max (max, a * b);
            Console.WriteLine (max);
        }
    }
}

Measured memory_bytes: 13140
#import numpy as np
import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N,D = map(int, input().split())
    count = 0
    D2 = D*D
    for _ in range(N):
        X,Y = map(int, input().split())
        if X*X+Y*Y <= D2:
            count += 1
    print(count)
main()


Measured memory_bytes: 9160
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int N, M; cin >> N >> M;
    
    unsigned int total = -1;
    for (int i = 0; i < N; i++) {
        int K; cin >> K;
        unsigned int fav = 0;
        for (int j = 0; j < K; j++) {
            int A; cin >> A; A--;
            fav |= (1 << A);
        }
        total &= fav;
    }

    int cnt = 0;
    while (total > 0) {
        total &= total-1;
        cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256