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

    using namespace std;
    #define ll  long long
    #define rep(i,n) for(ll i=0;i<n;i++)
    #define pb push_back
    #define in insert
    #define test   ll t;cin>>t;while(t--)
    #define bs  binary_search
    #define rep1(x,n) for(ll x=n-1;x>=0;x--) 
    
    #define SORT(x) sort(x.begin(),x.end())
    #define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
    #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
    #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
    #define All(x) (x).begin(),(x).end()
    #define rAll(x) (x).rbegin(),(x).rend()
    #define db  double
    #define sc scanf
    #define pf printf
    const ll MAX=1e8;
    //ll d[MAX],h[MAX];
    const double pi=3.14159265358979323846;
    const ll M=2e18 +7;
    ll gcd(ll x,ll y){
    	if(x==0)return y;
    	else return gcd(y%x,x);
    }
    ll lcm(ll x,ll y){
    	return (x*y)/gcd(x,y);
    }
   
      bool isPrime(ll n) 
{  
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6){ 
        if (n % i == 0 || n % (i + 2) == 0){ 
            return false; 
        }
    }
    return true; 
} 
bool pdrome(string s){
    ll n = s.length();
    for(ll i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1]){
            return false;
        }
    }
    return true;
}
ll mindig(ll x){
    ll ans = 9;
    ll t = x;
    while(x){
        ans = min(ans,x%10);
        x/=10;
    }
    x = t;
    return ans;
}
ll maxdig(ll x){
    ll ans = 0;
    ll t = x;
    while(x){
        ans = max(ans,x%10);
        x/=10;
    }
    x = t;
    return ans;
}
ll modpow(ll x,ll n,ll M){
	if(n==0)return 1%M;
	ll u=modpow(x,n/2,M);
	u=(u*u)%M;
	if(n%2==1)u=(u*x)%M;
	return u;

}
ll sum(ll a) {
    ll result = 0;
    while (a > 0) {
        result += a % 10;
        a /= 10;
    }
    return result;
}


  
  
    int main() {
    	ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
        ll n,m;
        cin>>n>>m;
        ll a[n+5]={0};vector<ll>ans(n+1);
        rep(i,n){cin>>a[i];ans[i]=0;}
        while(m--){
        	ll x,y;
        	cin>>x>>y;
        	ans[x-1]=max(ans[x-1],a[y-1]);
        	ans[y-1]=max(ans[y-1],a[x-1]);
        	
        } ll ans1=0;
        rep(i,n){ 
        ans1+=a[i]>ans[i];	
        }
        cout<<ans1;
    return 0;
}
    


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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

double dp[3010][3010];

int main() {

	int n;
	cin >> n;
	vector<double> p(n);
	rep(i,n) {
		cin >> p[i];
	}
	rep(i,3010) rep(j, 3010) dp[i][j] = 0;
	dp[0][0] = 1;
	for(int i=0; i<=n; i++) for(int j=0; j<=n-i; j++) {
		//cout << "i: " << i << " j:" << j << endl;
		if(i+j > n) continue;
		if(i == 0 && j == 0) continue;
		if(i != 0 && j != 0) {
			dp[i][j] = dp[i-1][j] * p[i+j-1] + dp[i][j-1] * (1 - p[i+j-1]);
		}
		else if (i == 0) {
			dp[i][j] = dp[i][j-1] * (1 - p[i+j-1]);
		}
		else if (j == 0) {
			dp[i][j] = dp[i-1][j] * p[i+j-1];
		}
		/*rep(i,n+1) {
			rep(j,n+1) {
				cout << setw(4) << dp[i][j];
			}
			cout << endl;
		}*/
	}
	double ans=0;
	for(int i=n; i>=n/2+1; i--) {
		ans += dp[i][n-i];
	}
	cout << setprecision(20) <<  ans << endl;
	
  return 0;
}


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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

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

void solve()
{
    int a, b, c;
    in3(a, b, c);
    int x, y;
    in2(x, y);
    int ans = inf;
    if (x >= y)
    {
        if (a + b > 2 * c)
        {
            if (a > 2 * c)
            {
                ans = 2 * c * x;
            }
            else
            {
                ans = 2 * c * y + a * (x - y);
            }
        }
        else
        {
            ans = a * x + b * y;
        }
    }
    else
    {
        if (a + b > 2 * c)
        {
            if (b > 2 * c)
            {
                ans = 2 * c * y;
            }
            else
            {
                ans = 2 * c * x + b * (y - x);
            }
        }
        else
        {
            ans = a * x + b * y;
        }
    }
    out(ans);
}

Measured memory_bytes: 256
#define ONLINE_JUDGE
#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <cmath>
#include <iterator>
#include <map>
#include <set>
#ifndef ONLINE_JUDGE
#include <prettyprint/prettyprint.hpp>
#endif

#define FOR(i, n) for(int i = 0; i < n; ++i)
#define TEST int T; std::cin >> T; while(T--)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vll = std::vector<ll>;
using vull = std::vector<ull>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

using namespace std;

const int mod = 1e9 + 7;

void add_self(int& a, int b) {
	a += b;
	if(a >= mod) a -= mod;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	ifstream fin("in.txt");
	ofstream fout("out.txt");
	auto cinbuf = cin.rdbuf(fin.rdbuf());    // save and redirect
	auto coutbuf = cout.rdbuf(fout.rdbuf()); // save and redirect
#endif	
	string digits;
	int d;
	cin >> digits >> d;

	vector<int[2]> dp(d);
	dp[0][0] = 1;

	for(int i = 0; i < digits.size(); ++i) {
		vector<int[2]> next(d);
		for(int j = 0; j < d; ++j) {
			for(auto s : {false, true}) {
				for(int digit = 0; digit < 10; ++digit) {
					if(s == false && digit > (digits[i] - '0')) break;
					add_self(next[(j + digit) % d][s || (digit < digits[i] - '0')],
							 dp[j][s]);
				}
			}
		}
		for(int i = 0; i < d; ++i) {
			dp[i][0] = next[i][0];
			dp[i][1] = next[i][1];
		}
	}
	int ans = dp[0][0];
	add_self(ans, dp[0][1]);
	--ans;
	if(ans < 0) ans += mod;
	cout << ans << endl;
#ifndef ONLINE_JUDGE
	cin.rdbuf(cinbuf);    // restore
	cout.rdbuf(coutbuf); // restore
#endif	
}


Measured memory_bytes: 256
n,l=map(int,input().split())
a=list(map(int,input().split()))
for i in range(1,n):
    if a[i]+a[i-1]>=l:
        print("Possible")
        for j in range(1,i):
            print(j)
        for j in range(n-1,i,-1):
            print(j)
        print(i)
        break
else:
    print("Impossible")

Measured memory_bytes: 14052
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		String S = nextString();
		char[] c = S.toCharArray();
		long[] alph = disassemblyAlph(S);
		String lost = "";
		for(int i=0;i<alph.length;i++){
			if(alph[i]==0){
				lost=String.valueOf((char)('a'+i));
				break;
			}
		}
		if(!"".equals(lost)){
			System.out.println(S+lost);
			return;
		}

		for(int i=c.length-2;i>=0;i--){
			if(c[i]<c[i+1]){
				int x='z'+10;
				for(int k=i+1;k<c.length;k++){

					if(c[k]-'a'> c[i]-'a'){
						x=Math.min(x,c[k]-'a');
					}
				}
				c[i]=(char)('a'+x);
				System.out.println(String.valueOf(c,0,i+1));
				return;
			}
		}

		System.out.println(-1);


	}

	public static long[] disassemblyAlph(String s) {
		long[] alph = new long['z' - 'a' + 1];
		Arrays.fill(alph, 0);
		for (int i = 0; i < s.length(); i++) {
			alph[s.charAt(i) - 'a']++;
		}
		return alph;
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
ll mo;
ll dp[202][202];


ll hoge(int N,int K) {
	
	if(N==1) return 1;
	if(N==2) return 0;
	
	int x,y,k,l,i;
	ll ret=0;
	for(k=1;k<=N-2;k++) {
		l=N-1-k;
		if(k>K || l>K) continue;
		ZERO(dp);
		dp[0][0]=1;
		FOR(y,k+1) FOR(x,l+1) {
			if(y==0&&x==l) dp[y][x]=0;
			if(y-1+(l-x)>K) continue;
			if(x+(k-y)>K) continue;
			//cout<<y<<x<<" "<<dp[y][x]<<endl;
			(dp[y+1][x]+=dp[y][x])%=mo;
			(dp[y][x+1]+=dp[y][x])%=mo;
		}
		ret+=dp[k][l];
	}
	//cout<<N<<K<<" "<<ret<<endl;
	for(i=1;i<=N-1;i++) ret=ret*i%mo;
	//cout<<N<<K<<" "<<ret<<endl;
	return ret;
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K>>mo;
	
	ll ret=0;
	ll fac=1;
	while(2*K>=N-1) {
		ret+=fac*hoge(N,K)%mo;
		fac=fac*N%mo;
		N--,K--;
	}
	
	cout<<ret%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3980
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] c = new String[]{"w", "", "k", "s", "t", "n", "h", "m", "y", "r"};
		String s = sc.next();
		for(int i=0;i<s.length()/2;i++){
			char ss = s.charAt(i*2+1);
			
			if(s.charAt(i*2) != '0' || ss != 'U'){
				System.out.print(c[s.charAt(i*2)-'0']);
				if(ss == 'T')
					System.out.print("a");
				else if(ss == 'L')
					System.out.print("i");
				else if(ss == 'U')
					System.out.print("u");
				else if(ss == 'R')
					System.out.print("e");
				else if(ss == 'D')
					System.out.print("o");
			}else{
				System.out.print("nn");
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 26972
#include <stdio.h>
#include <algorithm>
using namespace std;

main(){
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<=0&&b>=0)puts("Zero");
	else if(a>0)puts("Positive");
	else puts((a-b)%2==0?"Negative":"Positive");
	return 0;
}

Measured memory_bytes: 128
let scan4 f = stdin.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
let scanVecH f = stdin.ReadLine().Split() |> Array.map f
 
let N, M, X, Y = scan4 int
let xs = scanVecH int
let ys = scanVecH int
 
let xmax = Array.max xs
let ymin = Array.min ys
 
[xmax+1..ymin]
|> List.exists (fun z -> X < z && z <= Y)
|> function
   | true -> printfn "No War"
   | false -> printfn "War"

Measured memory_bytes: 13776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
	int n, a;
	cin >> n;
    vector<pair<int, int> > p(n);
    
    rep(i, n)
    {
        int x, y;
        cin >> x >> y;
        p.at(i) = make_pair(x, y);
    }
    sort(p.begin(), p.end());
    
    rep(i, n)
    {
        cout << p[i].first << " " << p[i].second << endl;
    }
}



Measured memory_bytes: 3624
#include <iostream>
#include <queue>
#include <stdio.h>

using namespace std;

int main(){


	int data[101];
	int flag[31];

	for(int i=0;i<=30;i++){
		flag[i]=0;
	}
	int cnt=0;
	data[0]=0;
	while(1){
		int num,ansNum;
		scanf("%d,%d",&num,&ansNum);

		if(num==0&&ansNum==0)break;
		cnt++;

		data[num]=ansNum;
	}

	int i;
	while(cin>>i){
		int ans=1;
		int tmpNum=0;
		for(int j=0;j<=30;j++){
			flag[j]=0;
		}
		for(int j=0;j<=cnt;j++){
			if(i==j)continue;


			if(data[j]>=0&&data[i]<data[j]&&flag[data[j]]==0){
				ans++;
				flag[data[j]]++;
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 1244
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC124_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            string[] strs = Console.ReadLine().Split(' ');

            int[] height = new int[n];

            height[0] = int.Parse(strs[0]);

            int goodViewCount = 1;

            for (int i = 1; i < n; ++i)
            {
                height[i] = int.Parse(strs[i]);

                bool goodView = true;

                for (int j = 0; j < i; ++j)
                {
                    if (height[j] > height[i])
                    {
                        goodView = false;
                        break;
                    }
                }

                if (goodView)
                {
                    ++goodViewCount;
                }
            }

            Console.WriteLine($"{goodViewCount}");
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    ll n;
    cin >> n;
    
    unordered_set<ll> us;
    us.emplace(n);
    for (int i = 0; ; i++) {
        n = n % 2 == 0 ? n / 2 : 3 * n + 1;
        if (us.count(n) >= 1) {
            cout << i + 2 << endl;
            return 0;
        }
        us.emplace(n);
    }

    return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>

int main(void){
    int n,m,i,o;
    for(;scanf("%d %d",&n,&m),n+m;printf("\n"))
        for(i=0;i<n;printf("\n"),i++)
            for(o=0;o<m;printf("#"),o++);
    return 0;
}

Measured memory_bytes: 572
#!/usr/bin/env python3
import sys
import collections
import heapq

def solve(N: int, S: "List[str]"):
    count_dict = collections.defaultdict(int)
    for s in S:
        count_dict[s] += 1
    
    largest = heapq.nlargest(1, [y for x, y in count_dict.items()])[0]
    answer_list = []
    for k, v in count_dict.items():
        if v == largest:
            answer_list.append(k)
    answer_list = sorted(answer_list)
    for ans in answer_list:
        print(ans)
    return


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 35568
n = int(input())
firsts = 0
lasts = 0
doubles = 0
inners = 0
for i in range(n):
    s = input()
    first = 1 if (s[0] == "B" and s[-1] != "A") else 0
    last = 1 if (s[-1] == "A" and s[0] != "B") else 0
    double = 1 if (s[0] == "B" and s[-1] == "A") else 0
    inner = s.count("AB")
    # ss += s
    firsts += first
    lasts += last
    doubles += double
    inners += inner
if doubles == 0 and firsts == 0 and lasts == 0:
    print(inners)
elif firsts == 0 and lasts == 0:
    print(inners + doubles - 1)
# elif firsts == 0 or lasts == 0:
#     print(inners + doubles)
else:
    print(inners + doubles + min(firsts, lasts))

Measured memory_bytes: 3444
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const double EPS=1e-10;
int main()
{
    double p[21][121]={}, ps[21][121], pss[21][121];
    p[0][0]=1;
    for(int i=1; i<=20; i++){
        for(int j=1; j<=6; j++){
            for(int k=0; k<=120-j; k++){
                p[i][k+j]+=(p[i-1][k]/6);
            }
        }
        ps[i][0]=0;
        for(int j=1; j<=120; j++){
            ps[i][j]=ps[i][j-1]+p[i][j];
        }
        pss[i][120]=0;
        for(int j=119; j>=0; j--){
            pss[i][j]=pss[i][j+1]+(double)(j+1)*p[i][j+1];
        }
    }
    while(1){
        int n; ll m; cin>>n>>m;
        if(n==0 && m==0) return 0;
        double dp[100001];
        dp[0]=0;
        for(int i=1; i<=min(m, 100000ll); i++){
            dp[i]=0;
            for(int j=0; j<=120; j++){
                if(j<dp[i-1]){
                    dp[i]+=(p[n][j]*dp[i-1]);
                }else{
                    dp[i]+=(p[n][j]*(double)j);
                }
            }
        }
        if(m<=100000ll){
            printf("%.3lf\n", dp[m]);
            continue;
        }
        double e=dp[100000];
		if(e>6*(double)n-0.01){
			printf("%.3lf\n", e);
            continue;
        }
        int e0=(int)(dp[100000]);
        ll m0=100000;
        while(1){
            double x0=pss[n][e0]/(1-ps[n][e0]);
			if(e0==6*n-1){
				e=pow(ps[n][e0], (double)(m-m0))*(e-x0)+x0;
                printf("%.3lf\n", e);
                break;
            }
            ll k=(ll)(log(((double)e0+1-x0)/(e-x0))/log(ps[n][e0])+1-EPS);
            if(m0+k>=m){
                e=pow(ps[n][e0], (double)(m-m0))*(e-x0)+x0;
                printf("%.3lf\n", e);
                break;
            }else{
                e=pow(ps[n][e0], (double)k)*(e-x0)+x0;
                m0+=k;
                e0++;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4340
import math
def A():
    H = int(input())
    W = int(input())
    N = int(input())
    print(int(min(math.ceil(N/H), math.ceil(N/W))))

def B():
    N = int(input())
    robots = []
    for i in range(N):
        temp = [int(n) for n in input().split()]
        robots.append([temp[0]-temp[1], temp[0]+temp[1]])
    robots.sort(key = lambda x:x[1])
    #print(robots)
    prev_end = robots[0][1]
    count = 1
    for i in range(1, len(robots)):
        cur_start = robots[i][0]
        cur_end = robots[i][1]

        if cur_start >= prev_end:
            #print(i)
            count += 1
            prev_end = cur_end

    print(count)

def C():
    temp = [int(n) for n in input().split()]
    N = temp[0]
    K = temp[1]
    S = temp[2]
    if S == 10**9:
        ans = [str(S)]*K + [str(S-1)]*(N-K)
    else:
        ans = [str(S)]*K + [str(S+1)]*(N-K)
    print(' '.join(ans))

B()

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

const int M = 1000006;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> cnt(M);
    for (int x : a) {
        if (cnt[x] != 0) {
            cnt[x] = 2;
            continue;
        }
        for (int i = x; i < M; i += x) cnt[i]++;
    }
    int ans = 0;
    for (int x : a) {
        if (cnt[x] == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7956
#include<stdio.h>

int main(){

    int n;
    scanf("%d", &n);

    int p[n];
    for (int i = 0; i < n; i++){
        scanf("%d", &p[i]);
    }

    int cnt = 0;

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

        if((p[i-1]<=p[i] && p[i]<p[i+1]) || (p[i+1]<=p[i] && p[i]<p[i-1]) || (p[i] < p[i-1] && p[i-1] == p[i+1])){
            cnt += 1;
        }
    }

    printf("%d", cnt);

    return 0;
}

Measured memory_bytes: 128
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();
		int c = sc.nextInt();

		if (a < b) {
			if (b < c) {
				System.out.printf("%d %d %d\n", a, b, c);
			} else if (a < c) {
				System.out.printf("%d %d %d\n", a, c, b);
			} else {
				System.out.printf("%d %d %d\n", c, a, b);
			}
		} else {
			if (a < c) {
				System.out.printf("%d %d %d\n", b, a, c);
			} else if (b < c) {
				System.out.printf("%d %d %d\n", b, c, a);
			} else {
				System.out.printf("%d %d %d\n", c, b, a);
			}
		}
	}

}

Measured memory_bytes: 26124
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(30) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> W;
  Vec(A,lli,N,0);
  Vec(B,lli,N,0);
  DV(dp,lli,N+1,W+1,0);
  rep(i,0,N)cin >> A[i] >> B[i];
  rep(i,1,N+1)rep(j,0,W+1){
    dp[i][j]=max(dp[i-1][j],dp[i][j]);
    if(j+A[i-1]<=W)dp[i][j+A[i-1]]=max(dp[i-1][j+A[i-1]],dp[i-1][j]+B[i-1]);
  }
  rep(i,0,W+1)sum=chmax(sum,dp[N][i]);
  Out(sum);
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#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 all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int jud(int x){
	int flag = 1;
	for(int i = 2; i*i <= x; i++){
		if(x%i == 0) flag = 0;
	}
	return flag;
}

int main(){
	int x;
	cin >> x;
	while(!jud(x)) x++;
	cout << x << endl;
	return 0;
}


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

b = [0]*n
c = [0]*(n-1)
for i in range(n-1):
  c[i] += a[i]-b[i]
  b[i+1] += c[i]

first = (a[-1] - b[-1])//2
b = [0]*n
b[0] = first
c = [0]*(n-1)
for i in range(n-1):
  c[i] += a[i]-b[i]
  b[i+1] += c[i]

print(int(first*2), end = " ")
for i in range(len(c)):
  print(int(c[i]*2), end = " ")

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

using namespace std;

int main() {
    long int n,i;int k;
    scanf("%ld%d",&n,&k);
    long long int dp[n+1];long int arr[n+1];arr[0]=-1;
    dp[0]=dp[1]=0;
    for(i=1;i<=n;i++){
        scanf("%ld",&arr[i]);
    }
    dp[2]=abs(arr[2]-arr[1]);
    for(i=3;i<=n;i++){
        dp[i]= dp[i-1] + abs(arr[i]-arr[i-1]);
        for(int j = 2;j<=k;j++){
            if(i-j >= 1)
            dp[i] = min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
            else
            break;
        }
    }
    printf("%lld",dp[n]);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
  int n;cin>>n;
  int ans=1;
  rep(i,n+1)if(pow(2,i)<=n)ans=pow(2,i);
  cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 1030, M = N << 1;

int n, m, b[N][N], a[N][N];

inline int popcnt(int x)
{
	int res = 0;
	while (x)
	{
		if (x & 1) ++res;
		x >>= 1;
	}
	return res;
}

int main()
{
	//File("");
	n = gi(), m = gi();
	int r = 1, c = 1;
	for (int i = 1; i <= n; i+=1) r <<= 1;
	for (int i = 1; i <= m; i+=1) c <<= 1;
	--r, --c;
	for (int i = 1; i <= r; i+=1)
		for (int j = 1; j <= c; j+=1)
			b[i][j] = popcnt(i & j) % 2;
	for (int i = 1; i <= r; i+=1)
	{
		for (int j = 1; j <= c; j+=1)
			a[i][j] = ((b[i][j] - b[i - 1][j] - b[i][j - 1] + b[i - 1][j - 1]) % 2 + 2) % 2,
				printf("%d", a[i][j]);
		puts("");
	}
	return 0;
}
//

Measured memory_bytes: 11924
def put_queen(board, pr, pc):
    def check_square(r, c):
        tmp = (pr == r) + (pc == c)
        if tmp:
            return tmp
        return 1 if abs(pr - r) == abs(pc - c) else board[r][c]

    return list(list(check_square(r, c) for c in range(8)) for r in range(8))


def check_board(board):
    return sum(sum(row) for row in board) == 72


def draw_board(board):
    print('\n'.join(''.join('Q' if c == 2 else '.' for c in row) for row in board))


def search_place(board):
    for r, row in enumerate(board):
        for c, square in enumerate(row):
            if square == 0:
                if search_place(put_queen(board, r, c)):
                    return True
    if check_board(board):
        draw_board(board)
        return True
    else:
        return False


n = int(input())
board = list(list(0 for c in range(8)) for r in range(8))

for _ in range(n):
    r, c = map(int, input().split())
    board = put_queen(board, r, c)

search_place(board)

Measured memory_bytes: 7800
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static long long mod = 1000000007;
struct mint {
  long long x;
  mint(ll x = 0):x((x%mod+mod)%mod) {}
  mint& operator+=(const mint a) {
    (x += a.x) %= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    (x += mod-a.x) %= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint ret(*this);
    return ret += a;
  }
  mint operator-(const mint a) const {
    mint ret(*this);
    return ret -= a;
  }
  mint operator*(const mint a) const {
    mint ret(*this);
    return ret *= a;
  }
  mint pow(ll t) const {
    if(t==0) return mint(1);
    mint a = pow(t>>1);
    a *= a;
    if(t&1) a *= *this;
    return a;
  }
  
  //for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint ret(*this);
    return ret /= a;
  }
};
ostream &operator<<(ostream& os, const mint& x) {
  os << x.x;
  return os;
}
class modutils {
  vector<mint> fact, invfact;
public:
  modutils(int n = 200005):fact(n+1),invfact(n+1) {
    fact[0] = 1;
    for(int i=1; i<=n; i++) fact[i] = fact[i-1] * i;
    invfact[n] = fact[n].inv();
    for(int i=n; i>=1; i--) invfact[i-1] = invfact[i] * i;
  }
  mint pow(mint x, ll n) {
    return x.pow(n);
  }
  mint comb(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    if(k == 0 || n == k) return 1;
    return fact[n] * invfact[k] * invfact[n-k];
  }
  mint perm(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[n-k];
  }
  mint fac(ll n) {
    return fact[n];
  }
};


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

void solve(int p, const vector<int>& a){
  modutils mutil(p-1);

  vector<mint> b(p, 0);

  rep(i,p){
    if(a[i] == 0) continue;
    b[0] += 1;
    mint pw = 1;
    for(int j=p-1; j>=0; j--){
      b[j] -= pw * mutil.comb(p-1, j);
      pw *= -i;
    }
  }

  rep(i,p){
    if(i>0) cout << " ";
    cout << b[i];
  }
  cout << endl;
}


int main(){
  int p;
  cin >> p;
  mod = p;
  vector<int> v;
  rep(i,p){
    int a;
    cin >> a;
    v.emplace_back(a);
  }
  
  solve(p, v);
  
  return 0;
}



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

string S;
vector<pair<long long, long long> >R;
vector<pair<long long, long long> >L;
long long ans[100005];

int main(){
	cin >> S;

	long long cur = 0;
	for(long long i = 0; i < S.size(); i++){
		if(S[i] == 'R'){
			cur++;
		}else{
			if(cur != 0){
			R.push_back(make_pair(i-1, cur));
			cur=0;
			}
		}
	}

	cur = 0;
	for(long long i = S.size() - 1; i >= 0; i--){
		if(S[i] == 'L'){
			cur++;
		}else{
			if(cur != 0){
			L.push_back(make_pair(i+1, cur));
			cur=0;
			}
		}
	}

	for(auto r: R){
		if(r.second%2 == 0){
			ans[r.first] += r.second/2;
			ans[r.first+1] += r.second/2; 
		}else{
			ans[r.first] += r.second/2 + 1;
			ans[r.first+1] += r.second/2; 
		}
	}
	for(auto l: L){
		if(l.second%2 == 0){
			ans[l.first] += l.second/2;
			ans[l.first-1] += l.second/2; 
		}else{
			ans[l.first] += l.second/2 + 1;
			ans[l.first-1] += l.second/2; 
		}
	}

	for(long long i = 0; i < S.size(); i++){
		cout << ans[i];
		if(i != S.size()-1){
			cout << " ";
		}else{
			cout << endl;
		}
	}

}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define pb(c) push_back(c)
#define vii vector<pair<int,int>>
#define ii pair<int,int>
#define max(a, b) (((a)<(b))?b:a)
#define min(a, b) ((a>b)?b:a)
#define mp(i, j) make_pair(i,j)
#define ull unsigned long long int
#define ll  long long int
#define pi 3.141592653589793238
#define mod ((int)1e9 + 7)
#define inf ((int)1e5)
#define eps 1e-14,
#define maxlg 18
#define left(i) ((i)<<1)
#define right(i) (((i)<<1)+1)
#define maxn 1051002
vii adj[maxn];
bool f;
bool visited[maxn];
int pos[maxn];
void dfs(int curr,int pos = 100) {
    visited[curr]=true;
    ::pos[curr] = pos;
    for (ii nxt:adj[curr]) {
        int w = nxt.second;
        if (!visited[nxt.first]) {
             dfs(nxt.first,pos+nxt.second);
        } else {
             if (::pos[nxt.first]-::pos[curr]!=w) {
                 if (!f)
                 cout<<"No";
                 f = true;
             }

        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE

#endif
    int n,m;
    cin>>n>>m;
    rep (i,0,m) {
        int r,l,x;
        cin>>l>>r>>x;
        adj[l].push_back(mp(r,x));
        adj[r].push_back(mp(l,-x));
    }
    for (int i=1;i<=n;i++)
        if (!visited[i])
            dfs(i);

    if (!f)
    rep (i,0,n)
        for (ii nx :adj[i]) {
            int l = i;
            int r = nx.first;
            if (pos[r]-pos[l]!=nx.second) {
                cout<<"No";
                return 0;
            }
        }


        if (!f)
            cout<<"Yes";
     return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
string S;
map<pair<string, string>, int> mp;

signed main() {
    cin >> N >> S;
    for (int i = 0; i < 1 << N; i++) {
        string S1 = "", S2 = "";
        int tmp = i;
        for (int j = N * 2 - 1; j >= N; j--) {
            if (tmp % 2 == 0) {
                S1 += S[j];
            } else {
                S2 += S[j];
            }
            tmp /= 2;
        }
        mp[make_pair(S1, S2)]++;
    }
    int ans = 0;
    for (int i = 0; i < 1 << N; i++) {
        string S1 = "", S2 = "";
        int tmp = i;
        for (int j = 0; j < N; j++) {
            if (tmp % 2 == 0) {
                S1 += S[j];
            } else {
                S2 += S[j];
            }
            tmp /= 2;
        }
        ans += mp[make_pair(S1, S2)];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 91904
import sys
x=int(input())
div=[]
for i in range(1,int(x**0.5)+1):
  if x%i==0:
    div.append(i)
    if i != x // i:
      div.append(x//i)
div.sort()
div.reverse()
for i in div:
  for j in range(-10,1000):
    a=i-i+j
    b=-i+j
    other=(a**4)+(a**3)*b+(a**2)*(b**2)+a*(b**3)+(b**4)
    if i*other==x:
      print(a,b)
      sys.exit()


Measured memory_bytes: 9364
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <sstream>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> x(n);
	int ttl = 0;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		ttl += x[i];
	}
	if (n == 2) {
		cout << abs(x[0] - x[1]) << endl;
		return(0);
	}
	int a = ttl;
	int b = 0;
	int c, d;
	a -= x[n - 1];
	b += x[n - 1];
	c = abs(a - b);
	for (int i = n - 2; i >= 0; i--) {
		a -= x[i];
		b += x[i];
		d = abs(a - b);
		if (c > d) {
			c = d;
		}
	}
  	cout << c << endl;
	return(0);
}





Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let x: u64 = input();
    match x {
        7 | 5 | 3 => println!("YES"),
        _ => println!("NO")
    }
}


Measured memory_bytes: 2116
S=input()

A=[0]*(len(S)+1)
for i in range(len(S)):
    if S[i]=='<':
        A[i+1]=max(A[i+1],A[i]+1)
    
for i in range(len(S)-1,-1,-1):
    if S[i]=='>':
        A[i]=max(A[i],A[i+1]+1)

print(sum(A))


Measured memory_bytes: 29020
n=int(input())

a = list(map(int,input().split()))

memo_1 = [0]*n
memo_1_ruiseki = [0]*n
memo_2 = [0]*n
memo_2_ruiseki = [0]*n

for i in range(n):
    if i%2==0:
        if memo_1_ruiseki[i-1]+a[i] < 0:
            memo_1[i] = abs(memo_1_ruiseki[i-1])+1
        elif memo_1_ruiseki[i-1]+a[i] == 0:
            memo_1[i] = a[i]+1
        else:
            memo_1[i] = a[i]
    else:
        if memo_1_ruiseki[i-1]+a[i] > 0:
            memo_1[i] = -1+(-1)*abs(memo_1_ruiseki[i-1])
        elif memo_1_ruiseki[i-1]+a[i] == 0:
            memo_1[i] = -1+a[i]
        else:
            memo_1[i] = a[i]
    memo_1_ruiseki[i] = memo_1_ruiseki[i-1]+memo_1[i]

for i in range(n):
    if i%2==1:
        if memo_2_ruiseki[i-1]+a[i] < 0:
            memo_2[i] = abs(memo_2_ruiseki[i-1])+1
        elif memo_2_ruiseki[i-1]+a[i] == 0:
            memo_2[i] = a[i]+1
        else:
            memo_2[i] = a[i]
    else:
        if memo_2_ruiseki[i-1]+a[i] > 0:
            memo_2[i] = -1+(-1)*abs(memo_2_ruiseki[i-1])
        elif memo_2_ruiseki[i-1]+a[i] == 0:
            memo_2[i] = -1+a[i]
        else:
            memo_2[i] = a[i]
    memo_2_ruiseki[i] = memo_2_ruiseki[i-1]+memo_2[i]

ans_1 = 0
ans_2 = 0

for i in range(n):
    ans_1 += abs(memo_1[i]-a[i])
    ans_2 += abs(memo_2[i]-a[i])

print(min(ans_1,ans_2))

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

int main() {
  int N, K;
  cin >> N >> K;
  if (N % 2 == 0 && K <= N / 2) cout << "YES" << endl;
  else if (N % 2 == 1 && K <= N / 2 + 1) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(text){console.log(text);}//standard output
//[no]param
//0:noConvert	1:singleNum	2:spaceList	3:newLineList	4:spaceNumList	5:newLineNumList
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,5);
  var a = input[0];
  var b = input[1];
  var c = input[2];
  var x = input[3];
  var output = 0;
  
  for(var i = 0; i <= a; i++){
    for(var j = 0; j <= b; j++){
      for(var k = 0; k <= c; k++){
        if(x == (i * 500 + j * 100 + k * 50)){
           output++;
           }
      }
    }
  }
  
  myout(output);
}

Main(myin());

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

int C = 0;

int LinearSearch(int x, int S[], int n){
 for(int i=0; i<n; i++){
  if(S[i]==x){ 
    C++;
    return i;
  }
 }
 return -1;
}

int main(){
 
 int n;
 cin >> n;

 int S[n];
 for(int i=0; i<n; i++){
  cin >> S[i];
 }

 int q;
 cin >> q;

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

 for(int i=0; i<q; i++){
  LinearSearch(T[i], S, n);
 }

 cout << C << endl;

 return 0;
}

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

using namespace std;

int main() {
	int M, T, P, R;
	while (cin >> M >> T >> P >> R) {
		if (M == 0 && T == 0 && P == 0 && R == 0) {
			break;
		}
		int m, t, p, j;
		int tm[50][10] = {0};
		int sol[50][3] = {0};

		for (int i = 0; i < T; i++) {
			sol[i][2] = i+1;
		}

		for (int i = 0; i < R; i++) {
			cin >> m >> t >> p >> j;
			t -= 1;
			p -= 1;
			if (j != 0) {
				tm[t][p] += 20;
			} else {
				tm[t][p] += m;
				sol[t][0]++;
				sol[t][1] += tm[t][p];
			}
		}

		/*for (int i = 0; i < T; i++) {
	//		cout << sol[i][0] << " " << endl;
		}*/

		for (int i = T-1; i > 0; i--) {
			for (int j = 0; j < i; j++) {
				if (sol[j][0] < sol[j+1][0]) {
					swap(sol[j][0], sol[j+1][0]);
					swap(sol[j][1], sol[j+1][1]);
					swap(sol[j][2], sol[j+1][2]);
				} else if (sol[j][0] == sol[j+1][0]) {
					if (sol[j][1] > sol[j+1][1]) {
						swap(sol[j][1], sol[j+1][1]);
						swap(sol[j][2], sol[j+1][2]);
					} else if (sol[j][1] == sol[j+1][1]) {
						if (sol[j][2] < sol[j+1][2]) {
							swap(sol[j][2], sol[j+1][2]);
						}
					}
				}
			}
		}
		for (int i = 0; i < T; i++) {
			if (i != 0) {
				if (sol[i][0] < sol[i-1][0]) {
					cout << "," ;
				} else {
					if (sol[i][1] != sol[i-1][1]) {
						cout << ",";
					} else {
						cout << "=";
					}
				}
			}
			cout << sol[i][2];
		} 
		cout << endl;
	}
	return 0;
}

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

using ll = long long;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SIZE(a) ((int)(a).size())

const int N = 100005;
const ll linf = 2e18;

int n, a[N];

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

	cin >> n;
	REP(i, n) cin >> a[i];
	reverse(a, a + n);
	ll l, r;
	l = r = 2;
	REP(i, n) {
		ll nl = l % a[i] ? l + a[i] - l % a[i] : l;
		ll nr = r - r % a[i] + a[i] - 1;
		if (nl > nr) {
			cout << -1 << '\n';
			return 0;
		}
		l = nl;
		r = nr;
	}

	cout << l << ' ' << r << '\n';

	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

// 

public class Program_DPC5_A // ←Class名変更！！
{
    public static void Main()
    {
        Rs();
        var a = Ria();
        var avg = a.Average();

        var diff = Abs(a[0] - avg);
        var pos = 0;
        for (int i = 1; i < a.Length; i++)
        {
            var d = Abs(a[i] - avg);
            if (d<diff )
            {
                pos = i;
                diff = d;
            }
        }

        WriteLine(pos);

    } // Main

    public static string Rs() { return ReadLine(); }
    public static int Ri() { return int.Parse(ReadLine()); }
    public static long Rl() { return long.Parse(ReadLine()); }
    public static int[] Ria() { return Array.ConvertAll(ReadLine().Split(' '), int.Parse); }
    public static long[] Rla() { return Array.ConvertAll(ReadLine().Split(' '), long.Parse); }
    public static char[] Rca() { return ReadLine().ToCharArray(); }
}     // Class


Measured memory_bytes: 13268
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()
S = [input() for _ in range(N)]
 
cnt_s = Counter(S)
tmp = cnt_s.most_common()[0][1]
for key, val in sorted(cnt_s.most_common(), key=itemgetter(0)):
		if val == tmp:
      			print(key)

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

int main()
{
  int N, K;
  cin >>N>>K;
  vector<int> A(N);
  for(int i=0;i<N;i++)
    cin >> A[i];
  for(int i=K;i<N;i++){
    if(A[i-K]<A[i]) cout << "Yes" << endl;
    else cout <<"No" << endl;
  }
}

Measured memory_bytes: 4048
#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(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin>>A[i];

    sort(A.rbegin(), A.rend());

    ll ans=0;
    int t=N-1;
    rep(i, N){
        int lim=2;
        if(i==0) lim=1;
        rep(j, lim){
            if(t>0){
                ans+=A[i];
                t--;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4840
from itertools import accumulate
N, M = map(int, input().split())

# left = 1
# right = N
#
# for i in range(M):
#     a,b = map(int, input().split())
#     left = max(left,a)
#     right = min(right, b)
#
# print(max(0,right-left+1))

imos = [0] * (N + 2)
for i in range(M):
    l, r = map(int, input().split())
    imos[l] += 1
    imos[r + 1] -= 1

imos = list(accumulate(imos))

ans = 0
for im in imos:
    ans += (im == M)

print(ans)


Measured memory_bytes: 13800
// #include "coins.h"
#include <iostream>
#include <numeric>
#include <vector>
#include <iomanip>

#include <iterator>

using Probabilities = std::vector<double>;

/*There are two possible ways to get exactly j heads with i coins -

a) if (i-1) coins have j heads, and ith coin is tail, and

b) if (i-1) coins have j-1 heads, and ith coin is head

so

P(i, j) = P(i-1, j) * (1 - p[i]) + P(i-1, j-1) * p[i]*/
double probability_of_more_heads(const Probabilities& heads_probabilities)
{
    std::vector<double> prev(heads_probabilities.size() + 1, 0);
    // dp[i] - probability that we have i heads so far
    std::vector<double> dp(heads_probabilities.size() + 1, 0);

    prev.front() = 1;

    for (size_t pos = 1; pos <= heads_probabilities.size(); ++pos) {
        for (size_t num_heads = 0; num_heads <= pos; ++num_heads) {
            const double p_heads{heads_probabilities[pos - 1]};
            const double p_tails{1 - p_heads};
            if (num_heads == 0)
                dp[num_heads] = prev[num_heads] * p_tails;
            else
                dp[num_heads] = prev[num_heads] * p_tails + prev[num_heads - 1] * p_heads;
        }
        std::swap(prev, dp);
    }

    // for (const auto& row : dp) {
    //     std::copy(row.cbegin(),
    //               row.cend(),
    //               std::ostream_iterator<
    //                   std::iterator_traits<decltype(row.cbegin())>::value_type>(
    //                   std::cout, ", "));
    //     std::cout << '\n';
    // }
    double ans{0};
    for (size_t num_heads = 0; num_heads <= heads_probabilities.size(); ++num_heads) {
        size_t num_tails = heads_probabilities.size() - num_heads;
        if (num_heads > num_tails)
            ans += prev[num_heads];
    }
    // std::copy(prev.cbegin(), prev.cend(), std::ostream_iterator<std::iterator_traits<decltype(prev.cbegin())>::value_type>(std::cout, ", "));
    // std::cout << '\n';
    return ans;
    // return std::accumulate(
    //     std::next(prev.cbegin(), prev.size() / 2),
    //     prev.cend(),
    //     double{0.0});
}

int main(int argc, char* argv[])
{
    size_t num_coins;
    std::cin >> num_coins;
    Probabilities heads_probabilities(num_coins);
    for (size_t i = 0; i < num_coins; ++i) {
        double p_heads;
        std::cin >> p_heads;
        heads_probabilities[i] = p_heads;
    }
    std::cout << std::fixed << std::setprecision(10) << probability_of_more_heads(heads_probabilities) << std::endl;
    return 0;
}



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

void solve() 
{
    ll sum=0,n;cin>>n;
    for(int i=1;i<=n;i++){
        if(i%3&&i%5&&i%15)sum+=i;
    }cout<<sum<<endl;
}

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


Measured memory_bytes: 3640
c=[list(map(int,input().split())) for _ in range(3)]
a=[0,0,0]
b=[0,0,0]

for i in range(3):
  b[i] = c[0][i] - a[0]

for i in range(1,3):
  a[i] = c[i][0] - b[0]

for i in range(3):
  for j in range(3):
    if c[i][j] != a[i]+b[j]:
      print("No")
      exit()
print("Yes")

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
bitset<8> adj[8];
int n,m;
int ct=0,z=0;

void dfs(int x, int p) {
    //printf("%d %d\n", x, p);
    if (x==(1<<n)-1) {
        ct++;
        return;
    }
    for (int i=0; i<n; i++) {
        //printf("%d %d %d %d\n", x, p, i, adj[p][i] ? 1 : 0);
        if (!(1<<i & x) && adj[p][i]) {
            dfs(x+(1<<i),i);
        }
    }
}
 
int main() {
    scanf("%d%d", &n, &m);
    for (int i=0; i<m; i++) {
        int a,b;
        scanf("%d%d", &a, &b);
        a--; b--;
        adj[a][b]=true;
        adj[b][a]=true;
    }
    dfs(1,0);
    printf("%d\n", ct);
}

Measured memory_bytes: 256
from fractions import gcd


def prime_factorize(num): # 整数に対し素因数分解
    prime_factor = {}
    i = 2
    while i ** 2 <= num:
        while num % i == 0:
            num //= i
            if i in prime_factor.keys():
                prime_factor[i] += 1
            else:
                prime_factor[i] = 1
        i += 1
    if num > 1:
        prime_factor[num] = 1
    return prime_factor
a,b = map(int,input().split())
x = gcd(a,b)

data = prime_factorize(x)
print(len(data)+1)

Measured memory_bytes: 64620