akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(), (v).end()

int main(){
    int n,m;
    cin >> n >> m;
    int a[m];
    rep(i,m) { 
        cin>>a[i];
    }
    int sum = 0;
    rep(i,m){
        sum += a[i];
    }
    int ans = -1;
    if(n-sum >= 0){
        ans = n- sum;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define pb push_back
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;

int main()
{
  int h, n, a, sum = 0;
  cin >> h >> n;
  rep(i, n)
  {
    cin >> a;
    sum += a;
  }
  if (sum < h)
  {
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		boolean flag = true;
		ArrayList<Integer> x = new ArrayList<>();
		ArrayList<Integer> y = new ArrayList<>();
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X_ = sc.nextInt();
		int Y_ = sc.nextInt();
		for(int i=0;i<N;++i){
			x.add(sc.nextInt());
		}
		for (int i = 0; i < M; ++i) {
			y.add(sc.nextInt());
		}
		String ans = "War";
		int Z = Collections.max(x)+1;
		int ymin = Collections.min(y);
		if(X_<Z && Z<=Y_ && ymin>=Z){
			ans = "No War";
		}
		System.out.println(ans);
	}
}



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

int main(){
    int N,K;
    cin>>N>>K;
    vector<int>H(N);
    for(int i=0;i<N;i++){
        cin>>H[i];
    }
    sort(H.begin(),H.end());
    int Min=H[K-1]-H[0];
    for(int i=1;i<=N-K;i++){
        Min=min(Min,H[i+K-1]-H[i]);
    }
    cout<<Min<<endl;
}


Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
	int n;
	cin >>n;
	for (int i = 1; i < 10; i++){
		for (int j = 1; j < 10; j++){
			if (i*j == n){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
//============================================================================
// Name        : AOJ1180.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;

void sortASC(int a[], int b[], int n) {
	int i, j, min_i, tmp;
	for (i = 0; i < n; i++)
		b[i] = a[i];
	for (i = 0; i < n - 1; i++) {
		min_i = i;
		for (j = i + 1; j < n; j++) {
			if (b[min_i] > b[j])
				min_i = j;
		}
		if (min_i != i) {
			tmp = b[i];
			b[i] = b[min_i];
			b[min_i] = tmp;
		}
	}
	return;
}

void sortDSC(int a[], int b[], int n) {
	int i, j, max_i, tmp;
	for (i = 0; i < n; i++)
		b[i] = a[i];
	for (i = 0; i < n - 1; i++) {
		max_i = i;
		for (j = i + 1; j < n; j++) {
			if (b[max_i] < b[j])
				max_i = j;
		}
		if (max_i != i) {
			tmp = b[i];
			b[i] = b[max_i];
			b[max_i] = tmp;
		}
	}
	return;
}

void sub(int a[], int b[], int c[], int n) {
	int i;
	for (i = 0; i < n; i++)
		c[i] = a[i];
	for (i = n - 1; i > 0; i--) {
		c[i] = c[i] - b[i];
		if (c[i] < 0) {
			c[i - 1]--;
			c[i] += 10;
		}
	}
	c[0] -= b[0];
	return;
}

int main() {
	int flag, inp, i, j, k, L, count, *a[21], *aA, *aD;
	scanf("%d %d", &inp, &L);
	while (inp != 0 || L != 0) {
		for (i = 0; i <= 20; i++)
			a[i] = (int *) malloc(sizeof(int) * L);
		aA = (int *) malloc(sizeof(int) * L);
		aD = (int *) malloc(sizeof(int) * L);
		for (i = L - 1; i >= 0; i--) {
			a[0][i] = inp % 10; /* 入力された値を配列形式にして代入 */
			inp /= 10;
		}
		sortDSC(a[0], aA, L);
		sortASC(a[0], aD, L);
		flag = 0;
		for (i = 1; flag == 0 && i <= 20; i++) {
			sub(aA, aD, a[i], L);
			sortDSC(a[i], aA, L);
			sortASC(a[i], aD, L);
			for (j = 0; j < i && flag == 0; j++) {
				count = 0;
				for (k = 0; k < L; k++) {
					if (a[i][k] == a[j][k])
						count++; /*一致した配列の数を数える*/
				}
				if (count == L)
					flag = 1;
			}
		}
		i--;
		j--;
		printf("%d ", j);
		count = 0;
		for (k = 0; k < L; k++) {
			if (a[i][k] == 0)/* ０の数を数える */
				count++;
		}
		if (count == L)
			printf("0");
		else {
			for (k = 0; k < L; k++) {
				if (a[i][k] != 0) {
					while (k < L) {
						printf("%d", a[i][k]);
						k++;
					}
				}
			}

		}
		printf(" %d\n", i - j);
		scanf("%d %d", &inp, &L);
	}
	return 0;
}

Measured memory_bytes: 1084
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<map>
#include<stack>
#include<cstdlib>
#include<cstring>
#include<algorithm>

using namespace std;

int main(void){
	int n;
	
	while(scanf("%d", &n) && n ){
		int ans = 0;
		
		for(int i = n+1; i <= 2*n; i++){
			bool flg = true;
			for(int j = 2; j*j <= i; j++){
				if(i%j == 0){
					flg = false;
					break;
				}
			}
			if(flg){
				ans++;
			}
		}
		printf("%d\n", ans);
	}
	
	
	return 0;
}

Measured memory_bytes: 872
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <string>
using namespace std;

int main(void)
{
    //float f;
    string s;
    int m,n,o;
    //vector <float> f(10);
    //char a,b,c;
    int i=0,j,sum=0,z=0;
    //long long int m,n,o,total=0;
    cin>>m;
    for(i=1;i<=m;i+=2)
    {
        sum=0;
        for(j=1;j*j<i;j++)
            if(i%j==0) sum++;
        if(sum==4) z++;
    }
    cout<<z;
    return 0;
}



Measured memory_bytes: 256
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my ($n, $a, $b, $c, $d) = split / /, <STDIN>);
chomp (my $s = <STDIN>);
if (index(substr($s, 0, max($c, $d)), '##', min($a, $b)) != -1) {
  say "No";
  exit;
}
if ($c < $d) {
  say "Yes";
} elsif (index(substr($s, 0, min($c, $d)+1), '...', max($a, $b)-2) != -1) {
  say "Yes";
} else {
  say "No";
}

Measured memory_bytes: 1280
using System;
 
class Sample{
	public static void Main(){
      int temp;
      temp=int.Parse(System.Console.ReadLine());
      if(temp==25){System.Console.WriteLine("Christmas");}
      else if(temp==24){System.Console.WriteLine("Christmas Eve");}
      else if(temp==23){System.Console.WriteLine("Christmas Eve Eve");}
      else if(temp==22){System.Console.WriteLine("Christmas Eve Eve Eve");}
    }
}

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

using namespace std;

const int MOD = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> A(N + 1, 0);
  for (int i = 0; i < M; i++) {
    int a;
    cin >> a;
    A[a] = -1;
  }
  A[0] = 1;
  for (int i = 0; i < N; i++) {
    if (A[i] == -1) continue;
    if (i + 1 < N + 1 && A[i + 1] != -1) A[i + 1] = (A[i + 1] + A[i]) % MOD;
    if (i + 2 < N + 1 && A[i + 2] != -1) A[i + 2] = (A[i + 2] + A[i]) % MOD;
  }
  cout << A[N] << '\n';
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long N, i, j, K, dp[200001] = {0}, a[200001] = {0};
	cin >> N >> K;
	for(i = 0; i < N; i++)
	{
		cin >> a[i];
		dp[i] = 100000000000000;
	}
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for(i = 2; i < N; i++)
	{
		for(j = 1; j <= K && (i - j >= 0); j++)
			dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
	}
	cout << dp[N - 1];
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    int N, M;
    cin >> N >> M;

    vector<bool> isAlreadyAC(N, false);
    vector<int> waList(N, 0);

    int p;
    string result;
    for (int i = 0; i < M; i++)
    {
        cin >> p >> result;
        p--;
        if (result == "AC")
        {
            isAlreadyAC[p] = true;
        }
        else
        {
            if (isAlreadyAC[p] == false)
            {
                waList[p]++;
            }
        }
    }

    int ac = 0;
    int wa = 0;
    for (int i = 0; i < N; i++)
    {
        if (isAlreadyAC[i] == true)
        {
            ac++;
            wa += waList[i];
        }
    }

    cout << ac << " " << wa << endl;
    return (0);
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
#include<limits>

int a[105];
int n;

int fun(int x){
    int res=0;
    for(int i=0;i<n;i++){
        res+=(pow(a[i]-x,2));
    }
    return res;
}

int main(){
    int res=2100000000;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=-200;i<=200;i++){
       res=min(res,fun(i));
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int n, m, c;
    cin>>n>>m>>c;
    int a[n+5][m+5];
    int b[m+5];
    int i, j;
    FOR0(i, m) cin>>b[i];
    FOR0(i, n) FOR0(j, m) cin>>a[i][j];
    int ans = 0;
    FOR0(i, n)
    {
        int cur = c;
        FOR0(j, m)
        {
            cur += b[j]*a[i][j];
        }
        if(cur > 0) ans ++;
    }
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main()
{
    int n;
    cin >> n;
    vector<char> s(n), t(n);
    rep(i, n)
    {
        cin >> s[i];
    }
    rep(i, n) cin >> t[i];
    rep(i, n)
    {
        cout << s[i] << t[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	R, G, B, N := ReadInt(), ReadInt(), ReadInt(), ReadInt()
	c := 0
	for r := 0; R*r <= N; r++ {
		for g := 0; G*g <= N; g++ {
			remaining := N - R*r - G*g
			if remaining >= 0 && remaining%B == 0 {
				c++
			}
		}
	}
	fmt.Println(c)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1868
#include<bits/stdc++.h>
using namespace std;
#define int long long  
#define mod 1000000007
#define am 998244353
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){ 
  int c=max(a,b)-min(a,b);
  return c;
}
int gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for(int i=3;i<=sqrtNum;i+=2){
    if(num%i==0){
      return false;
    }
  }
}
int lcm(int a,int b){//最小公倍数
    return (a*b)/gcd(a,b);
}	    
signed main(){
// __builtin_ctz(N);      Nを２で何回割り切れるかを返す
//(n+1)*n/2;              １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    string b[10000];
    int a,c=0;
    cin>>a;
    for(int i=0;i<a;i++) cin>>b[i];
    for(int i=1;i<a;i++){
	if(b[i-1][b[i-1].size()-1]!=b[i][0]) c=1;
    }
    for(int i=0;i<a;i++){
	for(int j=i+1;j<a;j++){
	    if(b[i]==b[j]) c=1;
	}
    }
    if(c) cout<<"No";
    else cout<<"Yes";
    cout<<"\n";
}



Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <math.h>
using namespace std;

int timecheck( int time ) {
  if ( time % (60*24) >= 60*6 && time % (60*24) < 60*18 ) return 0;
  return 1;
}

int main() {

    while(true) {

      int s,n,t,p,m;
      string week_input,time_input;
      cin >> s >> n >> t >> week_input >> time_input >> p >> m;
      if ( s == 0 ) break;

      int week;
      if ( week_input == "Sun" ) {
	week = 0;
      }else if ( week_input == "Mon" ) {
	week = 1;
      }else if ( week_input == "Tue" ) {
	week = 2;
      }else if ( week_input == "Wed" ) {
	week = 3;
      }else if ( week_input == "Thu" ) {
	week = 4;
      }else if ( week_input == "Fri" ) {
	week = 5;
      }else if ( week_input == "Sat" ) {
	week = 6;
      }

      int timer = 0;
      if ( time_input == "Night" ) timer = 1;

      int cnt_max = 0;
      for ( int i = 0; i < 60*24*7; i++ ) {
	int time = i;

	int cnt = 0;
	for ( int j = 0; j < m; j++ ) {
	  time = ( time + t ) % ( 60 * 24 * 7 );
	  if ( week_input != "All" ) {
	    if ( time / (60*24) != week || ( (time+s) / (60*24) ) %7 != week ) continue;
	  }

	  if ( time_input != "All" ) {
	    if ( timecheck( time ) != timer || timecheck( time+s ) != timer ) continue;
	  }

	  cnt++;
	}

	cnt_max = max( cnt_max, cnt );
      }

      double q = 1.0 - 1.0/p;
      printf("%.10lf\n", 1 - pow(q, n * cnt_max));

    }
    return 0;
}

Measured memory_bytes: 1320
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#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 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)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    int i=0;
    while(n!=1){
      i++;
      if(n%2)n=3*n+1;
      else   n/=2;
    }
    cout<<i<<endl;
  }
}

Measured memory_bytes: 3000
#include <climits>
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define min(a, b) (a > b ? b : a)

int main() {
    int m, n;
    while (std::cin >> m >> n && m != 0 && n != 0) {
        int tb[n][n][2];

        rep(i, n) rep(j, n) tb[i][j][0] = tb[i][j][1] = tb[j][i][0] =
            tb[j][i][1] = (i == j ? 0 : INT_MAX / 3);
        rep(i, m) {
            int f, t, c, tm;
            std::cin >> f >> t >> c >> tm;
            f--;
            t--;
            tb[f][t][0] = tb[t][f][0] = c;
            tb[f][t][1] = tb[t][f][1] = tm;
        }
        rep(x, n) rep(y, n) rep(z, n) rep(i, 2) tb[z][y][i] = tb[y][z][i] =
            min(tb[y][z][i], tb[y][x][i] + tb[x][z][i]);

        int k;
        std::cin >> k;
        rep(i, k) {
            int s, e, q;
            std::cin >> s >> e >> q;
            s--;
            e--;
            std::cout << tb[s][e][q] << std::endl;
        }
    }
}

Measured memory_bytes: 3120
package main

import (
  "fmt"
  "sort"
)

func main() {
  var k, n int
  fmt.Scanf("%d %d", &k, &n)
  a := make([]int, n)
  for i:=0; i<n; i++ {
    fmt.Scan(&a[i])
  }
  
  d := make([]int, 0)
  d = append(d, k-a[n-1]+a[0])
  for i:=1; i<n; i++ {
    d = append(d, a[i]-a[i-1])
  }
  
  r := 0
  sort.Ints(d)
  for i:=0; i<n-1; i++ {
    r += d[i]
  }
  
  fmt.Println(r)
}

Measured memory_bytes: 9984
# AtCoder Beginner Contest 125
# https://atcoder.jp/contests/abc125
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main(N, An):
    n0 = An[0]
    n1 = -An[0]
    for i in range(1, N-1):
        n0t = max(n0 + An[i], n1 - An[i])
        n1t = max(n0 - An[i], n1 + An[i])
        n0 = n0t
        n1 = n1t
    n0 += An[N-1]
    n1 -= An[N-1]
    print(max(n0, n1))

N = i2n()
An = i2nn()
main(N, An)


Measured memory_bytes: 15540
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	vector<int> a(5);
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < 5; i++) {
		if (a[i] == 0)
			cout << i + 1 << endl;;
	}
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)

int main() {
    int N,K; cin >> N >> K;
    cout << (N % K ? 1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
var lines = [];

var N, A, B, C;
var l;
var ans = Infinity;

var readline = require("readline");

var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

rl.on('line', function (x) {
  lines.push(x);
});

rl.on('close', function () {
  N = Number(lines[0].split(" ")[0])
  A = Number(lines[0].split(" ")[1])
  B = Number(lines[0].split(" ")[2])
  C = Number(lines[0].split(" ")[3])

  lines.shift();

  l = lines.map(i => Number(i));
  dfs(0, [])
  console.log(ans);
});

// 利用する竹は,「A,B,C,使わない」の4択
// 4^8で間に合うと思う

function dfs(n, comb) {
  if (n === N) { calc(comb); }

  else {
    //　0: Aに利用　　1: Bに利用
    //　2: Cに利用　　3: 使わない

    for (var i = 0; i < 4; i++) {
      comb[n] = i; dfs(n + 1, comb)
    }
  }
}

function calc(comb) {
  var Ax = 0, Bx = 0, Cx = 0;
  var MP = 0;

  for (var i = 0; i < N; i++) {
    switch (comb[i]) {
      case 0: if (Ax !== 0) { MP += 10; } Ax += l[i]; break;
      case 1: if (Bx !== 0) { MP += 10; } Bx += l[i]; break;
      case 2: if (Cx !== 0) { MP += 10; } Cx += l[i]; break;
    }
  }
  // 竹の長さ0から伸ばすことは無理
  if (Ax === 0 || Bx === 0 || Cx === 0) { return (0) }
  else {
    MP += Math.abs(A - Ax) + Math.abs(B - Bx) + Math.abs(C - Cx);
    ans = Math.min(ans, MP);

  }
}

Measured memory_bytes: 7992
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    int x;
    cin >> x;
    vector<bool> expo(x + 1);
    expo[1] = 1;
    for (int b = 2; b <= x; b++)
    {
        int v = b * b;
        while (v <= x)
        {
            expo[v] = 1;
            v *= b;
        }
    }
    for (int i = x; x >= 1; i--)
    {
        if (expo[i] == 1)
        {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
vector<int> h, memo;

// int dp(int n) {
//     if (memo[n] != -1) {
//         return memo[n];
//     }
//     if (n == 0) {
//         return 0;
//     }
//     if (n == 1) {
//         return abs(h[1] - h[0]);
//     }
//     memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
//     return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
// }

signed main() {
    int a, b;
    cin >> a >> b;
    cout << max(a - b, 0) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
int main(){
  int c;
  int cnt[500]={0};
  while(c!=EOF){
    c=getchar();
    if(islower(c)){
      cnt[c]++;
    }else{
      cnt[c+32]++;
    }
  }
  for(c='a';c<='z';c++){
    printf("%c : %d\n",c,cnt[c]);
  }
  return 0;
}

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

#define ll long long int
#define str string

ll MOD = 1000000007,INFL = 1ll << 60,INF = 1 << 30;
ll A[10000000] = {}, X[1000000] = {};
ll aiti[10000];
int dy[]={0, 0, 1, -1},dx[]={1, -1, 0, 0};
vector <ll> v;
ll a = 0,b = 0,c = 0,n = 0,sum = 0, max = INF;
str S;
int ans = 0;

int findDigits(int n) {
        int i = 0;
        while (n > 0) {

                sum += n%10;
                n /= 10;
                i++;
        }
        return i;
}


int main(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        //Code Line
cin >> n;
for(int i = 0;i < n;i++)cin >> S;
for(int i = 0;i < n;i++){
  if(S[i] == 'R')sum++;
  else ans++;
}
if(sum > ans)cout << "Yes" << endl;
else cout << "No" << endl;
  //Code Line
        return 0;
}


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

int main(){
    int moke;
    std::cin >> moke;
    std::vector<unsigned long long int> lucas;
    lucas.push_back(2);
    lucas.push_back(1);

    for(int i = 2; i <= moke; ++i){
        lucas.push_back(lucas[i-2] + lucas[i-1]);
    }
    std::cout << lucas[moke];

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
#define pii pair<int , int>
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
const int INF = 1000 * 1000 * 1000 + 7;
const ll LINF = INF * (ll)INF;
int k;
string n;
ll dpT[105][4][2];
ll dp(int id , int cnt , int vpr)
{
	
	if(cnt == k)
		return 1;
	if(id == sz(n))
		return 0;
	if(dpT[id][cnt][vpr] != -1)
		return dpT[id][cnt][vpr];
	ll ans = 0;
	int bound = vpr ? (n[id] - '0') : 9;
	for(int i = 0; i <= bound; i++)
	{
		
		ans += dp(id + 1 , cnt + (i != 0) , vpr & (i == n[id] - '0'));
	}
	return dpT[id][cnt][vpr] = ans;
}
int main()
{
	memset(dpT , -1 , sizeof dpT);
	
	cin >> n >> k;
	cout << dp(0 , 0 , 1);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* 答えをにぶたんで狭めていく系 */

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

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

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

    REP(i, n/2) {
        if(s[i] == s[i+n/2]) {

        } else {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        int zeroCount = 0;
        int oneCount = 0;
        for(char ch : S.toCharArray()) {
            if (ch == '0') zeroCount++;
            if (ch == '1') oneCount++;
        }
        System.out.println(Math.min(zeroCount, oneCount) * 2);
    }
}

Measured memory_bytes: 26732
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>


typedef long long LL;
using namespace std;
 
void read(int &v) {
    int k = 0, l = 1;
    char ch;
    ch = getchar();
    while (ch > '9' || ch < '0') {
        if (ch == '-')
            l = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') k = k * 10 + ch - '0', ch = getchar();
    v = l * k;
}

void print(int v) {
    if (v < 0)
        putchar('-'), v = -v;
    if (v > 9)
        print(v / 10);
    putchar(v % 10 + '0');
}

int max(int a, int b) {
        return a > b ? a : b;
}

int min(int a, int b) {
        return a < b ? a : b;
}

static int n, d;

int main() {
        read(n), read(d);
        d = (d << 1) + 1;
        print((n + d - 1) / d);
        return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define N 10000
int isprime(int);
int main()
{
  int n,i,count=0,x,a;
  int array[N];

  scanf("%d",&n);

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

  for(i=0;i<n;i++)
    {
      x=array[i];
      a=isprime(x);
      if(a==1)
	{
	  count=count+1;
	}
    }
 
  printf("%d\n",count);
  return 0;
}

int isprime(int x){
  int i;
  if(x==2) return 1;
  else if(x<2||x%2==0) return 0;
  for(i=3;i<=sqrt(x);i++)
    {
      if(x%i==0) return 0;
    }
  return 1;
}

Measured memory_bytes: 628
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()
	count := make([]int, n)
	red := make([]int, n)
	for i := 0; i < n; i++ {
		count[i] = 1
		red[i] = 0
	}
	red[0] = 1

	for i := 0; i < m; i++ {
		from := nextInt() - 1
		to := nextInt() - 1

		if red[from] == 1 {
			red[to] = 1
		}
		count[from]--
		count[to]++
		if count[from] == 0 {
			red[from] = 0
		}
	}
	sum := 0
	for i := 0; i < n; i++ {
		if red[i] == 1 {
			sum++
		}
	}
	fmt.Println(sum)

}

func readInput() string {
	sc.Scan()
	buf := sc.Text()
	return buf
}

func nextInt() int {
	n, err := strconv.Atoi(readInput())
	if err != nil {
		panic(err)
	}
	return n
}

func nextString() string {
	return readInput()
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, x[50], y[50];

int main() {
	cin >> n;
	inc(i, n) { cin >> x[i] >> y[i]; }
	
	int ans = n;
	inc(i, n) {
	inc(j, n) {
		if(i == j) { break; }
		
		int c = n;
		inc(ii, n) {
		inc(jj, n) {
			if(x[ii] - x[jj] == x[i] - x[j] && y[ii] - y[jj] == y[i] - y[j]) { c--; }
		}
		}
		setmin(ans, c);
	}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  string S;
  cin >> S;
  reverse(S.begin(), S.end());

  ll foo = 0;
  ll bar = -1;

  for (auto c: S) {
    ll num = c - '0';
    ll next_foo = min(foo + num, bar + num + 1);
    ll next_bar = foo + 10 - num;
    if (bar >= 0) next_bar = min(foo + 10 - num, bar + 10 - (num + 1));
    foo = next_foo;
    bar = next_bar;
  }

  ll ans = min(foo, bar + 1);
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


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

using namespace std;

int main() {
    int N, D;
    cin >> N >> D;

    int ans = 0;
    for(int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        if(sqrt(pow(x, 2) + pow(y, 2)) <= D) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int que = sc.nextInt();


        int[][] sum = new int[n + 1][n + 1];
        for (int i = 0; i < m; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            sum[l][r]++;
        }

        List<Integer> p = new ArrayList<>();
        List<Integer> q = new ArrayList<>();
        for (int i = 0; i < que; i++) {
            p.add(sc.nextInt());
            q.add(sc.nextInt());
        }

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                sum[i][j] += sum[i - 1][j];
                sum[i][j] += sum[i][j - 1];
                sum[i][j] -= sum[i - 1][j - 1];
            }
        }

        for (int i = 0; i < que; i++) {
            int ans = sumRange(sum, p.get(i), q.get(i));
            System.out.println(ans);
        }
    }
    public static int sumRange(int[][] sum, int l, int r) {
        int ans = sum[r][r] - sum[r][l - 1] - sum[l - 1][r] + sum[l - 1][l - 1];
        return ans;
    }
}


Measured memory_bytes: 166448
from collections import Counter
N=int(input())
blue = Counter([input() for i in range(N)])
M=int(input())
red = [input() for i in range(M)]
for i in red:
    if i in blue:
        blue[i] -=1
ans = 0
for i in blue.values():
    if ans < i:
        ans = i
print(ans)

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

int main() {
int a,b;
cin>>a>>b;
if(a<0&&b<0&&(b-a)%2==0)
{
cout<<"Negative";
}
else if((a<0&&b<0&&(b-a)%2!=0)||(a>0&&b>0))
cout<<"Positive";
else if(a<=0&&b>=0||a>=0&&b<=0)
cout<<"Zero";
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
from math import sqrt


def f(b, n):
    if n < b:
        return n
    else:
        return f(b, int(n / b)) + n % b


n = int(input())
s = int(input())

if n < s:
    print(-1)
    quit()
if n == s:
    print(n+1)
    quit()

for b in range(2, int(sqrt(n))+1):
    if f(b, n) == s:
        print(b)
        quit()

for p in reversed(range(1, int(sqrt(n)+1))):
    if (n - s) % p == 0:
        b = int((n - s) / p + 1)
        if f(b, n) == s:
            print(b)
            quit()

print(-1)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        int cost = 0;

        for(int i = 0; i < n; i++){
            int tempcost = sc.nextInt();
            int temptime = sc.nextInt();
            if(t >= temptime){
                if(cost > tempcost || cost == 0) {
                    cost = tempcost;
                }
            }
        }

        if(cost == 0){
            System.out.println("TLE");
        }
        else {
            System.out.println(cost);
        }
    }
}


Measured memory_bytes: 23636
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a==1)
	 switch(b)
	  {case 2 :cout<<"3";break;
	   default  :cout<<"2";
	  }
	else if(a==2)
	 switch(b)
	  {case 1 :cout<<"3";break;
	   default  :cout<<"1";
	  }
	else if(a==3)
	 switch(b)
	  {case 1 :cout<<"2";break;
	   default  :cout<<"1";
	  }
	return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>

#pragma warning(disable : 4996)

using namespace std;

int N, M, K, A, B, L;

vector<vector<pair<int, int> > > G;

vector<int> P, D;

int main()
{
	scanf("%d", &N);
	scanf("%d", &M);
	scanf("%d", &K);

	G = vector<vector<pair<int, int> > >(N);

	for (int i = 0; i < M; i++)
	{
		scanf("%d", &A);
		scanf("%d", &B);
		scanf("%d", &L);

		G[A - 1].push_back(make_pair(B - 1, L));
		G[B - 1].push_back(make_pair(A - 1, L));
	}

	P = vector<int>(K);

	for (int i = 0; i < K; i++)
	{
		scanf("%d", &P[i]); P[i]--; // 0 - indexed
	}

	D = vector<int>(N, 999999999);

	for (int i = 0; i < K; i++)
	{
		priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;

		que.push(make_pair(0, P[i])); D[P[i]] = 0;

		while (!que.empty())
		{
			int dist = que.top().first;
			int node = que.top().second; que.pop();

			for (int j = 0; j < G[node].size(); j++)
			{
				int node2 = G[node][j].first;
				int leng2 = G[node][j].second;

				if (D[node2] > D[node] + leng2)
				{
					D[node2] = D[node] + leng2;

					que.push(make_pair(D[node2], node2));
				}
			}
		}
	}

	int ret = 0;

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < G[i].size(); j++)
		{
			ret = max(ret, D[i] + D[G[i][j].first] + G[i][j].second);
		}
	}

	printf("%d\n", (ret + 1) / 2);

	return 0;
}

Measured memory_bytes: 5988
#include<stdio.h>
int main()
{
	int N;
	scanf("%d",&N);
	int p[N];
	int i;
	int f=0;
	for (i=1;i<=N;i++)
	{
		scanf("%d",&p[i]);
		if (p[i]!=i) f++;
	}
	if (f>2)
	{
		printf("NO");	
	}
	else
	{
		printf("YES");
	}
return 0;
}

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

int main(){
	long long int price,a,b,n,month;
	bool judge;
	while(cin >> n && n){
		price = 0;
		judge = false;
		for(int i = 0;i< 12 ;i++){
			cin >> a >> b;
			price += (a-b);
			if(price >= n && judge == false) {
				month = i + 1;
				judge = true;
			}
		}
		if(judge == true) cout << month << endl;
		else cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import numpy as np
N = int(input())
k = 1
while k*k < 2*N:
    k += 1
if k*(k - 1) != 2*N:
    print('No')
else:
    print('Yes')
    print(k)
    S = np.zeros([k, k-1], dtype=int)
    max = int(0)
    for i in range(k-1):
        S[i, i:] = list(range(max+1, max+k-i))
        S[i+1:, i] = S[i, i:]
        max += k-i-1
    for i in range(k):
        print(' '.join(map(str, np.insert(S[i], 0, k-1))))

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

char a[50][50];
int c,d,b[55][55];

int main()
{
    cin>>c>>d;
    for(int i=0;i<c;i++)
    cin>>a[i];
    for(int i=0;i<c;i++)
    for(int j=0;j<d;j++)
    if(a[i][j]=='#')
    b[i][j]++,b[i][j+1]++,b[i][j+2]++,
    b[i+1][j]++,b[i+1][j+1]++,b[i+1][j+2]++,
    b[i+2][j]++,b[i+2][j+1]++,b[i+2][j+2]++;
    for(int i=0;i<c;i++)
    {
        for(int j=0;j<d;j++)
        if(a[i][j]=='#') cout<<'#';
        else cout<<b[i+1][j+1];
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;

int main() {
	int a[50] = {0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	cout << a[k] << endl;
}


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

using namespace std;

const long long MOD = 1000000007;
const long long MAX = 200000;

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
   int H,W;
   cin>>H>>W;
   char S[H][W];
   for(int i=0;i<H;i++){
       for(int j=0;j<W;j++){
           cin>>S[i][j];
       }
   }
   int maxx=-1;
   for(int a=0;a<H;a++){
       for(int b=0;b<W;b++){
           if(S[a][b]=='#'){
               continue;
           }
           int tmp=0;
           queue<pair<int,int> >ff;
           ff.push(make_pair(a,b));
           int flag[H][W];
           for(int i=0;i<H;i++){
               for(int j=0;j<W;j++){
                   flag[i][j]=-1;
               }
           }
           flag[a][b]=1;
           while(!ff.empty()){
               vector<pair<int,int> >ppp;
               while(!ff.empty()){
                   ppp.push_back(ff.front());
                   ff.pop();
               }
               int size=(int)ppp.size();
               for(int i=0;i<size;i++){
                   pair<int,int> ll=ppp[i];
               if(ll.first-1>=0){
                   if(flag[ll.first-1][ll.second]==-1&&S[ll.first-1][ll.second]=='.'){
                       ff.push(make_pair(ll.first-1,ll.second));
                       flag[ll.first-1][ll.second]=1;
                   }
               }
               if(ll.first+1<H){
                   if(flag[ll.first+1][ll.second]==-1&&S[ll.first+1][ll.second]=='.'){
                       ff.push(make_pair(ll.first+1,ll.second));
                       flag[ll.first+1][ll.second]=1;
                   }

               }
               if(ll.second-1>=0){
                   if(flag[ll.first][ll.second-1]==-1&&S[ll.first][ll.second-1]=='.'){
                       ff.push(make_pair(ll.first,ll.second-1));
                       flag[ll.first][ll.second-1]=1;
                   }
               }
               if(ll.second+1<W){
                   if(flag[ll.first][ll.second+1]==-1&&S[ll.first][ll.second+1]=='.'){
                       ff.push(make_pair(ll.first,ll.second+1));
                       flag[ll.first][ll.second+1]=1;
                   }
               }
                   flag[ll.first][ll.second]=1;
               }
               tmp++;


           }
           if(tmp>maxx){
               maxx=tmp;
           }

       }
   }
   cout<<maxx-1<<endl;







}


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

int main() {
    string S;
    cin >> S;

    set<char> st;
    for (char c='a'; c<='z'; ++c)
        st.insert(c);

    for (size_t i=0; i<S.size(); ++i) {
        st.erase(S[i]);
    }

    //for (auto &c: st) cout << c << ", ";
    //cout << endl;
    if (st.size() == 0) {
        cout << "None" << endl;
    }
    else {
        auto iter = st.begin();
        cout << *iter << endl;
    }
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 

// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }

const ll mod = 1e9+7;

class UnionFind{
public:
    //親の番号を格納する。親だった場合はー（その集合のサイズ）
    vector<int> parents;

    //作る時はparentsを-1で初期化する
    //こうすることで全部ばらばらになる
    UnionFind(int n){
        parents = vector<int>(n, -1);
    }

    //Aがどのグループにいるか調べる
    int root(int A){
        if(parents[A]<0) return A;
        return parents[A] = root(parents[A]);
    }

    //自分のいるグループの大きさを調べる
    int size(int A){
        return -parents[root(A)];
    }

    //AとBをくっつける
    bool connect(int A, int B){
        //AとBを直接ではなく親同士をくっつける
        A=root(A);
        B=root(B);
        if(A==B){
            return false;
        }

        //大きい方（A)に小さい方（B)をくっつけたい
        if(size(A)<size(B)) swap(A, B);

        parents[A] += parents[B];
        parents[B] = A;

        return true;
    }
};


class Edge {
    public:
    ll source, target, cost;
    Edge(ll source=0, ll target=0, ll cost=0):
    source(source), target(target), cost(cost){}
    bool operator < (const Edge &e) const{
        return cost < e.cost;
    }
};

ll kruskal(int N, vector<Edge> edges){
    ll totalCost = 0;
    sort(edges.begin(), edges.end());

    UnionFind uni(N);
    for(int i=0; i<edges.size(); i++){
        Edge e=edges[i];
        if(uni.root(e.source) != uni.root(e.target)){
            totalCost += e.cost;
            uni.connect(e.source, e.target);
        }
    }

    return totalCost;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
 
    int n; cin >> n;
    vector<pair<ll, int>> xi(n), yi(n);
    for(int i=0; i<n; ++i){
        cin >> xi[i].first >> yi[i].first;
        xi[i].second = i; yi[i].second = i;
    }

    vector<Edge> edge;
    sort(xi.begin(), xi.end());
    sort(yi.begin(), yi.end());
    for(int i=0; i<n-1; ++i){
        edge.push_back({xi[i].second, xi[i+1].second, xi[i+1].first-xi[i].first});
        edge.push_back({xi[i+1].second, xi[i].second, xi[i+1].first-xi[i].first});
        edge.push_back({yi[i].second, yi[i+1].second, yi[i+1].first-yi[i].first});
        edge.push_back({yi[i+1].second, yi[i].second, yi[i+1].first-yi[i].first});
    }

    cout << kruskal(n, edge) << endl;

    return 0;
}

Measured memory_bytes: 24552
n=int(input())
k=int(input())
l=[int(i) for i in "0"+str(n)]
# [0]=n [1]<n
dp=[[[0]*5,[0]*5] for i in "ww"]
dp[0][0][0]=1
for i,j in enumerate(str(n),start=1):
    for p in range(k+1):
        if dp[i%2-1][0][p]:
            dp[i%2][0][p+[0,1][l[i]>0]]=1
            for q in range(l[i]):
                dp[i%2][1][p+[0,1][q>0]]+=1
        if dp[i%2-1][1][p]:
            dp[i%2][1][p]+=dp[i%2-1][1][p]
            dp[i%2][1][p+1]+=dp[i%2-1][1][p]*9
    for p in range(10): dp[i%2-1][p//5][p%5]=0
print(dp[0][0][k]+dp[1][0][k]+dp[0][1][k]+dp[1][1][k])

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

int main(){
    int n;
    cin >> n;
    long long mod = 1000000007;

    long long num10 = 1;
    long long num9 = 1;
    long long num8 = 1;
    long long cnt10 = 0;
    long long cnt9 = 0;
    long long cnt8 = 0;

    rep(i,n){
        num10 *= 10;
        num9 *= 9;
        num8 *= 8;
        if(num10 >= mod){
            num10 %= mod;
            cnt10 ++;
        }
        if(num9 >= mod){
            num9 %= mod;
            cnt9 ++;
        }
        if(num8 >= mod){
            num8 %= mod;
            cnt8 ++;
        }
    }

    long long ans = num10 % mod;
    ans -= num9;
    ans += mod;
    ans %= mod;
    ans -= num9;
    ans += mod;
    ans %= mod;
    ans += num8;
    ans %= mod;

    cout << ans << endl;

}

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

int main(void)
{
	char buf[1005];
	int len;

	if (fgets(buf, sizeof(buf), stdin) == NULL)
      return (-1);
	len = strlen(buf);
	len--;
	if (buf[len - 1] == 's')
	{
		buf[len] = 'e';
		buf[len + 1] = 's';
		buf[len + 2] = '\0';
	}
	else
	{
		buf[len] = 's';
		buf[len + 1] = '\0';
	}
	printf("%s\n", buf);
	return (0);
}


Measured memory_bytes: 1516
import fractions
import collections
from collections import deque
import math
import itertools

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

ans=10000000
for i in range(1,101):
    tmp=0
    for j in range(N):
        tmp+=(i-X[j])**2
    ans=min(tmp,ans)
print(ans)

Measured memory_bytes: 5304
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define dump(x) cout << (x) << endl;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
  }
  int cnt = 0;
  rep(i, n) {
    while (a[i]%2 == 0) {
      cnt++;
      a[i] /= 2;
    }
  }
  dump(cnt);
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val height = readLine()!!.split(" ").map(String::toInt)

    val dp = Array<Int>(N) { 10000 }
    dp[0] = 0
    for (i in 1 until N) {
        dp[i] = dp[i - 1] + Math.abs(height[i] - height[i - 1])
        if (i >= 2) {
            dp[i] = Math.min(dp[i], dp[i - 2] + Math.abs(height[i] - height[i - 2]))
//            dp.joinToString(" ").let(::println)
        }
    }

    println(dp[N - 1])
}


Measured memory_bytes: 50024
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

int main() {
  int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
  int dx = x2-x1;
  int dy = (y2-y1) * -1;
  swap(dx, dy);
  int x3 = x2+dx, y3 = y2+dy;
  int x4 = x1+dx, y4 = y1+dy;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}


Measured memory_bytes: 3564
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
   
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, k;
	cin>>n>>k;
	ll x[100001];
	for(int i=0; i<n; i++){
		cin>>x[i];
	}
	ll ans=1e18;
	for(int i=0; i+k-1<n; i++){
		if(x[i]<0 && x[i+k-1]<0){
			ans=min(ans, abs(x[i]));
		}else if(x[i]>=0 && x[i+k-1]>=0){
			ans=min(ans, abs(x[i+k-1]));
		}else{
			ans=min(ans, 2*(x[i+k-1]-x[i])-max(-x[i], x[i+k-1]));
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024