akhauriyash/Code-Regression huggingface dataset:
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!T;r.popFront;}}
void readM(T)(size_t r,size_t c,ref T[][]t){t=new T[][](r);foreach(ref v;t)readA(c,v);}

void main()
{
  int h, w; readV(h, w);
  int[][] c; readM(10, 10, c);
  int[][] a; readM(h, w, a);

  auto g = GraphM!()(10).init;
  foreach (i; 0..10)
    foreach (j; 0..10)
      g[i][j] = c[i][j];

  auto d = FloydWarshal!(typeof(g)).floydWarshal(g);

  auto r = 0;
  foreach (i; 0..h)
    foreach (j; 0..w)
      if (a[i][j] != -1)
        r += d[a[i][j]][1];

  writeln(r);
}

struct GraphM(W = int, W i = 10^^9)
{
  alias Wt = W, inf = i;
  int n;
  Wt[][] g;
  alias g this;
  this(int n) { this.n = n; g = new Wt[][](n, n); }
  ref auto init() { foreach (i; 0..n) { g[i][] = inf; g[i][i] = 0; } return this; }
}

template FloydWarshal(Graph)
{
  import std.algorithm, std.array, std.traits;
  alias Wt = TemplateArgsOf!Graph[0];

  Wt[][] floydWarshal(ref Graph g)
  {
    Wt[][] dist;
    int[][] inter;
    floydWarshal(g, dist, inter);
    return dist;
  }

  void floydWarshal(ref Graph g, out Wt[][] dist, out int[][] inter)
  {
    auto n = g.n, sent = n;
    dist = g.g.map!(i => i.dup).array;

    inter = new int[][](n, n);
    foreach (i; 0..n) inter[i][] = sent;

    foreach (k; 0..n)
      foreach (i; 0..n)
        foreach (j; 0..n)
          if (dist[i][j] > dist[i][k] + dist[k][j]) {
            dist[i][j] = dist[i][k] + dist[k][j];
            inter[i][j] = k;
          }
  }
}


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

using namespace std;

const int max_n = -1, inf = 1000111222;

int n, a, b, c, ans;
string s;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    while (n--) {
        cin >> s;
        for (int i = 0; i + 1 < s.length(); ++i) {
            if (s[i] == 'A' && s[i + 1] == 'B') {
                ++ans;
            }
        }
        if (s[0] == 'B' && s.back() == 'A') {
            ++c;
        } else if (s[0] == 'B') {
            ++b;
        } else if (s.back() == 'A') {
            ++a;
        }
    }
    if (a && c) {
        ans += c;
        ans += min(a, b);
    } else if (a) {
        ans += min(a, b);
    } else if (c) {
        ans += c - 1;
        if (b) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

public class HelloWorld
{
    static public void Main ()
    {
        var N = long.Parse(Console.ReadLine());
        var D = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        
        var dis = new long[N];
        for(int i = 0;i < N ;i++){
            dis[D[i]]++;
        }
        
        long ans = 0;
        if(dis[0] == 1){
         ans = 1;
         //Console.WriteLine(ans);
         var pas = 0;
         for(int i = 1;i < N ;i++){
             if(D[i] > 0){
                 if(i == pas+1){
                     ans *= Pow(dis[i-1],dis[i]);
                     
                     ans %= 998244353;
                     
                     pas = i;
                 }else{
                     ans = 0;
                     
                     break;
                 }
             }
         }
        }
        
        Console.WriteLine(ans);
    }
    
    public static long RepPow(long x, long p, long m = 998244353){
        if (p == 1) return x % m;
        long b = RepPow(x, p / 2, m) % m; if (p % 2 == 0) { return (b * b) % m; } else { return (x * ((b * b) % m)) % m; }}
        static long Pow(long n, long p, int mod = 998244353) { if (p == 0) return 1;　else if (p % 2 == 0) { var x = Pow(n, p / 2, mod); return (x * x) % mod; } else { return Pow(n, p - 1, mod) * n % mod; } }
        

}


Measured memory_bytes: 36816
#include <stdio.h>

const int max = 10000; //素数表最大数
int prime[max + 1]; //素数表配列
int idx, idx2, tmp;

void list(); //素数表作成
void judge(int n); //双子素数判定

int main(){
    
    int n;
    
    list();
    
    while (scanf("%d", &n)){
        if (n == 0) break;
        judge(n);
        printf("%d %d\n", idx2, idx);
    }
    
    return 0;
}

void list(){
    int i, k;
    for (i = 2; i <= max; i++){
        prime[i] = 1;
    }
    for (i = 2; i * i <= max; i++){
        if (prime[i]){
            for (k = 2 * i; k <= max; k += i){
                prime[k] = 0;
            }
        }
    }
}

void judge(int n){
    int i;
    for (i = n; 0 < n; i--){
        tmp = i - 2;
        if(prime[i]){
            if(prime[tmp]){
                idx = i;
                idx2 = tmp;
                break;
            }
        }
    }
}

Measured memory_bytes: 1064
h,w = map(int,input().split())
s = [list(input()) for _ in range(h)]
s.insert(0,[0]*w)
s.append([0]*w)

for i in range(h+2) :
    s[i].insert(0,0)
    s[i].append(0)

around = [[0,1],[0,-1],[1,0],[-1,0]]

for i in range(1,h+1) :
    for j in range(1,w+1) :
        if s[i][j] == '#' :
            ans = False
            for k in range(4) :
                if s[i-around[k][0]][j-around[k][1]] == '#' :
                    ans = True
            if not ans  :
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 3064
#include <iostream>
 
using namespace std;
 
int len, l;
string str, in;
 
bool check(int i, int j){
    for(int k = 0 ; k < l ; k++){
	if(i+j*k >= len) return false;
	if(str[k] != in[i+j*k]) return false;
    }
    return true;
}
 
int main(){
    int N, ans = 0;
 
    cin >> N >> str; l = str.size();
    for(int i = 0 ; i < N ; i++){
	cin >> in;
	len = in.size();
	for(int i = 0 ; i < len ; i++){
	    for(int j = 1 ; j < len ; j++){
		if(check(i,j)){
		    ++ans;
		    goto next;
		}
	    }
	}
    next:;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    string a, b;
    cin >> a >> b;
    if(a.size() > b.size())cout << "GREATER" << endl;
    else if(a.size() < b.size())cout << "LESS" << endl;
    else{
        for(int i=0;i<a.size();++i){
            if(a[i] > b[i]){
                cout << "GREATER" << endl;
                return 0;
            }else if(a[i] < b[i]){
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int[] a = new int[N];
   String ans = "YES"; 
   for(int i=0;i<N;i++) 
   {
     a[i] = sc.nextInt();
   }
   Arrays.sort(a);
   int tmp = a[0];
   for(int i =1;i<N;i++)
   {
     if(a[i] == tmp) 
     {
       ans = "NO";
       break;
     }
     tmp = a[i];
   }
   System.out.print(ans);
 }
}

Measured memory_bytes: 65276
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,m;
  cin >> n >> m;
  vl dp(n+1,0);
  if(m!=0){
  vl a(m);
  rep(i,m){
    cin >> a[i];
  }
  dp[0]=1;
  ll j=0;
  if(a[0]==1){
    dp[1]=0;
    j=1;
  }
  else
    dp[1]=1;
  FOR(i,2,n+1){
    if(i==a[j]){
      j++;
      dp[i]=0;
    }
    else
      dp[i]=(dp[i-1]+dp[i-2])%MOD;
  }
  }
  else{
    dp[0]=1;
    dp[1]=1;
    FOR(i,2,n+1){
      dp[i]=(dp[i-1]+dp[i-2])%MOD;
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>


using namespace std;
#define MAX 100000

int main(){
    int N, x;
    vector<int> a;

    cin >> N >> x;
    for (int i = 0; i < N; i++){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    sort(a.begin(), a.end());
    int cnt = 0;
    for (int ii = 0; ii < N; ii++){
        if (a[ii] <= x){
            cnt++;
            x -= a[ii];
        }
        else{
            break;
        }
    }
    if ((cnt == N) && (x > 0)){
        cnt--;
    }
    cout << cnt << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

long long EulersPhiFunction(long long n){
  vector<bool> prime(round(sqrt(n))+1,1);
  long long ans = n;
  for(long long i = 2;i*i <= n;i++){
    if(prime[i]){
      for(long long j = 2*i;j*j <= n;j += i){
        prime[j] = 0;
      }
      bool flag = 0;
      while(n%i == 0){
        n /= i;
        flag = 1;
      }
      if(flag){
        ans /= i;
        ans *= (i-1);
      }
    }
  }
  if(n != 1){
    ans /= n;
    ans *= (n-1);
  }
  return ans;
}


 
signed main(){
  ll n;
  cin >> n;
  cout << EulersPhiFunction(n) << endl;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
int tmp;
int gcd(int a,int b){
  while(b > 0){
    tmp=a;
    a=b;
    b=tmp%b;
  }
  return a;
}
int main(){
  int n;
  cin>>n;
vector<long long int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
for(int i=0;i<n-1;i++){
  a[i+1]=gcd(a[i],a[i+1]);
}
  cout<<a[n-1]<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
string s1,s2;
int i;
 
int main(){
  i=0;
  cin>>s1>>s2;
  if(s1.length()>s2.length()) cout<<"GREATER"<<endl;
  else if(s1.length()<s2.length())cout<<"LESS"<<endl;
  else if(s1>s2) cout<<"GREATER"<<endl;
  else if(s1<s2) cout<<"LESS"<<endl;
  else cout<<"EQUAL"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string n;
    cin>>n;
    string ans="No";
    if(n[0]==n[1]&&n[1]==n[2])ans="Yes";
    if(n[1]==n[2]&&n[2]==n[3])ans="Yes";
    cout<<ans<<endl;
}

Measured memory_bytes: 384
import itertools as it
import sys

N, M = map(int, input().split())
if N==0 or M==0:
    print(0)
    sys.exit()
a=[]

for i in range(M):
    x,y=map(int,input().split())
    a.append([x,y])
    a.append([y,x])

ans=0
for e in it.permutations(range(N)):
    if e[0]!=0:
        break
        
    count=1
    for j in range(N-1):
        if [e[j]+1,e[j+1]+1] in a:
            count*=1
        else:
            count*=0
            break
            
    ans+=count

print(ans)

Measured memory_bytes: 9232
import java.util.Scanner;

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

        int stLength = st.length();
        int counter=0;

        //System.out.println(stLength);
        //System.out.println(st.substring(0,1));
        for(int i = 0;i<stLength/2;i++)
        {
            //System.out.print(st.substring(i,i+1)+",");
            //System.out.println(st.substring(stLength-i-1,stLength-i));
            if(!(st.substring(i,i+1).equals(st.substring(stLength-i-1,stLength-i))))
            {
                counter++;
            }
        }

        System.out.println(counter);
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int n;
  cin >> n;
  int x[27] = {};
  string str;
  cin >> str;
  for(int i = 0; i < str.size(); ++i){
    x[str[i]-'a']++;
  }
  for(int i = 1; i < n; ++i){
    string str2;
    cin >> str2;
    int x2[27] = {};
    for(int j = 0; j < str2.size(); ++j){
      x2[str2[j]-'a']++;
    }
    for(int j = 0; j < 27; ++j){
      x[j] = min(x[j], x2[j]);
    }
  }
  for(int i = 0; i < 27; ++i){
    for(int j = 0; j < x[i]; ++j){
      cout << (char)('a'+i);
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
from heapq import heappop, heappush, heapify
import sys
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))

#####  動的計画法（DP）による解法  #####
N, M = inpl()
LRC = sorted([inpl() for _ in range(M)])
# L,Rとして登場する点だけを取り出す。中間点が寄与することはない。
points = sorted(list({lrc[i] for i in range(2) for lrc in LRC}))
# 1またはNが無ければ終了。
if points[0] > 1 or points[-1] < N:
    print(-1)
    exit()

# 各経路の(1からの距離、有効範囲の限界点)ペアをヒープに格納。
# 初期状態は「(距離0、点1まで)」。
dq = [(0,1)]
m = 0 # エッジ群の番号。開始点の順にソートされている。
# DPループ。
# DP部分の計算量は O(M log M)。ヒープを叩くのは総計M+M回なので。Nにはよらない。
# 上のソート等も O(M log M) なので全体の計算量も同じ。
for i in points:
    # 有効範囲が終了したものを捨てる。
    # 距離が長いものは捨てずに放置しておいてもOK。
    while dq and dq[0][1] < i:
        heappop(dq)
    # 現在の点まで到達する経路が無ければ終了。
    if not dq:
        print(-1)
        break
    # 点1から現在の点までの最短距離。
    d = dq[0][0]
    # 現在の点から始まる各エッジ群による(距離、限界点)を順に格納。
    while m < M and LRC[m][0] == i:
        heappush(dq, (d+LRC[m][2], LRC[m][1]))
        m += 1
else:
    # 最後の点Nまで正常に終了した場合。
    print(d)


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

int main()
{
    long int a, b;
    cin >> a >> b;
    if(a<=0 && 0<=b) cout << "Zero" << endl;
    else if (a>0 && b>0) cout << "Positive" << endl;
    else if (a<0 && b<0 && (abs(b - a))%2==1) cout << "Positive" << endl;
    else cout << "Negative" << endl;
    return 0;
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    int count = 0;
    if (s[0] == '1') count++;
    if (s[1] == '1') count++;
    if (s[2] == '1') count++;
    cout << count << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define INF 10000000000

int main() {
    int N, K; cin >> N >> K;
    vector<ll> h(N+1);
    h[0] = 0;

    for (int i = 1; i <= N; i++) {
        cin >> h[i];
    }

    vector<ll> dp(N+1);
    for (int i = 0; i <= N; i++) dp[i] = INF;
    dp[0] = 0;
    dp[1] = 0;
    for (int i = 1; i < N; i++) {
        for (int j = i+1; j <= min(N, i+K); j++) {
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 1792
def main():
  x1, y1, x2, y2 = map(int, input().split())
  y = y2 - y1
  x = x2 - x1
  x3 = x2 - y
  y3 = y2 + x
  x4 = x1 - y
  y4 = y1 + x
  print(x3, y3, x4, y4)

if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int table[201][201];
void maketable() {
    rrep(i, 1, 201) {
        table[i][1] = 1;
        int tmp = i;
        rrep(j, 2, i + 1) {
            while (tmp % j == 0) {
                table[i][j]++;
                tmp /= j;
            }
        }
    }
}
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    maketable();
    //rep(i, 105) cout << table[105][i] << " "; cout << endl;
    int n; cin >> n;
    int ans = 0;
    rrep(i, 1, n + 1) {
        int c = 1;
        rrep(j, 2, i + 1) if (table[i][j]) c *= table[i][j] + 1;
        if (c == 8 && i % 2 != 0) ans++;
    }
    cout << ans << endl;
    
}


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

int a[100010];

int main()
{
  int n;
  scanf("%d", &n);
  for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for(int i = 1; i <= n; i++)
  {
    if(a[i] % 2 == 0)
    {
      if(a[i] % 3 != 0 && a[i] % 5 != 0)
      {
        printf("DENIED");
        return 0;
      }
    }
  }
  printf("APPROVED");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <atomic>
#include <bitset>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include <cmath>
using namespace std;

#define rep(i, a, n) for(int i = a; i <= n; i++)

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

// 第一引数 == 第二引数 ? true : false
template<class T, class U>
bool check(T first, U second) {
    return (first == second);
}

// 約数列挙
vector<int64_t> divisor(int64_t n) {
  vector<int64_t> ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


// 数字和
template<class T>
T digitSum(T num) {
    T dig;
    T sum = 0;
    while (num) {
        dig = num % 10;
        sum += dig;
        num /= 10;
    }
    return sum;
}

string background_black(string s) { return "\x1b[40m" + s; }
string background_red(string s) { return "\x1b[41m" + s + "\x1b[40m"; }
string background_green(string s) { return "\x1b[42m" + s + "\x1b[40m"; }
string background_yellow(string s) { return "\x1b[43m" + s + "\x1b[40m"; }
string background_bleu(string s) { return "\x1b[44m" + s + "\x1b[40m"; }
string background_white(string s) { return "\x1b[47m" + s + "\x1b[40m"; }

string black(string s) { return "\x1b[30m" + s + "\x1b[37m"; }
string red(string s) {return "\x1b[31m" + s + "\x1b[37m"; }
string green(string s) { return "\x1b[32m" + s + "\x1b[37m"; }
string yellow(string s) { return "\x1b[33m" + s + "\x1b[37m"; }
string blue(string s) { return "\x1b[34m" + s + "\x1b[37m"; }
string white(string s) { return "\x1b[37m" + s + "\x1b[37m"; }

const int ten = 10;
const int hundred = 100;
const int thousand = 1000;

typedef long long ll;
typedef unsigned long long ull;

string tolower(string s) {
  string c;
  for (int i = 0; i < s.size(); i++) {
    if ((s[i] >= 'A') && (s[i] <= 'Z')) {
        c.push_back((s[i] + 0x20));
    } else {
        c.push_back(s[i]);
    }
  }
  return c;
}
#include <cstdlib>
string solve() {
  string str = "";
// int->string: to_string, string->int: stoi
//=============================================================================


  
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;

  int cnt = 0;

  if (s == t) {
    str += to_string(n);  
  } else {
    for (int i = 0 ; i < n; i++) {
      int k = i;
      for (int j = 0; j < n; j++, k++) {
        if (s[k] == t[j] && k != n) {
          cnt++;
        } else {
          break;
        }
      }
      if (k == n) {
        break;
      } else {
        cnt = 0;
      }
    }
        str += to_string(n*2 - cnt);
  }





//=============================================================================
  str += "\n";
  return str;
}

int main() {	
  std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
  cout << solve() << endl;
}


Measured memory_bytes: 256
#include <cstring>
#include <string>
#include <memory>
#include <iostream>

/**
@note prime number and less than 1,000,000
*/
constexpr int max_size()
{
    return 1000003;
}

constexpr int null_val()
{
    return -1;
}

class dictionary {
public:
    dictionary()
        : _data(std::make_unique<int[]>(max_size()))
    {
        for (int i = 0; i < max_size(); ++i) {
            _data[i] = null_val();
        }
    }

    void insert(const std::string& str) {
        return insert(str2key(str), 0);
        return;
    }

    bool find(const std::string& str) {
        return find(str2key(str), 0);
    }

private:
    int str2int(const char ch) {
        if (ch == 'A') {
            return 1;
        }
        if (ch == 'C') {
            return 2;
        }
        if (ch == 'G') {
            return 3;
        }
        if (ch == 'T') {
            return 4;
        }
        return 0;
    }

    int str2key(const std::string& str)
    {
        int sum = 0;

        for (std::size_t i = 0; i < str.size(); ++i) {
            sum += str2int(str[i]);
            sum *= 5;   //move up;
        }
        
        return sum;
    }

    int base_hash(const int key) const
    {
        return key % max_size();
    }

    int collision_hash(const int key) const
    {
        constexpr int modulo = max_size() + 1;
        return 1 + key % modulo;
    }

    int create_hash(const int key, const int r) const 
    {
        const int base = base_hash(key);
        const int collision = collision_hash(key);
        const int h = (base + r * collision) % max_size();
        return h;
    }

    void insert(const int key, const int r)
    {
        const int h = create_hash(key, r);
        if (is_empty(h)) {
            _data[h] = key;
            return;
        }
        if (_data[h] == key) {
            return;
        }

        return insert(key, r + 1);
    }

    bool find(const int key, const int r) const
    {
        const int h = create_hash(key, r);
        if (is_empty(h)) {
            return false;
        }
        if (_data[h] == key) {
            return true;
        }

        return find(key, r + 1);
    }

    bool is_empty(const int idx) const {
        return _data[idx] == null_val();
    }

private:
    std::unique_ptr<int[]> _data;
};

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

    int n;
    std::cin >> n;
    std::cin.ignore();

    dictionary dict;
    std::string buf;
    for (int i = 0; i < n; ++i) {
        getline(std::cin, buf);
        if (buf.front() == 'i') {
            static const std::size_t size = strlen("insert ");
            const std::string val
                = buf.substr(size, buf.size() - size);
            dict.insert(val);
        }
        else {
            static const std::size_t size = strlen("find ");
            const std::string val
                = buf.substr(size, buf.size() - size);
            if (dict.find(val)) {
                std::cout << "yes" << std::endl;
            }
            else {
                std::cout << "no" << std::endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 6804
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int const INF = 1e15;
int n, k;
int a[20];
signed main() {
    cin >> n >> k;
    rep(i,0,n) cin >> a[i];

    int ans = INF;
    rep(bit,0,1<<n) {
        int prev = a[0];
        int temp = 0;
        if(__builtin_popcount(bit) < k) continue;
        if(!(bit & 1)) continue;
        rep(i,1,n) {
            if(bit >> i & 1) {
                if(prev < a[i]) {
                    prev = a[i];
                    continue;
                }
                int cost = prev - a[i] + 1;
                temp += cost;
                prev = a[i] + cost;
            }
            else if(prev < a[i]) temp = INF;
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define pll pair<long long,long long>
#define vl vector<long long>
#define vll vector<pll>
#define vi vector<int>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
#define watch(x) cerr<<"\n"<<(#x)<<" is "<<(x)<<endl;
using namespace std;
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000010;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;
const ll boun = 1000000000LL;
// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define trav(a, x) for(auto& a : x)
#define fill(x,y) memset(x,y,sizeof(x))
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr<< *it << " = " << a << endl;
	err(++it, args...);
}
int main()
{
    sws
    int n,W;
    cin>>n>>W;
    vi val(n);
    vl weight(n);
    int maxval=0;
    forn(i,n)
    {
        cin>>weight[i]>>val[i];
        maxval+=val[i];
    }
    ll dp[maxval+1];
    fill(dp,LLINF);
    dp[0]=0;
    forn(i,n)
    {
        int rem=maxval-val[i];
        for(int j=rem;j>=0;j--)
        {
            dp[j+val[i]]=min(dp[j+val[i]],dp[j]+weight[i]);
        }
    }
    ll ans=0;
    forn(i,maxval+1)
    {
    //    error(i,ans,dp[i])
        if(dp[i]<=W)
            ans=max(ans,(ll)i);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn =  new Scanner(System.in);
        
        double max = 0;
        double min = 1000000;
        
        while(stdIn.hasNext()){
            double x = stdIn.nextDouble();
            
            if(x > max){
                max = x;
            }
            
            if(x < min){
                min = x;
            }
            
        }
        
        System.out.println(max - min);
    }
}



Measured memory_bytes: 28028
#include <iostream>
using namespace std;
int d[100005];
int main( void )
{
  ios::sync_with_stdio(false);
  int N, M, a, b;
  cin >> N >> M;
  for( int i=0; i<M; i++ ){
    cin >> a >> b;
    d[a]++;
    d[b]++;
  }
  for( int i=2; i<=N; i++ ){
    if( d[i] % 2 == 1 ){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair

int main()
{
  ll k;
  cin>>k;
  string s;
  cin>>s;
  if(s.length()<=k)
  cout<<s<<endl;
  else
  {
    for(ll i=0;i<k;i++)
    cout<<s[i];
    cout<<"...";
  }
}


Measured memory_bytes: 3620
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

void main_() {
  const usize n = scan<usize>();
  std::vector<u32> b(n - 1_z);
  for (auto &e : b) {
    std::cin >> e;
  }
  u32 ans = static_cast<u32>(0);
  ans += b.front();
  ans += b.back();
  for (const auto i : rep(1_z, n - 1_z)) {
    ans += std::min(b[i - 1_z], b[i]);
  }
  std::cout << ans << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
def find_missing_cards(suit_list):

    cards = [[ 0 for a in range(13)],
             [ 0 for a in range(13)],
             [ 0 for a in range(13)],
             [ 0 for a in range(13)]]

    suit_to_index = {"S" : 0, "H" : 1, "C" : 2, "D" : 3}
    index_to_suits = {0 : "S", 1 : "H", 2 : "C", 3 : "D"}

    for i in range(len(suit_list)):
        cards[ suit_to_index[ suit_list[i][0] ] ][ suit_list[i][1] - 1 ] = 1

    for i, l in enumerate(cards):
        for j in range(len(l)):
            if cards[i][j] == 0:
                print(index_to_suits[i] + " " + str( j + 1 ) )

if __name__ == "__main__":

    n = int(input())
    suit_list = list()

    while(n > 0):
        param = input().split(" ")

        suit = param[0]
        number = int(param[1])

        suit_list.append([suit, number])

        n = n - 1

    find_missing_cards(suit_list)


Measured memory_bytes: 5616
#include <iostream>
using namespace std;
int main(){
  int N,T;
  cin >> N >> T;
  int t[N];
  for(int i=0;i<N;i++){
  scanf("%d",&t[i]);
}
  long long now=0,ans=0;
  for(int i=0;i<N;i++){
    if(t[i]>now){
      ans-=(t[i]-now);
    }
    if(t[i]+T>now){
      now=t[i]+T;
    }
  }
  ans+=now;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
local n, c = io.read("*n", "*n")
local d = {}
for i = 1, c * c do
  d[i] = io.read("*n")
end
local diffsum = {}
for i = 1, 3 * c do
  diffsum[i] = 0
end
for pos = 1, n * n do
  local row, col = 1 + math.floor((pos - 1) / n), pos % n
  if(col == 0) then col = n end
  local md = (row + col) % 3
  local a = io.read("*n")
  for i_c = 1, c do
    local idx = md * c + i_c
    diffsum[idx] = diffsum[idx] + d[(a - 1) * c + i_c]
  end
end
local dfmin = diffsum[1] + diffsum[c + 2] + diffsum[2 * c + 3]
local mmin = math.min
for i_1 = 1, c do
  for i_2 = 1, c do
    if(i_1 ~= i_2) then
      for i_3 = 1, c do
        if(i_1 ~= i_3 and i_2 ~= i_3) then
          dfmin = mmin(dfmin, diffsum[i_1] + diffsum[c + i_2] + diffsum[2 * c + i_3])
        end
      end
    end
  end
end
print(dfmin)


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

int main() {
    int n; cin >> n;
    int nAC = 0, nWA = 0, nTLE = 0, nRE = 0;
    for (int i = 0; i < n; ++i) {
        string inp; cin >> inp;
        if (inp == "AC") {
            nAC++;
        } else if (inp == "WA") {
            nWA++;
        } else if (inp == "TLE") {
            nTLE++;
        } else {
            nRE++;
        }
    }
    cout << "AC x " << nAC << endl;
    cout << "WA x " << nWA << endl;
    cout << "TLE x " << nTLE << endl;
    cout << "RE x " << nRE << endl;
}

Measured memory_bytes: 3628
n=int(input())
p=tuple(map(str,input().split()))
q=tuple(map(str,input().split()))
#print(p,q)
a=0
b=0
moji=""
for i in range(1,n+1):
  i=str(i)
  moji+=i
import itertools as it
lis=list(it.permutations(moji,n))
for j in range(0,len(lis)):
  #print(lis[j])
  if lis[j]==p:
    a=j
  if lis[j]==q:
    b=j
print(abs(a-b))
    

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

bool conv(char a){
 return a == 'H';  
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll a,b;
  cin >> a >> b;
  string ans;
  if(a==b)
    ans = "Draw";
  else if(a==1 || (a>b && b!=1))
    ans = "Alice";
  else if(b == 1 || a<b)
    ans = "Bob";
  
  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    X = int(input())

    if X < 600:
        print(8)
    elif X < 800:
        print(7)
    elif X < 1000:
        print(6)
    elif X < 1200:
        print(5)
    elif X < 1400:
        print(4)
    elif X < 1600:
        print(3)
    elif X < 1800:
        print(2)
    elif X < 2000:
        print(1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 61724
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

ll f(ll n) {return n * (n+1) / 2;}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  ll ans = a[0];
  int j = 0, k = 1;
  rep(i,n-2) {
    ans += a[k];
    j++;
    if (j % 2 == 0) k++;
  }

  cout << ans << endl;

}



Measured memory_bytes: 4828
# calc
seq = {i: 10 ** i for i in range(0, 9+1)}
squared = {index: x ** 2 for index, x in seq.items()}


def sq(number):
    for i, s in squared.items():
        if number <= s:
            return i


def main():
    target = int(input())
    first_e = sq(target)
    first = 10 ** first_e

    if target == squared[first_e]:
        second = first
    else:
        second = (target // seq[first_e]) + 1
    over = first * second
    rest = over - target
    x0 = 0
    y0 = 0
    x1 = first
    y1 = 1
    x2 = rest
    y2 = second
    print(x0, y0, x1, y1, x2, y2)


if __name__ == '__main__':
    main()





Measured memory_bytes: 3064
#if defined(_WIN32)
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

using ulong = unsigned long;
using ll = long long;
using ull = unsigned long long;

#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)

using namespace std;

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

	set<ll> s;

	ll n;
	cin >> n;

	REP(i, n)
	{
		ll a;
		cin >> a;
		s.insert(a);
	}

	cout << s.size() << endl;
	return 0;
}


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

int main()
{
    ll n,s=0,i,x=0,len=0;
    cin>>n;
    string str = "abcdefghijklmnopqrstuvwxyz";
    string s1="";
    while(n)
    {
        n--;
        x=n%26;
        s1+='a'+(n%26);
        n/=26;
        len++;
    }
    for(i=len-1; i>=0; i--)
    {
        cout<<s1[i];
    }
    return 0;
}



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

#define io ios::sync_with_stdio(false)
#define pb push_back
#define pqueue priority_queue
#define fi first
#define se second
#define ls rt<<1
#define rs rt<<1|1
#define sz(x) (int)(x).size()
#define dbg(x) cout<<#x<<" --- "<<x<<endl
#define mst(x,a) memset(x,a,sizeof(x))
#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r; }
const int inf=0x7fffffff;
const int maxn=1e5+10;
vector<int> g[maxn];
int ans[maxn],d[maxn];
pii e[maxn];
int n,mx;

void dfs(int u,int pre,int c){
	int cc=c;
	for(int i=0;i<sz(g[u]);i++){
		int x=e[g[u][i]].fi,y=e[g[u][i]].se,id=g[u][i];
		if(x!=u)swap(x,y);
		if(y==pre)continue;
		cc++;cc%=mx;
		ans[id]=cc;
		dfs(y,u,cc);
	}
}

int main(){
	io;
	cin>>n;
	for(int i=1;i<n;i++){
		int u,v;cin>>u>>v;
		e[i].fi=u;e[i].se=v;
		g[u].pb(i);g[v].pb(i);
		d[u]++;d[v]++;
	}
	for(int i=1;i<=n;i++)mx=max(mx,d[i]);
	// dbg(d[2]);
	cout<<mx<<endl;
	dfs(1,0,0);
	for(int i=1;i<n;i++){
		if(ans[i]==0)ans[i]=mx;
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 9088
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int M1,D1,M2,D2;

	cin >> M1 >> D1 >> M2 >> D2;

	if(M1+1==M2)
		cout << 1;
	else
		cout << 0;
	cout << endl;
	return 0;
}



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

int main() {
  long long n;
  cin >> n;
  string ans ="";
  while (n > 0)
  {
     n--;
     ans += (char)('a' + (n%26));
     n =n/26;
  }
  
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

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

int main(){
   string s,t;cin>>s>>t;
   vector<char> v_s(26,'A');
   vector<char> v_t(26,'A');
   int flag=1;
   for(int i=0;i<s.size();i++){
       char a=s[i];
       if(v_s[a-'a']=='A') v_s[a-'a']=t[i];
       else{
           if(v_s[a-'a']!=t[i]) flag=0;
       }
   }
   for(int i=0;i<t.size();i++){
       char a=t[i];
       if(v_t[a-'a']=='A') v_t[a-'a']=s[i];
       else{
           if(v_t[a-'a']!=s[i]) flag=0;
       }
   }
   if(flag) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   
}

Measured memory_bytes: 776
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");

const [n, l]: number[] = input[0].split(' ').map((x: string): number => +x);
let total: number = 0;
for(let i = l; i < n+l; i++){
    total += i;
}

if(l >= 0){
    console.log(total - l);
}else if (l < 0 && n+l-1 >= 0){
    console.log(total);
}else{
    console.log(total - (n+l-1));
}

Measured memory_bytes: 7372
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// solution 
use std::cmp;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        N: usize,
        F: [ [usize; 10]; N],
        P: [ [i64; 11]; N],
    }

    let mut max = std::i64::MIN;
    for ind in 1..(1 << 10) {
        let mut c = vec![0_usize; N];
        let mut res = ind;
        let mut count = 0;
        while res > 0 {
            let is = res&1;
            for i in 0..N {
                c[i] += F[i][count] * is;
            }
            res >>= 1;
            count += 1;
        }
        let mut sum = 0;
        for (ind, cc) in c.iter().enumerate() {
            sum += P[ind][*cc];
        }
        max = cmp::max(max, sum);
    }
    println!("{}", max);
}


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

int main() {
  string s; cin >> s;
  string alfa = "abcdefghijklmnopqrstuvwxyz";
   vector<int> num(26);
  int size = s.size();
  for(int i = 0; i<size;i++){
    for(int j = 0; j<26;j++){
      if(s.at(i)== alfa.at(j)){
        num[j] = 1;
      }
    }
  }
    char ans = 'a';
  int count = 0;
    for(int i = 0; i < 26; i++){
      if(num[i]==0){
       printf("%c", ans+i);
        break;
      } else count++;
    }
  if(count==26) cout << "None" << endl;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7;
vector<int> g[N], d[N];
int p[N], dep[N], pw[N];

int add(int x, int y) {
  return (x += y) >= mod ? x - mod : x;
}

int sub(int x, int y) {
  return (x -= y) < 0 ? x + mod : x;
}

void Add(int &x, int y) {
  x = add(x, y);
}

int mul(int x, int y) {
  return 1ll * x * y % mod;
}

void Mul(int &x, int y) {
  x = mul(x, y);
}

void init() {
  pw[0] = 1;
  for(int i = 1; i < N; ++i) 
    pw[i] = add(pw[i - 1], pw[i - 1]);
}

int q_pow(int x, int y) {
  int ans = 1;
  for(; y; y >>= 1) {
    if(y & 1) Mul(ans, x);
    Mul(x, x);
  }
  return ans;
}

int now = 0;
int f[N][2], vs[N];

auto cmp = [](int a,int b){return dep[a] < dep[b];};
priority_queue<int, vector<int>, decltype(cmp)> q(cmp);
void bfs() {
  while(!q.empty()) {
    int u = q.top(); q.pop();
//    printf("u = %d\n", u);
    if(vs[p[u]] != now) {
      vs[p[u]] = now;
      g[p[u]].clear();
      f[p[u]][0] = f[p[u]][1] = 0;
      q.push(p[u]);
    }
    if(g[u].size() == 1) {
      if(u) {
        p[g[u][0]] = p[u];
        g[p[u]].push_back(g[u][0]);
      }
    } else if(u) {
      g[p[u]].push_back(u);
    }
    if(g[u].size() > 1 || u == 0) {
      int pos = 1, tmp = 1;
      for(int i = 0; i < (int)g[u].size(); ++i) {
        int to = g[u][i];
//        printf("to = %d, [0] = %d, [1] = %d\n", to, f[to][0], f[to][1]);
        Mul(pos, f[to][0]);
        Mul(tmp, add(f[to][0], f[to][1]));
      }
      for(int i = 0; i < (int)g[u].size(); ++i) {
        int to = g[u][i];
        Add(f[u][1], mul(f[to][1], mul(pos, q_pow(f[to][0], mod - 2))));
      }
      f[u][0] = sub(tmp, f[u][1]);
    }
  }
}

int main() {
  init();
  int n;
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i) 
    scanf("%d", &p[i]);
  for(int i = 1; i <= n; ++i) dep[i] = dep[p[i]] + 1;
  for(int i = 1; i <= n; ++i) {
    d[dep[i]].push_back(i);
  }
  int ans = pw[n];
  for(int i = 1; i <= n; ++i) {
    if(!d[i].size()) break;
    ++now;
    for(int j = 0; j < (int)d[i].size(); ++j) {
      q.push(d[i][j]);
      f[d[i][j]][0] = f[d[i][j]][1] = 1;
      vs[d[i][j]] = now;
    }
    bfs();
//    printf("qwq%d %d\n", i, f[0][1]);
    Add(ans, mul(f[0][1], pw[n + 1 - d[i].size()]));
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 26752
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  vector<ll> c(n);
  for(int i = 0;i < n;i++)cin >> a[i] >> b[i] >> c[i];
  vector<vector<ll>> res(n,vector<ll>(3));
  for(int i = 0;i < n;i++)for(int j = 0;j < 3;j++)res[i][j] = 0;
  res[0][0] = a[0];
  res[0][1] = b[0];
  res[0][2] = c[0];
  for(int i = 1;i < n;i++){
    res[i][0] = max(res[i - 1][2],res[i - 1][1]) + a[i];
    res[i][1] = max(res[i - 1][0],res[i - 1][2]) + b[i];
    res[i][2] = max(res[i - 1][0],res[i - 1][1]) + c[i];
  }
  //for(auto i:res)cout << i << " ";
  //cout << endl;
  cout << max({res[n - 1][0],res[n - 1][1],res[n - 1][2]}) << endl;
}

Measured memory_bytes: 8064
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll a, b, c;
    cin >> a >> b >> c;
    if(c - a - b <= 0) {
        output("No");
        return 0;
    }
    ll lhs = 2 * (b * c + c * a);
    ll rhs = (a - b) * (a - b) + c * c;
    if(lhs < rhs) output("Yes");
    else output("No");
    return 0;
}


Measured memory_bytes: 256