akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
  int x, y, suma=0, sumb=0, cnt=0;
  while(scanf("%d%*c%d",&x,&y)==2) {
    suma+=x*y;
    sumb+=y;
    cnt++;
  }
  double ans=(double)sumb/cnt*10;
  if((int)ans%10>=5) {
    ans/=10;
    ans++;
  }
  int ansb=(int)ans;
  cout << suma << endl << ansb << endl;
  return 0;
}


Measured memory_bytes: 1208
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	int con = 0;
	vector<pair<int,int>> L;
	multiset<int> x;
	
	cin>>N;
	
	L.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>L[i].first;
		// x.insert(L[i]);
	}
	
	sort(L.begin(), L.end());
	
	for(int i = 0; i < N; i++){
		L[i].second = i+1;
	}
	
	for(int i = 0; i < N; i++){
		for(int j = i + 1; j < N; j++){
			// int a = max(abs(L[i] - L[j]), d[j]), b = L[i] + L[j];
			pair<int,int> a = {abs(L[i].first-L[j].first)+1, -INF}, b = {L[i].first + L[j].first, -INF};
			
			if(a.first == L[j].first) a.second = L[j].second+1;
			else if(a.first < L[j].first){
				a.first = L[j].first;
				a.second = L[j].second+1;
			}
			
			// cout<<"i = "<<i<<" j = "<<j<<endl;
			// cout<<"Li = "<<L[i].first<<" Lj = "<<L[j].first<<endl;
			
			// cout<<a.first<<" "<<a.second<<" "<<b.first<<" "<<b.second<<endl;
			// cout<<lower_bound(L.begin(), L.end(), b) - lower_bound(L.begin(), L.end(), a)<<endl;
			con += lower_bound(L.begin(), L.end(), b) - lower_bound(L.begin(), L.end(), a);
			
		
		}
		
	
	}
	
	cout<<con<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl


void solve(long long N, long long A, long long B){
  int x = N % (A + B);
  bool isBlue = 1 <= x and x <= A; 

  if (isBlue) {
    cout << N / (A + B) * A + x << endl;
  } else {
    cout << N / (A + B) * A + A + ((N % (A + B) == 0) ? -A : 0) << endl;
  }
}

signed main(){
  long long N;
  scanf("%lld",&N);
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  solve(N, A, B);
}


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

int main()
{
	char N[5];

	scanf("%s", N);

	if (N[3] == N[2] && N[2] == N[1])
		printf("Yes");

	else if (N[2] == N[1] && N[1] == N[0])
		printf("Yes");

	else 
		printf("No");

	getchar(); getchar();
	return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  for (auto it = vc.begin(); it != vc.end(); ++it)
  {
    if (std::next(it) == vc.end())
      os << *it;
    else
      os << *it << ' ';
  }
  return os;
}

template<class T1, class T2>
inline
std::ostream & operator<<(std::ostream & os, const std::pair<T1, T2> & p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  using std::cout;
  ui A{}, B{}, C{}; std::cin >> A >> B >> C;

  ui ans = std::min(B / A, C);

  cout << ans << '\n';
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
import numpy as np
import itertools
a1row = np.array(list(map(int,input().split())))
a2row = np.array(list(map(int,input().split())))
a3row = np.array(list(map(int,input().split())))
amatrix = np.array([a1row,a2row,a3row])
a1a2row = amatrix[0,:]-amatrix[1,:]
a2a3row = amatrix[1,:]-amatrix[2,:]
a1a2col = amatrix[:,0]-amatrix[:,1]
a2a3col = amatrix[:,1]-amatrix[:,2]
flag1 = all(a1a2row == a1a2row[0])
flag2 = all(a2a3row == a2a3row[0])
flag3 = all(a1a2col == a1a2col[0])
flag4 = all(a2a3col == a2a3col[0])
if flag1*flag2*flag3*flag4:
    print('Yes')
else:
    print('No')

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

using ll = long long;

const int N = 5005;
const ll M = ll(1e9) + 7;

int n, s[N], m;
ll a[N], d[N][N], r;
vector<int> e[N];

ll pw(ll n, ll k){
    if(!k) return 1;
    return pw(n * n % M, k / 2) * (k % 2 ? n : 1) % M;
}

int g(int x, int p){
    s[x] = 1;
    for(int i : e[x]) if(i != p) s[x] += g(i, x);
    return s[x];
}

int f(int x, int p, int t){
    for(int i : e[x])
        if(i != p && s[i] > t / 2) return f(i, x, t);
    return x;
}

int main(){
    scanf("%d", &n);
    for(int i = 0, x, y; i < n - 1; i++){
        scanf("%d%d", &x, &y);
        e[x].push_back(y);
        e[y].push_back(x);
    }
    int c = f(1, 0, g(1, 0));
    for(int i : e[c]) a[++m] = g(i, c);
    a[++m] = d[0][0] = 1;
    for(int i = 1; i <= m; i++){
        ll t = 1;
        for(int k = 0; k <= a[i]; k++){
            for(int j = k; j <= n; j++)
                d[i][j] = (d[i][j] + d[i - 1][j - k] * t) % M;
            t = t * (a[i] - k) * (a[i] - k) % M * pw(k + 1, M - 2) % M;
        }
    }
    for(int i = 0, v = 1; i <= n; i++, v *= -1){
        ll x = 1, y = 1;
        for(int j = 1; j <= n - i; j++){
            x = x * j % M;
            if(j < n - i) y = y * j % M;
        }
        r = (r + M + v * (d[m][i] * x + d[m - 1][i] * y) % M) % M;
    }
    printf("%lld\n", r);
}

Measured memory_bytes: 196096
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
A = Counter(readInts())
print('YES' if A[5] == 2 and A[7] == 1 else 'NO')


Measured memory_bytes: 10252
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
mod = 10**9+7
ans = 0 ;count = 0 ;

n=int(input())
pro = [0]*(n+1)
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort();B.sort()
for i,bi in enumerate(B):
    pro[i+1]=bisect.bisect_left(A,bi)
for i in range(n):
    pro[i+1]+=pro[i]
for i,ci in enumerate(C):
    ans+=pro[bisect.bisect_left(B,ci)]
print(ans)

Measured memory_bytes: 87336
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
const int INF = 1e9;

int main(void) {
    int N;
    string S, T;
    cin >> N;
    cin >> S >> T;
    string ans;
    for (int i = 0; i < N; i++) {
        ans += S[i];
        ans += T[i];
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;
int main(){
	int n,k;
  	cin>>n>>k;
  	cout<<fixed<<setprecision(6);
  	vector<double>a(n);
  	vector<double>b(0);
  	for(int i=0;i<n;i++){
    	cin>>a[i];
      	b.push_back((1+a[i])/2);
    }
  	vector<double>c(1);
  	double sum=0;
  	for(int i=0;i<k;i++){
    	sum=sum+b[i];
    }
  	c[0]=sum;
  	for(int i=1;i<n-k+1;i++){
    	c.push_back(c[i-1]+b[k+i-1]-b[i-1]);
    }
  	vector<double>d(0);
  	for(int i=0;i<c.size();i++){
    	d.push_back(c[i]);
      	
    }
  	sort(d.begin(),d.end());
  	cout<<fixed<<setprecision(6);
    cout<<d[c.size()-1]<<endl;

}

Measured memory_bytes: 8048
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;

    int i = n;
    for (; i * i <= m; ++i) {
        if (m % i == 0) {
            cout << m / i << endl;;
            return 0;
        }
    }

    for (--i; i >= 1; --i) {
        if (m / i < n) {
            continue;
        }

        if (m % i == 0) {
            cout << i << endl;
            return 0;
        }
    }

    return 1;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char **argv)
{
  char s[10] = {0};
  int alp[26] = {0};
  int i = 0;
  int count = 0;

  scanf("%s", s);

  for(i = 0; i < 4; i++)
  {
    if(++alp[s[i] - 'A'] == 2)
    {
      count++;
    }
  }

  printf("%s\n", (count == 2 ? "Yes" : "No"));

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    int n;
    cin >> n ;
    int f[n+1];
    for(int i=0;i<=n;i++){
        f[i]=0;
    }
    int sum=0;

    for(int x=1;x<=100;x++){
        if(x*x>2*n){
            break;
        }
        else{
        for(int y=1;y<=100;y++){
            if((x+y)*(x+y)+y*y>2*n){
                break;
            }
            else{
            for(int z=1;z<=100;z++){
                if((x+y)*(x+y)+(x+z)*(x+z)+(y+z)*(y+z)>2*n){
                    break;
                }
                else{
                sum = (x+y)*(x+y)+(y+z)*(y+z)+(z+x)*(z+x);
                for(int i=1;i<=n;i++){
                    if(sum==2*i){
                            f[i-1] += 1;
                    }
                    if(sum<2*i){
                        break;
                    }
                }
                }
            }
            }
            }
        }
    }


    for(int i=1;i<=n;i++){
         cout << f[i-1] << endl;
    }
}



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

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            // 整数配列の入力
            var hArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToList();

            hArray.Sort();

            long result = 0;
            for(int i = 0; i < hArray.Count - inputLongArray[1]; i++)
            {
                result += hArray[i];
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 38016
#include <iostream>
  
using namespace std;
 
long long n,s,dp[11][1001];

int main(void){

  dp[0][0] = 1;
   
  for(int i=0;i<101;i++)
    for(int j=9;j>=0;j--)
      for(int k=0;i+k<1001;k++)
        dp[j+1][k+i]+=dp[j][k];

  while(cin >> n >> s, n|s)
    cout << dp[n][s] << endl;

  return 0;
}

Measured memory_bytes: 1236
import math
n , k = map(int , input().split())
arr = list(map(int , input().split()))
tot=0
for i in range(0 , k):
	tot = tot + (math.log2(arr[i]))
j = 0
for i in range(k , n):
	now = tot + math.log2(arr[i])
	now = now-math.log2(arr[j])
	j=j+1
	if now>tot:
		print("Yes")
	else:
		print("No")


Measured memory_bytes: 94112
#include <iostream>

using namespace std;

const int W = 12, H = 12;
int m[12][12];
void paint(int x, int y) {
	if (x < 0 || x >= W || y < 0 || y >= H) return;
	if (m[y][x] == 0) return;
	m[y][x] = 0;

	paint(x+1, y);
	paint(x-1, y);
	paint(x, y+1);
	paint(x, y-1);
}
int main() {
	while (1) {
		for (int y = 0; y < H; ++y) {
			string str; if ( !(cin >> str) ) return 0;
			for (int x = 0; x < W; ++x) {
				m[y][x] = str[x] == '1' ? 1 : 0;
			}
		}

		int ans = 0;
		for (int y = 0; y < H; ++y) for (int x = 0; x < W; ++x) {
			if (m[y][x]) {
				++ans;
				paint(x, y);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1188
N = int(input())
A = list(map(int,input().split()))

ans = [0 for x in range(N+1)]
for i in range(N,0,-1):
    s = 0
    for j in range(2*i,N+1,i):
        if ans[j] == 1:
            s += 1
    ans[i] = s & 1 != A[i-1]

ans_m = 0
ans_a = []
for i in range(len(ans)):
    if ans[i]:
        ans_m += 1
        ans_a.append(i)

print(ans_m)
if ans_m > 0:
    print(" ".join(map(str,ans_a)))



Measured memory_bytes: 19896
#include<stdio.h>
int main(void)
{
	int a,b,c;
	int sort = 0;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		sort=b;
		b=a;
		a=sort;
	}else if(a>c){
		sort=c;
		c=a;
		a=sort;
	}
	if(b>c){
		sort=c;
		c=b;
		b=sort;
	}
	if(a>b){
		sort=b;
		b=a;
		a=sort;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
int main(){
    int N,M; cin >> N >> M;
    priority_queue<int> que;
    vector<int> a(N);
    rep(i, N){
        cin >> a[i];
        que.push(a[i]);
    }

    rep(i,M){
        int max = que.top();
        int half = max/2;
        que.pop();
        que.push(half);
    }

    ll ans = 0;
    while(!que.empty()){
        ans += que.top();
        que.pop();
    }

    cout << ans <<endl;
}

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

char m[100][100];
int h,w;
int a;

void walk(int i,int j){
	char c=m[i][j];
	m[i][j]='1';
	if(i+1<h&&m[i+1][j]==c)walk(i+1,j);
	if(i-1>=0&&m[i-1][j]==c)walk(i-1,j);
	if(j+1<w&&m[i][j+1]==c)walk(i,j+1);
	if(j-1>=0&&m[i][j-1]==c)walk(i,j-1);
}

int main(void){
	while(cin>>h>>w,h||w){
		for(int i=0;i<h;i++){
			scanf("%s",m[i]);
		}
		a=0;

		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(m[i][j]!='1'){
					a++;
					walk(i,j);
				}
			}
		}
		cout<<a<<endl;
	}
}

Measured memory_bytes: 3924
s = str(input())
acgt = {"A", "C", "G", "T"}

ans = 0
for i in range(len(s)):
    for j in range(i, len(s) + 1):
        t = s[i: j]
        for k in t:
            if k not in acgt:
                break
        else:
            ans = max(ans, len(t))
print(ans)


Measured memory_bytes: 3060
<?php
fscanf(STDIN, "%d %d %d", $a, $b, $c);
$array = [ $a, $b, $c ];
$five = 0;
$seven = 0;
for ($tmp = 0; $tmp < 3; $tmp++){
    if ($array[$tmp] == 5){
        $five += 1;
    }
    if ($array[$tmp] == 7){
        $seven += 1;
    }
}
if ($five == 2 and $seven == 1){
    print("YES\n");
} else {
    print("NO\n");
}
?>

Measured memory_bytes: 4728
def mergeSort(A,left,right,B):
    if left + 1 < right:
        mid = (left+right)//2
        mergeSort(A,left,mid,B)
        mergeSort(A,mid,right,B)
        merge(A,left,mid,right,B)

def merge(A,left,mid,right,B):
    L = A[left:mid]
    R = A[mid:right]
    L.append(1000000000)
    R.append(1000000000)

    i = 0
    j = 0
    for k in range(left,right):
        B.append(1)
        if L[i] < R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

n = int(input())
nums = list(map(int,input().split(" ")))
B = []

mergeSort(nums,0,n,B)
print(' '.join(map(str,nums)))
print(str(len(B)))



Measured memory_bytes: 140904
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	p := make([]int,n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}

	ans := 0
	for i := 0; i < n-2; i++ {
		if p[i+1] > p[i] && p[i+1] < p[i+2] {
			ans++
		}
		if p[i+1] < p[i] && p[i+1] > p[i+2] {
			ans++
		}
	}
	fmt.Println(ans)
}


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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int w = Integer.parseInt(br.readLine());
		int n = Integer.parseInt(br.readLine());
		int[] seq = new int[w];
		for(int i = 0; i < seq.length;i++){
			seq[i] = i+1;
		}
		for(int i = 0 ; i < n;i++){
			String[] s= br.readLine().split(",");
			int a=Integer.parseInt(s[0]);
			int b=Integer.parseInt(s[1]);
			int c = seq[a-1];
			seq[a-1] = seq[b-1];
			seq[b-1] = c;
		}
		for(int i = 0; i<seq.length;i++){
			System.out.println(seq[i]);
		}
	}

}

Measured memory_bytes: 24324
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  string A;
  cin >> A;
  int size = A.size();
  int X = 0;
  int Y = 0;
  rep(i, size) {
    Y++;
    if(A.at(i) == 'C') {
      X++;
      break;
    }
  }
  if(X == 1) {
    rep2(i, Y - 1, size) {
      if(A.at(i) == 'F') {
        cout << "Yes" << endl;
        X++;
        break;
      }
    }
  }
  if(X == 1) {
    cout << "No" << endl;
  }
  if(X == 0) {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3600
#include<iostream>
#include<math.h>
using namespace std;

int main() {
	float v,t;
	double y;
	
	while ( cin >> v ) {
		t = v / 9.8;
		y = 4.9 * t * t;
		y = (y + 5.0)/5.0;
		
		y = ceil( y );
		
		cout << y << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define s_pri(str) printf("%s\n",str);
#define PRINT(str) printf(#str "\n")
#define v_pri(val) printf("%d\n",val);
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define pi acos(-1.0)
#define sca(x) scanf("%d",&x);

typedef long long int ll;

/*
puts("aa");
//*/
int cmp(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}


int main(void) {
	char S[11], T[11],U[11];
	int A, B;
	scanf("%s%s", S, T);
	scanf("%d%d", &A, &B);
	scanf("%s", U);
	if (strcmp(S, U) == 0) {
		A--;
	}
	else {
		B--;
	}
	printf("%d %d\n", A, B);

	return 0;
}

Measured memory_bytes: 128
V, E, r = map(int, input().split())
paths = []

for i in range(E) :
    s, t, d = map(int, input().split())
    
    paths.append([s, t, d])
    
INF = 10**20
n = [INF for x in range(V)]
n[r] = 0

while True :
    break_flg = True
    
    for p in paths :
        if n[p[0]] + p[2] < n[p[1]] :
            n[p[1]] = min(n[p[1]], n[p[0]] + p[2])
            break_flg = False
            
    if break_flg == True :
        break

for i in n :
    if i == INF :
        print("INF")
    else :
        print(i)


Measured memory_bytes: 102508
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll ara[2000];
ll fact(ll n,ll r)
{
  ll ret;
    if(n<r){return 0;}
    else{
        ret=(n%2==0)?((n/2)*(n-1)):n*(n-1)/2;
    }
  return ret;
}
int main()
{
    ll i,j,n,k,ts=1,sd,nm;
    ll nsx,nsy,ndx,ndy;
    ll T;
    scanf("%lld\n",&T);
    string str;
    char ara[11],vh;
    memset(ara,0,sizeof(ara));
    vector<ll>v;
    vector<string> vc;
    map<string,ll>m;
    for(i=1;i<=T;i++){
        //getline(cin,str);
        scanf("%s",ara);
        scanf("%c",&vh);
        int in=0;
        /*for(j=0;j<str.size();j++){
            in=in+str[j];
        }*/
        sort(ara,ara+10);
        str=ara;

        if(m[str]==0){vc.push_back(str); }m[str]++;
        //ara[in]++;
        //cout<<in<<'\n'<<str<<'\n';

    }
    ll cnt=0;
    for(i=0;i<vc.size();i++){

        cnt=cnt+fact(m[vc[i] ],2);

    }
    printf("%lld\n",cnt);


    return 0;
}


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

int main() {
  int p1, p2, p3, j1, j2;
  cin >> p1 >> p2 >> p3 >> j1 >> j2;
 
  int mp = min(p1, min(p2, p3));
  int mj = min(j1, j2);
  cout << mp+mj-50 << endl;
}

Measured memory_bytes: 1160
lc = [[int(w) for w in input().split()] for i in range(3)]
cond = True

lb = lc[0]
a2 = lc[1][0]-lb[0]
a3 = lc[2][0]-lb[0]
la = [0, a2, a3]
for i in range(3):
    for j in range(3):
        if lc[i][j] != la[i]+lb[j]:
            cond = False
            break

print("Yes" if cond else "No")


Measured memory_bytes: 9132
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> hoge(n);
    for(int i = 0; i < n; i++){
        cin >> hoge.at(i);
    }
    vector<int> huga(n);
    for(int i = 0; i < n; i++){
        huga.at(hoge.at(i) - 1) = i + 1;
    }
    for(int i = 0; i < n; i++){
        cout << huga.at(i);
        if(i != n - 1) cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1664
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) a[i] = sc.nextInt();
		long [] sum = new long[n + 1];
		for(int i = 0; i < n; i++) sum[i + 1] = (sum[i] + a[i]) % m;
		Map<Long, Integer> map = new HashMap<>();
		for(int i = 0; i < n + 1; i++) {
			if(map.containsKey(sum[i])) map.put(sum[i], map.get(sum[i]) + 1);
			else map.put(sum[i], 1);
		}
		long ans = 0;
		for(long key : map.keySet()) {
			if(map.get(key) >= 2) {
				long x = map.get(key);
				ans += x * (x - 1) / 2;
			}
		}
		System.out.println(ans);
	}
}


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

vector<string> split(const string &s, regex delim) {
    vector<string> res;
    sregex_token_iterator itr(s.begin(), s.end(), delim, -1), end;
    for(; itr!=end; itr++){
        /*if(*itr != "")*/ res.push_back(*itr);
    }
    return res;
}

int main(){
    while(1){
        vector<string> a(2);
        cin >> a[0];
        if(a[0]==".") break;
        cin >> a[1];

        vector<vector<string> > b(2);
        for(int i=0; i<2; i++){
            b[i] = split(a[i], regex{R"(")"});
        }
        if(b[0].size() != b[1].size()){
            cout << "DIFFERENT" << endl;
        }else{
            vector<int> dif(2, 0);
            for(int i=0; i<(int)b[0].size(); i++){
                if(b[0][i] != b[1][i]) dif[i%2]++;
            }
            if(dif[0]==0 && dif[1]==0){
                cout << "IDENTICAL" << endl;
            }else if(dif[0]==0 && dif[1]==1){
                cout << "CLOSE" << endl;
            }else{
                cout << "DIFFERENT" << endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3232
_n, x = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
as.sort!.map! { |a|
  if x >= a
    x -= a
    1
  else
    0
  end
}
num = as.inject(:+)
num -= 1 if (as.last == 1 && x != 0)
puts num


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
const int INF = 1e9;
const long long LINF = 1e18;
const double EPS = 1e-8;
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define reps(i,j,k) for(int i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> Pii;
typedef pair<Pii,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;

template<class T>
ostream& operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()){
		out << v[i] <<", ";
	}
	return out << "}" << endl;
}

int N;

int main() {
	
	cin >> N;
	vi a(N);
	vector<double> d(N);
	double ans = 0;

	rep(i,N){
		cin >> a[i];
		double pos = a[i];
		rep(j, i){
			double s = a[j] + a[i], t = a[j] - a[i];
			pos = max(pos, sqrt(s * s - t * t) + d[j]);
		}
		d[i] = pos;
		ans = max(ans, pos + a[i]);
	//	cout << pos << endl;
	}

	printf("%.6f\n", ans);
	return 0;
}

Measured memory_bytes: 3240
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let mut iter = line.split_whitespace().map(|s| s.parse::<i32>().unwrap());
    let (a, b, c) = (iter.next().unwrap(), iter.next().unwrap(), iter.next().unwrap());
    if a < b && b < c {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 5032
def euc(a, b):
	if b == 0:
		return a
	return euc(b, a%b)

N, X = map(int, input().split())
x = list(map(int, input().split()))
dist = list(map(lambda v: abs(v-X), x))
ans = dist[0]
for i in range(1, N):
	ans = euc(ans, dist[i])
print(ans)

Measured memory_bytes: 63768
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a[n], b[n], c[n-1];
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    for (int i=0; i<n; i++) {
        cin >> b[i];
    }
    for (int i=0; i<n-1; i++) {
        cin >> c[i];
    }
    int sum = 0;
    sum += b[a[0]-1];
    for (int i=1; i<n; i++) {
        sum += b[a[i]-1];
        if (a[i] - a[i-1] == 1) {
            sum += c[a[i-1]-1];
        }
    }
    cout << sum << endl;
}

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

vector<pair<int, int>> p[200005];
pair<string, string> res[200005];


int main()
{
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        int x, y;
        cin >> x >> y;
        p[x].push_back({y, i});
    }

    for(int i = 1; i <= n; ++i){
        sort(p[i].begin(), p[i].end());
    }

    for(int i = 1; i <= n; ++i){
        for(int j = 0; j < (int)p[i].size(); ++j){
            stringstream ss;
            ss << i;
            string last = ss.str();
            while(last.size() < 6){
                last = "0" + last;
            }

            res[p[i][j].second].first = last;

            stringstream ss2;
            ss2 << j + 1;
            last = ss2.str();
            while(last.size() < 6){
                last = "0" + last;
            }

            res[p[i][j].second].second = last;
        }
    }

    for(int i = 0; i < m; ++i){
        cout << res[i].first << res[i].second << "\n";
    }
    return 0;
}


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

int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}

vector<int>a;
int pos;

void mul(int x){
    int up=0;
    int next;
    for(int i=0;i<pos+10;i++){
        a[i]=a[i]*x+up;
        up=a[i]/10;
        a[i]%=10;
        if(a[i])next=i;
    }
    pos=next;
}

void print(){
    for(int i=pos;i>=0;i--)cout<<a[i];cout<<endl;
}

int main(){
    a.resize(100000,0);
    pos=0;
    a[0]=1;

    int n,m,r;
    cin>>n>>m>>r;
    if(r-n*m<0){
        cout<<0<<endl;
        return 0;
    }

    r-=n*m;

    ///(r+n-1)C(r)->AC


    int cnt[20000]={0};
    int x=max(r,n-1);
    int y=r+n-1-x;
    for(int i=2;i<=r+n-1;i++)cnt[i]++;

    for(int i=2;i<=x;i++)cnt[i]--;


    for(int i=2;i<=y;i++){
        int latte=i;
        for(int j=r+n-1;j>1;j--){
            if(cnt[j]==0)continue;
            while(cnt[j]){
                int g=gcd(j,latte);
                if(g==1)break;
                cnt[j]--;
                cnt[j/g]++;
                latte/=g;
            }
        }


    }

    for(int i=2;i<=r+n-1;i++){
        while(cnt[i]){
            mul(i);cnt[i]--;
        }
    }

    print();

    return 0;
}

Measured memory_bytes: 1536
N,M,X = (int(i) for i in input().split())  
a = [int(i) for i in input().split()]

cost = 0
cost2 = 0

for i in range(X, N):
   if i in a:
       cost += 1

for i in range(X, 0, -1):
    if i in a:
        cost2 += 1

if cost < cost2:
    print(cost)
else:
    print(cost2)


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

int main(){
  ll n;
  cin >> n;
  vector<ll> kosuu(10000,0);
  ll ruton = pow(n, 0.5);
  ll i=2, j=-1;
  int ans = 0;
  while(n!=1){
    if(n%i==0)j++;
    while(n%i==0){
      kosuu[j]++;
      n/=i;
    }
    i++;
    if(i==ruton){
      if(n==1) break;
      else{
        ans++;
        break;
      }
    }
  }

  rep(i,10000){
    int j=1;
    while(kosuu[i]-j >= 0){
      kosuu[i] -= j;
      j++;
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4076
#include<iostream>
 using namespace std ;
 int main()
{
short int c=0,price;
char s[3];

cin>>s;

if(s[0]=='o') ++c;
if(s[1]=='o') ++c;
if(s[2]=='o') ++c;

price=700+c*100;

cout<<price;

}

Measured memory_bytes: 3548
import java.util.*;
 
class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int[] a = new int[n];
    int min = 0, max = 0;
    for(int i=0; i<n; i++){
      if(i==0){
        a[i] = sc.nextInt();
        min = a[i];
        max = a[i];
      } else {
        a[i] = sc.nextInt();
        if(min > a[i]){
          min = a[i];
        } else if(max < a[i]){
          max = a[i];
        }
      }
    }
    System.out.println(max - min);

    sc.close();
  }
}


Measured memory_bytes: 22736
n=int(input())
cards=[i+1 for i in range(2*n)]
m=int(input())
for i in range(m):
    k=int(input())
    if k==0:
        A=cards[0:n]
        B=cards[n:2*n]
        cards=[B[j//2] if j%2 else A[j//2] for j in range(n*2)]
    else:
        A=cards[0:k]
        B=cards[k:2*n] 
        cards=B+A

for i in cards:
    print(i)


Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,n,ans=10000000000000LL;
  cin>>a>>b>>n;
  for(ll i=1;i<=n;i++){
    if(b%i) continue;
    for(ll j=1;j<=n;j++){
      ans=min(ans,abs(a-b/i*j));
    } 
  }
  cout << ans << endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    cin.tie(0);

    int n;
    cin >> n;

    vector<int> ans(n * n);

    vector<pair<int, int>> ord;

    vector<int> xs(n);
    for (int i = 0; i < n; i++) {
        cin >> xs[i];
        xs[i]--;
        ans[xs[i]] = i + 1;
        ord.emplace_back(xs[i], i + 1);
    }

    sort(ord.begin(), ord.end());

    bool b = [&]() {
        int pos = 0;
        for (int i = 0; i < ord.size(); i++) {
            for (int j = 0; j < ord[i].second - 1; j++) {
                while (ans[pos] > 0) {
                    pos++;
                }
                ans[pos++] = ord[i].second;
            }
            if (pos > ord[i].first)
                return false;
        }

        pos = n * n - 1;

        for (int i = ord.size() - 1; i >= 0; i--) {
            for (int j = 0; j < n - ord[i].second; j++) {
                while (ans[pos] > 0) {
                    pos--;
                }
                ans[pos--] = ord[i].second;
            }
            if (pos < ord[i].first)
                return false;
        }

        return true;
    }();

    if (b) {
        cout << "Yes" << endl;
        for (int i = 0; i < ans.size(); i++) {
            if (i > 0)
                cout << " ";
            cout << ans[i];
        }
        cout << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int a = 0, b = 0, e;
	string s;
	cin >> s;
	for (int h = 0; h < s.size(); h++) {
		if (s[h] == 'A' || s[h] == 'C' || s[h] == 'G' || s[h] == 'T') {
			a++;
			b = max(a, b);
		}
		else {
			a = 0;
		}
	}
	cout << b << endl;
	cin >> e;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BSubstring solver = new BSubstring();
        solver.solve(1, in, out);
        out.close();
    }

    static class BSubstring {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] s = in.next().toCharArray();
            char[] t = in.next().toCharArray();

            int answer = Integer.MAX_VALUE;
            for (int i = 0; i + t.length <= s.length; i++) {
                int score = 0;
                for (int j = i; j < i + t.length; j++) {
                    if (s[j] != t[j - i])
                        score++;
                }
                answer = Math.min(answer, score);
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public final BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 25952
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i,a,b) for(ll i=(a);i<(b);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)
typedef string::const_iterator State;

int space(State &beg){
    int ret = 0;
    while(*beg==' '){
        ret++;
        beg++;
    }
    return ret;
}


string str(State &beg){
    string ret = "";
    while( *beg!=':' && *beg!=';' ){
        assert( isdigit(*beg) || 'a'<=*beg && *beg<='z' || *beg==' ' );
        ret+=*beg;
        beg++;
    }
    return ret;
}


void eval(State &beg, int &ind, string &key, string &val){
    ind = 0;
    val = "*";
    bool colon = false;
    if(*beg==' ')ind = space(beg);
    if(colon==false){
        key = str(beg);
        assert(*beg==':');
        colon = true;
        beg++;
        
        if(*beg==';')return ;
        
        assert(*beg==' ');
        beg++;
        
        
        
    }
    val = str(beg);
    assert(*beg==';');
    beg++;
}

int main(){
    string s;
    cin>>s;
    cin.ignore();
    
    vector<string> vs;
    string t;
    while(getline(cin,t))vs.pb(t);
    
    map<vector<string>,string> mp;
    vector<string> obj;
    vector<int> indent;
    for(auto str: vs){
        str+=";";
        State beg = str.begin();
        int ind;
        string key,val;
        eval(beg,ind,key,val);
        
        while( indent.size() && indent[indent.size()-1]>=ind ){
            obj.pop_back();
            indent.pop_back();
        }
        
        if(val=="*"){
            obj.push_back(key);
            indent.push_back(ind);
            mp[obj] = "*obj";
        }else{
            obj.push_back(key);
            
            mp[obj] = val;
            
            obj.pop_back();
        }
    }
    
    vector<string> query;
    s+='.';
    string buf = "";
    rep(i,s.size()){
        if( s[i]=='.' ){
            if(buf.size()==0)continue;
            query.pb(buf);
            buf = "";
        }else{
            buf+=s[i];
        }
    }
    
    if( mp.count(query)==0 )cout<<"no such property"<<endl;
    else if(mp[query]=="*obj")cout<<"object"<<endl;
    else cout<<"string \""<<mp[query]<<"\""<<endl;
}


//indent[ indent.size()-1 ] != the indent -> pop_back
//hoge:\n -> obj & indent push(hoge,ind)
//map<obj+key> = string

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

#define MAX_R 10
#define MAX_C 10000
#define MAX(a, b) ((a) < (b) ? (b) : (a))

int main() {
	int r, c;
	static int osenbei[MAX_R][MAX_C];
	int i, j;
	int bit;
	int ans;
	int cnt;
	int one;

	while(scanf("%d %d", &r, &c) == 2 && r) {
		for(i = 0; i < r; ++i) {
			for(j = 0; j < c; ++j) {
				scanf("%d", &osenbei[i][j]);
			}
		}

		ans = 0;
		for(bit = 0; bit < (1 << r); ++bit) {
			cnt = 0;
			for(j = 0; j < c; ++j) {
				one = 0;
				for(i = 0; i < r; ++i) {
					one += ((bit >> i) & 1) ^ osenbei[i][j];
				}
				cnt += MAX(one, r - one);
			}

			if(ans < cnt) ans = cnt;
		}

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

	return EXIT_SUCCESS;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

char a[105][105];
int r[105][105], c[105][105];

void solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
  for (int j = 1; j <= m; j++) {
    cin >> a[i][j];
  }
  for (int i = 1; i <= n; i++) {
    r[i][0] = 1;
  }
  for (int j = 1; j <= m; j++) {
    c[0][j] = 1;
  }
  for (int i = 1; i <= n; i++)
  for (int j = 1; j <= m; j++) {
    if (a[i][j] == '#') continue;
    r[i][j] = r[i][j - 1];
    c[i][j] = c[i - 1][j];
  }
  /*for (int i = 1; i <= n; i++)
  for (int j = 1; j <= m; j++) {
    cout << r[i][j] << " \n"[j == m];
  }
  for (int i = 1; i <= n; i++)
  for (int j = 1; j <= m; j++) {
    cout << c[i][j] << " \n"[j == m];
  }*/
  for (int i = 1; i <= n; i++) {
    if (r[i][m]) continue;
    for (int j = 1; j <= m; j++) {
      if (c[n][j]) continue;
      cout << a[i][j];
    }
    cout << '\n';
  }
}

signed main() {
#ifdef _DEBUG
  freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3812
#include <iostream>
#include <vector>

using namespace std;

int f(int n) {
  return n % 2 == 0 ? n / 2 : 3 * n + 1;
}

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

  vector<int> result;

  for (int r = s;;) {
    result.push_back(r);

    for (int i = 0; i < (int)result.size() - 1; ++i) {
      if (result[i] == r) {
        cout << (int)result.size() << endl;
        return 0;
      }
    }

    r = f(r);
  }
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
#include <list>
using namespace std;
#include <stdio.h>
#include <map> 
#include <algorithm>
#include <functional>
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>




int main()
{
	std::vector<long int> a;
	long int N;
	std::string S;
	cin >> N;

	std::vector<int> d;
	for (int i = 0; i < N; ++i) {
		int tt;
		cin >> tt;
		d.push_back(tt);
	}

	int c = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			c += d[i] * d[j];
		}
	}

	printf("%d", c);
	printf("\n");

	return 0;
}

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

int main(){
    
    int N,K,x,Km;
    
    int sum = 0;
    
    cin >> N >> K;
    
    for(int i = 0; i < N; i++){
        
        cin >> x;
        
       Km = K - x;
        
        if(Km < 0){
            Km *= -1;
        }
        
        if(x < Km ){
            sum += 2 * x;   //robotbのけいさんが間違えてる
        }else{
            sum += 2 * Km;
        }
        
    }
    
    cout << sum << endl;
}

Measured memory_bytes: 256
N = int(input())

lst = []

for i in range(N):
    W = input()
    lst.append(W)

for n in range(1, N):
    if lst[n][0] != lst[n-1][-1] or lst.count(lst[n])>=2:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define MAX 300000
int main(){
  bool T[MAX+1];
  int N, Q, q, x, L[MAX+1];

  for ( int i = 0; i <= MAX; i++ ) { T[i] = false; L[i] = 0; }

  scanf("%d %d", &N, &Q);

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

  int m = 0;
  for ( int i = 1; i <= MAX; i++ ){
    L[i] = m;
    if ( T[i] ) m = i;
  }

  for ( int i = 0; i < Q; i++ ){
    scanf("%d", &q);
    int maxv = 0;
    int cur = m;

    while(cur){
      int p = cur%q;
      maxv = max(maxv, p);
      if ( cur - p < 0 ) break;
      cur = L[cur - p];
    }

    printf("%d\n", maxv);
  }
}

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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define STDIO
#define mp make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front 
#define pb push_back
#define pp push
#define lb lower_bound 
#define ub upper_bound

inline void checkmin(int &x, int y){x = min(x, y);}
inline void checkmax(int &x, int y){x = max(x, y);}

int a, b;

int main() {
	#ifndef STDIO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>a>>b;
    for(int i = 0; ; i++) {
    	db x = (db)i * 0.08;
    	db y = (db)i * 0.1;
    	int ax = floor(x), ay = floor(y);
    	if(ax == a && ay == b) {
    		cout<<i<<endl;
    		return 0;
		}
		if(ax > a && ay > b) {
			cout<<-1<<endl;
			return 0;
		}
	}
    /* end code */
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<59;

// 前方の index
int former(const vector<long long> &v, long long x) {
    return (int)(upper_bound(v.begin(), v.end(), x) - v.begin()) - 1;
}

// 後方の index
int latter(const vector<long long> &v, long long x) {
    return (int)(lower_bound(v.begin(), v.end(), x) - v.begin());
}

int main() {
    int A, B, Q; cin >> A >> B >> Q;
    vector<long long> s(A), t(B);
    for (int i = 0; i < A; ++i) cin >> s[i];
    for (int i = 0; i < B; ++i) cin >> t[i];
    s.push_back(INF); s.push_back(-INF);
    t.push_back(INF); t.push_back(-INF);
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    
    for (int _ = 0; _ < Q; ++_) {
        long long x; cin >> x;
        long long res = INF;
        
        // 最初に s (前方に行くか後方に行くか場合分け)
        for (int fl = 0; fl < 2; ++fl) {
            int sid = (fl == 0 ? former(s, x) : latter(s, x));
            // t の前か後ろか
            for (int fl2 = 0; fl2 < 2; ++fl2) {
                int tid = (fl2 == 0 ? former(t, s[sid]) : latter(t, s[sid]));
                chmin(res, abs(x - s[sid]) + abs(s[sid] - t[tid]));
            }
        }
        
        // 最初に t (前方に行くか後方に行くか場合分け)
        for (int fl = 0; fl < 2; ++fl) {
            int tid = (fl == 0 ? former(t, x) : latter(t, x));
            // t の前か後ろか
            for (int fl2 = 0; fl2 < 2; ++fl2) {
                int sid = (fl2 == 0 ? former(s, t[tid]) : latter(s, t[tid]));
                chmin(res, abs(x - t[tid]) + abs(t[tid] - s[sid]));
            }
        }
        
        cout << res << endl;
    }
}

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

object Main extends App {

  def exec(w:String):Unit =  {
    val len = w.length

    def shuffle(i:Int):String = {
      val cnt = (for(j <- 0 until i) yield readInt).sum
      (w drop (cnt%len))+(w take (cnt%len))
    }

    if(w=="-") return else { val n = readInt;println(shuffle(n));val w = readLine ; exec(w) }
  }

  val w = readLine; exec(w)
}

Measured memory_bytes: 43932
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n;
  cin >> n;

  vector<ll> a(10000001,0);
  for(int i=1;i<=n;i++){
    ll k=1;
    while(i*k<=n){
      a[i*k]++;
      k++;
    }
  }

  ll s=0;
  for(int i=1;i<=n;i++){
    s+=i*a[i];
  }

  cout << s << endl;

}

Measured memory_bytes: 81396
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N_MAX = 100001;
int main()
{
  int n,i,j=0,a,t=-1,res=1;
  vector<int> v;
  decltype(v)::iterator it;
  cin >> n;
  cin >> a;
  v.push_back(a);
  for(i=1;i<n;i++){
    cin >> a;
    it=upper_bound(v.begin(),v.end(),a,greater<int>());
    if(it==v.end()){
      v.push_back(a);
    } else {
      *it=a;
    }
  }
  cout << v.size() << endl;
  return 0;
}


Measured memory_bytes: 892