akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n, x;
    cin >> n >> x;
    vi a(n);
    rep(i, n) cin >> a[i];
    a.push_back(x);
    sort(all(a));
    vi b;
    rep(i, n) b.push_back(a[i+1] - a[i]);
    int ans = b[0];
    rep(i, n) ans = __gcd(ans, b[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1528
#include <stdio.h>
#include <math.h>

int main(int argc, char** argv)
{
    int n,k;

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

    // log_k(n)
    // log(n)/log(k)
    printf("%d\n", (int)(log(n)/log(k))+1);

    return 0;
}


Measured memory_bytes: 2348
import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    var k=scan.nextLine().toInt()
    var s =scan.nextLine()

    if(s.length>k)
    {
        var q = s.substring(0,k)
        println(q + "...")
    }
    else
        println(s)
}


Measured memory_bytes: 36420
# -*- coding: utf-8 -*-
import numpy as np

def main():
    i=list(map(int, input().split()))
    coin=0
    if (i[0]<i[1]):
        coin =coin+i[1]
        i[1] =i[1]-1
    else:
        coin = coin + i[0]
        i[0] = i[0] - 1
    if (i[0] < i[1]):
        coin = coin + i[1]
        i[1] = i[1] - 1
    else:
        coin = coin + i[0]
        i[0] = i[0] - 1
    print(coin)

if __name__ == '__main__':
    main()

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

int main()
{
  int N;

  cin >> N;
  if (N / 100 == 7 || (N / 10) % 10 == 7 || N % 10 == 7)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		
        Scanner sc= new Scanner(System.in);
        
        int a=sc.nextInt();
        int b=sc.nextInt();
        
        if(a>b)
        System.out.println("a > b");
        else if(a==b)
        System.out.println("a == b");
        else
        System.out.println("a < b");
 
}

}


Measured memory_bytes: 26100
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

using namespace std;
typedef long long LL;
typedef pair<LL, LL> LLLL;

LLLL solve(LL x) {
	map<LL, LL> m;
	for (LL i = -2000; i < 2000; ++i) {
		m[i * i * i * i * i] = i;
	}
	for (auto kv : m) {
		LL y = kv.first - x;
		if (m.find(y) != m.end()) {
			return LLLL(-m[y], -kv.second);
		}
	}
	return { 0,0 };
}

int main(int argc, char* argv[]) {
	LL x = -1;
	cin >> x;
	LLLL ans = solve(x);
	cout << ans.first << " " << ans.second << endl;
	return 0;
}


Measured memory_bytes: 3880
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

#define abs(N) ((N>0)?N:-1*N)
//#define min(A,B) ((A>B)?B:A)
//#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

#define M_PI 3.14159265358979

#define TOP 0
#define SOUTH 1
#define EAST 2
#define WEST 3
#define NORTH 4
#define BOTTOM 5

class Dice {
public:

	Dice(int args[]){
		for (int i = 0; i < 6; ++i) {
			labels[i] = args[i];
		}
	}
	void move(char d){
		int tmp[6];
		for (int i = 0; i < 6; ++i) {
			tmp[i] = labels[i];
		}

		switch(d){
	    case 'N':
	      labels[TOP] = tmp[SOUTH];
	      labels[SOUTH] = tmp[BOTTOM];
	      labels[BOTTOM] = tmp[NORTH];
	      labels[NORTH] = tmp[TOP];
	      break;
	    case 'S':
	      labels[SOUTH] = tmp[TOP];
	      labels[BOTTOM] = tmp[SOUTH];
	      labels[NORTH] = tmp[BOTTOM];
	      labels[TOP] = tmp[NORTH];
	      break;
	    case 'E':
	      labels[TOP] = tmp[WEST];
	      labels[WEST] = tmp[BOTTOM];
	      labels[BOTTOM] = tmp[EAST];
	      labels[EAST] = tmp[TOP];
	      break;
	    case 'W':
	      labels[WEST] = tmp[TOP];
	      labels[BOTTOM] = tmp[WEST];
	      labels[EAST] = tmp[BOTTOM];
	      labels[TOP] = tmp[EAST];
	      break;
		}
	}

	void prt(){
		for (int i = 0; i < 6; ++i) {
			cout << labels[i] << " ";
		}
		cout << endl;
	}

	int getPosOfLabel(int label){
		for (int i = 0; i < 6; ++i) {
			if(labels[i]==label)
				return i;
		}
		return -1;
	}

	void setST(int southLabel, int topLabel){
		switch(getPosOfLabel(southLabel)){
		case SOUTH:
			break;
		case NORTH:
			move('S');move('S');
			break;
		case EAST:
			move('W');move('S');
			break;
		case WEST:
			move('E');move('S');
			break;
		case TOP:
			move('S');
			break;
		case BOTTOM:
			move('N');
			break;
		}

		while(labels[TOP]!=topLabel){
			move('W');
		}
	}

	bool isSame(Dice another){
		Dice tmp(another.labels);
		tmp.setST(labels[SOUTH],labels[TOP]);
		for (int i = 0; i < 6; ++i) {
			if(tmp.labels[i]!=labels[i]){
				return false;
			}
		}
		return true;
	}

	int labels[6];
};

int main(){
	int labels[6];
	for (int i = 0; i < 6; ++i) {
		cin >> labels[i];
	}
	Dice d1(labels);
	for (int i = 0; i < 6; ++i) {
		cin >> labels[i];
	}
	Dice d2(labels);

	string res = (d1.isSame(d2))? "Yes" : "No";

	println(res);

	return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
// -----------------------------------------------------------------------------

typedef pair<int, int> P;
const int N = 2E5 + 100, MOD = 1E9 + 7;
vector<P> a[N];
int c[N], w[N], n, x, y;
map<int, int> b[N];

int fa[N];
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
void merge(int x, int y) {
    int fx = find(x), fy = find(y);
    if (fx != fy) fa[fx] = fy;
}

void connect(int color) {
    int wt = y - a[color].front().first;
    int id = a[color].front().second;
    FOR (i, 1, n + 1) {
        if (c[i] != color && w[i] <= wt)
            merge(i, id);
    }
}

void connect_self(int color) {
    if (a[color].empty()) return;
    P p = a[color][0];
    FOR (i, 1, a[color].size()) {
        const P &q = a[color][i];
        if (p.first + q.first <= x)
            merge(p.second, q.second);
    }
}

LL bin(LL x, LL n, LL MOD) {
    LL ret = MOD != 1;
    for (x %= MOD; n; n >>= 1, x = x * x % MOD)
        if (n & 1) ret = ret * x % MOD;
    return ret;
}

LL invf[N], fac[N];
void fac_inv_init(LL n, LL p) {
    fac[0] = 1;
    FOR (i, 1, n)
        fac[i] = i * fac[i - 1] % p;
    invf[n - 1] = bin(fac[n - 1], p - 2, p);
    FORD (i, n - 2, -1)
        invf[i] = invf[i + 1] * (i + 1) % p;
}

int main() {
    fac_inv_init(N, MOD);
    cin >> n >> x >> y;
    FOR (i, 1, n + 1) {
        cin >> c[i] >> w[i];
        a[c[i]].emplace_back(w[i], i);
    }
    FOR (i, 1, n + 1) {
        sort(a[i].begin(), a[i].end());
    }
    int min1 = -1, min2 = -1;
    FOR (i, 1, n + 1) {
        if (!a[i].empty() && (min1 == -1 || a[i].front().first < a[min1].front().first))
            min1 = i;
    }
    FOR (i, 1, n + 1) {
        if (i == min1) continue;
        if (!a[i].empty() && (min2 == -1 || a[i].front().first < a[min2].front().first))
            min2 = i;
    }
    dbg(min1, min2);

    iota(fa, fa + N, 0);
    if (min1 != -1) connect(min1);
    if (min2 != -1) connect(min2);
    FOR (i, 1, n + 1)
        connect_self(i);

    FOR (i, 1, n + 1)
        b[find(i)][c[i]]++;

    LL ans = 1;
    FOR (i, 1, n + 1) {
        if (!b[i].empty()) {
            LL s = 0;
            for (auto& p: b[i]) {
                ans = ans * invf[p.second] % MOD;
                (s += p.second) %= MOD;
            }
            ans = ans * fac[s] % MOD;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 33536
#include <iostream>
#include <cstdio>
#include <queue>

using namespace std;

int n;
deque<int> qu, ql;
bool a[100005];

int main()
{
    scanf("%d", &n);
    qu.push_back(1);
    ql.push_back(1);
    while(!qu.empty())
    {
        int t1 = qu.front();
        int t2 = ql.front();
        qu.pop_front();
        ql.pop_front();
        if(t1 == 0)
        {
            printf("%d", t2);
            return 0;
        }
        if(a[t1]) continue;
        a[t1] = true;
        qu.push_front(t1 * 10 % n);
        ql.push_front(t2);
        qu.push_back((t1 + 1) % n);
        ql.push_back(t2 + 1);
    }
    return 0;
}


Measured memory_bytes: 1152
n=int(input())
v_list=list(map(int,input().split()))
c_list=list(map(int,input().split()))

diff_list = [v_list[i]-c_list[i] for i in range(n) if v_list[i] - c_list[i] > 0]
diff_list.append(0)
print(sum(diff_list))

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

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int x=a*10+b+c;
	int y=b*10+a+c;
	int z=c*10+a+b;
	cout<<max(x,max(y,z))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 100005
#define For(i,x,y) for(int i=x;i<=y;i++)
#define Rep(i,x,y) for(int i=x;i>=y;i--)
#define mp make_pair
#define pa pair<ll,int>
using namespace std;
inline int read(){
	int x=0,f=0;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-48;
	return f?-x:x;
}
int n,h,in[405],ou[405],fa[405];
bool flag[405];
inline int find(int x){return (fa[x]==x)?x:fa[x]=find(fa[x]);}
int main(){
	n=read();h=read();
	For(i,1,h*2) fa[i]=i;
	For(i,1,n){
		int a=read(),b=read(),c=read(),d=read();
		int l=(c==0)?h+a:c;
		int r=(d==0)?b:h+d;
		in[r]++;ou[l]++;
		fa[find(l)]=find(r);
	}
	For(i,1,h) if(ou[i]>in[i]){puts("NO");return 0;}
	For(i,h+1,h*2) if(ou[i]<in[i]){puts("NO");return 0;}
	For(i,1,h*2) if(in[i]!=ou[i]) flag[find(i)]=1;
	For(i,1,h*2) if(find(i)==i&&!flag[i]&&in[i]+ou[i]!=0){puts("NO");return 0;}
	puts("YES");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			
			int[] p = new int[n];
			for(int i=0;i<n;i++) p[i] = sc.nextInt();
			
			boolean flag = false;
			for(int i=0;i<n;i++){
				if(flag==false){
					if(i!=0) System.out.print(" ");
					System.out.print(p[i]);
					if(i<n-1 && p[i+1]==p[i]+1) flag = true;
				}else if(flag==true && (i==n-1 || p[i+1]!=p[i]+1)){
					System.out.print("-" + p[i]);
					flag = false;
				}
			}
			System.out.println();
		}	
	}	
}

Measured memory_bytes: 24624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int[] b = new int[a];
		for (int i = 0; i < a; i++)
			b[i] = scanner.nextInt();
		for (int i = b.length - 1; i >= 0; i--) {
			if (i == b.length - 1)
				System.out.print(b[i]);
			else
				System.out.print(" " + b[i]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 18992
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    cout << 180 * (n-2) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define NUMBER 200001
int main()
{
  char s[NUMBER],t[NUMBER];
  scanf("%s", s);
  scanf("%s", t);
  int i,cnt=0,len=0;
  while(s[len])
    len++;
  for(i=0;i<len;i++){
    if(s[i] == t[i])
    continue;
  else
    cnt++;
  }
printf("%d", cnt);
  return 0;
}


Measured memory_bytes: 2124
import re

S = input()
flag = True
while(flag):
    if(len(S)==0):
        flag = False
    if(S[-5:]=='dream' or S[-5:]=='erase'):
        S=S[:-5]
    elif(S[-6:]=='eraser'):
        S=S[:-6]
    elif(S[-7:]=='dreamer'):
        S=S[:-7]
    else:
        break
if(flag):
    print('NO')
else:
    print('YES')


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
 
int main () {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<vector<int>> vec(N, vector<int>(N,99));

  rep(i, N){
    cin >> A[i];
    int x,y;
    rep(j,A[i]){
      cin >> x >> y;
      vec[i][x - 1] = y;
    }
  }

  //bool ok = false;
  int anstmp = 0;
  int ans = 0;
  // すべての選び方を試して調べる
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bitset<15> s(tmp);  // 最大15個なので15ビットのビット列として扱う
    bool ok = true;
    rep(i, N){
      if(s.test(i)){
        rep(j, N){
          if(vec[i][j] == 99) continue;
          else if(vec[i][j] != s.test(j)) ok = false;
          //else{
          //  ok = false;
          //  break;
          //}
        }
      }
      //if(!ok) break;
    }
    if(ok){
      anstmp = s.count();
      ans = max(ans, anstmp);
    }
  }

  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 256
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	L, R, d = rli()
	ans = 0
	for x in range(L, R+1):
		if x % d == 0:
			ans += 1
	print(ans)
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 65388
using System;

class Program
{
  static void Main(string[] args)
  {
    int N = int.Parse(Console.ReadLine());
    string[] s = Console.ReadLine().Split(' ');
    int T = int.Parse(s[0]);
    int A = int.Parse(s[1]);
    int[] H = new int[N];
    string[] s2 = Console.ReadLine().Split(' ');
    for (int i = 0; i < N; i++)
    {
      H[i] = int.Parse(s2[i]);
    }
    int cc = 1000000000;
    int res = 0;
    for (int i = 0; i < N; i++)
    {
      int d = 1000 * T - H[i] * 6;
      if (cc > Math.Abs(d - A * 1000))
      {
        res = i + 1;
        cc = Math.Abs(d - A * 1000);
      }
    }
    Console.WriteLine(res);
  }
}


Measured memory_bytes: 27896
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long res = 0;

        long remainder = n % (a + b);
        if(remainder >= a) res += a;
        else res += remainder;

        res += (n / (a + b)) * a;
        System.out.println(res);
    }
}


Measured memory_bytes: 24916
import scala.math._

object Main {
  def main(args: Array[String]): Unit = {
    val lines = io.Source.stdin.getLines().toSeq
    println(solve(lines))
  }

  def solve(lines: Seq[String]): String = {
    val n = lines.head.toInt // N
    val nums = lines.tail.head.split(" ").map(_.toLong).toSeq
    debug(n, nums)

    val minusNumsCount = nums.count(_ < 0)
    val result = if (minusNumsCount % 2 == 0) nums.map(abs).sum else nums.map(abs).sum - nums.map(abs).min * 2
    result.toString
  }

  private def debug(x: Any): Unit = {
    if (System.getenv("LOCAL_DEBUG") != null)
      println(x)
  }
}


Measured memory_bytes: 53680
#include<bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++) 
#define fr(i,a,b) for(int i=a;i<b;i++) 
#define F first 
#define S second 
#define mp make_pair 
#define pb push_back 
#define ll long long 
using namespace std;

void test(){
	ll n,k;
	cin>>n>>k;
	ll ans = 0;
	while(n>0){
		ans++;
		n = n/k;
	}
	cout<<ans<<"\n";
}

int main(){
	int t=1;
//	cin>>t;
	while(t--){
		test();
	}
}

Measured memory_bytes: 256
A, B = list(map(int, input().split()))

ans = -1
for i in range(B * 10, (B + 1) * 10):
    a = int(i * 0.08)
    b = int(i * 0.10)
    #print(i, a, b, a==b)
    if (a == A) and (b == B):
        ans = i
        break

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
using namespace std;

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

      int t=1;
      //cin>>t;
      while(t--)
      {
            int a[6];
            for(int i=1;i<=5;++i)
               cin>>a[i];
            for(int i=1;i<=5;++i)
            {
                 if(a[i]==0)
                    cout<<i;

            }
      }
}


Measured memory_bytes: 3648
import sys

n = int(input())

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

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

temperature_sub = 0
area_no = 0
temperature_store = 0

for index, item in enumerate(area):
    temperature = t - (item*0.006)
    temperature_sub = abs(a - temperature)

    if index == 0:
        temperature_store = temperature_sub
        area_no = index + 1
    else:
        if temperature_store > temperature_sub:
            temperature_store = temperature_sub
            area_no = index + 1

print("{}".format(area_no))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  vector <int> arr;
  for(int i=0;i<n;i++)
  {
    int temp;
    cin>>temp;
    arr.push_back(temp);
  }
  int flag=0;
  int sum=accumulate(arr.begin(),arr.end(),0);
  sort(arr.begin(),arr.end(),greater<int>());
    for(int i=0;i<m;i++)
    {
     double value=(double)sum/(4*m);
      if(arr[i]<value)
         flag=1;
     }
      if(flag==0)
         cout<<"Yes";
         else
         cout<<"No";
        
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <limits.h>
using namespace std;
typedef long long LL;
const int MAXN = 200000 + 10;
LL sum[MAXN];
int main() {
//    freopen("test.txt", "r", stdin);
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &sum[i]);
        sum[i] += sum[i-1];
    }
    LL ret = LLONG_MAX;
    LL tmp;
    for (int i = 1; i < n; i++) {
        tmp = sum[n] - 2*sum[i];
        ret = min(ret, abs(tmp));
    }
    cout << ret << endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define inf 100000000000000000
#define mod 1000000007
#define endl '\n'
#define omarshagar                    \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
using namespace std;

int main()
{

   omarshagar
    int n,k;
   cin>>n>>k;
   int arr[n];
   for(int i=0;i<n;i++)
   {
       cin>>arr[i];
   }
   sort(arr,arr+n);
   ll res=inf;
   for(int i=0;(i+k)-1<n;i++)
   {
       res=min(res,(ll)arr[(i+k)-1]-arr[i]);
   }
cout<<res<<endl;
}


Measured memory_bytes: 640
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    #[i]:数字iの個数
    prime_list = [0]*100
    # 素因数分解
    def prime_decomp(n):
        i = 2
        res = []
        while i ** 2 <= n:
            while n % i==0:
                n //= i
                res.append(i)
            i += 1
        if n > 1:
            res.append(n)
        return res
    for i in range(1, n+1):
        l = prime_decomp(i)
        for j in l:
            prime_list[j] += 1
    
    a,b,c,d,e = 0,0,0,0,0
    for i in prime_list:
        if i >= 74:
            a += 1
        if i >= 24:
            b += 1
        if i >= 14:
            c += 1
        if i >= 4:
            d += 1
        if i >= 2:
            e += 1
    
    res = a + b*(e-1) + c*(d-1) + d*(d-1)*(e-2)//2
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
S = input()
dp = [0] * (len(S) + 1)
dp[0] = 1

words = ["dream", "dreamer", "erase", "eraser"]
done = 'NO'

for i in range(len(S)):
    if dp[i] == 0:
        continue
    for w in words:
        if S[i:i+len(w)] == w:
            dp[i+len(w)] = 1
    
    if dp[len(S)] == 1:
        done = 'YES'

print(done)

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

int maxPath(vector<vector<int> >& graph, vector<int>& memo, int vertex) {
    if(memo[vertex] != -1) return memo[vertex];

    if(graph[vertex].empty()) {
        memo[vertex] = 0;
    } else {
        for(int prev : graph[vertex]) {
            memo[vertex] = max(memo[vertex], 1 + maxPath(graph, memo, prev));
        }
    }
    
    return memo[vertex];
}

int main() {
    int numVertices;
    cin >> numVertices;
    int numEdges;
    cin >> numEdges;

    vector<vector<int> > graph(numVertices, vector<int>());
    int from, to;
    for(int i = 0; i < numEdges; i++) {
        cin >> from;
        cin >> to;
        graph[to-1].push_back(from-1);
    }

    //stores max path if ending at that vertex
    vector<int> memo(numVertices, -1);
    int result = 0;
    for(int vertex = 0; vertex < numVertices; vertex++) {
        result = max(result, maxPath(graph, memo, vertex));
    }
    cout << result;
    return 0;
}

Measured memory_bytes: 14668
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<complex>
#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,a[110];
    cin>>n;
    lol(i,n)cin>>a[i];
    sort(a,a+n);
    int x=0,y=0;
    lol(i,n){
	if(i%2==0)x+=a[i];
	else y+=a[i];
    }
    cout<<abs(x-y)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
 
typedef vector<int> vi;
typedef pair<int,int> pii;
 
int main(void) {
  int i;
  string s,str;
  s="XYZABCDEFGHIJKLMNOPQRSTUVW";
  cin>>str;
  int len=str.size();
  rep(i,len)
    cout<<s[str[i]-'A'];
  cout<<endl;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

struct UnionFind{
    std::vector<int> parent, rank, cnt;

    UnionFind(int n) : parent(n), rank(n, 0), cnt(n, 1) {
        std::iota(parent.begin(), parent.end(), 0);
    }

    int find(int v){
        if(v == parent[v]){return v;}
        return parent[v] = find(parent[v]);
    }

    bool same(int v, int w){
        return find(v) == find(w);
    }

    void unite(int v, int w){
        v = find(v);
        w = find(w);

        if(v == w){return;}

        if(rank[v] > rank[w]){
            parent[w] = v;
            cnt[v] += cnt[w];
        }else{
            parent[v] = w;
            cnt[w] += cnt[v];
            if(rank[v] == rank[w]){rank[w] += 1;}
        }
    }

    int count(int v){
        return cnt[find(v)];
    }
};

int N, M;
int A[100100], B[100100];
ll cnt[100100];

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

    std::cin >> N >> M;

    for(int i=0;i<M;++i){
        std::cin >> A[i] >> B[i];
    }

    UnionFind uf(100100);

    ll total = 0;

    for(int i=M-1;i>=0;--i){
        cnt[i] = 1ll * N * (N - 1) / 2 - total;
        
        unless(uf.same(A[i], B[i])){
            total += 1ll * uf.count(A[i]) * uf.count(B[i]);
            uf.unite(A[i], B[i]);
        }
    }

    for(int i=0;i<M;++i){
        std::cout << cnt[i] << std::endl;
    }
}


Measured memory_bytes: 4096
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, p[10], q[10], a[8], P, Q;
set<int> st;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> p[i];
	for (int i = 0; i < n; i++) cin >> q[i];
	P = p[0];
	for (int i = 1; i < n; i++) {
		P = P * 10;
		P += p[i];
	}
	Q = q[0];
	for (int i = 1; i < n; i++) {
		Q = Q * 10;
		Q += q[i];
	}
	for (int i = 1; i <= n; i++) {
		a[i - 1] = i;
	}
	do {
		int cur = a[0];
		for (int i = 1; i < n; i++) {
			cur = cur * 10;
			cur = cur + a[i];
		}
		st.insert(cur);
	} while (next_permutation(a, a + n));
	int u, v, cnt = 0;
	for (auto x : st) {
		if (x == P) u = cnt;
		if (x == Q) v = cnt;
		cnt++;
	}
	cout << abs(u - v) << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 2176
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int[] types = new int[n];
		for (int i = 0; i < n; i++) {
		    String s = sc.next();
		    if (s.equals("AB")) {
		        types[i] = 0;
		    } else if (s.equals("AC")) {
		        types[i] = 1;
		    } else {
		        types[i] = 2;
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
		    switch (types[i]) {
		        case 0:
		            if (a == 0) {
		                if (b == 0) {
		                    System.out.println("No");
		                    return;
		                }
		                a++;
		                b--;
		                sb.append("A");
		            } else if (b == 0) {
		                b++;
		                a--;
		                sb.append("B");
		            } else {
		                if (i != n - 1 && types[i + 1] == 2) {
		                    b++;
		                    a--;
		                    sb.append("B");
		                } else {
		                    a++;
		                    b--;
		                    sb.append("A");
		                }
		            }
		            break;
		        case 1:
		            if (a == 0) {
		                if (c == 0) {
		                    System.out.println("No");
		                    return;
		                }
		                a++;
		                c--;
		                sb.append("A");
		            } else if (c == 0) {
		                c++;
		                a--;
		                sb.append("C");
		            } else {
		                if (i != n - 1 && types[i + 1] == 2) {
		                    c++;
		                    a--;
		                    sb.append("C");
		                } else {
		                    a++;
		                    c--;
		                    sb.append("A");
		                }
		            }
		            break;
		        case 2:
		            if (b == 0) {
		                if (c == 0) {
		                    System.out.println("No");
		                    return;
		                }
		                b++;
		                c--;
		                sb.append("B");
		            } else if (c == 0) {
		                c++;
		                b--;
		                sb.append("C");
		            } else {
		                if (i != n - 1 && types[i + 1] == 0) {
		                    b++;
		                    c--;
		                    sb.append("B");
		                } else {
		                    c++;
		                    b--;
		                    sb.append("C");
		                }
		            }
		            break;
		    }
		    sb.append("\n");
		}
		System.out.println("Yes");
		System.out.print(sb);
	}
}


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

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = n - 1; i > 0; i--) {
        cout << a[i] << ' ';
    }
    cout << a[0] << endl;
}

Measured memory_bytes: 1160
package main
import (
    "fmt"
    "strconv"
)

func main() {
    var a, b string
    f := false
    fmt.Scanf("%s %s", &a, &b)
    x, _ := strconv.Atoi(a+b)

    for i:=1; i<=x; i++ {
        if i*i == x {
            fmt.Print("Yes")
            f = true
            break
        }
    }
    if !f {
        fmt.Print("No")
    }

}

Measured memory_bytes: 512
from sys import stdin

def solve(n, k, s):
    ans = ''
    for i, char in enumerate(s):
        newChar = char.lower() if i + 1 == k else char
        ans = ans + newChar
    return ans


def main():
    lines = stdin.readlines()
    n, k = [int(n) for n in lines[0].split(' ')]
    s = lines[1]
    ans = solve(n, k, s)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef long double ld;
const ld pi = 4*atan((ld)1);
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll nax = 0;

ll r, c, k;
ll a[3005][3005], memo[3005][3005][4];

ll dp(ll x, ll y, ll cnt){
	if(x == r && y == c){
		if(cnt < 3){
			return a[x][y];
		}
		else{
			return 0;
		}
	} 
	if(x > r){
		return -inf;
	}
	if(y > c){
		return -inf;
	}
	if(memo[x][y][cnt] != -1){
		return memo[x][y][cnt];
	}
	ll ret = 0, ret2 = 0;
	ret = max(dp(x + 1, y, 0), dp(x, y + 1, cnt));
	if(cnt < 3){
		ret2 = max(dp(x + 1, y, 0) + a[x][y], dp(x, y + 1, cnt + 1) + a[x][y]);
	}
	return memo[x][y][cnt] = max(ret, ret2);
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	memset(memo, -1, sizeof(memo));
	cin >> r >> c >> k;
	for(ll i = 0; i < k; i++){
		ll x, y, z;
		cin >> x >> y >> z;
		a[x][y] = z;
	}
	cout << dp(1, 1, 0) << '\n';
}



Measured memory_bytes: 356708
#include<iostream>
#include<cstdio>
using namespace std;
int gcd(int a,int b)
{
	int c;
	if(a<b){
		a+=b;
		b=a-b;
		a-=b;
	}
	while(b!=0){
		c=a%b;
		a=b;
		b=c;
	}
	return a;
}
int lcm( int m, int n )
{
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	return ((m / gcd(m, n)) * n);
}
int main(){
	int a,b,i,j,t;
	while(scanf("%d%d",&a,&b)!=EOF){
		cout<<gcd(a,b)<<" "<<lcm(a,b)<<endl;
	}
return 0;
}

Measured memory_bytes: 1208
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
using namespace std;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	int x = 0, y = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R')x += 1;
		else y += 1;
	}
	if (x > y)cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
def main():
    n, x = list(map(int, input().split()))
    a, p = [1, ], [1, ]
    for i in range(n):
        a.append(a[i] * 2 + 3)
        p.append(p[i] * 2 + 1)
    def f(n, x):
        if n == 0:
            return 0 if x <= 0 else 1
        elif x <= 1 + a[n-1]:
            return f(n-1, x-1)
        else:
            return p[n-1] + 1 + f(n-1, x-2-a[n-1])

    print(f(n, x))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]
ans = 'No'


for x in range(N-M+1):
    for y in range(N-M+1):
        for j in range(M):
            #print(A[y+j][x:x+M])
            #print(B[j])
            if A[y+j][x:x+M] != B[j]:
               # print('No')
                break
        else:
            ans ='Yes'
            #print('Yes')

print(ans)

Measured memory_bytes: 3064
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define REPR(i, x, n) for(int i = n - 1 ; i >= x ; i--)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) REPR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector< pair<lint, lint> > p(n);
    rep(i, n){
        lint x, y;
        cin >> x >> y;
        p[i] = make_pair(x, y);
    }
    SORT(p);
    lint ans = LLINF;
    rep(i, n-1){
        REP(j, i+1, n){
            lint hi = max(p[i].second, p[j].second), lo = min(p[i].second, p[j].second);
            int l = 0, r = 0, cnt = 0;
            while(r <= n){
                if(cnt < k){
                    if(lo <= p[r].second && p[r].second <= hi){
                        cnt++;
                    }
                    r++;
                }else{
                    ans = min(ans, (hi - lo) * (p[r-1].first - p[l].first));
                    if(lo <= p[l].second && p[l].second <= hi){
                        cnt--;
                    }
                    l++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>

#define MP make_pair

using namespace std;

int main(){
    int cases;
    cin >> cases;
    for(int c=0;c<cases;c++){
        map<pair<pair<int,int>, pair<int,int> >, bool> m;
        int x,y;
        cin >> x >> y;
        int dp[x+1][y+1];
        memset(dp, 0, sizeof(dp));
        dp[0][0] = 1;

        int p,a,b,c,d;
        cin >> p;
        for(int i=0;i<p;i++){
            cin >> a >> b >> c >> d;
            m[make_pair(make_pair(a,b), make_pair(c,d))] = true;
            m[make_pair(make_pair(c,d), make_pair(a,b))] = true;
        }

        for(int i=0;i<=x;i++){
            for(int j=0;j<=y;j++){
                if(i==0 && j ==0){

                }else if(i == 0){
                    if(m[MP(MP(i,j), MP(i,j-1))] == false &&
                       m[MP(MP(i,j-1), MP(i,j))] == false){
                        dp[i][j] += dp[i][j-1];
                    }
                }else if(j == 0){
                    if(m[MP(MP(i,j), MP(i-1,j))] == false &&
                       m[MP(MP(i-1,j), MP(i,j))] == false ){
                        dp[i][j] += dp[i-1][j];
                    }
                }else{
                    if(m[MP(MP(i,j), MP(i-1,j))] == false &&
                       m[MP(MP(i-1,j), MP(i,j))] == false ){
                        dp[i][j] += dp[i-1][j];
                    }
                    if(m[MP(MP(i,j), MP(i,j-1))] == false &&
                       m[MP(MP(i,j-1), MP(i,j))] == false){
                        dp[i][j] += dp[i][j-1];
                    }
                }
            }
        }
        if(dp[x][y] == 0){
            cout << "Miserable Hokusai!" << endl;
        }else{
            cout << dp[x][y] << endl;
        }
    }
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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 T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 998244353, INF = 1e18;


template <std::int_fast64_t Modulus>
class modint
{
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept
	{
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept
	{
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept
	{
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept
	{
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept
	{
		a += rhs.a;
		if (a >= Modulus)
		{
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept
	{
		if (a < rhs.a)
		{
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept
	{
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept
	{
		u64 exp = Modulus - 2;
		while (exp)
		{
			if (exp % 2)
			{
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
typedef modint<MOD> ModInt;

lint A, B, C, D;
ModInt dp[3002][3002];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> A >> B >> C >> D;
	REP(i, 3001) {
		REP(j, 3001) {
			dp[i][j] = 0;
		}
	}
	dp[A][B] = 1;
	FOR(i, A, C + 1) {
		FOR(j, B, D + 1) {
			dp[i + 1][j] += dp[i][j] * j;
			dp[i][j + 1] += dp[i][j] * i - dp[i - 1][j]*(i - 1)*(j);
		}
	}
	cout << dp[C][D].a << endl;
}


Measured memory_bytes: 74052
#include <stdio.h>   
#include <stdlib.h>   
#include <ctype.h> 

#define MAXOP 100   
#define NUMBER '0'   
int getop (char []);   
void push (double);   
double pop(void);  
int getch(void);   
void ungetch(int);  
  
int main() {   
int type;   
double op;   
char s[MAXOP];   
while ((type=getop(s))!=EOF) {   
    switch(type){   
        case NUMBER:   
            push(atof(s));
            break;   
        case '+':   
            push(pop()+pop());   
            break;   
        case '*':   
            push(pop()*pop());   
            break;   
        case '-':   
            op=pop();   
            push(pop()-op);   
            break;   
        case '/':   
            op=pop(); 
            push(pop()/op);   
            break;   
        case '\n':   
            printf("%.8g\n",pop());   
            return 0;  
        default: break;   
        }   
    }   
return   0;   
}   
  
#define AAA 100   

int sp=0;   
double  val[AAA];   
  
void push(double f) {   
    if(sp<AAA)   
        val[sp++]=f;    
} 

double pop(void) {   
    if (sp>0) return val[--sp];   
}  
    
int getop(char s[]) {   
    int   i,c;   
    while   ((s[0]=c=getch())==' '|| c=='\t');   
        s[1]='\0';   
    if(!isdigit(c))   
        return c;   
    i=0;   
    if(isdigit(c))   
        while (isdigit(s[++i]=c=getch()));   
    if(c!=EOF)   
        ungetch(c);   
    return NUMBER;   
}   
 
#define BUFSIZE 100   
char buf[BUFSIZE];   
int bufp=0; 

int getch(void) {   
    return(bufp>0) ? buf[--bufp]:getchar();   
}

void ungetch(int c) {   
    buf[bufp++]=c;   
}


Measured memory_bytes: 2144
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	long N,i,a,b,hours=0;
	cin>>N;
	vector<pair<long,long>> time(N);
	for(i=0;i<N;i++){
		cin>>a>>b;
		time.at(i)=make_pair(b,a);
	}
	sort(time.begin(),time.end());
	for(i=0;i<N;i++){
		hours+=time.at(i).second;
		if(hours>time.at(i).first){
			break;
		}
	}
	if(i==N){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
}


Measured memory_bytes: 3328
#include <iostream>

#define MX 1000000000

using namespace std;
int cost[100][100],n;

int dijkstra(int s , int g , int c){
  bool visited[100];
  int d[100][11];
  for(int i=0;i <= c;i++){
    for(int j=0;j < n;j++) d[j][i] = MX , visited[j] = false;
    d[s][i] = 0;
      while(1){
        int u;
        int mincost = MX;
        for(int j=0;j<n;j++)if(!visited[j] && d[j][i] < mincost) mincost = d[j][i],u = j;
        if(mincost == MX) break;
        visited[u] = true;
        for(int v = 0;v < n;v++){
          if(visited[v] || cost[u][v] == MX) continue;
          if(d[v][i] > d[u][i] + cost[u][v]) d[v][i] = d[u][i] + cost[u][v];
          if(i > 0) if(d[v][i] > d[u][i-1] + cost[u][v] / 2) d[v][i] = d[u][i-1] + cost[u][v] / 2;
        }
      }
  }
  return d[g][c];
}

int main(){
  int c,m,s,d;
  while(cin >> c >> n >> m >> s >> d && (c|n|m|s|d)){
    for(int i=0;i<n;i++)for(int j=0;j<n;j++) cost[i][j] = MX;
    while(m--){
      int a,b;
      cin >> a >> b;
      cin >> cost[a-1][b-1];
      cost[b-1][a-1] = cost[a-1][b-1];
    }
    cout << dijkstra(s-1,d-1,c) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
/*
	@・ω・@ <だれだろうね
*/

/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>
#include <fstream>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<long long, long long>;
template<class T> using pr = pair<T, T>;
template<class T> using vec = vector<T>;

#define debug(x) (std::cerr << x)
#define debugln(x) (std::cerr << x << "\n")
#define debug_tab(n, x) (std::cerr << strMulti("\t",n) << (x) << "\n")
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define str(n)	(n.toString())

#define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(ll i=(n)-1; i >= 0; --i)
#define rrep1(i, n) for(ll i=(n); i > 0; --i)
#define step(i, a, n) for(ll i=(a), i##_len=(a)+(n); i<i##_len; ++i)
#define rstep(i, a, n) for(ll i=(a)+(n)-1, i##_len=(a); i>=i##_len; --i)
#define range(i, a, b) for(ll i=(a), i##_len=(b); i<i##_len; ++i)
#define rrange(i, a, b) for(ll i=(b)-1, i##_len=(a); i>=i##_len; --i)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b)
constexpr int INF = 2000000100;
constexpr ll MOD = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = math_P(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool cmp_2nd(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T mod_pow(T x, T n, const T& p) { T ret = 1; while (n > 0) { if (n & 1) { (ret *= x) %= p; } (x *= x) %= p; n >>= 1; } return ret; }

/*****/

using graph = vec<vec<ll>>;

void Main()
{
	ll n, k;
	cin >> n >> k;

	n %= k;

	ll min = n;
	while (true)
	{
		n = abs(k - n);
		if (!chmin(min, n))
		{
			break;
		}
	}

	cout << min;
}

/*****/

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

	//std::cout << std::fixed << std::setprecision(10);

	/**
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
	ofstream out("output.txt");
	cout.rdbuf(out.rdbuf());
	/**/

	/**
	while (true)
	{
		Main();
		std::cerr << flush;
		cout << endl;
	}
	/*/
	Main();
	std::cerr << flush;
	cout << endl;
	/**/

	return 0;
}


Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


class UnionFind:
    def __init__(self, size):
        """
        size:頂点の数
        parent[x]->parent of x
        rank[x] -> height of tree of x
        """
        self.parent = [i for i in range(size)]
        self.rank = [0 for _ in range(size)]

    def find(self, x):
        """
        xのrootを返す
        """
        if self.parent[x] == x:
            return x
        else:
            return self.find(self.parent[x])

    def union(self, x, y):
        """
        x,yを同じグループとしてまとめる
        """
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        """
        xとyが同じグループならTrue
        """
        return self.find(x) == self.find(y)

    def component(self):
        """
        各連結成分のrootの集合を返す
        len()をとれば連結成分の数が求められる
        return-> set()
        """
        comp = set()
        for i in self.parent:
            p = self.find(i)
            comp.add(p)
        return comp

    def componentNum(self):
        """
        連結成分の数を返す
        """
        return len(self.component())

    def __str__(self):
        """
        for debug
        クラスのlistの情報を出力
        """
        ret = "parents\n"
        ret += " ".join(map(str, self.parent))
        ret += '\n'
        ret += " ".join(map(str, self.rank))
        return ret


N = int(input())
X = []
Y = []
cand = []
for i in range(N):
    x, y = map(int, input().split())
    X.append([i, x])
    Y.append([i, y])

X = sorted(X, key=lambda x: x[1])
Y = sorted(Y, key=lambda x: x[1])

for p1, p2 in zip(X, X[1:]):
    i1, x1 = p1
    i2, x2 = p2
    cand.append([i1, i2, x2-x1])

for p1, p2 in zip(Y, Y[1:]):
    i1, y1 = p1
    i2, y2 = p2
    cand.append([i1, i2, y2-y1])

Un = UnionFind(N)
ans = 0

cand = sorted(cand, key=lambda x: x[2])
for s, g, w in cand:
    if Un.same(s, g):
        continue
    else:
        Un.union(s, g)
        ans += w
print(ans)


Measured memory_bytes: 70732
#include<stdio.h>
int n, s[100000];
int binary_search(int t)
{
	int left = 0;
	int right = n - 1;
	int mid;
	while (left <= right) {
		mid = (left + right) / 2;
		if (t == s[mid]) {
			return 1;
		}
		else if (t < s[mid]) {
			right = mid - 1;
		}
		else {
			left = mid + 1;
		}
	}
	return 0;
}

int main()
{
	int q, t[50000],i,c=0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &s[i]);
	}
	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &t[i]);
		
	}
	for (i = 0; i < q; i++) {
		if (binary_search(t[i]) == 1) {
			c++;
		}
	}
	printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 3300
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
//#define _GLIBCXX_DEBUG

int gcd(int n, int m) {
  if(n < m) swap(n, m);
  if(m == 1) return 1;
  else if(m == 0) return n;
  else return gcd(m, n%m);
}

signed main() {
  int N, K; cin >> N >> K;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  
  sort(all(A));
  
  int g = gcd(A[0], A[1]);
  rep(i, N-2) g = gcd(g, A[i+2]);
  
  if(K > A[N-1]) {
    cout << "IMPOSSIBLE" << endl;
  } else if(count(all(A),K) >= 1) {
    cout << "POSSIBLE" << endl;
  } else {
  cout << (K%g == 0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
  }
  
}


Measured memory_bytes: 1024