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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int h, w;
    cin >> h >> w;

    vector<string> c(h);
    rep(i, h){
        cin >> c[i];
    }

    rep(i, h){
        cout << c[i] << endl;
        cout << c[i] << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

using namespace std;

void change(int *x, int *y);

int main(void){
	int w,n;
	int p[31];
	int a, b;
	cin >> w;
	cin >> n;
	
	for(int i = 1; i <= w; i++){
		p[i] = i;
	}
	
	for(int j = 0; j < n; j++){
		scanf("%d,%d", &a, &b);
		change(&p[a], &p[b]);
		
	}
	for(int i = 1; i <= w; i++){
		cout << p[i] << endl;
	}
	return 0;
}

void change(int *x, int *y){
	int type = *x;
	*x = *y;
	*y = type;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
string a[111];
bool cmp(string a,string b)
{
	return a<b;
}
int main()
{
	int n,l;
	cin>>n>>l;
	for(int i=1;i<=n;i++)
	    cin>>a[i];
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
	    cout<<a[i];
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
N,W=map(int,input().split())
List=[[] for i in range(4)]
for i in range(N):
  w,v=map(int,input().split())
  if i==0:
    List[0].append(v)
    w0=w
  else:
    List[w-w0].append(v)
ans=0
for i in range(4):
  List[i].sort(key=lambda x:-x)
n0,n1,n2,n3=len(List[0]),len(List[1]),len(List[2]),len(List[3])
for i in range(n0+1):
  for j in range(n1+1):
    for p in range(n2+1):
      for q in range(n3+1):
        if w0*i+(w0+1)*j+(w0+2)*p+(w0+3)*q<=W:
          ans=max(ans,sum(List[0][:i])+sum(List[1][:j])+sum(List[2][:p])+sum(List[3][:q]))
print(ans)
  

Measured memory_bytes: 57432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

ll calculate_gcd(ll a, ll b){
    if(a<b){swap(a,b);}
    if(b<1){return 0;}
    ll r;
    while((r = a%b) != 0){
        a = b;
        b = r;
    }
    return b;
}
ll calculate_lcm(ll a,ll b){
    return a*b/calculate_gcd(a,b);
}

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

    vector<ll> cd;
    for(int i = 1; i < sqrt(a)+1; i++){
        if(a%i==0){
            if(b%i == 0){
                cd.push_back(i);
            }
            if(b%(a/i) == 0){
                cd.push_back(a/i);
            }
        }
    }
    sort(all(cd));
    cd.erase(unique(all(cd)), cd.end());
    ll num = 1;
    ll ans = 0;
    for(int i = 0; i < cd.size(); i++){
        if(num * cd[i] == calculate_lcm(num, cd[i])){
            num *= cd[i];
            ans++;
        }
    }

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 384
#「県ごとの市の「市番号(id)、誕生年(year)」リスト」と「市番号順の市の認識番号(tag)リスト」を用意する

class City:
    #市番号と誕生年を管理する
    def __init__(self,id,y):
        self.id = id
        self.year = y


def main():
    n,m = map(int,input().split())
    pre_lst = [[] for _ in range(n)]  #各県に含まれる市のリスト
    city_tags = [0 for _ in range(m)] #上記のリストから作った市の認識番号を格納するためのリスト

    for i in range(m):
        p,y = map(int,input().split())
        pre_lst[p-1].append(City(i,y)) #入力を受け取り、県ごとのリストを作る

    for pre_num,pre in enumerate(pre_lst):
        if len(pre) <= 0:
            continue
        pre.sort(key = lambda x:x.year) #各県ごとに誕生年順にソート

        counter = 0 #認識番号の右側、何番目に誕生した都市かを作るためのカウンター
        for city in pre:
            city_tags[city.id] = str(pre_num+1).zfill(6) + str(counter+1).zfill(6)
            counter += 1
    for tag in city_tags:
        print(tag)


if __name__ == '__main__':
    main()


Measured memory_bytes: 46216
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

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

    N = int(input())
    if N%2==0:
        print(N)
    else:
        print(N*2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3436
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();
 
  
int main(){
  int h,n;
  cin>>h>>n;
  int sum=0,tmp;
  for(int i = 0;i<n;i++){
    cin>>tmp;
    sum+=tmp;
  }
  if(h-sum<=0){
    cout<<"Yes"<<"\n";  
  }
  else{
    cout<<"No"<<"\n";  
  }
  return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  s' <- BS.getLine
  t <- BS.getLine

  let len = BS.length t

      checkMatch offset i
        | i == len  = True
        | otherwise = let c = s' `BS.index` (offset + i)
                          c' = t `BS.index` i
                      in (c == '?' || c == c') && checkMatch offset (i+1)

      solve offset
        | offset < 0 = BS.pack "UNRESTORABLE"
        | checkMatch offset 0 = mkAns offset
        | otherwise = solve (offset - 1)

      mkAns offset =
        let sl = BS.take offset s'
            sr = BS.drop (offset + len) s'
        in BS.map (\c -> if c == '?' then 'a' else c) (BS.concat [sl, t, sr])

  BS.putStrLn $ solve (BS.length s' - len)


Measured memory_bytes: 3692
<?php
  list($n, $y) = explode(" ", trim(fgets(STDIN)));


  if($y < $n * 1000 || $y > $n * 10000){
    echo "-1 -1 -1";
    exit;
  }

  for($i=0; $i<=$n; $i++){
    for($j=0; $j<=$n-$i; $j++){
      $k = $n - $i - $j;
      if($y == $i*10000+$j*5000+$k*1000){
        echo $i." ".$j." ".$k;
        exit;
      }
    }
  }
  echo "-1 -1 -1";


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

int main() {
  
  int r, g, b;
  cin >> r >> g >> b;
  
  int a = r*100 + g*10 + b;
  
  cout << ((a % 4 == 0) ? "YES" : "NO") << endl;

}

Measured memory_bytes: 256
import math

S = list(input())

S1 = "01"*(len(S)//2)
if len(S1)<len(S):
    S1 += "0"
S2 = "10"*(len(S)//2)
if len(S2)<len(S):
    S2 += "1"

cnt1, cnt2 = 0, 0
for i in range(len(S)):
    if S[i] != S1[i]:
        cnt1 += 1
    if S[i] != S2[i]:
        cnt2 += 1
print(min(cnt1, cnt2))

Measured memory_bytes: 4004
n, s = map(int, input().split())
a = [int(i) for i in input().split()]

mod = 998244353
dp = [[0]*(s+1) for _ in range(n+1)]
dp[0][0] = 1
for i in range(n):
    for k in range(s+1):
        dp[i+1][k] += 2 * dp[i][k]
        dp[i+1][k] %= mod
        if k+a[i] <= s:
            dp[i+1][k+a[i]] += dp[i][k]
            dp[i+1][k+a[i]] %= mod
print(dp[n][s])


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int n, m, k;
    cin >> n >> m >> k;
    for(int i = 0; i <= n; ++i){
        for(int j = 0; j <= m; ++j){
            int sum = i * m + j * (n - 2 * i);
            if(sum == k){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
N, K, S = [int(v) for v in input().split()]

array = []

    
if N == K:
    for i in range(N):
        array.append(str(S))
else:
    for i in range(K):
        array.append(str(S))

    if S == 1000000000:
        while len(array) < N:
            array.append(str(1))
    else:
        while len(array) < N:
            array.append(str(S+1))

print(" ".join(array))



Measured memory_bytes: 13464
MOD = 10 ** 9 + 7

N, K = map(int, input().split())
lst = [0] * (K + 1)
ans = 0
for i in range(K, 0, -1):
    tmp = K // i
    tmp = pow(tmp, N, MOD)
    for j in range(2 * i, K + 1, i):
        tmp -= lst[j]
    ans += (i * tmp)
    ans %= MOD
    lst[i] = tmp

print (ans)


Measured memory_bytes: 11220
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	p := nextInts(n)

	ans := 1
	min := p[0]
	for i := 1; i < n; i++ {
		if p[i] <= min {
			ans++
			min = p[i]
		}
	}
	puts(ans)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int a[N],b[N],n,val,cnt;
vector<int> p,q;
inline int read()
{
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(c<='9'&&c>='0')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}

int main()
{
	n=read();
	for(register int i=1;i<=n;i++)
		a[i]=read();
	for(register int i=1;i<=n;i++)
		b[i]=read();
	reverse(b+1,b+1+n);
	for(register int i=1;i<=n;i++)
	{
		if(a[i]!=b[i])
			continue;
		cnt++;
		p.push_back(i);
		val=b[i];
	}
	for(register int i=1;i<=n;i++)
	{
		if(!cnt)
			break;
		if(a[i]==b[i])
			continue;
		if(a[i]!=val&&b[i]!=val)
		{
			cnt--;
			q.push_back(i);
		}
	}
	if(cnt)
	{
		puts("No");
		return 0;
	}
	for(register int i=0;i<q.size();i++)
		swap(b[p[i]],b[q[i]]);
	puts("Yes");
	for(register int i=1;i<=n;i++)
		printf("%d ",b[i]);
	puts("");
	return 0;
}


Measured memory_bytes: 5688
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main() 
{
  ll N; cin>>N;
  if(N%2==1) {cout<<0<<endl; return 0;}
  ll ans=0;
  ans+=N/10;
  N/=10;
  while(N>0)
  {
    ans+=N/5;
    N/=5;
  }  
  cout<<ans<<endl;
  return 0;
}


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


int main() {
    int n,m,x;
    cin>>n>>m>>x;
    int gate[m];
    int counta=0,countb=0;
    for (int i = 0; i < m; ++i) {
        cin>>gate[i];
        if(gate[i]<x)counta++;
        else if(gate[i]>x)countb++;
    }
    cout<<min(counta,countb)<<endl;
    return 0;
}

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


int main(){
  int M,N;
  cin>>N>>M;
  int A[N];
  rep(i,N) cin>>A[i];
  
  ll all=0,ans=0;
  rep(i,N) all+=A[i];
  
  rep(i,N){
  	if(A[i]*4*M >= all) ans++;
  }
  
  if(ans>=M){
  	cout<<"Yes";
  }else{
  	cout<<"No";
  }
}


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

using namespace std;

typedef long long int ll;

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for(int i=1 ; i<=n ; i++)
    {
        int p;
        cin >> p;
        if(i&1 && p&1)
            ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <vector>
#include <typeinfo>
#include <algorithm>

using namespace std;

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

    vector<int> v;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(), v.end(), greater<int>());
    int ret = stoi(to_string(v[0]) + to_string(v[1])) + v[2];
    cout << ret << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int n,a,b;
	scanf("%d",&n);
	if(!(n - 1)){
		printf("Hello World\n");
	}
	else{
		scanf(" %d %d",&a,&b);
		printf("%d\n",a + b);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    string s; cin>>s;
    if(s=="zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl;
        return 0;
    }
    map<char, int> m;
    for(int i=0; i<26; i++){
        m['a'+i] = 0;
    }
    for(auto &x: s){
        m[x]=1;
    }
    char apW= ' ';
    for(int i=0; i<26; i++){
        if(m['a'+i]==0){
            apW = 'a'+i;
            cout << s+apW << endl;
            return 0;
        }
    }
    int N = s.size();
    set<char> sc;
    sc.insert(s[N-1]);
    for(int i=N-2; i>=0; i--){
        char c = *--sc.end();
        if(c<=s[i]) {
            sc.insert(s[i]);
            continue;
        }
        else{
            for(auto &x:sc){
                if(x>s[i]) {
                    s[i]=x;
                    break;
                }
            }
            for(int j=i+1; j<N; j++){
                s[j] = ' '; 
            }
            break;
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <list>
#include <map>

typedef std::pair<double,double> TPoint;

TPoint GetLeft(TPoint Left,TPoint Right)
{
	return std::make_pair((Left.first * 2 + Right.first) / 3,(Left.second * 2 + Right.second) / 3);
}

void Turn(TPoint& Vector)
{
	double X = (Vector.first - (std::sqrt)(3.) * Vector.second) / 2;
	double Y = ((std::sqrt)(3.) * Vector.first + Vector.second) / 2;
	Vector = std::make_pair(X,Y);
}

TPoint GetCenter(const TPoint& Left,const TPoint& Right)
{
	TPoint Vector = std::make_pair(GetLeft(Left,Right).first - Left.first,GetLeft(Left,Right).second - Left.second);
	Turn(Vector);
	return std::make_pair(GetLeft(Left,Right).first + Vector.first,GetLeft(Left,Right).second + Vector.second);
}

TPoint GetRight(const TPoint& Left,const TPoint& Right)
{
	return std::make_pair((Left.first + Right.first * 2) / 3,(Left.second + Right.second * 2) / 3);
}

typedef std::list<TPoint> TPoints;

void Insert(TPoints& Points,const TPoints::iterator Right)
{
	TPoints::iterator It = Right;
	It--;
	TPoint LeftEdge = *It;
	TPoint RightEdge = *Right;
	It++;
	Points.insert(It,GetLeft(LeftEdge,RightEdge));
	Points.insert(It,GetCenter(LeftEdge,RightEdge));
	Points.insert(It,GetRight(LeftEdge,RightEdge));
}

int main()
{
	int Count = 0;
	std::cin >> Count;
	
	TPoints Points;
	Points.push_back(std::make_pair(0.,0.));
	Points.push_back(std::make_pair(100.,0.));
	
	for(int i=0;i<Count;i++)
	{
		TPoints::iterator It = Points.begin();
		It++;
		while(It != Points.end())
		{
			Insert(Points,It);
			It++;
		}
	}
	
	while(!Points.empty())
	{
		std::cout << Points.front().first << " " << Points.front().second << std::endl;
		Points.pop_front();
	}
	return 0;
}

Measured memory_bytes: 1468
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    BIMissYou solver = new BIMissYou();
    solver.solve(1, in, out);
    out.close();
  }

  static class BIMissYou {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      String s = in.next();
      StringBuffer sb = new StringBuffer();
      for (int i = 0; i < s.length(); i++) {
        sb.append("x");
      }
      out.println(new String(sb));
    }

  }
}



Measured memory_bytes: 21844
#ifdef __GNUC__
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#endif

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>

#include <string>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <cassert>//assert();
#include <fstream>
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)

/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#define PII pair<int,int>
/////////
using namespace::std;

// 最大公約数
template<class T>
inline T gcd(T a, T b){return b == 0 ? a : gcd(b, a % b);}
// 最小公倍数
template<class T>
inline T lcm(T a, T b){return a * b / gcd(a, b);}
////////////////////////////////

inline void solve(){
	ULL X;
	cin >> X;
	ULL Q,R;
	Q = X/11;
	R = X%11;
	ULL ANS = 0;
	if( R > 6 ){
		ANS = 2;
	}else if( R > 0){
		ANS = 1;
	}
	ANS += Q*2;
	cout << ANS << endl;
}

int main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数をいっぱい表示する。16?

	solve();

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int S[25];
    int N = 0;
    int res = 0;
    cin>>N;
    for(int i = 0;i < N;i++)cin>>S[i];
    for(int i = 1;i < N-1;i++){
        if (S[i-1] < S[i] && S[i+1] > S[i] || S[i-1] > S[i] && S[i+1] < S[i]){
            res++;
        }
    }
    cout<<res;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll h, w;
  cin >> h>> w;
  if(w==1 || h==1){
      cout << 1 << endl;
      return 0;
  }
  
  ll ans = w * (h/2);
  if(h % 2 == 1){
    ans += ((w/2)+(w%2));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
cij = [[int(i) for i in input().split()] for j in range(10)]
aij = [[int(i) for i in input().split()] for j in range(h)]

#print(cij,aij)





#exit()
"""
for i in range(10):
	mat[i][i]=0
"""

mat = cij
"""
for i in range(M):
	u,v,l=map(int,input().split())
	mat[u][v] = l
	mat[v][u] = l
"""
for i in range(10):
	for x in range(10):
		for y in range(10):
			mat[x][y] = min(mat[x][y], mat[x][i] + mat[i][y])
#print(mat)
ans = 0

for i in range(h):
    for j in range(w):
        if aij[i][j] != -1 and aij[i][j] != 1:
            #print(aij[i][j])
            ans += mat[aij[i][j]][1]

print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include <stdio.h>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <queue> 
#include <map>
#include <set>
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
using namespace std;

int main(){

  int a,b,c,d;
  string n;
  cin >> n;
  
  a = n[0] - '0';
  b = n[1] - '0';
  c = n[2] - '0';
  d = n[3] - '0';
  
  if (a -b -c - d ==7)       printf ("%d-%d-%d-%d=7\n" ,a ,b ,c , d );
  else if (a -b - c + d ==7) printf ("%d-%d-%d+%d=7\n" ,a ,b ,c , d );
  else if (a - b +c - d ==7) printf ("%d-%d+%d-%d=7\n" ,a ,b ,c , d );
  else if (a - b + c + d ==7) printf ("%d-%d+%d+%d=7\n" ,a ,b ,c , d );
  else if ( a +b -c - d ==7) printf ("%d+%d-%d-%d=7\n" ,a ,b ,c , d );
  else if ( a +b - c + d ==7) printf ("%d+%d-%d+%d=7\n" ,a ,b ,c , d );
  else if ( a + b +c - d ==7) printf ("%d+%d+%d-%d=7\n" ,a ,b ,c , d );
  else if ( a + b + c + d ==7) printf ("%d+%d+%d+%d=7\n" ,a ,b ,c , d );

 return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        int[] list = new int[n];
        for (int i = 0; i < list.length; i++) {
			list[i] = sc.nextInt();
		}
        
        int sum = 0;
        for (int i = 0; i < list.length; i++) {
			int min = Math.min(k - list[i], list[i]);
			sum += min * 2;
		}
        
        System.out.println(sum);
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    string S, T;
    cin >> S;
    cin >> T;
    int cnt = 0;
    for (size_t i=0; i<S.size(); i++) {
        if (S[i] != T[i])
            ++cnt;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3848
#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;
// 0 -> 1
// 1 -> 1
// 2 -> 2
// 3 -> 3
int main() {
  int n;
  int dp[44] = {};
  cin >> n;
  dp[1] = dp[0] = 1;

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

Measured memory_bytes: 3084
#include <iostream>
using namespace std;
const double INF = 10000000;

int A,B,C,D,E,F;
int Count = 1;
double toriurumizu[101];
double toriurusatou[3001];
bool sugarCheck[3001];

void mizu(int water){
	if(water > F){
		return;
	}
	if(Count>99)return;
	toriurumizu[Count] =double( water + 100*A);
	Count++;
	toriurumizu[Count] =double( water + 100*B);
	Count++;
	mizu(water + 100*A);
	mizu(water + 100*B);
	
}

void satou(int sugar){
	if((F/100)*E<sugar){
		return;
	}
	if(Count>2999)return;
	
	if(sugarCheck[sugar + C]){
		
	}else{
		toriurusatou[Count] = double(sugar + C);
		sugarCheck[sugar+C] = true;
		Count++;
		satou(sugar + C);
	}
	
	if(sugarCheck[sugar + D]){
		
	}else{
		toriurusatou[Count] = double(sugar + D);
		sugarCheck[sugar+D] = true;
		Count++;
		satou(sugar + D);
	}
	
	
	
	
}

int main(){//100*A 100*B の水　　C Dの砂糖　100gあたりEの砂糖が溶ける Fg以下で作る
	//作ることのできる砂糖水は？
	cin >> A >> B >> C >> D >> E >> F;
	for(int i=0;i<101;i++){
		toriurumizu[i] = INF;
	}
	for(int i=0;i<3001;i++){
		toriurusatou[i] = INF;
		sugarCheck[i] = false;
	}
	toriurumizu[0] = 0;
	mizu(0);
	
	Count = 1;
	toriurusatou[0] = 0;
	satou(0);
	
	double waterAns=0,sugarAns=0;
	double noudo=-1;
	int I,J;
	
	for(int i=0;i<101;i++){
		for(int j=0;j<3001;j++){
			if((toriurumizu[i]/100.0)*E<(toriurusatou[j]))continue;//とけのこる
			if(toriurumizu[i]+toriurusatou[j]>F)continue;//ビーカーから出る
			if(i==0&&j==0){
				noudo = 0;
				waterAns = toriurumizu[i]+toriurusatou[j];
				sugarAns = toriurusatou[j];
				continue;
			}
			if(noudo < ((toriurusatou[j])*100.0)/(toriurusatou[j]+toriurumizu[i])){
				noudo = (toriurusatou[j]*100.0)/(toriurusatou[j]+toriurumizu[i]);
				waterAns = toriurumizu[i]+toriurusatou[j];
				sugarAns = toriurusatou[j];
				I = i;
				J = j;
			}
		}
	}
	
	if(waterAns==0 && sugarAns==0){
		cout << min(A,B)*100 << " " << 0 << endl;
		return 0;
	}
	cout << waterAns << " " << sugarAns << endl;
	//cout << I << " " << J << endl;
	
	return 0;
}


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

int main() {
    int n, k; double p = 0;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        int m = i;
        while (m < k) {
            m *= 2;
        }
        p += 1. * i / m;
    }
    printf("%.9f\n", p/n);
}

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

const int mod = 998244353;
const int MAXN = 200*1000+5;

int fen[MAXN];

int mul(int a, int b) { return 1LL * a * b % mod; }
int mpow(int a, int n) {
	if(n == 0) return 1;
	int x = mpow(a, n/2);
	x = mul(x, x);
	if(n % 2 == 1) x = mul(x, a);
	return x;
}
void add_self(int& a, int b) { a += b; if(a >= mod) a -= mod; }
void sub_self(int& a, int b) { a -= b; if(a < 0) a += mod; }

void upd(int i, int v) {
	for(; i < MAXN; i += i & -i) {
		add_self(fen[i], v);
	}
}

int get(int i) {
	int ans = 0;
	for(; i > 0; i -= i & -i) {
		add_self(ans, fen[i]);
	}
	return ans;
}

void compress(vector<pair<int, int>>& arr) {
	map<int, int> mp;
	int i = 1;
	for(auto p : arr) {
		mp[p.first] = -1;
	}
	for(auto& p : mp) {
		p.second = i++;
	}
	for(auto& p : arr) {
		p.first = mp[p.first];
	}
	i = 1;
	mp.clear();
	for(auto p : arr) {
		mp[p.second] = -1;
	}
	for(auto& p : mp) {
		p.second = i++;
	}
	for(auto& p : arr) {
		p.second = mp[p.second];
	}
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<pair<int, int>> arr(n);
	for(auto& p : arr) {
		cin >> p.first >> p.second;
	}
	
	compress(arr);
	sort(arr.begin(), arr.end());
	int ans = 0;
	
	for(int i = 0; i < n; i++) {
		add_self(ans, mpow(2, n));
		sub_self(ans, mpow(2, i));
		sub_self(ans, mpow(2, n-i-1));
		sub_self(ans, mpow(2, arr[i].second-1));
		sub_self(ans, mpow(2, n-arr[i].second));
		int bl = get(arr[i].second);
		int tl = i - bl;
		int br = arr[i].second-1-bl;
		int tr = n-1 - (bl + tl + br);
		add_self(ans, mpow(2, bl));
		add_self(ans, mpow(2, br));
		add_self(ans, mpow(2, tl));
		add_self(ans, mpow(2, tr));
		sub_self(ans, 1);
		upd(arr[i].second, 1);
	}
		
	
	cout << ans << endl;
}


Measured memory_bytes: 12032
#include<stdio.h>
int main()
{
          int a,b,c,x,y,i;
          scanf("%d %d %d",&a,&b,&c);
          for(i=0;i<3;i++)
                    {
          if(a>b)
          {
                    x=a;
                    a=b;
                    b=x;

          }
          if(b>c)
          {
                    y=b;
                    b=c;
                    c=y;
          }
                    }
          printf("%d %d %d\n",a,b,c);
          return 0;

}



Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int MOD = 1e9 + 7;

struct Combination{
  vector<int> fact; //　fact[i] = iの階乗
  Combination(int n) : fact(n+1){
    fact[0] = fact[1] = 1;
    for(int i = 2; i <= n; i++){
      fact[i] = fact[i-1] * i % MOD;
    }
  }

  int nCr(int n, int r){ // nCr = n!/r!(n-r)!
    if(n < r) return 0;
    return fact[n] * inv(fact[r]*fact[n-r]%MOD) % MOD;
  }

  int inv(int n){ // a/n ≡ a*n^(p-2) nとpは互いに素
    int r = 1, p = MOD-2;
    for(; p > 0; p >>= 1){
      if(p & 1LL) r = (r * n) % MOD;
      n = (n * n) % MOD;
    }
    return r; // r = n^p % MOD
  }

};

signed main(){

  int n; cin >> n;
  vector<vector<int>> G(n);
  for(int i = 0; i < n-1; i++){
    int a, b; cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  Combination c(n+1);
  vector<int> num(n, 0), dp(n, 1);
  auto dfs1 = [&](auto&& dfs1, int u, int p)->void{
    for(int v : G[u]){
      if(v == p) continue;
      dfs1(dfs1, v, u);
      num[u] += num[v];
      dp[u] = dp[u] * dp[v]%MOD * c.nCr(num[u], num[v]) % MOD;
    }
    num[u]++;
  };
  dfs1(dfs1, 0, -1);

  vector<int> ans(n);
  auto dfs2 = [&](auto&& dfs2, int u, int p, int res)->void{
    ans[u] = dp[u] * res%MOD * c.nCr(n-1, n-num[u]) % MOD;
    for(int v : G[u]){
      if(v == p) continue;
      res = ans[u] * c.inv(dp[v])%MOD * c.inv(c.nCr(n-1, num[v])) % MOD;
      dfs2(dfs2, v, u, res);
    }
  };
  dfs2(dfs2, 0, -1, 1);

  for(int p : ans){
    cout << p << endl;
  }

  return 0;
}


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

const int mod = 1000000007;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
int pow(int a, int b, int res = 1) {
	for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a);
	return res;
}
const int MAXN = 1010;
char mat[MAXN][MAXN];
int H, W; LL K;
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> H >> W >> K;
	if (K <= 1) return std::cout << 1 << std::endl, 0;
	int tc = 0;
	for (int i = 1; i <= H; ++i) {
		std::cin >> mat[i] + 1;
		for (int j = 1; j <= W; ++j)
			tc += mat[i][j] = mat[i][j] == '#' ? 1 : 0;
	}
	int ud = 0, lr = 0, ans = pow(tc, (K - 1) % (mod - 1));
	for (int i = 1; i <= H; ++i) lr += mat[i][1] && mat[i][W];
	for (int i = 1; i <= W; ++i) ud += mat[1][i] && mat[H][i];
	if (!ud && !lr) ;
	else if (ud && lr) ans = 1;
	else {
		int td = 0;
		if (ud) for (int i = 1; i < H; ++i)
			for (int j = 1; j <= W; ++j)
				td += mat[i][j] && mat[i + 1][j];
		else for (int i = 1; i <= H; ++i)
			for (int j = 1; j < W; ++j)
				td += mat[i][j] && mat[i][j + 1];
		lr |= ud;
		int t = pow(tc, (K - 2) % (mod - 1), td);
		int pw = pow(tc, mod - 2, lr);
		t = mul(t, 1 + mod - pow(pw, (K - 1) % (mod - 1)));
		t = mul(t, pow(1 + mod - pw, mod - 2));
		reduce(ans -= t);
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	while (cin >> n, n) {
		vector<pair<int, int> > v;
		for (int i = 0; i < n; i++) {
			int x, y; cin >> x >> y;
			v.push_back(make_pair(x, y));
		}
		cin >> n;
		int x = 10, y = 10;
		for (int i = 0; i < n; i++) {
			char c; int l; cin >> c >> l;
			for (int j = 0; j < l; j++) {
				if (c == 'E') x++;
				else if (c == 'W')x--;
				else if (c == 'N')y++;
				else if (c == 'S')y--;
				auto itr = std::find(v.begin(), v.end(), make_pair(x, y));
				if (itr != v.end())v.erase(itr);
			}
		}
		if (v.size() == 0)cout << "Yes\n";
		else cout << "No\n";
	}
}

Measured memory_bytes: 3104
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll rsum[]={1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000,10000000000,100000000000};
//int dm[]={1,-1};
ll ab(ll a){ return a>0?a:-a; }
int main(){
  ll n;
  while(scanf("%lld",&n),n){
    int st = 0;
    ll res = 0;
    if(n<0) st = 1;
    n=ab(n);
    int k=0;
    bool tf = false;
    //    bool kf=false;
    while(n>0){
      ll a = n%10;
      //      printf("%lld\n",a);
      if(!(st&1)){
	if(tf)  a++;
	///	a%=10;
		if(a>9){
	  n+=10;
	  a%=10;
	}
		tf=false;
      } else {
		if(a>9){
	  a%=10;
	  n+=10;
	}
		if(a!=0){
	  a = 10-a;
	  tf=true;
	}
      }
      res += a*rsum[k];
      k++; st++;
      n/=10;
    }
    if(tf){
      res += rsum[k];
    }
    printf("%lld\n",res);
  }
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll r,g,b;
    cin >> r >> g >> b;
    if((10*g + b) % 4 == 0){
        print("YES");
    }else{
        print("NO");
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
using namespace std;

int n=0, e=0, w=0, s=0;
string str;
char tmp[1001];

int main(){
	scanf("%s", tmp);
	str = tmp;
	for(int i=0; i<str.size(); i++){
		if(str[i] == 'N') n++;
		if(str[i] == 'E') e++;
		if(str[i] == 'W') w++;
		if(str[i] == 'S') s++;
	}
	if(((n>0 && s>0) || (n==0 && s==0)) && ((e>0 && w>0) || (e==0 && w==0))) printf("Yes\n");
	else printf("No\n");

	return 0;
}

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

int main(){
    int n;
    cin>>n;
    int d1[110],d2[110];
    bool ans=false;
    rep(i,n){
        cin>>d1[i]>>d2[i];
        if(d1[i]==d2[i]&&i>=2){
            if(d1[i-1]==d2[i-1]){
                if(d1[i-2]==d2[i-2]) ans=true;
            }
        }
    }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n;
    cin >> n;
    vll a(1 << n);
    for(ll i = 0; i < (1 << n); i++) cin >> a[i];
    sort(a.begin(), a.end());
    ll n2 = 1 << n;
    vll s;
    s.push_back(a.back());
    a[n2 - 1] = -1;
    for(ll i = 0; i < n; i++) {
        vll t = s;
        sort(t.begin(), t.end(), greater<ll>());
        ll k = n2 - 1;
        for(ll j = 0; j < t.size(); j++) {
            while(k >= 0 && (a[k] == -1 || t[j] <= a[k])) k--;
            if(k == -1) {
                cout << "No" << endl;
                return;
            }
            s.push_back(a[k]);
            a[k] = -1;
        }
    }
    cout << "Yes" << endl;
    return;
}

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

Measured memory_bytes: 5484
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,i,x,minn;
    cin>>n>>k;
    int ara[n];
    for(i=0;i<n;i++)
        cin>>ara[i];
    sort(ara,ara+n);
    minn=ara[n-1];
    for(i=0;i<=n-k;i++)
    {
        x=(ara[i+k-1]-ara[i]);
        minn=min(x,minn);
    }
    cout<<minn<<endl;
    return 0;
}


Measured memory_bytes: 3976
import math

N,K=map(int,input().split())
A=list(map(int,input().split()))

x=A.index(1)

#1の左側を埋める

B=math.ceil(x/(K-1))


#Bで何個目まで塗られたか.

if B==0:
    y=1
else:
    y=(B-1)*(K-1)+K

#右側を埋める.

C=math.ceil((N-y)/(K-1))

#print(B,y,C)

print(B+C)

Measured memory_bytes: 13812
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1000000001;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
vector<ll> v;
ll m=3234566667;
void dfs(ll now,ll num){
    if(now<=m)v.push_back(now);
    else return;
    if(num>0){
        dfs(now*10+num-1,num-1);
    }
    if(num<9)dfs(now*10+num+1,num+1);
    dfs(now*10+num,num);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int k;cin>>k;
    rep(i,1,10)dfs(i,i);
    sort(v.begin(),v.end());
    
        cout<<v[k-1]<<endl;
    return 0;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main(){
    int n,k,q;
    cin>>n>>k>>q;
    int sanka[n];
    for(int i=0;i<n;i++) sanka[i]=k-q;
    for(int i=0;i<q;i++){
        int a;
        cin>>a;
        sanka[a-1]++;
    }
    for(int i=0;i<n;i++){
        cout<<(sanka[i]<=0?"No":"Yes")<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		
        long[]a= new long[n];
        
        for(int i=0;i<n;i++) {
            a[i] = sc.nextInt();
        }
        long ans=a[0];
        
        for(int i=1;i<n;i++) {
            ans= gcd(ans,a[i]);
        }
        System.out.println(ans);
	}
		public static long gcd(long a, long b) {	//最大公約数
	        if(b%a==0) {
	            return a;
	        } else {
	            return gcd(b%a,a);
	        }
		}
}


Measured memory_bytes: 49744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if(c - a - b < 0) {
    cout << "No" << endl;
    return 0;
  }
  ll l = 4 * a * b;
  ll r = (c - a - b) * (c - a - b);
  cout << (l < r ? "Yes" : "No") << endl;
}

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

int main(void){

	int N;
	cin >> N;

	int W;
	cin >> W;
	
	vector<int> wts(N,0);
	vector<int> vals(N,0);

	for(int i=0;i<N;i++){
		cin >> wts[i];
		cin >> vals[i];
	}

	vector< vector<long int> >arr(N+1, vector<long int>(W+1,0));

	for(int i=1;i<N+1;i++){

		for(int j=1;j<W+1;j++){

			if(wts[i-1]>j){
				arr[i][j] = arr[i-1][j];
			}
			else{
				arr[i][j] = max(arr[i-1][j], arr[i-1][j-wts[i-1]] + vals[i-1]);
			}

		}

	}

	// for(int i=0;i<N+1;i++){
	// 	for(int j=0;j<W+1;j++){
	// 		cout << arr[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }

	cout << arr[N][W];

}

Measured memory_bytes: 80256
(<&>) = flip fmap

count :: (a -> Bool) -> [a] -> Int
count f (x:[]) = if f x then 1 else 0
count f (x:xs) = (if f x then 1 else 0) + (count f xs)

main = do
    [n, k] <- map read . words <$> getLine
    let modEqualList = [0] ++ (if (even k) then [quot k 2] else [])
    let combinations = modEqualList <&> (\e -> count (\m -> mod m k == e) [1..n]) <&> (flip (^) 3)
    putStrLn $ show $ sum combinations


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

int main()
{
    int n,panduan=0;
    scanf("%d",&n);

   
        if(n%4==0) panduan=1;
    else if(n%7==0) panduan=1;
    else if(n%11==0) panduan=1;
    else if((n%7)%4==0)panduan=1;
    else if((n%11)%7==0)panduan=1;
    else if((n%11)%4==0)panduan=1;
    else if(n/4>0&&(n%4)%3==0) panduan=1;
    else if(n%15==0)panduan=1;
    else if((n%15)%4==0)panduan=1;
    else if((n%15)%7==0)panduan=1;
    else if(n%18==0)panduan=1;
    else if((n%18)%4==0)panduan=1;
    else if((n%18)%7==0)panduan=1;
    else if(n>=20) panduan=1;
    else panduan=0;
        if(panduan) printf("Yes\n");
        else printf("No\n");

    return 0;
}


Measured memory_bytes: 256
/****************************** بسم الله الرحمن الرحيم ************************/
/*---------------------------------------------------------------------*/
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#define ordered_set tree<pair<int, int>, null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define compare bool operator <
#define main int main()
#define sf(n) scanf ("%d", &n)
#define pf(n) printf ("%d", n)
#define sfl(n) scanf ("%lld", &n)
#define pfl(n) printf ("%lld", n)
#define pfnewline() printf("\n")
#define pfspace() printf(" ")
#define mem(x,y) memset( (x), (y), sizeof(x) )
#define max3(a,b,c)   max(a , max(b,c) )
#define min3(a,b,c)  min(a, min(b,c) )
#define Ex 2.718281828
#define pi acos(-1.0)
#define toDecimal(n) fixed<< setprecision(n)
#define rep1(i, n) for(int i = 1; i<=n;i++)
#define rep(i, n) for(int i = 0; i<n;i++)
#define sfc(ch) scanf("%c",&ch)
#define sfs(ch) scanf("%[^\n]%*c", ch);

const ll mxn = 1e5+3;

/** ---8 moves --- **/
//int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
//int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

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

using namespace __gnu_pbds;
using namespace std;

queue<int>q;
vector<int>graph[100005];
int in[100005];
int ans[100005];

void longestPath()
{
    while(!q.empty())
    {
        int u = q.front();
        q.pop();
        for(int i = 0; i<graph[u].size();i++)
        {
            int v = graph[u][i];
            ans[v] = max(ans[v],ans[u]+1);
            in[v]--;
            if( in[v] ==0)
            {
                q.push(v);
            }
        }
    }
}



main
{
    fast;
    int n,m;
    cin >> n >> m;
    for(int i = 0; i<m;i++)
    {
        int u,v;
        cin >> u >> v;
        graph[u].push_back(v);
        in[v]++;
    }
    rep1(i,n)
    {
        if( in[i] == 0 )
        {
            q.push(i);
        }
    }
    longestPath();
    int mx = 0;
    rep1(i,n)
    {
        mx = max(mx,ans[i]);
    }
    cout << mx << endl;
}



Measured memory_bytes: 6528
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REP(i,a,b) for(ll i=(a);i<(b);++i)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}




int main() {
    ll N;
    cin >> N;
    cout << N*800-((N)/15)*200 << endl;
}

Measured memory_bytes: 256