akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
class e{
  public static void Main(){
    int size = 30;
    int n = int.Parse(Console.ReadLine());
    long[] num = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
    int[] bits = new int[size];
    String[] bits_s = new String[n];
    for(int i=0; i<n; i++){
      String s = Convert.ToString(num[i], 2);
      bits_s[i] = s;
      for(int j=0; j<s.Length; j++){
        bits[j] += (s[s.Length-1-j]-'0');
      }
    }
    //Console.WriteLine(string.Join(" ",bits));
    int[] ans = new int[n];
    for(int i=0; i<n; i++){
      String tgt = bits_s[i];
      for(int j=0; j<tgt.Length; j++){
        bits[j] -= tgt[tgt.Length-1-j]-'0';
      }
      int mul = 1;
      for(int j=0; j<size; j++){
        ans[i] += (bits[j]%2)*mul;
        mul *= 2;
      }
      for(int j=0; j<tgt.Length; j++){
        bits[j] += tgt[tgt.Length-1-j]-'0';
      }
    }
    Console.WriteLine(string.Join(" ",ans));
  }
}


Measured memory_bytes: 66036
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <climits>
#include <functional>
#include <map>
#include <stack>
#include <cstdlib>
#include <queue>
#define endl '\n'
#define ll long long
#define NCONS 100001

using namespace std;

struct Pos{
    int x;
    int y;
    int dis;
};

int H, W;
vector<string> grid;
bool visited[50][50];
int dx[]{1, 0, -1, 0};
int dy[]{0, 1, 0, -1};

int bfs()
{
    queue<Pos> quu; quu.push(Pos{0, 0, 1}); visited[0][0] = true;
    
    while(!quu.empty())
    {
        auto cur = quu.front(); quu.pop();
        if(cur.x == H - 1 && cur.y == W - 1)
        {
            return cur.dis;
        }
        
        for(int i = 0; i < 4; i++)
        {
            auto nx = cur.x + dx[i], ny = cur.y + dy[i];
            if(min(nx, ny) < 0 || nx >= H || ny >= W) continue;
            if(visited[nx][ny]) continue;
            if(grid[nx][ny] == '#') continue;
            quu.push(Pos{nx, ny, cur.dis + 1});
            visited[nx][ny] = true;
        }
    }
    
    return -1;
}

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    cin >> H >> W;
    int black = 0;
    for(int i = 0; i < H; i++)
    {
        string temp; cin >> temp;
        grid.push_back(temp);
        for(int j = 0; j < temp.length(); j++)
            if(temp[j] == '#')
                black += 1;
    }
    auto ret = bfs();
    if(ret == -1)
        cout << ret << endl;
    else
        cout << H * W - black - ret << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  string a;
  cin >> a;
  if (a[0] == a[1] && a[2] == a[3] && a[0] != a[2]){
    cout << "Yes" << endl;
  }
  else if (a[0] == a[2] && a[1] == a[3] && a[0] != a[1]){
    cout << "Yes" << endl;
  }
  else if (a[0] == a[3] && a[1] == a[2] && a[0] != a[1]){
  	cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
/*
    Author:    DreamCat4er
    Created:   22.08.2020 18:16:56
*/
#include <bits/stdc++.h>
using namespace std;

void solve() {
    int n, x, t;
    cin >> n >> x >> t;

    cout << t * ((n + x - 1) / x) << "\n";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
                
    #ifdef _LOCAL
        int t;
        cin >> t;
        for (int _t = 0; _t < t; ++_t) {
            cout << "Case " << _t << " :\n";
            solve();
            cout << "\n";
        }
    #else
        solve();
    #endif // _LOCAL

    return 0;
}

Measured memory_bytes: 3628
import math

def s(x):
    r=0
    s=math.sqrt(x)
    s=(int)(s)

    for i in range(2,s+1):
        w=x%i
        if w==0:
            r=r+1
    return r

N=int(input())
A=[0 for i in range(N)]
for i in range(N):
    A[i]=int(input())

t=0
i=2
for i in range(N):
    r=s(A[i])
    if r==0:
        t=t+1
print(t)


Measured memory_bytes: 5988
D = int(input())
c = list(map(int, input().split()))
s = []

t = [0]*D
v = [0]*D
d = [0]*26

for i in range(D):
    S = list(map(int, input().split()))
    s.append(S)

for i in range(D):
    t[i] = int(input())

now = 0

for i in range(D):
    now += s[i][t[i]-1]
    d[t[i]-1] = i+1
    for j in range(26):
        now -= c[j] * (i+1-d[j])
    v[i] = now
    print(v[i])

Measured memory_bytes: 9520
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <limits>
#include <bitset>
using namespace std;
const int INF = numeric_limits<int>::max();
int solve(int a, int b, int c, int a_mask, int b_mask, int c_mask, const vector<int> &ls)
{
    if (a_mask == 0) return INF;
    if (b_mask == 0) return INF;
    if (c_mask == 0) return INF;
    int cost = 0;
    int sum_a = 0;
    int sum_b = 0;
    int sum_c = 0;
    for(int i = 0; i < ls.size(); ++i)
    {
        if((a_mask & (1 << i)) == 0) continue;
        if(sum_a != 0) cost += 10;
        sum_a += ls[i];
    }
    
    for(int i = 0; i < ls.size(); ++i)
    {
        if((b_mask & (1 << i)) == 0) continue;
        if(sum_b != 0) cost += 10;
        sum_b += ls[i];
    }
    
    for(int i = 0; i < ls.size(); ++i)
    {
        if((c_mask & (1 << i)) == 0) continue;
        if(sum_c != 0)cost += 10;
        sum_c += ls[i];
    }
    cost += abs(a - sum_a);
    cost += abs(b - sum_b);
    cost += abs(c - sum_c);
    return cost;
}

int main()
{
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<int> ls;
    for (int i = 0; i < n; ++i)
    {
        int l;
        cin >> l;
        ls.push_back(l);
    }
    int cost_min = numeric_limits<int>::max();
    for (int i = 0; i < 1 << ls.size(); ++i)
    {
        for (int j = 0; j < 1 << ls.size(); ++j)
        {
            for (int k = 0; k < 1 << ls.size(); ++k)
            {
                const auto a_mask = i;
                const auto b_mask = j & (~i);
                const auto c_mask = k & (~(i | j));
                auto s = solve(a, b, c, a_mask, b_mask, c_mask, ls);
                cost_min = min(cost_min, s);
            }
        }
    }
    cout << cost_min << endl;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

int main ()
{
	int N , M;
	cin >> N >> M;
	string str = "" , str2 = "" , str3 = "";
	vector<int> data ( M , 0 );
	int count = 0;
	for( size_t i = 0; i < N; i++ )
	{
		char c;
		cin >> c;
		str += c;
		if( c == '0' )
		{
			count++;
		}
	}
	int count2 = 0;
	for( size_t i = 0; i < M; i++ )
	{
		cin >> data[i];
		if( i % 2 )
		{
			count2 += data[i];
		}
		for( size_t j = 0; j < data[i]; j++ )
		{
			if( i % 2 )
			{
				str2 += '0';
				str3 += '1';
			} else
			{
				str2 += '1';
				str3 += '0';
			}
		}
	}
	auto f = []( string a , string b )
	{
		int ans = 0;
		int p = 0 , q = 0;
		for( auto x : a )
		{
			if( x == '0' )p++;
		}
		for( auto x : b )
		{
			if( x == '0' )q++;
		}
		if( p != q )return INT_MAX;
		for( size_t i = 0; i < a.size (); i++ )
		{
			if( a[i] != b[i] )
			{
				int y = i;
				while( y != a.size () && a[y] != b[i] )y++;
				if( y == a.size () )return INT_MAX;
				ans += y - i;
				for( int j = y; j > i; j-- )
				{
					swap ( a[j] , a[j - 1] );
				}
			}
		}
		return ans;
	};
	cout << min ( f ( str2 , str ) , f ( str3 , str ) ) << endl;
	return 0;
}

Measured memory_bytes: 1216
N=int(input())
A=list(list(map(int,input().split())) for _ in range(2))
ans=0
mans=0
for i in range(N):
    if i==0:
        ans=A[0][0]+sum(A[1])
        mans=ans
    else:
        ans=max(mans-A[1][i-1]+A[0][i],ans)
        mans=mans-A[1][i-1]+A[0][i]
print(ans)

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

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        int K = int.Parse(Console.ReadLine());

        int idx = K - 1;
        char target = s[idx];

        var ans = new string(s.Select(c => c == target ? c : '*').ToArray());

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define OK { cout << "OK" << endl; return 0; }
#define NG { cout << "NG" << endl; return 0; }
#define sz(v) ((int)(v).size())
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
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; }
template<class T>void out(T a){cout << a << endl;}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

#define SIZE 200005
#define MOD 1000000007
 
typedef pair <int,int> P;
 
ll inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<SIZE; i++)
	{
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
    return ;
}
ll comb(int a,int b){
	if(a < b) return 0;
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}



ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}

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

	int X,Y; cin >>X>>Y;
	int ans = 0;
	if(X == 1 and Y == 1 ) {
		cout << 10 * 100000 << endl;
		return 0;
	}
	else{
		if(X == 1) ans+= 3;
		else if(X == 2) ans += 2;
		else if (X == 3) ans += 1;

		if(Y == 1) ans+= 3;
		else if(Y == 2) ans += 2;
		else if(Y == 3) ans += 1;

		cout << ans * 100000 << endl;

	}
}

Measured memory_bytes: 3616
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;

public class Main{
    static int[] G = {1, 4, 13, 40, 121, 364, 1093, 3280, 9841, 29524, 88573, 265720, 797161}; //G(n)=3G(n)+1
    
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());
        int[] A = new int[n];
        for(int i=0; i<n; i++){
            A[i] = Integer.parseInt(br.readLine());
        }

        shellSort(A);
    }

    static int get_g(int x){
        int low = 0;
        int high = G.length-1;

        while(low<=high){
            int mid = (low+high)/2;
            if(mid==G.length-1||(G[mid]<=x&&G[mid+1]>x)){
                return mid;
            }else if(G[mid]>x){
                high = mid-1;
            }else{
                low = mid+1;
            }
        }
        return 0;
    }

    static void shellSort(int[] A){
        int count=0;
        int m = get_g(A.length);
        System.out.println(m+1);
        for(int i=m; i>-1; i--){
            System.out.print(G[i]);
            count=insertionSort(A, G[i], count);
            System.out.print(i!=0?" ":"\n");
        }
        System.out.println(count);
        for(int a:A){
            System.out.println(a);
        }
    }

    static int insertionSort(int[] A,int gap, int count){
        for(int i=gap; i<A.length; i++){
            int key = A[i];
            int j = i-gap;
            while(j>-1 && A[j]>key){
                A[j+gap]=A[j];
                j=j-gap;
                count++;
            }
            A[j+gap]=key;
        }    
        return count;
    }
}



Measured memory_bytes: 106544
# スペース区切りの整数の入力
b, c = map(int, input().split())

p = b + c
m = b - c
k = b * c

if p > m:
    if p > k:
        print(p)
    else:
        print(k)
elif k > m:
    print(k)
else:
    print(m)


Measured memory_bytes: 2940
import java.util.HashSet;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;



 class Main{
     public static void main(String args[]){
         Scanner sc = new Scanner(System.in);
         String line;
         while(sc.hasNext()){
             line=sc.nextLine();
             if(line.isEmpty())break;
             String[] split=line.split(",");
             int[] ints = new int[5]; for(int i=0;i<5;i++)ints[i]=Integer.parseInt(split[i]);
             if(!_4c(ints)){//System.out.println("aa");
                 if(!fullH(ints)){//System.out.println("bb");
                     if(!st(ints)){//System.out.println("cc");
                         if(!_3c(ints)){//System.out.println("dd");
                             if(!_2p(ints)){//System.out.println("dd");
                                 //System.out.println(_1p(ints));
                                 if(!_1p(ints)){//System.out.println("ee");
                 System.out.println("null");}}}}}}
         }
         
         
     }
     static boolean _4c(int[] ints){
         if(ints[1]==ints[2]&&ints[1]==ints[3]&&ints[1]==ints[4]){System.out.println("four card");
         return true;}
         int count=0; for(int x : ints) if(x==ints[0])count++;
         if(count==4){System.out.println("four card");return true;}
         return false;
     }
     static boolean fullH(int[] ints){
         HashSet<Integer>hs=new HashSet<Integer>();
         for(int x:ints) hs.add(x);
         if(hs.size()==2){System.out.println("full house"); return true;}
         return false;
     }
     static boolean st(int[] ints){
         TreeSet<Integer>hs=new TreeSet<Integer>();
         
         for(int x:ints) hs.add(x);
         if(hs.size()!=5)return false;
         if(hs.last()-hs.first()==4){System.out.println("straight");return true;}
         if(hs.first()==1){hs.remove(1);
             if(hs.first()==10){System.out.println("straight");return true;}
        }return false;
     }
     static boolean _3c(int[] ints){
        for(int i=0; i<5;i++){
            int count=0;
            for(int j=i+1;j<5;j++){
                if(ints[i]==ints[j])count++;
            }
            if(count==2){System.out.println("three card");return true;}
        }
        return false;
     }
     static boolean _2p(int[] ints){
         TreeMap<Integer,Integer>tm=new TreeMap<Integer,Integer>();
         for(int in:ints){
             if(tm.containsKey(in))tm.put(in, tm.get(in)+1);
             else tm.put(in, 1);
         }
         if(tm.keySet().size()==3){System.out.println("two pair");return true;}
         return false;
     }
     static boolean _1p(int[] ints){
         for(int i=0; i<5;i++){
             for(int j=i+1;j<5;j++){
                 if(ints[i]==ints[j]){System.out.println("one pair");return true;}
         }
        }return false;
     }
 }

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

namespace ConsoleApp43 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int A = st[0];
            int B = st[1];

            if (A + B >= 10) {
                Console.WriteLine("error");
            } else {
                Console.WriteLine(A + B);
            }

        }
    }
}


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

namespace AOJ1_11_B
{
    class Program
    {
        static int[] _dice = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; ++i)
            {
                int[] question = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                Console.WriteLine(Dice.JudgeRight(_dice, question[0], question[1]));
            }
        }
    }
    class Dice
    {
        static internal int JudgeRight(int[] a_Dice, int top, int center)
        {
            int right = 0;
            if (top == a_Dice[1] && center == a_Dice[2]
                || top == a_Dice[2] && center == a_Dice[4]
                || top == a_Dice[3] && center == a_Dice[1]
                || top == a_Dice[4] && center == a_Dice[3])
            {
                right = a_Dice[0];
            }
            else if (top == a_Dice[0] && center == a_Dice[3]
                || top == a_Dice[2] && center == a_Dice[0]
                || top == a_Dice[3] && center == a_Dice[5]
                || top == a_Dice[5] && center == a_Dice[2])
            {
                right = a_Dice[1];
            }
            else if (top == a_Dice[0] && center == a_Dice[1]
                || top == a_Dice[1] && center == a_Dice[5]
                || top == a_Dice[4] && center == a_Dice[0]
                || top == a_Dice[5] && center == a_Dice[4])
            {
                right = a_Dice[2];
            }
            else if (top == a_Dice[0] && center == a_Dice[4]
               || top == a_Dice[1] && center == a_Dice[0]
               || top == a_Dice[4] && center == a_Dice[5]
               || top == a_Dice[5] && center == a_Dice[1])
            {
                right = a_Dice[3];
            }
            else if (top == a_Dice[0] && center == a_Dice[2]
                || top == a_Dice[2] && center == a_Dice[5]
                || top == a_Dice[3] && center == a_Dice[0]
                || top == a_Dice[5] && center == a_Dice[3])
            {
                right = a_Dice[4];
            }
            else if (top == a_Dice[1] && center == a_Dice[3]
                || top == a_Dice[2] && center == a_Dice[1]
                || top == a_Dice[3] && center == a_Dice[4]
                || top == a_Dice[4] && center == a_Dice[2])
            {
                right = a_Dice[5];
            }
            return right;
        }
    }
}



Measured memory_bytes: 16360
using System;

class Prog{
  static void Main(){
    string s = Console.ReadLine();
    for(int i =0;i<s.Length;i++){
      string k = s[i].ToString();
      if(i % 2 ==0){
        if(k.Equals("R") || k.Equals("U")  || k.Equals("D") ){
          continue;
        }else{
          Console.WriteLine("No");
          Environment.Exit(0);
        }
      }else if(i % 2 !=0){
        if(k.Equals("L") || k.Equals("U")  || k.Equals("D") ){
          continue;
        }else{
          Console.WriteLine("No");
          Environment.Exit(0);
        }
      }
    }
    Console.WriteLine("Yes");
  }
}




Measured memory_bytes: 13140
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

double compute_next_x_duration(double x, double r, double v, double e, double f){
  if(x >= r){
    return 1.0 / (v - e * (x - r));
  }
  else{
    return 1.0 / (v - f * (r - x));
  }
}

double compute_duration(double from, double to, double r, double v, double e, double f){
  double sum = 0;
  
  for(int pos = 0; pos < to - from; pos++){
    sum += compute_next_x_duration(pos,r,v,e,f);
  }
  return sum;
}


double dp[101][101]; // dp[current_i][last_change_pos]

int main(){
  int num_of_checkpoints;
  while(~scanf("%d",&num_of_checkpoints)){
    if(num_of_checkpoints == 0) break;

    vector<int> checkpoints;
    checkpoints.push_back(0);
    for(int checkpoint_i = 0; checkpoint_i < num_of_checkpoints; checkpoint_i++){
      int pos;
      scanf("%d",&pos);
      checkpoints.push_back(pos);
    }
    double tire_change_time;
    scanf("%lf",&tire_change_time);
    double r,v,e,f;
    scanf("%lf %lf %lf %lf",&r,&v,&e,&f);

    fill((double*)dp,(double*)dp + 101 * 101,1000000000000.0);
    dp[0][0] = 0;
    for(int current_i = 0; current_i < checkpoints.size(); current_i++){
      for(int prev_i = 0; prev_i < current_i; prev_i++){
        // x is a nonnegative integer denoting the distance (in kilometers) 
        // from the latest checkpoint where tires are changed
        
        dp[current_i][prev_i]
          = min(dp[prev_i][prev_i]
                + compute_duration(checkpoints[prev_i],checkpoints[current_i],r,v,e,f),
                dp[current_i][prev_i]);

        dp[current_i][current_i]
          = min(dp[prev_i][prev_i]
                + compute_duration(checkpoints[prev_i],checkpoints[current_i],r,v,e,f)
                + tire_change_time,
                dp[current_i][current_i]);
      }
    }

    double res = numeric_limits<double>::max();
    for(int i = 0; i < checkpoints.size(); i++){
      res = min(res,dp[checkpoints.size()-1][i]);
    }
    printf("%lf\n",res);
  }
}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  vector<int> p(N);
  for (int i=0; i<N; i++) {
    cin >> p.at(i);
  }
  
  sort(p.begin(), p.end());
  int x = 0;
  
  for (int i=0; i<K; i++) {
    x += p.at(i);
  }
  
  cout << x << endl;
  
}

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

using namespace std;
using ll = long long;

int main() {

	string s;
	cin>>s;
	int t;
	cin>>t;
	int x;
	string pre;
	string suf;
	bool f = true;
	deque<char> q;
	int len = s.length();
	int i = 0;
	while (len--) {
		q.push_back(s[i++]);
	}

	while (t--) {
		cin>>x;
		if (x == 1) {
			f =  1 - f;
		}
		else {
			int t;
			char c;
			cin>>t;
			cin>>c;
			if (t == 1) {
				if (f) {
					q.push_front(c);
				}
				else {
					q.push_back(c);
				}
			}
			else {
				if (f) {
					q.push_back(c);
				}
				else {
					q.push_front(c);
				}
			}
		}
	}


	string ans(q.begin(), q.end());
	if (!f) {
		reverse(ans.begin(), ans.end());
	}

	cout<<ans<<endl;
	return 0;
}


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

int main(){

    ll h,n;
    cin >> h >> n;
    vector<int> a(n);
    ll su =0L;
    rep(i,n){
        cin >> a[i];
        su+=(ll)a[i];
    }

    if(su>=h){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 640
import math
from decimal import Decimal
n = int(input())
i = 0
list = []
while i < n:
   list.append(input().split())
   i += 1
h = 0
th = 1
ah = 1
while h < n:
     listh = list[h]
     x = int(listh[0])
     y = int(listh[1])
     m = max((th+x-1)//x, (ah+y-1)//y)
     th = m*x
     ah = m*y
     h += 1
print(th+ah)

Measured memory_bytes: 5844
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val h = Array(100010) { 0 }
    val ma = Array(100010) { 0 }

    readLine()!!.split(' ').map { it.toInt() }.forEachIndexed { index, i ->
        h[index + 1] = i
    }

    (0 until m).forEachIndexed { index, i ->
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        ma[a] = Math.max(ma[a], h[b])
        ma[b] = Math.max(ma[b], h[a])
    }

    var ans = 0

    (0..n).forEachIndexed { index, i ->
        if (h[i] > ma[i]) {
            ans++
        }
    }

    println(ans)
}


Measured memory_bytes: 75656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long INF = 1LL << 60;

int keta(int N)
{
  int count = 0;
  while(N > 0)
  {
    N /= 10;  
    count++;
  }
  return count;
}
  
int main()
{
  int N; cin >> N;
  int res = 0;
  for(int i = 1; i <= N; i++)
  {
    if(keta(i)%2 == 1) res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

struct Dijkstra{
  ll INF=1000000000000000009;
  ll MAX_V=1000000;
  ll st = -1;
  struct edge{ll to, cost;};
  typedef pair<ll, ll> p;
  vector<vector<edge>> G;
  vector<ll> pre, d;
  priority_queue<p, vector<p>, greater<p> > que; //class, inner, compair
  Dijkstra(ll s){
    G.resize(s+2);
    pre.resize(s+2, -1);
    d.resize(s+2, INF);
  }
  inline void insert(ll a, ll b, ll c){
    G[a].push_back(edge{b, c});
  }
  void init(){
    for(int i=0;i<d.size();i++) pre[i] = -1, d[i] = INF;
  }
  void dijkstra(int start){
    init();
    st = start;
    d[start]=0;
    que.push(p(0, start));
    while(!que.empty()){
      p p_now=que.top(); que.pop();
      ll v = p_now.second;
      if(d[v]<p_now.first) continue;
      for(int i=0;i<G[v].size();i++){
        edge e = G[v][i];
        if(d[e.to]>d[v]+e.cost){
          d[e.to]=d[v]+e.cost;
          pre[e.to] = v;
          que.push(p(d[e.to], e.to));
        }
      }
    }
  }
  vll get_path(int now){
    vll ret;
    while(now!=-1){
      ret.push_back(now);
      now = pre[now];
    }
    return ret;
  }
};
int main(int argc, char const *argv[]) {
  ll n, m, s;std::cin >> n >> m >> s;
  //max_coin = 5000
  Dijkstra dj(2600*(n+1));
  re(i, m){
    ll a, b, cost, tm;std::cin >> a >> b >> cost >> tm;
    a--, b--;
    for(ll i=cost;i<=2500;i++){
      dj.insert(i*n+a, (i-cost)*n+b, tm);
      dj.insert(i*n+b, (i-cost)*n+a, tm);
    }
  }
  re(i, n){
    ll a, b;std::cin >> a >> b;
    for(int j=0;j<2500;j++){
      dj.insert(j*n+i, (j+a)*n+i, b);
    }
  }
  s = min(s, (ll)2500);
  dj.dijkstra(s*n);
  for(int i=1;i<n;i++){
    ll ans = 1000000000000000000;
    for(int j=0;j<=2500;j++) ans = min(ans, dj.d[j*n+i]);
    std::cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 24768
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans;
    if (k % 2 == 0)
    {
        ans = a - b;
    }
    else
    {
        ans = b - a;
    }
    if (ans < 1000000000000000000)
    {
        cout << ans << endl;
    }
    else
    {
        cout << "Unfair" << endl;
    }
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#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
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()

typedef unsigned long long ll;

int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

int main(){ 
string a,b,c;
cin >> a >> b >> c;
queue<char> Sa;
queue<char> Sb;
queue<char> Sc;
rep(i,a.size()){
    Sa.push(a[i]);
}
rep(i,b.size()){
    Sb.push(b[i]);
}
rep(i,c.size()){
    Sc.push(c[i]);
}
char x; x = Sa.front();
Sa.pop();
while(true){
    if(x == 'a'){
        if(Sa.empty()){ 
            cout << 'A' << endl;
            return 0;
        }
        x = Sa.front();
        Sa.pop();  
          }  
    else if(x == 'b'){
        if(Sb.empty()){ 
            cout << 'B' << endl;
            return 0;
        }        
        x = Sb.front();
        Sb.pop();
    } 
    else {
        if(Sc.empty()){ 
            cout << 'C' << endl;
            return 0;
        }        
        x = Sc.front();
        Sc.pop(); 
    }
}

}





Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <sstream>
#include <iomanip>
#include<fstream>
#include <cmath>
#include <algorithm>
#include <iterator>
#include <utility>   // std::pair, std::make_pair
#include <stdlib.h>  //atoi
using namespace std;
typedef long long ll;
const  double PI = 3.141592654;
#define rep(i,x) for(int(i)=0;(i)<(ll)(x);(i)++)
#define all(s)      (s).begin(),(s).end()
#define allv(v)      (v).begin(),(v).end()
#define pb          push_back
#define sz          s.size()
#define ssz          ss.size()
#define vz          v.size()
//x = atoi(a.c_str())
void fast()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL), cout.tie(NULL);
}
int main()
{
	fast();
	string s;
	cin >> s;
	int c = 1, mx = 0;
	rep(i, sz)
	{
		if (s[i] == s[i + 1])
			c++;
		else
			mx=max(mx,c), c = 1;
	}
	if (mx >= 3)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>    //C++の標準ライブラリのヘッダを全て読み込む
 
int main() {
    using std::cout;
    using std::endl;
    using std::cin;
    using std::string;

    int A,B;
    int temp = 0, digits[5] = {0},cnt = 0;

    cin >> A >> B;
 
    for(int i = A; i <= B; i++)
    {
        int k = 10000;
        temp = i;
        for(int j = 0; j < 5; j++, k /= 10){
            digits[j] = temp / k;
            temp -= digits[j] * k;
        }
        cnt += (digits[0] == digits[4] && digits[1] == digits[3]) ? 1 : 0;
    }

    cout << cnt << endl;

}

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

const int INF = 10000;

bool used[26];

int solve(string s, int tar){
	int res;
	for(res = 0; ; res++){
		bool flag = (s[0]-'a' == tar);
		for(int i = 1; i + res < s.length(); i++){
			if(s[i]-'a' != tar){
				flag = false;
				continue;
			}
			s[i-1] = 'a'+tar;
		}
		if(flag) break;
	}
	return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    for(char& c : s) used[c-'a'] = true;
	int ans = INF;
	for(int i = 0; i < 26; i++){
		if(!used[i]) continue;
		ans = min(ans, solve(s, i));
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)
#define fi first
#define se second
#define pb push_back
typedef pair<int, int> Pi;
const int LLINF = 1LL << 60;
 
inline int llabs(int n) { return n < 0 ? -n : n; }
 
struct Edge {
  int to, cost;
};
 
vector< Edge > G[3005];
int mc[3005];
int N, M, K;
 
void Dijkstra(int s)
{
  priority_queue < Pi, vector< Pi >, greater< Pi > > pq;
   
  pq.push(Pi(0, s)); mc[s] = 0;
  while(!pq.empty()) {
    int v = pq.top().se, w = pq.top().fi; pq.pop();
    if(mc[v] < w) continue;
    Rep(i, G[v].size()) {
      int u = G[v][i].to, nw = w + G[v][i].cost;
      if(nw < mc[u]) {
	mc[u] = nw; pq.push(Pi(nw, u));
      }
    }
  }
}
 
int A[100005], B[100005], C[100005];
signed main()
{
  int ans = 0;
  int k;
   
  cin >> N >> M >> K;
  Rep(i, M) {
    cin >> A[i] >> B[i] >> C[i]; --A[i], --B[i];
    G[A[i]].pb( (Edge) { B[i], C[i] } );
    G[B[i]].pb( (Edge) { A[i], C[i] } );
  }
 
  fill_n(mc, 3005, LLINF);
  Rep(i, K) {
    cin >> k; --k;
    Dijkstra(k);
  }
 
  Rep(i, M) {
    ans = max(ans, min(mc[A[i]], mc[B[i]]) + (llabs(mc[A[i]] - mc[B[i]]) + C[i] + 1) / 2);
  }
 
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 11116
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>


#define int  long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define pf push_front
#define eb emplace_back //FASTER THAN PUSH BACK!
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define mi multiset<int>
#define mii multiset<pii>
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

int modp(int a,int n)
{
    if(n==0) return 1;
    if(n==1) return a%mod;
    int res=modp(a,n/2);
    if(n%2==0) return (res*res)%mod;
    else return (a*res*res)%mod;
}

// vi adj[100005];
// vector<bool> vis(100005,false);


// void dfs(int s)
// {
//     vis[s]=true;
    
//     for(int u:adj[s])
//     {
//         if(!vis[u])
//         {
//             vis[u]=true;
//             dfs(u);
//         }
//     }
// }

void solve()
{
    int t,n,m,i,k,l,r,u,v,w,j,s,sum=0,pos=-5,flag=0,count=0;
    string S,T,U;
    int a,b,c,d;
    cin>>n;
    set<string> types;
    while(n--)
    {
        cin>>S;
        types.insert(S);
    }
    cout<<sz(types);
}




signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 19260
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S divup_L(S a, T b){
  return (a+b-1)/b;
}
int N;
int D;
int X;
int A[100];
int main(){
  rd(N);
  rd(D);
  rd(X);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY;
    for(KL2GvlyY=0;KL2GvlyY<(N-1) + 1;KL2GvlyY++){
      X += (divup_L(D,A[KL2GvlyY]));
    }
  }
  wt_L(X);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int N, D, X, A[100];
// {
//   rd(N,D,X,A(N));
//   X += (D /+ A[0..N-1]);
//   wt(X);
// }


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

ans = []
for i in range(B):
  row = '1'*A+'0'*(W-A)
  ans.append(row)

for i in range(H-B):
  row = '0'*A+'1'*(W-A)
  ans.append(row)

print(*ans,sep='\n')

Measured memory_bytes: 5108
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
int k,t;
cin>>k>>t;
string s;
char q;
int o=0;
for(int i=1; i<=t*k; i++){
cin>>s;
if(s=="snuke"){
if(i%t==0){
q = 'A' + (t-1);
o=i/t;}
else{
q = 'A' + i%t-1;
o=i/t+1;}
cout<<q<<o<<endl;}}}


Measured memory_bytes: 3632
def main():
    N = int(input())
    d = list(map(int, input().split()))
    ans = 0

    for xi in range(len(d)):
        for yi in range(len(d)):
            if xi != yi:
                ans += d[xi] * d[yi]

    print(ans // 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39152
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
from datetime import datetime as dt

def main():
  k = int(input())
  if k%2==0:
    print((k//2)**2)
  else:
    print((k//2)*(k//2+1))
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5884
//#define _GLIBCXX_DEB // Iterator safety; out-of-bounds access for Containers, etc.
//#pragma GCC optimize "trapv" // abort() on (signed) integer overflow.
#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define ll long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define INF 1000000000
#define bits(n) __builtin_popcount(n)

void solve()
{
    int n;
    cin>>n;
    vector<pair<int,int>> v;
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        v.push_back({a,b});
    }
    int c=0;
    for(int i=0;i<n;i++)
    {
        if(v[i].first==v[i].second)
        {
            c++;
            if(c==3)
            {
                cout<<"Yes";
                return;
            }
        }
        else
        {
            c = 0;
        }
    }
    cout<<"No";
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3640
val = [int(i) for i in input().split()]
N = int(input())*4

li = [1,2,4,8]

m = [0]*4
for i in range(4):
    m[i] = val[i]*(2**(4-i-1))

ans = 0
while N != 0:
    j = m.index(min(m))
    ans += N//li[j]*val[j]
    N = N%li[j]
    m.pop(j)
    li.pop(j)
    val.pop(j)

print(ans)


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

//-----------------------------------------------------------------------------

int V,E,R;
#define INIT INF
typedef int Weight;
typedef pair<Weight,int> P;

struct Edge {
	int to;
	Weight cost;
	Edge(int to,Weight cost):to(to),cost(cost) {}
};

typedef vector< vector<Edge> > Graph;

bool operator<(const Edge &e,const Edge &f) {
	return e.cost!=f.cost?e.cost>f.cost:e.to<f.to;
}

void dijkstra(const Graph &G,int s,vector<Weight> &dist) {
	int n=(int)G.size();
	dist.assign(n,INIT);
	dist[s]=0;
	priority_queue< P,vector<P>,greater<P> > Q;
	Q.push(P(0,s));
	while(!Q.empty()) {
		P p=Q.top();Q.pop();
		int v=p.second;
		if(dist[v]<p.first) continue;
		REP(i,(int)G[v].size()) {
			Edge e=G[v][i];
			if(dist[e.to]<=dist[v]+e.cost) continue;
			dist[e.to]=dist[v]+e.cost;
			Q.push(P(dist[e.to],e.to));
		}
	}
}

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

	cin>>V>>E>>R;
	Graph G(V);
	vector<Weight> dist(V,INIT);
	REP(i,E) {
		int u,v;Weight c;
		cin>>u>>v>>c;
		G[u].push_back(Edge(v,c));
	}
	dijkstra(G,R,dist);
	REP(i,V) {
		if(dist[i]==INIT) cout<<"INF"<<endl;
		else cout<<dist[i]<<endl;
	}

	return 0;
}



Measured memory_bytes: 13072
// AtCoder150 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>
#include <ctype.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

int revcompare(const void* a, const void* b) {
    return *(int*)b- *(int*)a;
}

int main(void)
{
    int i,j,n;
    char s[27];

    scanf("%s", s);
    int* used = (int*)calloc(26, sizeof(int));

    for(i=0;i<strlen(s);i++){
        if(used[s[i]-'a'] == 0){
            used[s[i]- 'a'] = 1;
        }else{
            printf("no");
            return 0;
        }
    }
    printf("yes");

    return 0;

}


Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#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 <math.h> // sqrt
#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 <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        vector<char> data(W, ' ');
        for (int j = 0; j < W; j++) {
            char c;
            cin >> c;
            data[j] = c;
            cout << c;
        }
        cout << endl;
        for (int j = 0; j < W; j++) {
            cout << data[j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3596
#include<stdio.h>
int main(void)
{
	int n,k,l[100],x,sum,i,j;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d",&l[i]);
	}
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(l[i]<l[j]){
				x=l[i];
				l[i]=l[j];
				l[j]=x;
			}
		}
	}
	sum=0;
	for(i=0;i<k;i++) sum+=l[i];
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
long long num_size(long long X){
  int ans=0;
  while(true){
    if(X==0){
      break;
    }
    else{
      X/=10;
      ans++;
    }
  }
  return ans;
}
int main() {
  
  long long N;
  cin>>N;
  
  long long ans=1000000000;
  
  
  for(int i=1;i<=pow(N,0.5);i++){
    if(N%i==0){
      ans=min(ans,max(num_size(i),num_size(N/i)));
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 4024
#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>;

const int A = 1000005;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> c(A);
    rep(i, n) {
        cin >> a[i];
        c[a[i]]++;
    }
    bool pairwise = true;
    for (int i = 2; i < A; i++) {
        int cnt = 0;
        for (int j = 0; j < A; j += i) {
            cnt += c[j];
        }
        if (cnt > 1) {
            pairwise = false;
            break;
        }
    }
    if (pairwise) {
        cout << "pairwise coprime" << endl;
        return 0;
    }

    int g = 0;
    rep(i, n) g = gcd(g, a[i]);
    if (g == 1) {
        cout << "setwise coprime" << endl;
        return 0;
    }

    cout << "not coprime" << endl;

    return 0;
}

Measured memory_bytes: 11120
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int N, M;
LL f[200][200];
int main()
{
	scanf("%d%d", &N, &M);
	LL sum_odd = 0, sum_even = 0;
	for (int i = 1; i <= N; ++i)
	{
		int x;
		scanf("%d", &x);
		if (x % 2) sum_odd ++;
		else sum_even ++;
	}
	f[0][0] = 1;
	for (int i = 1; i <= 60; ++i)f[i][0] = 1;
	for (int i = 1; i <= 60; ++i)
		for (int j = 1; j <= i; ++j)
			f[i][j] = f[i-1][j] + f[i-1][j-1];
	if (!M)
	{
		LL sum1 = 0, sum2 = 0;
		for (int i = 0; i <= sum_even; ++i)
			sum1 += f[sum_even][i];
		for (int i = 0; i <= sum_odd; i += 2)
			sum2 += f[sum_odd][i];
		printf("%lld", sum1 * sum2);
	}
	else 
	{
		LL sum1 = 0, sum2 = 0;
		for (int i = 0; i <= sum_even; ++i)
			sum1 += f[sum_even][i];
		for (int i = 1; i <= sum_odd; i += 2)
			sum2 += f[sum_odd][i];
		printf("%lld", sum1 * sum2);
	}
	return 0;
}

Measured memory_bytes: 384