akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;



import java.util.StringTokenizer;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Lotfi
 */
 class Main {
    public static void main(String[] args) throws IOException {
        IO sc = new IO (System.in);
        int n=sc.nextInt();
        int[] arr= new int[n];
        for (int i = 0; i < n; i++) {
            arr[i]=sc.nextInt();
        }
        System.out.println(count(arr));
   }
    static int count(int[] arr){
        int i=0;
        int count=0;
        while(i<arr.length-1){
        if(arr[i]==arr[i+1]){
               count++;
            i+=2;
           
        }
        else{
            i++;
        }}
        return count;
    }
    public static class IO {
  private BufferedReader br;
  private StringTokenizer st;
  public IO(InputStream inputStream){
    br = new BufferedReader(new InputStreamReader(inputStream));
  }
  public String nextLine() throws IOException{
      return br.readLine();
  }
  public String next() {
    while (st == null || !st.hasMoreTokens()){
      try {
        st = new StringTokenizer(br.readLine());
      } catch (IOException ignored){}
    }
    return st.nextToken();
  }
  public int nextInt() {
    return Integer.parseInt(next());
  }
  public long nextLong() {
    return Long.parseLong(next());
  }
 
}
}


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



int main(){
	long long N;
	cin>>N;
	long long A[5];
	long long mini = 100000000000000000;
	for(int i=0;i<5;i++){
		cin>>A[i];
		mini = min(mini,A[i]);
	}

	
	long long ans_e=(N+A[0]-1)/A[0];
	long long ans_f = 1;
	for(int i=1;i<5;i++){
		if(A[i]>=A[i-1]){
			ans_e++;
			ans_f++;
			A[i]=A[i-1];
		}
		else{
			ans_e=ans_f+(N+A[i]-1)/A[i];
			ans_f++;
		}
		
	}
	
	cout<<ans_e<<endl;
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools

mod = int(1e9+7)

class Library():
    @staticmethod
    def Swap(a,b):
        return [b,a]

    @staticmethod
    def myRound(a,dig=0): # 四捨五入
        # dig => 桁数
        # dig = 1 => 10の位
        # dig = -1 => 小数第一位
        p = 10 ** dig
        return (a * p * 2 + 1) // 2 / p

    @staticmethod
    def Roundup(a): # 切り上げ
        if a < 0:
            return int(a)
        else:
            return int(a + 0.9)
    # 整数の切り上げ => (a + b - 1) // b

    @staticmethod
    def Gcd(a,b): #最大公約数
        if (a<b):
            a,b = Library.Swap(a,b)
        if (b==0):
            return a
        else:
            return Library.Gcd(b,a%b)

    @staticmethod
    def Lcm(a,b): #最小公倍数
        return a//Library.Gcd(a,b)*b

    @staticmethod
    def Divisors(a): # 約数列挙
        divisors = []
        for i in range(1,int(a**0.5)+1):
            if a%i==0:
                divisors.append(i)
                if i!=a//i:
                    divisors.append(a//i)
        divisors.sort()
        return divisors

class Prime():
    # コンストラクタ
    # エラストテネスの篩
    def __init__(self,num):
        self.num = num
        self.sieve = [0] * (self.num + 1)
        self.sieve[0] = -1
        self.sieve[1] = -1
        for i in range(2,self.num + 1):
            if not self.sieve[i]:
                self.sieve[i] = i
                for j in range(i * i,self.num + 1,i):
                    if self.sieve[j]:
                        self.sieve[j] = i
    
    # 素数判定
    def isPrime(self,num = None):
        if num is None:
            num = self.num
        if self.sieve[num] == num:
            return True
        else:
            return False
    
    # 素数列挙
    def PrimeNum(self,num = None):
        if num is None:
            num = self.num
        prime = []
        for i in range(2,num):
            if self.sieve[i] == i:
                prime.append(i)
        return prime
    
    # 素因数分解
    def PrimeFact(self,num = None):
        if num is None:
            num = self.num
        fact = []
        while self.sieve[num] != num:
            fact.append(self.sieve[num])
            num //= self.sieve[num]
        fact.append(num)
        return fact

def main():
    x,y = map(int,input().split())
    ans = 0
    if x == 1:
        ans += 300000
    elif x == 2:
        ans += 200000
    elif x == 3:
        ans += 100000
    if y == 1:
        ans += 300000
    elif y == 2:
        ans += 200000
    elif y == 3:
        ans += 100000
    if x ==1 and y == 1:
        ans += 400000
    print(ans)
    return

if __name__=='__main__':
    main()


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans = 0;
  int f = 1;
  rep(i,n){
    if(a[i]==f){
      f++;
    }
    else ans++;
  }
  if(ans==n) ans = -1;
  cout << ans << endl;
}


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

long long f(long long v) {
  if (v == 1) return 1;
  long long a = f(v/2);
  return a * 2 + 1;
}

int main() {

  long long H;
  cin >> H;
  
  cout << f(H) << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int a, cnt=0;
	scanf("%d", &a);
	int x[a], i;
	for (i=0;i<a;i++) {
		scanf("%d", &x[i]);
		while(x[i]%2==0) {
			cnt++;
			x[i]/=2;
		}
	}
	printf("%d", cnt);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <iterator>
#include <map>


using namespace std;

#define DT long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
typedef list<DT> lst;
typedef vector<DT> vec;

int main() {
	vector<int>vc(101);
	DT n,k,s=1,i;
	cin >> n>> k;
	
	s = k;
	s *= pow(k - 1, n - 1);
	cout << s << endl;
	return 0;
}
		
	
	
				

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stdio.h>
#include <math.h>
using namespace std;

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

int binary(int bina) {
    int ans = 0;
    for (int i = 0; bina > 0; i++)
    {
        ans = ans + (bina % 2) * pow(10, i);
        bina = bina / 2;
    }
    return ans;
}

int main() {
    string S;
    cin >> S;
    int length = S.length();
    // 比較対象作成
    string value1;
    string value2;
    for (int i = 0; i < length; i++) {
        if (i % 2 == 0) {
            value1 = value1 + "0";
            value2 = value2 + "1";
        }
        else {
            value1 = value1 + "1";
            value2 = value2 + "0";
        }
    }
    int res1 = 0;
    int res2 = 0;
    for (int i = 0; i < length; i++) {
        if (value1[i] != S[i]) ++res1;
        if (value2[i] != S[i]) ++res2;
    }

    if (res1 > res2) {
        cout << res2 << endl;
    }
    else {
        cout << res1 << endl;
    }
}

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

#define rep(i,n) for(int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
  int n;
  cin >> n;
  vector<pll> v(n);
  rep(i,n) {
    ll x, l;
    cin >> x >> l;
    v[i] = pll(x-l, x+l);
  }

  sort(v.begin(), v.end(), [](pll a, pll b) {
			     return a.second < b.second;});

  int res = 0;
  ll cur = -(1LL << 60);
  rep(i,n) {
    if (cur > v[i].first) continue;
    ++res;
    cur = v[i].second;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1792
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a,b = na()
count = 0
for i in range(a,b+1):
    i = str(i)
    if i[0]==i[1]==i[3]==i[4]:
        count += 1
    elif i[0]==i[4] and i[1]==i[2]==i[3]:
        count += 1
    elif i[0]==i[4] and i[1]==i[3]:
        count += 1
    else:
        pass
print(count)


Measured memory_bytes: 3188
import java.util.*;

public class Main {

    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();
        }
        Arrays.sort(a);
        int okIdx = 0;
        long s = a[0];
        for (int i = 1; i < n; i++) {
            if(s*2 < a[i]) okIdx = i;
            s += a[i];
        }
        System.out.println(n-okIdx);
        sc.close();

    }

}


Measured memory_bytes: 50784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 ll INF = 1LL << 60;

int main() {
    int n; cin >> n;
    string s = to_string(n);
    int sum = 0;
    for (int i = 0; i < s.length(); i++) {
        sum += s[i] - '0';
    }
    if (n % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n=5;
  vll a(5);
  rep(i,n) cin>>a[i];
  
  rep(i,n){
    if(a[i]==0){
      cout<<i+1<<endl;
      return 0;
    }
  }
  
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int a,b,i,c=0,k;
	cin >> a >> b >> k;
	for(i=100; i>0; --i){
		if(!((a%i)||(b%i))){
			++c;
		}
		if(c==k){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a*b>=c*d)
    printf("%d\n",a*b);
    else
    printf("%d\n",c*d);
    return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().split())
h = []
d = [0 for _ in range(n)]
ans = 1e9

for _ in range(n):
    h.append(int(input()))

h = sorted(h)

for i in range(n - k + 1):
    diff = h[i + k - 1] - h[i]
    ans = min(ans, diff)

print(ans)


Measured memory_bytes: 9048
#include"bits/stdc++.h"
using namespace std;
string s;
int x,y,z;
int main(){
	cin>>x>>y>>z;
	if((x*100+y*10+z)%4==0)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
# 解説を参考に作成


def solve():
    N, A, B, C = map(int, input().split())
    ls = [int(input()) for n in range(N)]

    def dfs(n=0, a=0, b=0, c=0, now_mp=0, min_mp=float('inf')):
        if n == N:
            if 0 in [a, b, c]:
                return min_mp
            else:
                return min(abs(A - a) + abs(B - b) + abs(C - c) - 30 + now_mp,
                           min_mp)
        result1 = dfs(n + 1, a, b, c, now_mp, min_mp)
        result2 = dfs(n + 1, a + ls[n], b, c, now_mp + 10, min_mp)
        result3 = dfs(n + 1, a, b + ls[n], c, now_mp + 10, min_mp)
        result4 = dfs(n + 1, a, b, c + ls[n], now_mp + 10, min_mp)
        return min(result1, result2, result3, result4)

    print(dfs())


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main() {
	int k, l, r;
	cin >> k >> l >> r;
	int flag = 0, ans = k;
	while (ans <= r) {
		if (ans >= l&&ans <= r)flag = 1;
		ans += k;
		
	}
	if (flag)cout << "OK" << endl;
	else cout << "NG" << endl;
	return 0;
}

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    vector<int> a(n), dp(k+1);
    for (int i=0; i<n; ++i)
    	cin>>a[i];
    for (int i=1; i<=k; ++i){
    	for (auto& x: a){
    		if (i-x>=0 && !dp[i-x]){
    			dp[i]=1;
    			break;
    		}
    	}
    }
    cout<<(dp[k]?"First":"Second");
    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
int main(void){
	int N;
	int a[100];
	int b[100];
	int c[100];
	int d[100];
	int ans = 0;
	scanf("%d",&N);
	int i,j;
	for(i=0;i<N;i++){
		scanf("%d %d",&a[i],&b[i]);
	}
	for(i=0;i<N;i++){
		scanf("%d %d",&c[i],&d[i]);
	}
	//まずBについてx座標の小さい順にソートしていく。
	//バブルソートの場合は、
	for(i=0;i<N;i++){
		for(j=i+1;j<N;j++){
			if(c[i]>c[j]){
				int temp1;
				int temp2;
				temp1 = c[i];
				temp2 = d[i];
				c[i] = c[j];
				d[i] = d[j];
				c[j] = temp1;
				d[j] = temp2;
			}
		}
	}
	//上の操作をするとc[0]は最小のx座標になっている。これは昇り順って言う？
	//次にRedをy座標について降り順ににソートする
	for(i=0;i<N;i++){
		for(j=i+1;j<N;j++){
			if(b[i]<b[j]){
				int temp1;
				int temp2;
				temp1 = a[i];
				temp2 = b[i];
				a[i] = a[j];
				b[i] = b[j];
				a[j] = temp1;
				b[j] = temp2;
			}
		}
	}
	//上の操作でRedがy座標について下り順ソートされた。
	//次にマッチングさせていく。Blueのxが一番小さいヤツとRedのy座標が一番大きいやつでペアを作る。
	//ペアを作ったらその2つの点は捨てていく。ansを加算する。
	//ええとまずBlueの数分だけループを回せばいいのか？
	for(i=0;i<N;i++){
		//Blueの点c[i],d[i]について
		//Redを見ていく、Redはもうy順でソートされているのでRed[0]から条件を満たすかどうかチェックする。
		for(j=0;j<N;j++){
			if(d[i]>b[j]){//もしもBのy座標がAより大きかったら
				if(c[i]>a[j]){//x座標B>Aをチェックする。
					//printf("(%d,%d) matched (%d,%d)\n",a[j],b[j],c[i],d[i]);
					a[j]=1e9;
					b[j]=1e9;
					ans++;
					break;
				}
			}
		}
	}
	
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=2e5+4;

int main()
{
	int a,b,k;

	scn(k); scn(a); scn(b);

	if(a>b)
	swap(a,b);

	int flag=0;

	rep(i,1,1001)
	if(i*k>=a and i*k<=b)
	flag=1;

	if(flag)
	cout<<"OK";
	else
	cout<<"NG";

    return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int h,w;
    cin >> h >> w;
    vector<vector<int>> a(w+2,vector<int>(h+2,1));
    rep(i,h){
      rep(j,w){
        char s;
        cin >> s;
        if (s=='.') a[j+1][i+1]=0;
      }
    }
    int ans=0;
    for(int i=1;i<=h;i++){
      for(int j=1;j<=w;j++){
        if (a[j][i]==1) continue;
        vector<vector<int>> b=a;
        b[j][i]=1;
        queue<pair<pp,int>> q;
        q.push(mk(mk(j,i),0));
        while(!q.empty()){
          int f=q.front().first.first,g=q.front().first.second,e=q.front().second;
          ans=max(ans,e);
          q.pop();
          if (b[f+1][g]==0){
            b[f+1][g]=1;
            q.push(mk(mk(f+1,g),e+1));
          }
          if (b[f-1][g]==0){
            b[f-1][g]=1;
            q.push(mk(mk(f-1,g),e+1));
          }
          if (b[f][g+1]==0){
            b[f][g+1]=1;
            q.push(mk(mk(f,g+1),e+1));
          }
          if (b[f][g-1]==0){
            b[f][g-1]=1;
            q.push(mk(mk(f,g-1),e+1));
          }
        }
      }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 1050;
const long long INF = 1e18;

int n, m;
long long x[MAXN], y[MAXN], z[MAXN];
long long dp[MAXN][MAXN];
long long ans = -INF;

int getBit(long long x, int pos) {
  return (x & (1ll << pos)) > 0 ? 1 : 0;
}

int main() { 

  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%lld %lld %lld", &x[i], &y[i], &z[i]);
  }

  if (m == 0) {
    cout << 0 << endl;
    return 0;
  }

  for (int mask = 0; mask < (1 << 3); mask++) {
    memset(dp, 0, sizeof(dp));

    for (int i = 0; i < n; i++) {
      if (getBit(mask, 0)) {
        x[i] = -x[i];
      }
      if (getBit(mask, 1)) {
        y[i] = -y[i];
      }
      if (getBit(mask, 2)) {
        z[i] = -z[i];
      }
    }

    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        dp[i][j] = -INF;
      }
    }

    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= min(i, m); j++) {
        if (i > 1) {
          dp[i][j] = dp[i - 1][j];
        }
        dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + x[i - 1] + y[i - 1] + z[i - 1]);
      }
    }

    for (int i = 0; i < n; i++) {
      if (getBit(mask, 0)) {
        x[i] = -x[i];
      }
      if (getBit(mask, 1)) {
        y[i] = -y[i];
      }
      if (getBit(mask, 2)) {
        z[i] = -z[i];
      }
    }

    ans = max(ans, dp[n][m]);
  }

  cout << ans << endl;

  return 0;
}


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

int a[109];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	int s = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		s += a[i]; a[i] *= n;
	}
	int mn = 1000000000;
	for (int i = 0; i < n; i++)
		mn = min(mn, abs(a[i] - s));
	for (int i = 0; i < n; i++)
		if (mn == abs(a[i] - s)) {
			cout << i << '\n';
			break;
		}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int needtime = reader.nextInt();
		int timedBy = reader.nextInt();

		float resultF = (float) (needtime * 1.0 / timedBy);

		System.out.println(resultF);
		reader.close();

	}

}


Measured memory_bytes: 23892
#include<iostream>
using namespace std;
string s,t;
main(){
  cin>>s>>t;
  if(s.size()!=t.size()){
    cout<<(s.size()<t.size()?"LESS":"GREATER")<<endl;
    return 0;
  }
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      cout<<(s[i]<t[i]?"LESS":"GREATER")<<endl;
      return 0;
    }
  }
  cout<<"EQUAL"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <string.h>         // strlen()
#define MAX_N 100
 
int dice[6];
 
void
east()
{
    int t = dice[2];
    dice[2] = dice[0];
    dice[0] = dice[3];
    dice[3] = dice[5];
    dice[5] = t;
}
 
void
south()
{
    int t = dice[1];
    dice[1] = dice[0];
    dice[0] = dice[4];
    dice[4] = dice[5];
    dice[5] = t;
}
 
void
west()
{
    int t = dice[3];
    dice[3] = dice[0];
    dice[0] = dice[2];
    dice[2] = dice[5];
    dice[5] = t;
}
 
void
north()
{
    int t = dice[4];
    dice[4] = dice[0];
    dice[0] = dice[1];
    dice[1] = dice[5];
    dice[5] = t;
}
 
int
main(int argc, char** argv)
{
    char cmd[MAX_N + 1];
    int l;
    int i;
 
    for (i = 0; i < 6; ++i)
        scanf("%d", &dice[i]);
 
    scanf("%s", cmd);
    l = strlen(cmd);
    for (i = 0; i < l; ++i)
    {
        switch (cmd[i])
        {
        case 'E':
            east();
            break;
 
        case 'S':
            south();
            break;
 
        case 'W':
            west();
            break;
 
        case 'N':
        default:
            north();
        }
    }
 
    printf("%d\n", dice[0]);
    return 0;
}


Measured memory_bytes: 2096
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n = I()
edge = [[] for _ in range(n)]
for v in range(1,n):
    u = I()-1
    edge[u].append(v)

dp = [None]*n
def dfs(s):
    if dp[s] != None:
        return dp[s]
    if edge[s] == []:
        dp[s] = 0
        return 0
    tmp = []
    for v in edge[s]:
        tmp.append(dfs(v))
    tmp.sort(reverse=True)
    m = 0
    for i,j in enumerate(tmp):
        m = max(m,(i+1)+j)
    dp[s] = m
    return m

dfs(0)
print(dp[0])


Measured memory_bytes: 120180
#include<stdio.h>
int main(){
	int n,m,i,j;
	int a[55],b[55],x[55];
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)
		scanf("%d %d",&a[i],&b[i]);
	for(i=0;i<55;i++)
		x[i]=0;
	for(i=1;i<=n;i++){
		for(j=0;j<m;j++){
			if(a[j]==i)
				x[i]++;
			if(b[j]==i)
				x[i]++;
		}
		printf("%d\n",x[i]);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
main () {
	int m, f, r;
	while (cin >> m >> f >> r, m!=-1||f!=-1||r!=-1) {
		if ((m == -1 || f == -1) || m + f < 30) cout << "F" << endl;
		else if (m + f >= 80) cout << "A" << endl;
		else if (m + f >= 65) cout << "B" << endl;
		else if (m + f >= 50 || r >= 50) cout << "C" << endl;
		else cout << "D" << endl;
	}
}

Measured memory_bytes: 3088
#include <iostream>

int main() {
  int group_num;
  std::cin >> group_num;

  int sum = 0;
  for (int i = 0; i < group_num; i++) {
    int l, r;
    std::cin >> l >> r;
    sum += r - l + 1;
  }
  std::cout << sum << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int a,b;
  cin >> a >> b;
  cout << max({a + b,a - b,a * b});
  return 0;
}


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

struct Node {
  long key;
  Node *parent, *left, *right;
};

Node *root, *nil;

void insert(long k) {
  Node *y = nil;
  Node *x = root;

  Node *z;
  z = (Node*)malloc(sizeof(Node));
  z->key = k;
  z->parent = nil;
  z->left = nil;
  z->right = nil;

  while (x != nil) {
    y = x;
    if (z->key < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;

  if (y == nil) {
    root = z;
  } else if (z->key < y->key) {
    y->left = z;
  } else {
    y->right = z;
  }
}

void in(Node* n) {
  if (n == nil) return;
  in(n->left);
  cout << ' ' << n->key;
  in(n->right);
}

void pre(Node* n) {
  if (n == nil) return;
  cout << ' ' << n->key;
  pre(n->left);
  pre(n->right);
}

void print() {
  in(root); cout << endl;
  pre(root); cout << endl;
}

int main() {

  long l; cin >> l;

  while (l--) {
    string s; cin >> s;

    if (s == "insert") {
      long k; cin >> k;
      insert(k);
    } else {
      print();
    }
  }

  return 0;
}

Measured memory_bytes: 24652
n = int(input())
s = input()
cnt = 0
for i in range(10):
    a = s.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b = s.find(str(j), a + 1)
        if b == -1:
            continue
        for k in range(10):
            c = s.find(str(k), b + 1)
            if c != -1:
                cnt += 1
print(cnt)

Measured memory_bytes: 9284
#include <bits/stdc++.h>
using namespace std;
int main() {
  double w,h,x,y;
  cin >> w >> h >> x >> y;
  int kai = 0;
  if(x == w/2 && y == h/2) kai = 1;
  cout << h*w/2 << " " << kai << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin >>s;
int count =0;
int output =0;
for(int i=0;i<s.size();i++){
if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
count ++;
}else{
count =0;
}
output =max(output,count);
}
cout << output <<endl;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edge{
  ll from,to,dis;
};
bool cmp(const edge& a,const edge& b){
  return a.dis<b.dis;
}
ll par[400010];
ll len[400010];
void init(ll n){
  for(ll i=0;i<n;i++){
    par[i]=i;
    len[i]=0;
  }
}
ll root(ll n){
  if(par[n]==n)return n;
  return par[n]=root(par[n]);
}
void unit(ll a,ll b){
  a=root(a);
  b=root(b);
  if(a==b)return;
  if(len[a]<len[b]){
    par[a]=b;
  }
  else{
    par[b]=a;
    if(len[a]==len[b])len[a]++;
  }
}
int main(){
  ll n,m,k;cin>>n>>m>>k;
  ll c[n];
  ll now=1;
  for(int i=0;i<n;i++){
    cin>>c[i];
    if(c[i]==0){
      c[i]=now+100000;
      now++;
    }
  }
  vector<edge> v;
  for(int i=0;i<m;i++){
    ll a,b,w;cin>>a>>b>>w;
    a--;b--;
    edge e={a,b,w};
    v.push_back(e);
  }
  sort(v.begin(),v.end(),cmp);
  init(200001);
  ll ans=0;
  ll cnt=0;
  for(int i=0;i<m;i++){
    edge e=v[i];
    ll f=e.from,t=e.to,d=e.dis;
    f=c[f],t=c[t];
    if(root(f)!=root(t)){
      unit(f,t);
      ans+=d;
      cnt++;
    }
    if(cnt==k-1){
      cout<<ans<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

Measured memory_bytes: 9584
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

long long n;
long double maxn[2] = {0}, minn[2] = {0};
vector<pair<long long, bool>> lst[2];

long double solve();
long double calc(long double x);

int main() {
  cout << fixed << setprecision(10);
  cin >> n;
  minn[0] = minn[1] = (long long)1e10;
  maxn[0] = maxn[1] = -(long long)1e10;
  for(int i = 0; i < n; ++i) {
    long double x, y;
    char d;
    cin >> x >> y >> d;
    if(d == 'R') {
      minn[1] = min(minn[1], y);
      maxn[1] = max(maxn[1], y);
      lst[0].push_back({x, 1});
    }
    else if(d == 'L') {
      minn[1] = min(minn[1], y);
      maxn[1] = max(maxn[1], y);
      lst[0].push_back({x, 0});
    }
    else if(d == 'U') {
      minn[0] = min(minn[0], x);
      maxn[0] = max(maxn[0], x);
      lst[1].push_back({y, 1});
    }
    else {
      minn[0] = min(minn[0], x);
      maxn[0] = max(maxn[0], x);
      lst[1].push_back({y, 0});
    }
  }
  cout << solve() << endl;
  return 0;
}

long double solve() {
  long double ans = 1e18, l = 0, r = 1e9;
  for(int i = 0; i < 1500; ++i) {
    long double nowl, nowr, ansl, ansr;
    nowl = (2 * l + r) / 3;
    nowr = (l + 2 * r) / 3;
    ansl = calc(nowl);
    ansr = calc(nowr);
    if(ansl > ansr)
      l = nowl;
    else
      r = nowr;
    ans = min({ans, ansl, ansr});
  }
  return min(ans, calc((l + r) / 2));
}

long double calc(long double x) {
  long double nmaxn[2] = {0}, nminn[2] = {0};
  for(int t = 0; t < 2; ++t) {
    nmaxn[t] = maxn[t];
    nminn[t] = minn[t];
  }
  for(int t = 0; t < 2; ++t)
    for(int i = 0; i < lst[t].size(); ++i) {
      long double nowp = lst[t][i].fi;
      if(lst[t][i].se)
        nowp += x;
      else
        nowp -= x;
      nmaxn[t] = max(nmaxn[t], nowp);
      nminn[t] = min(nminn[t], nowp);
    }
  return (nmaxn[0] - nminn[0]) * (nmaxn[1] - nminn[1]);
}

Measured memory_bytes: 2036
N = gets.to_i
H = gets.split(' ').map(&:to_i)
ans = 0
cnt = 0
1.upto(N-1) do |i|
  if H[i-1] < H[i]
    cnt = 0
  else
    cnt += 1
    ans = [ans, cnt].max
  end
end
puts ans

Measured memory_bytes: 12284
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

a,b,c,d = map(int,input().split())

zero_b = b - b // c - b // d + b // lcm(c,d)
zero_a = (a-1) - (a-1) // c - (a-1) // d + (a-1) // lcm(c,d)

print(zero_b - zero_a)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define INF (10000000)
int n, v, w;

int dist[108000];
int deg[108000];
vector<int> edge[108000];
int dfs(int x, int last = -1){
	if(last == -1)dist[x] = 0;
	for(int i = 0;i < edge[x].size();i++){
		int to = edge[x][i];
		if(to == last)continue;
		dist[to] = dist[x] + 1;
		dfs(to, x);
	}
}

vector<int> check(int x){
	int now = x;
	int p = 1;
	vector<int> ans;
	int last = -1;
	while(p <= n){
		int nxt = -1;
		for(int i = 0;i < edge[now].size();i++){
			int to = edge[now][i];
			if(to == last)continue;
			if(deg[to] != 1){
				if(nxt == -1)nxt = to;
				else{
					ans.push_back(INF);
					ans[0] = INF;
					return ans;
				}
			}
		}
		if(nxt == -1 &&  edge[now].size() > 0 && edge[now][0] != last)nxt = edge[now][0];
		if(nxt == -1 &&  edge[now].size() > 1)nxt = edge[now][1];

		ans.push_back(p++);

		for(int i = 0;i < edge[now].size();i++){
			int to = edge[now][i];
			if(to == last)continue;
			if(to == nxt)continue;
			ans.push_back(p++);
			swap(ans[ans.size() - 1], ans[ans.size() - 2]);
		}		last = now;
		now = nxt;
	 
	}
	return ans;
}

int main(){
	cin >> n;
	for(int i = 0;i < n-1;i++){
		cin >> v >> w;
		deg[v]++;
		deg[w]++;
		edge[v].push_back(w);
		edge[w].push_back(v);
	}
	dfs(1);
	int nxt = 0;
	for(int i = 1;i <= n;i++){
		if(dist[nxt] < dist[i])nxt = i;
	}
	vector<int> hoge = check(nxt);
	dfs(nxt);
	for(int i = 1;i <= n;i++){
		if(dist[nxt] < dist[i])nxt = i;
	}
	vector<int> fuga = check(nxt);
	
	if(hoge[0] == INF && fuga[0] == INF)cout << -1 << endl;
	else{
		if(hoge > fuga)swap(hoge, fuga);
		
		for(int i = 0;i < hoge.size();i++)cout << hoge[i] <<" " ;cout << endl;
	}
	return 0;	
}

Measured memory_bytes: 14456
s=input()

logk = (10**100).bit_length()
lens = len(s)
logs = lens.bit_length()
doubling = [[0]*lens for _ in range(logk)]

for i in range(lens):
  if s[i] == 'R':
    doubling[0][i] = i + 1
  else:
    doubling[0][i] = i - 1

for i in range(1,logk):
  for j in range(lens):
    doubling[i][j] = doubling[i-1][doubling[i-1][j]]

from collections import Counter
result = Counter(doubling[logk-1])
for i in range(lens):
  print(result[i])


Measured memory_bytes: 351720
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > points;
bool present(pair<int, int> p){
    int l = 0; int r = points.size()-1;
    while (l <= r){
        int m = (l + r) / 2;
        if (p.first == points[m].first){
            if (p.second == points[m].second){
                return true;
            }
            if (p.second > points[m].second){
                l = m + 1; continue;
            }else{
                r = m-1; continue;
            }
        }
        if (p.first > points[m].first){
            l = m + 1; continue;
        }else{
            r = m - 1; continue;
        }
    }
    return false;
}
int main(){
    ios::sync_with_stdio(false);
    int h, w, m; cin >> h >> w >> m;
    vector<int> H(300001), W(300001);
    for (int i = 0; i < m; i++){
        int hi, wi; cin >> hi >> wi;
        H[hi]++; W[wi]++;
        points.push_back({hi, wi});
    }
    sort(points.begin(), points.end());
    int max_h = 0; int max_w = 0;
    for (int i = 0; i <= 300000; i++){
        max_h = max(max_h, H[i]);
        max_w = max(max_w, W[i]);
    }
    vector<int> Hmax, Wmax; long long Hcnt = 0; long long Wcnt= 0;
    for (int i = 0; i <= 300000; i++){
        if (H[i] == max_h){
            Hmax.push_back(i);
            Hcnt++;
        }
        if (W[i] == max_w){
            Wmax.push_back(i);
            Wcnt++;
        }
    }
    long long num = Hcnt * Wcnt;
    if (num > m){
        cout << max_h + max_w << '\n';
        return 0;
    }
    bool sol = true;
    for (int i = 0; i < Hcnt; i++){
        for (int j = 0; j < Wcnt; j++){
            if (!present({Hmax[i], Wmax[j]})){
                sol = false;
                cout << max_h + max_w << '\n';
                return 0;
            }
        }
    }
    if (sol) cout << max_h + max_w - 1 << '\n';
    return 0;
}

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int a, b;
    cin >> a >> b;
    unordered_map<int, P> d;
    rep(i, 1, 1001){
        d[i] = make_pair(floor(i * 0.08), floor(i * 0.1));
    }
    rep(i, 1, 1001){
        if(d[i].first == a && d[i].second == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
int main(){
 std::string S,T;
 std::cin >> S >> T;
 S= S+T;
int A= std::stoi(S);
  for(int i=1;i<=A/2;i++){
      if(A%i==0 && A/i==i){
        std::cout << "Yes" << std::endl;
        return 0;
      }
   }
 std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Shuffle
 */
public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String str = sc.next();
            if (str.equals("-")) {
                break;
            }

            int m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int h = sc.nextInt();
                str = str.substring(h) + str.substring(0, h);
            }

            System.out.println(str);
        }

        sc.close();
    }
}


Measured memory_bytes: 26316
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AizuOnline
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var n = Console.ReadLine().Split(' ');
            var c = Console.ReadLine().Split(' ');

            var J = int.Parse(n[0]);
            var I = int.Parse(n[1]);
            var dp = new int[I + 1, J + 1];

            for (int i = 0; i <= I; i++)
            {
                for (int j = 0; j <= J; j++)
                {
                    if (i == 0 || j == 0)
                    {
                        dp[i, j] = 0;
                    }
                    else
                    {
                        dp[i, j] = int.MaxValue;
                    }
                    if (i == 1)
                    {
                        dp[i, j] = j;
                    }
                }
            }

            for (int i = 1; i < I; i++)
            {
                for (int j = 0; j < J + 1; j++)
                {
                    if (j - int.Parse(c[i]) >= 0)
                    {
                        dp[i + 1, j]
                            = Math.Min(
                                dp[i, j],
                                dp[i + 1, j - int.Parse(c[i])] + 1);
                    }
                    else
                    {
                        dp[i + 1, j] = dp[i, j];
                    }
                }
            }
            var min = int.MaxValue;
            for (int i = 1; i < I+1; i++)
            {
                min = Math.Min(min, dp[i, J]);
            }
            Console.WriteLine(min);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13264
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}  
int D;
vector<int> c(26);
vector<vector<int>> s;
struct State {
  int ans = 0;
  vector<int> t;
  vector<int> sscore;
  vector<vector<int>> cscore;
};
void score(State &st, set<int> idx) {
  vector<int> last(26);
  REP(i, D) {
    st.ans += s[i][st.t[i]] - st.sscore[i];
    st.sscore[i] = s[i][st.t[i]];
    last[st.t[i]] = i + 1;
    for(int j : idx) {
      st.ans -= (c[j] * (i + 1 - last[j]) - st.cscore[i][j]);
      st.cscore[i][j] = c[j] * (i + 1 - last[j]);
    }
  }
}
double TIME_LIMIT = 1980;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> D;
  REP(i, 26) cin >> c[i];
  s = vector<vector<int>>(D, vector<int>(26));
  REP(i, D) REP(j, 26) cin >> s[i][j];

  State st;
  vector<int> t(D);
  REP(i, D) t[i] = i%26;
  st.t = t;
  vector<int> sscore(D);
  st.sscore = sscore;
  vector<vector<int>> cscore(D, vector<int>(26));
  st.cscore = cscore;
  set<int> idxset;
  REP(i, 26) idxset.insert(i);
  score(st, idxset);
  
  clock_t start_time = clock();
  int loop = 0;
  double start_temp = 5000, end_temp = 100;
  while(true) {
    loop++;
    clock_t now_time = clock();
    double time = static_cast<double>(now_time - start_time) / CLOCKS_PER_SEC * 1000.0;
    if(time > TIME_LIMIT) break;
    int mode = rand() % 2;
    int tmpidx, tmptype;
    idxset.clear();
    int lastans = st.ans;
    if(mode == 0) {
      int idx = rand() % D;
      int type = rand() % 26;
      tmpidx = idx;
      tmptype = st.t[idx];
      st.t[idx] = type;
      idxset.insert(type);
    } else {
      int idx = rand() % (D-1);
      swap(st.t[idx], st.t[idx+1]);
      tmpidx = idx;
      idxset.insert(st.t[idx]);
      idxset.insert(st.t[idx+1]);
    }
    score(st, idxset);
    double temp = start_temp + (end_temp - start_temp) * time / TIME_LIMIT;
    double prob = exp((st.ans-lastans)/temp);
    if(st.ans > lastans || prob > (rand()%INF)/(double)INF) {
      ;
    } else {
      if(mode == 0) {
        st.t[tmpidx] = tmptype;
      } else {
        swap(st.t[tmpidx], st.t[tmpidx+1]);
      }
      score(st, idxset);
    }
    //cout << st.ans << "\n";
    //if(next < now) cout << prob << "\n";
  }
  REP(i, D) cout << (st.t[i]+1) << "\n";
  //cout << max << "\n";
  //cout << loop << "\n";
}

Measured memory_bytes: 4436
#include <bits/stdc++.h>
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
using namespace std;
map <int,int> mp;
typedef pair<int, int> P;
typedef long long ll;
static const int MAX=10000;
static const int NMAX=50;
static const int MMAX=50;
ll a[MAX+1];
int N;

//xの約数kの個数
int count_divisor(ll x,ll k){
    int cunt=0;
    while(x){
        if(x%k) return cunt;
        x /= k; cunt++;
    }
}

void solve(){
    int ans = 0;
    for(int i = 0;i < N; i++) ans += count_divisor(a[i],2);
    cout << ans << "\n";
}

int main(){
    cin >> N;
    for(int i = 0; i < N; i++) cin >> a[i];
    solve();
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
using namespace std;

const double pi = acos(-1);
#define nyan cout << "(=^•ω•^=)" << endl;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop while(true)

int ans;
int n;

bool judge(string s){
    bool f[3]={false};
    for(int i=0;i<s.length();i++){
        if(s[i]=='3')f[0]=true;
        else if(s[i]=='5')f[1]=true;
        else f[2]=true;
    }
    int v=stoi(s);
    if(v>n)return false;
    return f[0]&&f[1]&&f[2];
}

int manipulate(string s, int depth, int i){
    if(depth==0){
        if(judge(s))ans++;
        return 0;
    }
    if(i==7){
        manipulate(s+"7",depth-1,3);
        manipulate(s+"7",depth-1,5);
        manipulate(s+"7",depth-1,7);
    }
    else if(i==5){
        manipulate(s+"5",depth-1,3);
        manipulate(s+"5",depth-1,5);
        manipulate(s+"5",depth-1,7);
    }
    else if(i==3){
        manipulate(s+"3",depth-1,3);
        manipulate(s+"3",depth-1,5);
        manipulate(s+"3",depth-1,7);
    }
    return 0;
}

signed main(){
    cin>>n;
    for(int e=3;e<=9;e++){
        manipulate("",e,3);
        manipulate("",e,5);
        manipulate("",e,7);
    }
    cout<<ans/3<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func ReplaceComma(length, targetNum int, targetStr string) string {
	splitTargetStr := strings.Split(targetStr, "")
	notReplaceStr := splitTargetStr[targetNum-1]
	for i, s := range splitTargetStr {
		if s != notReplaceStr {
			splitTargetStr[i] = "*"
		}
	}
	return strings.Join(splitTargetStr, "")
}

func main() {
	var n, k int
	var s string
	fmt.Scan(&n, &s, &k)

	fmt.Println(ReplaceComma(n, k, s))
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
	int A, B, C, a, b, c, d, e, f, g, h, X, o, p;
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	scanf("%d", &X);
  A += 2; B += 2; C += 2;
	int g_z = 0;
	for (int i = 0; i < A; i++){
		e = (i - 1) * 500;
		f = X - e;
		if (f == 0) g_z += 1;
		if (f > 0 && e >= 0){
			for (int j = 0; j < B; j++){
				g = (j - 1) * 100;
				h = f - g;
				if (h == 0) g_z += 1;
				if (h > 0 && g >= 0){
					for (int k = 0; k < C; k++){
						o = (k - 1) * 50;
						p = h - o;
						if (p == 0) g_z += 1;
					}
				}
			}
		}
	}
	printf("%d", g_z);
}


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

int main() {
  int n;
  cin >> n;
  vector<int> h(n + 1);
  for (int i = 0; i < n; i++) cin >> h[i];
  h[n] = 0;
  int ans = 0;
  while (true) {
    for (int i = 0; i < n+1; i++) {
      if(i==n){
        cout << ans << endl;
        return 0;
      }
      if (h[i] != 0) break;
    }
    bool con = false;
    for (int i = 0; i < n + 1; i++) {
      if (h[i] > 0) {
        h[i]--;
        con = true;
      } else {
        if (con == true) ans++;
        con = false;
      }
    }
  }
}

Measured memory_bytes: 256
/*
[abc133] C - Remainder Minimization 2019
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MOD = 2019;

int L, R;

ll solve() {
    R = min(R, L + MOD);

    ll ans = MOD;
    for (int i = L; i <= R; i++) {
        for (int j = i + 1; j <= R; j++) {
            ans = min(ans, (ll)i * j % MOD);
        }
    }

    return ans;
}

int main() {
    cin >> L >> R;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

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

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

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

class Task{
public:
    void solve(istream& in, ostream& out){
        int N, M;
        in>>N>>M;
        vc<double> P(N);
        vvc<int> G(N);
        REP(i, M){
            int s, t;
            in>>s>>t;
            s--, t--;
            G[s].pb(t);
        }
        P[0] = 1;
        REP(i, N){
            for(auto& v : G[i]) P[v] += P[i] / LEN(G[i]);
        }
        vc<double> dp(N, 0);
        for(int i=N-2;0<=i;--i){
            for(auto& v : G[i]) dp[i] += dp[v];
            dp[i] = dp[i] / LEN(G[i]) + 1;
        }
        double ans = dp[0];
        for(int i=N-2;0<=i;--i){
            if(LEN(G[i])==1) continue;
            int sz = LEN(G[i]) - 1;
            double now = 0;
            for(auto& v : G[i]) now += dp[v];
            now = now / sz + 1;
            for(auto& v : G[i]){
                now -= dp[v] / sz;
                chmin(ans, dp[0]+P[i]*(now-dp[i]));
                now += dp[v] / sz;
            }
        }
        out<<fixed<<setprecision(12)<<ans<<'\n';
    }
};

int main(){
    istream& in(cin);
    ostream& out(cout);
    ios_base::sync_with_stdio(false);
    in.tie(nullptr), out.tie(nullptr);
    Task solver;
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 4720
n, k = map(int, input().split())
mink = (n - 1) * (n - 2) // 2
if k > mink:
    print(-1)
else:
    m = n - 1 + (mink - k)
    print(m)
    count = 0
    i = 1
    j = 2
    while count < m:
        if j == n + 1:
            i += 1
            j = i + 1
        print(i, j)
        j += 1
        count += 1

Measured memory_bytes: 42992
// abc110_b
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(void) {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	vector<int> x(N);
	vector<int> y(M);
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> y[i];
	}
	int max_x = *max_element(x.begin(),x.end());
	int min_y = *min_element(y.begin(), y.end());
	for (int i = X + 1; i <= Y; i++) {
		if (i > max_x && i <= min_y) {
			cout << "No War" << endl;
			return 0;
		}
	}
	cout << "War" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#include<string.h>
using namespace std;


int main(){
	char a[110], b[110], c[110];
	scanf("%s",a);
	scanf("%s",b);
	scanf("%s",c);
	int lena=strlen(a), lenb=strlen(b), lenc=strlen(c);
	int cura=0, curb=0, curc=0, end=0, now=0;
	while(end==0){
		if(now==0){
			if(cura>=lena){
				end=1;
				break;
			}
			if(a[cura]=='a')
				now=0;
			else if(a[cura]=='b')
				now=1;
			else
				now=2;
			cura++;
		}
		else if(now==1){
			if(curb>=lenb){
				end=2;
				break;
			}
			if(b[curb]=='a')
				now=0;
			else if(b[curb]=='b')
				now=1;
			else
				now=2;
			curb++;
		}
		else{
			if(curc>=lenc){
				end=3;
				break;
			}
			if(c[curc]=='a')
				now=0;
			else if(c[curc]=='b')
				now=1;
			else
				now=2;
			curc++;
		}
	}
	if(end==1)
		printf("A");
	else if(end==2)
		printf("B");
	else
		printf("C");
	return 0;
}

Measured memory_bytes: 128