akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int d[101][101];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m,s,a,b;
	while(cin >> n >> m >> s >> a >> b,n){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i==j)d[i][j]=0;
				else d[i][j]=1e8;
			}
		}
		s--; a--; b--;
		while(m--){
			int x,y,z; cin >> x >> y >> z;
			x--; y--;
			d[x][y]=z;
		}
		for(int k=0;k<n;k++){
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
				}
			}
		}
		int res=1e9;
		for(int i=0;i<n;i++){
			res=min(res,d[s][i]+d[i][a]+d[i][b]);
		}
		printf("%d\n",res);
	}
}


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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

vector<char> boin = {'a','i','u','e','o'};
vector<char> alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

int main(){
    int M,D,m,d;
    cin >> M >> D >> m >> d;
    if(M != m)cout << 1 << endl;
    else cout << 0 << endl;
    //cin >> M;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する


int main() {
    string s;
    cin >> s;
    for(int i = 0; i < 12; i++){
        cout << s[i];
        if(i == 3) cout << " ";
    }
    cout << endl;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    int h[n];
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    int a[m], b[m];
    vector<vector<int>> r(n);
    for(int i=0;i<m;i++){
        cin >> a[i] >> b[i];
        r[a[i]-1].push_back(b[i]-1);
        r[b[i]-1].push_back(a[i]-1);
    }

    int anss[n] = {};
    for(int i=0;i<n;i++){
        if(r[i].empty()){
            anss[i]++;
        }else{
            for(int j=0;j<(int)r[i].size();j++){
                if(h[i] <= h[r[i][j]]){
                    anss[i] = 0;
                    break;
                }
                anss[i]++;
            }
        }
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        if(anss[i]){
            ans++;
        }
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 9856
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){	
			int a = sc.nextInt();
			String op =sc.next();
			int b = sc.nextInt();
			if("?".equals(op)) break;
			if("+".equals(op)){
				int x = a+b;
				System.out.println(x);
			}else if("-".equals(op)){
					int x = a-b;
					System.out.println(x);
					}else if("*".equals(op)){
						int x = a*b;
						System.out.println(x);
					}else if("/".equals(op)){
							int x = a/b;
							System.out.println(x);
			}
		}
	}	
}

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

namespace abc103_d
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int[] first = new int[x[1]]; int[] second = new int[x[1]];
			for (int i = 0; i < x[1]; i++)
			{
				int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
				first[i] = a[0]; second[i] = a[1] - 1;
			}
			int ret = 0;
			Array.Sort(second, first);
			while (first.Length != 0)
			{
				ret++;
				List<int> a = first.ToList(); List<int> b = second.ToList();
				int time = b[0];
				for (int i = 0; i < a.Count; i++)
				{
					if (a[i] <= time)
					{
						a.RemoveAt(i); b.RemoveAt(i);
						i--;
					}
				}
				first = a.ToArray(); second = b.ToArray();
			}
			Console.WriteLine(ret);
		}
	}
}

Measured memory_bytes: 35892
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String N;
		int K;

		N = sc.next();
		K = Integer.parseInt(sc.next());

		int D[] = new int[K];

		for(int i = 0; i < K; i++){
			D[i] = Integer.parseInt(sc.next());
		}

		while(distinct(N, D, K)){
			int n = Integer.parseInt(N);
			n++;
			N = String.valueOf(n);
		}

		System.out.println(N);
	}

	public static boolean distinct(String S, int D[], int K){
		for(int i = 0; i < S.length(); i++){
			int s = Character.getNumericValue(S.charAt(i));
			for(int j = 0; j < K; j++){
				if(s == D[j]){
					return true;
				}
			}
		}
		return false;
	}
}


Measured memory_bytes: 14544
#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;
    cin >> n;
    double sum = 0;
    rep(i,n){
        double a;
        cin >> a;
        sum += 1/a;
    }
    printf("%.10f", 1/sum);
}

Measured memory_bytes: 3752
N,M,C=map(int,input().split())
B = list(map(int, input().split()))
A=[list(map(int,input().split())) for i in range(N)]
ans=0
for i in range(N):
  Sum=0
  for n in range(M):
    Sum+=A[i][n]*B[n]
  if Sum+C>0:
    ans+=1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int n,num,a,b,c,d,mi,cou;
int wf[100][100];
const int INF=1e9;
int main(){
    for(;;){
        cin>>n>>num;
        if(n==0&&num==0)break;
        fill(wf[0],wf[0]+100*100,INF);
        for(int i=0;i<n;i++)wf[i][i]=0;
        for(int i=0;i<num;i++){
            cin>>d;
            if(d){
                cin>>a>>b>>c;
                a--,b--;
                wf[a][b]=min(wf[a][b],c);
                wf[b][a]=min(wf[b][a],c);
                for(int i=0;i<n;i++){
                    for(int j=0;j<n;j++){
                        int v1=wf[i][a]+wf[a][b]+wf[b][j];
                        int v2=wf[i][b]+wf[b][a]+wf[a][j];
                        wf[i][j]=min(wf[i][j],min(v1,v2));
                    }
                }
            }
            else {
                cin>>a>>b;
                a--,b--;
                if(wf[a][b]==INF)cout<<"-1"<<endl;
                else cout<<wf[a][b]<<endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;

int main() {
  string s, t;
  cin >> s;
  cin >> t;

  ll a, b;
  scanf("%lld %lld", &a, &b);

  string u;
  cin >> u;

  if (u == s) {
    a--;
  }
  if (u == t) {
    b--;
  }
  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
 
using namespace std;
 
long N, W;
long w[110], v[110];
long dp[110][100100];

int main()
{
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> w[i] >> v[i];
    // initialize
    for (int j = 0; j <= W; ++j) dp[0][j] = 0;
    // dp
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= W; ++j){
            if (j >= w[i]) dp[i+1][j] = max(dp[i][j-w[i]] + v[i], dp[i][j]);
            else dp[i+1][j] = dp[i][j];
        }
    }
    
    cout << dp[N][W] << endl;
    
    return 0;
}


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

#define int long long

int a[10010];

signed main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
//	int t;
//	cin >> t;
//	while(t--){
		int n;
		cin >> n;
		for(int i=1;i<=sqrt(n);i++){
			for(int j=1;j<=sqrt(n);j++){
				for(int k=1;k<=sqrt(n);k++){
					int num=i*i + j*j + k*k + i*j + j*k + i*k;
					if(num<=n){
						a[num]++;
					}
				}
			}
		}
		for(int i=1;i<=n;i++){
			cout << a[i] << endl;
		}
//	}
}


Measured memory_bytes: 3680
N = int(input())
taro = 0
hanako = 0
for n in range(N):
    t_str, h_str = map(str, input().split())
    if t_str == h_str:
        taro += 1
        hanako += 1
    else:
        min_len = min(len(t_str), len(h_str))
        for l in range(min_len):
            if t_str[l] < h_str[l]:
                hanako += 3
                break
            elif t_str[l] > h_str[l]:
                taro += 3
                break
            if l == min_len - 1:
                if len(t_str) < len(h_str):
                    hanako += 3
                    break
                else:
                    taro += 3
                    break
print("{} {}".format(taro, hanako))



Measured memory_bytes: 5596
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int n,k;
    cin >> n >> k;
    int cnt = 1;
    while(n/=k){
        cnt++;
    }
    cout << cnt;
    return 0;
}

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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll n,m;
const ll SIZE = 1e5+10;
ll l[SIZE],r[SIZE];

int main(){
    ll lef = 0, rig = LL_INF;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> l[i] >> r[i];
        lef = max(l[i],lef);
        rig = min(r[i],rig);
    }

    ll ans = rig-lef;
    if(ans < 0) ans = 0;
    else    ans++;
    cout << ans << endl;
}

Measured memory_bytes: 1792
# -*- config: utf-8 -*-
if __name__ == '__main__':
	for i in range(int(raw_input())):
		nums = map(lambda x:x**2,map(int,raw_input().split()))
		flg = False
		for i in range(3):
			s = int(0)
			for j in range(3):
				if i == j :
					continue
				s += nums[j]
			if s == nums[i] :
				flg = True

		if flg == True :
			print "YES"
		else :
			print "NO"

Measured memory_bytes: 4232
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        for(int i=1;;i++){
            int x = sc.nextInt();
            if(x == 0){
                break;
            }
            System.out.printf("Case %d: %d\n",i,x);
        }
    }
}



Measured memory_bytes: 68812
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
typedef long long ll;
const ll INF = 1e18L + 1;

int main()
{
  string s;
  cin >> s;

  int pos = s.length() - 1;
  ll ans = 0;

  for (int i = 0; i < (1 << pos); i++)
  {
    ll target = stol(s);
    int temp = 0;
    int digits = 0;
    for (int j = 0; j < pos; j++)
    {
      digits++;
      if (i & (1 << j))
      {
        int divisor = pow(10, digits);
        ans += (target % divisor);
        target /= divisor;
        digits = 0;
      }
    }
    ans += target;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define all(a) a.begin(),a.end()
typedef pair<int,int> P;
constexpr long long mod=1000000007;
constexpr long long inf=1ll<<61;
struct segtree{
  vector<int>node,lazy;
  int n;
  void init(int N){
    n=1;
    while(n<N)n*=2;
    node.resize(n*2);
    lazy.resize(n*2);
  }
  void eval(int k,int l,int r){
    if(!lazy[k])return;
    node[k]+=lazy[k]*(r-l);
    if(k<n-1){
      lazy[2*k+1]+=lazy[k];
      lazy[2*k+2]+=lazy[k];
    }
    lazy[k]=0;
  }
  void update(int a,int b,int x,int k,int l,int r){
    eval(k,l,r);
    if(r<=a||b<=l)return;
    if(a<=l&&r<=b){
      lazy[k]=x;
      eval(k,l,r);return;
    }
    update(a,b,x,k*2+1,l,(l+r)/2);
    update(a,b,x,k*2+2,(l+r)/2,r);
    node[k]=node[k*2+1]+node[k*2+2];
  }
  int calc(int a,int b,int k,int l,int r){
    eval(k,l,r);
    if(r<=a||b<=l)return 0;
    if(a<=l&&r<=b)return node[k];
    int vl=calc(a,b,k*2+1,l,(l+r)/2);
    int vr=calc(a,b,k*2+2,(l+r)/2,r);
    return vl+vr;
  }
  void add(int a,int b,int x){
    update(a,b,x,0,0,n);
  }
  int getsum(int a,int b){
    return calc(a,b,0,0,n);
  }
};

vector<P>seg[100006];
int ans[100006];
segtree S;
signed main(){
  int n,m;cin>>n>>m;
  rep(i,n){
    int l,r;cin>>l>>r;
    seg[r-l+1].push_back(P(l,r));
  }
  int unused=n;
  S.init(m+1);
  for(int i=1;i<=m;i++){
    ans[i]+=unused;
    unused-=seg[i].size();
    for(int j=i;j<=m;j+=i){
      ans[i]+=S.getsum(j,j+1);
    }
    for(auto e:seg[i]){
      S.add(e.first,e.second+1,1);
    }
  }
  rep(i,m)cout<<ans[i+1]<<endl;
}

Measured memory_bytes: 17688
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}



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

    ll N, K, L; cin >> N >> K >> L;
    vi a(N); REP(i, N) cin >> a[i];

    auto check = [&](int x) {
        // K番目がx以下になる区間がL個以上存在するか?
        int r = 0, cnt = 0;
        ll sum = 0;
        REP(l, N) {
            while (r < N and cnt < K) {
                if (a[r] <= x) ++cnt;
                ++r;
            }
            if (cnt >= K) {
                sum += r - l - 1;
            } else {
                sum += r - l;
            }
            if (a[l] <= x) --cnt;
        }
        return N * (N + 1) / 2 - sum >= L;
    };

    int l = -1, r = N;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        (check(mid) ? r : l) = mid;
    }
    cout << r << endl;

    return 0;
}



Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int K = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int count = 0;

		for (int i = a; i <= b; i++) {
			if (i % K == 0) {
				count++;
			}
		}

		if (count > 0) {
			System.out.println("OK");
		} else {
			System.out.println("NG");
		}

	}

}

Measured memory_bytes: 35760
#include <iostream>

using namespace std;

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

	if (a < b) cout << "a < b" << endl;
	else if (a > b) cout << "a > b" << endl;
	else if (a == b) cout << "a == b" << endl;
	return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
string ABCD;
cin >> ABCD;

for (int i = 0; i < 8; ++i) {
int res = 0;
        for (int j = 0; j < 3; ++j) {
                if ((i >> j) & 1) {
                        res += ABCD[3-j] - '0';
                } else {
                        res -= ABCD[3-j] - '0';
                }   
        }   
                res += ABCD[0] - '0';
        string s = ""; 
        if (res == 7) {
                for (int j = 0; j < 3; ++j) {
                        if ((i >> (2 - j)) & 1) {
                                s += ABCD[j];
                                s += '+';
                        } else {
                                s += ABCD[j];
                                s += '-';
                        }   
                }   
                s += ABCD[3];
                cout << s << "=7" << endl;
                break;
        }   
}
}

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

using namespace std;

#define rep(i, a, n) for (int i = a, _n = n; i <= _n; ++i)
#define drep(i, a, n) for (int i = a, _n = n; i >= _n; --i)
#define erep(i, u) for (int i = first[u]; i; i = edge[i].nxt)
#define debug(x) cout << #x << " = " << x << endl

#define N 100005

int n, m;

int dp[N][3];

int first[N], num;
struct Edge {
	int v, nxt;
} edge[N];

void Add_Edge (int u, int v) {
	++num;
	edge[num].v = v;
	edge[num].nxt = first[u];
	first[u] = num;
}

struct node {
	int u, now;
};

queue<node> Q;

int main () {
	memset(dp, -1, sizeof dp);
	scanf ("%d%d", &n, &m);

	rep(i, 1, m) {
		int u, v;
		scanf ("%d%d", &u, &v);
		Add_Edge(u, v);
	}

	int s, t;
	scanf ("%d%d", &s, &t);

	dp[s][0] = 0;
	Q.push((node) { s, 0});

	while (!Q.empty()) {
		node now = Q.front();
		Q.pop();
		int& u = now.u, x = now.now;
		erep(i, u) {
			Edge& e = edge[i];
			if (dp[e.v][(x + 1) % 3] == -1) {
				dp[e.v][(x + 1) % 3] = dp[u][x] + 1;
				if (e.v == t && (x + 1) % 3 == 0) {
					printf ("%d\n", dp[e.v][(x + 1) % 3] / 3);
					return 0;
				}
				Q.push((node) { e.v, (x + 1) % 3});
			}
		}
	}

	puts("-1");

	return 0;
}


Measured memory_bytes: 2816
N = int(input())
d = {}
for n in range(N):
    c, v = input().split()
    v = int(v)
    if c in  d:
        d[c] = d[c]+[(v, n+1)]
    else:
        d[c] = [(v, n+1)]
d = sorted(d.items())
for c in d:
    for v in sorted(c[1], reverse=True):
        print(v[1])

Measured memory_bytes: 3064
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
char s[SIZE];
int main(){
    RS(s);
    int K; R(K);
    int n=LEN(s);
    vector<pair<char,int>>AA;
    for(int i=0,j;i<n;i=j){
        for(j=i;s[j]==s[i];j++);
        AA.PB(MP(s[i],j-i));
    }
    if(SZ(AA)==1){
        W((LL)n*K/2);
    }
    else if(AA[0].F==AA.back().F){
        LL an=0;
        REP(i,SZ(AA)){
            if(!i||i==SZ(AA)-1){
                an+=AA[i].S/2;
            }
            else an+=AA[i].S/2LL*K;
        }
        an+=(AA[0].S+AA.back().S)/2LL*(K-1);
        W(an);
    }
    else{
        LL an=0;
        REP(i,SZ(AA)){
            an+=AA[i].S/2LL*K;
        }
        W(an);
    }
    return 0;
}


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

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);


int main()
{
    int i = 0, j = 0, cs = 0, in;
    string s; cin>>s;
    if(s.back() == 's') s += "es";
    else s += "s";
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3624
S = input()
T = input()
S_a = [0]*(len(S)+1)
S_b = [0]*(len(S)+1)
T_a = [0]*(len(T)+1)
T_b = [0]*(len(T)+1)
for i, s in enumerate(S):
    if s == 'A':
        S_a[i+1] = S_a[i]+1
        S_b[i+1] = S_b[i]
    else:
        S_a[i+1] = S_a[i]
        S_b[i+1] = S_b[i]+1
        
for i, T in enumerate(T):
    if T == 'A':
        T_a[i+1] = T_a[i]+1
        T_b[i+1] = T_b[i]
    else:
        T_a[i+1] = T_a[i]
        T_b[i+1] = T_b[i]+1
q = int(input())
for _ in range(q):
    a, b, c, d = map(int, input().split())
    s_a = S_a[b]-S_a[a-1]
    s_b = S_b[b]-S_b[a-1]
    t_a = T_a[d]-T_a[c-1]
    t_b = T_b[d]-T_b[c-1]
    if ((t_a-t_b)%3) == ((s_a-s_b)%3):
        print('YES')
    else:
        print('NO')
        

Measured memory_bytes: 57856
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */

/* function */

/* main */
int main() {

    string S, T;
    cin >> S >> T;
    S += S;
    
    for (int i = 0; i < S.size() - T.size(); i++) {

        bool can = false;
        if(S.substr(i, T.size())==T){
            can = true;
        }
        if (can) {
            cout << "Yes" << '\n';
            return 0;
        }
    }
    cout << "No" << '\n';

}



Measured memory_bytes: 3228
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

void solution() {
}

int main() {
  int n, a, b;
  std::cin >> n >> a >> b;
  std::cout << std::min(a, b) << " " << std::max((a+b) - n, 0) << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const char newl = 10;
const string sep = "\n_____\n";
const ll MOD = 1000000007; // 998244353
const int maxN = 1000005;
const double PI = atan(1.0)*4;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void run(){
   int n, m;
   cin >> n >> m;
   vector<int> a(m);
   int sum = 0;
   for (int i = 0; i < m; i++) {
      cin >> a[i];
      sum += a[i];
   }
   if (sum > n) cout << -1;
   else cout << n - sum;
}
int main(){
   ios_base::sync_with_stdio(0);cin.tie(0);
   cout.tie(0);
   // stress(); return 0;
   int t = 1;
   // cin >> t;
   for (int tc = 1; tc <= t; tc++) {
      // cout << "Case #" << tc << ": ";
      run();
      cout << newl;
   }
   return 0;
}

Measured memory_bytes: 3688
program main
   implicit none
   character a
   read(*,*)a
   if(a=="A")then
      write(*,*)"T"
   endif
   if(a=="T")then
      write(*,*)"A"
   endif
   if(a=="C")then
      write(*,*)"G"
   endif
   if(a=="G")then 
      write(*,*)"C"
   endif
end program main


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   
   ll n;
	cin>>n;
	if(n>=30)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
  
}

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

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

    for(ll i=a; i<=a*b; i+=a){
        if (i % b == c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 3600
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
 
#define int long long
typedef pair<int, int> P;
 
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
 
/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/
 
#include "bits/stdc++.h"
using namespace std;
 
#define int long long
 
//セグ木を用いたRMQ
const int MAX_N = 420000;
 
struct RMQ {
    int n, dat[2 * MAX_N - 1];
 
    void init(int n_) {
        n = 1;
        while (n < n_) n *= 2;
        for (int i = 0; i < 2 * n - 1; i++) dat[i] = LLONG_MAX;
    }
 
    void update(int k, int a) {
        k += n - 1;
        dat[k] = a;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
 
    int query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return LLONG_MAX;
        if (a <= l && r <= b) return dat[k];
        else {
            int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
};
 
typedef pair<int, P> seg;
RMQ rmq0, rmq1;
int N;
int p[220000], ap[220000];
 
// [l, r)
seg getSeg(int l, int r) {
    int pri;
    if (l % 2 == 0) pri = rmq0.query(l, r, 0, 0, rmq0.n);
    else  pri = rmq1.query(l, r, 0, 0, rmq1.n);
    return seg(pri, P(l, r));
}
 
signed main() {
    cin >> N;
    rmq0.init(N + 10), rmq1.init(N + 10);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
        ap[p[i]] = i;
        if (i % 2 == 0) rmq0.update(i, p[i]);
        else rmq1.update(i, p[i]);
    }
    priority_queue<seg, vector<seg>, greater<seg>> pq;
    pq.push(getSeg(0, N));
    for (int i = 0; i < N / 2; i++) {
        seg cur = pq.top(); pq.pop();
        int l = cur.second.first, r = cur.second.second;
        int mid = ap[cur.first];
        cout << cur.first << " ";
        if (l != mid) pq.push(getSeg(l, mid));
        int pri;
        if ((mid + 1) % 2 == 0) pri = rmq0.query(mid + 1, r, 0, 0, rmq0.n);
        else  pri = rmq1.query(mid + 1, r, 0, 0, rmq1.n);
        cout << pri << " ";
        int nid = ap[pri];
        if (mid + 1 != nid)pq.push(getSeg(mid + 1, nid));
        if (nid + 1 != r)pq.push(getSeg(nid + 1, r));
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 16756
from collections import deque
from operator import itemgetter
def main():
    n = int(input())
    robots = []
    for _ in range(n):
        x, l = map(int, input().split())
        lside = x - l
        rside = x + l
        robots.append((lside, rside))
    # ロボットの腕の右端を基準にして昇順ソート。
    robots = sorted(robots, key=itemgetter(1))
    robots = deque(robots)
    a_robot = robots.popleft()
    cnt = n
    while robots:
        robot_next = robots.popleft()
        if a_robot[1] > robot_next[0]:
            cnt -= 1
        else:
            a_robot = robot_next
            continue
    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 19372
n = int(input())
a = list(map(int, input().split()))

print(" ".join(map(str, a)))
for i in range(1, n):
  v = a[i]
  j = i - 1
  while j >= 0 and a[j] > v:
    a[j+1] = a[j]
    j -= 1
  a[j+1] = v
  print(" ".join(map(str, a)))



Measured memory_bytes: 5596
n = int(input())
ans = 0

def judge_divisor(n):
    if n%2==0:
        return False
    count = 0
    for i in range(1,n+1):
        if n%i == 0:
            count+=1
    if count == 8:
        return True
    else:
        return False

for number in range(1,n+1):
    if judge_divisor(number):
        ans += 1

print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int a[220000];
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
     int maxa=-9999999999;
     int maxq=a[0];
     for(int i=1;i<n;i++)
     {

        maxa=max(maxa,a[i]-maxq);
        maxq=min(maxq,a[i]);
     }
     cout<<maxa<<endl;
     return 0;
}

Measured memory_bytes: 3864
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  bool ans = (a + b + c) % 2 == 0 && (a + b + c) / 2 == max({ a,b,c });
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
    #include <string>
    #include <vector>
    #include <algorithm>
    #include <map>
    using namespace std;
    typedef long long ll;
    #define rep(i,n) for (int i=0;i < (int)(n);i++)

    int main(){
      string s;
      cin >> s;
      int one=0,zero=0;
      bool f=true;
      if (s[0] != '1') {
        f=false;
        zero++;
      }
      else one++;
      int ans=0;
      for(int i=1;i < s.size();i++){
        if (s[i] == '1' && f) one++;
        else if (s[i] == '1' && !f ){
          zero--;
          ans+=2;
          if (zero == 0) {
            i++;
            if (s[i] == '1') {
              f=true;
              one=1;
            }
            else {
              f=false;
              zero = 1;
            }
          }
        }
        else if (s[i] == '0'  && f) {
          one--;
          ans+=2;
          if (one == 0){ 
            i++;
            if (s[i] == '1') {
              f=true;
              one=1;
            }
            else {
              f=false;
              zero = 1;
            }
          }
        }
        else zero++;
      }
      cout << ans << endl;

      
      return 0;
    }
      
      

Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	weight := []int{512, 256, 128, 64, 32, 16, 8, 4, 2, 1}

	for sc.Scan() {
		var wgt []int
		i, _ := strconv.Atoi(sc.Text())

		if i > 1023 {
			i = 1023
		}

		bin := fmt.Sprintf("%010b", i)

		for i := 9; i >= 0; i-- {
			if bin[i] == '1' {
				wgt = append(wgt, weight[i])
			}
		}

		for i := 0; i < len(wgt); i++ {
			if i == len(wgt)-1 {
				fmt.Printf("%d\n", wgt[i])
			} else {
				fmt.Printf("%d ", wgt[i])
			}

		}
	}

}



Measured memory_bytes: 1068
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

auto comb=make_vec<ll>(51,51);
ll c(int i,int j) {
    if(comb[i][j]!=-1) return comb[i][j];
    if(j==0 || j==i) return comb[i][j]=1;
    return comb[i][j]=c(i-1,j-1)+c(i-1,j);
}

int main() {
    rep(i,51) rep(j,51) comb[i][j]=-1;
    int n,a,b;
    cin>>n>>a>>b;
    vector<double> vec(n);
    rep(i,n) cin>>vec[i];
    sort(all(vec),greater<double>());
    
    double ave=0;
    rep(i,a) ave+=vec[i];
    ave/=a;
    cout<<fixed<<setprecision(10)<<ave<<endl;
    
    if(vec[0]==vec[a-1]) {
        int pos=a-1;
        while(pos+1<n && vec[pos+1]==vec[0]) pos++;
        ll ans=0;
        FOR(i,a,min(b,pos+1)) ans+=c(pos+1,i);
        cout<<ans<<endl;
    }
    else {
        int l=a-1,r=l-1;
        while(l-1>=0 && vec[l-1]==vec[a-1]) l--;
        while(r+1<n && vec[r+1]==vec[a-1]) r++;
        cout<<c(r-l+1,a-l)<<endl;
    }
}


Measured memory_bytes: 256
/**
 *   created: 28 April 2019  23:46:46
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) (c).begin,(c).end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
// #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================
vector< vi  > adj;
vi vis;
void dfs(int node){
	// trace1(node);
	vis[node]=1;
	for(int x:adj[node]){
		if(!vis[x])
			dfs(x);
	}
}
int main()
{
	optimizeIO();
	int tt=1;
	// cin>>tt;
	while(tt--){
		int n,m;
		cin>>n>>m;
		adj.resize(n+1);
		while(m--){
			int a,b,c;
			cin>>a>>b>>c;
			adj[a].push_back(b);
			adj[b].push_back(a);
		}
		vis.resize(n+1,0);
		// cout<<"re"<<endl;
		int comp=0;
		rep(i,1,n+1){
			if(!vis[i]){
				// trace1(i);
				dfs(i);
				comp++;
			}
		}
		cout<<comp;
	}
	return 0;
}





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

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    int a,b,c;
    cin>>a>>b>>c;
    int sum = a+b+c;
    if(sum>=22){
        cout << "bust\n";
    }
    else cout << "win" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
     
#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll int
#define ld long double
     
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
     
#define infi INT_MAX
#define infl LONG_LONG_MAX
#define infd LDBL_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second
#define G(a,b) get<a>(b)
#define MP make_pair
#define MT make_tuple
#define pll pair<ll,ll> 
#define endl "\n"
#define ALL(v) v.begin(),v.end()
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;
#define deb printf("***************************************************************************************\n");
#define moshi printf("moshi moshi ! \n");
#define hi printf("hi ! \n");
#define bye printf("bye bye ! \n");
#define o_set(ll) tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define number_of_set_bits  __builtin_popcountll  
const ld PI=3.1415926535897932384626433; 

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }     
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const ll N=1e6+6,NN=2e5+5;
ll arr[NN];
vll factors[N];
ll cnt[N];

void func()
{ 
  ll n;
  cin>>n;

  f(i,1,n+1) 
  {
    cin>>arr[i];
    cnt[arr[i]]++;
  }

  f(i,1,N)
  {
    ll j=i;
    while(j<N) 
    {
      factors[j].pb(i);
      j+=i;
    }
  }
  
  ll ans=0;
  if(cnt[1]>0) 
  {
    if(cnt[1]==1) ans=1;
    pr(ans) nl
    return;
  }

  f(i,1,n+1)
  {
     bool flag=1; 
     for(auto j:factors[arr[i]]) 
     {
       if(j==arr[i] && cnt[j]>1) 
       {
         flag=0;
         break;
       }
       
       else if(j!=arr[i] && cnt[j]>0)
       {
        flag=0;
        break;
       }

     }

     if(flag) ans++;
  }

  pr(ans) nl
}   

     
     
int main() 
{
    fast

    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE*/
        
     
    ll ntc=1;
    //cin>>ntc;
     
    f(i,1,ntc+1)
    {
      //cout<<"Case #"<<i<<": ";
      func();
    }     
    return 0;
}

Measured memory_bytes: 189112
import java.util.Scanner;

public class Main{
		
	public static void main(String args[]){
		  
	    Scanner sc = new Scanner(System.in);
	    
	    int a = sc.nextInt();
	    int b = sc.nextInt();
	    
	    if(a == 1) {
	    	a+= 13;
	    }
	    if(b == 1) {
	    	b+= 13;
	    }
	    
	    if(a > b) {
	    	System.out.println("Alice");
	    }else if(a < b) {
	    	System.out.println("Bob");
	    }else {
	    	System.out.println("Draw");
	    }
	}
}

Measured memory_bytes: 21844
def main():
    N = int(input())
    i = 1
    sm = 1
    while sm < N:
        i += 1 
        sm += i

    a = [i]
    n = N - i
    i -= 1
    while n != 0:
        if n - i >= 0:
            n = n - i
            a.append(i)
        i -= 1
    # print(a)
    for i in a:
        print(i)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3444
using System;
using System.Collections.Generic;

namespace Volume0_0003
{
    class Program
    {
        static void Main(string[] args)
        {
            int len = Convert.ToInt32(Console.ReadLine());

            for(int i = 0; i < len; i++)
            {
                var list = new List<int>(3);
                String[] inputs = Console.ReadLine().Split(' ');
                
                list.Add(Convert.ToInt32(inputs[0]));
                list.Add(Convert.ToInt32(inputs[1]));
                list.Add(Convert.ToInt32(inputs[2]));

                list.Sort();

                if(list[0]*list[0] + list[1] * list[1] == list[2] * list[2])
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }
}

Measured memory_bytes: 5764
import math

n, k = map(int, input().split())

# for small
score = 0
times = []
for i in range(1, min(n + 1, k)):
    times.append(math.ceil(math.log2((k / i))))

if len(times):
    bottom_max = times[0]
    for t in times:
        score += 2 ** (bottom_max - t)
    score /= 2 ** (bottom_max) * n

# for big
big = [i for i in range(k, max(k, n + 1))]
score += len(big) / n
print('{:.10f}'.format(score))


Measured memory_bytes: 12904
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define int ll
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'
#define hyphen() cerr << "--\n"

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

#define fst first
#define pb push_back

const int MOD = (int)1e9 + 7;
const int INF = numeric_limits<int>::max();

signed main() {
    int N, H;

    cin >> N >> H;

    vector<int> As(N);
    vector<int> Bs(N);
    REP(i, N) {
        cin >> As.at(i) >> Bs.at(i);
    }

    // 一番良い刀(a)よりも投げてダメージを与えられるものがあれば、
    // 投げ続ける

    // 一番良い刀を極力振る

    // トドメは一番良い刀の投げ

    int best_katana_a = 0;
    int best_katana_b = 0;
    int best_katana_ind = 0;

    REP(i, N) {
        if (As.at(i) > best_katana_a) {
            best_katana_a = As.at(i);
            best_katana_b = Bs.at(i);
            best_katana_ind = i;
        } else if (As.at(i) == best_katana_a && Bs.at(i) < best_katana_b) {
            best_katana_a = As.at(i);
            best_katana_b = Bs.at(i);
            best_katana_ind = i;
        }
    }

    // 刀が残っているかどうか
    vector<bool> remain(N, true);

    // bの大きい順にソートしておこう
    vector<pair<int, int>> katana_for_throw;
    REP(i, N) {
        if (Bs.at(i) > best_katana_a && i != best_katana_ind) {
            pair<int,int> p = make_pair(Bs.at(i), i);
            katana_for_throw.pb(p);
        }
    }
    sort(REVALL(katana_for_throw));

    int ans = 0;

    for(auto p : katana_for_throw) {
        int b = p.first;

        H -= b;
        ans += 1;

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

    if (H > best_katana_b) {
        int cnt = (H - best_katana_b) / best_katana_a;
        H -= best_katana_a * cnt;
        ans += cnt;
    }

    // a + b もしくは b
    if (H > best_katana_b) {
        ans += 2;
    } else {
        ans += 1;
    }

    cout << ans << endl;
}


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

using vi=vector<int>;
using vvi=vector<vector<int>>;

int gcd(int a, int b){
  if(a<b) swap(a,b);
  while(a%b!=0){
    a=a%b;
    swap(a,b);
  }
  return b;
}

int main(){
  long a,b,c,d,e;cin>>a>>b>>c>>d;
  e=c*d/gcd(c,d);
  long anc=b/c-(a-1)/c;
  long ant=b/d-(a-1)/d;
  long ane=b/e-(a-1)/e;
  cout<<b-a+1-anc-ant+ane<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll h, w, n, x, y;
	vector<P> v;
	cin >> h >> w >> n;
	zep(i, 0, n){
		cin >> x >> y;
		v.push_back(P(y, x));
	}
	v.push_back(P(1, h+1)); n++;
	sort(v.begin(), v.end());
	
	ll ans = INF;
	ll sx = 1;
	ll sy = 1;
	ll t = 0;
	zep(i, 0, n){
		x = v[i].second;
		y = v[i].first;
		if(x-sx > y-sy){
			ans = min(x-1, ans);
		}
		if(x-sx == y-sy){
			sx = x;
			sy = y-1;
		}
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 6512