akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int  h, a ,b;

int main(){
  int out =0;
  scanf("%d %d %d",&h,&a,&b);
  while (1)  {
    if(h % a == 0){out++;}
    if(a == b){break;}a++;
  }
  printf("%d\n",out);
  return 0;
}


Measured memory_bytes: 2064
#include <iostream>

typedef long long ll;

#define FOR(i,a,b) for(ll i = (a);i < (b);++i)
#define REP(i,n) FOR(i,0,n)

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int main(void){

  int h;
  int hPerDay = 24;
  cin >> h;
  int rest = hPerDay -h;
  cout << hPerDay + rest << endl;
    
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        //int num[] = new int[3];
        //String s = stdIn.next();
        //char c[] = s.toCharArray();
        //boolean flag = true;
        
        System.out.println(Math.max(a + b, Math.max(a - b, a * b)));
        
        //System.out.println();
        //System.out.print();
    }
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

vvi to;

void Main(){
    int n, m; cin >> n >> m;
    to.resize(n);
    rep(i, m){
        int u, v; cin >> u >> v; u--; v--;
        to[u].pb(v);
    }
    int s, t; cin >> s >> t; s--; t--;
    
    vector<bool> checked(n, false);
    queue<P> q;
    q.push({s, 0});
    checked[s] = true;

    while(!q.empty()){
        P v = q.front(); q.pop();
        int now = v.fi;
        int cnt = v.se;
        for(auto u1 : to[now]){
            for(auto u2 : to[u1]){
                for(auto u3 : to[u2]){
                    if(u3 == t){
                        cout << cnt + 1 << endl;
                        return;
                    }
                    if(!checked[u3]) {
                        q.push({u3, cnt + 1});
                        checked[u3] = true;
                    }
                }
            }
        }
    }
    
    cout << -1 << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 8684
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n, ans=0; cin >> n;
    vector<vector<int> > a(2, vector<int>(n));
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < n; j++) cin >> a[i][j];
    }
    for(int i = 0; i <= n; i++){
        int cnt=0;
        for(int j = 0; j < i; j++) cnt += a[0][j];
        for(int j = i-1; j < n; j++) cnt += a[1][j];
        ans = max(ans, cnt); 
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] l = new int[n][4];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                l[i][j] = sc.nextInt();
                l[i][3] += l[i][j];
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < n; k++) {
                    if (i != k && l[i][j] == l[k][j]) {
                        l[i][3] -= l[i][j];
                        break;
                    }
                }
            }
        }
        for (int i = 0; i < n; i++) {
            System.out.println(l[i][3]);
        }
    }
}


Measured memory_bytes: 28968
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <iostream>

using namespace std;
typedef long long ll;
ll b,c,i,j,k,n,m,t,r,s,p;
ll arr[100005];
struct node{
	ll x,y;
};
node a[100005];
bool cmp(const struct node aa,const struct node bb){
	return aa.y<bb.y;
}
int main(){
	scanf("%lld",&n);
	for(i=0;i<n;i++){
		scanf("%lld%lld",&a[i].x,&a[i].y);
	}
	for(i=0;i<n;i++){
		b=a[i].x+a[i].y;
		if(a[i].x-a[i].y<0)
			a[i].x=0;
		else
			a[i].x=a[i].x-a[i].y;
		a[i].y=b;
	}
	sort(a,a+n,cmp);
	i=0;j=1;s=0;
	while(i<n&&j<n)
	{
		while(a[j].x<a[i].y&&i<n&&j<n)
			j++,s++;
		i=j; j=i+1;
	}
	printf("%lld",n-s);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(begin(v), end(v))
#define REV(v) reverse(begin(v), end(v))
#define VI vector<int>
#define PB(x) push_back(x)
#define SZ(x) end(x) - begin(x)
#define DEBUG(x) cerr << __LINE__ << ":" << #x << ": " << x << "\n";
//#define int long long
using namespace std;
using lint = long long;
struct Fast{Fast(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};} fast;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
inline void CO(auto &a) {REP(i, SZ(a)) cout << i << ": " << a[i] << "\n";}
//if (IO > 1e5){lint a;	scanf(%lld, &a);	printf("%lld\n", a);}

signed main(){
	int a;	cin >> a;
	if (a == 3 or a == 5 or a == 7){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(0);

    int n; cin >> n;

    map<int, int> dmp;

    for(int i = 0; i < n; i++)
    {
        int d; cin >> d;

        dmp[d]++;
    }

    int m; cin >> m;

    map<int, int> tmp;

    for(int i = 0; i < m; i++)
    {
        int t; cin >> t;

        tmp[t]++;
    }

    int fl = 1;

    for(auto& pr : tmp)
        fl &= dmp[pr.first] >= pr.second;

    if(fl) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 19072
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

a,b,c,k=l_in()

if k <= a:
    print(k)
elif k <= a+b:
    print(a)
else:
    r = k-(a+b)
    print(a-r)


Measured memory_bytes: 61668
use std::collections::HashSet;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    n: usize,
    a: [usize; n],
    q: usize,
    ms: [usize; q]
    }
    let mut map = vec![vec![]; 2005];
    for i in 0..q{
        map[ms[i]].push(i);
    }
    let sms = ms.iter().collect::<HashSet<_>>();
    let mut ans = vec!["no"; q];
    for i in 0..1 << n {
        let mut c = 0;
        for j in 0..n {
            if (1 << j) & i > 0 {
                c += a[j];
            }
        }
        if sms.contains(&c) {
            for &k in &map[c] {
                ans[k] = "yes";
            }
        }
    }

    for i in ans {
        println!("{}", i);
    }
}



Measured memory_bytes: 5036
#include<stdio.h>
int n,a[200001],yak[200001][300],yac[200001]={0};
int hab[200001]={0},b[200000]={0};

int main(){
	int i,m=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	for(i=1;i<=n;i++){
		int j,f=0;
		yak[i][yac[i]++]=1;
		if(i==1)continue;
		for(j=2;j*j<=i;j++){
			if(i%j==0){
				yak[i][yac[i]++]=j;
			}
		}
		for(j=0;j<yac[i];j++){
			if(yak[i][j]*yak[i][j]!=i)yak[i][yac[i]+j]=i/yak[i][j];
			else f=1;
		}
		yac[i]*=2;
		if(f==1)yac[i]--;
	}
	for(i=n;i>0;i--){
		if(hab[i]%2!=a[i]%2){
			b[m++]=i;
			int j;
			for(j=0;j<yac[i];j++)hab[yak[i][j]]++;
		}
	}
	if(hab[1]%2!=a[1]%2)puts("-1");
	else{
		printf("%d\n",m);
		for(i=0;i<m;i++)printf("%d ",b[i]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 237952
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int Q=1<<19;
char s[Q];
int n,m;
const int MOD=1e9+7;
inline int add(int a,int b)
{a+=b;return a>=MOD?a-MOD:a;}
inline int sub(int a,int b)
{a-=b;return a<0?a+MOD:a;}
inline int mul(int a,int b)
{return 1LL*a*b%MOD;}
int dp[Q];
void DP(int n,int lim)
{
	dp[0]=1;
	int sm=1;
	for(int i=1;i<=n;i++){
		if(i>lim)sm=sub(sm,dp[i-lim-1]);
		dp[i]=sm;
		sm=add(sm,dp[i]);
	}
}
void s1()
{
	dp[0]=1;
	int sm=0;
	for(int i=1;i<=n;i++){
		if(i>=2)sm=add(sm,dp[i-2]);
		dp[i]=sm;
	}
	int als=1;
	for(int i=2;i<=n;i++){
		als=add(als,mul(i,dp[n-i]));
	}
	printf("%d\n",als);
}
void s2(int fir)
{
	if(n&1){
		puts("0");
		return;
	}
	int mus=fir+(fir%2==0);
	for(int len=0,i=fir+2;i<=m;i++){
		if(s[i]==s[1])++len;
		else{
			if(len&1)mus=min(mus,len);
			len=0;
		}
	}
	n/=2,mus=(mus+1)/2;
	// printf("%d %d WCNM\n",n,mus);
	
	DP(n,mus);
	// for(int i=0;i<=n;i++)
		// printf("%d ????\n",dp[i]);
	int als=0;
	for(int i=1;i<=n&&i<=mus;i++){
		als=add(als,mul(2*i,dp[n-i]));
	}
	printf("%d",als);
}
int main()
{
	scanf("%d%d%s",&n,&m,s+1);
	for(int i=2;i<=m;i++)
		if(s[i]!=s[1]){
			s2(i-1);
			return 0;
		}
	s1();
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int mod(int n)
{
  if(n < 0)
    return -n;
  return n;
}
int main()
{
  int n ;
  cin>>n;
  if(n == 0)
  {
    cout<<0;
    return 0;
  }
  int arr[n];
  for(int i = 0  ; i < n ; i++)
    cin>>arr[i];
  if(n == 1)
  {
    cout<<0;
    return 0;
  }
  int brr[n];
  brr[0] = 0;
  brr[1] = mod(arr[1] - arr[0]);
  for(int i = 2; i < n ; i++)
  {
    brr[i] = min(brr[i-2] + mod(arr[i] - arr[i-2] ), brr[i-1] + mod(arr[i] - arr[i-1]));
  }
	cout<<brr[n-1];  
  
  
  
  
  
}

Measured memory_bytes: 4424
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  cin >> s >> t;
  if(s == "H")print(t);
  else{
    if(t == "H")puts("D");
    else puts("H");
  }
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c, x int // 500yen, 100yen, 50yen, sum
	fmt.Scan(&a, &b, &c, &x)

	res := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if (i*500 + j*100 + k*50) == x {
					res++
				}
			}
		}
	}

	fmt.Println(res)
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
# define  max 200
int d,n;
int t[max];
int a[max],b[max],c[max];
bool suit[max][max];
int dp[max][max];

int main(){
  scanf("%d %d",&d,&n);
  for(int i=0;i<d;i++){
    scanf("%d",&t[i]);
  }
  for(int j=0;j<n;j++){
    scanf("%d %d %d",&a[j],&b[j],&c[j]);
  }
  for(int i=0;i<d;i++){
    for(int j=0;j<n;j++){
      suit[i][j]=(t[i]>=a[j]&&t[i]<=b[j]);
    }
  }
   for(int i=0;i<d;i++){
   	for(int j=0;j<n;j++){
   		dp[i][j]=-1;
   	}
   }
   for(int j=0;j<n;j++){
   	  if (suit[0][j]==true) {
		dp[0][j]=0;
	}
   }
   for(int i=0;i<d-1;i++){
   	for(int j=0;j<n;j++){
   		if(dp[i][j]>=0){
   			for(int k=0;k<n;k++){
   				if(suit[i+1][k]==true){
   				  if(dp[i+1][k]<dp[i][j]+abs(c[j]-c[k])){
   				  	dp[i+1][k]=dp[i][j]+abs(c[j]-c[k]);
   				  }	
   				}
   			}
   		}
   		}
   	}
   	int ans=-1;
  for(int i=0;i<n;i++){
  	if(ans<dp[d-1][i]){
  		ans=dp[d-1][i];
  	}
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef string str;
const long long INF = INT64_MAX / 2;

#define REP(i, n) for(ll i=0;i<n;i++)
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

void solve() {
    str S;
    cin >> S;
    if(S.size() != 26){
        str t = S;
        char mc = '\0';
        UNIQ(t);
        for(char c = 'a'; c <= 'z'; c++) {
            bool f = true;
            for(auto &d:S) {
                if(c == d) {
                    f = false;
                    break;
                }
            }
            if(f){
                mc = c;
                break;
            }
        }
        cout << S + mc << endl;
    }else {
        str T = S;
        bool f = next_permutation(S.begin(), S.end());
        if(!f) {
            cout << -1 << endl;
        }else {
            for (int i = 0; i < 26; i++)
            {
                if(S[i] != T[i]) {
                    S.erase(S.begin() + i + 1, S.end());
                    break;
                }
            }
            cout << S << endl;
        }
    }
}

int main() {
    FIO;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

std::vector<std::vector<LL>>G(212345);
std::vector<bool>vis(212345, false);

std::pair<LL, LL> dfs(LL v)
{
	if (vis[v]) return { 0,0 };
	vis[v] = true;
	std::pair<LL, LL>res;
	if (v <= 100000) res.first = 1;
	else res.second = 1;
	for (LL u : G[v])
	{
		auto temp = dfs(u);
		res.first += temp.first;
		res.second += temp.second;
	}
	return res;
}

int main()
{
	LL N;
	in >> N;
	std::vector<LL>x(N), y(N);
	rep(i, N) in >> x[i] >> y[i];

	LL ans = 0;
	rep(i, N)
	{
		y[i] += 100000;
		G[x[i]].push_back(y[i]);
		G[y[i]].push_back(x[i]);
	}
	for (LL i = 1; i <= 200000; ++i)
	{
		auto res = dfs(i);
		ans += res.first * res.second;
	}
	ans -= N;

	out << ans << std::endl;
}


Measured memory_bytes: 12928
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	int a, b, c;
	int ans = 0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++) {
		if (c%i == 0) {
			ans++;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

const int N = 3003;
double dp[N][N], a[N];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lf", &a[i]);
		//printf("%lf ", a[i]);
	}
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= i; j++) {
			if (j == 0) {
				dp[i][j] = dp[i-1][j] * (1.0 - a[i]);
			} else {
				dp[i][j] = (dp[i-1][j-1] * a[i]) + (dp[i-1][j] * (1.0 - a[i]));
			}
		}
	}
	double res = 0;
	for (int i = n / 2 + 1; i <= n; i++) {
		//dp[n][n] += dp[n][i];
		res += dp[n][i];
	}
	//printf("%lf", dp[n][n]);
	printf("%.9lf", res);
	return 0;
}


Measured memory_bytes: 68992
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  int64_t result = 0;
  for (int i = 1; i < N; ++i) {
    if (x < a[i - 1] + a[i]) {
      result += (a[i - 1] + a[i] - x);
      a[i] = max(x - a[i - 1], 0);
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>

#include <string>
#include <vector>
#include <algorithm>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAXN 10004
int N;
string handles[MAXN];

string replace(string S, char c) {
   REP(i, SZ(S))
      if (S[i] == '?')
         S[i] = c;
   return S;
}


int compare(const string& a, const string b) {
   string aa = replace(a, 'a');
   string az = replace(a, 'z');
   string ba = replace(b, 'a');
   string bz = replace(b, 'z');

   if (az < ba) return -1;
   if (bz < aa) return +1;
   
   return 0;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(NULL);

   cin >> N;
   REP(i, N)
      cin >> handles[i];

   string T;
   cin >> T;

   int L = 1, R = N+1;
   REP(i, N) {
      int cmp = compare(T, handles[i]);
   // cerr << i << ": " << cmp << endl;
      if (cmp < 0)
         --R;
      else if (cmp > 0)
         ++L;
   }
   //cerr << L << ' ' << R << endl;

   FOR(i, L, R) {
      if (i > L) cout << ' ';
      cout << i;
   }
   cout << endl;

   return 0;
}


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


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

	string s,t;
	cin >> s >> t;
	if(t.size()!= s.size()+1){
		cout << "No";
	}
	else{
		bool p = true;
		for(int i =0;i<s.size();i++){
			if(s[i]!=t[i]){
				p = false;
				break;
			}
		}
		if(p) cout <<"Yes";
		else cout << "No";
	}


	
}


Measured memory_bytes: 3608
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        Map<Integer, Integer> m = new HashMap<>();
        for (int i = 0; i < 9; i++) {
            m.put(i, 0);
        }
        for (int i = 0; i < n; i++) {
            int a = s.nextInt();
            int t = a / 400;
            if (t >= 9) {
                t = 8;
            }
            m.put(t, m.get(t) + 1);
        }
        int min = 0;
        for (int i = 0; i < 8; i++) {
            if (m.get(i) != 0) {
                min++;
            }
        }
        int max = min + m.get(8);
        if (min == 0 && m.get(8) != 0) {
            min = 1;
        }
        System.out.printf("%s %s", min, max);
    }
}


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

signed main(void)
{
	long long num; cin >> num;
	
	cout << num << ":";
	
	for (int i = 2; i*i <= num; ++i)
		while (num % i == 0)cout << " " << i, num /= i;
	
	if (num != 1)cout << " " << num; cout << endl;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
const int N=2e3+10;
const int MOD=1e9+7;
int n,m,a[N],b[N],dp[N][N];

int main()
{
	cin>>n>>m;
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=m;i++) scanf("%d",&b[i]);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++) {
			dp[i][j]=((dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1])%MOD+MOD)%MOD;
			if (a[i]==b[j]) dp[i][j]=(dp[i][j]+dp[i-1][j-1]+1)%MOD;
		} 
	cout<<(dp[n][m]+1)%MOD<<endl;	
	return 0;
}

Measured memory_bytes: 16000
#include <stdio.h>
/*At Corder Beginner Contest137 A問題*/

int main(void)
{
  int A,B;
  int cal;
  int max;

  scanf("%d%d",&A,&B );
  max=A+B;
  if(max<A*B)max=A*B;
  if(max<A-B)max=A-B;

  printf("%d\n",max );

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
	int n,m,a;
	cin>>n>>m;
	lol(i,m)cin>>a;
	cout<<n-m-1<<endl;
	return 0;
}

Measured memory_bytes: 3068
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        
        new Main().q1();
    }
    
    
    public void q1(){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(b-a==c-b){
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
        
    }
    
  
    
    
}



Measured memory_bytes: 21844
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)
	s, t := []byte(getString()), []byte(getString())

	S := make([]int, len(s))
	for i := 0; i < len(s); i++ {
		S[i] = int(s[i])
	}

	T := make([]int, len(t))
	for i := 0; i < len(t); i++ {
		T[i] = int(t[i])
	}

	sort.Ints(S)
	sort.Sort(sort.Reverse(sort.IntSlice(T)))

	// out(string(t), string(s))
	L := min(len(S), len(T))
	for i := 0; i < L; i++ {
		if S[i] > T[i] {
			out("No")
			return
		} else if S[i] < T[i] {
			out("Yes")
			return
		}
		// out(i, ":", string(S[i]), string(T[i]))
	}
	if len(T) > L {
		out("Yes")
		return
	}
	out("No")
}


Measured memory_bytes: 640
import sys

def main(inp):
    dna=list(next(inp))[0]
    
    if(dna=='A'):
        return "T"
    elif(dna=='T'):
        return "A"
    elif(dna=='C'):
        return "G"
    elif(dna=='G'):
        return "C"
      
print(main(sys.stdin))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

using Int = __int128_t;
Int abs128(Int val){return val<0?-val:val;}

ostream &operator<<(ostream &os,Int val){
  if(ostream::sentry(os)){
    __uint128_t tmp=abs128(val);
    char buf[64];
    char *d=end(buf);
    do{
      --d;
      *d=char(tmp%10+'0');
      tmp/=10;
    }while(tmp);
    if(val<0) *--d='-';
    int len=end(buf)-d;
    if(os.rdbuf()->sputn(d,len)!=len){
      os.setstate(ios_base::badbit);
    }
  }
  return os;
}

istream &operator>>(istream &is,Int &val){
  string s;
  is>>s;
  val=0;
  for(int i=0;i<(int)s.size();i++)
    if(isdigit(s[i])) val=val*10+s[i]-'0';
  if(s[0]=='-') val*=-1;
  return is;
}

struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

using D = long double;

struct frac{
  Int num,dom;
  frac(){}
  frac(Int num,Int dom):num(num),dom(dom){
    if(num==0){
      dom=1;
    }else{
      Int tmp=__gcd(num,dom);
      num/=tmp;
      dom/=tmp;
    }
  }
  frac norm(){
    if(num==0) return frac(0,1);
    Int tmp=__gcd(num,dom);
    return frac(num/tmp,dom/tmp);
  }
  frac operator+(frac a){return frac(num*a.dom+a.num*dom,dom*a.dom).norm();}
  frac operator-(frac a){return frac(num*a.dom-a.num*dom,dom*a.dom).norm();}
  frac operator*(frac a){return frac(num*a.num,dom*a.dom).norm();}
  frac operator/(frac a){return frac(num*a.dom,dom*a.num).norm();}
  
  bool operator<(const frac a)const{
    return num*a.dom<a.num*dom;
  }
  bool operator>(const frac a)const{
    return num*a.dom>a.num*dom;
  }
  bool operator==(const frac a)const{
    return num*a.dom==a.num*dom;
  }
  bool operator!=(const frac a)const{
    return num*a.dom!=a.num*dom;
  }
  bool operator<=(const frac a)const{
    return num*a.dom<=a.num*dom;
  }
  bool operator>=(const frac a)const{
    return num*a.dom>=a.num*dom;
  }
  
  D d(){return sqrt(D(num)/D(dom));}
};

//INSERT ABOVE HERE
signed main(){
  Int T;
  Int n;
  cin>>T>>n;
  vector<Int> xs(n),ls(n),hs(n);
  for(Int i=0;i<n;i++) cin>>xs[i]>>ls[i]>>hs[i];
  
  auto getA=[&](Int x,Int y)->frac{
              return frac(y*(2*T*T),x*T-x*x);              
            };
  auto cost=[&](D a)->D{
              return sqrt((T/a)*(T/a)+(a/2)*(a/2));
            };

  frac mA(2*T,1);

  using P = pair<frac, frac>;
  vector<P> vl,vm,vr;
  for(Int i=0;i<n;i++){
    frac l=getA(xs[i],ls[i]);
    frac h=getA(xs[i],hs[i]);
    
    if(h<mA) vl.emplace_back(h,l);
    else if(mA<l) vr.emplace_back(l,h);
    else vm.emplace_back(l,h);
  }

  sort(vl.begin(),vl.end());
  sort(vr.rbegin(),vr.rend());
  
  D ans=0;
  frac ll(0,1),lr(0,1);  
  for(auto p:vl){
    if(ll!=frac(0,1)&&p.second<=ll) continue;
    ll=p.first;
    ans+=cost(ll.d());
  }
  for(auto p:vr){
    if(lr!=frac(0,1)&&p.second>=lr) continue;
    lr=p.first;
    ans+=cost(lr.d());
  }
  for(auto p:vm){
    if(ll!=frac(0,1)&&p.first <=ll) continue;
    if(lr!=frac(0,1)&&p.second>=lr) continue;
    ans+=cost(mA.d());
    break;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 19252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const double pi = 3.141592653589793;



int main(){
    ll N;
    cin>>N;
    ll P, W, G, Y;
    P=0;
    W=0;
    G=0;
    Y=0;
    vector<char> S(N);
    rep(i, N){
        cin>>S[i];
        if(S[i]=='P')P++;
        if(S[i]=='W')W++;
        if(S[i]=='G')G++;
        if(S[i]=='Y')Y++;
    }
    ll Ans=0;
    if(P)Ans++;
    if(W)Ans++;
    if(G)Ans++;
    if(Y)Ans++;
    if(Ans==3)cout<<"Three"<<endl;
    if(Ans==4)cout<<"Four"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_Node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
    fastIO;
    ll n;
    cin>>n;
    pair<ll,ll>p[n];
    for(int i=0;i<n;i++)
    {
        cin>>p[i].fi>>p[i].se;
    }
    vector<ll>v(n);
    for(int i=0;i<n;i++)
    {
        if(p[i].fi==p[i].se)
        {
            v[i]=1;
        }
    }
    for(int i=0;i<n-2;i++)
    {
        int fl=0;
        for(int j=i;j<i+3;j++)
        {
            if(v[j]==0)
            {
                fl=1;
            }
        }
        if(!fl)
        {
            cout<<"Yes\n";
            goto end;
        }
    }
    cout<<"No\n";
    end:;
}


Measured memory_bytes: 3620
function main()
	lines=readlines()
	H,W,D=map(x->parse(Int,x),split(shift!(lines)))
	id=Array{Pair{Int,Int}}(H*W)
	for i=1:H
		A=map(x->parse(Int,x),split(shift!(lines)))
		for j=1:W
			id[A[j]]=i=>j
		end
	end
	dp=zeros(Int,H*W)
	for i=1:H*W
		if i>D
			dp[i]=dp[i-D]+abs(id[i].first-id[i-D].first)+abs(id[i].second-id[i-D].second)
		end
	end
	Q=parse(Int,shift!(lines))
	for i=1:Q
		L,R=map(x->parse(Int,x),split(shift!(lines)))
		println(dp[R]-dp[L])
	end
end
main()


Measured memory_bytes: 212100
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int givenNumber = scanner.nextInt();
        int[] array = new int[givenNumber];
        for(int i=0; i<givenNumber; i++) {
            array[i] = scanner.nextInt();
        }
        Arrays.sort(array);
        System.out.println(array[array.length-1]-array[0]);
    }
}


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

using namespace std;

int N;
vector<queue<int>> A;
vector<int> days;
list<int> remain;

int solve() {
  bool changed = true;
  int max_days = 0;
  for (; changed;) {
    changed = false;
    for (auto it = remain.begin(); it != remain.end();) {
      auto i = *it;
      if (A[i].empty()) {
        it = remain.erase(it);
      } else {
          auto opponent = A[i].front();
          if (i == A[opponent].front()) {
            changed = true;
            int day = max(days[i], days[opponent]) + 1;
            days[i] = days[opponent] = day;
            max_days = max(max_days, day);
            A[opponent].pop();
            A[i].pop();
            continue;
          }
        ++it;
      }
    }
    if (remain.empty()) {
      return max_days;
    }
  }
  return -1;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N;
  A.resize(N + 1);
  days.resize(N + 1);

  for (int i = 1; i <= N; ++i) {
    remain.emplace_back(i);
    for (int j = 0; j < N - 1; ++j) {
      int aii;
      cin >> aii;
      A[i].push(aii);
    }
  }
  cout << solve() << endl;
}



Measured memory_bytes: 4736
N = int(input())
A = map(int, input().split())

a =[]

for i in A:
  if i%2 == 0:
    a.append(i)
    
count = 0

for j in a:
  if j%3==0 or j%5==0:
    continue
  else:
    count +=1

print("APPROVED" if count ==0 else "DENIED")


Measured memory_bytes: 2940
import java.util.*;
public class Main {
     static int getTheNumberOfCoin(int C[],int n,int m){
    	 int T[] = new int[n + 1];
    	 for(int i = 1;i < n + 1;i++){
    		 T[i] = T[i - 1] + C[0];
    	 }
    	 for(int i = 0;i < m;i++){
    		 for(int j = C[i];j < n + 1;j++){
    			 if(T[j] < T[j - C[i]] + 1){
    				 T[j] = T[j];
    			 }else{
    				 T[j] = T[j - C[i]] + 1;
    			 }
    		 }
    	 }
    	 return T[n];
     }
     public static void main(String[] args) {
    	 Scanner in = new Scanner(System.in);
    	 int n = in.nextInt();
    	 int m = in.nextInt();
    	 int C[] = new int [m]; 
    	 for(int i = 0;i < m;i++){
    		 C[i] = in.nextInt();
    	 }
    	 int min = getTheNumberOfCoin(C,n,m);
    	 System.out.println(min);
     }
}

Measured memory_bytes: 20368
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, a, x[550];
LL dp[55][55][2550];

int main() {
	cin >> n >> a;
	REP(i, n)cin >> x[i];
	dp[0][0][0]=1;
	REP(i, n) {
		REP(j, n) {
			REP(k, 2500) {
				dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
				dp[i + 1][j][k] += dp[i][j][k];
			}
		}
	}
	LL ans = 0;
	REP(i, n+1) {
		if(i)ans += dp[n][i][i*a];
	}
	cout << ans << endl;
}

Measured memory_bytes: 56448
import math as mt
N = int(input())

if N % 2 == 1 or N < 2:
    print(0)
    exit()

r = 0
L = int(mt.log(N,5))
for i in range(1,L+1):
    p = N//(5**i)//2
    r += p
    #print(N,5**i,p)
print(r)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0288
{
    class Tool
    {
        public int Attack { get; set; }
        public int Exp { get; set; }
        public int Requirement { get; set; }
        public Tool(int[] vs)
        {
            Attack = vs[0];
            Exp = vs[1];
            Requirement = vs[2];
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] dn = RArInt();
                if (dn.Sum() == 0) break;

                Tool[] tools = new Tool[dn[1]];
                for (int i = 0; i < dn[1]; i++) tools[i] = new Tool(RArInt());

                int[,] dp = new int[dn[0] + 1, 101];
                for (int i = 0; i < dp.GetLength(0); i++)
                {
                    for (int j = 0; j < dp.GetLength(1); j++)
                    {
                        dp[i, j] = int.MaxValue;

                    }
                }
                dp[0, 0] = 0;

                int maxI = dp.GetLength(0);
                int maxJ = dp.GetLength(1);

                for (int i = 0; i < maxI; i++)
                {
                    for (int j = 0; j < maxJ; j++)
                    {
                        if (dp[i, j] == int.MaxValue) continue;
                        foreach (var tool in tools)
                        {
                            if (j >= tool.Requirement)
                            {
                                int nextI = i + tool.Attack;
                                int nextJ = j + tool.Exp;
                                dp[Math.Min(nextI, maxI - 1), Math.Min(nextJ, maxJ - 1)] = Math.Min(dp[Math.Min(nextI, maxI - 1), Math.Min(nextJ, maxJ - 1)], dp[i, j] + 1);
                            }
                        }
                    }
                }

                int res = int.MaxValue;
                for (int i = 0; i < maxJ; i++)
                {
                    res = Math.Min(res, dp[maxI - 1, i]);
                }
                Console.WriteLine(res == int.MaxValue ? "NA" : res.ToString());

            }

        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 19772
flag = 0
a = []
for i in range(3):
    a.append(list(map(int,input().split())))

n = int(input())

hit = []
for j in range(n):
    hit.append(int(input()))


for k in hit:
    for l in a:
        if k in l:
          l[l.index(k)] = 0

for m in a:
    if m == [0,0,0]:
        flag = 1

for i in range(3):
    if a[0][i] == a[1][i] == a[2][i] == 0:
        flag = 1

if a[0][0] == a[1][1] == a[2][2] == 0:
    flag = 1

if a[0][2] == a[1][1] == a[2][0] == 0:
    flag = 1
    
if flag == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
#define N 10210
#define INF 0xfffffff

int cnt, Head[N], num[N], vis[N];
int fhead[N],fnum[N];
long long  dist[N];
int n, m, p;

struct Edge
{
    int v, w, next;
}e[N],fe[N];

void Add(int u, int v, int w)
{
    e[cnt].v = v;
    e[cnt].w = w;
    e[cnt].next = Head[u];
    Head[u] = cnt;
    swap(u,v);
    fe[cnt].v = v;
    fe[cnt].w = w;
    fe[cnt].next = fhead[u];
    fhead[u] = cnt++;
}
int F[N];
bool spfa()///spfa模板；
{
    memset(vis, 0, sizeof(vis));
    memset(num, 0, sizeof(num));
    queue<int>Q;
    vis[1] = 1;
    dist[1] = 0;
    Q.push(1);
    num[1]++;
    while(Q.size())
    {
        int p=Q.front();
        Q.pop();
        vis[p] = 0;
        for(int i=Head[p]; i!=-1; i=e[i].next)
        {
            int q = e[i].v;
            if(dist[q] > dist[p] + e[i].w&&F[q])
            {
                dist[q] = dist[p] + e[i].w;
                if(!vis[q])
                {
                    vis[q] = 1;
                    Q.push(q);
                    num[q] ++;
                    if(num[q]>n)
                        return true;
                }
            }
        }
    }
    return false;
}
void dfs(int root){
    F[root]=1;
    int t=fhead[root];
    while(t!=-1){
        if(!F[fe[t].v]) dfs(fe[t].v);
        t=fe[t].next;
    }
}
int main()
{
    ios::sync_with_stdio(false);
    memset(dist,0x7f,sizeof(dist));
    cin>>n>>m>>p;
    memset(Head,-1,sizeof(Head));
    memset(fhead,-1,sizeof(fhead));
    for(int i=1;i<=m;i++){
        int a,b,c; cin>>a>>b>>c;
        c-=p; c=-c;
        Add(a,b,c);
    }
    dfs(n);
    int res=spfa();
    if(res) cout<<-1;
    else cout<<max(0ll,-dist[n]);
    return 0;
}

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

int main() {
    int N,M;
    cin >> N >> M;

    vector<int> a(M);
    vector<int> b(M);
    vector<int> n(N);
    
    for (int i=0;i<M;i++) cin>>a.at(i)>>b.at(i);
    for (int i=0;i<N;i++) {
        n.at(i) = 0;
        for (int j=0;j<M;j++){
            if (a.at(j)==i+1) n.at(i)++;
            if (b.at(j)==i+1) n.at(i)++;
        }
        cout << n.at(i) << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  int P[M],Y[M];
  REP(i,M)cin>>P[i]>>Y[i];
  map<int,int> m[100000];
  REP(i,M)m[P[i]-1][Y[i]]=0;
  REP(i,N){
    int j=1;
    for(auto& k:m[i]){
      k.second=j;
      j++;
    }
  }
  REP(i,M){
    cout<<setfill('0')<<setw(6)<<P[i]<<setfill('0')<<setw(6)<<m[P[i]-1][Y[i]]<<endl;
  }
  return 0;
}


Measured memory_bytes: 9976
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int D, G;
int p[10], c[10];

int main(void){
    cin >> D >> G;
    for(int i = 0; i < D; i++){
        cin >> p[i] >> c[i];
    }

    int res = INF;

    for(int i = 0; i < 1<<D; i++){
        int sum = 0;
        int num = 0;
        for(int j = 0; j < D; j++){
            if(i>>j & 1){
                sum += 100 * (j+1) * p[j] + c[j];
                num += p[j];
            }
        }

        if(sum >= G){
            res = min(res, num);
        }else{
            for(int j = D - 1; j >= 0; j--){
                if(i>>j & 1) continue;

                if(G - sum <= 100 * (j+1) * (p[j] - 1)){
                    while(sum < G){
                        sum += 100 * (j+1);
                        num++;
                    }
                    res = min(res, num);
                }else{
                    break;
                }
            }
        }
    }

    cout << res << '\n';

    return 0;
}

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

#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)

#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FFE(i,L,R) for (int i = L; i >= R; i--)

#define wez(n) int (n); cin >> n
#define wez2(n,m) int (n),(m); cin >> n >> m
#define wez3(n,m,k) int (n),(m),(k); cin >> n >> m >> k

#define whileZ int T; cin >> T; while(T--)

#define ALL(c) (c).begin(),(c).end()
#define ll long long 
#define ull unsigned long long
#define ld long double

#define fi first
#define se second

// for debug
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
#define printV(a) if(a.size()) printA(a,0,a.size()-1)

#define pb push_back
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> ii;
//  priority_queue <int, vector<int>, greater<int> > pq; // min heap

int n, m;
int par[200005];
int r[200005];
int sz[200005];
int ans;

int gp(int x) {
    if(x==par[x]) return x;
    return par[x] = gp(par[x]);
}
bool join(int a, int b) {
    a=gp(a); b=gp(b);
    if (a==b) return 0;
    if (r[a]<r[b]) swap(a,b);
    if (r[a]==r[b]) r[a]++;
    par[b] = a;
    return 1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin >> n >> m;
    FE(i,1,n) par[i]=i, r[i]=1;

    for (int i=0; i<m; i++) {
        wez2(a,b);
        join(a,b);
    }

    for (int i=1; i<=n; i++)
        ans = max(ans, ++sz[gp(i)]);

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 5868
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int X; cin >> X;
    X %= 7;

    vector<string> day = {"thu", "fri", "sat", "sun", "mon", "tue", "wed"};
    cout << day[X] << endl;
    return 0;
}



Measured memory_bytes: 3184
def resolve():
    N, K = list(map(int, input().split()))
    P = list(map(int, input().split()))
    total = 0
    ans = 0
    for i in range(N):
        if i < K:
            total += (P[i]+1)/2
            if i == K-1:
                ans = max(ans, total)
        else:
            total -= (P[i-K]+1)/2
            total += (P[i]+1)/2
            ans = max(ans, total)
    print(ans)
        

if '__main__' == __name__:
    resolve()


Measured memory_bytes: 91948
fun main(args: Array<String>) {
    val (N, A) = readLine()!!.split(" ").map { it.toInt() }
    val x = readLine()!!.split(" ").map { it.toLong() }.toLongArray()
    val max = 50 * 50
    val dp = Array(N + 1) { Array(N + 1, { LongArray(max + 1, { 0}) })}
    for (i in 0..N) {
        dp[i][0][0] = 1
    }

    for (i in 1..N) {
        for (k in 1..N) {
            for (j in 0..max) {
                dp[i][k][j] =
                                dp[i - 1][k][j] +
                        dp[i-1][k-1].getOrElse((j - x[i-1]).toInt(), { 0 })
            }
        }
    }

    var answer = 0L
    for (i in 1..N) {
        val trg = A * i
        answer += dp[N][i][trg]
    }

    println(answer)
}

Measured memory_bytes: 112636
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
using namespace std;
#define NUM 1000000
int main(){
	long int n;
	int p[NUM],i,j,k,a,b;
	for(i=0;i<NUM;i++){
		p[i]=0;
	}
	for(i=2;i<NUM;i++){
		if(p[i]==0){
			p[i]=2;
			for(j=2;j<=(NUM/i);j++){
				p[i*j]=1;
			}
		}	
	}
	while(cin>>n){
		a=0;
		for(i=2;i<=n;i++){
			if(p[i]==2)a++;
		}
		cout<<a<<endl;
	}

    return 0;
}

Measured memory_bytes: 5064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
//const long long MOD = 1000000007LL;
const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,M; cin >> N >> M;
    vector<vector<int>> G(N);
    rep(i,M) {
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    vector<int> dist(N,-1);
    dist[0] = 0;
    queue<int> que;
    que.emplace(0);
    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (auto nv : G[v]) {
            if (dist[nv] != -1) {
                if (dist[nv]%2 != (dist[v]+1)%2) {
                    cout << N*(N-1)/2 - M << endl;
                    return 0;
                }
                continue;
            }
            dist[nv] = dist[v]+1;
            que.emplace(nv);
        }
    }

    ll odd = 0, even = 0;
    rep(i,N) {
        if (dist[i]%2==0) even++;
        else odd++;
    }
    cout << odd*even - M << endl;
}


Measured memory_bytes: 6272
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int S[1000], top = 0;
void push(int);
int pop();
int main()
{
    int x, y, z;
    char s[100];

    while (scanf("%s", s) != EOF)
    {
        if (s[0] == '+')
        {
            push(pop() + pop());
        }
        else if (s[0] == '-')
        {
            x = pop();
            y = pop();
            push(y - x);
        }
        else if (s[0] == '*')
        {
            push(pop() * pop());
        }
        else
        {
            push(z = atoi(s));
        }
    }
    printf("%d\n", pop());

    return 0;
}
void push(int x)
{
    S[++top] = x;
}

int pop()
{
    top--;
    return S[top + 1];
}


Measured memory_bytes: 2044