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

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vi;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl cout<<'\n'
#define pb push_back
#define all(s) s.begin(),s.end()
#define bs binary_search

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a)*(b)/(__gcd((a),(b)))

const int Mod=1e9+7;
#define sum(a,b) (((a)%Mod)+((b)%Mod))%Mod
#define sub(a,b) (((a)%Mod)-((b)%Mod))%Mod
#define mul(a,b) (((a)%Mod)*((b)%Mod))%Mod
#define digit(x) floor((log10(x))+1)


#define count1(x) __builtin_popcount(x)

#define dbg(x) cout << #x <<":"<<x<<endl;

bool isPowerOfTwo (int x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
} 

ll pow(ll x, ll y, ll mod)
{
	int ans=1;
	while(y)
	{
		if(y&1)
			ans=(ans*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}
	return ans;
}

int main()
{
	fast;
	ll i,flag,count;
	string s,t;
	cin >> s >> t;
	string temp=t.substr(0,s.length());
	//dbg(temp);
	flag=0;
	if(temp==s)
	{
		flag=1;
	}
	if(flag)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3616
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
// #pragma comment(linker, "/stack:200000000"]
 
#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>
#include <fstream>
#include <sstream>
 
#define fr first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map 
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forln(i, l, n) for (int i = l; i < n; ++i)

#define int ll

using namespace std;

#ifdef __LOCAL
	#define dbg(x) cerr << #x << " : " << x << '\n'
	const int maxn = 20;
#else 
	#define dbg(x)
	const int maxn = 2e5 + 20;
#endif

//tg: @galebickosikasa
 
const ll inf = (ll) 2e9;
const ld pi = 3.14159265358979323846264;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

random_device rd;
mt19937 SuperRandom(rd());



signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	cin >> n;
	vector<int> goo (n);
	cinv (goo);
	hm <int, int> kek;
	for (auto& x: goo) ++kek[x];
	int ans = 0;
	for (auto& x: kek) ans += x.se * (x.se - 1) / 2;
	for (int i = 0; i < n; ++i) {
		int res = ans;
		int tmp = kek[goo[i]];
		res -= tmp * (tmp - 1) / 2;
		--tmp;
		res += tmp * (tmp - 1) / 2;
		cout << res << '\n';
	}







}

Measured memory_bytes: 9160
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn=2e5+8;
int arr[maxn];
int main()
{
	int k,n;
	scanf("%d%d",&k,&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&arr[i]);
	sort(arr+1,arr+1+n);
	int ans=1e7;
	for (int i=2;i<=n-1;i++)
	{
		if (abs(arr[i]-arr[i-1])>=abs(arr[i+1]-arr[i]))
			ans=min(ans,k-abs(arr[i]-arr[i-1]));
		else
			ans=min(k-abs(arr[i+1]-arr[i]),ans);
	}
	if (k-(arr[n]-arr[1])>=arr[2]-arr[1])
		ans=min(ans,arr[n]-arr[1]);
	else
		ans=min(ans,arr[n]-arr[1]);
	cout<<ans<<endl;
} 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
 int $(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 
signed main(){
  int a,b,d=0;
  cin>>a>>b;
  vector<pair<int,int>> c(a);
  for(int i=0;i<a;i++)
    cin>>c.at(i).first>>c.at(i).second;
  sort(c.begin(),c.end());
  for(int i=0;b>0;i++){
    if(b>=c.at(i).second){
      b-=c.at(i).second;
      d+=c.at(i).second*c.at(i).first;
    }
  else{
    d+=b*c.at(i).first;
    break;
  }
}
cout<<d<<endl;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		max = 0;
		a = new int[N];
		dfs(0);
		Console.WriteLine(max);
	}
	
	long max;
	int[] a;
	
	void dfs(int now){
		if(now == N){
			
			long sc = 0;
			for(int i=0;i<Q;i++){
				if(a[B[i]] - a[A[i]] == C[i]) sc += D[i];
			}
			if(sc > max){
				max = sc;
			}
			return;
		}
		int strt = now == 0 ? 1 : a[now - 1];
		for(int i=strt;i<=M;i++){
			a[now] = i;
			dfs(now + 1);
			a[now] = 0;
		}
	}
	
	
	int N,M,Q;
	int[] A,B,C;
	long[] D;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1]; Q = d[2];
		A = new int[Q];
		B = new int[Q];
		C = new int[Q];
		D = new long[Q];
		for(int i=0;i<Q;i++){
			d = ria();
			A[i] = d[0] - 1; B[i] = d[1] - 1; C[i] = d[2]; D[i] = d[3];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 27588
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
#define N 100007
#define pb push_back;
vector<ll> v[N];
vector<bool> vs(N);
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    ll i;
    ll sm=0;
    ll x;
    ll cnt=0;
    for(i=1;i<=5;i++)
    {
        cin>>x;
        sm+=x;
        cnt+=i;
    }
    cout<<cnt-sm;
}

Measured memory_bytes: 5900
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    long long int a=0,b=0,n,ans; //a是青色 b是红色,ans是包含的青色数目
    string s;
    cin>>n>>a>>b;
    if(a+b>n)
    {
        if(a>=n)
            ans=n;
        else
            ans=a;
    }
    else if(a+b==n)
    {
        ans=a;
    }
    else
    {
        long long int temp;
        if(n%(a+b)>=a)
            temp=a;
        else
            temp=n%(a+b);
        ans=(n/(a+b))*a+temp;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,a[101];
ll dfs(ll l,ll r,ll x,ll y){
	if(l+1==r)return 0;
	ll i,ans=1e18,xlh=x+y;
	for(i=l+1;i<r;i++)ans=min(ans,dfs(l,i,x,xlh)+dfs(i,r,xlh,y)+xlh*a[i]);
	return ans;
}
int main(){
	ll i;
	scanf("%lld",&n);
	for(i=1;i<=n;i++)scanf("%lld",&a[i]);
	printf("%lld",dfs(1,n,1,1)+a[1]+a[n]);
}
/*
发现是道较简单题 
*/

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const double PI  = acos(-1.0);
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int main()
{

    int a;
    cin >> a;
    cout << a + a * a + a * a * a;
    return 0;
}



Measured memory_bytes: 3620
package main

import (
  "fmt"
)

func main() {
  var S string
  fmt.Scan(&S)

  max := 0
  c := 0
  for i := 0; i < len(S); i++ {
    if S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] =='T' {
      c++
      if max < c {
        max = c
      }
    } else {
      c = 0
    }
  }
  fmt.Println(max)
}

Measured memory_bytes: 512
n = int(input())
A = list(map(int, input().split()))

big = -float('inf')
number = 0

for a in A:
    big = max(big, a)


ans = -float('inf')
ans_num = 0
for a in A:
    if a == big:
        continue
    number = min(a, big - a)
    if ans < number:
        ans = number
        ans_num = a
print(big, ans_num)


Measured memory_bytes: 14060
#include <iostream>
#include<cstdio>

using namespace std;

int main(void)
{
    double x_p1,y_p1,x_p2,y_p2;
    int q;
    double x_p[1000],y_p[1000];
    double x[1000],y[1000];
    
    cin>>x_p1>>y_p1>>x_p2>>y_p2;
    cin>>q;
    for(int i=0;i<q;i++)
        cin>>x_p[i]>>y_p[i];
    
    for(int i=0;i<q;i++)
    {
        x[i]=((x_p2-x_p1)*(x_p2-x_p1)*x_p[i]+(y_p2-y_p1)*(y_p2-y_p1)*x_p1+(y_p[i]-y_p1)*(x_p2-x_p1)*(y_p2-y_p1))/((y_p2-y_p1)*(y_p2-y_p1)+(x_p2-x_p1)*(x_p2-x_p1));
        if(x_p1!=x_p2)
            y[i]=((y_p2-y_p1)*(x[i]-x_p1))/(x_p2-x_p1)+y_p1;
        else
            y[i]=(-(x_p2-x_p1)*(x[i]-x_p[i]))/(y_p2-y_p1)+y_p[i];
        
        printf("%.8lf %.8lf\n",x[i],y[i]);
    }
    
    
    return 0;
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define sz          size()
#define ff          first
#define ss          second
#define mem(a,val)  memset(a, val, sizeof(a))
#define md          1000000007
#define pi          acos(-1.0)


map<ll,ll>m;
int main()
{
   ll t,n,i,j,x;

   for(i=1; i<=120; i++)
   {
       ll p=pow(i,5);
       m[i]=p;
   }
   cin>>x;
   for(int i=0; i<=120; i++)
   {
       for(int j=i; j<=120; j++)
       {
           if(m[j]-m[i]==x)
           {
               cout<<j<<" "<<i<<endl;
               return 0;
           }
           if(m[j]+m[i]==x)
           {
               cout<<j<<" -"<<i<<endl;
               return 0;
           }
       }
   }
}



Measured memory_bytes: 4112
package main

import (
	"fmt"
)

type q struct {
	data []point
}

type point struct {
	x, y int
}

func (q *q) q(v point) {
	q.data = append(q.data, v)
}

func (q *q) dq(v *point) {
	if len(q.data) > 0 {
		*v = q.data[0]
		q.data = q.data[1:]
	}
}

var h, w int

// var s, g point
var maze [][]byte
var d [][]int
var dx = [4]int{1, -1, 0, 0}
var dy = [4]int{0, 0, -1, 1}

func bfs(s []point) int {
	var q q
	for i := 0; i < len(s); i++ {
		d[s[i].y][s[i].x] = 0
		q.q(point{s[i].x, s[i].y})
	}
	longest := 0
	for len(q.data) > 0 {
		var p point
		q.dq(&p)
		for i := 0; i < 4; i++ {
			nx := p.x + dx[i]
			ny := p.y + dy[i]
			if 0 <= ny && ny < h && 0 <= nx && nx < w && d[ny][nx] == -1 && maze[ny][nx] != '#' {
				d[ny][nx] = d[p.y][p.x] + 1
				q.q(point{nx, ny})
				if d[ny][nx] > longest {
					longest = d[ny][nx]
				}
			}
		}
	}
	return longest
}

func main() {
	fmt.Scan(&h, &w)
	var starts []point
	maze = make([][]byte, h)
	d = make([][]int, h)
	for i := range maze {
		maze[i] = make([]byte, w)
		fmt.Scan(&maze[i])
		for j := 0; j < w; j++ {
			if maze[i][j] == '#' {
				starts = append(starts, point{j, i})
			}
		}
		d[i] = make([]int, w)
		for j := range d[i] {
			d[i][j] = -1
		}
	}
	fmt.Println(bfs(starts))
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define pb emplace_back

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

vector<int> prime;

void cal(){
    for(int i = 2; i <= 100; i++){
        int tmp = i;
        for(int j = 2; j <= i; j++){
            if(j == i) prime.emplace_back(i);            
            if(!(i%j)) break;
        }
    }
}

int main()
{
    cal();
    int n;
    cin >> n;
    int cnt[prime.size()]; fill(cnt,cnt+prime.size(),0);
    for(int i = 2; i <= n; i++){
        int tmp = i;
        for(int j = 0; j < prime.size(); j++){
            while(!(tmp%prime[j])){
                tmp /= prime[j];
                cnt[j]++;
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < prime.size(); i++){
        if(cnt[i] >= 74) ans++;
    }
    for(int i = 0; i < prime.size(); i++){
        for(int j = 0; j < prime.size(); j++){
            if(i == j) continue;
            if(cnt[i] >= 2 && cnt[j] >= 24) ans++;
            if(cnt[i] >= 4 && cnt[j] >= 14) ans++;
        }
    }
    for(int i = 0; i < prime.size(); i++){
        for(int j = 0; j < prime.size(); j++){
            for(int k = j+1; k < prime.size(); k++){
                if(i == j || i == k) continue;
                if(cnt[i] >= 2 && cnt[j] >= 4 && cnt[k] >= 4) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    
    n,m = map(int,input().split())
    l = list(input())[::-1]
    ans = []
    i = 0
    l[0] = 0

    while i < n+1:
        if l[i] == 0:
            a = -1
            for j in range(m,0,-1):
                if i+j < n+1 and l[i+j] != "1":
                    a = i+j
                    ans.append(j)
                    l[a] = 0
                    break
            if a == -1:
                print(-1)
                exit()
            else:
                i = a
            
            if l[-1] == 0:
                break
    
    print(*ans[::-1])

if __name__ == "__main__":
    main()


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

int W,a,b;

int main(){

	scanf("%d %d%d",&W,&a,&b);
if(a<b){
	if(a+W>=b){
		printf("0\n");
	}else{
		printf("%d\n",b-(a+W));
	}
}else{
	if(b+W>=a){
		printf("0\n");
	}else{
		printf("%d\n",a-(b+W));
	}
}

	
//	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<stdarg.h>
#include<math.h>
using ll = long long;

using namespace std;




int main()
{/*7日目*/
//少数も使いたい割り算はしない方がいい
// 数値の大きさ
//for文で0代入する場所はforの一文下
//オーバーフローする一手手前を分解して作る・ 割り算で減らしていく
//for文いつも間違える/ i<nなら最後はa[n-1]
	
	int a, b; cin >> a >> b;//aが８％ｂが１０％
	int bdot;
	bool ok=false;
	for (int i = 1; i <= 1300;i++) {
		int t = i * 0.1;
		int tt = i * 0.08;
		if(tt==a and t==b)
		{
			cout << i;
			ok = true;
			break;
		}
	}if (!ok)
		cout << "-1";

}

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

const long long MOD = 1000000007;


void solve(long long S) {
    int dp[2001] = {};
    dp[S] = 1;
    for(int i = S ; i >= 0 ; i--){
        for(int j = 3 ; i - j >= 0 ; j++){
            dp[i - j] += dp[i];
            dp[i - j] %= MOD;
        }
    }
    cout << dp[0] << endl;
}

int main() {
  long long S;
  scanf("%lld", &S);
  solve(S);
  return 0;
}


Measured memory_bytes: 3716
from collections import deque

N,M = map(int,input().split())
node = [[[],0]for i in range(N)]
for i in range(M):
    x,y = map(int,input().split())
    node[x-1][0].append(y-1)
    node[y-1][1]+=1


queue = deque([])
for i in range(N):
    if node[i][1] == 0:
        queue.append(i)
DP = [0]*N
while queue != deque([]):
    p = queue.popleft()
    for i in node[p][0]:
        node[i][1] -= 1
        DP[i] = max(DP[i],DP[p]+1)
        if node[i][1] == 0:
            queue.append(i)

print(max(DP))

Measured memory_bytes: 71200
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var nums = input.trim().split('\n').map(function(n){return +n;});
 
nums.sort(function(a,b){return a-b;});
var diff = nums[nums.length - 1] - nums[0];
console.log(diff.toFixed(3));

Measured memory_bytes: 7640
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.min

fun main(args: Array<String>) {

    // IO Templates
    val br = BufferedReader(InputStreamReader(System.`in`))
    val out = PrintWriter(System.out)

    val (n, k) = br.readLine()!!.split(' ').map { it.toInt() }

    val lrs = Array(k) { 0 to 0 }

    for (i in 0 until k) {
        val (l, r) = br.readLine()!!.split(' ').map { it.toInt() }
        lrs[i] = (l to r+1)
    }

    val dp = LongArray(n + 10)
    val dif = LongArray(n + 10)
    dp[1] = 1
    dif[2] = -1

    for (i in 1 until n) {
        for (j in 0 until k) {
            val (l, r) = lrs[j]
            if (i + l <= n) {
                dif[i + l] += dp[i]
                dif[i + l] % MyMod.MOD
            }
            if (i + r <= n) {
                dif[i + r] -= dp[i]
                dif[i + r] % MyMod.MOD
            }
            dp[i + 1] = (dp[i] + dif[i + 1]) % MyMod.MOD
        }
    }

    out.println((dp[n] + MyMod.MOD) % MyMod.MOD)

    out.flush()
}

class MyMod(var value: Long = 0L) {
    operator fun plus(a: Long) {
        value = plus(value, a)
    }

    operator fun minus(a: Long) {
        value = minus(value, a)
    }

    operator fun times(a: Long) {
        value = times(value, a)
    }

    operator fun div(a: Long) {
        value = div(value, a)
    }

    operator override fun equals(other: Any?): Boolean {
        // FIXME: 2020/08/30 定義途中
        return super.equals(other)
    }

    companion object {
        const val MOD: Long = 998244353L
        fun plus(a: Long, b: Long): Long {
            return (a % MOD + b % MOD) % MOD
        }

        fun minus(a: Long, b: Long): Long {
            return (a % MOD - b % MOD + MOD) % MOD
        }

        fun times(a: Long, b: Long): Long {
            return (a % MOD) * (b % MOD) % MOD
        }

        fun div(a: Long, b: Long): Long {
            return (a % MOD) * (pow(b, MOD - 2) % MOD) % MOD
        }

        // calc a^b
        // b <= 0 は1を返す
        fun pow(a: Long, b: Long): Long {
            var a = a
            var b = b
            var result = 1L
            a %= MOD
            while (b > 0) {
                if (b % 2 == 1L) result = result * a % MOD
                a = a * a % MOD
                b = b shr 1
            }
            return result
        }

        // calc inverse element
        fun invEle(a: Long): Long {
            return pow(a % MOD, MOD - 2) % MOD
        }
    }

}

Measured memory_bytes: 41292
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;

bool validate(int k, ll a[], ll n){
  for(int i = 0; i < k; i++){
    n -= n % a[i];
  }
  return n == 2;
}

void check(int k, ll a[]){
  ll ma = -1, mi = 10000000;
  for(int i = 2; i <= 10000000; i++){
    ll n = i;
    for(int j = 0; j < k; j++){
      n -= n % a[j];
    }
    if(n == 2){
      mi = min(mi, (ll)i);
      ma = max(ma, (ll)i);
    }
  }
  cout << to_string(mi) + " " + to_string(ma) << endl;
}

int main(){
  int k;
  cin >> k;
  ll a[k];
  for(int i = 0; i < k; i++){
    cin >> a[i];
  }

  ll min = 2, max = 2;
  bool exist = true;
  for(int i = k - 1; i >= 0; i--){
    min = a[i] * ((min + a[i] - 1) / a[i]);
    max = a[i] * (max / a[i]) + a[i] - 1;
  }

  if(validate(k, a, min) && validate(k, a, max)){
    cout << min << " " << max << endl;
  }
  else{
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
	int i,j,rank,n,card[4][13]={};
	char mark;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s ",&mark);
		scanf("%d",&rank);
		switch(mark){
			case 'S':	card[0][rank-1]=1;
					//	if(rank-1==0)	printf("S1=%d",card[0][0]);
					//	printf("mark=0 rank-1=%d\n",rank-1);
						break;
			case 'H':	card[1][rank-1]=1;
						//printf("mark=1 rank=%d\n",rank-1);
						break;
			case 'C':	card[2][rank-1]=1;
						//printf("mark=2 rank=%d\n",rank-1);
						break;
			case 'D':	card[3][rank-1]=1;
						//printf("mark=3 rank=%d\n",rank-1);
						break;	
		}
			//printf("card[0][0]=%d\n",card[0][0]);
	}
	//printf("card[0][0]=%d\n",card[0][0]);
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			if(card[i][j]!=1){
				switch(i){
					case 0:	printf("S %d\n",j+1);
							break;
					case 1:	printf("H %d\n",j+1);
							break;
					case 2:	printf("C %d\n",j+1);
							break;
					case 3:	printf("D %d\n",j+1);
							break;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 1800
/*
 * Given a DAG G, print the order of vertices after the topological sort.
 * Output
 * Print the vertices numbers in order. Print a number in a line.
 * If there are multiple possible solutions, print any one of them (the solution
 * is judged by a special validator).
 *
 * Constraints
 * 1≤|V|≤10,000
 * 0≤|E|≤100,000
 * There are no parallel edges in G
 * There are no self loops in G
 */

#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>

#define MAXN 10000
#define MAXM 100000

using namespace std;

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

  struct {
    int to, next;
  } E[MAXM];
  vector<int> LE(MAXN, -1);

  int n, m;
  cin >> n >> m;
  for (int i = 0, s, t; i < m; ++i) {
    cin >> s >> t;
    E[i] = {t, LE[s]};
    LE[s] = i;
  }

  bool visited[MAXN]{0};

  struct data {
    int id;
    bool post;
  };
  stack<data> dfs;
  stack<int> topo;
  for (int i = 0; i < n; ++i) {
    if (visited[i])
      continue;
    dfs.push({i, 0});
    while (!dfs.empty()) {
      data d = dfs.top();
      dfs.pop();
      if (visited[d.id] && !d.post)
        continue;
      if (visited[d.id] && d.post) {
        topo.push(d.id);
      } else {
        visited[d.id] = true;
        dfs.push({d.id, 1});
        for (int e = LE[d.id]; e != -1; e = E[e].next)
          if (!visited[E[e].to])
            dfs.push({E[e].to, 0});
      }
    }
  }

  while (!topo.empty()) {
    cout << topo.top() << endl;
    topo.pop();
  }
}


Measured memory_bytes: 3616
#include<stdio.h>

int main()
{
    long a,b;
    
    scanf("%ld%ld",&a,&b);
    long long x=a*b;
    long tmp;
    long r;
    if(a<b){
        tmp=a;
        a=b;
        b=tmp;
    }
    r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    printf("%ld\n",x/b);
    return 0;

}

Measured memory_bytes: 128
#pragma region Macros
#include <bits/stdc++.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()
#define SZ(x) ((int)(x).size())
#define IN(x, a, b) x >= a and x < b

using namespace std;
using ll = long long;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  FOR(i, 1, 4) {
    if (i != a and i != b) {
      cout << i << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
A = [int(i) for i in input().split()]

m = [A[0]]

mv = A[0]
for a in A[1:] :
    if a < mv :
        m.append(a)
        mv = a
    else :
        m.append(mv)

Md, Mn = 0, 0
for i in range(N - 1, 0, -1) :
    d = A[i] - m[i-1]
    if d > Md :
        Md, Mn = d, 1
    elif d == Md :
        Mn += 1
        
print(Mn)

Measured memory_bytes: 64876
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=1e5+10;
int a[maxn];
int main(){
	int n=read();
	int Min=n,Max=0;
	REP(i,1,n){
		int x=read();
		chkmin(Min,x),chkmax(Max,x);
		++a[x];
	}
	if(Max-Min>1) return printf("No\n"),0;
	if(Max==Min){
		if(Max==n-1) return printf("Yes\n"),0;
		if(Max<=n/2) return printf("Yes\n"),0;
		return printf("No\n"),0;
	}
	int u=a[Max],v=a[Min];
	if(Max-v>0 && Max-v<=u/2) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 640
import math
a,b,x=map(int,input().split())
y=(2*x)/(a*b)
if y<=a:
    rad=math.atan2(b,y)
    deg=math.degrees(rad)
    print(deg)
else:
    z=(2*x/a**2)-b
    rad=math.atan2(b-z,a)
    deg=math.degrees(rad)
    print(deg)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
const int N = 2005;
using ll = long long;
using ii = pair <int , int>;
int n,x,y,d[N][N],ans[N];
vector <int> adj[N];
bool vis[N];

void markDist() {
   for (int cn = 1 ; cn < n ; cn++) {
      memset (vis , false , sizeof vis);
      queue <ii> q;
      q.push({cn , 0});
      while (q.size()) {
         ii curr = q.front(); q.pop();
         int u = curr.fi, cd = curr.se;
         if (vis[u]) continue;
         vis[u] = true, d[cn][u] = cd;
         for (int v : adj[u]) {
            q.push({v , cd + 1});
         }
      }
   }
}

int main() {
   scanf("%d%d%d" , &n , &x , &y);
   for (int i = 1 ; i < n ; i++) {
      adj[i].pb(i + 1);
      adj[i + 1].pb(i);
   }
   adj[x].pb(y); adj[y].pb(x);
   markDist();
   for (int u = 1 ; u <= n ; u++) {
      for (int v = u + 1 ; v <= n ; v++) {
         ans[d[u][v]]++;
      }
   }
   for (int i = 1 ; i < n ; i++) {
      printf("%d\n" , ans[i]);
   }
   return 0;
}


Measured memory_bytes: 16000
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    S = [str(c) for c in input().strip()]

    ans = 0
    d = {}
    for i in range(N-1, -1, -1):
        s = S[i]
        if s in d:
            d[s] += 1
        else:
            d[s] = 1

        t = 1
        for k in d:
            if k == s:
                continue

            t *= d[k] + 1

        ans += t
    
    print(ans % (10**9 + 7))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
package main

import "fmt"

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func main() {
	nums := scanNums(2)
	if (nums[0]*nums[1])%2 == 0 {
		fmt.Println("Even")
	} else {
		fmt.Println("Odd")
	}
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true) {
			if(!sc.hasNextInt()) break;
			double a = sc.nextInt();
			double b = sc.nextInt();
			double c = sc.nextInt();
			double d = sc.nextInt();
			double e = sc.nextInt();
			double f = sc.nextInt();
			
			double x = (c*e - b*f) / (a*e - b*d);
			double y = (a*f - c*d) / (a*e - b*d);

			if(Math.abs(x)<0.001) x = 0;
			if(Math.abs(y)<0.001) y = 0;
			System.out.printf("%.3f %.3f\n",x,y);
		}
	}
}

Measured memory_bytes: 0
package main

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

// 整数 a , b , c , d が与えられます。 a ≤ x ≤ b , c ≤ y ≤ d を満たす整数 x , y について、 x × y の最大値はいくつですか。
var sc = bufio.NewScanner(os.Stdin)

func main() {
	var s string
	if sc.Scan() {
		s = sc.Text()
	}
	ss := strings.Split(s, " ")
	a := toInt(ss[0])
	b := toInt(ss[1])
	c := toInt(ss[2])
	d := toInt(ss[3])
	var result int
	ac := a * c
	result = ac
	ad := a * d
	if result < ad {
		result = ad
	}
	bc := b * c
	if result < bc {
		result = bc
	}
	bd := b * d
	if result < bd {
		result = bd
	}
	fmt.Println(result)
}


func toInt(target string) int {
	a ,_ := strconv.ParseFloat(target, 64)
	integerValue := int(a)

	if float64(integerValue) == a {
		return integerValue
	}

	if a < 0 {
		return integerValue + 1
	} else {
		return integerValue
	}
}

Measured memory_bytes: 1740
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define ll long long
#define int long long
#define pb push_back
using namespace std; 

const ll N = 1e6 + 100, OO = 1e10 + 10, M = 1e9 + 7, lg = 20;
typedef pair <int, int> pii;

int32_t main() {
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++) {
		if(i % 2 == 0 && s[i] == 'L') {
			cout << "No" << endl;
			return 0;
		}
		else if(i % 2 == 1 && s[i] == 'R') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

ll C[51][51];
ll combi(ll n, ll k) {
    if(C[n][k] != 0) return C[n][k];
    if (n == k || k == 0)
      return C[n][k] = 1;
    else {
      return C[n][k] = combi(n - 1, k - 1) + combi(n - 1, k);
    }
}
 
int main()
{
    ll n, p;cin>>n>>p;
    vector<ll> a(n);
    ll sum = 0;
    for(int i = 0; i < n; i++) {
        cin>>a[i];
        a[i] %= 2;
        sum += a[i];
    }
    ll ans = 0;
    for(ll i = p; i <= sum; i += 2){
        ans += combi(sum, i)*(ll)pow(2, n - sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define ll long long
#define FOR(i,n) for(int i=0;i<n;i++)
//map<key,value>

int main(){
  int n;
  int maxi=0;
  int semi=0;
  cin >> n;
  vector<int> a(n);
  vector<int> s(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
    s[i] = a[i];
  }
  sort(ALL(a));
  maxi = a[n-1];
  semi = a[n-2];
  for(int i=0;i<n;i++){
    if(s[i] == maxi)cout << semi << "\n";
    else cout << maxi << "\n";
  }
  return 0;
}

Measured memory_bytes: 3200
import java.util.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}.toIntArray()

fun <T> T.print() = this.also(::println)

fun main() {
	abc000X()
}

fun abc000X() {
	val s = Scanner(System.`in`)
	val a = s.nextLong()
	val b = s.next().replace(".","").toLong()
	println(a*b/100)
}


Measured memory_bytes: 41896
import java.io.*;
import java.util.StringTokenizer;

class Main {
	public static void main(String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		try {
			String buf = br.readLine();
			StringTokenizer st = new StringTokenizer(buf);

			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			int c = Integer.parseInt(st.nextToken());
			int count = 0;
			for (int i=a;i<=b;i++) {
				if (c%i==0) count++;
			}
			System.out.println(count);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  int n,m,t;
  cin >> n >> m >>t;
  int res=0;
  int a[n+1];
  for(int i=1;i<=n;i++) cin >> a[i];
  res += max(0,a[1]-m);
  for(int i=1;i<n;i++) res+= max(0,a[i+1]-a[i]-2*m);
  res+= max(0,t-a[n]-m);
  cout << res << endl;
}

Measured memory_bytes: 3204
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)

static uint32_t A[100000];

int main(void) {
	uint32_t N, K;

	scanf("%"PRIu32"\n%"PRIu32"\n", &N, &K);
	for (uint32_t idx = 0; idx < N - 1; idx++) {
		scanf("%"PRIu32"\n", &(A[idx]));
	}
	scanf("%"PRIu32, &(A[N - 1]));

	printf("%"PRIu32, 1 + (N == K ? 0 : (N - 2)/(K - 1)));

	return 0;
}


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

#define fastIO ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define ld long double
#define ll long long
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define vi vector<ll>
#define min3(a, b, c) min(a,min(b, c))
#define min4(a, b, c, d) min(a, min(b, min(c, d)))
#define max3(a, b, c) max(a,max(b, c))
#define max4(a, b, c, d) max(a, max(b, max(c, d)))
#define INF (int)1e9



int main()
{
    fastIO
    int n,k,co=0;
    cin>>n>>k;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for (int i = 0; i < k; ++i)
    {
        co+=a[i];
    }
    cout<<co;
}


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

using namespace std;

using Value = int32_t;

Value calc(Value a, Value b) {
  Value ret = -b;
  auto const n = b - a;
  for (Value i = 1; i <= n; ++i) {
    ret += i;
  }
  return ret;
}

int main() {
  Value a, b;
  std::cin >> a >> b;
  auto ret = calc(a, b);
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

limit = 10 ** 18
A = sorted(A)

total = A[0]
if total == 0:
    print(total)
    exit()

for a in A[1:]:
    total *= a
    if total > limit:
        print(-1)
        exit()
print(total)


Measured memory_bytes: 21732
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   : combinatorics NCR
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define rw freopen("graphs_as_a_service.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define rep(i,a) lp(i,0,a-1)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 2e3 + 3, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
int dp[N][N] = { };
int solve(int num, int g) {
	if (!g || !num)
		return !(g | num);
	int &ret = dp[num][g];
	if (ret != -1)
		return (ret % mod);
	ret = 0;
	ret += solve(num - 1, g);
	if (ret >= mod)
		ret %= mod;
	ret += solve(num - 1, g - 1);
	if (ret >= mod)
		ret %= mod;
	return ret;
}
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	int n, k;
	cin >> n >> k;
	clr(dp, -1);
	lp(i,1,k)
	{
		int b = solve(k, i);
		int sum = solve(n - k, i);
		sum <<= 1;
		if (sum >= mod)
			sum %= mod;
		sum += solve(n - k, i + 1);
		if (sum >= mod)
			sum %= mod;
		sum += solve(n - k, i - 1);
		if (sum >= mod)
			sum %= mod;
		cout << (sum * 1LL * b) % mod << "\n";
	}
	return 0;
}

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

using namespace std;

struct Graph {
    struct Edge {
        int u, v;
        int cost;
        Edge(int _u, int _v, int _cost) : u(_u), v(_v), cost(_cost) {}
    };
    int n, m;
    bool is_digraph;
    vector<vector<int>> g;
    vector<Edge> e;

    Graph(int _n) : n(_n), m(0) {
        assert(n >= 1);
        g.resize(n);
        set_di(false);
    }
    Graph(int _n, int _m, bool _di=false) : n(_n) {
        assert(n >= 1);
        g.resize(n);
        e.reserve(_m);
        m = 0;
        set_di(_di);
        input(_m);
    }
    void set_di(bool _di) {
        is_digraph = _di;
    }
    inline void add(int u, int v, int cost=1) {
        assert(0 <= u && u < n);
        assert(0 <= v && v < n);
        if (is_digraph) {
            //outdeg[u]++; indeg[v]++;
            g[u].emplace_back(m);

        } else {
            //deg[u]++; deg[v]++;
            g[u].emplace_back(m);
            g[v].emplace_back(m);
        }
        e.emplace_back(u, v, cost);
        m++;
    }
    void input(int _m) {
        int u, v, c;
        for (int i = 0; i < _m; i++) {
            cin >> u >> v >> c;
            u--; v--; // input 1-based
            add(u, v, c);
        }
    }
    template <typename T=int>
    vector<T> dijkstra(int s);
};

// single source shortest path
template <typename T>
vector<T> Graph::dijkstra(int s) {
    // modify T's INF
    //const int INF = 0x3f3f3f3f;
    const long long INF = 0x3f3f3f3f3f3f3f3f;
    vector<bool> trk(n, false);
    vector<T> d(n, INF);
    d[s] = 0;
    using pi=pair<T,int>;
    priority_queue<pi, vector<pi>, greater<pi>> pq;
    pq.push({0, s});
    while (!pq.empty()) {
        T dis; int u;
        tie(dis, u) = pq.top();
        pq.pop();
        if (trk[u])
            continue;
        trk[u] = true;
        for (int i: g[u]) {
            int v = e[i].u ^ e[i].v ^ u;
            if (d[v] > d[u] + e[i].cost) {
                d[v] = d[u] + e[i].cost;
                pq.push({d[v], v});
            }
        }
    }
    return d;
}

void solve() {
    int n; cin >> n;
    Graph g(n, n-1);

    int q,k;
    cin >> q >> k;
    k--;
    auto d = g.dijkstra<long long>(k);
    while (q--) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        long long res = d[x] + d[y];
        cout << res << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

const int INF = 1.5e9;

//Graph/Template
template<class T>
struct Edge{
	int from,to;
	T cost;
	Edge(int to,T cost) : to(to),cost(cost){}
	Edge(int from,int to,T cost) : from(from),to(to),cost(cost){}
};

template<class T>
using WeightedGraph = vector<vector<Edge<T>>>;
using Graph = vector<vector<int>>;
template<class T>
using Matrix = vector<vector<T>>;

//Graph/Dijkstra
template<class T>
vector<T> dijkstra(const WeightedGraph<T> &G,int source = 0){
	using P = pair<T,int>;
	vector<T> dist(G.size(),INF);
	priority_queue<P,vector<P>,greater<P>> que;
	dist[source] = 0;
	que.emplace(dist[source],source);
	while(!que.empty()){
		P p = que.top();que.pop();
		int v = p.second;
		if(dist[v] < p.first) continue;
		for(const auto &e : G[v]){
			if(dist[e.to] > dist[v] + e.cost){
				dist[e.to] = dist[v] + e.cost;
				que.emplace(dist[e.to],e.to);
			}
		}
	}
	return dist;
}

signed main(){
	int n,m,r;
	scanf("%d %d %d",&n,&m,&r);
	WeightedGraph<int> G(n);
	for(int i = 0;i < m;i++){
		int s,t,d;
		scanf("%d %d %d",&s,&t,&d);
		G[s].emplace_back(t,d);
	}
	vector<int> dist = dijkstra(G,r);
	for(int i = 0;i < n;i++){
		if(dist[i] == INF) printf("INF\n");
		else printf("%d\n",dist[i]);
	}
}



Measured memory_bytes: 15384
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>
#include <iomanip>

using namespace std;
using lint = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<int>;
using pii = pair<int, int>;
using pll = pair<lint, lint>;
using pqi = priority_queue<int>;
using pql = priority_queue<lint>;
#define mii = map<int, int>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define repf(i, f, n) for (int i = (f); i < (n); i++)
#define mp(x, y) make_pair((x), (y))
#define pb(x) push_back((x))
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define foreach(it, x) for (auto it = (x).begin(); it != (x).end(); it++)
#define space (char)0x20

constexpr lint MOD = 1e9 + 7;
int A, B, C, D, E, F, G, H, I, J, K, L, M, N;
int O, P, Q, R, S, T, U, V, W, X, Y, Z;
// string s;
// int ans = 1;
vi ans;
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	cin >> N;
    ans.resize(N);
    rep(i, N) {
        cin >> A;
        ans[A-1] = i + 1;
    }
 
    rep(i, N) {
        cout << ans[i] << space;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gc getchar
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
LL total(LL l,LL r){
	//cout<<l<<" di proses "<<r<<endl;
	if(l==r)
		return 1;
	int beda=0,last=-1;
	while((1LL<<beda)<=r)
	{
		if((l&(1LL<<beda))!=(r&(1LL<<beda)))
			last=beda;
		beda++;
	}
	assert(last!=-1);
	beda=last;
	l%=(1LL<<(beda+1));
	r%=(1LL<<(beda+1));
	LL ret=0;
	ret+=(1LL<<beda)-l;
	ret+=min((1LL<<beda),((1LL<<beda)-l)+total(0,r%(1LL<<beda)));
	//cout<<"return dari "<<l<<" "<<r<<" "<<ret<<endl;
	return ret;
}
int main()
{
	LL l,r;
	cin>>l>>r;
	cout<<total(l,r)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n,k,ans[300005],cnt,i,j;
int main(){
    scanf("%d%d",&k,&n); cnt=n;
    if(k%2==1){
        for(i=1;i<=n;i++) ans[i]=k/2+1;
        for(i=1;i<=n/2;i++){
            if(ans[cnt]==1){
				cnt--;
				continue;
			}
            ans[cnt]--;
            for(j=cnt+1;j<=n;j++) ans[j]=k;
            cnt=n;
        }
        for(i=1;i<=cnt;i++) printf("%d ",ans[i]);
        return 0;
    }
    printf("%d ",k/2);
    for(int i=2;i<=n;i++) printf("%d ",k);
    return 0;
}


Measured memory_bytes: 3456
n = int(input())
red = sorted(list(map(int, input().split())) for _ in range(n))
blue = sorted(list(map(int, input().split())) for _ in range(n))
red = sorted(red, key = lambda x:x[1])
red_used = []
pair = 0

for i in range(n):
    for j in range(n):
        if blue[i][0] > red[n-1 - j][0] and blue[i][1] > red[n-1 - j][1] and j not in red_used:
            pair += 1
            red_used.append(j)
            break

print(pair)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


LL n;
LL dp[100][2][2];

LL rec(int k,bool f,bool t){
    if(k==-1) return !t;
    if(~dp[k][f][t]) return dp[k][f][t];
    LL ret = 0;
    int x = f?((n>>k)&1):1;
    for (int i = 0; i <= x; i++) {
        if(i==0){
            ret = (ret + rec(k-1,f&(x==i),false))%mod;
            if(t){
                ret = (ret + rec(k-1,f&(x==i),true))%mod;
            }
        }
        else{
            if(!t){
                ret = (ret + rec(k-1,f&(x==i),t))%mod;
                ret = (ret + rec(k-1,f&(x==i),true))%mod;
            }
            if(t){
                ret = (ret + rec(k-1,f&(x==i),true))%mod;
            }
        }
    }
    return dp[k][f][t] = ret;
}


int main(){
    cin >> n;
    LL t = n;
    int k = 0;
    while(t){
        t >>= 1;
        k++;
    }
    memset(dp,-1,sizeof(dp));
    cout << rec(k-1,true,false) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
const int inf=0x7fffffff;
const int mod=1e9+7;
const int eps=1e-6;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
signed main()
{
    IOS;
    string s;
    cin>>s;
    for(int i=0;i<s.size()-1;i++)
    {
        if(s[i]!=s[i+1])
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <climits>
#include <math.h>
 
using namespace std;
typedef unsigned long ul;

int main() {
	string s;
	int n;
	cin>>s>>n;
	for(int i=0;i<s.length();i+=n)cout<<s[i];
	cout<<endl;
}

Measured memory_bytes: 256
import scala.io.StdIn.{readLine,readInt}

object Main extends App {
  val seq1 = for(i<-1 to 9) yield List(i,i,i)
  val seq2 = (1 to 9).iterator.sliding(3).toList

  def check(m:List[Int], count:Int,u:Int):Boolean =  {
    if(m.length != count) false
    else if(count==2) { if(m.head==m.last) true else false }
    else {
      if((u to 8).exists( i=> if(m.contains(i+1)) check(m diff seq1(i),count-3,i) else false)) true
      else (0 to 6).exists(i=> if(m.contains(i+1)) check(m diff seq2(i),count-3,u) else false)
    }
  }

  Iterator.continually(readLine).takeWhile ( _!=null ).foreach { line =>
    val l = line.map(_.asDigit).toList
    val m = (1 to 9).filter { i=> if(l.count( _==i ) >= 4) false else check(i::l,14,0) }
    if(m.length>0) println(m.mkString(" ")) else println(0)
  }
}

Measured memory_bytes: 74160
#include<bits/stdc++.h>
using namespace std;
int n, m;
int a, b, c;
int d[3];
int main(){
    scanf("%d %d %d", &d[0], &d[1], &d[2]);
    sort(d, d+3);
    printf("%d %d %d\n", d[0], d[1], d[2]);
    return 0;
}


Measured memory_bytes: 3200
#include<stdio.h>
#include<set>
#include<iostream>
using namespace std;

int main(){
    int n; cin >> n;
    set<string> s;
    string d;
    for (int i = 0; i < n; i++)
    {
        cin >> d;
        s.insert(d);
    }

    cout << s.size() <<endl;
    

    return 0;
}

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

int main() {
  int N,x=0,ans=0;
  cin >> N;
  char S[N];
  cin >> S;

  for (int i = 0; i < N; i++)
  {
    switch (S[i])
    {
    case 'I':
      x++;
      break;
    case 'D':
      x--;
      break;
    }
    ans = max(x, ans);
  }
  

  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
#define MAX 100000+10
int a[MAX];

int ss[MAX];
void isPrime()
{
	int i,j;  
    memset(a,0,sizeof(a));   
    a[0] = a[1] = 1;  
    for(i = 2; i<MAX; i++)  
    {  
        if(a[i])  
            continue;  
        for(j = i+i; j<MAX; j+=i)  
            a[j] = 1;  
    }  
}
int main()  
 {  
      
    isPrime();
    ss[0]=ss[1]=0;
    for(int i=2;i<MAX;i++)
    {
    	ss[i]=ss[i-1];
		if(!a[i]&&!a[(i+1)/2])
    	{
    		ss[i]+=1;
		}
	}
  	int n,m,t;
  	scanf("%d",&t);
  	
  	while(t--)
  	{
  		scanf("%d %d",&n,&m);
  		int sum=0;
  		if(n==m&&(!a[n]&&!a[(n+1)/2]))
  		printf("1\n");
  		else
  		{
  			int t=0;
		  	if(!a[n]&&!a[(n+1)/2])
  			t++;
  			printf("%d\n",ss[m]-ss[n]+t);
		}
	
	}
  	
 }  

Measured memory_bytes: 1408
import math
def check(x):
    return math.sqrt(x) == int(math.sqrt(x)) and x != 1

n = int(input())
a = [1]* (n +1);
for i in range(2, n+1):
    for j in range(i, n+1, i):
        if j // i != i:
            a[j] += 1
        else:
            a[j] += 2
ans = 0
for i in range(1, n):
    ans += a[n - i] if not check(n-i) else a[n-i] - 1

print(ans)


Measured memory_bytes: 81684