akhauriyash/Code-Regression huggingface dataset:
// 1_1_A
#include <stdio.h>
#include <stdlib.h>

void PrintSequence(int numbers[], int length){
    int i;
    for(i = 0; i < length - 1; i++){
        printf("%d ", numbers[i]);
    }
    printf("%d\n", numbers[i]);
    return;
}

void InsertionSort(int numbers[], int length){
    int i, j, v;
    for(i = 0; i < length; i++){
        v = numbers[i];
        j = i - 1;
        while(j >= 0 && numbers[j] > v){
            numbers[j+1] = numbers[j];
            j--;
        }
        numbers[j+1] = v;
        PrintSequence(numbers, length);
    }
    return;
}

int main(){
    int n, i, *numbers;
    scanf("%d", &n);

    numbers = (int*) malloc(sizeof(int)*n);

    for(i = 0; i < n; i++){
        scanf("%d", &numbers[i]);
    }

    InsertionSort(numbers, n);
    free(numbers);
    return 0;
}

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

int main(){
  vector<int> A(4);
  for(int i = 0; i < 4; ++i) cin >> A[i];
  sort(A.begin(), A.end());
  vector<int> t = {1,4,7,9};
  if(A == t) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

using static Input;
using static Util;
class Program
{
    static int N;
    static int[] W;
    static void INPUT()
    {
        N = NextInt();
        W = LineInt();
    }
    static void OUT()
    {
        var A = new int[N + 1];
        foreach(var w in W)
        {
            A[w]++;
        }


        for(var i = 1; i <= N; i++)
            Console.WriteLine(A[i]);
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{
}




Measured memory_bytes: 40420
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; scanf("%lld", &x); return x;}
ld fin(){double x; scanf("%lf", &x); return x;}
char yuyushiki[1000010]; string stin(){scanf( "%s", yuyushiki ); return yuyushiki;}

// head

int n;
int a[110];

int main(){

  n = in();
  REP(i, n){
    a[i] = in();
  }

  int ans = 0;
  int prv = -1;
  int cnt = 0;
  REP(i, n+1){
    if(a[i] == prv){
      cnt++;
    } else {
      ans += cnt / 2;
      prv = a[i];
      cnt = 1;
    }
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n;
long long a, ac = 1;
double ac2 = 1;
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%lld", &a);
		ac *= a;
		ac2 *= a;
		if(ac2 > 2e18){
			ac = -1;
			for(int j=i+1; j<n; j++){
				scanf("%lld", &a);
				if(a == 0) ac = 0;
			}
			break;
		}
	}
	if(ac > (long long)1e18) ac = -1;
	printf("%lld\n", ac);
}

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

#define F first
#define S second
#define MP make_pair

using namespace std;

const int N = 1e7+100;
pair<long long int, long long int> p[N];

int main () {
    ios::sync_with_stdio(0);
    long long int n;
    cin >> n;
    for(int i = 0 ; i < n ; i++ ) {
        cin >> p[i].F;
        p[i].S=i+1;
    }
    sort(p,p+n);
    for(int i = 0 ; i < n ; i++ ) {
        cout << p[i].S << ' ';
    }
}


Measured memory_bytes: 2432
#coding:utf-8

N = int(raw_input())

point = map(int, raw_input().split())

prev = 0
total = 0
for i_p in point:
    current = abs(i_p - prev)
    total += current
    prev = i_p

total += abs(0 - prev)

point.insert(0, 0)
point.append(0)

origin = total

#print total

for idx, value in enumerate(point):
    if (idx == 0) or (idx == len(point) - 1):
        continue

    tmp1 = point[idx - 1]
    tmp = point[idx]
    tmp2 = point[idx + 1]

    total -= abs(tmp - tmp1)
    total -= abs(tmp - tmp2)
    total += abs(tmp2 - tmp1)

    print total

    total = origin


Measured memory_bytes: 11236
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n;
    cin>>n;
    long long int s=0;
    for(long long int i=1;i<=n;i++)
    {
        if(i%3==0)
        continue;
        else if(i%5==0)
        continue;
        else if(i%15==0)
        break;
        else
        s+=i;
        
    }
    cout<<s<<endl;
	// your code goes here
	return 0;
}

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

long long MOD = 1e9+7;
int MAX_INT = 1e9;

// 最大公約数
long long gcd(long long a, long long b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
// 最小公倍数
long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}

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

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

  map<int, int> mp;
  for (int i = 0; i < N; i++) {
    mp[a[i]]++;
  }

  int ans = 0;
  for (auto p: mp) {
    int x = p.first;
    int n = p.second;
    if (n < x) ans += n;
    else ans += n - x;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8152
#include<bits/stdc++.h>
using namespace std;
string s,t;
bool a[26]={true};
int main()
{
	for(int i=0;i<26;i++)
     a[i]=true;
  cin>>s;
  t=s;
  if(s.size()<26)
  {
   for(int i=0;i<s.size();i++)
   {
     a[s[i]-'a']=false;
	}
   cout<<s;
   for(int i=0;i<26;i++)
   {
    if(a[i]) {
	                 cout<<char('a'+i)<<endl;
	                 return 0;
					 }
	}
   }
   else 
   {
    if(next_permutation(s.begin(),s.end())) 
    {
	 for(int i=0;i<26;i++)
	 {
	  cout<<s[i];
	  if(s[i]!=t[i]) break;
	  }
	 }
    else cout<<-1<<endl;
	}
 return 0;} 

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

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

set< vector<int> > data;

void rec(vector<int> d , int last){
	data.insert(d);
	for(int i=0;i<last;i++){
		if(i && d[i]+1 > d[i-1])continue;
		d[last]-- , d[i]++;
		if(data.find(d) == data.end())rec(d,d[last]==0?last-1:last);
		d[last]++ , d[i]--;
		
	}
}

int main()
{
	int n;
	while(cin >> n , n){
		vector<int> d(n,1);
		set< vector<int> > emp;
		data = emp;
		rec(d,n-1);
		for(set<vector<int> >::reverse_iterator it = data.rbegin(); it != data.rend() ; ++it){
			for(int j=0;j<(*it).size();j++)
				if((*it)[j])cout << (j?" ":"") << (*it)[j];
			cout << endl;
		}
	}
}

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

int main() {
  // n スイッチの数
  // m 電球の数
  int n, m;
  cin >> n >> m;

  // 電球と、電球がつながっているスイッチ
  vector<set<int>> light_bulbs(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;

    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      s--; // 0-indexed
      light_bulbs.at(i).insert(s);
    }
  }

  // 点灯条件
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    cin >> p.at(i);
  }

  int ans = 0;

  // スイッチの点灯パターンをbit探索する
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    vector<set<int>> copied = light_bulbs;

    for (int i = 0; i < n; i++) {
      // i桁目のbitが1かどうか = i番目のスイッチがonかoffか
      // 1ではない場合、スイッチoffと見做す
      if (tmp & (1 << i)) {
        continue;
      } else {
        // 電球から対象のスイッチを off とする
        for (int j = 0; j < m; j++) {
          copied.at(j).erase(i);
        }
      }
    }

    // 全ての電球が点灯しているか確認する
    bool ok = true;
    for (int i = 0; i < m; i++) {
      // 条件を満たさない場合を探す
      if ((int)copied.at(i).size() % 2 != p.at(i)) {
        ok = false;
        break;
      }
    }
    if (ok) { ans++; }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
<?php

  list($n, $m) = explode(" ", trim(fgets(STDIN)));

  list($s) = explode(" ", trim(fgets(STDIN)));

  $m--;
  for ($i=0; $i<$n; $i++) {
    if($i==$m){
      if($s[$i]=='A'){
        echo 'a';
      }else if($s[$i]=='B'){
        echo 'b';
      }else{
        echo 'c';
      }
    }else{    
      echo $s[$i];
    }
  }

Measured memory_bytes: 4604
N=int(input())
L=list(map(int,input().split()))
L.sort()
K=0


for i in range(N-2):
    for j in range(N-i-1):
        for k in range(N-i-j-2):
            if L[i]<L[i+j+1]<L[i+j+k+2]and L[i]+L[i+j+1]>L[i+j+k+2]:
                K=K+1
print(K)

Measured memory_bytes: 9148
#include <iostream>
#include <cstring>

using namespace std;

int main() {
	int n;
	cin >> n;
	int v[20];
	int c[20];
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	int x = 0;
	for (int i = 0; i < n; i++) {
		if (v[i] > c[i]) {
			x += v[i] - c[i];
		}
	}
	cout << x;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

template<class Type> Type ilcm(Type x,Type y){return x/__gcd(x,y)*y;}

int main(){
	llong a,b;
	cin>>a>>b;
	
	cout<<ilcm(a,b)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------------------

int main(void) {
  ll N, W;
  cin >> N >> W;
  ll w[N+1], v[N+1];
  rep(i,N){
    cin >> w[i+1] >> v[i+1];
  }
  ll dp[N+1][W+1];
  rep(i,W+1){
    dp[0][i]=0;
  }

  REP(i,1,N+1){
    rep(j,W+1){
      if(j-w[i]>-1){
        dp[i][j] = max(dp[i-1][j-w[i]]+v[i], dp[i-1][j]);
      } else {
        dp[i][j] = dp[i-1][j];
      }
    }
  }
/*
  rep(i,N+1){
    rep(j,W+1){
      cout << dp[i][j] << " ";
    }
    cout << "\n";
  }
*/

  prt(dp[N][W]);
}


Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int M = 1000005;

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> cnt(M);
    int i;
    for(int i = 0; i<n; i++){
        cin >> a[i];
    }
    for(int i = 0; i<n; i++){
        if(cnt[a[i]] != 0){
            cnt[a[i]] = 2;
            continue;
        }
        for(int j = a[i]; j < M; j += a[i]){
            cnt[j]++;
        }
    }
    int ans = 0;
    for(int i = 0; i<n; i++){
        if(cnt[a[i]] == 1){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8020
def main():
    N = int(input())
    string = [chr(i) for i in range(97, 97+26)]
    ans = [[] for _ in range(10)]
    ans[0].append('a')
    for i in range(9):
        for s in ans[i]:
            n = len(set(s))
            for j in range(n+1):
                ans[i+1].append(''.join([s, string[j]]))
    print('\n'.join(ans[N-1]))

main()

Measured memory_bytes: 17012
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	string memo = "aeiou";
	char cc;
	cin >> cc;
	for(int64 ii = 0;ii < 5;ii++)
	{
		if(cc == memo[ii])
		{
			cout << "vowel" << endl;
			return 0;
		}
	}
	cout << "consonant" << endl;
	return 0;
}

Measured memory_bytes: 3596
a, b, k = map(int, input().split())

if a < b:
    m = a
else:
    m = b

lst = list()
for i in range(1, m+1):
    if a % i == 0 and b % i == 0:
        lst.append(i)

lst = sorted(lst, reverse=True)
print(lst[k-1])

Measured memory_bytes: 3060
N = int(input())
h = [int(i) for i in input().split()]

dp = [0]*N
dp[1] = abs(h[1] - h[0])

for i in range(N-2):
  dp[i+2]=min(dp[i+1]+ abs(h[i+2]-h[i+1]), dp[i]+ abs(h[i+2]-h[i]))
print(dp[N-1])

Measured memory_bytes: 13708
#include <bits/stdc++.h>
#define sz(c)       int(c.size())
#define rep(i,a,b)  for (int i=a; i<(b); ++i)
#define per(i,a,b)  for (int i=(b)-1; i>=(a); --i)
#define fore(c,...) for (auto __VA_ARGS__:(c))
using namespace std;
typedef long long ll;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int k,a,b;
	cin>>k>>a>>b;
	rep(i,a,b+1) if (i%k==0) {
		cout<<"OK\n";
		return 0;
	}
	cout<<"NG\n";
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_R = 100;
const int MAX_C = 100;
const int MAX_S = 1000;
const int MAX_N = 1000;
const int MAX_SN = MAX_S * MAX_N;
const int MAX_P = 12;
const int MAX_BITS = 1 << MAX_P;

const int dxs[] = {1, 0, -1, 0}, dys[] = {0, -1, 0 , 1};

/* typedef */

typedef pair<int,int> pii;

/* global variables */

int flds[MAX_R][MAX_C];
int trps[26], ptns[MAX_P], dmgs[MAX_SN], dp[MAX_BITS];
pii rts[MAX_S];

/* subroutines */

/* main */

int main() {
  for (;;) {
    int h, hmax;
    cin >> h >> hmax;
    if (h == 0) break;

    int r, c;
    cin >> r >> c;

    memset(trps, 0, sizeof(trps));

    for (int y = 0; y < r; y++) {
      string line;
      cin >> line;
      for (int x = 0; x < c; x++) flds[y][x] = line[x] - 'A';
    }

    int t;
    cin >> t;

    for (int i = 0; i < t; i++) {
      char ch;
      int d;
      cin >> ch >> d;
      trps[ch - 'A'] = d;
    }

    int s;
    cin >> s;

    for (int i = 0; i < s; i++) {
      char ch;
      cin >> ch >> rts[i].second;

      switch (ch) {
      case 'R': rts[i].first = 0; break;
      case 'U': rts[i].first = 1; break;
      case 'L': rts[i].first = 2; break;
      case 'D': rts[i].first = 3; break;
      }
    }

    int p, max_bits;
    cin >> p;
    max_bits = 1 << p;

    for (int i = 0; i < p; i++) cin >> ptns[i];

    int x = 0, y = 0;
    int sn = 0;

    for (int i = 0; i < s; i++) {
      int di = rts[i].first;
      int dx = dxs[di], dy = dys[di];
      int ni = rts[i].second;

      while (ni--) {
	x += dx, y += dy;
	dmgs[sn++] = trps[flds[y][x]];
      }
    }
    //printf("sn=%d\n", sn);

    for (int bits = 0; bits < max_bits; bits++) dp[bits] = 0;
    dp[0] = h;

    for (int i = 0; i < sn; i++) {
      for (int bits = 0; bits < max_bits; bits++) {
	if (dp[bits] <= 0) continue;
	for (int bi = 0; bi < p; bi++) {
	  int bits0 = bits | (1 << bi);
	  if (bits == bits0) continue;
	  int d = min(dp[bits] + ptns[bi], hmax);
	  if (dp[bits0] < d) dp[bits0] = d;
	}

	dp[bits] -= dmgs[i];
      }
    }

    bool ok = false;
    for (int bits = max_bits - 1; bits >= 0; bits--)
      if (dp[bits] > 0) {
	ok = true;
	break;
      }

    cout << (ok ? "YES" : "NO") << endl;
  }

  return 0;
}

Measured memory_bytes: 1276
// AOJ
#include<stdio.h>

int sum2(int);
int sum3(int);

int sum2(int n){
	if(n >= 0 && n <= 18){
		if(n <= 9)
			return n+1;
		else
			return 19-n;
	}
	else
		return 0;
}


int sum3(int n){
	int i;
	if(n >= 0 && n <= 27){
		int ans = 0;
		for(i=0; i<=9; i++){
			if(i <= n)
				ans += sum2(n-i);
		}
		return ans;
	}
	else
		return 0;
}

int main(){
	int n, i;
	int ans;
	while(scanf("%d", &n) != EOF){
		ans = 0;
		for(i=0; i<=9; i++){
			if(i <= n)
				ans += sum3(n-i);
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

#define HW_MAX 50
int H,W;
char s[HW_MAX][HW_MAX];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  int i,k,j;
  cin >> H >> W;
  for(i=0;i<H;i++){
    for(k=0;k<W;k++){
      cin >> s[i][k];
    }
  }
  
  //幅優先探索で2マス以上繋がってるマスか確認
  bool flag=true;
  for(i=0;i<H;i++){
    for(k=0;k<W;k++){
      //黒色マスかどうか
      if(s[i][k]=='#' && flag){
        flag=false;
        for(j=0;j<4;j++){
          if( (i+dx[j]<H)&&(i+dx[j]>=0)
            &&(k+dy[j]<W)&&(k+dy[j]>=0) ){
            if(s[i+dx[j]][k+dy[j]]=='#'){
              flag=true;break;}
          }
        }
      }
    }
  }
  
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = []
for _ in range(H):
    s = input()
    S.append(s)
    
import copy
maze = copy.deepcopy(S)

import queue

INT_MAX = 2**63-1
stayed = [[INT_MAX] * W for _ in range(H)]

def bfs():
    gole = (W-1, H-1)
    q = queue.Queue()
    q.put((
        0, # current x
        0, # current y
        0, # count
    ))

    while not q.empty():
        cur_x, cur_y, cnt = q.get()
        if (cur_x, cur_y) == gole:
            return cnt
        next_pos = [
            (cur_x, cur_y-1),
            (cur_x, cur_y+1),
            (cur_x-1, cur_y),
            (cur_x+1, cur_y)
        ]
        
        for x, y in next_pos:
            if x == -1 or y == -1 or x == W or y == H:
                continue
            if S[y][x] == '#':
                continue
            if stayed[y][x] > cnt+1:
                stayed[y][x] = cnt+1
                q.put((x, y, cnt+1))
                
        #print(stayed)
    return -1
            

shortest_path_len = bfs()

if shortest_path_len != -1:
    cnt_dot = sum([s.count('.') for s in maze])


    ans = cnt_dot - shortest_path_len - 1
    print(ans)
else:
    print(-1)
        
        
        

Measured memory_bytes: 4080
#include <stdio.h>

int main(void)
{
  int n;

  scanf("%d", &n);

  if(n < 0){
    return -1;
  }
  else if(n % 2){
    printf("%d\n", 2 * n);
  }
  else{
    printf("%d\n", n);
  }

  return 0;
}


Measured memory_bytes: 128
s = gets.chomp
keyence = "keyence"
KEYENCE_SIZE = 7
n = s.size
ans = false

KEYENCE_SIZE.times do |i|
    head = keyence[0...i]
    tale = keyence[i...n]
    ans = true if s =~ /^#{head}.*#{tale}$/
end

puts ans ? "YES" : "NO"

Measured memory_bytes: 14284
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x,y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x,y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define d4(x,y,z,w)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z << " | "<< #w << "--> " << w <<endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=1ll<<32;
const ll maxn=1e3+10;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getRand(ll l, ll r){ uniform_int_distribution<int> uid(l, r); return uid(rng); }



void solve(){
	
	ll n,k;
	cin>>n>>k;
	ll p1=n/k;
	ll p2=p1-1;
	ll p3=p1+1;
	cout<<min({abs(n-p1*k), abs(n-p2*k), abs(n-p3*k)})<<endl;
	
	
	return;
}

int main(){ 
    
    #ifndef ONLINE_JUDGE
  	//	freopen("input.txt", "r", stdin);
    #endif
    srand(time(0)); 
    
    ios::sync_with_stdio(0);
    cin.tie(0);


	//T{ solve(); }
	solve();
		
	
	return 0;
}

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

int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    if (a == 0) {
        cout << 1 << endl;
    } else if (b == 0) {
        cout << 2 << endl;
    } else if (c == 0) {
        cout << 3 << endl;
    } else if (d == 0) {
        cout << 4 << endl;
    } else if (e == 0) {
        cout << 5 << endl;
    }
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
    int N,K,M = 0; cin >> N >> K;
    vector<vector<int> > v(N);
    for (int i = 0; i < N-1; i++){
        for (int j = i+1; j < N-1; j++){
            if (K > 0){
                K--;
            } else {
                M++;
                v[i].push_back(j);
            }
        }
        M++;
        v[i].push_back(N-1);
    }
    if (K > 0){
        cout << -1 << endl;
        return 0;
    } 
    cout << M << endl;
    for (int i = 0; i < N; i++){
        for (int j = 0; j < v[i].size(); j++){
            cout << i+1 << " " << v[i][j]+1 << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max(a*b,c*d)<<"\n";
  
  return 0;
}

Measured memory_bytes: 3592
import sys
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, *A = map(int, read().split())
 
U = 10 ** 18
p = 1
for x in A:
    p *= x
    if p > U:
        p = U + 1
 
if p > U:
    print(-1)
else:
    print(p)


Measured memory_bytes: 19984
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int prime(int a) {
	int count = 0;
	while (a % 2 == 0) {
		++count;
		a /= 2;
	}
	return count;
}

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		ans += prime(a[i]);
	}
	cout << ans << endl;
	return 0;
}

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

int main () {
  sc s; string in;
  cin >> in;
  for (auto elem: in) {s.insert(elem);}
  cout << (s.size() == 2 ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		b,c,i,j,k,n,m,x,y,ans = 0;
	

	cin >> n;
	vector<ll> a(n+1);
	map<ll,ll> ii,jj;
	for(i=1;i<=n;i++) {
		cin >> a[i];
		ii[i+a[i]]++;
		jj[i-a[i]]++;
	}

	for(i=1;i<n;i++) {
		ans += ii[i]*jj[i];
	}


	cout << ans << endl;

}


Measured memory_bytes: 47524
#include<bits/stdc++.h>
using namespace std;
const int N=5e6+5;
int n,k,tot,head[55],nex[N],to[N],fi[N],se[N];
void add(int u,int x,int y)
{
    if(tot+1>=N) exit(0);
    ++tot;nex[tot]=head[u];head[u]=tot;fi[tot]=x;se[tot]=y;
}
int upbit(int x)
{
    for(int i=30;i>=0;i--)
        if(x>>i&1) return i;
    return -1;
}
long long sum[55];
int main()
{
    //freopen("01.txt","r",stdin);
    scanf("%d%d",&n,&k);
    if(n>1e5) exit(0);
    long long ans=0,res=0;
    int u=upbit(k);
    for(int i=1;i<=n;i++)
    {
        int a,b;scanf("%d%d",&a,&b);
        int k=upbit(a);
        if(k==-1||(a&k)==a) res+=b;
        else add(k,a,b),sum[k]+=b;
    }
    for(int i=u;i>=0;i--)
        if(k>>i&1)
        {
            long long s=0;
            for(int j=i-1;j>=0;j--)
                s+=sum[j];
            ans=max(ans,res+s);
            for(int j=head[i];j;j=nex[j])
            {
                int f=fi[j],s=se[j];
                f^=1<<i;
                int k=upbit(f);
                if(k==-1) res+=s;
                else add(k,f,s),sum[k]+=s;
            }
        }
    ans=max(ans,res);
    printf("%lld\n",ans);
}


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

struct stu
{
	int num;
	int order;
	bool operator <(const stu&s)
	{
		return num<s.num;
	}
}a[100099];
 
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i].num;
		a[i].order=i+1;
	}
	sort(a,a+n);
	for(int i=0;i<n;i++)
	{
		cout<<a[i].order<<' ';
	}
	cout<<endl;
	return 0;
}

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


#define DEBUG(x) 			   cout << '>' << #x << ':' << x << endl;
#define D(x)        		   cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define DD(x,y)     		   cerr << __LINE__ << ": " << #x << " = " << x << "   " << #y << " = " << y << '\n'
#define DDD(x,y,z)  		   cerr << __LINE__ << ": " << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << '\n'
#define DBG         		   cerr << __LINE__ << ": Hi" << '\n'
#define fresh                  {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define read                   freopen("in.txt","rt",stdin)
#define write                  freopen("out.txt","wt",stdout)
#define PI                     3.1415926535897932384626433832795
#define mems(ds_name,val)      memset(ds_name,val,sizeof(ds_name))


int main()
{
    fresh;
//    read;
//	write;

    int t;
    cin>>t;
    int divs = t/2;
    int mods=t%2;
    if(!mods){
        cout<<divs*divs<<endl;
    }
    else{
        cout<<divs*(divs+1)<<endl;
    }



}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import numpy as np

# 奇数番目、または偶数番目、の好きな部分集合を足せる（ただし1元以上）
# 交互に塗り分けると交互が維持されることから分かる

N = int(input())
A = np.array(input().split(), dtype=np.int64)

def select_operation(select,N):
    result = []
    # 余分な左端
    x = select.min()
    result = [0] * x
    select -= x
    N -= x
    # 余分な右端
    y = select.max()
    result += list(range(N-1,y,-1))
    N = y + 1
    # 右から見て、要らない偶数を除外
    result += np.setdiff1d(np.arange(N)[::2], select)[::-1].tolist()
    # 0,2,4,...番目を集約
    result += [1] * (len(select) - 1)
    result = [1+x for x in result]
    return result

ev_sum = np.maximum(0,A[::2]).sum()
od_sum = np.maximum(0,A[1::2]).sum()
if ev_sum >= od_sum > 0:
    select = np.where(A[::2] >= 0)[0] * 2
elif od_sum > 0:
    select = np.where(A[1::2] >= 0)[0] * 2 + 1
else:
    n = np.argmax(A)
    select = np.array([n])
S = A[select].sum()

ope = select_operation(select,N)

# 答えの出力
print(S)
print(len(ope))
print('\n'.join(map(str,ope)))

select

Measured memory_bytes: 12544
#include <iostream>
using namespace std;
int main(void){
    long long n, count=0, sho, sumA = 0, i=0;
  	cin >> n;
  	while(i<n){
      sho = n/(i+1);
      sumA = (i+1)*(n/(i+1)+1)*(n/(i+1))/2;
      count+=sumA;
      i++;
    }
  cout << count;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
int X1[1000],X2[1000],Y1[1000],Y2[1000];
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
bool F[6000][6000];
int W,H,N;
int compress(int *X1,int *X2,int W) {
	vector<int> VX;
	for(int i=0;i<N;i++) {
		for(int d=-1;d<=1;d++) {
			int nx1=X1[i]+d,nx2=X2[i]+d;
			if(0<=nx1 && nx1<W) VX.push_back(nx1);
			if(0<=nx2 && nx2<W) VX.push_back(nx2);
		}
	}
	sort(VX.begin(),VX.end());
	VX.erase(unique(VX.begin(),VX.end()),VX.end());
	for(int i=0;i<N;i++) {
		X1[i]=find(VX.begin(),VX.end(),X1[i])-VX.begin();
		X2[i]=find(VX.begin(),VX.end(),X2[i])-VX.begin();
	}
	return VX.size();
}
int main() {
	while(scanf("%d %d",&W,&H),W|H) {
		scanf("%d",&N);
		for(int i=0;i<N;i++) {
			scanf("%d %d %d %d",&X1[i],&Y1[i],&X2[i],&Y2[i]);
		}
		W=compress(X1,X2,W);
		H=compress(Y1,Y2,H);
		memset(F,0,sizeof(F));
		for(int i=0;i<N;i++) {
			for(int y=Y1[i];y<Y2[i];y++) for(int x=X1[i];x<X2[i];x++) {
				F[x][y]=1;
			}
		}
		int ans=0;
		for(int y=0;y<H;y++) for(int x=0;x<W;x++) {
			if(F[x][y]) continue;
			ans++;
			queue<P> Q;
			Q.push(P(x,y));
			while(!Q.empty()) {
				P p=Q.front();Q.pop();
				for(int i=0;i<4;i++) {
					int nx=p.first+dx[i],ny=p.second+dy[i];
					if(0>nx||nx>=W||0>ny||ny>=H) continue;
					if(F[nx][ny]) continue;
					F[nx][ny]=true;
					Q.push(P(nx,ny));
				}
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 36244
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN=1e5+10,MAXM=1e9;
const int INF=0x7fffffff;
ll dp1[50][50],dp2[50][50];
int main()
{
    ll s;
    cin>>s;
    ll a=s/MAXM+1;
    ll b=a*MAXM-s;
    if(s!=1e18)
    printf("0 0 1 %lld %lld %lld",MAXM,a,b);
    else
        printf("0 0 0 %lld %lld %lld",MAXM,MAXM,MAXM);
    return 0;
}


Measured memory_bytes: 256
require 'matrix'

sixty_degree = Math::PI/3
@rotate_mat = Matrix[
  [Math.cos(sixty_degree), -Math.sin(sixty_degree)],
  [Math.sin(sixty_degree),  Math.cos(sixty_degree)]
]

def init(arr)
  arr[0...-1]
end

def koch(d, a, b) # => [Vector]
  if d == 0
    return [a, b]
  else
    p = a + (b - a) / 3.0
    r = a + (b - a) * 2.0 / 3.0
    q = p + @rotate_mat * (r - p)

    init(koch(d-1, a, p)) + init(koch(d-1, p, q)) + init(koch(d-1, q, r)) + koch(d-1, r, b)
  end
end

n = $stdin.gets.strip.to_i

init_a = Vector[0.0, 0.0]
init_b = Vector[100.0, 0.0]
points = koch(n, init_a, init_b)

points.each do |point|
  puts "#{point[0]} #{point[1]}"
end



Measured memory_bytes: 7264
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

#define TIMES(i) while(i--)
#define REP(i, n) for ( int i = 0; i < n; i++ )

using namespace std;

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

    TIMES(n) {
        // 入力
        double ax, ay, ar, bx, by, br;
        cin >> ax >> ay >> ar >> bx >> by >> br;

        // 距離を求める
        double dis_x = abs(ax-bx),
            dis_y = abs(ay-by),
            dist = sqrt(dis_x * dis_x + dis_y * dis_y);

        // cout << dis_x << " " << dis_y << " " << dist << endl;

        // 離れている
        if ( dist > ar + br ) {
            cout << 0;

        // aが内包されている
        } else if ( dist + ar < br ) {
            cout << -2;

        // bが内包されている
        } else if ( dist + br < ar ) {
            cout << 2;

        // 交わっている
        } else {
            cout << 1;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1228
n = gets.chomp.to_i
x = gets.chomp.split(' ').map {|v| v.to_i}
x.sort!
dist = Array.new(x.length - 1)

dist.length.times do |i|
  dist[i] = x[i + 1] - x[i]
end

dist.sort!.reverse!
dist.slice!(0, n - 1)
r = 0
dist.map {|v| r += v}
puts r



Measured memory_bytes: 10352
#include<bits/stdc++.h>
using namespace std;
int mp[1000005];
int main()
{
    int n;
    scanf("%d", &n);
    int ar[n];
    for (int i = 0; i < n; i++) scanf("%d", &ar[i]), mp[ar[i]]++;
    int cnt = 0;
    for (int i = 0; i < n; i++){
        int val = ar[i];
        bool f = 1;
        for (int j = 1; j * j <= val; j++){
            if (val % j == 0){
                int a = j, b = val / j;
                if (a == val && mp[val] > 1) {f = 0; break;}
                else if (b == val && mp[val] > 1) {f = 0; break;}
                else if (mp[a] > 0 && a != val) {f = 0; break;}
                else if (mp[b] > 0 && b != val) {f = 0; break;}
            }
        }
        if (f) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 8284
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	ll M;
	cin >> M;
	vl d(M);
	vl c(M);
	ll csum = 0;
	ll dsum = 0;
	rep(i, M) {
		cin >> d[i] >> c[i];
		csum += c[i];
		dsum += d[i] * c[i];
	}
	ll ans = csum + (dsum - 1) / 9 - 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <ctype.h>
using namespace std;
int a,b;
int main(void)
{
    cin >> a >> b;
    if(a * b % 2 == 0)cout << "No";
    else cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
// 2424_Kakezan.cpp
// 途中
#include <bits/stdc++.h>
using namespace std;

int solve(int n, int cnt){
  if(n<10) return cnt;

  int m=-1;
  for(int i=10;n/i>0;i*=10)
    m=max(m, (n/i)*(n%i));

  cnt++;
  return solve(m,cnt);
}
int main() {
  int q,n;
  cin>>q;

  for(int i=0;i<q;++i) {
    cin>>n;
    cout<<solve(n,0)<<endl;
  }

  return 0;
}



Measured memory_bytes: 3112
#include <stdio.h>
int main(){
	int x, y, i, j;
	while(1){
		scanf("%d %d", &x, &y);
		if(x == 0 && y == 0)break;
		for(i = 0; i < x; i++){
			for(j = 0; j < y; j++){
				if(i == 0 || i == x - 1){
					for(j = 0; j < y; j++){
						printf("#");
					}printf("\n");
				}else if(j == 0){
					printf("#");
				}else if(j == y-1){
					printf("#\n");
				}else{
					printf(".");
				}
			}
		}printf ("\n");
	}
	return 0;
}

Measured memory_bytes: 588
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
using namespace std;
int d1[4]={0,1,0,-1};//これで四方向のベクトルを表現
int d2[4]={1,0,-1,0};
int h,w,ans;
int map[20][20];
 
void dfs(int depth,int y,int x){
    int i,ny,nx;
    if(depth>=ans)return;
    for(i=0;i<4;i++){    
        ny=y+d1[i];nx=x+d2[i];//ポイント
        if(map[ny][nx]==1)continue;//すぐ隣のブロックの破壊を防ぐ
        while(0<=ny&&ny<h&&0<=nx&&nx<w&&map[ny][nx]!=1){//ブロックにぶつかるまで、while文
            if(map[ny][nx]==3){
                ans=depth;return;
            }else {
                ny+=d1[i];nx+=d2[i];
            }
        }   
        if(map[ny][nx]==1&&0<=ny&&ny<h&&0<=nx&&nx<w){//while文に入れると、
                    map[ny][nx]=0;//ブロック消滅
                    dfs(depth+1,ny-d1[i],nx-d2[i]);
                    map[ny][nx]=1;//ここで戻すのがポイント!!
                }
    }
}
 
 
int main(){
    while(1){
        int i,j;
        ans=11;
        cin>>w>>h;
        if(h==0&&w==0)break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                cin>>map[i][j];
            }
        }
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                if(map[i][j]==2){
                    dfs(1,i,j);
                    goto OUT;
                }               
            }
        }
        OUT:
        if(ans==11){
            cout<<"-1"<<endl;
        }else{
            cout<<ans<<endl;
        }
 
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    ll n, k;
    cin>>n>>k;

    n %= k;
    cout<<min(n, abs(n - k))<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 10000

int main( void )
{
  int n[MAX];
  for ( int i = 0; i < MAX; ++i ) {
    scanf( "%d", n + i );
  }
  for ( int i = 0; i < MAX; ++i ) {
    if ( n[i] == 0 ) {
      break;
    }
    printf( "Case %d: %d\n", i + 1, n[i] );
  }
return 0;
}


Measured memory_bytes: 2628
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 100005
#define oo 2000000007
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n;
map<int, int> m;
multiset<int> s;

int main () {
    scanf("%d", &n);
    fto(i, 1, n) {
        int x; scanf("%d", &x);
        ++m[x];
    }

    forit(it, m) {
        fto(i, 1, it->ss/2) s.insert(it->ff);
    }

    if (s.size() < 2) puts("0");
    else {
        ll f[2];
        fto(i, 0, 1) {
            f[i] = *s.rbegin();
            s.erase(s.find(*s.rbegin()));
        }
        cout << f[0]*f[1];
    }

    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define ll long long
using namespace std;


ll f(ll b, ll n) {
    
    ll answer = 0;
    while(n >= b) {
        answer += n % b;
        n /= b;
    }
    return answer + n;
    
    
}


ll SolveSmall(ll n, ll s) {
    vector<ll> divs;
    for(ll j=2;j*j<=n;j++) {
        if (n % j == 0) {
            ll m = n;
            while(m % j == 0) {
                m /= j;
            }
            
            if (m == s && j >= s + 1) {
                return j;
            }
        }
    }
    
    if (n > 1)
        return n;
    else
        return -1;
    
}


ll SolveRev(ll n, ll s) {
    // 1, s-1
    // s-1 <= b-1
    
    // b + s - 1 = n
    
    // b = n-s+1 >= s
    if (n-s+1 >= s) {
        return n-s+1;
    }
    else
        return -1;
    
    
}

ll SolveSmall2(ll n, ll s) {
    if (n == s)
        return n+1;
    // 1,b,..,b^(L-1)
    
    // d(1) * b + d(0) = n
    // d(1)  + d(0) = s
    
    // d(1) = (n-s) / (b-1) <= b-1
    // d(0) = s - d(1) <= b-1
    
    
    vector<ll> divs;
    for(ll x = 2; x*x <= n; x++) {
        if ((n-s)%x == 0) {
            divs.push_back(x);
            divs.push_back((n-s)/x);
            
        }
    }
    
    sort(divs.begin(), divs.end());
    
    for(int j=0;j<divs.size();j++) {
        ll x = divs[j];
        ll b = x + 1;
        ll d1 = (n-s)/(b-1);
        ll d0 = s - d1;
        
        
        if (d1 >= 0 && d1 <= b-1 && d0 >= 0 && d0 <= b-1) {
            return b;
        }
    }
    
    
    
    return -1;
}


ll Solve(ll n, ll s) {
    
    
    
    ll prev = -1;
    int time_since_last_increase = 0;
    ll low = 50000000 + 1;
    for(int j=2;j<=50000000;j++) {
        ll curr = f(j,n);
        if (curr == s) {
            return j;
        }
        prev = curr;
    }
    ll high = 1000000000000000000ll;
    
    while(low < high) {
        ll mid = (low + high)/2;
        
        if (f(mid, n) >= s) {
            high = mid;
        } else {
            low = mid + 1;
        }
    }
    
    
    
    
    vector<ll> answers;
    answers.push_back(f(low, n) == s ? low : -1);
    
    answers.push_back(SolveSmall(n, s));
    
    answers.push_back(SolveRev(n, s));
    
    answers.push_back(SolveSmall2(n, s));
    
    sort(answers.begin(), answers.end());
    for(int j=0;j<answers.size();j++) {
        if (answers[j]>=2 && f(answers[j], n) == s)
            return answers[j];
    }
    
    return -1;
}




int main() {
    ll n,s;
    
    cin>>n>>s;
    
    cout << Solve(n, s) << endl;
    
    
    return 0;
    
    
}


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

int main() {
	
	string A, B;
	int size = 0;
	
	while( cin >> A >> B) {
	
	A += A;
	
	if(A.find(B) != A.npos)
	cout << "Yes\n";
	else
	cout << "No\n";
	
}
	return 0;
}


Measured memory_bytes: 3192
H,W = map(int,input().split())
c,A,s = [],[],0
for i in range(10):
    c.append(list(map(int,input().split())))
for i in range(H):
    A.append(list(map(int,input().split())))
for i in range(10):
    for j in range(10):
        for k in range(10):
            c[j][k] = min(c[j][k], c[j][i]+c[i][k])
for i in range(10):
    for j in range(H):
        s = s + A[j].count(i) * c[i][1]
print(s)

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

int main(void) {
	int i;
	char s[21];
	char *p;
	int len, cnt, turn;

	scanf("%s%n", s, &len);

	p = s;
	cnt = turn = 0;
	while (p != NULL) {
		if (!turn)
			p = strchr(p, 'A');
		else {
			p = strchr(p, 'Z');
			cnt += p != NULL;
		}

		turn ^= 1;
	}

	if (cnt == 0)
		puts("-1");
	else {
		for (i = 0; i < cnt; i++)
			printf("AZ");
		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 528
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

signed main(void) {
    int i,j;
    int n;
    cin >> n;
    if(n==0){
        cout << 0 << endl;
        return 0;
    }
    string ans = "";
    while(n){
        if(n%2) n--,ans = "1" + ans;
        else ans = "0" + ans;
        n/=-2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

N = int(input())
T = list(map(int,input().split()))
t = sum(T)
M = int(input())
P = []
X = []
for i in range(M):
    p,x = map(int,input().split())
    P.append(p)
    X.append(x)

for i in range(M):
    s = t - T[P[i]-1] + X[i]
    print(s)

Measured memory_bytes: 3064
#include<cstdio>
#define M 4004
#define N 2002
int a[N],b[M],c[M],f[N],g[N],h[N],n,x;char s[N];
void dfs(int u,int v)
{
    f[u]=g[u]=0,h[u]=s[u]&1;
    for(int i=a[u];i;i=b[i])if(c[i]!=v)dfs(c[i],u),f[u]<g[c[i]]+h[c[i]]?f[c[i]]+h[c[i]]<g[u]?f[u]=(g[u]^g[c[i]]^h[c[i]])&1:f[u]=f[c[i]]+h[c[i]]-g[u]:f[u]-=g[c[i]]+h[c[i]],g[u]+=g[c[i]]+h[c[i]],h[u]+=h[c[i]];
}
int main()
{
    scanf("%d%s",&n,s+1),x=n*n;
    for(int i=1,u,v;i<n;i++)scanf("%d%d",&u,&v),b[i<<1]=a[u],c[a[u]=i<<1]=v,b[i<<1|1]=a[v],c[a[v]=i<<1|1]=u;
    for(int i=1;i<=n;i++)if(dfs(i,0),!f[i]&&g[i]>>1<x)x=g[i]>>1;
    return 0&printf("%d\n",x==n*n?-1:x);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
using namespace std;
typedef long long ll;

vector<pair<int, int>> to[100010];
bool visited[100010];
ll dist[100010];
int main() {
    int n,m,k;
    cin>>n>>m>>k;
    vector<ll>a(n);
    vector<ll>b(m);
    rep(i,0,n)cin>>a[i];
    ll t = 0;
    int j = 0;
    rep(i,0,m){
        cin>>b[i];
        t+=b[i];
        j++;
        if(t>k){
           t-=b[i];
           j--;
           break;
        }
    }
    int ans = 0;
    rep(i,0,n+1){
        while( j>0 && t>k){
            j--;
            t-=b[j];
        }
         
        if(t>k)break;
        t+=a[i];
        ans = max(ans, i+j);
        if(i==n)break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8812
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long s = sc.nextLong();
        if (n < s) {
            System.out.println(-1);
            return;
        }
        if (n == s) {
            System.out.println(n + 1);
            return;
        }
        for (long b = 2; b * b <= n; b++) {
            if (f(b, n) == s) {
                System.out.println(b);
                return;
            }
        }
        long ans = 1000_000L;
        boolean found = false;
        for (long p = 1; p * p < n; p++) {
            if ((n - s) % p != 0) continue;
            long b = (n - s) / p + 1;
            if (f(b, n) == s) {
                found = true;
                ans = b;
            }
        } 
        if (found) System.out.println(ans);
        else System.out.println(-1);
    }

    public static long f(long b, long n) {
        if (n < b) return n;
        return f(b, n / b) + n % b;
    }
}

Measured memory_bytes: 21844