akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
    int h,w,n;
    cin>>h>>w>>n;
    int x,y;
    cin>>y>>x;
    string s,t;
    cin>>s>>t;
    string k="UDLR";
    
    int xx=x,yy=y;
    for(int i=0;i<n;i++){
        if(s[i]=='L') x--;
        if(x<=0){
            cout<<"NO"<<endl;
            return 0;
        }
        if(t[i]=='R') x=min(x+1,w);
        if(s[i]=='U') y--;
        if(y<=0){
            cout<<"NO"<<endl;
            return 0;
        }
        if(t[i]=='D') y=min(y+1,h);
    }
    x=xx,y=yy;
    for(int i=0;i<n;i++){
        if(s[i]=='R') x++;
        if(x>w){
            cout<<"NO"<<endl;
            return 0;
        }
        if(t[i]=='L') x=max(x-1,1);
        if(s[i]=='D') y++;
        if(y>h){
            cout<<"NO"<<endl;
            return 0;
        }
        if(t[i]=='U') y=max(y-1,1);
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
  ll N;
  cin >> N;
  Vll a(N);
  INPUT(a);
  REPx(x, a) if (x % 2) {cout << "first" << endl; return 0;}
  cout << "second" << endl;

  return 0;
}


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

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


int main(){
    // Your code here!
    int n;
    
    cin >> n;
    
    vector<int> a(n);
    
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    
    vector<int> left(n);
    left[0]=0;
    for (int i=1; i<n; i++) {
        int x = max(left[i-1],a[i-1]);
        int y = min(left[i-1],a[i-1]);
        left[i] = gcd(x,y);
    }
    
    
    vector<int> right(n);
    right[n-1]=0;
    for (int i=n-2; i>-1; i--) {
        //cout << i << endl;
        int x = max(right[i+1],a[i+1]);
        int y = min(right[i+1],a[i+1]);
        right[i] = gcd(x,y);
    }
    
    int ans = 0;
    for (int i=0; i<n; i++){
        ans=max(ans,gcd(left[i],right[i]));
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4188
#include<bits/stdc++.h>
using namespace std;
signed main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  long long a,b,c;
  cin>>a>>b>>c;
  if(a<b && b<c){
    cout<<"Yes"<<'\n';
  }
  else{
    cout<<"No"<<'\n';
  }
  return(0);
}



Measured memory_bytes: 3136
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    n = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    A = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    S = [0]
    for i in range(n):
        S.append(S[i]+A[i])
    ans = 0
    for i in range(n-1):
        ans += (( A[i] * (S[-1] - S[i+1])) % MOD)
    print(ans%MOD)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 31600
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static final int MAX = 100+24;
    private static int[] d=new int[MAX];
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        while(in.hasNext()) {
            int n=in.nextInt();
            for(int i=0;i<n;i++){
                d[i]=in.nextInt();
            }
            Arrays.sort(d,0,n);
            int answer=1;
            for(int i=1;i<n;i++){
                answer += d[i]!=d[i-1]?1:0;
            }
            out.println(answer);
            out.flush();
        }
        in.close();
        out.close();
    }

}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<string, int> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    m[s]++;
  }
  const string s[] = {"AC", "WA", "TLE", "RE"};
  for (auto& e : s) cout << e << " x " << m[e] << endl;
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    int sum = 1;
    rep(i, N)
    {
        if((sum+K)<(sum*2))
            sum+=K;
        else
            sum*=2;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
    double x1,y1,x2,y2,x3,y3,x4,y4;
    float ax,ay,bx,by;
   
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
    
      ax=x2-x1;
      ay=y2-y1;
      bx=x4-x3;
      by=y4-y3;
      if((ax*by)-(ay*bx)==0) printf("YES\n");
      else printf("NO\n");
    }
    return 0;
}



Measured memory_bytes: 2040
N,K = map(int,input().split())
A = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[0])
cnt = 0
i = 0
while i<N:
    a,b = A[i]
    if cnt+b<=K:
        cnt += b
    else:
        break
    i += 1
if cnt==K:
    print(A[i-1][0])
else:
    print(A[i][0])

Measured memory_bytes: 94460
from collections import defaultdict


def topological_sort(N, edges):
    def dfs(u):
        used[u] = True
        for v in edges[u]:
            if not used[v]:
                dfs(v)
        result.append(u)

    used = [False] * N
    result = []
    for i in range(N):
        if not used[i]:
            dfs(i)

    return result[::-1]


def main():
    N, M = map(int, input().split())
    edges = defaultdict(list)
    for _ in range(M):
        s, t = map(int, input().split())
        edges[s].append(t)

    ans = topological_sort(N, edges)
    print(*ans)


if __name__ == '__main__':
    main()

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

int main()
{
    int n,b,c,sum=0;
    string s;

    cin>>n;
    int arr[n];

    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    sum=0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(((arr[i]+arr[j])>arr[k]) && ((arr[i]<arr[j]) && (arr[j]<arr[k]))){
                    sum++;
                    //cout<<sum<<endl;
                }
            }
        }
    }


    cout<<sum<<endl;



    return 0;
}




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

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define fi first
#define se second
#define pb push_back
 
#define ll long long
#define pii pair<int, int>
//#define int ll
const int MOD = 1000000007;

int fac[524300], ifac[524300], inv[524300];

int gt(int k) {
	if(k < 0) return 1;
	return ifac[k];
}

int cnt(int n, int m) {
	return 1ll * fac[m] * gt(m-n) % MOD;
}

int ncr(int n, int k) {
	return 1ll * fac[n] * gt(k) % MOD * gt(n-k) % MOD;
}

int cnt2(int n, int m) {
	int ans = 0;
	rep(same, n+1) {
		int mult = (same%2) ? (MOD-1) : 1;
		int p = 1ll * ncr(n, same) * cnt(n-same, m-same) % MOD;
		ans = (ans + 1ll * mult * p) % MOD;
	}
	return ans;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    fac[0] = ifac[0] = fac[1] = ifac[1] = inv[0] = inv[1] = 1;
    iter(i, 2, 524290) {
    	inv[i]=1ll*(MOD-MOD/i)*inv[MOD%i]%MOD;
    	fac[i] = 1ll * fac[i-1] * i % MOD;
    	ifac[i] = 1ll * ifac[i-1] * inv[i] % MOD;
    }
    int n, m; cin >> n >> m;
    cout << 1ll * cnt(n, m) * cnt2(n, m) % MOD << endl;
}



Measured memory_bytes: 9768
n,m = map(int, input().split())

MOD = 10**9+7
NUM = 10**6
g1 = [1, 1]
g2 = [1, 1]
inv = [0, 1]

for i in range( 2, NUM + 1 ):
    g1.append( ( g1[-1] * i ) % MOD )
    inv.append( ( -inv[MOD % i] * (MOD//i) ) % MOD )
    g2.append( (g2[-1] * inv[-1]) % MOD )

def comb(n, r, mod=MOD):
    if r<0 or r>n:
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

def perm(n,r,mod=MOD):
    if r<0 or n<r or n<0:
        return 0
    return (g1[n] * g2[n-r]) % mod

ans = perm(m,n)**2
sub=0

for k in range(1,n+1):
    cnt = comb(n,k)*perm(m-k,n-k) % MOD
    if k%2==1:
        sub+=cnt
    else:
        sub-=cnt

sub*=perm(m,n)%MOD
ans-=sub
print(ans%MOD)

Measured memory_bytes: 213052
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();

        int n = sc.nextInt();
        var x = new int[n];
        var y = new int[n];
        for (int i = 0; i < n; i++)
        {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }

        double ans = 0;

        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                if (i == j) continue;
                ans += Distance(x[i], y[i], x[j], y[j]);
            }
        }

        Console.WriteLine(ans / n);
    }

    static double Distance(int x1, int y1, int x2, int y2)
    {
        return Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int i = 0;
		while (i < 1000) {
			String line = sc.nextLine();
			String[] array = line.split(" ");
			int H = Integer.parseInt(array[0]);
			int W = Integer.parseInt(array[1]);

			if (W == 0 && H == 0) {
				break;

			} else {

				for (int k = 0; k < H; k++) {

					for (int j = 0; j < W; j++) {
						System.out.print("#");
					}
					System.out.println();
				}
				System.out.println();
			}
		}

	}

}

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

int main(void)
{
	int n, an[100];
	int cnt = 0;

	cin >> n;

	for(int i = 0; i < n; i++)
		cin >> an[i];

	for(int i = 0; i <= n - 2; i++) {
		for(int j = n - 1; j - 1 >= i; j--) {
			if(an[j - 1] > an[j]) {
				int tmp = an[j - 1];
				an[j - 1] = an[j];
				an[j] = tmp;
				cnt++;
			}
		}
	}

	for(int i = 0; i < n; i++)
		cout << an[i] << (i == n - 1 ? '\n' : ' ');
	cout << cnt << endl;

	return 0;
}

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

int main()
{
  int n,x;
  int cnt=0;
  cin >> n >> x;
  int dou[n];
  for(int i=0;i<n;i++) {
    cin >> dou[i];
    x-=dou[i];
    cnt++;
  }
  sort(dou,dou+n);
  if(x>=dou[0]) {
    cnt+=x/dou[0];
    cout << cnt;
  }
  else cout << cnt;
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;


int main() {
  int  n , l, r ;
  ll ans = 0LL ;
  scanf("%d", &n) ;

  for(int i = 0 ;i<n ; i++){
    scanf("%d %d", &l, &r) ;
    ans+=(r-l+1) ;
  }
  cout << ans << endl ;
	
  return 0 ;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}

};

int main() {
	int n, in;
	vi v;
	cin >> n;
	rep(i, n) {
		cin >> in;
		v.push_back(in);
	}
	map<int, int> mf, ms;
	rep(i, n) {
		if (i % 2==0) {
			if (mf.find(v[i]) == mf.end()) {
				mf[v[i]] = 1;
			}
			else mf[v[i]]++;
		}
		else {
			if (ms.find(v[i]) == ms.end()) {
				ms[v[i]] = 1;
			}
			else ms[v[i]]++;
		}
	}
	int maxf = 0, maxfit = 0, maxs = 0,maxsit = 0;
	int mxsf = 0, mxsfit = 0, mxss = 0, mxssit = 0;
	rep(i, n) {
		if (i % 2==0) {
			if (mf[v[i]] > maxf) {
				maxf = mf[v[i]];
				maxfit = v[i];
			}
		}
		else {
			if (ms[v[i]] > maxs) {
				maxs = ms[v[i]];
				maxsit = v[i];
			}
		}
	}
	mf[maxfit] = 0;
	ms[maxsit] = 0;
	rep(i, n) {
		if (i % 2==0) {
			if (mf[v[i]] > mxsf) {
				mxsf = mf[v[i]];
				mxsfit = v[i];
			}
		}
		else {
			if (ms[v[i]] > mxss) {
				mxss = ms[v[i]];
				mxssit = v[i];
			}
		}
	}
	if (maxfit != maxsit) {
		cout << n - (maxf + maxs) << endl;
	}
	else {
		int ans = min(n - (maxf + mxss), n - (mxsf + maxs));
		cout << ans << endl;
	}

}


Measured memory_bytes: 5368
S = input()
ans = 0
for s in range(len(S)):
    num = 0
    for e in S[s:]:
        if e =="A" or e=="T" or e=="G" or e=="C":
            num += 1
        else:
            ans = max(ans,num)
            break
    else:
        ans = max(ans,num)
print(ans)

Measured memory_bytes: 3060
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/
#define int ll

int cnt[51], pcnt[51];
int solve(int n, int x) {
	if(n==0)
		return (x==1);
	if(x == 1)
		return 0;
	if(x <= 1+cnt[n-1])
		return solve(n-1, x-1);
	if(x == 2+cnt[n-1])
		return pcnt[n-1]+1;
	if(x < cnt[n])
		return solve(n-1, x-cnt[n-1]-2)+1+pcnt[n-1];
	return pcnt[n];
}

signed main() {
	EmiliaMyWife

	int n, x;
	cin >> n >> x;
	pcnt[0] = cnt[0] = 1;
	for(int i = 1; i <= n; i++)
		pcnt[i] = pcnt[i-1]*2 + 1, cnt[i] = cnt[i-1]*2 + 3;
	cout << solve(n, x);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<ll> a(n), acc(n + 1, 0);
  rep(i, 0, n) {
    cin >> a[i];
    acc[i + 1] = acc[i] + a[i];
  }

  map<ll, ll> mp;
  rep(i, 0, n + 1) { mp[acc[i]]++; }

  ll ans = 0;
  for (auto m : mp) {
    if (m.second > 1) {
      ans += m.second * (m.second - 1) / 2;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 15872
L,R = (int(x) for x in input().split())
ModL = list(x%2019 for x in range(L,min(L+2019,R+1)))
if 0 in ModL:
    print('0')
else:
    MIN = 2019
    for I in range(0,len(ModL)-1):
        for II in range(I+1,len(ModL)):
            if (ModL[I]*ModL[II])%2019<MIN:
                MIN = (ModL[I]*ModL[II])%2019
    print(MIN)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

int main()
{
    int n;
    cin >> n;
    int *ac = new int[n];
    rep(i, n) ac[i] = 0;
    rep(i, n)
    {
        int a;
        cin >> a;
        ac[a - 1]++;
    }

    int *nt = new int[n + 1];
    rep(i, n + 1) nt[i] = 0;
    rep(i, n)
    {
        nt[ac[i]]++;
    }

    vector<pair<int,int>> list;
    int totalcount = 0;
    int pre = n;

    int *left = new int[n];

    for( int i = n; i > 0; i--)
    {
        totalcount += nt[i];
        left[i - 1] = pre - totalcount;
        pre = left[i - 1];
    }

    // k == 1
    cout << n << endl;
    for( int k = 2; k <= n; k++ )
    {
        int r = n / k;
        int l = 0;
        if( left[r] >= r * k )
        {
            cout << r << endl;
            continue;
        }

        while( l + 1 < r )
        {
            int m = (r + l) / 2;
            if( left[m] >= m * k )
            {
                l = m;
            }
            else
            {
                r = m;
            }
        }

        cout << l << endl;
    }

    delete nt;
    delete ac;
}

Measured memory_bytes: 6600
#include<stdio.h>

int main(void)
{
  int n = 0,m = 0,t[110],p = 0,x = 0,sum = 0;
  scanf("%d",&n);
  for(int i = 0;i<n;i++)
  {scanf("%d",&t[i]); sum += t[i];}
  
  scanf("%d",&m);
  for(int i = 0;i < m;i++)
  {
    scanf("%d%d",&p,&x);
    printf("%d\n",sum - t[p-1] + x);
  }
  return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		
		final int m = sc.nextInt();
		
		for(int i = 0; i < m; i++){
			final int money = sc.nextInt();
			final int year = sc.nextInt();
			final int kind = sc.nextInt();
		
			int max = Integer.MIN_VALUE;
			
			for(int j = 0; j < kind; j++){
				final int type = sc.nextInt();
				final double per = sc.nextDouble();
				final int tax = sc.nextInt();
				
				int mo = money;
				
				if(type == 0){
					int p = 0;
					
					for(int k = 0; k < year; k++){
						p += mo * per;
						mo -= tax;
					}
					
					mo += p;
				}else{
					
					for(int k = 0; k < year; k++){
						int p = (int)(mo * per);
						mo += p - tax;
					}
					
				}
				
				max = Math.max(max, mo);
			}
			
			System.out.println(max);
		}
		
	}

}

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

#define M 1000000007
#define pb emplace_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define mp(a, b) make_pair(a, b) 

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vec;
typedef vector<pll> vecp;
typedef map<ll, ll> mpll;

const long double PI  = 3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


void solve()
{
	ll n, m;
	cin>>n>>m;
	ll ans = n / m + (n%m>0?1:0);
	cout<<ans<<endl;
}


int main()
{
	ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
    	solve();
    }
    return 0;
}

Measured memory_bytes: 256
def point(A, Q):
    return sum(q[3] for q in Q if A[q[1]] - A[q[0]] == q[2])

def solve(A, n, Q, M):
    if n == len(A):
        return point(A, Q)

    ans = 0
    for i in range(A[n-1], M+1):
        A[n] = i
        ans = max(ans, solve(A, n+1, Q, M))
    
    return ans

def main():
    N, M, Q = map(int, input().split())
    kumi = []
    for i in range(Q):
        a, b, c, d = map(int, input().split())
        kumi.append((a, b, c, d))
    A = [1] * (N + 1)

    print(solve(A, 1, kumi, M))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9124
table= list(map(int,input().split()))
for i in range(2,0,-1):
    k=0
    while k < i :
        if table[k] > table[k+1] :
            table[k],table[k+1]=table[k+1],table[k]
        k+=1
print(table[0],table[1],table[2])


Measured memory_bytes: 5596
n , m , l = map(int , input().split())
k=int(input())
for a in range(k+1):
  for b in range(k+1):
    for c in range(k+1):
      a1 = (n*(2**a))
      b1 = (m*(2**b))
      c1 = (l*(2**c))
      if a+b+c <= k and a1 < b1 and b1 < c1:
        print("Yes")
        exit()
        
print('No')

Measured memory_bytes: 9096
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

long long euclid(long long a, long long b)
{
	if(b == 0)
	{
		return a;
	}
	else
	{
		return euclid(b, a % b);
	}
}

int main()
{
	int n;
	cin >> n;
	
	vector<long long> t(n);
	for(int i = 0; i < n; i++)
	{
		cin >> t[i];
	}
	
	long long ans = 0;
	for(int i = 0; i < n; i++)
	{
		long long tmp = t[i];
		if(i == 0)
		{
			ans = tmp;
		}
		else
		{
			long long euc = ans > tmp ? euclid(ans, tmp) : euclid(tmp, ans);
			ans = ans * (tmp / euc);
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
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();
		}
		sc.close();
		int high[]=new int[2];
		int highnum;
		high[0]=A[0];
		highnum=0;
		for(int j=1;j<N;j++) {
			if(high[0]<A[j]) {
				high[0]=A[j];
				highnum=j;
			}
		}
		if(high[0]!=A[0]) {
			high[1]=A[0];
		}else {
			high[1]=A[1];
		}
		for(int k=0;k<N;k++) {
			if(high[1]<A[k]&&highnum!=k) {
				high[1]=A[k];
			}
		}
		for(int l=0;l<N;l++) {
			if(l!=highnum) {
			System.out.println(high[0]);
			}else {
			System.out.println(high[1]);
			}
		}
	}
}

Measured memory_bytes: 108728
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    A, B, C = [int(x) for x in input().split()]
    K = int(input())

    cnt = 0

    while A >= B:
        cnt += 1
        B *= 2

    while B >= C:
        cnt += 1
        C *= 2

    if cnt <= K:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()



Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int main(){
 string N;
  cin>>N;
  string ans="No";
  for(int i=0;i<3;i++){
  if(N.at(i)=='7'){
  ans="Yes"; break;
   }
  
  } cout<<ans<<endl;
 


 return 0;
}

Measured memory_bytes: 3556
import math

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

# サイコロだけで勝つ確率
prob = max(0,(N-K+1)/N)
log_2_K = math.log2(K)

for dice in range(1,min(K,N+1)):
    prob += (1/N)*(1/2**(math.ceil(log_2_K - math.log2(dice))))

print(prob)

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

int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    int tmpA = a%b;
    if(tmpA == 0 && c != 0)
    {
        cout<<"NO"<<endl;
        return 0;
    }
    if(tmpA == 0 && c == 0)
    {
        cout<<"YES"<<endl;
        return 0;
        
    }
    for(int i = 1; i<= b; i++)
    {
        if(c == (tmpA * i)%b)
        {
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

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

const int Q = 200010;

int n, q;
string s;

vector<char> T(Q), D(Q);

bool isLeftFallen(int now){
    bool fall = false;
    for(int i = 0; i < q; i++){
        if(s[now] != T[i]) continue;
        
        if(D[i] == 'L') now--;
        else now++;
        
        if(now == -1){
            fall = true;
            break;
        }
        if(now == n){
            break;
        }
    }
    return fall;
}

bool isRightFallen(int now){
    bool fall = false;
    for(int i = 0; i < q; i++){
        if(s[now] != T[i]) continue;
        
        if(D[i] == 'L') now--;
        else now++;
        
        if(now == n){
            fall = true;
            break;
        }
        if(now == -1){
            break;
        }
    }
    return fall;
}

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

    cin >> n >> q;
    cin >> s;

    T.resize(q);
    D.resize(q);

    for(int i = 0; i < q; i++){
        cin >> T[i] >> D[i];
    }

    int l1 = -1, r1 = n;
    while(r1 - l1 > 1){
        int mid = (r1 + l1) / 2;
        if(isLeftFallen(mid)) l1 = mid;
        else r1 = mid;
    }

    int leftFallenIndex = r1;

    int l2 = -1, r2 = n;
    while(r2 - l2 > 1){
        int mid = (r2 + l2) / 2;
        if(isRightFallen(mid)) r2 = mid;
        else l2 = mid;
    }

    int rightFallenIndex = l2;

    cout << max(0, rightFallenIndex - leftFallenIndex + 1) << endl;

    return 0;
}

Measured memory_bytes: 1104
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#include <stdio.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};
 
string S;
int N;
int num[3];
 
signed main()
{
  cin >> S;
  N = S.length();
  REP(i,N) num[S[i]-'a']++;

  if (N == 1) {
    cout << "YES" << endl;
    return 0;
  }

  if (N == 4) {
    int two = 0;
    REP(i,3) {
      if (num[i] >= 2) two++;
    }
    if (two >= 2) {
      cout << "NO" << endl;
      return 0;
    }
  }

  if (N > 4) {
    REP(i,3) {
      if ((N + 2) / 3 < num[i]) {
        cout << "NO" << endl;
        return 0;
      }
    }
  } else {
    REP(i,3) {
      if (num[i] > N / 2) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> p(n),q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    vector<int> a(n);
    rep(i,n) a[i] += i+1;

    map<vector<int>,int> mp;
    int cnt = 0;
    do {
        mp[a] = cnt;
        cnt ++;
    } while (next_permutation(a.begin(),a.end()));
    cout << abs(mp[p] - mp[q]) << endl;
}


Measured memory_bytes: 5248
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	public static long mod = (long) (1e9+7);
	public static long[][][] dp;
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastReader sc = new FastReader();
		char[] s = sc.next().toCharArray();
		int n = s.length;
		int k = sc.nextInt();
		dp = new long[2][k+1][n+1];
		out.print(rec(0,0,1,k,s));
	    out.close();
	  }

	private static long rec(int i, int cnt, int last, int k, char[] s) {
		if(i == s.length) return cnt == k ? 1L : 0L;
		if(cnt > k) return 0L;
		if(dp[last][cnt][i] != 0) return dp[last][cnt][i];
		long ans = 0L;
		for(int dig=0;dig<=9;++dig) {
			if(last!=0 && dig > s[i]-'0') break;
			ans+=rec(i+1,cnt + (dig!=0 ? 1:0), (last!=0 && dig == (s[i]-'0'))?1:0,k,s);
		}
		return dp[last][cnt][i] = ans;
	}
	  
	}

Measured memory_bytes: 22612
while True:
  N=int(input())
  if N==0:
    break
  houseki=[]
  for i in range(N):
    a=list(map(int,input().split()))
    houseki.append(a)
  
  M=int(input())
  houkou=[]
  kyori=[]
  for i in range(M):
    d,l=map(str,input().split())
    houkou.append(d)
    kyori.append(int(l))
  
  x=10
  y=10
  get=0
  robo=[]
  for i in range(len(houkou)):
    if houkou[i]=="N":
      for j in range(kyori[i]):
        y+=1
        robo.append([x,y])
    elif houkou[i]=="E":
      for j in range(kyori[i]):
        x+=1
        robo.append([x,y])
    elif houkou[i]=="S":
      for j in range(kyori[i]):
        y-=1
        robo.append([x,y])
    elif houkou[i]=="W":
      for j in range(kyori[i]):
        x-=1
        robo.append([x,y])
  for i in range(len(houseki)):
    for j in range(len(robo)):
      if robo[j]==houseki[i]:
        get+=1
        break
  #print(houseki)
  #print(robo)
  if get==N:
    print("Yes")
  else:
    print("No")


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::string S){
    if(N % 2 != 0){
        cout << NO << endl;
        return;
    }

    string T = S.substr(0, N / 2);
    string T2= T + T;
    if(S == T2){
        cout << YES << endl;
    }else{
        cout << NO << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,x,y,i,mndep,mxdep,cc,T,t[100100],l[100100],col[100100],e[200200];
vector<int> c[100100],d[100100],g[100100],f[100100],o;
bool u[100100],w[100100],ww[100100];
bool path(int i, int w, int dep) {
  e[dep]=i; u[i]=true;
  if (w==i) {
    printf("%d\n",dep+1);
    for (int j=0; j<=dep; j++) printf("%d%c",e[j],(dep==j)?'\n':' ');
    return true;
  }
  for (int j=0; j<g[i].size(); j++) {
    int k=g[i][j];
    if (!u[k]) {
      if (path(k,w,dep+1)) return true;
    }
  }
  return false;
}
void path2(int i, int c, int dep) {
  e[dep]=i; w[i]=true;
  for (int j=0; j<g[i].size(); j++) if (col[f[i][j]]==c && !ww[g[i][j]] && !w[g[i][j]]) {
    //printf("path2 %d->%d\n",i,g[i][j]);
    path2(g[i][j],c,dep+1);
    return;
  }
  for (int j=0; j<g[i].size(); j++) if (col[f[i][j]]==c && !w[g[i][j]]) {
    //printf("path2 %d~>%d\n",i,g[i][j]);
    path2(g[i][j],c,dep+1);
    return;
  }
  mxdep=dep;
}
void path3(int i, int c, int dep) {
  //printf("path3-> %d\n",i);
  e[dep]=i; w[i]=true;
  for (int j=0; j<g[i].size(); j++) if (col[f[i][j]]==c && !w[g[i][j]]) {
    path3(g[i][j],c,dep-1);
    return;
  }
  mndep=dep;
}
void dfs(int i, int p) {
  l[i]=t[i]=++T;
  for (int j=0; j<g[i].size(); j++) {
    int k=g[i][j];
    if (k==p) continue;
    if (t[k]==0) {
      dfs(k,i);
      l[i]=min(l[i],l[k]);
    } else l[i]=min(l[i],t[k]);
  }
//  printf("%d = %d %d\n",i,l[i],t[i]);
}
void cfs(int i, int cur) {
  u[i]=true;
  c[cur].push_back(i);
  bool was=false,e=false;
  for (int j=0; j<g[i].size(); j++) {
    int k=g[i][j];
    if (u[k]) {
      if (col[f[i][j]]==0) col[f[i][j]]=cur;
      continue;
    }
    if ((i==1 && e) || (i>1 && l[k]>=t[i])) {
      was=true;
      c[++cc].push_back(i);
      col[f[i][j]]=cc;
      cfs(k,cc);
    } else {
      e=true;
      col[f[i][j]]=cur;
      cfs(k,cur);
    }
  }
  if (!was) {
    d[cur].push_back(i);
    ww[i]=true;
  }
}
int main() {
  scanf("%d%d",&n,&m);
  for (i=0; i<m; i++) {
    scanf("%d%d",&x,&y);
    g[x].push_back(y); f[x].push_back(i);
    g[y].push_back(x); f[y].push_back(i);
  }
  for (i=1; i<=n; i++) if (g[i].size()==1) o.push_back(i);
  if (o.size()>1) {
    //puts("PATH");
    path(o[0],o[1],0);
    return 0;
  }
  dfs(1,0);
  cfs(1,cc=1);
/*  for (i=0; i<m; i++) printf("%d,",col[i]); puts("");
  for (i=1; i<=cc; i++) {
  printf("%d:\n",i);
  for (int j=0; j<c[i].size(); j++) printf("%d,",c[i][j]); puts("");
  for (int j=0; j<d[i].size(); j++) printf("%d,",d[i][j]); puts("");
  }*/
  for (i=1; i<=cc; i++) if (c[i].size()==d[i].size() || c[i].size()==d[i].size()+1) {
    path2(d[i][0],i,n+1);
    path3(d[i][0],i,n+1);
    printf("%d\n",mxdep-mndep+1);
    for (int j=mndep; j<=mxdep; j++) printf("%d%c",e[j],(j==mxdep)?'\n':' ');
    return 0;
  }
  return 0;
}



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

using namespace std;

const int N = (int) 1e6 + 7;

int a[N], dp[N];

int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  dp[1] = 0;
  for (int i = 2; i <= n; i++) {
    dp[i] = INT_MAX;
    for (int j = i - 1; j >= max(1, i - k); j--) {
      dp[i] = min(dp[i], dp[j] + abs(a[j] - a[i]));
    }
  }
  cout << dp[n];
  return 0;
}

Measured memory_bytes: 4736
import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] X = new long[N];
		for(int i = 0; i < N; i++) {
			X[i] = sc.nextLong();
		}
		long x1 = 0;
		for(int i = 0; i < N; i++) {
			x1 += ((i%2 == 0)?X[i]:-X[i]);
		}
		System.out.print(x1);
		for(int i = 0; i < N - 1; i++) {
			x1 = X[i] * 2 - x1;
			System.out.print(" "+x1);
		}
		System.out.println();
	}
}

Measured memory_bytes: 66588
using static System.Math;
using System.Linq;
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var gcd0 = gcd(a[0], a[1]);
        if (n == 2)
        {
            Console.WriteLine(gcd0 == 1 ? "pairwise coprime" : "not coprime");
            goto exit;
        }
        for (int i = 2; i < n; i++)
        {
            var t = gcd(gcd0, a[i]);
            gcd0 = t;
        }
        if (gcd0 != 1) { Console.WriteLine("not coprime"); goto exit; }
        getAns(n, a);
    exit:;
    }
    static void getAns(int n, int[] a)
    {
        var amax = a.Max();
        if (amax == 1) { Console.WriteLine("pairwise coprime"); return; }
        var pr = GeneratePrime(amax);
        var b = new int[amax + 1];
        for (int i = 0; i < n; i++) b[a[i]]++;
        foreach (var x in pr)
        {
            var p = x;
            var check = 0;
            while (p <= amax)
            {
                check += b[p];
                if (check > 1) { Console.WriteLine("setwise coprime"); return; }
                p += x;
            }
        }
        Console.WriteLine("pairwise coprime");
    }
    static List<int> GeneratePrime(int m)
    {
        var a = new List<int>();
        int p;
        var sqrtMax = Sqrt(m);
        var s = Enumerable.Range(2, m - 1).ToList();
        do
        {
            p = s.First();
            a.Add(p);
            s.RemoveAll(n => n % p == 0);
        }
        while (p < sqrtMax);
        a.AddRange(s);
        return a;
    }
    static int gcd(int a, int b)
    {
        if (a < b) return gcd(b, a);
        while (b != 0)
        {
            var w = a % b;
            a = b;
            b = w;
        }
        return a;
    }
}


Measured memory_bytes: 110112
#include <stdio.h>

int main(void)
{
    int n;
    int a, b, c, d;
    int count;

    while (scanf("%d", &n) != EOF){
        a = b = c = d = count = 0;
        for (a = 0; a < 10; a++){
            for (b = 0; b < 10; b++){
                for (c = 0; c < 10; c++){
                    for(d = 0; d < 10; d++){
                        if (a + b + c + d == n){
                            count++;
                        }
                    }
                }
            }
        }
        printf("%d\n", count);
    }

    return (0);
}

Measured memory_bytes: 596
#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 irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char> > c(h,vector<char>(w));
    rep(i,h){
        rep(j,w) cin>>c.at(i).at(j);
    }
    rep(i,2*h){
        rep(j,w){
            cout<<c.at(i/2).at(j);
        }
        cout<<endl;
    }
}



Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
  char ch[250]={0};
  char a[250] ={0};
  int h;
  int i,j,k,l,n,m;
 
 
  while(1){
    i=0;
    while(1){
       
      scanf("%c",&ch[i]);
      if(ch[i] == '\n') {    
    break;
      }
       
      i++;
    }
    
    if ( i == 1 && ch[0] == '-' ) break;
 
    //  printf("%d",i);
     
    scanf("%d",&m);
     
    for(j=0;j<m;j++){
      scanf("%d", &h );
       
      for(k=0;k<i-h;k++) {
    a[k] = ch[h+k];
    //    printf("a[%d] = ch[%d]の%c\n",k ,h+k,ch[h+k]);
      }
      for(k=0;k<h;k++){
    a[i-h+k] = ch[k];
    //   printf("a[%d] = ch[%d]の%c\n",i-h+k,k,ch[k]);
      }
      for(k=0; k<i; k++){
    ch[k] = a[k];
    // printf("ch[%d] = a[%d]の%c\n",k,k,a[k]);
      }
    }
    for(k=0;k<i;k++) {
      printf("%c",ch[k]);
    }
    printf("\n");
      scanf("%c",&ch[0]);
  }
   
   
  return 0;
   
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll INF=ll(1e18)+1;


// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(200005);

//繰り返し2乘法、２＾n
mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}





//組み合わせの数nCrを計算
   int calcNumOfCombination(int n, int r){
       int num = 1;
       for(int i = 1; i <= r; i++){
           num = num * (n - i + 1) / i;
       }
       return num;
   }


int main() {
  ios::sync_with_stdio(false);
	cin.tie(0);
  ll n,k;
  cin>>n>>k;
//  mint c1=comb(n,a);
//  mint c2=comb(n,b);

  //ll m=n-k;
  if (k>n) k=n;
  mint ans=0;
  rep(i,k+1){
    mint c1=comb(n,i);
    mint c2=comb(n-1,n-i-1);
    mint c=c1*c2;
    ans+=c;
  }
  cout<<ans;

}


Measured memory_bytes: 3328
import numpy as np

N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = np.zeros((N, len(B)))

for n in np.arange(N):
    A[n] = list(map(int, input().split()))

ans = 0
for n in np.arange(N):
    if np.dot(A[n], B) + C > 0:
        ans += 1

print(ans)

Measured memory_bytes: 27160
import itertools
n = int(input())
ls = []
for i in range(1,n+1):
    ls.append(i)
    
p = list(map(int,input().split()))
q = list(map(int,input().split()))

a = 0
b = 0
c = 1
for v in itertools.permutations(ls, n):
    if list(v) == p:
        a = c
    if list(v) == q:
        b = c
    c += 1
    
print(abs(a-b))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#define rep(i,n) for(long long i=0;i<n;i++)
 
using namespace std;
using ll = long long;
 
int main(void)
{
    ll n;
    cin >> n;
    ll sum=0;
    rep(i,n)
    {
        if((i+1)%3!=0  && (i+1)%5!=0) sum+=i+1;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
namespace io{
	const int l=1<<20;
	char buf[l],*s,*t;
	inline char gc(){
		if(s==t){
			t=(s=buf)+fread(buf,1,l,stdin);
			return s==t?EOF:*s++;
		}
		return *s++;
	}
	char c;
	template<class IT>inline void gi(IT &x){
		x=0;c=gc();while(c<'0'||c>'9')c=gc();
		while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^'0');c=gc();}
	}
};
using io::gi;
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
const ll p=998244353ll,inf=1000000000000000000ll;
const int N=200005,E=1000005;
struct qwq{
	int a,b,c;
	inline bool operator<(const qwq &x)const{
		return c>x.c;
	}
}x[N];
int g[N],f[N];
int find(int v){return f[v]?f[v]=find(f[v]):v;}
int main(){
	int t,n,m,a,b,c,i;ll s=0ll;
	scanf("%d%d%d",&t,&n,&m);
	for(i=1;i<=t;++i){scanf("%d%d%d",&x[i].a,&x[i].b,&x[i].c);x[i].b+=n;}n+=m;
	sort(x+1,x+t+1);
	for(i=1;i<=n;++i)g[i]=1;
	for(i=1;i<=t;++i){
//		printf("%d %d %d\n",x[i].a,x[i].b,x[i].c);
		a=find(x[i].a);
		b=find(x[i].b);
//		printf("a=%d b=%d g[a]=%d g[b]=%d\n",a,b,g[a],g[b]);
		if(g[a]||g[b]){
			if(a==b)g[a]=0;
			else{
				g[b]&=g[a];
				f[a]=b;
			}
			s+=x[i].c;
		}
	}
	printf("%lld",s);
	return 0;
}

Measured memory_bytes: 4480