akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int N;

  cin >> N;
  int A[N];
  vector<int> B;

  int tmp;
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    B.push_back(tmp);
  }
    
  int insert_pt = N - 1;
  int erase_pt = -1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j  < (int)B.size(); j++) {
      if (B[j] == j + 1)
	erase_pt = j;
    }
    if (erase_pt == -1) {
      cout << "-1" << endl;
      return 0;
    } else {
      A[insert_pt--] = B[erase_pt];
      B.erase(B.begin() + erase_pt);
      erase_pt = -1;
    }
  }

  for (int a : A)
    cout << a << endl;

  return 0;
}


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

#define maxn 10005
#define INF 0x3f3f3f3f
#define mod 1000000007
typedef long long ll;
using namespace std;


void slove()
{
	int a, b, c;
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << ' ' << b << ' ' << c << '\n';
}

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

	/*while (cin >> t)*/
	slove();

	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int c[3][n];
  int ans[n];
  for(int i = 0; i < n; i++){
    ans[i] = 0;
    for(int j = 0; j < 3; j++){
      cin >> c[j][i];
      ans[i] += c[j][i];
    }
  }
  for(int k = 0; k < 3; k++){
    for(int i = 0; i < n; i++){
      int el = c[k][i];
      int cnt = 0;
      for(int j = 0; j < n; j++){
        if(el == c[k][j])cnt++;
      }
      if(cnt > 1)ans[i] -= el;
    }  
  }
  for(int i = 0; i < n; i++)cout << ans[i] << endl;
}



Measured memory_bytes: 3112
N,A,B =list(map(int, input().split()))
S = input()
C = A+B
a_number = 0
b_number= 0
for i in S:
    if i == "a" and a_number< C:
        print("Yes")
        a_number = a_number+1
    elif i == "b" and a_number<C and b_number<B:
        print("Yes")
        a_number = a_number + 1
        b_number = b_number +1
    else:
        print("No")

Measured memory_bytes: 4016
#include <iostream>
#include <cstring>
#include <string>    
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll dp[100008][13];
ll MOD = 1e9+7;
string s;

int main(){
	cin >> s;
	ll n = s.size();
	for(ll j = 0; j < 13; j++){dp[0][j] = 0;}

	if(s[0] != '?'){dp[0][int(s[0])-int('0')] = 1;}
	else{for(ll j = 0; j < 10; j++){dp[0][j] = 1;}}

	for(ll i = 1; i < n; i++){
		for(ll j = 0; j < 13; j++){dp[i][j] = 0;}
		for(ll j = 0; j < 13; j++){
			if(s[i] != '?'){
				dp[i][(10*j+int(s[i])-int('0'))%13] += dp[i-1][j];
				dp[i][(10*j+int(s[i])-int('0'))%13] %= MOD;
			}
			else{
				for(ll k = 0; k < 10; k++){
					dp[i][(10*j+k)%13] += dp[i-1][j];
					dp[i][(10*j+k)%13] %= MOD;
				}
			}
		}
	}
	cout << dp[n-1][5] << endl;
	return 0;
}

Measured memory_bytes: 10624
using System;
using System.Linq;

public class Program
{
	public static void Main()
	{
        int[] i = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        Console.WriteLine((i[0]*i[1] <= i[2] * i[3]) ? i[2] * i[3] : i[0]*i[1]);
	}
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;

int main() {
  int n;
  cin>>n;
  vin a(n),b(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  ////////総和　少ない数をカウント
  ll aSum=0,bSum=0;
  bool ok=true;
  rep(i,n){
   aSum+=a[i];
   bSum+=b[i];
    
  }
  if(aSum<bSum) ok=false;
  ll cnt=0;
  ll husoku=0;
  priority_queue<int, vector<int>, less<int>> q;
  rep(i,n){
   if(a[i]<b[i]){
    cnt++; 
     husoku+=(b[i]-a[i]);
   }
   else{
    q.push(a[i]-b[i]);
    
   }
  }
  if(ok){
  while(husoku>0){
   cnt++; 
    husoku-=q.top();
    q.pop();
    
  }
  }
  
  if(ok) cout<<cnt<<endl;
  else cout<<-1<<endl;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);i++)
#define erep(i,l,r) for(int (i)=(l);(i)<=(r);i++)
using namespace std;
int main(){
    ll n;
    cin>>n;
    vector<ll> p(n);
    rep(i,0,n)cin>>p[i];
    ll ans=1,mi=p[0];
    rep(i,1,n){
        if(mi>p[i])ans++;
        mi=min(mi,p[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define ss second
#define ff first
#define w(x) ll x; cin>>x; while(x--)
#define pi acos(-1)
#define all(cont) cont.begin(), cont.end()
#define countbit(x) __builtin_popcount(x)
#define mod 1000000007
#define re(i,n) for(ll i=0;i<n;i++)
#define re1(i,n) for(ll i=1;i<n+1;i++)
#define de(n) ll n;cin>>n;
#define def(a,n) ll n;cin>>n;ll a[n];re(i,n){cin>>a[i];}
#define defi(a,n,k) ll n;cin>>n; ll k;cin>>k;ll a[n];re(i,n){cin>>a[i];}
#define deb(x) cout<<#x<<"="<<x<<endl;
#define tr(it,a) for(auto it=a.begin();it!=a.end();it++)
#define nl cout<<endl;
using namespace std;
//18-1326D1 1208B 845C 912B 1009B 1350C 20C 1333C 1234D 1327C 1305B 1304B (or in matrix) 1216-C(26) 21
void cp()
{
    ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); 
    #ifndef ONLINE_JUDGE  
    freopen("input.txt", "r", stdin);  
    freopen("output.txt", "w", stdout);
#endif
}
int main()
{
  cp();
  //w(x)
  {
    string s;
    cin>>s;
    int n=s.length()-1;
    if(s[n]=='s')
    {
      cout<<s<<"es"<<endl;
    }
    else
    {
      cout<<s<<"s"<<endl;
    }
  }
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        char[] ch = new char[s.length()];
        for(int i=0; i<ch.length; i++) {
            ch[i] = s.charAt(i);
        }
        for(int i=0; i<ch.length; i++) {
            int c = ch[i];
            if(c+n > 90) {
                c = c - 26 + n;
            } else {
                c = ch[i] + n;
            }
            System.out.print((char)(c));
        }
        System.out.println();
    }
}

Measured memory_bytes: 39192
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

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

    double N; cin >> N;
    double D; cin >> D;
    cout << ceil(N/(2.0*D+1.0)) << '\n';

    return 0;
}



Measured memory_bytes: 256
import scala.io.StdIn._
import scala.collection._

object Main {

  class Sieve(val n: Int){
    private[this] val top = (n - 3) / 2 + 1
    private[this] val cmpsts = new Array[Int]((top >>> 5) + 1)
    private[this] val sqrtLmtNdx = (Math.sqrt(n).toInt - 3) / 2

    def isPrime(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) == 0
    def setCmpst(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)

    private def innerLoop(j: Int, p: Int): Unit = {
      if(j <= top){
        setCmpst(j)
        innerLoop(j + p, p)
      }
    }

    private def loop(i: Int): Unit = {
      if(i <= sqrtLmtNdx){
        if(isPrime(i)){
          val p = 2 * i + 3
          innerLoop((p * p - 3) >>> 1, p)
        }
        loop(i + 1)
      }
    }

    private def next(i: Int): Int =
      if ((i > top) || isPrime(i)) 2 * i + 3 else next(i + 1)

    def exec: Iterator[Int] = {
      loop(0)
      Iterator.single(2) ++ Iterator.iterate(3)(p => next((p - 1) >>> 1)).takeWhile(_ <= n)
    }
  }

  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else println(new Sieve(n).exec.size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit = loop(readLine)
}

Measured memory_bytes: 65480
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
let katen = readInts()
let a = katen[0]
let b = katen[1]
let long = a - 2*b
if long >= 0 { 
  print(long) }
else {
  print(0)
}


Measured memory_bytes: 8324
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [0] * n
    dp[0] = 0
    dp[1] = abs(h[1] - h[0])
    for i in range(2, n):
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1])
        for j in range(2, min(i + 1, k + 1)):
            dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]), dp[i])
    print(dp[n - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 52448
#include <stdio.h>

int main () {

  int i,n,result;
  char a[100],b[100],c[100];

  scanf ("%d",&n);
  scanf("%s %s %s",a,b,c);

  result = 0;
  for (i=0;i<n;++i) {
     if (a[0+i]==b[0+i]) {
         if (a[0+i]!=c[0+i])result++;
     } else {
         if (a[0+i]==c[0+i]) {
           result++;
         } else {
           if (b[0+i]==c[0+i]) {
                result++;
           } else {
                result++ ;
                result++ ;
              }
           }
      }
  }

  printf ("%d\n",result);

  return 0;
}

Measured memory_bytes: 128
import collections
n = int(input())
a = sorted(list(map(int,input().split())))
b = set(a)
c = collections.Counter(a)
x = 0
for i in b:
    if c[i]%2==0:x+=1
ans = len(b)
if x%2==1:ans-=1
print(ans)

Measured memory_bytes: 68268
n, m = gets.chomp.split.map(&:to_i)
c = Hash.new(0)
m.times do |_|
  a, b = gets.chomp.split.map(&:to_i)
  c[a] += 1
  c[b] += 1
end

n.times do |i|
  puts c[i + 1]
end

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n,k;
llong T[MAX];

int check(llong P)
{
  int i=0;
  for (int j=0;j<k;j++)
    {
      llong s=0;
      while(s+T[i]<=P)
	{
	  s+=T[i];
	  i++;
	  if(i==n) return n;
	}
    }
  return i;
}

int solve()
{
  llong left=0;
  llong right = 100000*10000;
  llong mid;
  while(right-left>1)
    {
      mid=(left+right)/2;
      int v=check(mid);
      if(v>=n) right = mid;
      else left = mid;
    }
  return right;
}

main()
{
  cin >> n >> k;
  for (int i=0;i<n;i++) cin >> T[i];
  llong ans = solve();
  cout << ans << endl;
}
      



Measured memory_bytes: 3904
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const int MOD = 1000000007;
typedef pair<long long,long long> P;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



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

    long long N;cin >> N;
    long long X,M;cin >> X >> M;
    //余りのループを探す
    vector<bool> remainder(100005);
    vector<long long> trase;
    long long now = X;
    long long loop = -1;
    while(true){
        if(remainder.at(now)){
            trase.push_back(now);
            loop = now;
            break;
        }
        remainder.at(now) = true;
        trase.push_back(now);
        now *= now;
        now %= M;
        //cout << now << endl;
    }
    //cout << endl;
    vector<long long> beforeLoop_rui(1);
    long long loopIndex = 0;
    for(long long i = 0;i<trase.size();i++){
        if(trase.at(i) == loop){
            loopIndex = i;
            break;
        }
        beforeLoop_rui.push_back(beforeLoop_rui.at(i)+trase.at(i));
    }
    //ループ入る前にN回終わる時
    if(N <= loopIndex){
        cout << beforeLoop_rui.at(N) << endl;
        return 0;
    }
    N -= loopIndex;
    long long ans = beforeLoop_rui.back();
    vector<long long> loop_rui(1);
    for(long long i = loopIndex;i<trase.size();i++){
        if(i > loopIndex && trase.at(i) == loop){
            break;
        }
        loop_rui.push_back(loop_rui.at(i-loopIndex)+trase.at(i));
        //cout << loop_rui.back() << endl;
    }
    ans += loop_rui.back()*(N/(loop_rui.size()-1))+loop_rui.at(N%(loop_rui.size()-1));
    cout << ans << endl;
}

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

const int MOD = 1e9 + 7;
const int MAX = 500005;
int arr[MAX];

int main() {

//    freopen("in.txt","rt",stdin);
//    freopen("out.txt","wt",stdout);
    int n;
    string str;
    cin >> n >> str;
    for (auto &i:str)arr[i]++;
    long long ans = 1;
    for (int i = 'a'; i <= 'z'; i++) {
//        cout<<arr[i]<<endl;
        ans *= arr[i] + 1;
        ans %= MOD;
    }
    ans += MOD - 1;
    ans %= MOD;
    cout << ans << endl;
}



Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 1012345678
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    vector<vector<int>> dp(N * 10 + 1, vector<int>(N * 10 + 1, INF));
    dp[0][0] = 0;
    for (int i = 1; i <= N; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        for (int j = N * 10; j >= 0; j--)
        {
            for (int k = N * 10; k >= 0; k--)
            {
                if (j - a >= 0 && k - b >= 0) {
                    dp[j][k] = min(dp[j][k], dp[j - a][k - b] + c);
                }
            }
        }
    }
    int ans = INF;
    for (int i = 1; Ma*i <= N*10 && Mb*i <= N * 10; i++)
    {
        ans = min(ans, dp[Ma*i][Mb*i]);
    }
    if (ans != INF) {
        cout << ans << endl;
    }
    else {
        cout << -1 << endl;
    }
    getchar(); getchar();
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1000000007;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, d;
  cin >> n >> d;

  ll st = 1;
  ll res = 0;
  while (st <= n) {
    res++;
    st += 2 * d;
    st++;
  }
  cout << res << en;

  return 0;
}

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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector <int> v(n);
	for (int i = 0; i < n; ++i){
		cin >> v[i];
	}
	for (int i = 1; i < n; ++i)
		v[i] = v[i-1] + v[i];
	int ans = 10000;
	for (int i = 0; i < n - 1; ++i ){
		ans = min(ans, abs(v[n-1]-2*v[i]));
	}
	cout << ans;
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  char c;
  cin >> c;
  switch (c) {
  case 'a':
  case 'i':
  case 'u':
  case 'e':
  case 'o':
    cout << "vowel\n";
    break;
  default:
    cout << "consonant\n";
  }
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
h, w = map(int, input().split())
c = []
for i in range(10):
  s = list(map(int, input().split()))
  c.append(s)

a = []
for i in range(h):
  b = list(map(int, input().split()))
  a.append(b)


d = c
for k in range(10):
  for i in range(10):
    for j in range(10):
      d[i][j] = min(d[i][k]+d[k][j], d[i][j])

ans = 0

for i in range(h):
  for j in range(w):
    if a[i][j] == -1:
      continue
    x = a[i][j]
    ans += d[x][1]
print (ans)

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
int main()
{
  int A,B;
  cin >> A >> B;
  cout << A * B << endl;
}

Measured memory_bytes: 3632
function Main(input)
{
	input = input.split(" ");
	for(var cnt = 0; cnt < input.length; cnt ++)
	{
		input[cnt] = parseFloat(input[cnt]);
	}

	var degH = (input[2] / 12.0 + input[3] / (12.0 * 60.0) - input[3] / 60.0) * Math.PI * 2;

	var ans = Math.pow(input[0], 2) + Math.pow(input[1], 2) - (2 * input[0] * input[1] ) * Math.cos(degH); 
	var ans = Math.sqrt(ans);
	
	console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)


int main() {
  ll N;
  cin>>N;
  vector<ll>T(N);
  ll  ans;
  rep(i,N){
      cin>>T[i];
    if(i==0){
        ans=T[0];
    }
    else{
        ans=T[i]/__gcd(T[i],ans)*ans;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, k, ans = 0; cin >> n >> k;
    // タイプAのロボットは[0,r)、タイプBのロボットは[r,5)を移動
    ll Right = ceil(k/2.0);
    // 位置によって近いロボットを決定
    rep(i, n){
        ll x; cin >> x;
        // タイプAのロボット
        if(x < Right) ans += x*2;
        // タイプBのロボット
        else ans += (k-x)*2;
    }
    cout << ans << endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  int x, y;
  cin >> s >> x >> y;
  
  int count = 0, way = 0;
  vector<int> a, b;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == 'F') count++;
    else{
      if(way == 0) a.emplace_back(count);
      else b.emplace_back(count);
      count = 0;
      way ^= 1;
    }
  }
  if(way == 0) a.emplace_back(count);
  else b.emplace_back(count);
  a.emplace_back(0);
  b.emplace_back(0);
  
  vector<vector<int>> px(a.size(), vector<int>(16001, 0)), py(b.size(), vector<int>(16001, 0));
  for(int i = 0; i < a.size(); i++){
    if(i == 0 && s.at(0) == 'F') px[i].at(8000 + a.at(0)) = 1;
    else if(i == 0 && s.at(0) == 'T') px[i].at(8000) = 1;
    else{
      for(int j = 0; j < 16001; j++){
        if(px[i - 1].at(j) == 1){
          px[i].at(j + a.at(i)) = 1;
          px[i].at(j - a.at(i)) = 1;
        }
      }
    }
  }
  for(int i = 0; i < b.size(); i++){
    if(i == 0) py[i].at(8000 + b.at(i)) = py[i].at(8000 - b.at(i)) = 1;
    else{
      for(int j = 0; j < 16001; j++){
        if(py[i - 1].at(j) == 1){
          py[i].at(j + b.at(i)) = 1;
          py[i].at(j - b.at(i)) = 1;
        }
      }
    }
  }
  
  if(px.back().at(8000 + x) == 1 && py.back().at(8000 + y) == 1)cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 496768
#include <iostream>
#include <string>

using namespace std;


int tost(char c){
    return c-'0';
}
int main() {
    int n,k,fmt1,fmt2;
    string s;
    cin>>s;
fmt1=tost(s[0])*10+tost(s[1]);
fmt2=tost(s[2])*10+tost(s[3]);
if(fmt1<=12&&fmt1>=1&&fmt2>=1&&fmt2<=12){
    cout << "AMBIGUOUS" << endl;
    return 0;
}else if(fmt1<=12&&fmt1>=1){
    cout << "MMYY"<<endl;
    return 0;
}else if(fmt2<=12&&fmt2>=1){
cout << "YYMM"<<endl;
return 0;
}else{
    cout << "NA" << endl;
    return 0;
}

}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

int ans[4001];

int main() {
  rep(a,1001) rep(b,1001) ++ans[a+b];
  int n;
  while( cin >> n ) {
    long long sum = 0;
    rep(i,n+1) sum += (long long)ans[i] * (long long)ans[n-i];
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class F>
struct segment_tree{
    int sz;
    vector<T> seg;
    const F f;
    const T M;
    segment_tree(int n, const F f, const T &M) : f(f), M(M) {
        sz = 1;
        while(sz < n) sz <<= 1;
        seg.assign(2*sz, M);
    }

    void set(int k, const T &x){
        seg[k + sz] = x;
    }

    void build(){
        for (int i = sz-1; i > 0; --i) seg[i] = f(seg[2*i], seg[2*i+1]);
    }

    void update(int k, const T &x){ // 0-indexed
        k += sz;
        seg[k] = x;
        while (k >>= 1){
            seg[k] = f(seg[2*k], seg[2*k+1]);
        }
    }

    T query(int a, int b){ // 0-indexed
        T l = M, r = M;
        for(a += sz, b += sz; a < b; a >>=1, b>>=1){
            if(a & 1) l = f(l, seg[a++]);
            if(b & 1) r = f(seg[--b], r);
        }
        return f(l, r);
    }

    T operator[](const int &k) const { // 0-indexed
        return seg[k + sz];
    }
};

struct tup{
    ll s, p, abs;
    tup (ll s, ll p, ll n) : s(s), p(p), abs(n) {};
};

int main() {
    int n, q;
    cin >> n >> q;
    n *= 2;
    vector<int> a(n), b(n);
    for (auto &&i : a) scanf("%d", &i);
    for (auto &&j : b) scanf("%d", &j);
    auto f = [](tup a, tup b){
        return tup(a.s+b.s, a.p+b.p, min(a.abs, b.abs));
    };
    segment_tree<tup, decltype(f)> seg(n, f, tup(0, 0, INF<int>));
    ll s = 0;
    for (int i = 0; i < n; ++i) {
        s += a[i];
        int d = b[i]-a[i];
        seg.set(i,
                tup(max(0, d), d >= 0, abs(d))
                );
    }
    seg.build();
    for (int i = 0; i < q; ++i) {
        int p, x, y;
        scanf("%d %d %d", &p, &x, &y);
        p--;
        s += x - a[p];
        int d = y-x;
        a[p] = x, b[p] = y;
        seg.update(p,
                tup(max(0, d), d >= 0, abs(d))
        );
        auto ret = seg.query(1, n-1);
        ll ans = s + ret.s - ((ret.p)&1 ? ret.abs : 0);
        printf("%lli\n", ans);
    }
    return 0;
}

Measured memory_bytes: 15616
# -*- coding: utf-8 -*-
"""
Basic Modifications - Swap
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_4_C&lang=jp

"""
_ = input()
A = list(input().split())
for _ in range(int(input())):
    b, e, t = map(int, input().split())
    for k in range(e-b):
        A[b+k], A[t+k] = A[t+k], A[b+k]
print(*A, sep=' ')



Measured memory_bytes: 5848
import numpy as np
N, X, Y = [int(_) for _ in input().split()]
X -= 1
Y -= 1
cnt = np.zeros(N, dtype=int)
for i in range(0, (X + Y) // 2):
    #t-i<=abs(i-X)+1+Y-t
    #2*t<=abs(i-X)+1+Y+i
    #t<= tmax = 0 - - (abs(i-X)+1+Y+i)//2
    #tmin=i-X+1
    #range(tmin,tmin+Y-tmax) + range(1,tmax-i+1) + range(tmin+1,tmin+N-Y)
    tmin = abs(i - X) + 1
    tmax = 0 - -(abs(i - X) + 1 + Y + i) // 2
    cnt[1:tmax - i] += 1
    cnt[tmin:tmin + Y - tmax + 1] += 1
    cnt[tmin + 1:tmin + N - Y] += 1
for i in range((X + Y) // 2, N):
    cnt[1:N - i] += 1
print(*cnt[1:], sep='\n')


Measured memory_bytes: 27420
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))

s, t = map(str, input().split())
a, b = map(int, input().split())
u = input()

if (u == s):
    a -= 1
elif (u == t):
    b -= 1

print(a,b)


Measured memory_bytes: 9060
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int countInn = 1;
    int highestInn;
    cin >> highestInn;
    for(int i = 1; i < N; i++) {
        int nextInnH;
        cin >> nextInnH;
        if(nextInnH >= highestInn) {
            highestInn = nextInnH;
            countInn++;
        }
    }
    cout << countInn;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int cnt = 0;
  int check = 1;
  int n; cin >> n;
  vector<int>a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n;i++){
    if(a[i]==check) check++;
    else cnt++;
  }
  if(check==1) cout<< -1 <<endl;
  else cout<< cnt <<endl;
}


Measured memory_bytes: 1024
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  [a, b, c, d] <- map (read::String -> Int) . words <$> getLine
  putStrLn $ if abs (a - c) <= d
    then "Yes"
    else if abs (a - b) <= d && abs (b - c) <= d
      then "Yes"
      else "No"
  

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
struct union_find {
    vector<int> parent;
    int n;
    union_find(int n) : n(n) { clear(); }
    inline void clear(){ parent.assign(n, -1); }
    inline int find(int u){ return (parent[u] < 0) ? u : parent[u] = find(parent[u]); }
    inline bool same(int u, int v){ return find(u) == find(v); }
    inline bool join(int u, int v){
        u = find(u);
        v = find(v);
        if (u != v){
            if (parent[u] > parent[v])
                swap(u, v);
            parent[u] += parent[v];
            parent[v] = u;
        }
        return u != v;
    }
    inline int size(int u){ return -parent[find(u)]; }
};
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, k; cin >> n >> m >> k;
	union_find uf(n);
	vector<int> res(n, 0);
	for(int i = 0; i < m; i++){
		int x, y;
		cin >> x >> y; x--; y--;
		res[x]--;
		res[y]--;
		uf.join(x, y);
	}
	for(int i = 0; i < n; i++) res[i] += uf.size(i) - 1;
	for(int i = 0; i < k; i++){
		int x, y;
		cin >> x >> y; x--; y--;
		if(uf.same(x, y)){
			res[x]--;
			res[y]--;
		}
	}
	for(int i = 0; i < n; i++) cout << res[i] << ' ';
	cout << '\n';
	return 0;
}

Measured memory_bytes: 1664
H, W = map(int, input().split())

A = [list(input()) for _ in range(H)]

count = 0
for i in A:
    count += i.count('#')

if count != H + W - 1:
    print ('Impossible')
    exit()

def move(i, j): #今、マス(i, j)にいる
    if A[i][j] == '.': #道ではない時
        return False
    if i == H - 1 and j == W - 1: #ゴール地点にいる時
        return True
    if i == H - 1: #一番下の段にいるとき
        return move(i, j + 1)
    if j == W - 1: #一番右の列にいるとき
        return move(i + 1, j)
    if A[i + 1][j] == A[i][j + 1]: #両方道 or 両方行き止まり
        return False 
    if A[i + 1][j] == '#': #下が道の時
        return move(i + 1, j)
    if A[i][j + 1] == '#': #右が道の
        return move(i, j + 1)

if move(0, 0):
    print ('Possible')
else:
    print ('Impossible')
    

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;
using static System.Math;
using static System.Array;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{

    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static int N, K;
        
        

        public static void Input()
        {
            var cin = new Scanner();
            var input = cin.SplitReader();
            N = input[0];
            K = input[1];
            
        }

        static void Main(string[] args)
        {
            Input();

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            long ans = K;
            if (N > 1)
            {
                ans *= (long)Pow(K - 1, N - 1);
            }

            Console.WriteLine(ans);

            //Console.Out.Flush();

        }





    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

    }

    public class Graph
    {
        
    }
}

    



Measured memory_bytes: 13396
#include <stdio.h>
#define MAX_H 1000000

void maxHeapify(int *A,int i,int H);
void buildMaxHeap(int *A,int H);
void swap(int*,int*);

int main(){
  int H,i,a[MAX_H];
  scanf("%d",&H);
  for (i = 0 ; i < H ; i++)scanf("%d",&a[i]);
  buildMaxHeap(a,H);
  for(i = 0 ; i < H ; i++)printf(" %d",a[i]);
  putchar('\n');
  return 0;
}

void maxHeapify(int *A,int i,int H){
  int l = i*2+1, r = i*2+2;
  int largest;
  if(l <= H && A[l] > A[i]){
    largest = l;
  }else{ largest = i; }

  if(r <= H && A[r] > A[largest]){
    largest = r;
  }
  if(largest != i){
    swap(&A[i],&A[largest]);
    maxHeapify(A,largest,H);
  }
}

void buildMaxHeap(int *A,int H){
  int i;
  for(i = H/2 ; i >= 0 ; i--)maxHeapify(A,i,H);
}

void swap(int *a,int *b){
  int tmp = *a;
  *a = *b;
  *b = tmp;
}


Measured memory_bytes: 3768
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll N,T;
	cin>>N>>T;
	ll min=10000;
	REP(i,N){
		ll c,t;
		cin>>c>>t;
		if(t<=T){
			if(min>c)min=c;
		}
	}
	if(min==10000){
		cout<<"TLE"<<endl;
	}else{
		cout<<min<<endl;
	}
	return 0;
}


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

int main()
{
	int pair = 0;

	int n;
	cin >> n;

	int a[100000+1];
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	for (int i = 1; i <= n; i++) {
		if (i == a[a[i]]) {
			pair++;
		}
	}
	cout << pair / 2 << "\n";

	return (0);
}

Measured memory_bytes: 640
import java.util.Scanner;

//Combination of Number Sequences
public class Main{

	static int n, s, c;
	static boolean[] used;
	static int[][] cach;
	
	static void dfs(int k, int sum){
		if(s < sum)return;
		if(n==10&&k==7){
			if(s-sum>218)return;
			int id = 0;
			for(int i=0;i<10;i++)if(!used[i])id|=1<<i;
			c+=cach[id][s-sum];
			return;
		}
		if(k==n){
			if(sum==s)c++;
			return;
		}
		for(int i=0;i<10;i++){
			if(!used[i]){
				used[i] = true;
				dfs(k+1, sum+(k+1)*i);
				used[i] = false;
			}
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		cach = new int[1<<10][219];
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				if(i==j)continue;
				for(int k=0;k<10;k++){
					if(k==i||j==k)continue;
					cach[(1<<i)|(1<<j)|(1<<k)][i*8+j*9+k*10]++;
				}
			}
		}
		while(sc.hasNext()){
			n = sc.nextInt();
			s = sc.nextInt();
			c = 0;
			used = new boolean[10];
			dfs(0,0);
			System.out.println(c);
		}
	}
}

Measured memory_bytes: 13000
fun ac106(args: Array<String>) {
    val numList = args[1].split(" ").mapIndexed { index, s -> s.toLong() - index }.sorted()
    val med = numList[numList.size / 2]
    println(numList.map { Math.abs(it - med) }.sum())
}

fun main(args: Array<String>) {
    ac106(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

Measured memory_bytes: 83048
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589
#define endl "\n"
#define int long long
#define ld long double
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define fr(i,a,b) for (int i = (a); i < (b); ++i)

void solve(){
    int n, W;
    cin >> n >> W;
    int w[n], v[n];
    int dp[n + 1][W + 1];
    fr(i, 0, n) cin >> w[i] >> v[i];
    fr(i, 0, n + 1){
        fr(j, 0, W + 1){
            dp[i][j] = 0;
        }
    }
    fr(i, 0, n){
        fr(j, 0, W + 1){
            dp[i + 1][j] = dp[i][j];
            if(j - w[i] < 0) continue;
            dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i + 1][j]);
        }
    }
    int ans = 0;
    fr(i, 0, W + 1) ans = max(0ll, dp[n][i]);
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int t;
    t = 1;
    //cin >> t;
    while(t--) {solve();}
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<int, pii> piii;
const int INF = 1e9+1;
const ll INFL = 10000000010;
const int MAXN = 100010;

priority_queue<pii> pq;

vector<vector<int> > graph;

vector<ll> dist;
queue<int> que;
int A[MAXN];

void dijkstra(int src)
{
    que.push(src);
    dist[src] = 0;

    int here;
    int there;

    while(!que.empty()){

        here = que.front(); que.pop();

        for(int i=0;i<graph[here].size();i++){
            there = graph[here][i];
            if(dist[there]>dist[here]+1){
                dist[there] = dist[here]+1;
                que.push(there);
            }
        }
    }
    return;
}

int main()
{
    int n,m;
    int x,y,d;
    ll c;
    ll msum = 0;
    int st,en;

    cin>>n>>m;

    graph = vector<vector<int> > (3*n+1);
    dist = vector<ll> (3*n+1,INFL);

    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        x--; y--;
        graph[x*3].push_back(y*3+1);
        graph[x*3+1].push_back(y*3+2);
        graph[x*3+2].push_back(y*3);
    }
    cin>>st>>en;
    st--; en--;

    st*=3; en*=3;

    dijkstra(st);

    if(dist[en]==INFL)cout<<"-1";
    else cout<<dist[en]/3;

    return 0;
}


Measured memory_bytes: 18944
n = gets.to_i
c = Array.new(5, 0)
for i in 0...n do
  s = gets.chomp
  case s[0]
  when "M"
    c[0] += 1
  when "A"
    c[1] += 1
  when "R"
    c[2] += 1
  when "C"
    c[3] += 1
  when "H"
    c[4] += 1
  end
end
sum = 0
for i in 0..2 do
  for j in (i + 1)..3 do
    for k in (j + 1)..4 do
      sum += c[i] * c[j] * c[k]
    end
  end
end
puts sum


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

using namespace std;

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


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define pi 3.14159265358979323846
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

int main()
{

  int n; cin >> n;
  if (n%2==0){cout << n << endl;}
  else {cout << 2*n << endl;}


  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	fmt.Println(max(0, a+b*(n-1)-(b+a*(n-1))+1))
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;


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

    int n,k,a,d,ans = 0;
    cin>>n>>k;
    vector<int>list(n,0);
    
    rep(i,k){
        cin>>d;
        rep(j,d){
            cin>>a;
            list[a - 1]++;
        }
    }
    rep(i,n)if(list[i] == 0)ans++;
    cout<<ans<<endl;

    return 0;
}


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

int main(){
  string s;
  cin >> s;
  int num[26] = {};

  for(int i = 0; i < s.size(); i++){
    num[s[i]-'a']++;
  }

  for(int i = 0; i < 26; i++){
    if(num[i] == 0){
      printf("%c\n", 'a'+i);
      return 0;
    }
  }

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;
const ll MOD = 1000000007;

ll ddp[2][2][5][101];
//そこまでに0でないのは出たか、小さいことは確定しているか、0は何個か、何番目の文字か

int main() {
	string S;
	cin >> S;
	int K, N = S.size();
	cin >> K;

	ddp[0][0][0][0] = 1;
	for (int i = 0;i < N;i++) {
		for (int j = 0;j < 2;j++) {
			for (int k = 0;k < 2;k++) {
				for (int l = 0;l < 4;l++) {
					if (k) {
						for (int d = 0;d < 10;d++) {
							ddp[j || d > 0][k][l + (d != 0)][i + 1] += ddp[j][k][l][i];
						}
					}
					else {
						for (int d = 0;d <= (int)S[i] - 48;d++) {
							ddp[j || d > 0][d < (int)S[i] - 48][l + (d != 0)][i + 1] += ddp[j][k][l][i];
						}
					}
				}
			}
		}
	}
	cout << ddp[1][0][K][N] + ddp[1][1][K][N] << endl;
}

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)

#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define SWAP(x, y) do { char z = y; y = x; x = z; } while (0)
int main(void)
{
    int a,b;
    cin >> a >> b;
    cout << a*b<<endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
using Graph=vector<vector<int>>;
template<class T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, T b){ if(a>b){ a=b; return 1; } return 0; }

int main(){
    int x,n;
    cin>>x>>n;
    if(n==0){
        cout<<x<<endl;
        return 0;
    }
    bool f[101];
    for(int i=0;i<=100;++i) f[i]=false;
    for(int i=0;i<n;++i){
        int temp;
        cin>>temp;
        f[temp]=true;
    }

    int no=-111;
    int ans=abs(x-no);
    for(int i=-110;i<=1000;++i){
        if(0<i&&i<=100){
            if(f[i]) continue;
        }
        int a=abs(x-i);
        if(a<ans){
            ans=a;
            no=i;
        }
        else{
            cout<<no<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3632
import sys

sys.setrecursionlimit(10**7)

def dfs(x):
    if seen[x-1]==0:
        uni[cnt].add(x)
        seen[x-1]=1
        for i in fri[x-1]:
            dfs(i)
    

n,m,k=map(int,input().split())

fri=[[] for i in range(n)]
blk=[[] for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    fri[a-1].append(b)
    fri[b-1].append(a)

for i in range(k):
    c,d=map(int,input().split())
    blk[c-1].append(d)
    blk[d-1].append(c)


seen=[0 for i in range(n)]

uni=[]
cnt=0
for i in range(1,n+1):
    if seen[i-1]==0:
        uni.append(set())
        dfs(i)
        cnt+=1

seq=[0 for i in range(n)]

for unii in uni:
    for j in unii:
        cj=len(unii)-len(fri[j-1])-len(unii&set(blk[j-1]))-1
        seq[j-1]=cj

print(*seq)

Measured memory_bytes: 64804
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
supply_list = []
lack = 0
lack_cnt = 0

for i in range(n):
    if a_list[i] < b_list[i]:
        lack += b_list[i] - a_list[i]
        lack_cnt += 1
    elif a_list[i] > b_list[i]:
        supply_list.append(a_list[i] - b_list[i])

if lack_cnt == 0:
    print(0)
    exit()
elif len(supply_list) == 0:
    print(-1)
    exit()

supply = 0
supply_cnt = 0

for i in sorted(supply_list, reverse=True):
    supply += i
    supply_cnt += 1
    if supply >= lack:
        break

if supply < lack:
    print(-1)
    exit()

print(lack_cnt + supply_cnt)


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

int main(){
int a;
int uma;
int ushi;
int b;
int c;
int i;
while (true){
cin >> a;
if (a == 0){ break; }
else{
	while (true){
	if (i<a){
	cin >> b;
	cin >> c;
	if (b>c){
		uma = uma + b + c;
	}
	else if (b == c){
		uma = uma + b;
		ushi = ushi + c;
	}
	else{
	ushi = ushi + b + c;
	}
	i = i + 1;
}if (i == a){ break; }
}
cout << uma << " " << ushi << endl;
uma = 0;
ushi = 0;
i = 0;
}
}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pb push_back

using namespace std;

const int N=2e3+5;

int n,x,y,dis[N],freq[N];

vector<int>adj[N];

void BFS(int u)
{
    dis[u]=0;
    queue<int>q;
    q.push(u);
    while(!q.empty())
    {
        int v=q.front();
        q.pop();
        for (auto X:adj[v])
        {
            if (dis[X]==-1)
            {
                dis[X]=1+dis[v];
                freq[dis[X]]++;
                q.push(X);
            }
        }
    }
}

int main()
{
    cin >> n >> x >> y;
    adj[x].pb(y);
    adj[y].pb(x);
    for (int i=1;i<n;i++)
    {
        adj[i].pb(i+1);
        adj[i+1].pb(i);
    }
    for (int i=1;i<=n;i++)
    {
        memset(dis,-1,sizeof dis);
        BFS(i);
    }
    for (int i=1;i<n;i++)
    {
        freq[i]/=2;
        cout << freq[i] << endl;
    }
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
const double PI=3.1415926535897932;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

string s,t;

int main(){
    cin >> s >> t;
    ll ans = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == t[i]) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String ans = s;
		if(s.charAt(s.length()-1)!='s') ans+="s";
		else ans+="es";
		System.out.println(ans);
	}
}

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

int main() {
  long long N;
  cin >> N;
  
  long long result;
  if (N % 2 == 0) {
    result = N;
  } else {
    result = N * 2;
  }
  
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 256
from math import sqrt


def solve(n):
    res = set()
    for i in range(2, int(sqrt(n))+1):
        while n % i == 0:
            res.add(i)
            n /= i
        if(n<=1): break
    if n>1:
        res.add(n)
    res.add(1)
    return res


A, B = [int(_) for _ in input().split()]
print(len(solve(A) & solve(B)))


Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    ans = 0
    for i in range(N):
        for j in range(i+1,N):
            for k in range(j+1,N):
                if L[i] != L[j] and L[j] != L[k]:
                    if L[i] + L[j] > L[k]:
                        ans += 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9464