akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin>>x;
  int a,b;
  for(int i=-1000;i<1001;i++){
    for(int j=-1000;j<1001;j++){
      if(pow(i,5)-pow(j,5)==x){
        a=i;
        b=j;
        break;
      }
    }
  }
  cout<<a<<"\t"<<b<<endl;
}


Measured memory_bytes: 4100
from sys import stdin
#from collections import deque
#from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def lsi():
    x=list(stdin.readline())
    x.pop()
    return x
def si(): return stdin.readline()
############# CODE STARTS HERE #############
n, w=mi()
a=[[0] for _ in range(n+1)]
for _ in range(w):
    a[0].append(0)
for i in range(1, 1+n):
    x, v=mi()
    for j in range(1, 1+w):
        if j>=x:
            a[i].append(max(a[i-1][j-x]+v, a[i-1][j]))
        else:
            a[i].append(a[i-1][j])
print(a[-1][-1])

Measured memory_bytes: 147012
#import math
#=input()
k=int(input())
s=input()
#=map(int,input().split())
#=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]

if len(s) <= k:
    print(s)
else:
    s = s[:k]
    s += '...'
    print(s)

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

int main() {
    int n, h, Max = 0, ans = 0;
    cin >> n >> h;
    int a[n], b[n];
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &a[i], &b[i]);
        Max = max(Max, a[i]);
    }

    sort(b, b + n);
    for (int i = n - 1; i >= 0; i--) {
        if (Max > b[i] || h <= 0) break;
        h -= b[i];
        ans++;
    }
    if (h > 0) {
        ans += ceil(h * 1.0 / Max);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    char a;
    cin >> a;
    if ('a' <= a && a <= 'z') cout << "a" << endl;
    else cout << "A" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  
  bool yn=false;
  
  for(int i=0;i<N/7+1;i++){
    bool fin=false;
    for(int j=0;j<N/4+1;j++){
      if(4*j+7*i==N){
        yn=true;
        fin=true;
        break;
      }
    }
    if(fin==true)break;
  }
  
  if(yn==true)cout << "Yes"<<endl;
  else cout<<"No"<<endl;
  
}

Measured memory_bytes: 3536
/*
	w[x]-w[y]=d ?????????????????¨???????????£??±?????\???
	????????????,w[x]-w[y]?????????????????¨??????????????§??????
	d[x]=w[par[x]]-w[x]


	w[x]=?????° ??????????????????????????????,w[0]:=0??¨??????w[x]-w[0]=?????° ?????????
	w[x]+w[y]??¨????????????????????§
*/
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
typedef long long ll;
struct unionfind{
	int par[100000];
	ll d[100000];
	void init(int n) { rep(i,n) par[i]=i,d[i]=0; }
	int find(int x){
		if(x==par[x]) return x;
		int r=find(par[x]);
		d[x]+=d[par[x]];
		return par[x]=r;
	}
	void unite(int x,int y,int z){		//w[x]-w[y]=z	
		int rx=find(x),ry=find(y);
		if(rx==ry) return;
		d[ry]=d[x]-d[y]-z;
		par[ry]=rx;
	}
	int diff(int x,int y){		//w[x]-w[y]=?
		assert(same(x,y));
		find(x),find(y);			//??????!!
		return d[x]-d[y];
	}
	bool same(int x,int y) { return find(x)==find(y); }
}UF;

int main(){
	while(true){
		int N,M;
		cin>>N>>M;
		if(N==0) break;
		UF.init(N);
		rep(t,M){
			char c;
			cin>>c;
			if(c=='!'){
				int x,y,z;
				cin>>x>>y>>z;
				x--,y--;
				UF.unite(y,x,z);
			}else{
				int x,y;
				cin>>x>>y;
				x--,y--;
				if(!UF.same(x,y)) puts("UNKNOWN");
				else cout<<UF.diff(y,x)<<endl;
			}
		}
	}
}

Measured memory_bytes: 5720
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] chars = s.toCharArray();
		sc.close();

		System.out.print(chars[2] == chars[3] && chars[4] == chars[5] ? "Yes" : "No");
	}
}


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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const ll INF = 1e18;
const int mod = 1e9+7;
const int MAX = 1e6;

// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visit[MAX]; // 訪問の有無

int gcd(int a, int b) { // aとbの最大公約数（ユークリッドの互除法）
    if (b == 0) return a;
    return gcd(b, a % b);
}

// bool is_prime[MAX+1];
int d[MAX+1];

void erat() { // エラトステネスのふるい
    // memset(is_prime, true, sizeof(is_prime));
    rep(i, MAX+1) d[i] = i;
    for (int i = 2; i <= MAX; i++) {
        // if (is_prime[i]) {
        if (d[i] == i) {
            for (int j = i + i; j <= MAX; j += i) {
                // is_prime[j] = false;
                d[j] = i;
            }
        }
    }
}

void prime_fact(int x, set<int> &fact) { // 素因数分解
    if (x < 2) return;
    while (/*not is_prime[x] && */ x > 1 && x % d[x] == 0) {
        fact.insert(d[x]);
        x /= d[x];
    }
    // if (x != 1) {
    //     fact.insert(x);
    // }
}

int n;
int a[MAX];
set<int> s;
bool flag = true;

int main() {
// input
    erat();
    cin >> n;
    rep(i, n) {
        cin >> a[i];
    }
// solve
    rep(i, n) {
        if (a[i] == 1) continue;
        if (flag) {
            set<int> fact;
            prime_fact(a[i], fact);
            for (int x : fact) {
                if (not s.count(x)) {
                    s.insert(x);
                } else {
                    flag = false;
                    break;
                }
            }
        }
        if (i > 0) a[i] = gcd(a[i], a[i-1]);
    }
// output
    if (flag) cout << "pairwise coprime" << "\n";
    else if (a[n-1] == 1) cout << "setwise coprime" << "\n";
    else cout << "not coprime" << "\n";
}

Measured memory_bytes: 11484
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main() {

  ll x;
  cin >> x;

  ll ans = 100;
  ll i = 1;

  while(1)
  {
    ans = ans * 1.01;
    if(ans >= x)
      break;
    i++;
  }

  cout << i << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 3624
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll a[4], i, n;
  for(i = 0; i < 4; ++i) scanf("%lld", &a[i]);
  for(i = 1; i < 4; ++i) if(a[i] > a[i - 1] * 2) a[i] = a[i - 1] * 2;
  scanf("%lld", &n);
  printf("%lld", n / 2 * a[3] + (n & 1) * a[2]);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <bitset>
#include <utility>
#include <sstream>
#include <fstream>
#include <stack>
#include <cstdlib>
#include <complex>
#include <set>
#include <iomanip>

using namespace std;

#define INF 1070000000LL
#define pb push_back
#define irep(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) irep(i,0,n)

typedef long long lint;
typedef pair<int, int> pint;
typedef vector<vector<pint> > Graph;

void dfs(const vector<vector<int> >& graph, vector<int>& flag, int start){
    if(flag[start] == 0){
	flag[start] = 1;
	for(auto a : graph[start]){
	    dfs(graph, flag, a);	    
	}
    }
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int> > graph(n+1);
    rep(i,m){
	int x,y,z;
	cin >> x >> y >> z;
	graph[x].push_back(y);
	graph[y].push_back(x);
    }
    //    rep(i,graph.size())rep(j,graph[i].size())cout << "(" << i << "," << graph[i][j] << ")" << endl;
    vector<int> flag(n+1,0);
    int result = 0;
    irep(i,1,n+1){
	if(flag[i] == 0){
	    ++result;
	    dfs(graph, flag, i);
	}
	else continue;
    }
    cout << result << endl;
}

Measured memory_bytes: 10880
#include <stdio.h>
int zet(int a,int b){
  int c = a - b;
  if(c < 0){
    c = -c;
  }
  return c;
}

int main(){
  int N,M;
  scanf("%d %d",&N,&M);
  int a[N],b[N],c[M],d[M];
  for(int i = 0;i < N;i++){
    scanf("%d %d",&a[i],&b[i]);
  }
  for(int i = 0;i < M;i++){
    scanf("%d %d",&c[i],&d[i]);
  }
  for(int i = 0;i < N;i++){
    int min = 1000000000;
    int ans;
    for(int j = 0;j < M;j++){
      if(min > zet(a[i],c[j]) + zet(b[i],d[j])){
        min = zet(a[i],c[j]) + zet(b[i],d[j]);
        ans = j + 1;
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

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

namespace AtCoder124
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);
            int count = 0;

            for(int i = 0;i < 2; i++)
            {
                if(A > B)
                {
                    count += A;
                    A--;
                }
                else if(A < B)
                {
                    count += B;
                    B--;
                }
                else
                {
                    count += A;
                    A--;
                }
            }
            Console.WriteLine($"{count}");
        }
    }
}

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

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

int main() {
	cin >> a >> b >> c >> d;
	int x = abs(a - c);
	int y = abs(b - d);
	cout << x + y - gcd(x, y) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll INF=1e18;
int main(){
 int n;
  cin >>n;
  ll ans=1;
  vector<ll> a(n);
  rep(i,n) {
    cin>>a[i];
    if (a[i]==0){
     cout<<0<<endl;
      return 0;
    }
  }
  
  rep(i,n){
    if(ans*a[i]>INF || ans>INF/a[i]){
      cout<<-1<<endl;
      return 0;
    }
    
    ans*=a[i];
    
  }
 
  
  cout<<ans<<endl;
 

}

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

public class Main
{
	public static void main(String [] Args)
	{
		long ans=1;
		int flag=0;
		Scanner in = new Scanner(System.in);
		long a=in.nextLong();
		String b=in.next();
		ans=a*(b.charAt(0)-'0')*100+a*(b.charAt(2)-'0')*10+a*(b.charAt(3)-'0');
		System.out.println(ans/100);
	}
}
	

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

int main(){
        int i,K,N,ans=1e9+1;
        cin >> N >> K;
        vector<int> h(N);
        for(i=0;i<N;++i) cin >> h.at(i);
        sort(h.rbegin(),h.rend());
        for(i=0;i+K-1<N;++i){
                ans = min(ans, h.at(i)-h.at(i+K-1));
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  map<int, bool> c;
  rep(i, n) {
    c[a[i]] ^= 1;
  }

  int ans = 0;
  rep(i, n) {
    if (c[a[i]]) {
      ans++;
      c[a[i]] = false;
    }
  }
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 5376
N, M = map(int, input().split())

if N % 2 == 1:
    for a in range(1, M + 1):
        print(a, N - a + 1)
else:
    for a in range(1, M + 1):
        if a <= N // 4:
            print(a, N - a + 1)
        else:
            print(a, N - a)

Measured memory_bytes: 9180
n = int(input())
a = [0]*n
b = [0]*n
c = [0]*n
for i in range(n):
    a[i], b[i], c[i] = map(int, input().split())

dpa = [a[0]]+[0]*(n-1)
dpb = [b[0]]+[0]*(n-1)
dpc = [c[0]]+[0]*(n-1)
for i in range(1,n):
    dpa[i] = max(dpb[i-1]+a[i],dpc[i-1]+a[i])
    dpb[i] = max(dpc[i-1]+b[i],dpa[i-1]+b[i])
    dpc[i] = max(dpa[i-1]+c[i],dpb[i-1]+c[i])

print(max(dpa[-1], dpb[-1], dpc[-1]))

Measured memory_bytes: 52196
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int main(int argc, char const *argv[])
{
	int n,l;
	cin>>n>>l;
	int sum = (n + 2 * l - 1) * n / 2;
	int ans = 1e8,p = 0;
	for(int i = 1;i <= n; ++i)
	{
		if(abs(i + l - 1) < ans)
		{
			ans = abs(i + l - 1);
			p = i + l - 1;
		}
	}
	cout<<sum - p<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

// bool isOk(int index, int key)
// {
//     if (d[index] >= key)
//         return true;
//     else
//         return false;
// }

// int C(int key)
// {
//     int ng = -1;
//     int ok = N;

//     while (abs(ok - ng) > 1)
//     {
//         int mid = (ok + ng) / 2;
//         if (isOk(mid, key))
//             ok = mid;
//         else
//             ng = mid;
//     }
//     return ok;
// }

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<pair<int, int>> p(N);
    rep(i, N) cin >> p[i].first >> p[i].second;
    sort(all(p));

    ll cnt = 0;
    rep(i, N)
    {
        cnt += p[i].second;
        if (K <= cnt)
        {
            cout << p[i].first << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {
	int n,i;
	cin >> n>>i;
	
	cout << n+1-i << endl;
}

Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader br = new BufferedReader( new InputStreamReader(System.in) );
		String stdin;
		while( (stdin=br.readLine()) != null )
		{
			String params[] = stdin.split( " " );
			if( params.length >= 2 )
			{
				int a = Integer.parseInt( params[0] );
				int b = Integer.parseInt( params[1] );
				System.out.println( gcd(a,b) + " " + lcm(a,b) );
			}
		}
	}
	
	public static int gcd( int a, int b )
	{
		return (b==0)? a : gcd(b,a%b);
	}
	public static int lcm( int a, int b )
	{
		return a / gcd(a,b) * b;
	}
}

Measured memory_bytes: 16928
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int N,K;
    ll count = 0;
    cin >> N >> K;
    vector<int> H(N);

    rep(i, N){
        cin >> H.at(i);
    }

    sort(all(H));

    rep(i, K){
        H.pop_back();
    }

    rep(i, H.size()){
        count += H.at(i);
    }

    cout << count << endl;
}

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

using namespace std;

void changeSW(char x, int &y ,bool &c){
  if(x == 'a'){y = 0;}
  if(x == 'b'){y = 1;}
  if(x == 'c'){y = 2;}
  if(x == '0'){c = true;}
}


int main (){
  string A,B,C;
  int ctA = 0,ctB = 0,ctC = 0,sw = 0;
  cin >> A >> B >> C;
  bool end = false;
  A.push_back('0');
  B.push_back('0');
  C.push_back('0');
  
  for(int i = 0; end == false; i++){
    if(sw == 0){
      changeSW(A.at(ctA),sw,end);
      ctA++;
      if(end == false){continue;}
    }
    if(sw == 1){
      changeSW(B.at(ctB),sw,end);
      ctB++;
      if(end == false){continue;}
    }
    if(sw == 2){
      changeSW(C.at(ctC),sw,end);
      ctC++;
      if(end == false){continue;}
    }
    
  }
  char answer;
  if(sw == 0){answer = 'A';}
  if(sw == 1){answer = 'B';}
  if(sw == 2){answer = 'C';}
    
  cout << answer << endl;
  return 0;
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;
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; }
const ll inf = 1ll << 60;



int main() {
    int n;
    cin >> n;
    cout << n/3;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INFTY (1<<30)

int n;
vector<int> color(10001,0),d(10001,INFTY);
vector<vector<pair<int,int>>> M(10001,vector<pair<int,int>>(0));
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;

void dijkstra(int s){
    d[s]=0;
    pq.push(make_pair(0,s));
    while(!pq.empty()){
        int u=pq.top().second;
        int a=pq.top().first;
        pq.pop();
        color[u]=2;
        if(d[u]<a) continue;
        for(int i=0;i<M[u].size();i++){
            int v=M[u][i].first;
            if(color[v]!=2){
                if(d[u]+M[u][i].second<d[v]){
                    d[v]=d[u]+M[u][i].second;
                    color[v]=1;
                    pq.push(make_pair(d[v],v));
                }
            }
        }
    }

}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        int a,b,c,k;
        cin>>a>>k;
        for(int j=0;j<k;j++){
            cin>>b>>c;
            M[a].push_back(make_pair(b,c));
        }
    }

    dijkstra(0);

    for(int i=0;i<n;i++){
        cout<<i<<' '<<d[i]<<endl;
    }
}


Measured memory_bytes: 8168
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int h,w;
	string nojima[100];
	cin>>h>>w;
	for(int i=0;i<h;i++){
		cin>>nojima[i];
	}
	
	for(int i=0;i<h;i++){
		cout<<nojima[i]<<endl;
		cout<<nojima[i]<<endl;
	}
	
	return 0;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>

int main(){
    int32_t N;
    std::cin >> N;
    
    int32_t i,j,k;
    int32_t cnt = 0;
    for(i=1;i<=N;i++){
        for(j=1;j<=N;j++){
            for(k=1; k<=N; k++){
                cnt++;
            }
        }
    }

    std::cout << cnt;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <vector>
int main(){
int n;
  cin >> n;
vector<long long int> a(n);
 for(int i = 0; i < n; i++){
  cin >> a[i];
  if(a[i]==0){
   cout << 0 << endl;
    return 0;
  }
 }
  long long int sum = 1;
  for(int i = 0; i < n; i++){
      
  if(sum > 1000000000000000000/a[i]){
    cout << "-1" << endl;
   return 0; 
  }
    sum*=a[i];
  }
  cout << sum << endl;
}

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


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

	int n;
	cin>>n;
	int d[n];
	for(int i = 0; i < n; i++) cin>>d[i];
	unsigned long int sum = 0;
	for(int i = 0; i < n; i++) {
		for(int j = i+1; j < n; j++) {
			sum += d[i]*d[j];
		}
	}

	cout<<sum<<"\n";

}

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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

ll digsum(ll x, ll b){
  ll mx = 1LL;
  while (mx * b <= x) mx *= b;

  ll ans = 0LL;
  while (x){
    ans += (x / mx);
    x %= mx;
    mx /= b;
  }

  return ans;
}

void solve(){
  ll n, s;
  cin >> n >> s;

  for (ll i = 2; i < 1e6; i++){
    if (digsum(n, i) == s){
      cout << i << '\n';
      return;
    }
  }

  //kx + b = n
  //k + b = s
  //n - s = kx-k
  //n - s = k(x-1)

  if (n == s) {
    cout << n + 1LL << '\n';
    return;
  }

  ll mn = -1;
  for (ll i = 1; i <= sqrt(n - s); i++){
    if ((n-s) % i == 0LL){
      ll res = (n-s)/i + 1;
      //cerr << res << '\n';
      if (res > s-i && res * i <= n)
        mn = res;
    }
  }

  cout << mn << '\n';
}

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}


Measured memory_bytes: 3700
S = input()
T = 'KIHBR'
t = ''
pre = '#'
for i in S:
    if i != 'A':
        t += i
    else:
        if pre not in ['#', 'H', 'B', 'R']:
            print('NO')
            exit()

    pre = i


if t == T:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
     
template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    

int main() {
  ll a,b,c,d,x=0,y=0,z=0,k,n,m,h,w,ans=0,sum=0,Max=-1,Min=1e9+1;
  bool ok = true;
  string s,t,r;
  cin >> a >> b >> c >> d;
  while(1){
    c -= b;
    if(c<=0){
      cout << "Yes" << endl;
      return 0;
    }
    a -= d;
    if(a<=0){
      cout << "No" << endl;
      return 0;
    }
  }
  return 0;
}

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

const int N = 1000;
int a[N],n;

int main() {
    ios::sync_with_stdio(0);
    cin>>n;
    n*=2;
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    int ans = 0;
    for(int i=1;i<n;i+=2) {
        ans += a[i];
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	void main() {
		try(Scanner sc = new Scanner(System.in)){

			for(;;) {
				int y = sc.nextInt();
				int x = sc.nextInt();
				if(x == 0 && y == 0) break;
				System.out.println(Math.min(x,y) + " " + Math.max(x,y));
			}
		}

	}
	public static void main(String[] args) {
		new Main().main();
	}
}



Measured memory_bytes: 34748
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
    char S[1000]={};
    char S2[2000]={};
    unsigned long K=0;
    unsigned long renzoku=0;
    unsigned long result=0;
    
    scanf("%s",S);
    scanf("%ld",&K);
    int sw=0;
    unsigned long temp_renzoku=0;
    unsigned long renzoku2=0;

    for(unsigned long i=0;i<strlen(S)-1;i++){
        if(S[i]!=S[i+1]){
            sw=1;
            break;
        }
    }
    if(sw==0){
        printf("%ld\n",(strlen(S)*K)/2);
        return 0;
    }
    sw=0;
    for(unsigned long i=0;i<strlen(S)-1;i++){
        if(S[i]==S[i+1]&&sw==0){
            temp_renzoku=2;
            sw=1;
            if(i+1==strlen(S)-1){
                renzoku+=temp_renzoku/2;
                temp_renzoku=0;
                sw=0;
            }
            
        }
        else if(S[i]==S[i+1]&&sw==1){
            temp_renzoku+=1;
            if(i+1==strlen(S)-1){
                renzoku+=temp_renzoku/2;
                temp_renzoku=0;
                sw=0;
            }
        }
        else{
            renzoku+=temp_renzoku/2;
            temp_renzoku=0;
            sw=0;
        }
    }
    // printf("%ld\n",renzoku);
    sprintf(S2,"%s%s",S,S);
    
    for(unsigned long i=0;i<strlen(S2)-1;i++){
        if(S2[i]==S2[i+1]&&sw==0){
            temp_renzoku=2;
            sw=1;
            if(i+1==strlen(S2)-1){
                renzoku2+=temp_renzoku/2;
                temp_renzoku=0;
                sw=0;
            }
            
        }
        else if(S2[i]==S2[i+1]&&sw==1){
            temp_renzoku+=1;
            if(i+1==strlen(S2)-1){
                renzoku2+=temp_renzoku/2;
                temp_renzoku=0;
                sw=0;
            }
        }
        else{
            renzoku2+=temp_renzoku/2;
            temp_renzoku=0;
            sw=0;
        }
    }
    //printf("%ld %ld\n",renzoku,renzoku2);
    result=renzoku+(renzoku2-renzoku)*(K-1);
    printf("%ld\n",result);
    return 0;
}

Measured memory_bytes: 128
N,L = map(int,input().split())

a = 10**6
b = 0
ans = 0
for i in range(1,N+1):
    if abs(L+i-1) < a:
        a = abs(L+i-1)
        b = i

for i in range(1,N+1):
    if i != b:
        ans += (L+i-1)

print(ans)




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


import sys
if n == 2:
    print(max(a))
    sys.exit()


def gcd(x, y):
    while y:
        x, y = y, x % y
    return x


g = a[0]
gcd_left = [g]
for i in range(n-1):
    g = gcd(g, a[i+1])
    gcd_left.append(g)

g = a[n-1]
gcd_right = [g]
for i in range(n-1):
    g = gcd(g, a[n-2-i])
    gcd_right.append(g)

max_gcd = gcd_right[n-2]
for i in range(1, n-1):
    max_gcd = max(max_gcd, gcd(gcd_left[i-1], gcd_right[n - 2 - i]))
max_gcd = max(max_gcd, gcd_left[n-2])

print(max_gcd)

Measured memory_bytes: 14584
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n, k, best=0, ans=0;
int t[N], d[N], f[N];
set<int> types;
multiset<pair<int, int> > removable;
pair<int, int> a[N];

int32_t main()
{
	IOS;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>t[i]>>d[i];
		a[i].first=d[i];
		a[i].second=t[i];
	}
	sort(a+1, a+n+1);
	reverse(a+1, a+n+1);
	for(int i=1;i<=k;i++)
	{
		removable.insert({a[i].first, a[i].second});
		f[a[i].second]++;
		ans+=a[i].first;
		types.insert(a[i].second);
	}
	int sz=types.size();
	best=ans + sz*sz;
	for(int i=k+1;i<=n;i++)
	{
		if(types.find(a[i].second)!=types.end())
			continue;
		if(!removable.size())
			break;
		bool check=0;
		while(removable.size())
		{
			auto it=*removable.begin();
			if(f[it.second]==1)
				removable.erase(removable.find(it));
			else
			{
				check=1;
				ans-=it.first;
				f[it.second]--;
				removable.erase(removable.find(it));
				break;
			}
		}
		if(!check)
			break;
		ans+=a[i].first;
		f[a[i].second]++;
		types.insert(a[i].second);
		sz++;
		best=max(best, ans + sz*sz);
	}
	cout<<best;
	return 0;
}


Measured memory_bytes: 13056
def print_it(l, n):
    print(''.join([l[x % 2] for x in range(n)]))


while True:
    height, width = map(int, input().split())
    if height == 0:
        break
    for j in range(height):
        a = ['#', '.'] if j % 2 == 0 else ['.', '#']
        print("".join([a[i%2] for i in range(width)]))
    print()

Measured memory_bytes: 5624
import java.util.*;
import java.math.*;

public class Main {

  static int min = 10000;

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

    long x = kaijo(n);
    long y = kaijo(m);

    System.out.println(x+y);



  }

  public static long kaijo (long x) {
    long sum = 0;
    while (x > 0) {
      x--;
      sum += x;
    }
    return sum;
  }

}


Measured memory_bytes: 23380
#include <stdio.h>

int mtoi(char *str)
{
    int i;
    int ret;
    
    i = ret = 0;
    while (str[i] != '\0'){
        switch(str[i]){
            case 'm':
            ret += (i - 1 >= 0 && '0' <= str[i - 1] && str[i - 1] <= '9' ? str[i - 1] - '0' : 1) * 1000;
            break;
            
            case 'c':
            ret += (i - 1 >= 0 && '0' <= str[i - 1] && str[i - 1] <= '9' ? str[i - 1] - '0' : 1) * 100;
            break;

            case 'x':
            ret += (i - 1 >= 0 && '0' <= str[i - 1] && str[i - 1] <= '9' ? str[i - 1] - '0' : 1) * 10;
            break;

            case 'i':
            ret += (i - 1 >= 0 && '0' <= str[i - 1] && str[i - 1] <= '9' ? str[i - 1] - '0' : 1);
            break;
        }
        i++;
    }
    
    return (ret);
}

void itom(int t, char *ret)
{
    int len;
    
    len = 0;
    if (t / 1000){
        if (t / 1000 != 1){
            ret[len++] = t / 1000+ '0';
        }
        ret[len++] = 'm';
        t %= 1000;
    }
    if (t / 100){
        if (t / 100 != 1){
            ret[len++] = t / 100+ '0';
        }
        ret[len++] = 'c';
        t %= 100;
    }
    if (t / 10){
        if (t / 10 != 1){
            ret[len++] = t / 10+ '0';
        }
        ret[len++] = 'x';
        t %= 10;
    }
    if (t){
        if (t != 1){
            ret[len++] = t + '0';
        }
        ret[len++] = 'i';
    }
    ret[len] = '\0';
}

int main(void)
{
    int a, b;
    char str[128];
    int i, t;
    
    scanf("%d", &t);
    
    for (i = 0; i < t; i++){
        scanf("%s", str);
        a = mtoi(str);
        scanf("%s", str);
        b = mtoi(str);
        
        itom(a + b, str);
        printf("%s\n", str);
    }
    
    return (0);
}

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

int main(){
    int H, A;
    cin >> H >> A;

    if (H % A == 0) cout << H/A << endl;
    else cout << H/A + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
import itertools

N, X, Y = map(int, input().split())

combi = list(itertools.combinations(range(1,N+1), 2))
dist = [[i+1, 0] for i in range(0, N-1)]

c = [min([kyori[1] - kyori[0], int(abs((kyori[1] - Y))) + 1 + int(abs((X - kyori[0])))]) for kyori in combi]

for i in range(len(c)):
    dist[c[i]-1][1] += 1
for i in range(0, N-1):
    print(dist[i][1])


Measured memory_bytes: 185276
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int zoning[200][200] = {};
int main(){
	int w, h, n;
	cin >> w >> h >> n;
	REP(i, n) {
		int a, b, c;
		cin >> a >> b >> c;
		switch (c) {
			case 1:
				for (int i = 0; i < a; ++i) {
					for (int q = 0; q < h; ++q) {
						zoning[i][q] = 1;
					}
				}
				break;
			case 2:
				for (int i = a; i < w; ++i) {
					for (int q = 0; q < h; ++q) {
						zoning[i][q] = 1;
					}
				}
				break;
			case 4:
				for (int i = 0; i < w; ++i) {
					for (int q = b; q < h; ++q) {
						zoning[i][q] = 1;
					}
				}
				break;
			case 3:
				for (int i = 0; i < w; ++i) {
					for (int q = 0; q < b; ++q) {
						zoning[i][q] = 1;
					}
				}
				break;
		}
	}
	int ans = 0;
	REP(i, w) {
		REP(q, h) {
			ans += 1 - zoning[i][q];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
//\\//\\ * * * //\\// ||
#include <bits/stdc++.h> 

#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;

const int N = (int) 2e5 + 10;

class dsu {
 public:
  int p[N];
  int n;

  dsu(int _n) : n(_n) {
    iota(p, p + n, 0);
  }

  inline int get(int x) {
    return (x == p[x] ? x : (p[x] = get(p[x])));
  }

  inline bool unite(int x, int y) {
    x = get(x);
    y = get(y);
    if (x != y) {
      p[x] = y;
      return true;
    }
    return false;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, tt;
  cin >> n >> tt;
  dsu d(n);
  while (tt--) {
    int t, a, b;
    cin >> t >> a >> b;
    if (t == 0) {
      d.unite(a, b);
    } else {
      cout << (d.get(a) == d.get(b)) << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 4288
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
#define MODSIZE 1000000007
// priority_queue<int, vector<int>, greater<int> > PQ; // 昇順PQ
priority_queue<ll> pq[200006];

int main(){
  char s[2];

  scanf("%s", s);
  if(s[0] >= 'a' && s[0] <= 'z') printf("a\n");
  else printf("A\n");
  return 0;
}


Measured memory_bytes: 10008
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

//dp[i][j]はそれぞれiグラム、jグラム買うときの最小価格
vector<vector<ll>> dp(500, vector<ll>(500, INF));

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A;
    cin >> A;
    ll B;
    cin >> B;
    vector<ll> X(N,0);
    for(ll i=0;i<N;++i)cin>>X[i];
    ll ans=0;
    for(ll i=1;i<N;++i){
        ans+=min(A*(X[i]-X[i-1]),B);
    }
    prt(ans)

    return 0;
}


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

count = 0
for i in a:
    if i % 4 == 0:
        count +=2
    elif i %2 == 0 :
        count+=1
    else:
        continue

if len(a)%2 == 0:
    if count >=len(a):
        print("Yes")
    else:
        print("No") 
else:
    if count >= len(a)-1:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<(int64)n;i++)
#define FORr(i,k,n)  for(int64 i=(int64)k;i>=n;i--)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define FOREACHr(it, l) for (auto it = l.rbegin(); it != l.rend(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
const int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddx[4] = {1,0,-1,0};
const int ddy[4] = {0,1,0,-1};
//ONLINE_JUDGE   LOCAL
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}

int main(){
	//in_o();
	int n,k,S;
	scanf("%d%d%d",&n,&k,&S);
	if(S+1<=1000000000)
	{
		for(int i=0;i<k;i++) printf("%d ",S);
		for(int i=k;i<n;i++) printf("%d ",S+1);puts("");
	}
	else
	{
		for(int i=0;i<k;i++) printf("%d ",S);
		for(int i=k;i<n;i++) printf("%d ",1);puts("");
	}

	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>

int N, M;
int p[114514];
int isAC[114514];

int asumisu[114514];

int main(void) {
	int i;
	int mizuhasu = 0, kitaeri = 0;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < M; i++) {
		char S[4];
		if (scanf("%d%3s", &p[i], S) != 2) return 1;
		isAC[i] = (S[0] == 'A');
	}
	for (i = 0; i < M; i++) {
		if (asumisu[p[i]] >= 0) {
			if (isAC[i]) {
				mizuhasu++;
				kitaeri += asumisu[p[i]];
				asumisu[p[i]] = -1;
			} else {
				asumisu[p[i]]++;
			}
		}
	}
	printf("%d %d\n", mizuhasu, kitaeri);
	return 0;
}


Measured memory_bytes: 1408
(N, K) = [int(x) for x in input().split()]
P = [int(x) - 1 for x in input().split()]  # 0 indexed
C = [int(x) for x in input().split()]


inf = float("inf")


ans = max(C)  # at least one move
for pos in range(N):
    i = pos
    score = 0
    cycleLen = None
    cycleGain = None
    bestInc = 0
    k = 0
    while k < K:
        i = P[i]
        score += C[i]
        ans = max(ans, score)

        if i == pos:
            cycleLen = k + 1
            numCycles = max(0, (K - k - cycleLen) // cycleLen)
            if k + numCycles * cycleLen < K:
                k += numCycles * cycleLen
                score += numCycles * score
        k += 1

print(ans)


Measured memory_bytes: 68436
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int n,k;
int ans=1e18;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>k;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(all(a));
	for(int i=0;i+k<=n;i++) ans=min(ans,a[i+k-1]-a[i]);
	cout<<ans;
	re 0;
}

Measured memory_bytes: 3944
#include <iostream>
#include <string>
#include <cstdint>
#include <algorithm>
#include <cmath>
#include <vector>
#include <unordered_map>

int main()
{
	int N, P;
	std::string S;

	std::cin >> N >> P >> S;

	int64_t count = 0;

	if (P == 2 || P == 5)
	{
		for (int i = 0; i < N; ++i)
		{
			if ((S[i] - '0') % P == 0)
			{
				count += i + 1;
			}
		}
	}
	else
	{
		std::vector<int> value;
		value.resize(N + 1, 0);

		int base = 1;
		for (int i = N - 1; i >= 0; --i)
		{
			value[i] = ((S[i] - '0') * base + value[i + 1]) % P;
			base = (base * 10) % P;
		}

		std::unordered_map<int, int64_t> mode_map;
		for (int i = 0; i < N; ++i)
		{
			mode_map[value[i]] += 1;
		}

		count += mode_map[0];
		for (auto iter = mode_map.begin(); iter != mode_map.end(); ++iter)
		{
			count += (iter->second) * (iter->second - 1) / 2;
		}
	}

	std::cout << count << std::endl;

	return 0;
}

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


typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll h,w,m;
    map<pair<ll,ll>,ll> ram ; 
    map<ll,ll> a1,b1 ; 
    cin>>h>>w>>m ;
    ll i = 1 ; 
    while(i<=m)
    {ll x,y;cin>>x>>y;
    ram[{x,y}]++;
    a1[x]++;
    b1[y]++;
        
        
        i++;
    }
    vector <ll> X,Y;
    map <ll,ll> :: iterator itr;ll m1=-1;
for(itr = a1.begin(); itr != a1.end();++itr) 
    {   ll x1=itr->first;
        ll y1=itr->second;
        //cout<<x1<<" "<<y1;
        m1=max(m1,y1);
        //cout<<"\n";
    }
    
    for(itr = a1.begin(); itr != a1.end();++itr) 
    {   ll x1=itr->first;
        ll y1=itr->second;
        if(y1==m1)
        { X.push_back(x1);
            //cout<<x1<<"\n";
        }
       
        //cout<<"\n";
    }
    ll m2=-1;
    for(itr = b1.begin(); itr != b1.end();++itr) 
    {   ll x1=itr->first;
        ll y1=itr->second;
        //cout<<x1<<" "<<y1;
        m2=max(m2,y1);
        //cout<<"\n";
    }
    
    for(itr = b1.begin(); itr != b1.end();++itr) 
    {   ll x1=itr->first;
        ll y1=itr->second;
        if(y1==m2)
        {Y.push_back(x1);
            //cout<<x1<<"\n";
        }
        //cout<<"\n";
    }
    
    ll count=0;
    i=0;
    while(i<X.size() && count<=m+2)
    {
        
        
        ll j=0;
        while(j<Y.size() && count<=m+2)
        {
            
            
            ll x1=X[i];
            ll y1=Y[j];
            if(ram[{x1,y1}]==0)
            {
                count=1e18;
            }
            else
            {
                count++;
            }
            
            j++;
            
        }
        
        
        
        
        i++;
    }
    if(count==1e18)
    {
        cout<<m1+m2;
    }
    else
    {
        cout<<m1+m2-1;
    }
    
    
    return 0;
}

Measured memory_bytes: 67844
#include<stdio.h>
int main(void)
{
	int h1,h2,k1,k2,a,b,c,d,x,y;
	scanf("%d %d",&h1,&h2);
	scanf("%d %d",&k1,&k2);
	scanf("%d %d %d %d",&a,&b,&c,&d);
	x=(h1*a)+(h2*b)+((h1/10)*c)+((h2/20)*d); 
	y=(k1*a)+(k2*b)+((k1/10)*c)+((k2/20)*d);
	if(x>y){
		printf("hiroshi\n");
	}
	if(x<y){
		printf("kenjiro\n");
	}
	if(x==y){
		printf("even\n");
	}
	return 0;
}



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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

signed main(){
    string s1, s2;
    cin >> s1 >> s2;
    const int n = s1.size(), m = s2.size();
    vector<vector<int>> dp(n+1, vector<int>(m+1));
    rep(i, n+1) dp[i][0] = i;
    rep(i, m+1) dp[0][i] = i;

    rep(i, n) {
        rep(j, m) {
            int cost = s1[i] == s2[j] ? 0 : 1;
            dp[i+1][j+1] = min(dp[i][j] + cost, min(dp[i][j+1]+1, dp[i+1][j]+1));
        }
    }
    cout << dp[n][m] << nl;
}



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

int main() {
  int N;
  string S;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> S;
    if(S=="Y"){
      cout << "Four" << endl;
      break;
    }
  }
  if(S!="Y"){
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256