akhauriyash/Code-Regression huggingface dataset:
using System;
public class Hello{

    public static void Main(){
        int[] nml = LineToInt();
        int n = nml[0];
        int m = nml[1];
        int l = nml[2];

        int[,] A = new int[n,m];
        int[,] B = new int[m,l];
        long[,] C = new long[n,l];

        for(int i=0;i<n; i++){
            int[] arr = LineToInt();
            for(int j=0; j<m; j++){
            A[i,j]=arr[j];
            }
        }

        for(int i=0;i<m; i++){
            int[] arr = LineToInt();
            for(int j=0; j<l; j++){
            B[i,j]=arr[j];
            }
        }

        for(int i=0; i<n;i++){
          for(int j=0; j<l; j++){
            for(int k=0; k<m; k++){
              C[i,j] += A[i,k]*B[k,j];
            }
          }
        }
        
        for(int i =0;i<n; i++){
            for(int j=0; j<l; j++){
                if(j==l-1){
                    Console.WriteLine(C[i,j]);
                }else{
                    Console.Write(C[i,j]+" ");
                }
            }
        }
      }

  //#####################
    public static int[] LineToInt(){
      string line = Console.ReadLine();
      string[] arrStr = line.Split(' ');
      int[] arrInt = new int[arrStr.Length];

      for(var i=0; i<arrStr.Length;i++){
        arrInt[i] = int.Parse(arrStr[i]);
      }
      return arrInt;
  }
}



Measured memory_bytes: 18012
package main
import "fmt"
func main() {
  var n int
  var s string
  fmt.Scan(&n)
  fmt.Scan(&s)
  pre := 0
  cnt := 0
  for _, x := range s {
    if x == '(' {
      cnt++
    } else {
      cnt--
    }
    if cnt < 0 {
      pre++
      cnt = 0
    }
  }
  for i := 0; i < pre; i++ {
    fmt.Printf("%c", '(')
  }
  fmt.Printf("%s", s)
  for i := 0; i < cnt; i++ {
    fmt.Printf("%c", ')')
  }
  fmt.Printf("\n")
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main()
{

	int a, b, k;
	vector<int> ans;
	cin >> a >> b >> k;

	int max = a < b ? b : a;

	for (int i = max; i > 0; --i)
	{
		if (a % i == 0 && b % i == 0)
		{
			ans.emplace_back(i);
		}
	}

	cout << ans[k - 1] << "\n";

	return 0;
}

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  string S;
  cin >> N >> S;

  if (N % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }

  REP(i, N/2) {
    if (S[i] != S[i + N / 2]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner sc = new java.util.Scanner(System.in);

	public static void main(String[] args) {

		while (sc.hasNext()) {
			int d = sc.nextInt();
			int s = 0;
			for(int i=0;i<600/d;i++){
				s=s+d*i*d*i*d;
			}
			System.out.println(s);

		}
	}
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n+1);
    for (int i=2; i<=n; ++i) cin >> a[i];
    vi ans(n+1);
    for (int i=2; i<=n; ++i) ans[a[i]]++;
    rep1(i, n) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 4804
#include <iostream>

using namespace std;

void solve()
{
	int route[52][52];
	char cicada[52][52];
	int H, W;
	cin >> H >> W;
	for(int i = 0; i < H; ++i)
	{
		for(int j = 0; j < W; ++j)
		{
			cin >> cicada[i][j];
		}
	}
	for(int i = 0; i < H; ++i)
	{
		for(int j = 0; j < W; ++j)
		{
			route[i][j] = 999999999;
		}
	}
	route[0][0] = 0;
	for(int i = 0; i < H; ++i)
	{
		for(int j = 0; j < W; ++j)
		{
			if(route[i][j + 1] > route[i][j] + cicada[i][j + 1] - '0')
			{
				route[i][j + 1] = route[i][j] + cicada[i][j + 1] - '0';
			}
			if(route[i + 1][j] > route[i][j] + cicada[i + 1][j] - '0')
			{
				route[i + 1][j] = route[i][j] + cicada[i + 1][j] - '0';
			}
		}
	}
	cout << route[H - 1][W - 1] << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1172
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x,int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	if (A*N <= B)
		cout << A * N << endl;
	else
		cout << B << endl;

	return 0;
}


Measured memory_bytes: 256
/*
   AUTHOR :- Gaurang_Kothiya
   
   Quote:-" Great things never come from comfort zones."                                                                                                                
*/
 
#include<bits/stdc++.h>
using namespace std;
 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long  
#define ld long double
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(ll i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007
 




void solve()
{
	ll a,b,c;
	cin>>a>>b>>c;
	
	if(a==b && a!=c  || a==c && a!=b  || b==c && b!=a) cout<<"Yes";
	else cout<<"No";
	
}

signed main() 
{
	speed;
	
	int q=1;
	//cin>>q;
	
	while(q--)
		solve();
		
 	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


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

list = []
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(list[k-1])

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using ProCon.Util;

namespace ProCon
{
    class Program
    {
        static void Main(string[] args)
        {
            AC139D();
        }

        static void AC139D()
        {
            //https://atcoder.jp/contests/abc139/tasks

            var n = long.Parse(Console.ReadLine());
            long sum = 0;

            for (long i = 0; i < n; i++ )
            {
                sum += i;
            }

            Console.WriteLine(sum);
        }

    }
}


Measured memory_bytes: 11092
// #pragma GCC optimize("no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma vector temporal
// #pragma simd
// #pragma GCC diagnostic ignored "-W"

#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<sstream>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<vector>
#include<utility>
#include<functional>
#include<complex>
#include<climits>

// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define ll long long
#define ld long double
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vint vector<int>
#define SS stringstream
#define PQ priority_queue
#define MS(x,v) memset((x),(v),sizeof(x))
#define RZUNI(x) sort(x.begin(),x.end()), x.resize(unique(x.begin(),x.end())-x.begin())
#define FLH fflush(stdout)
#define CPPinput ios_base::sync_with_stdio(0); cin.tie(0)
#define FIN(fname) freopen(fname,"r",stdin)
#define FOUT(fname) freopen(fname,"w",stdout)

#define tm Ovuvuevuevue
#define y1 Enyetuenwuevue
#define left Ugbemugbem
#define ws Osas
#define dec tetteterette
#define exp expexpexpexp
#define expl explexplexpl

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl

#ifdef WEAK
#include"/home/edison/Coding/cpp/template/debug.cpp"
#define DEB(...) printf(__VA_ARGS__),fflush(stdout)
#define WHR() printf("%s: Line %d",__PRETTY_FUNCTION__,__LINE__),fflush(stdout)
#define LOG(...) printf("%s: Line %d ",__PRETTY_FUNCTION__,__LINE__),printf(__VA_ARGS__),fflush(stdout)
#define DEBUG 1
#define exit(x) cout<<"exit code "<<x<<endl, exit(0)
#else
#define PDE(...) ;
#define DEB(...) ;
#define WHR() ;
#define LOG(...) ;
#define DEBUG 0
#endif

#define lowbit(x) ((x)&(-(x)))

#if __cplusplus >= 201103L
#include<unordered_map>
#include<unordered_set>
#include<tuple>
#endif

void JIZZ(string output=""){cout<<output; exit(0);}

const ld PI=3.14159265358979323846264338327950288;
const ld eps=1e-13;
const ll mod=1e9+7;

int main(){
    CPPinput;
    int a[3]; cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout<<a[2]-a[0]<<endl;
}


Measured memory_bytes: 256
using System;

namespace ALDS1_2_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int n = int.Parse(str);

            string[] strs = Console.ReadLine().Split(' ');
            int[] A = new int[n];
            for (int i = 0; i < n; ++i)
            {
                A[i] = int.Parse(strs[i]);
            }

            bool flag = true;
            int count = 0;
            while (flag)
            {
                flag = false;
                for (int i = n - 1; i > 0; --i)
                {
                    if (A[i] < A[i - 1])
                    {
                        int temp = A[i];
                        A[i] = A[i - 1];
                        A[i - 1] = temp;
                        flag = true;
                        count += 1;
                    }
                }
            }

            Output(A);
            Console.WriteLine("{0}", count);
        }

        static private void Output(int[] A)
        {
            for (int i = 0; i < A.Length; ++i)
            {
                Console.Write("{0}", A[i]);
                if (i < A.Length - 1)
                {
                    Console.Write(" ");
                }
                else
                {
                    Console.Write("\n");
                }
            }
        }
    }
}

Measured memory_bytes: 13736
#include <iostream>
using namespace std;
int main(void){
    int n,p[10100];
    int d1[10100],d2[10100];
    
    while(true){
        cin>>n;
        if(n==0){
            break;
        }
        for(int i=0; i<n; i++){
            cin>>p[i]>>d1[i]>>d2[i];
        }
        int d_sum[10100];
        int d_max=0, p_max;
        
        for(int i=0; i<n; i++){
            d_sum[i]=d1[i]+d2[i];
            if(d_sum[i]>d_max){
                d_max=d_sum[i];
                p_max=p[i];
            }
        }
        cout<<p_max<<" "<<d_max<<endl;
    }
}



Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {
	public static void main(String[] argas){
		//????????£????????????????????°?????????????????£?¨?
		Scanner sc = new Scanner(System.in);

		//???????????°???
		int n = sc.nextInt();
		//
		int []ary = new int[n];
		//?????£?????\??????????????????
		for(int i =0; i<n; i++){
			ary[i] = sc.nextInt();
		}
		//??£?¨? ?????????
		int min = ary[0];
		int max = ary[0];
		long sum = 0;
		//
		for(int i = 0; i < n; i++){
			if(min>ary[i]){
				min = ary[i];
			}
			if(max < ary[i]){
				max = ary[i];
			}
			sum += ary[i];
		}
		//????????¨???
		System.out.println(min + " " + max + " " + sum);
	}
}

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

const int ALPHABET = 26; // アルファベットの文字数
int main() {
	string S;
	cin >> S;
	if (S.length() >= ALPHABET) {
		if (S == "zyxwvutsrqponmlkjihgfedcba") cout << -1;
		else {
			bool alphabet[ALPHABET];
			for (int i = 0;i < ALPHABET;i ++) alphabet[i] = false;
			for (int i = ALPHABET - 1;i >= 0;i --) {
				alphabet[S[i] - 'a'] = true;
				for (int j = S[i] - 'a' + 1;j < ALPHABET;j ++) {
					if (alphabet[j]) { // 自分より大きい文字列発見
						for (int k = 0;k < i;k ++) cout << S[k];
						cout << (char)(j + 'a');
						return 0;
					}
				}
			}
		}
	} else {
		bool alphabet[ALPHABET];
		for (int i = 0;i < ALPHABET;i ++) alphabet[i] = true;
		for (int i = 0;i < S.length();i ++) {
			alphabet[S[i] - 'a'] = false;
		}
		for (int i = 0;i < ALPHABET;i ++) {
			if (alphabet[i]) {
				cout << S << (char)(i + 'a');
				return 0;
			}
		}
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

26文字なら全種類のアルファベット使ってるので、次の文字列
それ以外なら使ってないうちで最初のアルファベットを後ろにくっつけて

ここで、次の文字列というのはどういうのか考えよう
後ろから見た時に、自分以降を消して自分を増加させることで前の文字列より辞書順で後になればそれが次の辞書順だね
つまり、自分より後ろに自分より大きい文字が来る最初の文字を選び、自分より大きい最小の文字に変えればおｋ

*/

Measured memory_bytes: 256
import random
import time

t1=time.time()
d=int(input())
c=input()
cl=[int(n) for n in c.split()]
sl=list()
for i in range(d):
    s=input()
    sl=sl+[int(n) for n in s.split()]
tl=list()
for i in range(d):
    tl.append(random.randint(1,26))
sat=0
for i in range(d):
    sat+=sl[i*26+tl[i]-1]

def decr(tl,cl):
    dec=0
    for i in range(26):
        last=[a for a, x in enumerate(tl) if x==i+1]
        if last==list():
            dec+=(d*(d+1)/2)*cl[i]
        else:
            for v in range(len(last)):
                if v!=len(last)-1:    
                    dec+=cl[i]*(last[v+1]-last[v]-1)*(last[v+1]-last[v])/2
                else:
                    dec+=cl[i]*(d-last[v]-1)*(d-last[v])/2
            dec+=cl[i]*(last[0])*(last[0]+1)/2
    return(int(dec))

oldscore=sat
oldans=oldscore-decr(tl,cl)
oldtl=[int(x) for x in tl]
t2=time.time()
while t2-t1<1.85:
    if round(t2)/2==0:
        d1=random.randint(1,d)
        d2=random.randint(1,d)
        q1=tl[d2-1]
        q2=tl[d1-1]
        cha=sl[(d1-1)*26+q1-1]-sl[(d1-1)*26+tl[d1-1]-1]+sl[(d2-1)*26+q2-1]-sl[(d2-1)*26+tl[d2-1]-1]
        tl[d2-1]=q1
        tl[d1-1]=q2
        newscore=oldscore+cha
        newans=newscore-decr(tl,cl)
    else:
        da=random.randint(1,d)
        q=random.randint(1,26)
        cha=sl[(da-1)*26+q-1]-sl[(da-1)*26+tl[da-1]-1]
        tl[da-1]=q
        newscore=oldscore+cha
        newans=newscore-decr(tl,cl)
    r=0
    if newans<oldans:
        if (t2-t1)/1.5>random.random():
            r=1
    if r==1:
        tl=[int(x) for x in oldtl]
    else:
        oldans=newans
        oldtl=[int(x) for x in tl]
        oldscore=newscore
    t2=time.time()
for i in range(d):
    print(tl[i])

Measured memory_bytes: 93828
#include<bits/stdc++.h>
using namespace std;
#define int long long int
vector<int> adj[200000];
int dp[300000][2];
#define mod (long)(1e9+7)

void dfs(int s,int p)
{
    int x=0;
    for(auto v:adj[s])
    {
        if(v==p)
            continue;
        dfs(v,s);
        dp[s][1]=(dp[s][1]*dp[v][0])%mod;
        dp[s][0]=(dp[v][1]*dp[s][0])%mod;
    }
    dp[s][0]=(dp[s][0]+dp[s][1])%mod;
}

signed main()
{
    int n;
    cin>>n;
    for(int i=0;i<=100000;++i)
        dp[i][0]=dp[i][1]=1;
    
    
    for(int i=0;i<n-1;++i)
    {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    
    dfs(1,0);
    cout<<dp[1][0];
}

Measured memory_bytes: 17152
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math

#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n,h = readInts()
A = [0] * n
B = [0] * n
for i in range(n):
    a,b = readInts()
    A[i] = a
    B[i] = b
A = sorted(A, reverse = True)
B = sorted(B, reverse = True)
MAX = A[0]
ans = 0
for v in B:
    # 投げれるMAXより大きい物はぶん投げろ
    if h <= 0:
        break
    if v > MAX: # 投げろ
        # いつ投げても一緒だねえ
        ans += 1
        h -= v
    else:
        break
if h > 0:
    ans += (h + MAX - 1) // MAX # 振れるやつ限界まで振ってやろう
print(ans)


Measured memory_bytes: 19044
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long A,B,C,K;
  cin >> A >> B >> C >> K;

  if(A>=K){
    cout << K << endl;
  }else if(A+B>=K){
    cout << A << endl;
  }else{
    cout << A - (K - A - B) << endl;
  }
}

Measured memory_bytes: 3632
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) long long((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;

string getStr(int key) {
    int k = 0;
    int vec[3];
    fill(vec, vec + 3, 0);
    while (key) {
        vec[k] = key % 10;
        k++;
        key /= 10;
    }
    string str = "";
    for (int i = 2; i >= 0; i--) str += vec[i] + '0';
    return str;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 0;
    for (int i = 0; i <= 999; i++) {
        string str = getStr(i);
        int crr = 0;
        for (int i = 0; i < n; i++) {
            if (crr > 2) break;
            if (s[i] == str[crr]) {
                crr++;
            }
        }
        if (crr > 2) ans++;
    }
    OUT(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define NIL -1
const int MOD = 1e9+7;
const int INF = 1 << 29;
int n,c[501],s[501],f[501];
ll ans[501];
int main(){
    cin>>n;
    int pos=0;
    rep(i,n-1)cin>>c[i]>>s[i]>>f[i];
    rep(j,n){
        pos=0;
    for(int i=j;i<n-1;i++){

        if(pos<s[i])pos=s[i];
        else if(pos%f[i]==0);
        else{
            pos+=f[i]-pos%f[i];
        }
        pos+=c[i];
    }
    cout<<pos<<endl;

    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
al = list(map(int, input().split()))

rusekiwa = [al[0]]

for i in range(1,N):
    rusekiwa.append(rusekiwa[-1] + al[i])

#print(rusekiwa)
lst = []
for n in range(0,N-1):
    x = rusekiwa[n]
    y = rusekiwa[-1] - rusekiwa[n]
    lst.append(abs(x - y))
#print(lst)
print(min(lst))

Measured memory_bytes: 28108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
#define ll long long 
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//typedef long long  MOD=1000000009;
ll MOD=998244353;
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll lcm(ll x, ll y) {ll res = (x * y) / __gcd(x, y); return res;}
ll power(ll x, ll y) {if (y < 0) return 1; ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}

void iofoj(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}



void solution()
{
    ll k,i,j,n,m,w;
    cin>>n;
    ll a[n],b[n];
    for(i=0;i<n;i++)cin>>a[i]>>b[i];
    for(i=0;i+3<=n;i++)
    {
        if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2]){
            cout<<"Yes";
            return;
        }
    }
    cout<<"No";
}

int main(){
    fio
    //iofoj();
    // ll t;
    // cin>>t;
    // while(t--)
    solution();
    return 0; 
}


Measured memory_bytes: 3648
import sys
import numpy as np
from collections import Counter

read = sys.stdin

N, K = map(int, read.readline().split())
k = 2 * K
xyc = np.array(read.read().split(), np.str).reshape(-1, 3)
x = xyc[:, 0].astype(int)
y = xyc[:, 1].astype(int)
c = xyc[:, 2]

x[c == 'B'] -= K
x %= k
y %= k

grid = np.zeros((3 * K, 3 * K), np.int64)
np.add.at(grid, (x, y), 1)
np.add.at(grid, (x + K, y + K), 1)
np.subtract.at(grid, (x + K, y), 1)
np.subtract.at(grid, (x, y + K), 1)
np.cumsum(grid, axis=0, out=grid)
np.cumsum(grid, axis=1, out=grid)

p1 = grid[:K, :K] + grid[k:, k:] + grid[K:k, K:k] + grid[k:, :K] + grid[:K, k:]
p2 = grid[K:k, :K] + grid[K:k, k:] + grid[:K, K:k] + grid[k:, K:k]
print(max(p1.max(), p2.max()))


Measured memory_bytes: 118308
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let mut counters: Vec<usize> = vec![0; 26];
    let a = read_as_string();

    for c in a.chars() {
        counters[(c as usize - 'a' as usize)] += 1;
    }

    let mut ans = 1;
    for i in 0..26 {
        for j in i + 1..26 {
            ans += counters[i] * counters[j];
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2340
#include <iostream>
#include <vector>
#include <list>
#include <queue>
using namespace std;
const int Max=10000;
vector<int>G[Max];
list<int>l;
int V,E;
int indeg[Max];
bool flag[Max];
void bfs(int u){
    queue<int>q;
    q.push(u);
    flag[u]=true;
    while(!q.empty()){
        int i=q.front();
        q.pop();
        l.push_back(i);
        for(int j=0;j<G[i].size();j++)
        {
            int v=G[i][j];
            indeg[v]--;
            if(!flag[v] && indeg[v]==0)
            {
                //l.push_back(v);
                flag[v]=true;
                q.push(v);
                
            }
        }
    }
}
void tsort(){
    for(int i=0;i<V;i++)
    {
        if(indeg[i]==0 && !flag[i])
            bfs(i);
    }
}
int main()
{
    int s,t;
    cin>>V>>E;
    for(int i=0;i<V;i++)
    {
        indeg[i]=0;
        flag[i]=false;
    }
    for(int i=0;i<E;i++)
    {
        cin>>s>>t;
        G[s].push_back(t);
        indeg[t]++;
    }
    tsort();
    for(list<int>::iterator it=l.begin();it!=l.end();it++)
        cout<<(*it)<<endl;
    return 0;
}


Measured memory_bytes: 4112
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		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.nextLong();
		}
		sc.close();
		long[] b = new long[N + 1];
		for(int i = 0; i < N; i++) {
			b[i + 1] = b[i] + A[i];
		}
		Map<Long, Long> m = new TreeMap<Long, Long>();
		for(int i = 1; i <= N; i++) {
			m.merge(b[i], 1l, (v1, v2) -> (v1 + v2));
		}
		long ans = 0;
//		for(long k : m.keySet()) {
//			System.out.printf("%d %d\n", k, m.get(k));
//		}
		for(long k : m.keySet()) {
			if(k == 0) {
				long t = m.get(k);
				ans += t * (t + 1) / 2;
			}else {
				long t = m.get(k);
				ans += t * (t - 1) / 2;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 93912
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; 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;
  }
}

// 二項係数計算
long long COM(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;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};
int main(){
  int n,m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i,0,m){
    int a,b,c;
    cin >> a >> b >> c;
    a--;b--;
    uf.unite(a,b);
  }
  cout << uf.num << endl;
  return 0;
}


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

#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}

ll mod(ll a, ll b) {return (a % b + b) % b;}

ll powerm(ll base,ll exp,ll mod) 
{ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}

using namespace std;

int main() 
{	
	fast;
	ll x; cin>>x;
	ll t = 100; ll ans = 0;
	while(t < x)
	{
		ll rem = t / 100;
		t += rem;
		ans++;
	}
	cout << ans << endl;
 	return 0;
}

Measured memory_bytes: 3604
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	var Ai = make([]int, N)
	var Bi = make([]int, N)
	var Ci = make([]int, N-1)

	for i := 0; i < N; i++ {
		fmt.Scan(&Ai[i])
	}

	for i := 0; i < N; i++ {
		fmt.Scan(&Bi[i])
	}

	for i := 0; i < N-1; i++ {
		fmt.Scan(&Ci[i])
	}

	Satisfaction := 0
	prev := 0

	for _, A := range Ai {
		Satisfaction += Bi[A-1]
		if prev != 0 && prev+1 == A {
			Satisfaction += Ci[A-2]
		}
		prev = A
	}

	fmt.Println(Satisfaction)

}


Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
	int a, b, c, d, e, f, g, h, i, p;
	scanf("%d",&a);
	int z[30];
	b = 0;
	for (i = 0; i < a; i++)scanf("%d", &z[i]);
	for (i = 0; i < a - 2; i++)
	{
		if (z[i + 1] > z[i] && z[i + 1] < z[i + 2] || z[i + 1]<z[i] && z[i + 1]>z[i + 2])b++;
	}
	printf("%d\n", b);


	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt();
			long[] result = new long[m];
			result[m - 1] = n * (long) (n - 1) / 2;
			int[] a = new int[m], b = new int[m];
			IntStream.range(0, m).forEach(i -> {
				a[i] = scanner.nextInt() - 1;
				b[i] = scanner.nextInt() - 1;
			});
			UnionFindTree uft = new UnionFindTree(n);
			IntStream.range(1, m).map(i -> m - i).forEach(i -> {
				if (uft.same(a[i], b[i])) {
					result[i - 1] = result[i];
				} else {
					result[i - 1] = result[i] - uft.count(a[i]) * uft.count(b[i]);
					uft.union(a[i], b[i]);
				}
			});
			Arrays.stream(result).forEach(System.out::println);
		}
	}

	/**
	 * Union Find Treeの実装<br/>
	 * https://atcoder.jp/contests/abc040/submissions/4708654 を参考に作成
	 */
	private static class UnionFindTree {
		int[] parent;
		int[] count;

		UnionFindTree(int size) {
			parent = IntStream.range(0, size).toArray();
			count = new int[size];
			Arrays.fill(count, 1);
		}

		/**
		 * @param x
		 * @return xのroot
		 */
		int find(int x) {
			if (parent[x] == x) {
				return x;
			} else {
				int v = find(parent[x]);
				parent[x] = v;
				return v;
			}
		}

		/**
		 * @param x
		 * @param y
		 * @return xとyがつながっているかどうか
		 */
		boolean same(int x, int y) {
			return find(x) == find(y);
		}

		/**
		 * xとyを結合する
		 * 
		 * @param x
		 * @param y
		 */
		void union(int x, int y) {
			int rootX = find(x);
			int rootY = find(y);
			if (rootX == rootY) {
				return;
			}
			parent[rootX] = rootY;
			parent[x] = rootY;
			count[rootY] += count[rootX];
		}

		/**
		 * @param x
		 * @return xと結ぶ都市の数
		 */
		public int count(int x) {
			return count[find(x)];
		}
	}
}


Measured memory_bytes: 63480
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	dp = -10^18*ones(Int,n,3)
	if n==2
		println(max(a[1],a[2]))
	else
		dp[1,1] = a[1]
		dp[1,2] = 0
		dp[1,3] = 0
		dp[2,1] = a[1]
		dp[2,2] = a[2]
		dp[2,3] = 0
		dp[3,1] = a[1]+a[3]
		dp[3,2] = a[2]
		dp[3,3] = max(a[1],a[3])
		for i in 4:n
			dp[i,1] = dp[i-2,1]+a[i]
			dp[i,2] = max(dp[i-2,2]+a[i],dp[i-3,1]+a[i])
			if i==4
				dp[i,3] = max(dp[i-2,3]+a[i],dp[1,2]+a[i],a[i])
			else
				dp[i,3] = max(dp[i-2,3]+a[i],dp[i-3,2]+a[i],dp[i-4,1]+a[i])
			end
		end
		if n%2==0
			println(max(dp[n,2],dp[n-1,1]))
		else
			println(max(dp[n-2,1],dp[n-1,2],dp[n,3]))
		end
	end
end

main()

Measured memory_bytes: 219304
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
   int N;
   int _K;
   cin >> N >> _K;
   mint K = _K;
   int A[N];
   for (int i = 0; i < N; i++)
   {
      cin >> A[i];
   }
   mint ans = 0;
   mint ans2 = 0;
   for(int i = 0; i < N; i++){
      for(int j = i+1; j < N ; j++){
         if(A[i]>A[j]) ans+=1;
         if(A[j]>A[i]) ans2+=1;
      }
   }
   ans *= K*(K+1)/2;
   ans2 *= K*(K-1)/2;
   cout << ans + ans2<< endl;
   return 0;
}


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

int main() {
  int A,B,C,X,cnt=0;
  cin >> A >> B >> C >> X;
  
  for(int i=0;i<=A;i++){
    for(int j=0;j<=B;j++){
      for(int k=0;k<=C;k++){
        if(X == 500*i + 100*j + 50*k){
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,K = inpl()
AA = inpl()
FF = inpl()

AA.sort()
FF.sort(reverse=True)


def solve(x):
    k = 0
    for i in range(N):
        A,F = AA[i],FF[i]
        k += max(0,A - (x//F))
    return k <= K

OK = 10**18
NG = -1

while OK - NG > 1:
    mid = (NG+OK)//2
    if solve(mid):
        OK = mid
    else:
        NG = mid

print(OK)


Measured memory_bytes: 110152
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	string s;
	int k;
	cin >> k >> s;
	if (k < s.size()) {
		for (int i = 0; i < k; i++) {
			cout << s[i];
		}
		cout << "..." << endl;
	}
	else {
		cout << s << endl;
	}
	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){int K,S,rt;
           cin>>K>>S;
           for(int X=0;X<=K;X++){
             for(int Y=0;Y<=K;Y++){
                int Z=S-X-Y;
               if(0<=Z&&Z<=K){
             rt++;
             }  
          }
         }
        
     cout<<rt<<endl;}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

vc<string> ans;
void dfs(int N,string S,int m){
    if(S.size()==N) {
        ans.eb(S);
        return;
    }
    rep(i,m){
        if(i==m-1) dfs(N,S+(char)('a'+i),m+1);
        else dfs(N,S+(char)('a'+i),m);
    }
}
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    string S;
    dfs(N,S,1);
    sort(all(ans));
    rep(i,SZ(ans)){
        cout << ans[i] << "\n";
    }
}

Measured memory_bytes: 7796
use proconio::input;
use proconio::marker::Chars;
use std::cmp;

fn main() {
    input!(mut a: i64,mut b: i64,mut c: i64,mut k: i64,);
    let mut ans = 0;
    let mut tmp = cmp::min(a, k);
    ans += tmp;
    a -= tmp;
    k -= tmp;
    tmp = cmp::min(b, k);
    b -= tmp;
    k -= tmp;
    tmp = cmp::min(c, k);
    ans -= tmp;
    println!("{}", ans);
}


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

#define MAX 200

bool solve(int i, int m, const int* a, const int n)
{
    if (m == 0) return true;
    if (i >= n) return false;
    return solve(i+1, m, a, n) || solve(i+1, m-a[i], a, n);
}

int main(int, char**)
{
    int n ,q;
    int a[MAX], m;

    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> m;
        if (solve(0, m, a, n)) cout << "yes" << endl;
        else cout << "no" << endl;
    }

    return 0;
}


Measured memory_bytes: 3104
#include<iostream>

using namespace std;

int main()
{
	string s,t;
	cin>>s>>t;
	int ans = t.size();
	for(int i=0; i<s.size(); i++)
	{
		int cnt = 0;
		if(i + t.size() > s.size()) break;
		for(int j=0; j<t.size(); j++)
		{
			if(s[i+j] != t[j]) cnt++;
		}
		ans = min(ans, cnt);
	}
	cout<<ans;
		
	return 0;
}


Measured memory_bytes: 3188
fun main(args: Array<String>) {
    val strings = readLine()!!
    val keyence = "keyence"
    val length = strings.length
    if (length < 7) {
        print("NO")
    } else {
        var firstCount = 0
        var secondCount = 0
        val charKeyence = keyence.toCharArray()
        run loop@{
            strings.subSequence(0, 7).forEach {
                if (it == charKeyence[firstCount]) {
                    firstCount++
                } else {
                    return@loop
                }
            }
        }
        run loop@{
            strings.subSequence(length - 7, length).reversed().forEach {
                if (it == charKeyence[7 - secondCount - 1]) {
                    secondCount++
                } else {
                    return@loop
                }
            }
        }
        if (firstCount + secondCount >= 7) {
            print("YES")
        } else {
            print("NO")
        }
    }
}

Measured memory_bytes: 33808
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  long long a,b,c;
  cin >> a >> b >> c;
  if(a%2==0 || b%2==0 || c%2==0) cout << 0 << "\n";
  else{
    long long m = max({a,b,c});
    long long mm;
    if(m==a) mm = b*c;
    else if(m==b) mm = c*a;
    else mm = a*b;
    cout << mm << "\n";
  }
  return 0;
}

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

int  main()
{
	string s; cin >>  s;
	long sum = 0;
	rep(i, s.size())
		sum += s[i] - 48;
	long n = stol(s);
	if (n % sum == 0) cout << "Yes" << endl;
	else cout << "No\n";
	return (0);
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100

static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, A[N][N];
int color[N], depth[N], first[N], c;

void dfs_visit(int u){
  int i;
  color[u] = GRAY;
  c++;
  depth[u] = c;
  for ( i = 0; i < n; i++ ){
    if ( A[u][i] == 0 ) 
        continue;
    if ( color[i] == WHITE ){
      dfs_visit(i);
    }
  }
  color[u] = BLACK;
  first[u] = ++c;
}

void DFS(){
  int i, u;
  for ( i = 0; i < n; i++ ) 
    color[i] = WHITE;

  c = 0;
  for ( u = 0; u < n; u++ ){
    if ( color[u] == WHITE )
         dfs_visit(u);
  }
  for ( i = 0; i < n; i++ ){
    printf("%d %d %d\n", i+1, depth[i], first[i]);
  }
}


main(){
  int u, k, v;
  int i, j;

  scanf("%d", &n);

  for ( i = 0; i <n; i++ ){
    for ( j = 0; j <n; j++ )
         A[i][j] = 0;
  }
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    u--;

    for ( j = 0; j < k; j++ ){
        scanf("%d", &v);
        v--;
        A[u][v] = 1;
    }
  }

  DFS();

  return 0;
}


Measured memory_bytes: 2108
n = int(input())
a = list(map(int, input().split()))

a.sort()
ai = a[n-1]

aj = 10**9


if ai % 2 == 0:
    m = ai // 2
    num = 0
    for i in range(n):
        if abs(m - a[i]) < aj:
            aj = abs(m - a[i])
            num = a[i]
    aj = num

else:
    m = ai // 2
    num = 0
    for i in range(n):
        if abs(m - a[i]) < aj:
            aj = abs(m - a[i])
            num = a[i]
    aj = num

    m = ai // 2 + 1
    for i in range(n):
        if abs(m - a[i]) < aj:
            aj = abs(m - a[i])
            num = a[i]
    aj = num


print(ai, aj)

Measured memory_bytes: 14428
n=int(input())
t=[]
for i in range(n):
  at,bt=map(int,input().split())
  t.append([bt,at])
t.sort()
temp=0
for i in range(n):
  temp=temp+t[i][1]
  if temp>t[i][0]:
    print("No")
    break
else:
  print("Yes")

Measured memory_bytes: 38180
#include<stdio.h>

int main(){
 int i,j,k;

 while(scanf("%d %d",&i,&j)!=EOF){
  i+=j;
  for(k=i,j=1;k>=10;j++,k/=10)
   ;
  printf("%d\n",j);
 }
 return 0;
}

Measured memory_bytes: 0
while True:
  h,w=map(int, input().split())
  if h==0 and w==0:
    break
  for y in range(h):
    for x in range(w):
      if y!=0 and y!=h-1 and x!=0 and x!=w-1:
        print(".",end="")
      else:
        print("#",end="")
    print()
  print()


Measured memory_bytes: 7000
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMX LONG_LONG_MAX
int main()
{
  ll n, wt, sum = 0;
  cin>>n>>wt;
  vector<ll>w(n), v(n);
  for(ll i=0;i<n;i++)
  {
    cin>>w[i]>>v[i];
    sum += v[i];
  }
  vector<ll>knap(sum + 1, INT_MAX);
  knap[0] = 0;
 
  for(ll i=0;i<n;i++)
  {
    for(ll j=sum;j>=v[i];j--)
    {
      if(j>=v[i])
      {
        knap[j] = min(knap[j - v[i]] + w[i], knap[j]); 
      }
      //cout<<knap[j]<<"\t";
    }
    //cout<<"\n";
  }
  for(ll i=sum;i>=0;i--)
  {
    if(knap[i] <= wt)
    {  cout<<i;break;
    }
  }
  return 0;
}

Measured memory_bytes: 1024
def test(a,b,u):
    ret = 0
    x,y = divmod(a,u)
    if y>0:
        x = x+1
    z = b//u
    if (u*x)>=a and (u*x)<=b:
        ret = ret + 1
        if z>x:
            ret = ret + z-x
    return ret
def Gcd(x,y):
    if( y>x ): # x>yにする
        r = x
        x = y
        y = r
    if( y==0 ):
        return x
    return Gcd(y,x%y)
def lcm(x,y):
    return (x*y)//Gcd(x,y)

a,b,c,d = map(int,input().split())

ans = (b-a+1-test(a,b,c)-test(a,b,d)+test(a,b,lcm(c,d)))
print(ans)

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

ll solve() {
    ll A;
    cin >> A;
    
    ll ans = A + A*A + A*A*A;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3612
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = li()

wa = 0
for num in A:
    wa ^= num
    #print(wa)

for num in A:
    print(wa^num, end = '')
    print(' ', end = '')

print()

Measured memory_bytes: 31432
package main

import "fmt"

func main() {
  var n int
  var tmp, ans uint
  zero := false
  over := false
  ans = 1
  fmt.Scan(&n)
  for i:=0;i<n;i++{
    fmt.Scan(&tmp)
    if tmp == 0 {
      zero = true
      break
    }
    ansTmp := ans
    ans *= tmp
    if ans > 1000000000000000000 || ans < ansTmp {
      over = true
    }
  }
  if zero == true {
    fmt.Println(0)
    return
  } else if over == true {
    fmt.Println(-1)
    return
  }
  fmt.Println(ans)
}

Measured memory_bytes: 6316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const ll INF = 1e17;
ll N, M, L, Q;
ll fuel[305][305];
ll dist[305][305];
ll s[105000], t[105000];
ll A[100000], B[100000], C[100000];

void input() {
    cin >> N >> M >> L;
    for(int i = 1; i <= M; i++) cin >> A[i] >> B[i] >> C[i];
    cin >> Q;
    for(int i = 1; i <= Q; i++) cin >> s[i] >> t[i];
}

void solve() {
    input();
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            fuel[i][j] = INF;
            dist[i][j] = INF;
        }
        fuel[i][i] = 0;
        dist[i][i] = 0;
    }
    for(int i = 1; i <= M; i++) {
        chmin(fuel[A[i]][B[i]], C[i]);
        chmin(fuel[B[i]][A[i]], C[i]);
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            for(int k = 1; k <= N; k++) {
                chmin(fuel[j][k], fuel[j][i] + fuel[i][k]);
            }
        }
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            if(i == j) continue;
            if(fuel[i][j] <= L) chmin(dist[i][j], 1LL);
        }
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            for(int k = 1; k <= N; k++) {
                chmin(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
    for(int i = 1; i <= Q; i++) {
        if(dist[t[i]][s[i]] < INF) cout << dist[t[i]][s[i]] - 1 << "\n";
        else cout << -1 << "\n";
    }
    return;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 7464