akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define rep(i, x, n) for(long long i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
const int ININF = 1000000;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    long long N, K;
    cin >> N >> K;
    long long res = 0;
    if(K==0){
        cout<<N*N<<endl;
        return 0;
    }
    rep(i, K + 1, N + 1) {
        long long c = i - K;
        long long m = N % i;
        res += (N / i) * c;
        if(m >= K) {
            // cout<<"a:"<<c + ((N - K) / i - 1) * c+ (m - K + 1)<<endl;
            res += m - K + 1;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;

typedef long long ll;


int main(){
    string str;
    cin>>str;
    int count=0;

    for(int i=1;i!=str.size();++i){
        if(str[i]!=str[i-1]){
            ++count;
        }
    }
    cout<<count<<endl;
    
}

Measured memory_bytes: 3760
S=input()
if len(S)&1:
  print("No")
  exit(0)
revS=S[::-1]
pairs={"p":"q","b":"d"}
for i in range(len(S)//2):
  if S[i] in pairs and pairs[S[i]]==revS[i]:
    continue
  elif revS[i] in pairs and pairs[revS[i]]==S[i]:
    continue
  else:
    print("No")
    break
else:
  print("Yes")


Measured memory_bytes: 3188
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int odd[100010],even[100010],A[100010],n,oddmax,evenmax,oddsecond,evensecond,oddpos,evenpos;

int main(){
    cin>>n;
    rep(i,n){
        cin>>A[i];
        if(i%2==0){
            odd[A[i]]++;
        }
        else{
            even[A[i]]++;
        }
    }
    rep(i,100010){
        if(odd[i]>oddmax){
            oddsecond=oddmax;
            oddmax=odd[i];
            oddpos=i;
        }
        else if(odd[i]>oddsecond){
            oddsecond=odd[i];
        }
        if(even[i]>evenmax){
            evensecond=evenmax;
            evenmax=even[i];
            evenpos=i;
        }
        else if(even[i]>evensecond){
            evensecond=even[i];
        }
    }
    // out(oddmax);
    // out(evenmax);
    if(evenpos==oddpos){
        out(min((n+1)/2-oddsecond+n/2-evenmax,(n+1)/2-oddmax+n/2-evensecond));
    }
    else{
        out((n+1)/2-oddmax+n/2-evenmax);
    }
}



Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<malloc.h>

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}


int main(void){
    int A,B;

    scanf("%d %d%*c",&A,&B);
    A = (A+11)%13;
    B = (B+11)%13;
    if(A>B)
        puts("Alice");
    else if(A<B)
        puts("Bob");
    else
    {
        puts("Draw");
    }
    

    return 0;
}

Measured memory_bytes: 128
S = input().strip()
N = len(S)
A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
B[0] = 1
for i in range(1,N):
    B[i] = (B[i-1]*10)%2019
a = 0
for i in range(N-1,-1,-1):
    a = (int(S[i])*B[N-1-i]+a)%2019
    A[i] = a
C = {i:0 for i in range(2019)}
for i in range(N):
    C[A[i]] += 1
cnt = C[0]
for i in range(2019):
    cnt += (C[i]*(C[i]-1))//2
print(cnt)

Measured memory_bytes: 100824
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;

int N;
vector<P> a;

bool compare_y(P a, P b) {
  return a.second < b.second;
}

// [l, r)
double closest_pair(int l, int r) {
  int n = r - l;
  if(r - l <= 1) return 2e9; // 1点しかない
  int m = (l + r) / 2;
  int x = a[m].first;
  int d = min(closest_pair(l, m), closest_pair(m, r));
  inplace_merge(a.begin(), a.begin() + m, a.begin() + n, compare_y); // 二つのソート済み配列をマージする 範囲指定->(先頭,中間,最後)

  vector<P> b;
  FOR(i,l,r){
    if(abs(a[i].first - x) >= d) continue;
    FOR(j,0,b.size()){
      // 近いものから見て行く
      int dx = a[i].first - b[b.size() - j - 1].first;
      int dy = a[i].second - b[b.size() - j - 1].second;
      if(dy >= d) break; // 枝狩り?
      d = min(d, dx * dx + dy * dy);
    }
    b.push_back(a[i]);
  }
  return d;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>N;
  a.resize(N);
  FOR(i,0,N)cin>>a[i].first>>a[i].second;
  sort(a.begin(), a.end());
  cout<<closest_pair(0, N)<<endl;

}


Measured memory_bytes: 12432
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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 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;
  }
};

// mint N;

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

// combination c(N);
// mint ans = c(N,n);
// cout << ans.x << endl;
// Nとnはll型(mintではない)
// -------------------------------------------------------------
// beetさんの素因数分解
template<typename T>
map<T, ll> factorize(T x){
  map<T, ll> res;
  for(int i=2;i*i<=x;i++){
    while(x%i==0){
      x/=i;
      res[i]++;
    }
  }
  if(x!=1) res[x]++;
  return res;
}
// 使用例
// vector<int> cnt(111,0);
// for(int i=1; i<=N; i++){
//   for(auto p: factorize(i)){
//     cnt[p.first] += p.second;
//   }
// }


int main(){
  ll N,M;
  cin >> N >> M;
  mint ans=1;
  for(auto p: factorize(M)){
    combination c(N-1+p.second);
    mint res;
    res = c(N-1+p.second,p.second);
    ans *= res;
  }
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 1860
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  string w;
  cin >> w;
  map<char, int> mp;
  rep(i, w.size())
  {
    mp[w.at(i)]++;
  }
  for (auto m : mp)
  {
   // cout << m.first << " " << m.second << endl;
    if (m.second % 2 != 0)
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char a[505][505],b[505][505],c[505][505];int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%s",a[i]+1);
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(a[i][j]=='#') b[i][j]=c[i][j]='#';
	for(int i=1;i<=m;i++) b[1][i]='#',c[n][i]='#';
	for(int i=2;i<n;i++) for(int j=1;j<=m;j++) if(j&1) b[i][j]='#';else c[i][j]='#';
	for(int i=1;i<=n;i++,putchar('\n')) for(int j=1;j<=m;j++) putchar(b[i][j]=='#'?'#':'.');
	putchar('\n');
	for(int i=1;i<=n;i++,putchar('\n')) for(int j=1;j<=m;j++) putchar(c[i][j]=='#'?'#':'.');
}

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

    while(N != 0){
        if(N%10 == 7){
            cout << "Yes" << endl;
            return 0;
        }
        N /= 10;
    }
    cout << "No" << endl;
}

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


def solve(T: str):
    T = [t if t!='?' else 'D' for t in T]
    print(''.join(T))
    return

    cnt = 0
    max_pd = 0
    prev_c = ''
    
    for idx, c in enumerate(T):

        if c == 'd':
            cnt += 1
        
        elif idx==len(T)-1:
            max_pd = max(max_pd, cnt)
            cnt = 0
            break
        elif T[idx+1]=='d':
            cnt += 1
        else:
            max_pd = max(max_pd, cnt)
            cnt = 0

    print(max_pd)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    T = next(tokens)  # type: str
    solve(T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 11380
#include <bits/stdc++.h>
#include <set>
using namespace std;
int main() {
  set<int> s;
  int n;
  cin >> n;
  for(int i=0;i<n;i++) {
    int d;
    cin >> d;
    s.insert(d);
    }
  cout << s.size() << endl;
  return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    ll x,k,d;
    ll ans;
    cin >> x >> k >> d;
    x = abs(x);
    ll n = x/d;
    if(k<=n){
        ans = x - k*d;
    }
    else{
        if(n%2 == k%2){
            ans = x%d;
        }
        else{
            ll kore=x%d;
            ll sa = k-n;
            if(sa % 2 == 0) ans = kore;
            else{
                ans = min(kore+d,abs(kore-d));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define pb              push_back
#define ll              long long
#define scd(a)          scanf("%d",&a)
#define mp(a,b)         make_pair(a,b)
#define scl(w)          scanf("%lld",&w)
#define scdd(a,b)       scanf("%d %d",&a,&b)
#define srt(a)          sort(a.begin(),a.end())
#define rsrt(a)         sort(a.rbegin(),a.rend())
#define scll(a,b)       scanf("%lld %lld",&a,&b)
///4direction ->        int del_x[]={-1,0,1,0},del_y[]={0,1,0,-1};
#define input(v,n)      for (int i=0;i<n;i++){int a;cin >> a;v.push_back(a);}
#define inputll(v,n)    for (ll i=0;i<n;i++){ll a;cin >> a;v.push_back(a);}
#define vii             vector < int >
#define vll             vector < ll >
#define pii             pair < int , int >
#define pll             pair < ll , ll >
#define mk              make_pair
#define inf8            100000008

using namespace std;

ll A[100005] , sum=0;
vll v;

int main()
{
    inputll(v,3);
    srt(v);
    cout << v[0]+v[1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
long long least_common_multiple(long long a, long long b) { return a / __gcd(a, b) * b; }

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  long long ans = 1;
  REP(i, n) {
    long long t; cin >> t;
    ans = least_common_multiple(ans, t);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct job{
    long long t;
    long long dL;
};
bool sortByDeadLine(job j1, job j2){
    return j1.dL<=j2.dL;
}
job jobs[200001];
job tArr[200001];
void mergeArr(job arr[200001], int left, int right, int mid){
    for(int i=left; i<=right; i++){
        tArr[i]=arr[i];
    }
    int i=left, j=mid+1;
    int k=left;
    while(i<=mid && j<=right){
        if(tArr[i].dL<tArr[j].dL){
            arr[k++]=tArr[i++];
        }
        else{
            arr[k++]=tArr[j++];
        }
    }
    while(i<=mid){
        arr[k++]=tArr[i++];
    }
    while(j<=right){
        arr[k++]=tArr[j++];
    }
}

void mergeSort(job arr[200001], int left, int right){
    if(left<right){
        int mid=(left+right)/2;
        mergeSort(arr, left, mid);
        mergeSort(arr, mid+1, right);
        mergeArr(arr, left, right, mid);
    }
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    long long t, dL;
    for(int i=0; i<n; i++){
        cin>>jobs[i].t>>jobs[i].dL;
    }
    mergeSort(jobs, 0, n-1);
    long long sum=0;
    bool canFinish=true;
    for(int i=0; i<n; i++){
        //printf("%d\n", i);
        sum+=jobs[i].t;
        if(sum>jobs[i].dL){
            canFinish=false;
        }
    }
    cout<<(canFinish ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 6528
/***********************************************
 *                                             *
 *   author: raghav_0901 (Raghav Dalmia)       *
 *   updated on: 21-06-2020, 12:25:15 am IST   *
 *                                             *
\***********************************************/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

signed main( )
{
    int n,k;cin>>n>>k;
    vector<int> v(n);
    for(int &i:v) cin>>i;
    sort(v.begin(), v.end());
    int ans=0;
    for(int i=0;i<k;i++)
        ans+=v[i];
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3628
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

s = rr()
ans = ''
for i in s:
    if i == '0':
        ans += '0'
    elif i == '1':
        ans += '1'
    elif ans:
        ans = ans[:-1]
print(ans)














Measured memory_bytes: 27000
import java.util.*;
import java.util.Scanner;
import java.io.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer;

import javax.lang.model.util.ElementScanner6; 

public class Main
{
    static class FastReader
    { 
        BufferedReader br; 
        StringTokenizer st; 

        public FastReader() 
        { 
            br = new BufferedReader(new
                    InputStreamReader(System.in)); 
        } 

        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 

        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 

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

        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 

        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    

    
    public static void main(String args[])
    {  
        FastReader in=new FastReader();
        int t=1;
        //t=in.nextInt();
        while(t-->0)
        {
           
            double d=in.nextDouble();
            double time=in.nextDouble();
            double s=in.nextDouble();
            
            if(d/time<=s)
            {
                System.out.println("Yes");
            }
            else
                System.out.println("No");
           
        }
    }
}

Measured memory_bytes: 25372
#include <stdio.h>

int main(void)
{
	int W, H, N;
	int w, h;
	int fx, fy;
	int tx, ty;
	int i;
	int sum;
	
	
	scanf("%d%d%d", &W, &H, &N);

	sum = 0;
	scanf("%d%d", &fx, &fy);
	for (i = 1; i < N; i++){
		scanf("%d%d", &tx, &ty);

		if (fx > tx){
			w = fx - tx;
		}
		else {
			w = tx - fx;
		}
		if (fy > ty){
			h = fy - ty;
		}
		else {
			h = ty - fy;
		}

		if ((fy < ty && fx < tx) || (fy > ty && fx > tx)){
			if (h > w){
				sum += h;
			}
			else {
				sum += w;
			}
		}
		else {
			sum += (h + w);
		}
		fx = tx;
		fy = ty;
	}
	
	printf("%d\n", sum);
	
	return (0);
}

Measured memory_bytes: 596
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[] A=new int[N+2];

		A[0]=A[N+1]=0;


		for (int i = 1; i < N+1; i++) {
			A[i]=sc.nextInt();
		}


		int sum=0;
		for (int i = 1; i < N+2; i++) {
			sum+=Math.abs(A[i]-A[i-1]);
		}

		for (int i = 1; i < N+1; i++) {

			int ans=sum-Math.abs(A[i-1]-A[i])-Math.abs(A[i]-A[i+1])+Math.abs(A[i-1]-A[i+1]);

			System.out.println(ans);
		}


	}

	//以下テンプレート

	public static int[] extgcd(int a, int b) {

		int x0 = 1;
		int x1 = 0;

		int y0 = 0;
		int y1 = 1;

		while (b != 0) {
			int q = a / b;
			int r = a % b;

			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;

			a = b;
			b = r;

			x0 = x1;
			x1 = x2;

			y0 = y1;
			y1 = y2;
		}

		return new int[] { a, x0, y0 };

	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;

		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		return gcd(b, a % b);

	}

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

	static void swap(int[] a) {
		int t;

		t = a[0];
		a[0] = a[1];
		a[1] = t;

		return;
	}

	static <T> void output(List<T> list) {

		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i));

			if (i != list.size() - 1) {
				System.out.print(" ");
			} else {
				nl();
			}
		}

	}

	static void output(String[][] str) {

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				print(str[i][j]);
			}

			nl();
		}

	}

	static void output(boolean flg, String Yes, String No) {

		if (flg) {
			pln(Yes);
		} else {
			pln(No);
		}

	}

	static void output(String[][] str, int digit) {

		String dig = "%" + String.valueOf(digit) + "s";

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				System.out.printf(dig, str[i][j]);
			}
			nl();
		}

	}

	static void pln(String str) {
		System.out.println(str);
	}

	static void pln(int x) {
		System.out.println(x);
	}

	static void print(String str) {
		System.out.print(str);
	}

	static void print(int x) {
		System.out.print(x);
	}

	static void print(String str, int times) {
		for (int i = 0; i < times; i++) {
			print(str);
		}
	}

	static void print(int x, int times) {
		for (int i = 0; i < times; i++) {
			print(x);
		}
	}

	static void nl() {
		System.out.println();
	}

}


Measured memory_bytes: 65492
import fractions
a = list(map(int,input().split()))

b = list(input())

c = list(input())

d = fractions.gcd(a[0],a[1])
d = (a[0] * a[1])//d

l = d //a[0]
ll = d//a[1]
lll = (l*ll)//fractions.gcd(l,ll)
p = 0
for i in range(1,d+1,lll):
    if i == 1:
        if b[0] != c[0]:
            p = 1
            break
    else:
        if b[(i-1) //l] != c[(i-1) // ll]:
            p = 1
            break


if p == 0:
    if d != max(a):
        print(d)
    else:
        print(-1)
else:
    print(-1)


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

const int mod = 1e9+7;
const int INF = 2000000;

int ans = 0;
int N,M,k,sw,p[10];
vector<vector<int>> S(10);

void dfs(int n, string b) {
    if(n == N) {
        for(int i =0;i<M;++i) {
            int c = 0;
            for(int s:S[i]) {
                if(b[s] == '1') ++c;
            }
            if(c%2 != p[i]) return;
        }
        ++ans;
        return;
    }
    dfs(n+1, b+"0");
    dfs(n+1, b+"1");
}
int main() {
   cin >> N >> M;
   for (int i = 0; i < M; i++)
   {
       cin >> k;
       for (int j = 0; j < k; j++)
       {
           cin >> sw;
           S[i].push_back(--sw);
       }
       
   }
   rep(i, M) cin >> p[i];
   dfs(0,"");
   cout << ans << endl;
}


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

#define fi first
#define se second
#define pb push_back
#define CLR(A, X) memset(A, X, sizeof(A))
#define bitcount(X) __builtin_popcountll(X)
//#pragma comment(linker, "/STACK:102400000, 102400000")
const double eps = 1e-10;
int dcmp(double x) { if(fabs(x) < eps) return 0; return x<0?-1:1; }
typedef long long LL;
typedef pair<int, int> PII;

const int N = 1e5+5;

map<int, int> ms;
vector<int> g;

int main() {
    int n, x;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &x);
        ms[x]++;
        if(ms[x] == 2) g.pb(x), ms[x] = 0;
    }
    sort(g.begin(), g.end());
    if(g.size() > 1) {
        int m = g.size();
        printf("%lld\n", 1LL*g[m-1]*g[m-2]);
    }
    else puts("0");
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define inf 1e19
#define maxn 500010   //最大点数
struct Edge{
    long long v, w, next;
}edge[500010];
long long head[maxn], tot, dis[maxn], n;
bool vis[maxn];
//注意初始化
void init()
{
    tot = 0;
    memset(head, -1, sizeof(head));
}
//注意双向加边
void addEdge(long long u, long long v, long long w)
{
    edge[tot].v = v;
    edge[tot].w = w;
    edge[tot].next = head[u];       //接替已有边
    head[u] = tot++;                //自己前插成为u派生的第一条边
}
void SPFA(long long u)
{
    long long v, w, i;
    for(i = 1; i <= n; i++)  //对于从1到n的编号
        dis[i] = inf, vis[i] = false;
    dis[u] = 0;
    queue<long long > q;
    q.push (u);
    vis[u] = true;
    while(!q.empty())
    {
        u = q.front();
        q.pop();
        vis[u] = false;
        for(i = head[u]; i != -1; i = edge[i].next)
        {
            w = edge[i].w;
            v = edge[i].v;
            if (dis[u] + w < dis[v])
            {
                dis[v] = dis[u] + w;
                if (!vis[v])
                {
                    q.push (v);
                    vis[v] = true;
                }
            }
        }
    }
}
int main()
{
        while(scanf("%lld",&n)!=EOF)
        {
                init();
                for(long long i=1;i<n;i++)
                {
                        long long x,y,z;
                        cin>>x>>y>>z;
                        addEdge(x,y,z);
                        addEdge(y,x,z);
                }
                long long Q,k;
                cin>>Q>>k;
                SPFA(k);
                for(long long i=1;i<=Q;i++)
                {
                        long long x,y;
                        cin>>x>>y;
                        cout<<dis[x]+dis[y]<<endl;
                }
        }
}


Measured memory_bytes: 12928
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	vector<int>v(31,0); 
	rep(i, 0, 28) {
		int a; cin >> a;
		v[a] = 1;
	}
	rep(i, 1, 31) {
		if (v[i] == 0)cout << i << endl;
	}
	return 0;
}

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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int k = 0;
    while (N > 0) {
        N /= K;
        ++k;
    }
    cout << k << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000001
#define pi 3.141592653589793
#define pii pair<int , int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti set <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
ll n;
void update(ll seg[],ll pos,ll val)
{
    for(ll i=pos+n;i>=1;i>>=1)
    {
        if(seg[i]<val)
            seg[i]=val;
        else
            break;
    }
}
ll find(ll seg[],ll u)
{
    ll l=n+1;
    ll a=0;
    for(u+=n;l<u;l>>=1,u>>=1)
    {
        if((l&1))
        {
            if(a<seg[l])
                a=seg[l];
            l++;
        }
        if((u&1))
        {
            if(a<seg[u-1])
                a=seg[u-1];
            u--;
        }
    }
    return a;
}
int main()
{  
    FAST
    cin>>n;
    ll h[n];
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>h[i];
    }
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll seg[(4*n)+4]={0};
    for(ll i=0;i<n;i++)
    {
        ll max=find(seg,h[i]);
        update(seg,h[i],(max+a[i]));
    }
    cout<<seg[1];
}

Measured memory_bytes: 9600
N = int(input())
data = []
for i in range(N) :
    A = int(input())
    wit = []
    for j in range(A) :
        x,y = map(int,input().split())
        wit.append((x-1,y))
    data.append(wit)

ans = 0

def check(tf) :
    for i in range(N) :
        if tf[i] == 1 :
            for x,y in data[i] :
                if y != tf[x] :
                    return False
    return True

def combination(tf) :
    global ans
    if len(tf) == N :
        if check(tf) :
            count = sum(tf)
            if count > ans :
                ans = count
    else :
        combination(tf + [0])
        combination(tf + [1])

combination([])
print(ans)

for i in range(2**N) :
    a = list(format(i,"b").zfill(N))
    for j in range(N) :
        if a[j] == "0" :
            data[j]
    


        

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

template <typename T>
class BinaryIndexedTree {

private:
	vector<T> data;

public:
	BinaryIndexedTree(int N) : data(N + 1) { }
	// calculate sum of a[0, i)
	T sum(int i){
		T s = T();
		for(; i > 0; i -= i & -i){ s += data[i]; }
		return s;
	}
	// add x to a[i]
	void add(int i, const T &x){
		for(++i; i < data.size(); i += i & -i){ data[i] += x; }
	}

};

struct LexicalCompare {
	bool operator()(int a, int b) const {
		char abuf[16] = { 0 }, bbuf[16] = { 0 };
		int alen = 0, blen = 0;
		while(a > 0){ abuf[alen++] = '0' + (a % 10); a /= 10; }
		while(b > 0){ bbuf[blen++] = '0' + (b % 10); b /= 10; }
		reverse(abuf, abuf + alen);
		reverse(bbuf, bbuf + blen);
		for(int i = 0; i < 16; ++i){
			if(abuf[i] < bbuf[i]){ return true; }
			if(abuf[i] > bbuf[i]){ return false; }
		}
		return false;
	}
};

int main(){
	while(true){
		ll A, B, P;
		cin >> A >> B >> P;
		if(A == 0 && B == 0 && P == 0){ break; }
		vector<int> lexical_order(B - A + 1);
		for(int i = A; i <= B; ++i){ lexical_order[i - A] = i; }
		sort(lexical_order.begin(), lexical_order.end(), LexicalCompare());
		int N = lexical_order.size();
		BinaryIndexedTree<ll> bit(N);
		vector<ll> dp(N);
		for(int i = 0; i < N; ++i){
			dp[i] = (bit.sum(lexical_order[i] - A) + 1) % P;
			bit.add(lexical_order[i] - A, dp[i]);
		}
		ll answer = accumulate(dp.begin(), dp.end(), 0ll) % P;
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 2872
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <stdio.h>
#include <queue>
#include <cmath>
#include <utility>
#include <map>

using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);++i)

bool isSame(string S) {
	char c = S[0];
	for (int i = 0; i < S.size(); i++) {
		if (S[i] != c)
			return false;
	}
	return true;
}

int main() {
	string S;
	cin >> S;
	int i;
	for (i = 0; i < S.size() && S[i] != 'C'; i++);
	for (; i < S.size() && S[i] != 'F'; i++);
	if (i >= S.size()) {
		cout << "No";

	}
	else
		cout << "Yes";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long ll;
#define ALL(V) V.begin(), V.end()
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}


int Main(int H, int A)
{
    return (H%A == 0) ? H/A : H/A+1;
}

int main(void){
    int H, A;
    cin >> H >> A;
    cout << Main(H, A) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    set<int>s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    if(s.size()==2)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}


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

void swap(int * a, int * b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

void print_int(int n)
{
    printf("%d\n",n);
    
}

void sort(int a[], int n)
{
    int h, i, j;

    for(h = 1; h < n / 9; h = h * 3 + 1)
        continue;

    for(; h > 0; h /= 3)
    {
        for(i = h; i < n; i++)
        {
            j = i;
            while(j >= h && a[j] < a[j-h])
            {
                swap(&a[j], &a[j-h]);
                j -= h;
            }
        }
    }
}

void print_list(int a[], int n)
{
    for(int i = 0; i < n; i++)
    {
        printf("%d ", a[i]);
    }
}

void intcpy(int a[], const int b[], int count)
{
    for(int i = 0; i < count; i++)
    {
        a[i] = b[i];
    }
}

int list_sum(int a[], int n)
{
    int sum = 0;

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

    return sum;
}


void permutate(int s[], int count, int n)
{
    if(n == count)
        return;

    for(int i = n; i < count; i++)
    {
        swap(&s[i], &s[n]);

        if(i != n)
        {
            //intcpy(result[j++], s, count);
        }
        
        permutate(s, count, n+1);
        swap(&s[i], &s[n]);
    }
}



int main(void)
{
    int a;
    scanf("%d", &a);
    if(a<=999)
        printf("%s","ABC");
    else
    {
        printf("%s", "ABD");
    }
    
    
    return 0;
}



Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	int n, q;
	cin >> n >> q;
	int result[100001][2] = {};
	result[0][0] = 1;
	result[1][1] = 1;
	int nowball = 0;
	for(int i = 0; i < q; i++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		if(result[a][1] != result[b][1]){
			swap(result[a][1], result[b][1]);
		}
		if(nowball == a){
			result[b][0] = 1;
			result[a][0] = 0;
			nowball = b;
			result[min(n - 1, b + 1)][1] = 1;
			result[max(0, b - 1)][1] = 1;
		} else if(nowball == b){
			result[a][0] = 1;
			result[b][0] = 0;
			nowball = a;
			result[min(n - 1, a + 1)][1] = 1;
			result[max(0, a - 1)][1] = 1;
		} else {
			result[min(n - 1, nowball + 1)][1] = 1;
			result[max(0, nowball - 1)][1] = 1;
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		ans += (result[i][0] | result[i][1]);
		// cout << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1152
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
	int ans = 0;
	long long n, t, a;
	cin >> n >> t >> a;
	t *= 1000, a *= 1000;
	vector<long long> h(n);
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
		if (abs(t - h[i] * 6 - a) < abs(t - h[ans] * 6 - a)) {
			ans = i;
		}
	}
	cout << (ans + 1) << endl;
	return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
typedef long long ll;

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<ll> A(N+1);
  vector<ll> B(N+1);
  for(int i = 0; i < N + 1; i++){
    cin >> A.at(i);
  }
  for(int i = 0; i < N; i++){
    cin >> B.at(i);
  }

  ll ans = 0;
  ll tmp = min(A.at(0), B.at(0));
  A.at(0) -= tmp;
  B.at(0) -= tmp;
  ans += tmp;
  for(int i = 1; i < N+1; i++){
    tmp = min(A.at(i), B.at(i-1));
    A.at(i) -= tmp;
    B.at(i-1) -= tmp;
    ans += tmp;
    tmp = min(A.at(i), B.at(i));
    A.at(i) -= tmp;
    B.at(i) -= tmp;
    ans += tmp;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <functional>

main () {
    int L[10];
    for (int i = 0; i < 3; i++) scanf("%d", &L[i]);
    std::sort(L, L+3, std::greater<>());
    printf ("%d\n", L[0] * 10 + L[1] + L[2]);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;
    int a[n+1]={0},b[n+1]={0},c[n+1]={0};
    int q,w,e;
    for(i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    for(i=1;i<=n;i++)
    {
        a[i]=max(a[i]+b[i-1],a[i]+c[i-1]);
        b[i]=max(b[i]+a[i-1],b[i]+c[i-1]);
        c[i]=max(c[i]+a[i-1],c[i]+b[i-1]);
    }
    cout<<max(a[n],max(b[n],c[n]));
    return 0;
    
}

Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#define PI 3.14159265359

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

	LL a,b;
	cin >> a >> b;
	if(a%2 == 0 && b%2 == 1){
		cout << (b-a+1)/2%2 << endl;
	}
	if(a%2 == 0 && b%2 == 0){
		cout << (((b-a+1-1)/2%2) ^ b) << endl;
	}
	if(a%2 == 1 && b%2 == 1){
		cout << (((b-a+1-1)/2%2) ^ a) << endl;
	}
	if(a%2 == 1 && b%2 == 0){
		cout << (((b-a+1-2)/2%2) ^ a ^ b) << endl;
	}

	return 0;
}

/*

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



return 0;
}
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5;
struct Element
{
    int u,v,opt;
} p[N+3];
int fa[N+3];
int find(int x){
    return x==fa[x]?x:fa[x]=find(fa[x]);
}
int main(){
    ll n,m,q;
    cin>>n>>m>>q;
    for(int i=1;i<=n;i++) fa[i]=i;
    for(int i=1;i<=q;i++){
        scanf("%d%d%d",&p[i].u,&p[i].v,&p[i].opt);
        p[i].u++;
        p[i].v++;
        if(p[i].opt==0){
            int fu=find(p[i].u),fv=find(p[i].v);
            if(fu!=fv)
                fa[fu]=fv;
        }
    }
    ll c=0;
    for(int i=1;i<=n;i++){
        if(find(i)==i)
            c++;
    }
    ll huan=0;
    for(int i=1;i<=q;i++){
        if(p[i].opt==1){
            huan++;
            if(find(p[i].u)==find(p[i].v)){
                printf("No\n");
                return 0;
            }
        }
    }
    ll temp=m-(n-c);
    ll l,r;
    l = huan?max(3ll,(ll)c):c-1ll,r = 1ll*c*(c-1ll)/2ll;
    if(l<=temp&&temp<=r)
        printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <cctype>
#include <cstring>
using namespace std;
typedef long long int64;
inline int64 read(int f = 1, int64 x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
int n, a, b;
int main()
{
    n = read(), a = read(), b = read();
    puts((a^b)&1?"Borys":"Alice");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define ll long long
const int inf = 1000000000; // 10^9

int main(){
    int n, cnt = 0, pnum = 0, qnum = 0;
    cin >> n;
    vector<int> p(n), q(n), a(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    
    rep(i, n) a[i] = i + 1;
    do{
        if(a == p) pnum = cnt;
        else cnt++;
    } while(next_permutation(a.begin(), a.end()));
    cnt = 0;
    do{
        if(a == q) qnum = cnt;
        else cnt++;
    } while(next_permutation(a.begin(), a.end()));
    cout << abs(pnum - qnum) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);   
} 
vector<int>a[100005];
int vis[100005];
int dp[100005];
int dfs(int i)
{
  if(dp[i]==1){
  trav(x,a[i])
  {
    if(vis[x]==0)
    {
      vis[x]=1;
    //  dp[x]=max(dp[x],dp[i]+1);
      dp[i]=max(dfs(x)+1,dp[i]);
    }
    vis[x]=0;
  }
  }
  return dp[i];
  //cout<<dp[3]<<endl;
}
void solve()
{
  int n,m;
  cin>>n>>m;
  fll(vis);
  rep(i,m)
  {
    int p,q;
    cin>>p>>q;
    p--;q--;
    a[p].pb(q);
  }
  fll(vis);
  rep(i,n){dp[i]=1;}
  rep(i,n)
  {
    dfs(i);
  }
  int k=0;rep(i,n){k=max(k,dp[i]);}
  cout<<k-1;
  //rep(i,n){rep(j,n){cout<<dp[i][j]<<" ";}cout<<endl;}
}
int main()
{
  fastio;
 // fopen();
  int t;
  //cin>>t;
  rep(i,1)
  { 
    solve();
    cout<<endl;
  }
  
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a,b) <<" " << max(0,a+b-n) << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>
int checka(int),checkb(int);
int main() {
    int n,count = 0;
    scanf("%d",&n);
    for(int i = 1;i <= n;i += 2) {
        int check = 0;
        if(i == 128) count += 1;
        else if(checka(i) == 1) count += 1;
        else if(checkb(i) == 1) count += 1;
    }
    printf("%d\n",count);
    return 0;
}

int checka(int i) {
    int prime[5] = {3,5,7,11,13};
    for(int j = 0;j < 5;j++) {
        if(i%(prime[j]*prime[j]*prime[j]) == 0) {
            int nokori = i/(prime[j]*prime[j]*prime[j]);
            if(nokori != prime[j] && (nokori == 3 || nokori == 5 || nokori == 7)) {
//                 printf("%d\n",prime[j]);
                return 1;
            }
        }
    }
    return 0;
}

int checkb(int i) {
    int prime[5] = {3,5,7,11,13};
    for(int j = 0;j < 5;j++) for(int k = j + 1;k < 5;k++) {
        if(i%(prime[j]*prime[k]) == 0) {
            int nokori = i/(prime[j]*prime[k]);
            if(nokori != prime[j] && nokori != prime[k] && (nokori == 3 || nokori == 5 || nokori == 7 || nokori == 11 || nokori == 13)) {
//             printf("%d %d\n",prime[j],prime[k]);
            return 1;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 128
a,b = map(int,input().split())
def fcd(a , b):
    if a>= b:
        while b != 0:
            a,b = b,a%b
        return a
    
    else:
        while a != 0:
            b,a = a,b%a
        return b
    
    
def lcm(a,b):
    return a*b//fcd(a , b)


print(lcm(a,b))


Measured memory_bytes: 2940
/**
 * ABC 150 C
 * 2020-04-25 19:13:10
 * unkounkounkounkounko
 * unko
 **/
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
   int N;
   cin >> N;
   string S;
   cin >> S;
   int ans = 1;
   for(int i = 1; i < N; i++){
      if(S[i] != S[i - 1]){
         ans++;
      }
   }
   cout << ans << endl;
return 0;}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a+n);
  int ans = 0;
  for (int i = 0; i < n-1; i++) {
    ans += abs(a[i] - a[i+1]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;

namespace B___Common_Raccoon_vs_Monster
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var h = int.Parse (input[0]);
            var n = int.Parse (input[1]);
            input = Console.ReadLine ().Split (' ');
            var total = 0;
            for (var i = 0; i < n; i++)
            {
                total += int.Parse (input[i]);
                if (total >= h)
                {
                    Console.WriteLine ("Yes");
                    return;
                }
            }
            Console.WriteLine ("No");
        }
    }
}

Measured memory_bytes: 16480
input = raw_input
range = xrange

n, m = map(int,input().split())
grid = [input() for i in range(n)]

use = [False]*n
cur = []
def backtrack_even(i, rem, addwhat):
    if rem == 0:
        if addwhat != None: cur.append(addwhat)
        check(cur)
        if addwhat != None: cur.pop()
        return
    if use[i]: return backtrack_even(i+1, rem, addwhat)
    use[i] = True; cur.append(i)
    for j in range(i+1, n):
        if use[j]: continue
        use[j] = True; cur.append(j)
        backtrack_even(i+1, rem-2, addwhat)
        use[j] = False; cur.pop()
    use[i] = False; cur.pop()

def backtrack():
    if n%2 == 0: return backtrack_even(0, n, None)
    for i in range(n):
        use[i] = True
        backtrack_even((0 if i else 1), n-1, i)
        use[i] = False

middle_initial = (m%2 == 0)
from collections import Counter
def check(cur):
    P = cur[::2] + cur[1::2][::-1]
    cols = Counter((''.join(grid[P[i]][j] for i in range(n))) for j in range(m))
    #print(cur, P, cols)
    middle_filled = middle_initial
    rem = m
    while rem:
        w = next(iter(cols))
        cols[w]-= 1; rem-= 1
        if cols[w] == 0: del cols[w]
        w2 = w[::-1]
        if w2 in cols:
            assert cols[w2]
            cols[w2]-= 1; rem-= 1
            if cols[w2] == 0: del cols[w2]
        elif w == w[::-1] and not middle_filled:
            middle_filled = True
        else: return False
    print("YES"); exit()

backtrack()
print("NO")

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

signed main () {
	int n;
	cin >> n;
	bool yes = 0;
	int row = 0;
	for (int i = 0; i < n; ++i) {
		int d1, d2;
		cin >> d1 >> d2;
		if (d1 == d2)
			++row;
		else
			row = 0;
		if (row >= 3)
			yes = 1;
	}
	if (yes)
		cout << "Yes\n";
	else
		cout << "No\n";
}


Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,w=map(int,input().split())
WV=[tuple(map(int,input().split())) for i in range(n)]
dp=[0]*(w+1)
for i in range(n):
  wi,vi=WV[i]
  for di in range(w,-1,-1):
    if not (0<=di-wi<10**7+10): continue
    dp[di]=max(dp[di],dp[di-wi]+vi)
print(dp[w])
# print(dp)

Measured memory_bytes: 42092
#include<bits/stdc++.h>
using namespace std;
int main() {
    //0.25 Qyen 0.5 Hyen 1 Syen 2 Dyen
    int Q,H,S,D;
    int N;

    cin >>Q>>H>>S>>D;
    cin >>N;

    int c025 = Q;
    int c05 = min(H, c025*2);
    int c1 = min(S, c05*2);
    int c2 = min(D, c1*2);

    printf("%lld\n",c2*1ll*(N/2)+c1*1ll*(N%2));
}

Measured memory_bytes: 384
#Bingo
card = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = list([int(input()) for _ in range(N)])
a = [[0]*3 for _ in range(3)]
for bi in b:
    for i in range(3):
        for j in range(3):
            if bi == card[i][j]:
                a[i][j] = 1
                
ans = 'No'
#tate
for i in range(3):
    if a[0][i] == 1 and a[1][i] == 1 and a[2][i] == 1:
        ans = 'Yes'
            
#yoko
for i in range(3):
    if a[i][0] == 1 and a[i][1] == 1 and a[i][2] == 1:
        ans = 'Yes'
    
#naname
if a[0][0] == 1 and a[1][1] == 1 and a[2][2] == 1:
    ans = 'Yes'
if a[0][2] == 1 and a[1][1] == 1 and a[2][0] == 1:
    ans ='Yes'
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

void print_array(int a[],int n);

int main(void){
	int n,i,j,key;
	int a[101];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++){
		key=a[i];
		j=i-1;
		while(j>=0 && a[j] > key){
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=key;
		print_array(a,n);
	}
	return 0;
}

void print_array(int a[], int n)
{
  int i;
  for(i = 0; i < n; i++){
    printf("%d",a[i]);
	if(i!=n-1) printf(" ");
  }
  printf("\n");
  return;
}

Measured memory_bytes: 604
N,M = map(int,input().split())

L = [list(map(int,input().split())) for i in range(M)]
L = sorted(L, key=lambda x: x[1])

a = -1
ans = 0
for i in range(M) :
    if L[i][0] <= a :
        continue
    else :
        ans += 1
        a = L[i][1] - 1
print(ans)


Measured memory_bytes: 29852