akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

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

	ll i,j,k,l,n;
	cin>>n;
	string s; map<string,ll> mp;
	for(i=1;i<=n;i++){
		cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"]<<endl;
	return 0;	
}

Measured memory_bytes: 3664
#include <cstdio>
using namespace std;
int main()
{
	int a[3][6];
	for(int i=0;i<3;i++) for(int j=0;j<6;j++)
	scanf("%d",&a[i][j]);
	for(int i=0;i<3;i++){
		if(a[i][2]>a[i][5]) {a[i][5]+=60; a[i][4]--;}
		if(a[i][1]>a[i][4]) {a[i][4]+=60; a[i][3]--;}
		printf("%d %d %d\n",a[i][3]-a[i][0],a[i][4]-a[i][1],a[i][5]-a[i][2]);
	}
}

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

public class Main {

    public static void main(String[] args) {

        // 入力データの取得
        Scanner scanner = new Scanner(System.in);
        int digitNum = scanner.nextInt();
        int checkNum = scanner.nextInt();
        Map<Integer, Integer> resultMap = new HashMap<>();
        for (int count = 0; count < checkNum; count++) {
            int checkDigitNumber = scanner.nextInt();
            int displayDigitNumber = scanner.nextInt();
            if (!resultMap.isEmpty() && resultMap.get(checkDigitNumber) != null && resultMap.get(checkDigitNumber) != displayDigitNumber) {
                System.out.println("-1");
                scanner.close();
                return;
            } else {
                resultMap.put(checkDigitNumber, displayDigitNumber);
            }
        }
        scanner.close();

        // 結果の出力
        StringBuilder displayBuilder = new StringBuilder();
        if (digitNum == 1) {
            if (resultMap.get(1) == null) {
                displayBuilder.append(0);
            } else {
                displayBuilder.append(resultMap.get(1));
            }
        } else {
            if (resultMap.get(1) != null && resultMap.get(1) == 0) {
                System.out.println("-1");
                return;
            } else {
                for (int count = 1; count <= digitNum; count++) {
                    if (resultMap.get(count) != null) {
                        displayBuilder.append(resultMap.get(count));
                    } else {
                        if (count == 1) {
                            displayBuilder.append(1);
                        } else {
                            displayBuilder.append(0);
                        }
                    }
                }
            }
        }

        System.out.println(displayBuilder.toString());

    }

}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const ll  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1000000007;

/*vll adj[MAXN];ll visit[MAXN]={};
ll dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/
// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m,k,d,w,summ;
string s,t;
vll a,b;

ll cnt[4000][4000];
// <------------- Implement Functions Here ----------> //

// <------------- Start of main() -------------------> //

void MAIN(ll _) {
	cin >> s;
	for(ll i=0;i<s.length();i+=2) {
		cout<<s[i];
	}
	newl;
}

int main() {
	fastio;randomINT;
	//freopen("out_hc.txt","w+",stdout);
	//cin>>T;
	for(ll i=1;i<=T;i++) {
		MAIN(i);
	}
	return 0;
}



Measured memory_bytes: 3708
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),m=sc.nextInt();
        int[] count = new int[n];
        for(int i =0;i<2*m;i++){
            count[sc.nextInt()-1]++;
        }
        for(int i = 0;i<n;i++){
            System.out.println(count[i]);
        }
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
using namespace std;

int main() {
    int N; cin >> N;
    vector<string> v;
    for(int i=0; i<N; ++i){
        string str; cin >> str;
        v.push_back(str);
    }
    int cnt=0, M;
    cin >> M;
    for(int i=0; i<M; ++i){
        bool flag = false;
        string str; cin >> str;
        for(int j=0; j<N; ++j){
            if(v[j]==str){
                if(cnt%2==0) cout << "Opened by " << str << endl;
                else cout << "Closed by " << str << endl; 
                flag = true;
                cnt++;
            }
            if(flag) break;
        if(j==N-1){
            cout << "Unknown " << str << endl;
        }
        }
        
               
    }
    return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N, M;
  cin >> N >> M;
  //vector<int> A(M);
  long sum = 0;
  rep(i, M)
  {
    int a;
    cin >> a;
    sum += a;
  }
  if(sum > N){
    cout << -1 << endl;
    return 0;
  }
  else{
    cout << N-sum << endl;
    return 0;
  }
}

Measured memory_bytes: 3632
import java.util.*;
import java.io.*;

public class Main {
		public static void main(String[] args) throws IOException {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
		String[] in = br.readLine().split("");
		
		int A = Integer.parseInt(in[0]);
		int B = Integer.parseInt(in[1]);
		int C = Integer.parseInt(in[2]);
		int D = Integer.parseInt(in[3]);
		
		String ans = "";
		
		//プラスなら0、マイナスなら1
		// 3個の箱があってそこに0と1を入れたい
		// 000から111までのすべてを試す時
		// 1<<3によって最大値111+1=1000を表せる
		int conN = 1 << 3;
		//0b0は、bitで表した0のことで、例えば0b10なら数字の2を表せる。
		for(int c=0b0; c<conN; c++) {
			
			int sum = A;
			String op1 = "+";
			String op2 = "+";
			String op3 = "+";
			
			//決めた組み合わせで数列を足し引きしたときに、合計が7であるかを確認する
			if(((c>>0)&1) == 1) {
			    sum -=B;
			    op1 = "-";
			}else{
			    sum +=B;
			}
			
			if(((c>>1)&1)== 1) {
			    sum -=C;
			    op2 = "-";
			}else{
			    sum +=C;
			}
			
			if(((c>>2)&1) == 1) {
			    sum -=D;
			    op3 = "-";
			}else{
			    sum +=D;
			}
			
			if(sum == 7){
			   ans = A+op1+B+op2+C+op3+D+"=7";
			   break;
			}
		}
		
		System.out.println(ans);
	}
}

    


Measured memory_bytes: 39332
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2,62);


int main(){
    string s;
    cin >> s;
    ll p = s.size();
    if(s[p-1] == 's'){
        cout << s + "es" << endl;
    }
    else{
        cout << s + "s" << endl;
    }
}


Measured memory_bytes: 3628
unittest
{
	assert( [ "3 3", "1 2", "1 3", "2 3" ].parse.expand.solve == 2 );
	assert( [ "7 7", "1 3", "2 7", "3 4", "4 5", "4 6", "5 6", "6 7" ].parse.expand.solve == 1 );
	
	assert( [ "4 4", "1 2", "1 3", "2 3", "3 4" ].parse.expand.solve == 1 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	auto abs = new long[][]( nm[ 1 ], 2 );
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
	}
	return tuple( nm[ 0 ], abs );
}

auto solve( long n, long[][] abs )
{
	return solve2( n, abs, 1L, new bool[]( n ), 0L );
}

long solve2( long n, long[][] abs, long p, bool[] ps, long pt )
{
	// 既に今の頂点を通っていたら探索を打ち切る
	if( ps[ p - 1 ] ) return 0L;
	
	// 全ての頂点を一回だけ通っていれば答えに追加
	pt++;
	if( pt == n ) return 1L;
	
	// 次の頂点に進む前に今の頂点を通ったフラグを立てる
	ps[ p - 1 ] = true;
	
	// 次の頂点を探索
	auto ans = 0L;
	foreach( i, ab; abs )
	{
		if( ab[ 0 ] == p ) ans += solve2( n, abs, ab[ 1 ], ps, pt );
		if( ab[ 1 ] == p ) ans += solve2( n, abs, ab[ 0 ], ps, pt );
	}
	
	// 前の頂点に戻る前に今の頂点を通ったフラグを下ろす
	ps[ p - 1 ] = false;
	
	return ans;
}


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

int main(){
	int n;
	while(cin >> n){
		if(n == 0) break;

		int count = 0;
		for(int i = (n + 1) / 2; i > 0; i--){
			int sum = 0;
			for(int j = i; sum < n; j--){
				sum += j;
				if(sum == n) count++;
			}
		}
		if(n == 1) count = 0;

		cout << count << endl;
	}

	return 0;
}

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

int main() {
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  while(true) {
    c -= b;
    if(c <= 0) {
      puts("Yes");
      break;
    }
    a -= d;
    if(a <= 0) {
      puts("No");
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 1620
#include <iostream>

using namespace std;

int main(){
  int a,b,k;
  cin >> a >> b >> k;
  for (int i=a;i<a+k&&i<=b;i++) {
    cout << i << endl;
  }
  int c = a+k > b-k+1?a+k:b-k+1;
  for (int i=c;i<=b;i++) {
    cout << i << endl;
  }
  return(0);
}


Measured memory_bytes: 256
(* O(1) *)
let solve a b c d e k = if e - a <= k then "Yay!" else ":("

let read_int_array n = Array.init n (fun _ -> read_int ())

let _ =
  match read_int_array 6 with
  | [|a; b; c; d; e; k|] -> solve a b c d e k |> print_endline
  | _ -> ()

Measured memory_bytes: 384
import itertools

N = int(input())
L = list(map(int, input().split()))

if N <= 2:
    print(0)
else:
    L = itertools.combinations(L, 3)
    cnt = 0
    for L1, L2, L3 in L:
        if L1 == L2 or L2 == L3 or L3 == L1:
            continue

        if L3 < L2+L1 and L2 < L1+L3 and L1 < L2+L3:
            cnt += 1
    print(cnt)

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

using namespace std;
const int MAXN = 200005;
const int MOD = 1000000007;

vector<int> g[MAXN],ans[2];
int vis[MAXN];

void dfs(int a,int f){
	vis[a] = 1;
	ans[f].push_back(a);
	for(int i:g[a]) if(!vis[i]) return dfs(i,f);
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	int m; cin >> m;
	for(int i=0;i<m;i++){
		int a,b; cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(1,0);
	dfs(1,1);
	int ka = ans[0].size();
	int kb = ans[1].size();
	cout << ka + kb - 1 << '\n';
	for(int i=ka-1;i;i--) cout << ans[0][i] << ' ';
	cout << 1 << ' ';
	for(int i=1;i<kb;i++) cout << ans[1][i] << ' ';
	return 0;
}


Measured memory_bytes: 12408
<?php

do {
    fscanf(STDIN, "%d %d", $input['height'], $input['width']);
    $inputs[] = $input;
} while ($input['height'] != 0 && $input['width'] != 0);

foreach($inputs as $input) {
    $result[] = Rectangle::printRectangle($input['height'], $input['width']);
}

echo implode(PHP_EOL.PHP_EOL, $result);

class Rectangle {

    public static function printRectangle($height, $width)
    {
        $rectangle = [];

        for ($i = 0; $i < $height; $i++) {
            $rectangle[] = str_repeat('#', $width);
        }
        return implode(PHP_EOL, $rectangle);
    }
}

Measured memory_bytes: 15444
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  vector<ll>vec(a);
  vector<ll>veco(a);
  for(ll i=0;i<a;i++){
    cin>>vec.at(i);
  }
  for(ll i=0;i<a;i++){
    cin>>veco.at(i);
  }
  ll b=0;
  for(ll i=0;i<a;i++){
    if(vec.at(i)>veco.at(i)){
      b+=vec.at(i)-veco.at(i);
    }
  }
  cout<<b<<endl;
  return 0;
}


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

using namespace std;

int main(){
  int sx ,sy ,tx ,ty , dx, dy;
  cin >> sx >> sy >> tx >> ty;
  dx = tx - sx;
  dy = ty - sy;
  //s -> t
  cout << string(dy,'U') << string(dx,'R');
  //t -> s
  cout << string(dy,'D') << string(dx,'L');
  //s -> t
  cout << 'L' << string(dy+1,'U') << string(dx+1,'R') << 'D';
  //t -> s
  cout << 'R' << string(dy+1,'D') << string(dx+1,'L') << 'U';

  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<set>
using namespace std;
/*int a[100005],b[100005];
bool com(int a,int b)
{
    return a<b;
}
int cz(int x[],int n,int key)
{
    int low=0;
    int high=n-1;
    while(low<=high)
    {
        int mid=(low+high)/2;
        int midval=x[mid];
        if(midval<key)
            low=mid+1;
        else if(midval>key)
            high=mid-1;
        else
            return mid;
    }
    return -1;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n,com);
    int p=0;
    int j=0;
    for(int i=1; i<=n; i++)
    {
        memset(b,0,sizeof(b));
        for(int k=0; k<j; k++)
        {
            b[k]=a[k];
        }
        for(int k=j; k<n-1; k++)
        {
            b[k]=a[k+1];
        }
        int f=a[j],rav;
        rav=cz(b,n-1,f);
        if(rav!=-1)
            p++;
        j++;
    }
    printf("%d\n",p);
    return 0;
}*/
int main()
{
    int n;
    scanf("%d",&n);
    set<int>st;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(st.count(x))
        {
            st.erase(x);
        }
        else
            st.insert(x);
    }
    cout<<st.size()<<endl;
    return 0;
}




Measured memory_bytes: 4864
#include<iostream>

#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)

#define endl "\n"

using namespace std;

int main()
{
    fastio;
    long long int x;
    cin >> x;
    if(x >= 30)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 3108
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
const int MaxN = 1e5 + 5;
long long a[MaxN];
int main(){
	int n;
	long long ans = 0;
	scanf("%d",&n);
	for(int i = 1; i <= n; i++)
		scanf("%lld",&a[i]);
	for(int i = 1; i <= n; i++){
		ans += a[i]/2;
		if(a[i] % 2){
			if(a[i+1] != 0) {
				ans++;
				a[i+1]--;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X,A,B;
        X=sc.nextInt();
        A=sc.nextInt();
        B=sc.nextInt();
        if(B-A<=0){
            System.out.println("delicious");
        }else if(B-A<=X){
            System.out.println("safe");
        }else{
            System.out.println("dangerous");
        }
    }
}

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

using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define mp make_pair
#define ld long double
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 1e6 + 100;
int T;

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << abs((h1 * 60 + m1) - (h2 * 60 + m2)) - k;
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>

#define rep(i,n) for(int i=0; i<(n); ++i)
#define ll long long

int main(){
    std::string s,t; std::cin >> s >> t;
    int ans=1e3;
    rep(i,s.size()-t.size()+1){
        int cost=0;
        rep(j,t.size()) if(s[i+j] != t[j]) ++cost;
        ans=std::min(ans,cost);
    }
    std::cout << ans << std::endl;
    return 0;
}


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

using namespace std;

int n,k,a[200005],mi=INT_MAX;

void nhap()
{
    scanf("%d %d",&k,&n);
    for (int i=1;i<=n;++i)
        scanf("%d",&a[i]);
    a[n+1]=a[1];
}

void process()
{
    mi=a[n]-a[1];
    for (int i=1;i<=n;++i)
        mi=min(mi,a[i]+k-a[i+1]);
    cout<<mi;
}

int main()
{
    nhap();
    process();
    return 0;
}


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

int main(){
    long long X=0,Y=0;
    int i=0;
    cin >> X >> Y;
    while(true){
        if(X>Y)break;
        i++;
        X *= 2;
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
import math
import sys
n = int(input())
li=[input()]
for i in range(n-1):
    li.append(input())
li.sort()
cnt = 0
tmp = 1
li.append('')
for i in range(n):
    if (li[i] == li[i + 1]):
        tmp += 1
    else:
        if(cnt<tmp):
            cnt=tmp
        tmp = 1
tmp=1
for i in range(n):
    if (li[i] == li[i + 1]):
        tmp += 1
    else:
        if (cnt == tmp):
                print(li[i])
        tmp = 1
        

Measured memory_bytes: 18640
#include <stdio.h>

int main(){
  int a, b, c, max;
  scanf("%d%d%d", &a, &b, &c);
  max = a;
  if(max < b) max = b;
  if(max < c) max = c;
  
  printf("%d\n", max * 10 + a + b + c - max);
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int read(){
	int x=0,w=1;
	char ch=0;
	while (ch<'0' || ch>'9'){
		  if (ch=='-') w=-1;
		  ch=getchar();
	}
	while (ch<='9' && ch>='0'){
		  x=(x<<1)+(x<<3)+ch-'0';
		  ch=getchar();
	}
	return x*w;
}
int a[200010]; 
int cmp(int x,int y){
	return x>y;	
}
int main(){
	int n=read(),k=read();
	for (int i=1;i<=n;++i)
		a[read()]++;
	sort(a+1,a+n+1,cmp);
	int ans=n;
	for (int i=1;i<=k;++i)
		ans-=a[i];
	printf("%d\n",ans); 
	return 0;
}


Measured memory_bytes: 896
from collections import deque
import sys

def BFS(task, ct):
  D = [(1,0), (0,1), (-1,0), (0,-1)]
  semi_visited = set()
  task_n = deque([])
  for s in task:
    semi_visited.add(s)
  while task:
    s = task.popleft()
    #print(s, ct, 1, task)
    if s == (hg, wg):
      print(ct)
      sys.exit()
    x = s[0]
    y = s[1]
    for d in D:
      s_n = (x+d[0], y+d[1])
      #print(s_n, s_n not in semi_visited)
      if 0 <= s_n[0] <= H-1 and 0 <= s_n[1] <= W-1 and (s_n not in semi_visited) and S[s_n[0]][s_n[1]] == ".":
        task.append(s_n)
        semi_visited.add(s_n) 
        visited.add(s_n)
  #print(semi_visited)   
  for s in semi_visited:
    warp(s, task_n)
  return (ct+1, task_n)

def warp(p, task_n):
  #print(p)
  x = p[0]
  y = p[1]
  for dh in range(-2,3):
    for dw in range(-2,3):
      s_n = (x+dh, y+dw)
      if 0 <= s_n[0] <= H-1 and 0 <= s_n[1] <= W-1:
        #print(s_n, visited)
        if S[s_n[0]][s_n[1]] == "." and s_n not in visited:
          task_n.append(s_n)
          visited.add(s_n)
  return task_n

H, W = map(int, input().split())
hs, ws = map(int, input().split())
hs -= 1
ws -= 1
hg, wg = map(int, input().split())
hg -= 1
wg -= 1

S = [input() for _ in range(H)]

task = deque([(hs, ws)])
visited = {(hs, ws)}
semi_visited = {(hs, ws)}
ct = 0

while task:
  #print(ct)
  ct, task = BFS(task, ct)
  #print(task, ct)
  
print(-1)



Measured memory_bytes: 158892
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    set<string> st;
    char c = '0';
    rep(i,0,N){
        string str;
        cin >> str;
        if(c == '0'){}
        else if(st.count(str) || str[0] != c){
            cout << "No" << endl;
            return 0;
        }
        st.insert(str);
        c = str[str.length()-1];
    }
    cout << "Yes" << endl;
}

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

using namespace std;

#define llong long long 
#define ii pair<int, int>
#define xx first
#define yy second
#define rep(i,n) for (int i = -1; ++i < n; )
#define sz(v) ((int)v.size())

deque<int> qu;

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  bool o = false;
  while (n--) {
    int num; cin >> num;
    if (o) qu.push_back(num);
    else qu.push_front(num);
    o = !o;
  }

  while (sz(qu)) {
    if (!o) {
      cout << qu.back() << ' ';
      qu.pop_back();
    } else {
      cout << qu.front() << ' ';
      qu.pop_front();
    }

  }

  return 0;
}


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	vector<int> tower;
	vector<bool> good;
	good.resize(n, true);

	rep(i, n){
		int h;
		cin >> h;
		tower.push_back(h);
	}

	rep(i, m){
		int a, b;
		cin >> a >> b;

		if(tower[a - 1] < tower[b - 1]){
			good[a - 1] = false;
		}
		else if(tower[b - 1] < tower[a - 1]){
			good[b - 1] = false;
		}
		else{
			good[a - 1] = false;
			good[b - 1] = false;
		}
	}

	int ans = 0;
	rep(i, n){
		if(good[i]) ans++;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3936
#include <stdio.h>

int main(void)
{
	int total;
	int book;
	int i;
	
	while (1){
		scanf("%d", &total);
		if (total == 0){
			break;
		}
		
		for (i = 0; i < 9; i++){
			scanf("%d", &book);
			total -= book;
		}
		printf("%d\n", total);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int a[1234], n;

int main() {
  scanf("%d", &n);
  for(int i=0;i<2*n;i++) scanf("%d", a+i);
  sort(a, a + 2*n);
  int mx = 0;
  for(int i=0;i<2*n;i+=2) {
    mx += min(a[i], a[i + 1]);
  }
  printf("%d\n", mx);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
main()
{
  int N,i;
  int A[100];
  double sum;
  for(i=0;i<100;i++)
  {
    A[i]=0;
  }
  scanf("%d",&N);
  for(i=0;i<N-1;i++)
  {
 	scanf("%d ",&A[i]);
  }
  scanf("%d",&A[i]);
  for(i=sum=0;i<N;i++)
  {
    sum+=1.0/(double)A[i];
  }
  printf("%lf",1.0/sum);
  return 0;
}
  

Measured memory_bytes: 128
using System;

class MyClass
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        Int64[] a = new Int64[n];
        Int64 max = -1000000;
        Int64 min = 1000000;
        Int64 sum = 0;
        string[] str = Console.ReadLine().Split(' ');
        for (int i = 0; i < n; i++)
        {
            a[i] = Int64.Parse(str[i]);
            max = (a[i] > max) ? a[i] : max;
            min = (a[i] < min) ? a[i] : min;
            sum += a[i];
        }
        Console.WriteLine("{0} {1} {2}", min, max, sum);
    }
}


Measured memory_bytes: 6384
s = input()

p = list(s)

even = []
odd = []

for i in range(len(p)):
    if (i + 1) % 2 == 1:
        odd.append(p[i])
    else:
        even.append(p[i])

for i in range(len(odd)):
    print(odd[i],end='')

print('')

Measured memory_bytes: 10380
#include<iostream>
#define INF 1<<30
using std::cin;
using std::cout;
using std::endl;
typedef struct { int vertex, cost; } pair;
pair pqueue[500000], graph[10000][10001];
int mincost[10000], size;
void fswap(pair *x, pair *y) {
  pair tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
void maxheap(int x) {
  int left = 2 * x, right = 2 * x + 1, minimum = x;
  if (left <= size && pqueue[left].cost<pqueue[x].cost) minimum = left;
  if (right <= size && pqueue[right].cost<pqueue[minimum].cost) minimum = right;
  if (minimum != x) {
    fswap(&pqueue[x], &pqueue[minimum]);
    maxheap(minimum);
  }
}
int extract() {
  while (1) {
    pair x = pqueue[1];
    pqueue[1] = pqueue[size--];
    maxheap(1);
    if (mincost[x.vertex] == INF) {
      mincost[x.vertex] = x.cost;
      return x.vertex;
    }
    if (size <= 0) return INF;
  }
}
void insert(pair x) {
  pqueue[++size] = x;
  int cur = size;
  while (cur != 1 && pqueue[cur].cost<pqueue[cur / 2].cost) {
    fswap(&pqueue[cur], &pqueue[cur / 2]);
    cur /= 2;
  }
}
int main() {
  int n; cin >> n;
  for (int i = 0; i < n; ++i) {
    int u, k; cin >> u >> k;
    for (int j = 0; j < k; ++j) cin >> graph[u][j].vertex >> graph[u][j].cost;
    graph[u][k].cost = INF;
  }
  for (int i = 0; i < n; ++i) mincost[i] = INF;
  insert({ 0,0 });
  while (1) {
    int x = extract();
    if (x == INF) break;
    for (int i = 0; graph[x][i].cost != INF; ++i)
      if(mincost[graph[x][i].vertex]==INF) insert({ graph[x][i].vertex,mincost[x] + graph[x][i].cost });
  }
  for (int i = 0; i < n; ++i) cout << i << " " << mincost[i] << endl;
  return 0;
}



Measured memory_bytes: 45500
import sys

n, u, v, *ab = map(int, sys.stdin.read().split())
ab = list(zip(*[iter(ab)] * 2))
graph = [[] for _ in range(n+1)]
for a, b in ab:
    graph[a].append(b)
    graph[b].append(a)


def main():
    dist_u = [None] * (n + 1)
    dist_u[u] = 0
    stack = [u]

    while stack:
        x = stack.pop()
        for y in graph[x]:
            if dist_u[y] is None:
                dist_u[y] = dist_u[x] + 1
                stack.append(y)

    dist_v = [None] * (n + 1)
    dist_v[v] = 0
    stack = [v]
    contain_v = [False] * (n + 1)
    contain_v[v] = True
    while stack:
        x = stack.pop()
        for y in graph[x]:
            if dist_v[y] is None:
                dist_v[y] = dist_v[x] + 1
                stack.append(y)

    d = 1
    for i in range(1, n+1):
        if dist_v[i] >= dist_u[i]:
            d = max(d, dist_v[i])
    ans = d - 1
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 37052
#include <algorithm>
#include <array>
#include <assert.h>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvd;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

ll get(ll x, ll y) {
    for (int i = 10; i >= 0; --i) {
        ll t = 1LL << i;
        if ((x & t) != (y & t)) return (i + 1);
    }
    assert(false);
}

int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll n;
    cin >> n;

    for (ll i = 0; i < n; ++i) {
        for (ll j = i + 1; j < n; ++j) {
            cout << get(i, j) << (j + 1 < n ? " " : "");
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxx = 2e5 + 7;
int n;
map <int, int> pos;
map <int, bool> vis;
int seq[maxx];
LL k;

int main() {
	scanf("%d %lld", &n , &k);
	for(int i = 1; i <= n; i++) scanf("%d", &pos[i]);
	int nxt = 1;
	int t = -1;
	seq[++t] = nxt;
	int i = 1;
	while(!vis[i]) {
		vis[nxt] = 1; //先打标记
		nxt = pos[i]; //更新nxt
		seq[++t] = nxt;
		i = nxt; //替换
	}
	//seq[t]是第一次重复的数字
	//定位第一次出现时的位置fir
	int x = 0;
	for(int j = 0; j < t; j++) {
		if(seq[j] == seq[t]) {
			x = j;
			break;
		}
	}
	//cout << x << endl;
	if(k <= x) printf("%d\n", seq[k]);
	else { 
		k -= (LL)x;
		LL id = k % ((LL)t - (LL)x);
		printf("%d\n", seq[x + id]);
	}
	return 0;
}

Measured memory_bytes: 23152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			execute(scanner);
		}
	}

	private static void execute(Scanner scanner) {
		int r = (int) Math.sqrt(scanner.nextInt());
		System.out.println(r * r);
	}
}


Measured memory_bytes: 23764
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, K = map(int, rl().split())
    p = list(map(int, rl().split()))
    
    p.sort()
    ans = sum(p[:K])
    print(ans)


if __name__ == '__main__':
    solve()


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

vector<int> frend[110000];
vector<int> broke[110000];

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

	rep(i,m) {
		int a, b;
		cin >> a >> b;
		frend[a].push_back(b);
		frend[b].push_back(a);
	}

	rep(i, k) {
		int c, d;
		cin >> c >> d;
		broke[c].push_back(d);
		broke[d].push_back(c);
	}

	vector<int>check(n + 1);
	vector<int>menber(n + 1);
	int count=0;

	for (int i = 1; i <= n;i++) {
		if (check[i]==1) {
			continue;
		}
		count++;
		menber[i]=count;
		queue<int> que;

		for (int j:frend[i]) {
			que.push(j);
		}

		while (!que.empty()) {
			int x = que.front();
			que.pop();
			if (check[x] == 1) {
				continue;
			}
			check[x] = 1;
			menber[x] = count;
			for (int j : frend[x]) {
				que.push(j);
			}
		}
	}
	vector<int> frendcount(n+1);
	for (int i = 1; i <= n; i++) {
		frendcount[menber[i]]++;
	}
	vector<int> frends(n + 1);
	for (int i = 1; i <= n; i++) {
		frends[i]= frendcount[menber[i]];
	}

	for (int i = 1; i <= n; i++) {
		int a = frends[i] - frend[i].size() - 1;
		for (int j : broke[i]) {
			if (menber[i] == menber[j]) {
				a--;
			}
		}
		cout << a << endl;
	}

	return 0;
}


Measured memory_bytes: 16148
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, w;
using P = pair<lli, lli>;
P g[101];
lli memo[101][100001];

lli dfs(lli i, lli c) {
  if (memo[i][c] >= 0) return memo[i][c];
  lli ww = g[i-1].first, v = g[i-1].second;
  lli res = max(dfs(i, c-1), dfs(i-1, c));
  if (c-ww >= 0) res = max(res, v + dfs(i-1, c-ww));
  return memo[i][c] = res;
}

int main() {
  cin >> n >> w;
  for (lli i=0; i<n; ++i) cin >> g[i].first >> g[i].second;
  for (lli i=1; i<=n; ++i) fill(&memo[i][1], &memo[i][w+1], -1);
  cout << dfs(n, w) << '\n';
  return 0;
}



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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,q,ans=0;
	cin>>n;
	vector<int>s(n);
	for(int i=0;i<n;++i)cin>>s.at(i);
	cin>>q;
	for(int i=0,k;i<q;++i){
		cin>>k;
		if(binary_search(s.begin(),s.end(),k))++ans;
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3220
#include <stdio.h>
int main()
{
  int X,Y,Z;
  int i=0;
  int j=0;
  scanf ("%d %d %d", &X, &Y, &Z);
  i=X;
  X=Y;
  Y=i;
  j=X;
  X=Z;
  Z=j;
  printf("%d %d %d", X, Y, Z);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void){
int a,b;

while(1){
scanf("%d %d",&a,&b);
if(a == b && a==0 )break;

if(a <= b){
  printf("%d %d\n",a,b);
} else {
  printf("%d %d\n",b,a);
}
}
return 0;
}

Measured memory_bytes: 600
open System

let a = stdin.ReadLine() |> int
let b = stdin.ReadLine() |> int
let c = stdin.ReadLine() |> int
let x = stdin.ReadLine() |> int
let mutable m = 0
for i in [0..a] do
    for j in [0..b] do
        for k in [0..c] do
            if 500 * i + 100 * j + 50 * k = x then
                m <- m + 1

printfn "%d" m

Measured memory_bytes: 34288
#include <bits/stdc++.h>
using namespace std;
vector <long long> primeNumbers;
vector <long long> primeCounts;
long long ans = 0;
bool isPrime(long long n){
    //cout << n << endl;
    if(n==0)return false;
    if(n==1)return false;
    if(n==2)return true;
    double sq = sqrt(n);
    for(long long i = 2; i <= sq; i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
void getPrimeNumbers(long long n){
    //cout << "getPrimeNumbers" << endl;
    //cout << n << endl;
    if(isPrime(n)){
        primeNumbers.push_back(n);
        return;
    }
    double sq = sqrt(n);
    if(n==1){
        return;
    }
    for(long long i = 2; i<=sq; i++ ){
        if(n%i==0){
            //cout << n << endl;
            if(isPrime(i))primeNumbers.push_back(i);
            getPrimeNumbers(n/i);
            break;
        }
    }
}

int main(){
    long long n;
    cin >> n;
    //cout<<"startCalcPrime"<<endl;
    getPrimeNumbers(n);
    //cout<<"endCalcPrime"<<endl;
    #if 0
    for(long long i = 0; i< primeNumbers.size(); i++){
        cout << primeNumbers[i] << " ";
    }
    cout << endl;
    #endif
    vector <long long>factrizedN;
    while(n>1){
        for(long long i = 0; i < primeNumbers.size(); i++){
            //cout << i << endl;
            if(n%primeNumbers[i]==0){
                n/=primeNumbers[i];
                factrizedN.push_back(primeNumbers[i]);
                break;
            }
        }
    }
    for(long long i = 0; i<factrizedN.size(); i++){
        if((i!=0)&&(i!=factrizedN.size()-1)){
            if(factrizedN[i-1]==factrizedN[i]){
                //cout<<"A"<<endl;
                primeCounts.back()++;
            }else{
                //cout<<"B"<<endl;
                primeCounts.push_back(1);
            }
        }else{
            if(i!=0){
                if(factrizedN[i-1]==factrizedN[i]){
                    //cout<<"C"<<endl;
                    primeCounts.back()++;
                }else{
                    //cout<<"D"<<endl;
                    primeCounts.push_back(1);
                }
            }else{
                //cout<<"E"<<endl;
                primeCounts.push_back(1);
            }
        }

    }
    #if 0
    for(long long i = 0; i < primeCounts.size(); i++){
        cout << primeCounts[i] << " ";
    }
    cout << endl;
    #endif
    long long exp = 0;
    while(true){
        exp++;
        long long oldAns = ans;
        for(long long i = 0; i < primeCounts.size(); i++){
            if(primeCounts[i]>=exp){
                primeCounts[i]-=exp;
                ans++;
            }
        }
        if(oldAns==ans){
            break;
        }
    }
    cout << ans << endl;
    #if 0
    for(long long i = 0; i < factrizedN.size(); i++){
        cout << factrizedN[i] << " ";
    }
    cout << endl;
    for(long long i = 0; i < primeCounts.size(); i++){
        cout << primeCounts[i] << " ";
    }
    cout << endl;
    #endif
    return 0;
}

Measured memory_bytes: 3620
D=[1<<99]*K=gets.to_i
q=[D[1]=1]
while n=q.shift;[[n*10%K,0,:unshift],[(n+1)%K,1,:<<]].each{|e,d,m|(D[e]>x=D[n]+d)&&(D[e]=x;q.send(m,e))};end
p D[0]

Measured memory_bytes: 4936
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int main(void) {
    int K,i,A,B,C;//red gree bule
    scanf("%d %d %d" ,&A,&B,&C);
    scanf("%d" ,&K);
    for (i=0; i<K; i++) {
        if(B>=C)C*=2;
        else if(C<=A)C*=2;
        else if(B<=A)B*=2;
        if (B>A && C>B){
            printf("Yes");
            return 0;
        }
    }
    printf("No");
    return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお


int digit(ll a){
    int count = 0;
    while(a!=0){
        a /= 10;
        count += 1;
    }
    return count;
}

int main() {
    string s; cin >> s;
    int num = stoi(s);
    if(s.size()==6){
        cout << 90909 << endl;
    }else if(s.size()==5){
        cout << num-10000+1+900+9 << endl;
    }else if(s.size()==4){
        cout << 909 << endl;
    }else if(s.size()==3){
        cout << num-100+1+9 << endl;
    }else if(s.size()==2){
        cout << 9 << endl;
    }else if(s.size()==1){
        cout << num << endl;
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Input.numL;
        var list = new List<long>();
        for (var i = 0; i < 15; i++)
            for (var j = 1; j < 150; j++)
                list.Add((j + 1) * (long)Pow(10, i) - 1);
        list = list.Distinct().OrderBy(v => v).ToList();
        for (var i = 0; i < list.Count; i++)
        {
            var cc = true;
            for (var j = i + 1; j < list.Count; j++)
                if (cc)
                    cc = calc(list[i]) <= calc(list[j]);
                else break;
            if (cc)
            {
                WriteLine(list[i]);
                num--;
            }
            if (num == 0) return;
        }
    }
    static double calc(long num)
    {
        double d = num;
        var dig = 0;
        var s = num.ToString();
        for (var i = 0; i < s.Length; i++)
            dig += s[i] - '0';
        return d / dig;
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


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

#ifdef _DEBUG
    #include "/home/v-o_o-v/deb.h"
    #define deb(x...)cerr << "[" << #x << "] = [";_print(x);
#else
    #define deb(x...)
#endif

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
   
    int n;
    cin >> n;
    ll f[n + 1];
    f[0] = 2LL;f[1] = 1LL;
    for(int i = 2; i <= n; i++)f[i] = f[i - 1] + f[i - 2];
    cout << f[n] << '\n'; 
    return 0;
}
// Write Here


Measured memory_bytes: 3656
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  cout<<N*N*N<<endl;
}



Measured memory_bytes: 3620
N = int(input())
T = [[] for i in range(N)]
for i in range(N):
    a = list(input())
    T[i] = a
num = 0
for i in range(N):
    flag = True
    for j in range(N):
        for k in range(N):
            q = k + i
            p = j + i
            if q >= N:
                q -= N
            if p >= N:
                p -= N
            if j == q:
                continue
            if T[j][q] != T[k][p]:
                flag = False

    if flag:
        num += 1

print(num * N)

Measured memory_bytes: 50056
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int N, K;
	long S;
	List<Long> result;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		this.N = Integer.parseInt(tokens[0]);
		this.K = Integer.parseInt(tokens[1]);
		this.S = Long.parseLong(tokens[2]);

	}

	void calc() {
		this.result = new ArrayList<>(N);
		for (int i = 0; i < K; ++i) {
			result.add(S);
		}
		// 残りの値が重要
		long remain = 1L;
		if (N - K > 0) {
			remain = (S - 1) / (N - K);
			if (remain == 0) {
				remain = 1000000000L;
			}
		}
		for (int i = K; i < N; ++i) {
			result.add(remain);
		}
	}

	void showResult() {
		StringBuilder strBuilder = new StringBuilder();
		strBuilder.append(Long.toString(result.get(0)));
		for (int i = 1; i < N; ++i) {
			strBuilder.append(" " + Long.toString(result.get(i)));
		}
		System.out.println(strBuilder.toString());
	}
}


Measured memory_bytes: 43732
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg puts("It's Just Begining.Wait For The End!!!!!\n")
#define CHECK(x) cout << (#x) << " is " << (x) <<"\n";
#define endl printf("\n")
typedef pair<ll,ll> pii;
#define pb push_back
#define ms(a,b) memset(a, b, sizeof(a))
#define in(x) scanf("%lld",&x)
#define out(x) printf("%lld",x)
#define X first
#define Y second
#define sps printf(" ")
#define dou(x) cout<<fixed<<setprecision(6)<<x
#define all(v) v.begin(),v.end()
#define dis(it,it1) distance(it,it1)+1
#define MAX 100005
#define INF 9223372036854775807LL
#define MOD 1000000007
#define print(cs) printf("Case %lld: ",cs)
#define Yesno(ok) if(ok)puts("YES");else puts("NO")
#define yesno(ok) if(ok)puts("Yes");else puts("No")
ll lcm(ll a,ll b){return ((a*b)/__gcd(a,b));}
int main()
{
     ll test=1,cas=1;
     while(test--)
     {
		ll i,j,k,l,n,m,r,x;
		in(x);in(n);
		bool visit[105];
		ms(visit,false);
		for(i=0;i<n;i++)
        {
            in(m);
            visit[m]=true;
        }
        ll diff=INF,ans;
        for(i=0;i<=101;i++)
        {
            if(visit[i])continue;
            if(abs(i-x)<diff)
            {
                ans=i;
                diff=abs(i-x);
            }
        }
        out(ans);endl;
     }
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define MAXN 200100
typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
inline ll mod(ll n, ll m){ll ret = n%m; if(ret < 0) ret += m; return ret;}
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }    else return mod(k*k,m);
}

struct seg{
 int l,r,v;	
};
seg v[MAXN];

struct LazySeg{
vector<int> tree;
vector<int> lazy;
int n;

void build(int no,int i,int j){
	lazy[no] = 0;
	if(i==j){
		tree[no] = 0;
		if(i==0)tree[no] = 0;
	}else{
		int m = (i+j)/2;
		int l = 2*no,r=2*no+1;
		build(l,i,m);
		build(r,m+1,j);
		tree[no] = max(tree[l],tree[r]);
	}
}

void propagate(int no,int i,int j){
	if(lazy[no]==0)return;
	tree[no]+=lazy[no];
	if(i!=j){
		lazy[2*no]+=lazy[no];
		lazy[2*no+1]+=lazy[no];
	}
	lazy[no] = 0;
}

void update(int no,int i,int j,int a,int b,int v){
	propagate(no,i,j);
	if(i>b || j<a || i>j)return;
	if(a<=i && j<=b){
		tree[no] += v;
		if(i!=j){
			lazy[2*no]+=v;
			lazy[2*no+1]+=v;
		}
		return;
	}
	int m = (i+j)/2;
	int l = 2*no,r=2*no+1;
	update(l,i,m,a,b,v);
	update(r,m+1,j,a,b,v);	
	tree[no] = max(tree[l],tree[r]);
}

int query(int no,int i,int j,int a,int b){
	if(i>b || j<a || i>j)return -1e18;
	
	propagate(no,i,j);
	
	if(a<=i && j<=b)return tree[no];
	
	int m = (i+j)/2;
	int l = 2*no,r=2*no+1;
	
	return max(query(l,i,m,a,b),query(r,m+1,j,a,b));
}

void init(int c){
	n = c;
	tree.resize(4*(n+1));
	lazy.resize(4*(n+1));
	build(1,0,n);
}
	
};

int A[MAXN];


struct event{
 int x,id,type;
 event(){}
 event(int a,int b,int c){
	 x = a;
	 id = b;
	 type = c;
 }	
 bool operator<(const event &o) const{
	return x < o.x;
 }
};
int dp[MAXN];
int32_t main(){
    fastio;
    int n,m;
    cin>>n>>m;
    
    vector<event> ev;
    for(int i=1;i<=m;i++){
		cin>>v[i].l>>v[i].r>>v[i].v;
		v[i].r++;
		// ^confere?
		ev.pb(event(v[i].l,i,0));
		ev.pb(event(v[i].r,i,1));
	}
    sort(td(ev));

    int cur=0;
    dp[0] = 0;
    LazySeg L;
    L.init(n);
    for(int i=1;i<=n;i++){
		while(cur<2*m && i==ev[cur].x){
			
			if(ev[cur].type==0){
				L.update(1,0,n,0, i - 1, v[ev[cur].id].v);
			}else{
				L.update(1,0,n,0,v[ev[cur].id].l - 1, -v[ev[cur].id].v);
			}
			cur++;
		}
		dp[i] = L.query(1,0,n,0,i-1);
		
		L.update(1,0,n,i,i,dp[i]);
	}
	 int r=0;
	 for(int i=1;i<=n;i++){
		 r= max(r,dp[i]);
	 }
	 cout<<r<<endl;
    
    
	// Math -> gcd it all
	//did you check N=1? Did you mix up N,M?
}


Measured memory_bytes: 31592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=s;i<t;i++)
typedef long long ll;
#define MAXNUM 2055555
const ll mod=998244353;
ll fact[MAXNUM],ifact[MAXNUM];

ll qpow(ll a, ll b)
{
    ll res = 1;
    while (b)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod, b >>= 1;
    }
    return res;
}
void sub(ll &a,ll b)
{
    a-=b;
    if(a<0)a+=mod;
}
ll getC(int a,int b)
{
    return fact[a]*ifact[b]%mod*ifact[a-b]%mod;
}
int main()
{
    int n,m;scanf("%d%d",&n,&m);
    fact[0]=ifact[0]=1;
    rep(i,1,2*m+n+1)fact[i]=fact[i-1]*i%mod,ifact[i]=qpow(fact[i],mod-2);
    ll res=0;
    rep(i,0,min(n,m)+1)
    {
        if(3*m-i>=0&&(3*m-i)%2==0)
            (res+=getC(n,i)*getC((3*m-i)/2+n-1,n-1))%=mod;
        if(m-i>=0&&(m-i)%2==0){
            sub(res,getC(n,i)*getC((m-i)/2+n-1,n-1)%mod*n%mod);
            if(n!=i)(res+=getC(n-1,i)*getC((m-i)/2+n-2,n-2)%mod*n)%=mod;
        }
    }
    printf("%lld\n",res);
}

Measured memory_bytes: 31872