akhauriyash/Code-Regression huggingface dataset:
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    ans = 0
    i = 0
    while i < n:
        # 右隣が同じにならないようにする
        while i+1 < n and a[i] == a[i+1]:
            i+=1
        # i は n-1 で抜けてくるので、下には引っかからない
        # 右隣の数の方が大きかったら
        if i+1 < n and a[i] < a[i+1]:
            # 右の方が小さくなるまで、次に進める
            while i+1 < n and a[i] <= a[i+1]:
                i += 1
        # 左隣の数の方が小さかったら
        elif i+1 < n and a[i] > a[i+1]:
            # 右の数が大きくなるまで、次に進める
            while i+1 < n and a[i] >= a[i+1]:
                i += 1
        # a[i]まで切り取る
        ans += 1
        # i をインクリメントして、新しい配列の先頭とする
        i += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14436
#include<stdio.h>

int main()
{
  int S, h, m, s;

  scanf("%d", &S);
  h = S/3600;
  m = S/60 - h*60;
  s = S - h*3600 - m*60;

  printf("%d:%d:%d\n", h, m, s);

  return 0;
}
   

Measured memory_bytes: 1848
N,K=map(int,input().split())
*A,=map(int,input().split())

vis=[0]*(N+1)
now=1
vis[now] = 1
his=[now]
while 1:
  new = A[now-1]
  if vis[new]==0:
    vis[new]=1
    his.append(new)
    now = new
  else:
    idx = his.index(new)
    cycle = his[idx:]
    margin = his[:idx]
    break
    
if K <= len(margin):
  print(his[K])
  exit()
  
K -= len(margin)
K %= len(cycle)

print(cycle[K])

Measured memory_bytes: 32324
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderF
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        long[] a = sc.LongArray();

        long[] memo = new long[n];
        long[] evenSum = new long[n];
        long[] oddSum = new long[n];

        evenSum[0] = a[0];
        oddSum[1] = a[1];
        for (int i = 2; i < n; i++)
        {
            if (i % 2 == 0)
            {
                evenSum[i] = evenSum[i - 2] + a[i];
            }
            else
            {
                oddSum[i] = oddSum[i - 2] + a[i];
            }
        }

        memo[0] = 0;
        memo[1] = Math.Max(a[0], a[1]);
        for (int i = 2; i < n; i++)
        {
            long tmpAnswer = 0;
            if (i % 2 == 1)
            {
                // i が 奇数の場合
                tmpAnswer = Math.Max(a[i] + memo[i - 2], evenSum[i - 1]);
            }
            else
            {
                // i が 偶数の場合

                // 自分を選んだ場合
                long answer1 = a[i] + memo[i - 2];

                // 自分の1つ前を選んだ場合
                long answer2;
                if (i >= 4)
                {
                    answer2 = a[i - 1] + memo[i - 3];
                }
                else
                {
                    answer2 = a[i - 1];
                }

                // 自分、自分の1つ前のどちらも選ばない場合
                long answer3 = evenSum[i - 2];

                tmpAnswer = Math.Max(answer1, Math.Max(answer2, answer3));
            }
            memo[i] = tmpAnswer;
        }

        long answer = memo[n - 1];

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 52488
#include <bits/stdc++.h>
using namespace std;
int main(){
	int h,w,n,x=0;
	cin>>h>>w>>n;
	int c[h][w],a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		for(int j=0;j<a[i];j++){
			if((x/w)%2==0) c[x/w][x%w]=i+1;
			else c[x/w][w-(x%w)-1]=i+1;
			x++;
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(j==w-1) cout<<c[i][j]<<endl;
			else cout<<c[i][j]<<" ";
		}
	}
	return 0;
}


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

//string型文字列をint型整数にして返す
int str_to_num(string s) {return atoi(s.c_str());}
//約数の総数を返す
int count_divisor(int n){int c[n/2] = {1}; int n_half = n/2; for(int i=2;i<n_half;i++){if(n%i==0){n /= i;c[i]+=1;i--;if(n>1) continue;else break;}  }int r = 1;for(int i=2;i<n_half;i++){r *= c[i];}return r;}
//各桁の数の和を返す
int dig_num(int n){return (n<10) ? n: dig_num(n/10) + n%10;}

int main(){
  int N; cin >> N;
  int r[N];
  string s[N];
  int p[N];
  
  REP(i,N){
    r[i] = i;
    cin >> s[i] >> p[i];
  }
  
  sort(r,r+N,[&](int a,int b){
    if(s[a]==s[b]) return p[a]>p[b];
    else return s[a]<s[b];
  });
  
  REP(i,N) cout << r[i]+1 << '\n';
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;


ll gcd(ll x, ll y){
  ll r;
  while((r = x % y) != 0) {
    x = y;
    y = r;
  }
  return y;
}

ll lcm(ll x, ll y){
  return (x * y / gcd(x, y));
}

int main() {
  ll N,M;
  cin >> N >> M;
  string S;
  string T;
  cin >>S;
  cin >> T;
  ll GCD=gcd(N,M);
  ll LCM=lcm(N,M);

  rep(i,GCD){
    if(S[i*LCM/M]!=T[i*LCM/N]){
      cout << -1;
      return 0;
    }
  }
  cout << LCM;
  return 0;
}


Measured memory_bytes: 512
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, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

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

    n = int(input())
    red, blue = [-1]*2*n, [-1]*2*n

    for _ in range(n):
        a,b = map(int, input().split())
        red[a] = b
    for _ in range(n):
        a,b = map(int, input().split())
        blue[a] = b

    kouho = []
    res = 0
    for i in range(2*n-1, -1, -1):
        if blue[i] >= 0:
            kouho.append(blue[i])
        else:
            kouho.sort()
            for j in range(len(kouho)):
                if red[i] < kouho[j]:
                    kouho.pop(j)
                    res += 1
                    break
    print(res)

if __name__ == '__main__':
    main()

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

int main(void)
{
	int n;
	int card[4][13] = {0};
	char mark[5] = "SHCD";

	cin >> n;

	for(int i = 0; i < n; i++) {
		char mark;
		int num;

		cin >> mark >> num;
		
		num --;
		switch(mark) {
		case 'S': card[0][num]++; break;
		case 'H': card[1][num]++; break;
		case 'C': card[2][num]++; break;
		case 'D': card[3][num]++; break;
		}
	}

	for(int i = 0; i < 4; i++)
		for(int j = 0; j < 13; j++)
			if(card[i][j] == 0)	cout << mark[i] << " " << j + 1 << endl;

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> F(N);
  for(int i=0;i<N;i++){
    int sum=0;
    int count=512;
    for(int j=0;j<10;j++){
      int x;
      cin >> x;
      x*=count;
      sum+=x;
      count/=2;
    }
    F.at(i)=sum;
  }
  vector<vector<int>> P(N,vector<int>(11));
  for(int i=0;i<N;i++){
    for(int j=0;j<11;j++){
      cin >> P.at(i).at(j);
    }
  }

  int ans=-1000000000;
  for(int bit=1;bit<(1<<10);bit++){
    int sum=0;
    for(int i=0;i<N;i++){
      int x=bit&F.at(i);
      int flag=0;
      for(int mask=1;mask!=0;mask=mask<<1){
        if(x&mask)  flag++;
      }
      sum+=P.at(i).at(flag);
    }
    ans=max(ans,sum);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll a,b; cin>>a>>b;
    if(a>0 || (b<0 && (b-a+1)%2==0)) cout<<"Positive"<<endl;
    else if(b<0 && (b-a+1)%2==1) cout<<"Negative"<<endl;
    else cout<<"Zero"<<endl;
}

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

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b)
	{
		if(b==c)cout<<"1"<<endl;
		else cout<<"2"<<endl;
	}
	else
	{
		if(a==c||b==c)cout<<"2"<<endl;
		else cout<<"3"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int l,r;
	scanf("%d%d",&l,&r);
	if(r-l+1>=2019){
		printf("0");
		return 0;
	}
	l%=2019;
	r%=2019;
	/*if(l==0 || r==0){
		printf("0");
		return 0;
	}*/
	if(r<l){
		printf("0");
		return 0;
	}
	int ans=1e9;
	for(int i=l;i<=r-1;i++)
		for(int j=i+1;j<=r;j++) ans=min(ans,(i*j)%2019);
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;
ll mod = pow(10,9) + 7;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}
int main() {
	string a,b,c; cin >> a >> b >> c;
	cout << 'A' << b[0] << 'C' << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import *

N, K = map(int, input().split())
A = list(map(int, input().split()))
log_size = 100
dp = [[0]*N for _ in range(log_size)]

for i in range(N):
    dp[0][i] = A[i]-1
    
for i in range(1, log_size):
    for j in range(N):
        dp[i][j] = dp[i-1][dp[i-1][j]]

c = 0
cur = 0
    
while K>0:
    if K&1:
        cur = dp[c][cur]
        
    c += 1
    K >>= 1

print(cur+1)

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

using namespace std;
const int ma=1e9;
int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	long long a,i=0,b;
	cin>>a>>b;
	for(i=0;i<=ma;i++){
		if(abs(a-i)==abs(b-i)){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<"IMPOSSIBLE";
	// your code goes here
	return 0;
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    ll s;
    cin >> s;

    if (s == 1000000000000000000LL) {
        cout << "0 0 1000000000 0 0 1000000000" << endl;
        return 0;
    }

    ll x = (ll)sqrt(s);
    x++;
    ll y = abs(s - x * x);
    ll z = 1;
    if (y > 1000000000) {
        FOR(i, 2, 100000) {
            if (y % i == 0 && y / i <= 1000000000) {
                y = y / i;
                z = i;
                break;
            }
        }
    }

    cout << "0 0 " << x << " " << y << " " << z << " " << x << endl;
}


Measured memory_bytes: 256
#-*-coding:utf-8-*-
import itertools

def main():
    #入力
    N, Y = map(int, input().split())

    #フラグ
    money_flag = 0

    #N枚を満たすi, j, kを求めて総当たり
    for i in range(N+1):
        for j in range(N-i+1):
            k = N - (i + j)
            money = 10000 * i + 5000 * j + 1000 * k
            if money == Y:
                print(i, j, k)
                #フラグで2重ループを抜ける
                money_flag += 1
                break
        if money_flag >= 1:
            break

    #当てはまるものがなかったら−1を出力
    if money_flag == 0:
        print(-1, -1, -1)

if __name__ == '__main__':
    main()
    

Measured memory_bytes: 3060
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                 as IM
import           Data.List
import qualified Data.Map                    as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  [k] <- readInt
  print $ lunlun !! (k - 1)

lunlun = [1 .. 9] ++ concatMap f lunlun

f n
  | m == 0 = [10 * n + m, 10 * n + m + 1]
  | m == 9 = [10 * n + m - 1, 10 * n + m]
  | otherwise = [10 * n + m - 1, 10 * n + m, 10 * n + m + 1]
  where
    m = n `mod` 10


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

using namespace std;

int main() {
  long long int n;
  cin >> n;
  int sum = 0;
  string s = to_string( n );
  int len = s.length();

  for ( int i = 0; i < len; i++ ) {
    sum += (s[i] - '0');
  }
  if ( n % sum == 0 )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define ff first
#define ss second
#define MAXN  1000005
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll v[305][305],n;
    cin>>n;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<n;j++){
            cin>>v[i][j];
        }
    }
    bool flag=1;
    ll ans=0;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            flag=1;
            for(ll h=0;h<n;h++){
                if(h!=i&&h!=j){
                    if(v[i][j]>(v[i][h]+v[h][j])){
                        cout<<-1;
                        return 0;
                    }
                    if(v[i][j]==(v[i][h]+v[h][j])){
                        flag=0;
                    }
                }
            }
            if(flag)
                ans+=v[i][j];
        }
    }
    cout<<ans;


    return 0;
}



Measured memory_bytes: 1152
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		String y = x.substring(0,4);
		String z = x.substring(4);
		
		int k = 2018;
		y = String.valueOf(k);
		
		String ans = y + z;
		System.out.println(ans);
	}

}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int t[n], v[n];
    int T = 0;
    REP(i,n){
        cin >> t[i];
        t[i] *= 2;
        T += t[i];
    }
    REP(i,n){
        cin >> v[i];
    }
    vector<double> maxv(T + 1, INF);
    int now = 0;
    for(int i = 0; i < n; i++){
        for(int s = now; s <= now + t[i]; s++){
            maxv[s] = min(maxv[s], (double)v[i]);
        }
        now += t[i];
    }
    maxv[0] = 0.0;
    for(int s = 0; s < T; s++){
        maxv[s + 1] = min(maxv[s + 1], maxv[s] + 0.5);
    }
    maxv[T] = 0.0;
    for(int s = T; s > 0; s--){
        maxv[s - 1] = min(maxv[s - 1], maxv[s] + 0.5);
    }
    double ans = 0;
    for(int s = 0; s <= T; s++){
        ans += maxv[s];
    }
    ans /= 2.0;
    printf("%.10lf\n", ans);
    return 0;
}

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

using namespace std;

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

    int n , k , q;
    cin >> n >> k >> q;

    vector<int> s(n + 1 , 0);
    for (int i = 0 ;i < q ;i++) {
        int x;
        cin >> x;
        s[x]++;
    }

    for (int i = 1 ;i <= n ;i++) {
        if (k - q + s[i] > 0)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
}

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

int main(){
  int d,g;
  int p[10],c[10];
  cin>>d>>g;
  for(int i=0;i<d;i++)cin>>p[i]>>c[i];
  int dp[11][1111]={};
  for(int i=0;i<d;i++){
    for(int j=0;j<1111;j++){
      if(j!=0&&dp[i][j]==0)continue;
      for(int k=0;k<=p[i];k++){
	int cost=dp[i][j]+k*100*(i+1);
	if(k==p[i])cost+=c[i];
	dp[i+1][j+k]=max(dp[i+1][j+k],cost);
      }
    }
  }
  for(int i=0;i<1111;i++){
    if(dp[d][i]>=g){
      cout<<i<<endl;
      return 0;
    }
  }
}


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
using li=list<int>;
using lil=list<ll>;
using lis=list<string>;
using fli=forward_list<int>;
using fll=forward_list<ll>;
using fls=forward_list<string>;
using si=stack<int>;
using sl=stack<ll>;
using ss=stack<string>;
using qi=queue<int>;
using ql=queue<ll>;
using qs=queue<string>;
using pqi=priority_queue<int>;
using pql=priority_queue<ll>;
using pqs=priority_queue<string>;
using dqi=deque<int>;
using dql=deque<ll>;
using dqs=deque<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

template<typename T,typename U>
void Printarray2(T f,U n){
  for(int i=0;i<n;i++) cout<<f[i]<<endl;
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n;cin>>n;
  int l,ans=0,hoge=1;
  for (int i = 0; i < n; ++i){
    cin>>l;
    hoge=max(hoge,l);
    ans+=l;
  }
  //cout<<hoge<<" "<<ans<<endl;
  flag2func(hoge<ans-hoge);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(void)
{
	scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<=1000;i++)
	{
		if(i*a%b==c)
		{
			printf("YES");
			exit(0);
		}
	}
	printf("NO");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  FOR(i,0,1900000000){
    if(i%2==0){
      n*=3;
    }
    else{
      n/=3;
    }
  }
  co(3*n*n)
}


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

int main() {
    int n;
    cin>>n;
    int arr[n];
    int m1=INT_MAX;
    
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        m1=min(m1,arr[i]);
        if(arr[i]<=m1){
            ans++;
        }
    }
    
    cout<<ans;
    
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int main(){
	int i;
	char in[15];
	char temp;
	scanf("%s", in);
	for(i=12; i>4; i--){
	        temp = in[i];
		in[i] = in[i-1];
		in[i-1] = temp;
		}
	in[4] = ' ';
	in[13]='\n';
	in[14]='\0';
	printf("%s",in);
	return 0;
	}


Measured memory_bytes: 128
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        long sum = 0;
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        scanner.close();
        for (int i = 1; i <= num; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                sum += i;
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 35804
#include<bits/stdc++.h>
using namespace std;
int read()
{
    char s;
    int k=0,base=1;
    while((s=getchar())!='-'&&s!=EOF&&!(s>='0'&&s<='9'));
    if(s==EOF)exit(0);
    if(s=='-')base=-1,s=getchar();
    while(s>='0'&&s<='9')
    {
        k=k*10+(s-'0');
        s=getchar();
    }
    return k*base;
}
void write(int x)
{
    if(x<0)
    {
        putchar('-');
        write(-x);
    }
    else
    {
        if(x/10)write(x/10);
        putchar(x%10+'0');
    }
}
const int maxn=5010;
long long n,now;
int ans;
struct node
{
	int h,p;
} a[maxn];
bool cmp(node aa,node bb)
{
	return aa.h+aa.p<bb.h+bb.p;
}
long long f[maxn];
int main()
{
	n=read();
	memset(f,0x3f3f3f3f,sizeof(f));
	for (int i=1;i<=n;i++)
	{
		a[i].h=read();a[i].p=read();
	}
	sort(a+1,a+n+1,cmp);
	f[0]=0;
	for (int i=1;i<=n;i++)
	{
		for (int j=i;j>=1;j--)
		{
			if (f[j-1]<=a[i].h)
			{
				f[j]=min(f[j],f[j-1]+(long long)a[i].p);
				ans=max(ans,j);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
import static java.lang.System.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		char c = sc.next().charAt(0);
		c++;
		out.println(c);

		out.close();
	}
}

Measured memory_bytes: 21844
import java.util.*;
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		//int[] p=new int[n];
		
		int g1=0;int g2=0;int g3=0;
		
		for(int i=1;i<=n;i++) {
			int p=sc.nextInt();
			if(p<=a)g1++;
			else if(p<=b)g2++;
			else g3++;
		}
		
		
	    System.out.println(Math.min(g1, Math.min(g2, g3)));
	}
}


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

int main()
{
	int N, K, X=0;
	cin >> N >> K;

	for (int i = 100;;i++) {
		N = N / K;
		X++;
		if (N == 0) {
			break;
		}
	}

	// 出力
	cout << X << endl;

	return 0;
}

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

#define gc( ) std::getchar( )
#define pc( i ) std::putchar( i )
#define enter '\n'
#define RE cout << "Passing [" << __FUNCTION__ << "] on " << __LINE__ << enter
#define DEBUG(...) for( auto &i: __VA_ARGS__ ) cout << i << " "; cout << enter
using std::make_pair;

template < typename T >
inline T read( )
{
 T x = 0;
 char ch = gc( );
 bool f = 0;
 while( !std::isdigit( ch ) )
 {
  f = ( ch == '-' );
  ch = gc( );
 }
 while( std::isdigit( ch ) )
 {
  x = x * 10 + ( ch - '0' );
  ch = gc( );
 }
 return f ? -x : x;
}

template < typename T >
void print( T x )
{
 if( x < 0 )
 {
  x = -x;
  pc( '-' );
 }
 if( x < 10 )
 {
  pc( x + 48 );
  return;
 }
 print < T > ( x / 10 );
 pc( x % 10 + 48 );
 return ;
}

namespace Solution
{
#define IOS std::ios::sync_with_stdio( false ), std::cin.tie( 0 ), std::cout.tie( 0 )
#define Rep( i, j, k ) for( int i = j; i >= k; --i )
#define rdi( ) read < int > ( )
#define rdl( ) read < long long > ( )
#define pti( i ) print < int > ( i ), putchar( space )
#define ptl( i ) print < long long > ( i ), putchar( space )
#define For( i, j, k ) for( int i = j; i <= k; ++i )
 using std::cin;
 using std::cout;
 using std::endl;
 using std::vector;
 using std::map;
 using std::queue;
 using std::deque;
 using std::set;
 using std::pair;
 const int N = 204001, mod = 1e9 + 7;
 
 void Fakemain( )
 {
  IOS;
  int n, x, t;
  cin >> n >> x >> t;
  cout << ( ( n - 1 ) / x + 1 ) * t;
  return;
 }

} // namespace Solution

int main( int argc, char* argv[] )
{
 Solution::Fakemain( );
 return 0;
}

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

int main(){
	int n, m, x;
	scanf("%d%d%d", &n, &m, &x);
	int cnt = 0;
	for(int i = 0; i < m; i++) {
		int a;
		scanf("%d", &a);
		if(a < x) cnt++;
	}
	printf("%d\n", (cnt < m - cnt) ? cnt : m - cnt);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <cstring>
using namespace std;
int a,b,c,q,n,man,mix,mix1,ans,ans1,l,r,l1,r1,d[100000],dp[1000][1000];
string s,s1,s2,s3;
vector<int> v[100000],v1;
// deque<int> dq;
map<int,int> mp,mp1,mp2;
bool o[100000];                                                               
stack<long long> st;
// char h;
// long double ld;
pair<long long, long long> p[1000000];
int main(){
    cin>>a>>s;
    ans=1;
    for(int i = 1; i <= a; i++){
        if(s[i]==s[i-1]){
            ans++;
        } else {
            ans1++;
            ans=1;
        }
    }
    cout<<ans1;
}

Measured memory_bytes: 4608
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int X;
    cin >> X;
    int ans;
    if (X < 600) {
        ans = 8;
    }
    else if (X < 800) {
        ans = 7;
    }
    else if (X < 1000) {
        ans = 6;
    }
    else if (X < 1200) {
        ans = 5;
    }
    else if (X < 1400) {
        ans = 4;
    }
    else if (X < 1600) {
        ans = 3;
    }
    else if (X < 1800) {
        ans = 2;
    }
    else {
        ans = 1;
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define lowbit(i) i&-i
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	ull ans=0; For(i,0,5)ans=ans<<15^rand(); return ans;
}
const int N=100005,mod=1000000007;
int a[N],f[N],fa[N],TO[N];
vector<int> pre[N],v[N];
ll fac[N],ni[N],ans=1;
bool vis[N];
inline int gf(int x){
	return fa[x]==x?x:fa[x]=gf(fa[x]);
}
void GG(int frog){
	if(!frog){
		puts("0"); exit(0);
	}
}
int getpre(int x,int id){
	For(i,0,1)if(vis[pre[x][i]]==id)return pre[x][i];
	assert(0);
}
ll ksm(ll a,int b){
	int ans=1;
	for(;b;b>>=1){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
void mer(int x,int y){
	fa[gf(x)]=gf(y);
}
int main(){
	int n=read();
	For(i,fac[0]=1,n)fac[i]=fac[i-1]*i%mod;
	ni[n]=ksm(fac[n],mod-2); Rep(i,n,1)ni[i-1]=ni[i]*i%mod;
	For(i,1,n)pre[a[fa[i]=i]=read()].pb(i);
	For(i,1,n)mer(i,a[i]);
	For(i,1,n)v[gf(i)].pb(i);
	For(i,1,n)if(fa[i]==i){
		int f=1;
		for(auto j:v[i])if(pre[j].size()!=1)f=0;
		if(f)TO[v[i].size()]++;
		else{
			for(int j=i;;j=a[j]){
				if(!vis[j])vis[j]=1;
				else{
					for(auto k:v[i])vis[k]=0;
					vis[j]=1; for(int k=a[j];k!=j;k=a[k])vis[k]=1;
					bool t=0; int sz=0;
					for(int k=j;t==0||k!=j;k=a[k]){
						t=1;
						int f=0,g=0;
						if(pre[k].size()>=2){//cout<<pre[k].size()<<endl;
							GG(pre[k].size()==2);
							for(int l=getpre(k,1);pre[l].size()==1;l=pre[l][0])f++;
							for(int l=getpre(k,0);pre[l].size();l=pre[l][0]){GG(pre[l].size()==1);g++;}
							g++;
							//cout<<g<<" "<<f<<endl;
							GG(g<=f+1);
							if(g<=f)ans=ans*2%mod; 
							//cout<<g<<" "<<f<<" "<<v[k].size()<<endl;
						}
					}
					break;
				}
			}
		}
	}
	For(i,1,n)if(TO[i]){
		int d=((i&1)&&i>1)?2:1;
		int sum=ksm(d,TO[i]);
		For(j,1,TO[i]/2)sum=(sum+fac[TO[i]]*ni[j]%mod*ni[TO[i]-j-j]%mod*ksm(d,TO[i]-j-j)%mod*ksm((ll)i*(mod+1)/2%mod,j))%mod;
		//cout<<sum<<" "<<TO[i]<<endl;
		ans=ans*sum%mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 13568
[N,M] = list(map(int,input().split()))
a = [int(input()) for i in range(M)]
DP = [-1]*(N+1)
DP[0] = 1
if 1 in a:
    DP[1] = 0
else:
    DP[1] = 1
for i in range(len(a)):
    DP[a[i]] = 0
for i in range(2,N+1):
    if DP[i] == -1:
        DP[i] = (DP[i-1] + DP[i-2])%1000000007
print(DP[N]%(1000000007))

Measured memory_bytes: 7848
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const ll LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
	long long n, c, k;
	cin >> n >> c >> k;
	long long t[n];
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	sort(t, t + n);
	long long start = t[0], end = t[0] + k, cnt = 1, ans = 1;
	for (int i = 1; i < n; i++) {
		if (t[i] >= start && t[i] <= end && cnt < c) {
			cnt++;
		} else {
			start = t[i], end = t[i] + k, ans++, cnt = 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

using namespace std;
using ll = long long;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}

int N; // 店の数
int F[111][11]; // 営業時間
int P[111][11]; // 利益

int main() {
   // 入力
   cin >> N;
   for (int i = 0; i < N; i++) {
      for (int j = 0; j < 10; j++) {
         cin >> F[i][j];
      }
   }
   for (int i = 0; i < N; i++) {
      for (int j = 0; j < 11; j++) { // 0個~10個なので1列の入力は11個ある
         cin >> P[i][j];
      }
   }

   ll ans = -1e15;
   for (int mask = 1; mask < (1<<10); mask++) {
      ll sum = 0;
      for (int i = 0; i < N; i++) {
         int cnt = 0;
         for (int j = 0; j < 10; j++) {
            if (((mask>>j)&1) && F[i][j]) cnt++;
         }
         sum += P[i][cnt];
      }
      ans = max(ans, sum);
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
main(){
  int N=0,i,j,m,n;
  char S[100005];
  scanf("%s",S);
  if(S[0]=='0'){
	for(i=1;i<strlen(S);i+=2){
		if(S[i]!='1'){
			S[i]='1';
			N++;
		}
		if(i==strlen(S)-1)break;
		n=i+1;
		if(S[i+1]!='0'){
			S[i+1]='0';
			N++;
		}
		if(i==strlen(S)-1)break;
    }
  }
  if(S[0]=='1'){
	  for(j=1;j<strlen(S);j+=2){
		if(S[j]!='0'){
			S[j]='0';
			N++;
		}
		if(j==strlen(S)-1)break;
		m=j+1;
		if(S[m]!='1'){
			S[m]='1';
			N++;
		}
		if(j==strlen(S)-1)break;
    }
  }
  printf("%d",N);
}

Measured memory_bytes: 384
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#define size 500010
#define debug(x) cerr<<#x<<"="<<x
#define gc getchar()
#define db double
#define ll long long
#define rep(i,s,n) for (register int i=s;i<=n;i++)
#define drep(i,n,s) for (register int i=n;i>=s;i--)
#define il inline
using namespace std;

il ll r()
{
	char c; ll x,f=1;
	for (c=gc;!isdigit(c);c=gc) if (c=='-') f=-1; x=c-'0';
	for (c=gc;isdigit(c);c=gc) x=(x<<1)+(x<<3)+c-'0';
	return f*x;
}

ll n,perm[size],a,b,len[size];

int main()
{
	n=r(); a=r(); b=r();
	if (a*b<n||a+b>n+1) {cout<<-1<<endl;return 0;}
	rep(i,1,a) cout<<n+i-a<<' '; n-=a,b--;
	if (!b) return 0;
	ll bl=n/b; rep(i,1,b) len[i]=bl;
	rep(i,1,n%b) len[i]++;
	rep(i,1,b)
	{
		rep(j,n-len[i]+1,n) cout<<j<<' ';
		n-=len[i];
	}  
	return 0;
}


















Measured memory_bytes: 5504
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
int top=0;
int const MAX=1000;
int stack[MAX];

bool isEmpty(){
    return top==0;
}
bool isFull(){
    return top>=MAX-1;
}

void push(int x){
    stack[top+1]=x;
    top++;
}

int pop(){
    top--;
    return stack[top+1];
}



int main()
{
    char input[100];
    int ans;
    int a,b;
    while(scanf("%s",input)!=EOF){
        switch (input[0]) {
            case '+':
                b = pop();
                a = pop();
                ans = a + b;
                push(ans);
                break;
            case '-':
                b = pop();
                a = pop();
                ans = a - b;
                push(ans);
                break;
            case '*':
                b = pop();
                a = pop();
                ans = a * b;
                push(ans);
                break;
            case '/':
                b = pop();
                a = pop();
                ans = a / b;
                push(ans);
                break;
            default:
                push(atoi(input));
        }
    }
    cout<<ans<<endl;
}


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

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

    bool c[30][30] = {false};
    int y = 10, x = 10;

    for (int i = 0; i < n; ++i) {
      int a, b;
      cin >> a >> b;
      c[b][a] = true;
    }

    cin >> m;
    for (int i = 0; i < m; ++i) {
      char a;
      int b, dx = 0, dy = 0;
      cin >> a >> b;
      if (a == 'S') dy = -1;
      if (a == 'N') dy = 1;
      if (a == 'W') dx = -1;
      if (a == 'E') dx = 1;
      for (int j = 0; j < b; ++j) {
        x += dx;
        y += dy;
        c[y][x] = false;
      }
    }

    bool f = true;
    for (int i = 0; i < 30; ++i) {
      for (int j = 0; j < 30; ++j) {
        if (c[i][j]) f = false;
      }
    }

    cout << (f ? "Yes" : "No") << endl;
  }
}

Measured memory_bytes: 3048
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	ll n, K; cin >> n >> K;
	vector<ll> h(n + 1); for (int i = 1; i <= n; i++) cin >> h[i];
	vector<vector<vector<ll>>> dp(n + 1, vector<vector<ll>>(n + 1, vector<ll>(K + 1, INF)));
	dp[0][0][0] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < i; j++) {
			for (int k = 0; k <= K; k++) {
				if (dp[i - 1][j][k] == INF) continue;
				if (k + 1 <= K) chmin(dp[i][j][k + 1], dp[i - 1][j][k]);
				chmin(dp[i][i][k], dp[i - 1][j][k] + max(h[i] - h[j], 0LL));
			}
		}
	}
	ll res = INF; for (int i = 0; i <= n; i++) for (int j = 0; j <= K; j++) chmin(res, dp[n][i][j]);
	cout << res << endl;
	return 0;
}

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

int main() {
	int N;cin>>N;
	vector<int>B(N-1);
	for(int i=0;i<N-1;i++)cin>>B[i];

	vector<int>A(N);
	A[0] = B[0];
	A[N-1] = B[N-2];
	for(int i=1;i<N-1;i++)A[i] = min(B[i], B[i-1]);
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		ans += A[i];
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let S = cin.getStr();
    let N = S.length;
    const ABC = ["A", "B", "C"];
    const MOD = 1000000007;
    let dp = new Array(N + 1).fill(0).map(() => new Array(4).fill(0));
    for (let i = N; i >= 0; --i) {
        for (let j = 3; j >= 0; --j) {
            if (i == N) {
                dp[i][j] = (j == 3 ? 1 : 0);
            } else {
                dp[i][j] = dp[i + 1][j] * (S[i] == '?' ? 3 : 1);
                if (j < 3 && (S[i] == '?' || S[i] == ABC[j])) {
                    dp[i][j] += dp[i + 1][j + 1];
                }
                dp[i][j] %= MOD;
            }
        }
    }
    console.log(dp[0][0]);
}
class Inputer{constructor(t){this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29780
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      int N = sc.nextInt();
      String[] S = new String[N];
      TreeMap<String,Integer> map = new TreeMap<>();
      int max = 0;
      for(int i=0;i<N;i++){
        S[i] = sc.next();
        if(map.containsKey(S[i])){
          map.put(S[i],map.get(S[i])+1);
        }else{
          map.put(S[i],1);
        }
        if(max < map.get(S[i])){
          max=map.get(S[i]);
        }
      }
      for(String tan:map.keySet()){
        if(map.get(tan)==max){
          System.out.println(tan);
        }
        
      }
    }
  
  private static long lcm(long m, long n) {
    return m * n / gcd(m, n);
}
  
  private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
}
}


Measured memory_bytes: 78408
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>
#include <cstdlib>
#include <string.h>
#include <cmath>
#include <cstdio>





using namespace std;

bool isPrime(int num);

int main()
{
	int count = 0;
	/*int m = 2, n = 0, num;

	cin >> num;

	int *data = new int[num + 1];
	int *result = new int[num + 1];

	data[0] = 0;
	data[1] = 0;

	do
	{
		for (i = 2 * m; i < num + 1; i += m)
		{

		}
	}
	while
	{

	}*/
	const int N = 9999999;
	int n;
	std::vector<bool> isPrime(N + 1, true);    // ?´???°????????°?????¨??¨ON???

	while (cin >> n)
	{
		count = 0;
		for (int i = 2; i <= n; ++i) {
			if (isPrime[i])
			{
				count++;

				for (int k = i + i; k <= n; k += i)
					isPrime[k] = false;      // ?´???°????????°????´???°????????°?????¨???OFF???
			}
		}

		cout << count << endl;
	}
	
	return 0;






	
}

Measured memory_bytes: 3900
n=int(input())
a=list(map(int,input().split()))
ans=10**19

for i in [-1,1]:
    b=0
    c=0
    for j in a:
        b+=j
        if b*i<=0:
            c+=abs(b-i)
            b=i
        i*=-1
    ans=min(ans,c)

print(ans)    

Measured memory_bytes: 63344
#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 all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
	int n,k;
	cin>>n>>k;
	ll ans=k;
	rep(i,n-1){
		ans*=(k-1);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import math

list = input().split(' ')
num = int(list[0])
d = int(list[1])
ans = 0

for i in range(num):
  list2 = input().split(' ')
  x = int(list2[0])
  y = int(list2[1])
  distance = math.sqrt(x**2 + y**2)
  if distance <= d:
    ans += 1

print(ans)


Measured memory_bytes: 9196
/****************************************************************************
Is this the real life? Is this just fantasy?
Caught in a landslide, no escape from reality
Open your eyes, look up to the skies and see
I'm just a poor boy, I need no sympathy
Because I'm easy come, easy go, little high, little low
Any way the wind blows doesn't really matter to me, to me!!!
--------------------------------------------------
CP is quite cool.It becomes cooler when you enjoy learning new things
******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define endl "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define pi pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(a) a.size()
#define ff first
#define ss second
#define debug(x) cout<<#x<<" = "<<x<<endl;
const int mod=1e9+7;

void solve()
{
  string s;
  cin>>s;
  int ans=0;
  rep(i,s.length())
  {
    ans+=(s[i]-'0');
    ans%=9;
  }

  if(ans==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
} 

int main()
{

  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

  ios::sync_with_stdio(false);
  cin.tie(0);

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

  return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
int main () {
	int h, w, k;
	cin >> h >> w >> k;
	int p = 1;
	int q = 0;
	string a = "";
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		int g = -1;
		for (int j = w-1; j >= 0; j--) {
			if (s[j] == '#') {
				g = j;
				break;
			}
		}
		if (g == -1) {
			q++;
			continue;
		}
		a = "";
		for (int j = 0; j < w; j++) {
			a += to_string(p) + " ";
			if (s[j] == '#' && j != g) {
				p++;
			}
		}
		a.back() = '\n';
		p++;
		for (int j = 0; j <= q; j++) {
			cout << a;
		}
		q = 0;
	}
	for (int i = 0; i < q; i++) cout << a;
}

Measured memory_bytes: 768
function Main(input){
    const arr = input.split(' ').map(Number);
    let K = arr[3];

    if(K>=arr[0]){
        K -= (arr[0]+arr[1]);
        console.log(K>0 ? arr[0]-K:arr[0])
    } else {
        console.log(K);
    }
}
 Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 30100
#include<cstdio>
#include<cstring>

int n;
int c[105];
char a[105];

signed main(){
	scanf("%d%s",&n,a);
	int tot=0;
	for(int i=0;i<n;i++){
		int ans=0;
		memset(c,0,sizeof c);
		for(int j=0;j<=i;j++){
			if(!c[a[j]-'A'])
				c[a[j]-'A']=1;
		}
		for(int j=i+1;j<n;j++){
			if(c[a[j]-'A']==1)
				c[a[j]-'A']=2,ans++;
		}
		if(ans>tot) tot=ans;
	}
	printf("%d\n",tot);
	return 0;
}


Measured memory_bytes: 256
n = int(input())
cards = {}
for i in range(n):
         card = input()
         cards[card] = 1
         
for c in ['S', 'H', 'C', 'D']:
    for n in range(1,14):
        key = c + ' ' + str(n)
        if not key in cards:
            print(key)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  string S;
  cin >> S;
  
  for(int i = 0;i < S.size() - 1;++i){
    for(int j = i + 1;j < S.size();++j){
      if(S[i] == S[j]){
        cout << "no" << endl;
        return 0;
      }
    }
  }
  
  cout << "yes" << endl;
  
}


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

class UF{
	vector<int> prsz;// parent & size
	public:
	UF(int n): prsz(n, -1){}
	int operator[](int v){return prsz[v] < 0? v: prsz[v]=operator[](prsz[v]);}//root
	bool operator()(int v, int u){//unite
		v = operator[](v); u = operator[](u);
		if(v == u) return false;
		if(size(v) < size(u)) swap(v, u);
		prsz[v] += prsz[u];
		prsz[u] = v;
		return true;
	}
	int size(int x){return -prsz[operator[](x)];}
};

int main(){
	int N, M; cin>>N>>M;
	UF uf(N);
	rep(i, M){
		int a,b; cin>>a>>b;
		uf(a, b); // unite(a,b)
	}
	int ans = 0;
	rep(i, N) ans = max(ans, uf.size(i));
	cout<< ans <<endl;
}


Measured memory_bytes: 4048