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

int main(void){
    int n, a[110];
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    int min = 100000000;
    for(int i=-100;i<=100;++i){
        int cost=0;
        for(int j=0;j<n;++j){
            cost += (i-a[j])*(i-a[j]);
        }
        if(min > cost) min = cost;
    }
    cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb emplace_back
#define mp make_pair

using namespace std;

int sum(int n, int a) {
	return ((n  * (2 * a + n - 1)) / 2);
}

int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10);
	int n; cin >> n;
	int l; cin >> l;
	if (l <= 0 && n + l - 1 >= 0) {
		cout << sum(n, l);
	} else if (l < 0)  {
		cout << sum(n - 1, l);
	} else {
		cout << sum(n - 1, l + 1);
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
	int N, L;
	cin >> N >> L;
	vector<string> S(N);
	for (int i = 0; i < N; ++i) {
		cin >> S[i];
	}
	sort(S.begin(), S.end());
	string answer = "";
	for (int i = 0; i < N; ++i) {
		answer = answer + S[i];
	}
	cout << answer << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
main(){
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    int m;
    scanf("%d",&m);
    int b[11]={};
    int j=0;
    while(m>0){
      b[j]=m%10;
      m/=10;
      j++;
    }
    /*    for(int k=0;k<j;k++) printf("%d",b[k]);
    puts("");
    printf("%d\n",j);
    for(int k=0;k<j;k++) printf("%d",b[k]);
    puts("");*/
    sort(b,b+j);
    int maxx=0,minn=0;
    for(int k=0,keta=1;k<j;k++,keta*=10){
      maxx+=b[k]*keta;
    }
    for(int k=j-1,keta=1;k>-1;k--,keta*=10){
      minn+=b[k]*keta;
    }
    printf("%d\n",maxx-minn);
  }
}

Measured memory_bytes: 1044
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vvl = vector<vector<ll>>;
using vl  = vector<ll>;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll MOD = 1000000007;
const double PI = acos(-1);  
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
//map<int,int>mp

ll n;
ll ans;
//string s;
signed main(){
	acc_io;
	ans=0;
	cin>>n;
	ll rt;
	ll a=0,b=0;
	ll is_pr=1;
	rt=sqrt(n);
	for(int i=rt;i>1;i--){
		if(n%i==0){
			is_pr=0;
			b=n/i;
			break;
		}
	}
	if(is_pr){
		a=n;
	}
	else{
		if(n%b){
			for(int j=b;j<n;j++){
				if(n%j==0){
					b=n/j;
					break;
				}
			}
		}
		a=n/b;
	}
//		cout<<a<<" "<<b<<endl;
	a=max(a,b);
	int ans=1;
	rep(i,0,10){
		a/=10;
		if(a>0){
			ans++;
		}
		else{
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a_list = [int(i) for i in input().split()]
f_list = [int(i) for i in input().split()]
a_list.sort(reverse=True)
f_list.sort()

if k >= sum(a_list):
    print(0)
    exit()

point = []
for i in range(n):
    point.append(a_list[i] * f_list[i])

import math
def binary_search(point, k):
    left = 0
    right = 10 ** 12
    while left + 1< right:
        ans = 0
        center = (left + right) // 2
        for i in range(n):
            if point[i] > center:
                ans += a_list[i] - (center // f_list[i])
        if ans <= k:
            right = center
        else:
            left = center
    return left
    
value = binary_search(point, k)
print(value + 1)


Measured memory_bytes: 122012
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

string S;

cin >> S;

if(S == "ARC") cout << "ABC" << endl;
else cout << "ARC" << endl;

return 0;

}

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

int n,a[100010];
bool has[100010];

int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    int cnt=0;
    for(int i=0;i<n;i++){
        if(!has[a[i]]){
            cnt++;
            has[a[i]]=1;
        }
    }
    if(cnt%2==1) printf("%d\n",cnt);
    else printf("%d\n",cnt-1);
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#define NIL -1
using namespace std;
int f[45] = {};

int fib(int n){
  if(n == 0 || n == 1){
    //cout << "a;n = " << n << " " << "f[n] = " << f[n] << endl;
    return f[n] = 1;
  }
  if(f[n] != NIL){
    //cout << "b;n = " << n << " " << "f[n] = " << f[n] << endl;
    return f[n];
  }
  //cout << "c;n = " << n << " " << "f[n] = " << f[n] << endl;
  return f[n] = fib(n - 1) + fib(n - 2);
}

int main(){

  int n;
  cin >> n;

  for(int i = 0;i < 45;i++) f[i] = NIL;

  cout << fib(n) << endl;

}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
int n;
std::vector<std::vector<int>> p;
int main(){
  cin >> n;
  p.resize(n, vector<int>(3));
  for (size_t i = 0; i < n; i++) {
    cin >> p[i][0] >> p[i][1] >> p[i][2];
    sort(p[i].begin(),p[i].end());
  }
  sort(p.begin(),p.end());
  int ans=0;
  for (size_t i = 0; i < n-1; i++) {
    if(p[i][0] == p[i+1][0] && p[i][1] == p[i+1][1] && p[i][2] == p[i+1][2]){
      ans++;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3224
/*
    author: kartik8800
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define inf (1LL<<60)
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x 
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll dp[1001][10001];
struct box
{
    int si;
    int wi;
    ll val;
};

bool comp(box& b1, box& b2)
{
    return b1.si + b1.wi > b2.si + b2.wi;
}

ll solve(vector<box>& v)
{
    int n = v.size();
    sort(v.begin(), v.end(), comp);
    for(int j = 0; j <= 10000; j++)
    {
        if(v[0].si >= j)
            dp[0][j] = v[0].val;
        else dp[0][j] = 0;
    }

    for(int i = 1; i < n; i++)
    {
        for(int j = 0; j <= 10000; j++)
        {
            ll op1 = dp[i-1][j];
            ll op2 = (v[i].si >= j) ? (v[i].val + ((j + v[i].wi > 10000)?0:dp[i-1][j+v[i].wi])) : 0;
            dp[i][j] = max(op1, op2);
        }
    }
    return dp[n-1][0];
}

int main() {
   int n;
   cin >> n;
   vector<box> v(n);
   for(int i = 0; i < n; i++)
        cin >> v[i].wi >> v[i].si >> v[i].val;
   cout << solve(v);
   return 0;
}


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

int h, w, n, r, c, to, mn[200005];
int main() {
	int i;
	cin >> h >> w >> n;
	for(i=1; i<=h; i++) mn[i] = 1e9;
	while(n--) {
		scanf("%d%d", &c, &r);
		mn[c] = min(mn[c], r);
	}
	for(i=1; i<=h; i++) {
		if(mn[i] <= to) break;
		if(to+1 < mn[i]) to++;
	}
	cout << i-1;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
	int W, H, x, y ,r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, m, n) for(int i = m;i >= n;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
    int n;
    ll a[200005]={},sum1=0,sum2=0,a_min=1e18;
    cin>>n;
    rep(i,0,n){
        cin>>a[i];
        sum2+=a[i];
    }
    rep(i,0,n-1){
        sum1+=a[i];
        a_min=min(a_min, abs(2*sum1-sum2));
    }
    cout<<a_min<<endl;
}

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

int main(){
  int m, f, r, sum;

  while(true){
    cin >> m >> f >> r;
    sum = m + f;

    if(m < 0 && f < 0 && r < 0) break;
    else if(m < 0 || f < 0) cout << 'F';
    else if(sum >= 80) cout << 'A';
    else if(sum < 80 && sum >= 65) cout << 'B';
    else if(sum < 65 && sum >= 50) cout << 'C';
    else if(sum < 50 && sum >= 30){
      if(r >= 50) cout << 'C';
      else cout << 'D';
    }
    else cout << 'F';
    cout << endl;
  }
  return 0;
}

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

namespace abc154_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var K = CIn.ReadInt();
      var p = CIn.ReadIntArray(N);

      var accSum = new double[N + 1];

      for (int i = 0; i < N; i++)
      {
        accSum[i + 1] = accSum[i] + (double)((p[i] + p[i] * p[i]) / 2) / p[i];
      }

      var max = 0.0;

      for (int i = 0; i <= N - K; i++)
      {
        max = Math.Max(max, accSum[i + K] - accSum[i]);
      }

      Console.WriteLine(max);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 34652
#include<bits/stdc++.h>
using namespace std;
#define LINE 8
#define st 1
#define YOKO 17
int main(){
    int N;
    cin>>N;
    int A[N+2];
    for(int i=1;i<N+1;i++){
        cin>>A[i];
    }
    A[0]=0;
    A[N+1]=0;
    int sum=0;
    for(int i=1;i<N+2;i++){
        if(A[i]-A[i-1]>=0){
            sum+=A[i]-A[i-1];
        }else{
            sum+=A[i-1]-A[i];
        }
    }
    int SUM=sum;
    for(int i=1;i<N+1;i++){
        sum=SUM;
        if(A[i]<A[i+1] && A[i]<A[i-1] && A[i-1]>=A[i+1]){
            sum-=(A[i+1]-A[i])*2;
            cout<<sum<<endl;
        }else if(A[i]<A[i+1] && A[i]<A[i-1] && A[i-1]<=A[i+1]){
            sum-=(A[i-1]-A[i])*2;
            cout<<sum<<endl;
        }else if(A[i]>A[i+1] && A[i]>A[i-1] && A[i-1]>=A[i+1]){
            sum-=(A[i]-A[i-1])*2;
            cout<<sum<<endl;
        }else if(A[i]>A[i+1] && A[i]>A[i-1] && A[i-1]<=A[i+1]){
            sum-=(A[i]-A[i+1])*2;
            cout<<sum<<endl;
        }else{
            cout<<sum<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>
 
int main(void) { 
  
  int count;
  
  scanf("%d", &count);
  
  int i;
  for(i = 0; i < count; i++) {
      int blockCount;
      scanf("%d", &blockCount);
      
      int j;
      int before, next, upDiff, downDiff;
      upDiff = downDiff = 0;
      
      scanf("%d", &before);
      
      for(j = 1; j < blockCount; j++) {
          scanf("%d", &next);
          int currentDiff = next - before;
          before = next;
          
          if(currentDiff > 0) { //登るとき
              if(currentDiff > upDiff) {
                  upDiff = currentDiff;
              }
          } else { //降りるとき
              if(currentDiff < downDiff) {
                  downDiff = currentDiff;
              }
          }
      }

      printf("%d %d\n", upDiff, abs(downDiff));
  }
  
  return 0;
  
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;

intt H;
int n;
int a[N];
map <intt, intt> mp;

intt kill (intt H) {
	if (mp[H] != 0) return mp[H];
	if (H == 1) return 1;
	return 2 * kill(H / 2) + 1;
}

int main() {

	FAST;

	cin >> H;
	cout << kill(H) << '\n';
	return 0;
}

Measured memory_bytes: 256
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline-------------------------------------------
    N = int(input())
    p = list(map(int,input().split()))
    ans = 0
    flag = False
    for i in range(N):
        if p[i] == i+1:
            if flag:
                flag = False
            else:
                ans += 1
                flag = True
        else:
            flag = False
    print(ans)
if __name__ == "__main__":
    main() #endline===============================================

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

int main(){
vector<int>a(5);
  int b,c;
  b=10;
  c=0;
  for(int i=0;i<5;i++){
  cin>>a[i];
    if(a[i]%10==0){
      c=c+a[i];
        }
    else{
    c=c+(a[i]/10+1)*10;
      b=min(b,a[i]%10);
    }
    }
  
  cout<<c-10+b<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  bool isok = true;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    isok &= (A % 2 != 0) || (A % 3 == 0) || (A % 5 == 0);
  }
  cout << (isok ? "APPROVED" : "DENIED") << endl;

  return 0;
}


Measured memory_bytes: 3648
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
d = defaultdict(int)
s = ['M','A','R','C','H']
for _ in range(n):
    a = input()
    for i,t in enumerate(s):
        if a[0] == t:
            d[i] += 1
res = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            res += d[i]*d[j]*d[k]
print(res)

Measured memory_bytes: 5324
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int digit_sum(int n){
	int ans=0;
	while(n>0){
		ans+=n%10;
		n/=10;
	}
	return ans;
}
int main()
{
	int n;
	cin >> n;

	if(n%digit_sum(n)){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int a, b, c, x, y;
	int p;
	
	scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);
	if(a+b>2*c){
		if(x>y){
			p=2*y*c;
		}else{
			p=2*x*c;
		}
		if(x-y>0){
			if(a<c){
				p+=a*(x-y);
			}else{
				if(c*(x-y)*2 < a*(x-y)){
					p+=c*(x-y)*2;
				}else{
					p+=a*(x-y);
				}
			}
			
		}else if(y-x>0){
			if(b<c){
				p+=b*(y-x);
			}else{
				if(c*(y-x)*2 < b*(y-x)){
					p+=c*(y-x)*2;
				}else{
					p+=b*(y-x);
				}
			}
		}
	}else{
		p=a*x+b*y;
	}
	printf("%d\n", p);
	return 0;
}

Measured memory_bytes: 128
n,x =  map(int, input().split())
lis = list(map(int, input().split()))

temp = 0
sum = 0
a = [0]
for i in range(len(lis)):
    sum = temp + lis[i]
    a.append(sum)
    temp = sum

count = 0
for i in range(len(a)):
    if(a[i] <= x):
        count += 1

print(count)
    

Measured memory_bytes: 3060
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int A[2000000];
int B[2000000];
int C[10001];

int Partition(int p, int r)
{
	int x = A[r];
	int i = p - 1;
	for (int j = p; j < r; j++)
	{
		if (A[j] <= x)
		{
			i++;
			int temp = A[i];
			A[i] = A[j];
			A[j] = temp;
		}
	}

	int temp = A[i + 1];
	A[i + 1] = A[r];
	A[r] = temp;
	return i + 1;
}

int main()
{
	int N;
	scanf("%d", &N);

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

	int q = Partition(0, N - 1);

	printf("%d", A[0]);
	for (int i = 1; i < N; i++)
	{
		if (i == q)
		{
			printf(" [%d]", A[i]);
		}
		else
		{
			printf(" %d", A[i]);
		}
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 3492
#include <stdio.h>
#include <stdlib.h>

int N;
int a[100];

int comp(const void* e1, const void* e2) {
  return *((int*)e2) - *((int*)e1);
}


int main()
{
  int i;
  int ans = 0;

  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf("%d", a + i);
  }

  qsort(a, N, sizeof(int), comp);

  for (i = 0; i + 1 < N; i += 2) {
    ans += (a[i] - a[i + 1]);
  }

  if (i == N - 1) {
    ans += a[N - 1];
  }

  printf("%d\n", ans);
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define TTF template<typename T, typename F>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline void Out(T&x){cout<<x;}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline int ubnd(T&v,ET(T)&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T)&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF inline void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF inline void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
#undef TT
#undef TTF
#undef ET

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}

const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000;
const int N = 10001;

bool sieve[N] = {true, true};
int main()
{
  for (int i = 2; i * i < N; i++){
    if (sieve[i]) continue;
    for (int j = i * i; j < N; j += i) sieve[j] = true;
  }
  vector<int> primes;
  for (int i = 0; i < N; i++){
    if (!sieve[i]) primes.push_back(i);
  }
  int pat[N] = {};
  for (int i = 0; i < primes.size(); i++){
    int sum = 0;
    for (int j = 0; j + i < primes.size(); j++){
      sum += primes[i + j];
      if (sum < N) pat[sum]++;
    }
  }
  int n;
  while (n = in()){
    printf("%d\n", pat[n]);
  }

  return (0);
}

// priority_queue queue deque front stringstream max_element min_element insert count make_tuple

Measured memory_bytes: 1264
import java.util.Scanner;

public class Main {
    public static void main(String[] args){

        Scanner sc =new Scanner(System.in);

        String S = sc.next();

        int pura =0;
        int mai = 0;

        for (int i=0; i<4; i++) {
          if (S.charAt(i) == '+'){
            pura += 1;
          }else if (S.charAt(i) == '-'){
            mai += 1;
          }
        }
        System.out.println(pura - mai);
    }
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define all(x, r) (x), (x)+(r)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define exst(x, data) (data).find(x) != (data).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define np next_permutation
#define b32 bitset<32>

using ll = long long;
using Pii = pair<int,int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;

class Edge {
public:
    int to, cap, rev;
    Edge(int t, int c, int r) {
        to = t;
        cap = c;
        rev = r;
    }
};
const int NODE_MAX = 101;

bool used[NODE_MAX];
vector<vector<Edge>> edges;
void edge_initializer(int n) {
    edges = vector<vector<Edge>>(n);
}
void add_edge(int from, int to, int cap) {
    edges[from].pb(Edge(to,cap,edges[to].size()));
    edges[to].pb(Edge(from,0,edges[from].size()-1));
}
int dfs(int v, int t, int f){
    if (v == t) return f;
    used[v] = true;
    for(int i=0; i < edges[v].size(); i++) {
        Edge &e = edges[v][i];
        if(!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                edges[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}
int max_flow(int s, int t){
    int flow = 0;
    while(true) {
        memset(used, 0, sizeof(used));
        int f = dfs(s,t,INT_MAX);
        if (f == 0) return flow;
        flow += f;
    }
}

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

    int V, E; cin >> V >> E;
    edge_initializer(V);
    rep(i,E) {
        int u, v, c; cin >> u >> v >> c;
        add_edge(u,v,c);
    }
    cout << max_flow(0,V-1) << endl;
    return 0;
}



Measured memory_bytes: 3248
from math import ceil
def main():
    x = int(input())
    r = 0
    for i1 in range(1, ceil(x**0.5) + 1):
        beki = 2
        while True:
            num = pow(i1, beki)
            if num <= x:
                r = max(r, num)
            else:
                break
            if num == pow(i1, beki - 1):
                break
            beki += 1

    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

map<int, int> mp;
string str;
int n;
int solve(string ss, int cnt){
	int mn = INF, mx = -1, m = ss.size();
	string s;
	rrep(i,m){
		s.push_back(ss[i-1]);
		if(i%cnt == 0){
			int num = atoll(s.c_str());
			//cout << s << " " << cnt << endl;
			chmax(mx, num);
			chmin(mn, num);
			s.clear();
			//printf("%lld %lld\n", num, cnt);
		}
	}
	//printf("%lld %lld %lld\n", mx, mn, cnt);
	return mx-mn;
}

int solve1(int cnt){
	string s = str;
	if(cnt > 4){
		s.clear();
		s = str.substr(0, cnt-3);
		rep(i,n/cnt)if(str.substr(i*cnt, cnt-3) != s){return INF;}
		s.clear();
		rep(i,n)if(i%cnt >= cnt-3)s += str[i];
		//cout << s << endl;
		cnt = 3;
	}
	return solve(s, cnt);
}

int solve2(){
	int mx = -1, mn = INF;
	string s;
	rep(i,n){
		s.pb(str[i]);
		if(str[i]-'0' != 1 or s.size() == 2){
			int num = atoll(s.c_str());
			chmax(mx, num);
			chmin(mn, num);
			s.clear();
		}
	}
	if(s.size() > 0){
		int num = atoll(s.c_str());
		chmax(mx, num);chmin(mn, num);
	}
	return mx-mn;
}

signed main(){
	cin >> str;
	n = str.size();
	for(int i = 1;i < n;i++){
		if(n%i == 0){mp[i] = 1;}
	}
	int ans = INF;
	for(map<int, int>::iterator it = mp.begin();it != mp.end();it++){
		chmin(ans, solve1(it->fi));
	}
	if(n != 2)chmin(ans, solve2());
	printf("%lld\n", ans);
	return 0;
}








Measured memory_bytes: 3456
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;

    cout << a - (a > b) << endl;


    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
#define _GLIBCXX_DEBUG

using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
int main()
{
    int X;
    cin >> X;

    int ans = 0;
 
    while(X - 500 >= 0) {
        X -= 500;
        ans += 1000;
    }

    while(X - 5 >= 0) {
        X -= 5;
        ans += 5;
    }
    cout << ans << "\n";
}

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

int main(){

    int n;
    cin >> n;

    int digit = 0, n_temp = n;
    while (n_temp != 0){
        n_temp /= 10;
        digit++;
    }

    int ans;

    if (digit == 1){
        cout << n << endl;
    }
    else if (digit == 2){
        cout << 9 << endl;
    }
    else if (digit == 3){
        cout << 9 + (n - 99) << endl;
    }
    else if (digit == 4){
        cout << 909 << endl;
    }
    else if (digit == 5){
        cout << 909 + (n - 9999) << endl;
    }
    else{
        cout << 90909 << endl;
    }

    return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, ans[505][505];

bool visited[505], color[505];


int DFS(int start, int level){
  if (visited[start]) return 0;
  visited[start] = true;

  for (int i = start + 1; i < N; i++){
    if (ans[start][i] == 0 && !visited[i]){
      if (color[start]) color[i] = false;
      else color[i] = true;
      DFS(i, level);
    }
  }


  for (int i = 0; i < N; i++){
    if (!visited[i]){
      DFS(i, level);
    }
  }

  return 0;
}


int main(){
  cin >> N;
  for (int L = 1; L <= N; L++){
    fill(visited, visited+ N, false);
    bool flag = false;
    int start = 0;
    for (int i = 0; i < N; i++){
      for (int j = i + 1; j < N; j++){
        if (ans[i][j] == 0){
          flag = true;
          start = i;
          DFS(i, L);
          break;
        }
      }
      if (flag) break;
    }

    if (!flag) break;

    for (int i = 0; i < N; i++){
      for (int j = i + 1; j < N; j++){
        if (ans[i][j] != 0) continue;
        if (color[i] != color[j]){
          ans[i][j] = L;
        }
      }
    }
  }

  for (int i = 0; i < N-1; i++){
    cout << ans[i][i+1];
    for (int j = i + 2; j < N; j++){
      cout << " " << ans[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 4628
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <stdio.h>
#include <cmath>
#include <limits.h>
using namespace std;

typedef long long ll;

#define min(a, b) (((a) < (b))? (a):(b))
#define max(a, b) (((a) > (b))? (a):(b))
#define REP(i, a, n) for(int i=(a); i<(n); ++i)
#define rep(i, n) REP(i, 0, (n))
#define square(a) (a)*(a)
#define pb push_back

int n;
int a[110000],b[110000],c[110000];
int main(){
	cin >> n;
	rep(i,n) cin >> a[i];
	
	int total;
	rep(i,n) total += abs(a[i]-a[i+1]);
	
	int ans = 0;
	rep(i,n) {
		ans = total - abs(a[i]-a[i+1]) - abs(a[i-1]-a[i]) + abs(a[i+1]-a[i-1]);
		cout << ans+abs(a[0]) << endl;
		
	}
	
}

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

#define INX(x) (cin >> x)
#define INXV(vec, cnt) for(ll i; i < cnt; i++) INX(vec[i])
#define OUTX(x) (cout << x << endl)
#define OUTXV(vec) for(ll i; i < (ll)vec.size(); i++) OUTX(vec[i])

#define ADD emplace_back
#define MP make_pair

int main()
{
    ll K;
    INX(K);

    string S;
    INX(S);

    if((ll)S.size() > K)
    {
        S.resize(K);
        S += "...";
    }
    OUTX(S);
    

    return 0;
}


Measured memory_bytes: 3628
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    string s;
    cin>>s;
    string res ="";
    forn(i, s.length()) res += 'x';
    cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    ll N, K;
    cin >> N >> K;
    map<ll, ll> mp;
    rep(i, N){
        int a, b;
        cin >> a >> b;
        mp[a] += b;
    }
    ll sum = 0;
    ll ans;
    for(auto p : mp){
        sum += p.second;
        if(sum >= K){
            ans = p.first;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    INT(n);
    vector<vector<int>> graph(n);
    rep(i,n){
        INT(x,y);
        rep(j,y){
            INT(z);
            graph[x-1].push_back(z-1);
        }
    }
    queue<int> Q;
    vector<int> checked(n,-1);
    Q.push(0);
    checked[0]=0;
    while(!Q.empty()){
        int x=Q.front();
        Q.pop();
        rep(i,graph[x].size()){
            if(checked[graph[x][i]]==-1){
                checked[graph[x][i]]=checked[x]+1;
                Q.push(graph[x][i]);
            }
        }
    }
    rep(i,n)out(i+1,checked[i]);
}


Measured memory_bytes: 3236
import sys
input = sys.stdin.readline

N, A = [int(x) for x in input().split()]
x = [int(x) - A for x in input().split()]

dp = [[0] * 5001 for _ in range(N + 1)]
dp[0][0 + 2500] = 1

for i in range(1, N + 1):
    for j in range(-2500, 2501):
        if 5000 >= j + 2500 - x[i - 1] >= 0:
            dp[i][j + 2500] = dp[i - 1][j + 2500 - x[i - 1]] + dp[i - 1][j + 2500]
        else:
            dp[i][j + 2500] = dp[i - 1][j + 2500]

print(dp[N][0 + 2500] - 1)

Measured memory_bytes: 41456
#include <iostream>

using namespace std;

int main(void) {
        int a, b;
        
        cin >> a >> b;
        
        if(a < b) {
                cout <<  "a < b" << endl;
        } else if (a > b) {
                cout << "a > b" << endl;
        } else {
                cout << "a == b" << endl;
        }

        return 0;
}

Measured memory_bytes: 1160
n = int(input())
h = list(map(int,input().split()))
i,j = 0,0
ans = 0
while j < len(h)-1:
    if h[j] >= h[j+1]:
        j += 1
    else:
        j += 1
        i = j
    ans = max(ans,(j-i))
print(ans)    

Measured memory_bytes: 14252
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    char c;
    cin >> c;
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
//スタート点,頂点数、辺を渡して、最短経路の配列を返す
std::vector<LL> dijkstra(int s,int N,vector<Edge> E){
    std::vector<LL> ans(N,LINF);
    std::vector<std::vector<Edge>> Edges(N);
    FOREACH(e,E){
        Edges.at(e.from).push_back(e);
    }
    priority_queue<P, std::vector<P>, greater<P>> que;
    ans.at(s)= 0;
    que.push(make_pair(0,s));
    while(!que.empty()){
        P p = que.top();que.pop();
        if(ans.at(p.second) < p.first)continue;
        for(int i = 0;i < Edges.at(p.second).size();i++){
            if(ans.at(p.second) + Edges.at(p.second).at(i).value < ans.at(Edges.at(p.second).at(i).to)){
                ans.at(Edges.at(p.second).at(i).to) = ans.at(p.second) + Edges.at(p.second).at(i).value;
                que.push(make_pair(ans.at(Edges.at(p.second).at(i).to),Edges.at(p.second).at(i).to));
            }
        }
    }
    return ans;
}
int main(){
    CIN(v);CIN(E);
    CIN(r);
    vector<Edge> Edges;
    for(int a = 0;a < E;a++){
        CIN(s);CIN(t);CIN(d);
        Edge e(s,t,d);
        Edges.pb(e);
    }
    V<LL> w = dijkstra(r,v,Edges);
    for(int a = 0;a < v;a++){
        if(LINF == w.at(a)){
            COUT("INF");
        }else{
            COUT(w.at(a));
        }
    }
    return 0;
}



Measured memory_bytes: 48168
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#include "bits/stdc++.h"

namespace adaptor = boost::adaptors;

const int64_t M = 1046527;
const int64_t NIL = -1;
const int64_t L = 14;

char H[M][L];

int64_t getChar(char ch) {
    if (ch == 'A')
        return 1;
    else if (ch == 'C')
        return 2;
    else if (ch == 'G')
        return 3;
    else if (ch == 'T')
        return 4;
    else
        return 0;
}

int64_t getKey(char str[]) {
    int64_t sum = 0, p = 1;
    for (int64_t i = 0; i < strlen(str); i++) {
        sum += p * (getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int64_t h1(int64_t key) { return key % M; }
int64_t h2(int64_t key) { return 1 + (key % (M - 1)); }

int64_t find(char str[]) {
    int64_t key, h;
    key = getKey(str);
    for (int64_t i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0)
            return 1;
        else if (strlen(H[h]) == 0)
            return 0;
    }
    return 0;
}

int64_t insert(char str[]) {
    int64_t key, h;
    key = getKey(str);
    for (int64_t i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0)
            return 1;
        else if (strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
}

void solve() {
    int64_t n, h;
    char str[L], com[9];
    for (int64_t i = 0; i < M; i++) H[i][0] = '\0';
    std::cin >> n;
    for (int64_t i = 0; i < n; i++) {
        std::cin >> com >> str;
        if (com[0] == 'i') {
            insert(str);
        } else {
            if (find(str)) {
                std::cout << "yes" << std::endl;
            } else {
                std::cout << "no" << std::endl;
            }
        }
    }
    return;
}

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



Measured memory_bytes: 17480
#include <stdio.h>
#include <string.h>
int main (void)
{
  char str[50],name[50],set[9],fes[9]="FESTIVAL";
  int i,j;
  scanf("%s",str);
  for(i=0;i<50;i++)
  {
    for(j=0;j<9;j++)
    {
      set[j]=str[i+j];
    }
    if(strcmp(fes,set)==0)
    {
      for(j=0;j<i;j++)
      {
        name[j]=str[j];
      }
        name[i]='\0';
      break;
    }
  }
  printf("%s",name);
    putchar('\n');
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>
#include<set>

//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define All(a) (a).begin(),(a).end()

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	ll k;
	cin >> s >> k;

	char c = s[0];
	int cnt = 0, cntf = 0;
	ll ans = 0;
	REPS(i, s.length() - 1) {
		if (c != s[i])break;
		cntf++;
	}
	REPS(i, s.length()-1) {
		if (c == s[i]) {
			cnt++;
			continue;
		}
		ans += (cnt+1) / 2;
		c = s[i];
		cnt = 0;
	}
	if (cnt == s.length() - 1) {
		cout << s.length()*k / 2 << endl;
		return 0;
	}
	if (s[s.length() - 1] == s[0]) {
		if (cntf % 2 == 0)cnt++;
		ans += (cnt+1) / 2;
		ans *= k;
		if (cntf%2==0&&cnt % 2 == 1)ans--;
	}
	else {
		ans += (cnt + 1) / 2;
		ans *= k;
	}
	cout << ans << endl;
}

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

int main(){
  int d,t,s;
  cin>>d>>t>>s;
  
  if(d<=s*t) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
const int N = 1e5;
int k,cnt,p=2;
int a[15];
bool check(int idx)
{
  if(idx==1)
  {
      if(a[1]<=a[2])return true;
      return false;
  }
  else if(idx<p){
    if(fabs(a[idx]+1-a[idx-1])<=1&&fabs(a[idx]+1-a[idx+1])<=1)return true;
    return false;
  }
  else {
    if(a[p]<=a[p-1])return true;
  }
  return false;
}
int main()
{
  cin>>k;
  if(k<=10)
  {
    cout<<k<<endl;
    return 0;
  }
  cnt=10;
  a[1]=0;a[2]=1;
  while(cnt<k)
  {
    for(int i=1;i<=p;i++)
    {
      if(check(i))
      {
        if(a[i]==9&&i<p)continue;
        a[i]++;
        cnt++;
        if(a[i]==10){
            for(int i=1;i<=p;i++)a[i]=0;
            a[++p]=1;
          }
          else {
            int t=a[i];
            for(int j=i;j>=1;--j)
            {
              a[j]=(t>0)?t:0;
              t--;
            }
        }
          break;
      }
      else continue;
      }
    // cout<<cnt<<": ";
    // for(int i=p;i>=1;i--)cout<<a[i];
    // cout<<endl;
  }
  for(int i=p;i>0;i--)cout<<a[i];
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    char a,b,c;
    scanf("%c%c%c",&a,&b,&c);
    int x=0;
    if(a=='o')
        x++;
    if(b=='o')
        x++;
    if(c=='o')
        x++;
    printf("%d\n",x*100+700);
    return 0;
}


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


int main(){
   string s; cin>>s;
   int cnt=0;
   for(int i=1;i<s.length();i++){
      if(s[i]==s[i-1]){
         cnt++;
         if(s[i]=='0') s[i]='1';
         else s[i]='0';
      }
   }
   cout<<cnt<<endl;
   return 0;
}

   


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

import sys
sys.setrecursionlimit(10**9) #再帰の上限をあげる

root=[-1 for i in range(n+1)] #自分が親ならグループの人数のマイナス倍を、そうでないなら（元）親の番号を示す

def r(x):   #親は誰？
    if root[x]<0:
        return x
    else:
        root[x]=r(root[x])
        return root[x]

def unite(x,y):
    x=r(x)
    y=r(y)
    if x==y:
        return
    if root[x]<root[y]:
        x,y=y,x
    root[x]+=root[y]
    root[y]=x

for i in range(m):
    x,y,z=map(int,input().split())
    unite(x,y)


g=[0]*(n+1)
for i in range(1,n+1):
    g[r(i)]+=1
ans=0
for i in range(n+1):
    if g[i]>0:
        ans+=1
print(ans)



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

int main(int argc, char const *argv[])
{
  int n;
  int a=0,sum=0;
  scanf("%d",&n);
  string s[n];
  string x;
  int t[n];
  for(int i=0;i<n;i++){
    cin>>s[i];
    scanf("%d",&t[i]);
  }
  cin>>x;
  for(int i=0;i<n;i++){
    if(s[i]==x){
      a=i;
      break;
    }
  }
  for(int i=a+1;i<n;i++){
  	sum+=t[i];
  }
  printf("%d",sum);
}

Measured memory_bytes: 256