akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  char c;
  cin >> c;

  string s = "aiueo";
  // TODO: &
  for (auto &v : s) {
    if (c == v) {
      cout << "vowel" << endl;
      return 0;
    }
  }

  cout << "consonant" << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
namespace ABC177
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(long.Parse).ToArray();

            var sum = 0L;
            var ans = 0L;
            for (int i = 0; i < N - 1; i++)
            {
                sum += A[i];
                ans += (sum % 1000000007 * A[i + 1] % 1000000007);
            }
            Console.WriteLine(ans % 1000000007);
        }
    }
}


Measured memory_bytes: 47496
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,i,a[100010],b[100010];
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(i=1;i<=n;i++)b[a[i]]++;
	if(a[n]!=a[n-1])return puts("Impossible"),0;
	for(i=a[n]/2+1;i<=a[n];i++)b[i]-=2;
	if(a[n]%2==0)b[a[n]/2]--;
	for(i=1;i<=(a[n]+1)/2;i++)if(b[i]!=0)return puts("Impossible"),0;
	for(i=(a[n]+1)/2+1;i<=a[n];i++)if(b[i]<0)return puts("Impossible"),0;
	puts("Possible");
}

Measured memory_bytes: 256
H,W = map(int,input().split())
S = []
for _ in range(H):
    S.append(list(input()))
P=[["#"]*W for _ in range(H)]
a = [[-1,0],[-1,-1],[-1,1],[0,1],[0,-1],[1,1],[1,0],[1,-1]]
n = len(a)
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            cnt = 0
            for h in range(n):
                if 0 <= i+a[h][0] < H and 0 <= j+a[h][1] < W:
                    if S[i+a[h][0]][j+a[h][1]] == '#':
                        cnt += 1
            P[i][j] = str(cnt)

for i in range(H):
    print(''.join(P[i]))



Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main(){
    int n, a, b, x = 0;

     cin >> n;
    cin >> a;

    for(int i = 1; i < n; ++i){
        cin >> b;
        if(a == b) x++, a = -1;
        else a = b;
    }
    cout << x;
}


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

int main()
{
	int n;
	cin >> n;
	int s = 0, m = n;
	while (n > 0)
	{
		s += n % 10;
		n /= 10;
	}
	if (m % s)
		cout << "No" << endl;
	else 
		cout << "Yes" << endl;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,-1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    int M;
    cin >> M;
    for(int i=0; i<M; i++){
        int a;
        cin >> a;
        a--;
        if(!(A[a] == 2019 or A[a]+1 == A[a+1])){
            A[a]++;
        }
    }
    for(int i=0; i<N; i++){
        cout << A[i] << enld;
    }
    return 0;
}


Measured memory_bytes: 3212
s=str(input())
if len(s)%2==1:
    print("No")
else:
    is_hitachi=1
    for i in range(int(len(s)/2)):
        if s[2*i]!="h" or s[2*i+1]!="i":
            is_hitachi=0
            break
    if is_hitachi==1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
#include<stdio.h>
#define MAX_i 50001

typedef struct process{
    char name[11];
    int time;
}pr;
void enqueue(pr x);
pr dequeue();
pr p[MAX_i];
int head,tail;

int main(void){
    int n,q,i,sum=0;
    pr x;
    
    scanf("%d %d",&n,&q);
    for(i=0;i<n;i++){
        scanf("%s %d",p[i].name,&p[i].time);
    }
    head=0;
    tail=n;
    while(head!=tail){
        x=dequeue();
        if(x.time<=q){
            sum+=x.time;
            printf("%s %d\n",x.name,sum);
        }else{
            sum+=q;
            x.time-=q;
            enqueue(x);
        }
    }
    return 0;
}

void enqueue(pr x){
    p[tail]=x;
    if(tail+1==MAX_i){
        tail=0;
    }else{
        tail++;
    }
}

pr dequeue(){
    if(head+1==MAX_i){
        head=0;
        return p[MAX_i-1];
    }else{
        head++;
        return p[head-1];
    }
}



Measured memory_bytes: 2480
function main(input) {
    'use strict'
    const num500   = parseInt(input.split('\n')[0],10);
    const num100   = parseInt(input.split('\n')[1],10);
    const num50    = parseInt(input.split('\n')[2],10);
    const totalYen = parseInt(input.split('\n')[3],10);

    let counter = 0;

    for (let i500 = 0; i500 <= num500; i500++) {
        for (let i100 = 0; i100 <= num100; i100++) {
            for (let i50 = 0; i50 <= num50; i50++) {
                let expextedYen = (500*i500) + (100*i100) + (50*i50);
                if(expextedYen === totalYen) {
                    counter++;
                }
            }
        }
    }
    console.log(counter);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
import sys;sys.setrecursionlimit(100000);n,k=map(int,input().split());x,t,e=10**9+7,[set()for _ in range(n)],enumerate
for i in range(n-1):a,b=map(int,input().split());t[a-1].add(b);t[b-1].add(a)
c=k
def b(o):
  global c
  for i,j in e(t[o-1]):c=(c*(k-2-i))%x;t[j-1].discard(o);b(j)
for i,j in e(t[0]):c=(c*(k-1-i))%x;t[j-1].discard(1);b(j)
print(c)

Measured memory_bytes: 109900
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef int64_t lint;
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using lb = long double;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SI(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define debug(x) cerr << #x << ": " << x << "\n"//手動デバッグ
#define debugV(x) for(int i=0;i<((ll)(x).size());i++)cerr << #x <<"at:"<<i<< ": " << x[i] << "\n"//手動デバッグ 
#define YES(c) cout<<((c)?"YES\n":"NO\n"),0
#define Yes(c) cout<<((c)?"Yes\n":"No\n"),0
#define O(p) cout<<p<<"\n",0
#define OS(p) cout<<p<<" ",0
#define ON(p) cout<<p,0
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define endl "\n"//endlを置き換える
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定

const int dy[4]={1,0,-1,0};
const int dx[4]={0,1,0,-1};//^>v<

template<class T=int> T in(){
    T x;
    cin>>x;
    return (x);
}
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 gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int Chatoi(char a){
    string s="";
    s+=a;
    return stoi(s);
}
//------------------------------------------------------------





//------------------------------------------------------------
int main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
//------------------------------------------------------------
    int n=in();
    if(n==0)O(1);
    else O(0);
    
    
    
    
    
    
    
    
//------------------------------------------------------------
	return 0;
}


Measured memory_bytes: 3612
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
  string S, T;

  cin >> S >> T;

  bool sol = false;
  int pos = 0;
  string ans = "";
  for (size_t i = 0; i < S.length(); i++) {
    if (i + T.length() > S.length()) break;
    if (S[i] == T[0] || S[i] == '?') {
      bool cur_sol = true;
      for (size_t j = 1; j < T.length(); j++) {
        if (S[i + j] != '?' && S[i + j] != T[j]) {
          cur_sol = false;
          break;
        }
      }
      if (cur_sol) {
        string tmp = S;
        pos = i;        
        for (size_t i = 0; i < T.length(); i++) {
          tmp[i + pos] = T[i];
        }
        for (size_t i = 0; i < S.length(); i++) {
          if (tmp[i] == '?') tmp[i] = 'a';
        }
        if (!sol) {
          sol = true;
          ans = tmp;
        } else {
          ans = min(ans, tmp);
        }
      }
    }  // if
  }    // i

  if (!sol) ans = "UNRESTORABLE";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.HashMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author koneko096
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    CManagement solver = new CManagement();
    solver.solve(1, in, out);
    out.close();
  }

  static class CManagement {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      Map<Integer, Integer> m = new HashMap<>();
      for (int i = 1; i < n; i++) {
        int p = in.nextInt();
        m.put(p, m.getOrDefault(p, 0) + 1);
      }
      for (int i = 1; i <= n; i++) {
        out.println(m.getOrDefault(i, 0));
      }
    }

  }


  static class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

  }
}



Measured memory_bytes: 62452
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll n;
    cin >> n;
    ll a[n];
    ll ans = 0;
    for (ll i = 0; i < n; i++) cin >> a[i];
    ll sum[n + 1];
    sum[0] = 0;
    map<ll, ll> mp;
    for (ll i = 0; i < n; i++) {
        sum[i + 1] = sum[i] + a[i];
    }
    for (ll i = 0; i < n+1; i++) {
        mp[sum[i]]++;
    }
    for (auto i : mp) {
        ans += (i.second * (i.second - 1)) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    string s;
    cin>>s;

    int n=s.size();
    bool flag=true;

    rep(i,n){
        flag&=(s[i]==s[n-1-i]);
    }

    string t="";
    rep(i,(n-1)/2){
        t+=s[i];
    }

    int m=t.size();
    rep(i,m){
        flag&=(t[i]==t[m-1-i]);
    }

    string u="";
    FOR(i,(n+3)/2-1,n){
        u+=s[i];
    }

    int l=u.size();
    rep(i,l){
        flag&=(u[i]==u[l-1-i]);
    }

    Yes(flag);



}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Mod:
    def __init__(self, m):
        self.m = m
    
    def add(self, a, b):
        return (a + b ) % self.m

    def sub(self, a, b):
        return (a - b) % self.m
    
    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, self.pow(b, self.m-2))

    def pow(self, x, y):
        if y == 0: 
            return 1
        elif y == 1: 
            return x % self.m
        elif y % 2 == 0: 
            return self.pow(x, y//2)**2 % self.m
        else: 
            return self.pow(x, y//2)**2 * x % self.m



@mt
def slv(N, S):
    CC = Counter()
    for c in S:
        CC[c] += 1

    for c in CC:
        CC[c] += 1
    
    m = Mod(10**9+7)
    return reduce(m.mul, CC.values()) - 1


def main():
    N = read_int()
    S = read_str()
    print(slv(N, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5956
N = int(input())+1
ali = list(map(int,input().split()))
nli = [0]*N

maxn = 2**(N-1)
nli[-1] = ali[-1]

for i in range(1,N+1):
  nli[-i] = min(maxn,nli[-i+1] + ali[-i])
  maxn //= 2
  

ulim = 1
for i in range(N):
  nli[i] = min(nli[i],ulim)
  ulim = (ulim - ali[i])*2
  if ulim < 0:
    print(-1)
    exit()
  
print(sum(nli))

Measured memory_bytes: 83596
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,a,b,c,d[10000],i,j;
	int s[1000],z[8000],v[10000],max;
	max=-1;
	scanf("%d",&n);
	scanf("%d %d",&a,&b);
	scanf("%d",&c);
	for(i=1;i<=n;i++){
		scanf("%d",&d[i]);
		s[i]=0;
		z[i]=0;
		v[i]=0;
	}
	s[0]=s[0]+c;
	z[0]=z[0]+a;
	sort(d+1,d+n+1,greater<int>());
	for(i=1;i<=n;i++){
		s[i]=s[i-1]+d[i];
		z[i]=z[i-1]+b;
	//	printf("xxx%d aaa%d\n",s[i],z[i]);
	}
	for(i=0;i<=n;i++){
		v[i]=s[i]/z[i];
		if(max<v[i]){
			max=v[i];
		}
	}
	printf("%d\n",max);
	return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b);
#define mins(a,b) a=min(a,b);

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){
   
    int n;cin>>n;
    vector<pi> a,b;
    int tmp;
    rep(i,n){
        cin>>tmp;
        a.emplace_back(tmp,i);
    }
    rep(i,n){
        cin>>tmp;
        b.emplace_back(tmp,i);
    }

    sort(all(a));
    sort(all(b));

    vi to(n);
    int frag=0;
    a.emplace_back(INT32_MAX,-1);
    rep(i,n){
        to[a[i].second]=b[i].second;
        if(a[i].first>b[i].first){
            cout<<"No"<<endl;
            return 0;
        }
        if(b[i].first>=a[i+1].first){
            frag=1;
        }
    }

    int c=0,ai=a[0].second,bi=b[0].second;
    while(ai!=bi){
        c++;
        bi=to[bi];
    }
    if(c<n-1){
        cout<<"Yes"<<endl;
        return 0;
    }

    if(frag){
        cout<<"Yes"<<endl;
        return 0;   
    }
    else cout<<"No"<<endl;

    return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll a, b;
    cin >> a >> b;
    ll res = 0;
    if (a > b)
    {
        res += a;
        a -= 1;
        if (a > b)
            res += a;
        else
        {
            res += b;
        }
    }
    else if (a < b)
    {
        res += b;
        b -= 1;
        if (a > b)
            res += a;
        else
        {
            res += b;
        }
    }
    else
    {
        res += (a + b);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
	os << "[ "; for(auto v : V) os << v << " "; return os << "]";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1> void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << endl;
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1<<" | ";
	__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define mems(x, y) memset(x, y, sizeof(x))
#define rep(i, n) for (int i = 0; i < n; ++i)
#define irep(i, n) for (int i = 1; i <= n; ++i)
#define print(x) cout << x << '\n'
#define err(x) clog << x << '\n'
typedef long long ll;
#define int ll
typedef long double ld;
#define double ld
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int INF = 0x3f3f3f3f;
const int M = 1e9+7;
const int N = 1e5+5;

int n;
vi g[N];

int dp[N][2];
bool done[N][2];

int dfs(int v, int p, int c) {
	if (done[v][c]) return dp[v][c];

	int ret = 1;
	if (c) {
		for (int u: g[v]) if (u != p) ret *= dfs(u, v, 0), ret %= M;
	} else {
		for (int u: g[v]) if (u != p) ret *= dfs(u, v, 0) + dfs(u, v, 1), ret %= M;
	}

	dp[v][c] = ret;
	done[v][c] = true;
	return ret;
}

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

	cin >> n;
	rep(i, n-1) {
		int x, y; cin >> x >> y;
		g[x].pb(y); g[y].pb(x);
	}

	g[1].pb(0);
	int ans = dfs(1,0,0) + dfs(1,0,1); ans %= M;
	print(ans);
}


Measured memory_bytes: 15872
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#define debug(...) (cerr<<"'"<<__FUNCTION__<<"': "),fprintf(stderr,__VA_ARGS__)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n;
int main()
{
	geti(n);
	int cnt0=0,cnt1=0,cnt2=0;
	for(int i=1;i<=n;i++)	
	{
		int x;
		geti(x);
		if(x%4==0)cnt2++;
		else if(x%2==0)cnt1++;
		else cnt0++;
	}
	if(cnt0>0)cnt2-=cnt0;
	if(cnt2==-1)
	{
		if(cnt1>0)puts("No");
		else puts("Yes");
	}
	else
	{
		if(cnt2<0)puts("No");
		else puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 384
<?php
$p='';
while(1){
  list($a,$o,$b)=explode(' ',trim(fgets(STDIN)));
  if($o=='?'){break;}
  switch($o){
    case '+':$p.=$a+$b;break;
    case '-':$p.=$a-$b;break;
    case '*':$p.=$a*$b;break;
    case '/':$p.=floor($a/$b);break;
  }
  $p.="\n";
}
print $p;

Measured memory_bytes: 15476
#include <stdio.h>
#include <math.h>
int main() {
    int n;scanf("%d",&n) ;
    n=n%10;
    if(n==2||n==4||n==5||n==7||n==9)printf("hon");
    else if(n==3)printf("bon");
    else printf("pon");
}

Measured memory_bytes: 1732
n = int(input())
loc = [list(map(int,input().split())) for _ in range(n)]
loc.sort(key = lambda x:x[2] ,reverse = True)
for i in range(101):
  for j in range(101):
    h = abs(loc[0][0]-i)+abs(loc[0][1]-j)+loc[0][2]
    for l in loc[1:]:
      if l[2] != max(h-abs(l[0]-i)-abs(l[1]-j),0):
        break
    else:
      print(i,j,h)
      break

      



Measured memory_bytes: 3064
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int ans = 0;
    for (int i = 1; i < n+1; i++){
      int x = i;
      int temp = 0;
      while (x > 0){
        temp += x%10;
        x
         /= 10;
      }
      if (a <= temp && temp <= b){ans += i;}
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 35440
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        a: [f64; n],
    }
    let mut sum = 0.0;
    for i in 0..n {
        sum += 1.0 / a[i];
    }
    println!("{}", 1.0 / sum);
}

Measured memory_bytes: 4352
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int H, W, K;
  cin >> H >> W >> K;

  vector<string> cs(H);
  F0R(r, H) {
    cin >> cs[r];
  }

  i64 result = 0;
  for (int rb = 0; rb < (1 << H); rb++) {
    for (int cb = 0; cb < (1 << W); cb++) {
      int n = 0;
      F0R(r, H) {
        if ((rb >> r) & 1) continue;
        F0R(c, W) {
          if ((cb >> c) & 1) continue;
          if (cs[r][c] == '#') n++;
        }
      }
      if (n == K) result++;
    }
  }
  cout << result;
}
#endif


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n, m, p;
    cin >> n >> m >> p;
    vector<vector<ll>> g(n);
    struct edge { ll from, to, cost; };
    vector<edge> es;
    REP(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        c -= p;
        es.push_back({a, b, -c});
    }

    vector<ll> dist(n, LLINF);
    dist[0] = 0;
    REP(i, n) {
        for(auto e: es) {
            if(dist[e.from] != LLINF && dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
            }
        }
    }
    ll ans = dist[n-1];

    vector<bool> neg(n);
    REP(i, n) {
        for(auto e: es) {
            if(dist[e.from] != LLINF && dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
                neg[e.to] = true;
            }
            if(neg[e.from]) neg[e.to] = true;
        }
    }

    if(neg[n-1]) cout << -1 << endl;
    else cout << max(0LL, -ans) << endl;

    return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      String x = sc.next();
      Stack<Character> stack = new Stack<>();
      int cntT = 0;
      for(char c : x.toCharArray()) {
        if(c == 'S') 
          stack.push(c);
        else {
          if(stack.isEmpty()) cntT++;
          else stack.pop();
        }
      }
      System.out.println(cntT + stack.size());
  }
}

Measured memory_bytes: 25604
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_set>
using namespace std;
//#define long long ll

int main() {
	int t;
	scanf("%d", &t);
	for (int i = 0; i < t; i++)
	{
		int n, d;
		scanf("%d %d", &n, &d);
		long long ans = (n - 1) * 127;
		if (n % 2 != 0)
			ans += d;
		else
			ans += d ^ 127;
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 256
// Problem : E - Knapsack 2
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define tc ll t;cin>>t;while(t--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF 1e18

int main()
{
	io;
	ll n,W,V=0,ans=-1;
	cin>>n>>W;
	vll w(n+1),v(n+1);
	FOR(i,1,n+1)
	{
		cin>>w[i]>>v[i];
		V+=v[i];
	}
	
	vvll dp(n+1,vll(V+1,INF));
	dp[0][0]=0;
	FOR(i,0,n+1)
	{
		dp[i][0]=0;
	}
	
	FOR(i,1,n+1)
	{
		FOR(j,1,V+1)
		{
			dp[i][j]=dp[i-1][j];
			if(j-v[i]>=0){dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+w[i]);}
		}
	}
	
	REV(i,V,1)
	{
		if(dp[n][i]<=W){ans=max(ans,i);}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 80256
// AOJ DSL_2_A Range Minimum Query (RMQ)
// 2018.5.5 bal4u
// 2018.5.17

#include <stdio.h>
#include <string.h>

#define INF 0xffffffff

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
unsigned in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(unsigned n)
{
	int i;
	char ob[20];
	char inf[11] = "2147483647";

	if (!n) pc('0');
	else if (n == INF) for (i = 0; i < 10; i++) pc(inf[i]);
	else {
		i = 0; while (n) ob[i++] = n%10 + '0', n/=10;
		while (i--) pc(ob[i]);
	}
	pc('\n');
}

#define MAX_N 100005
unsigned node[MAX_N << 2]; int sz;

unsigned range_min_query(int t, int l, int r, int x, int y)
{
	int m;
	unsigned a, b;

    if (x <= l && r <= y) return node[t];
    m = (l + r) >> 1;
    if (y <= m) return range_min_query(t << 1, l, m, x, y);
    if (m < x)  return range_min_query((t<<1)|1, m+1, r, x, y);
    else {
        a = range_min_query(t << 1, l, m, x, m);
		b = range_min_query((t<<1)|1, m+1, r, m+1, y);
		return (a <= b)? a: b; 
	}
}

void update(int t, int l, int r, int x, unsigned y)
{
	int m;
	unsigned a, b;

	if (l == r) { node[t] = y; return; }
 	m = (l + r) >> 1;
    if (x <= m) update(t << 1, l, m, x, y);
    else        update((t<<1)|1, m+1, r, x, y);

	a = node[t<<1], b = node[(t<<1)|1];
	node[t] = (a <= b)? a: b;
}


int main()
{
	int n, q, op;
	unsigned x, y;

	n = in(), q = in();
	sz = n << 2;
	memset(node, INF, sz << 2);

	while (q--) {
		op = in(), x = in()+1, y = in()+1;
		if (op) out(range_min_query(1, 1, n, (int)x, (int)y));
		else update(1, 1, n, (int)x, y-1);
	}
	return 0;
}



Measured memory_bytes: 3220
def yakusu(x):
    ans=[1]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        if(x%check==0):
            ans.append(check)
            while(x%check==0):
                x=x//check
        check+=1
    if x != 1:
      ans.append(x)
    return ans
def main():
    a,b = map(int,input().split())	
    ans=0
    y1=yakusu(a)
    for i in y1:
        if b%i==0:
            ans+=1
    print(ans)
 
main()

Measured memory_bytes: 3188
A, B, M = [int(x) for x in input().split(" ")]
As = list([int(x) for x in input().split(" ")])
Bs = list([int(x) for x in input().split(" ")])


minimumValue = 999999999
for i in range(M):
    x, y, c = [int(x) for x in input().split(" ")]
    x -= 1
    y -= 1
    minimumValue = min(minimumValue, As[x] + Bs[y] - c)

As.sort()
Bs.sort()

minimumValue = min(minimumValue, As[0] + Bs[0])
print(minimumValue)
    

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int x, n; std::cin >> x >> n;
    vi p(n); rep(i, n) std::cin >> p[i];
    sort(rng(p));
    int ans = inf, dist = 0;
    while (ans == inf) {
        if (!binary_search(rng(p), x-dist)) ans = x-dist;
        else if (!binary_search(rng(p), x+dist)) ans = x+dist;
        dist++;
    }
    std::cout << ans << "\n";
}


Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,i;
    cin >> n >> i;
    cout << n-i+1 << endl;
    return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int a,b,c;
    cin >>a>>b>>c;
    if(b-a==c-b) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    return 0;
}

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

const int N = 2e5 + 1;
pair<int, int> arr[N];

int main(int argc, char **argv)
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

#ifdef LOCAL_DEFINE
   freopen("in.txt", "r", stdin);
#endif

   int n;
   cin >> n;
   for (int i = 0; i < n; ++i)
      cin >> arr[i].second >> arr[i].first;
   // second = time to complete
   // first = deadline

   sort(arr, arr + n);
   for (int i = 0, time = 0; i < n; ++i)
   {
      if (time + arr[i].second <= arr[i].first)
      {
         time += arr[i].second;
      }
      else
      {
         cout << "No\n";
         return 0;
      }
   }

   cout << "Yes\n";

   return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		sc.close();
		
		int limit = (int) Math.floor(Math.sqrt(X));
		int ans = 1;
		int max = 1;
		
		for(int i=1; i<=limit; i++) {
			for(int j=2; j<1000; j++) {
				max = (int)Math.pow(i, j);
				if(max <= X) {
					if(ans < max) {
						ans = max;
					}else {
						ans += 0;
					}
				}
			}
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 21972
def main():
    import sys
    input = sys.stdin.readline

    def check(S, T):
        assert len(S) == len(T)
        for s, t in zip(S, T):
            if s == t or s == '?' or t == '?':
                continue
            return 0
        return 1

    A = input().rstrip('\n')
    B = input().rstrip('\n')
    C = input().rstrip('\n')
    la = len(A)
    lb = len(B)
    lc = len(C)
    AB = [1] * 10010
    BC = [1] * 10010
    AC = [1] * 10010
    for i in range(-lb, la+1):
        AB[i] = check(A[max(0, i):min(la, i+lb)], B[max(0, -i):min(lb, la-i)])
    for i in range(-lc, lb+1):
        BC[i] = check(B[max(0, i):min(lb, i+lc)], C[max(0, -i):min(lc, lb-i)])
    for i in range(-lc, la+1):
        AC[i] = check(A[max(0, i):min(la, i+lc)], C[max(0, -i):min(lc, la-i)])

    ans = la+lb+lc
    for i in range(-lb-lc-3, la+lc+3):
        if not AB[i]:
            continue
        for j in range(-lb-lc-3, la+lb+3):
            if BC[j-i] and AC[j]:
                l = min(0, i, j)
                r = max(la, lb+i, lc+j)
                #print(i, j, l, r, r-l)
                ans = min(ans, r-l)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 56156
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node {
	int key;
	Node *prev, *next;
};

Node *nil;

void init() {
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void insert(int key){
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

Node* listSearch(int key){
	Node *cur = nil->next;
	while(cur != nil && cur->key != key){
		cur = cur->next;
	}
	return cur;
}
void deleteNode(Node *t){
	if(t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst(){
	deleteNode(nil->next);
}

void delateLast(){
	deleteNode(nil->prev);
}

void deleteKey(int key){
	deleteNode(listSearch(key));
}

void printList() {
	Node *cur = nil->next;
	int isf = 0;
	while(1){
		if(cur == nil) break;
		if (isf++ > 0) printf(" ");
		printf("%d", cur->key);
		cur = cur->next; 
	}
	printf("\n");
}

int main(){
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for(i = 0; i < n; i++){
		scanf("%s%d", com, &key);
		if(com[0] == 'i'){insert(key); np++; size++; }
		else if(com[0] == 'd'){
			if(strlen(com) > 6){
				if(com[6] == 'F') deleteFirst();
				else if(com[6] == 'L') delateLast();
			} else {
				deleteKey(key); nd++;
			}
			size--;
		}
	}

	printList();
}






Measured memory_bytes: 33820
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
#define rg register
#define ll long long
#define LDB long double
#define ull unsigned long long
#define view(i,x) for(rg int i=hd[x];i!=-1;i=e[i].nt)
#define go(i,x,a) for(rg int i=a;i<x;i++)
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
using namespace std;

const int maxn=1000;
int n,a[maxn];

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc=='-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

int main(){
	n=rd(); n*=2;
	go(i,n+1,1) a[i]=rd();
	sort(a+1,a+n+1);
	int ans=0;
	for(rg int i=1;i<=n;i+=2) ans+=a[i];
	printf("%d",ans);
	
	return 0;
}//Faze


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

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
const int N = 300000;

vector<vector<int> > msp;

bool isprime(int k){
    return k % 7 == 1 || k % 7 == 6;
}

int main(){
    msp.assign(N, vector<int>());
    for(int i=2; i<N; ++i){
        if(!isprime(i) || !msp[i].empty())continue;
        for(int j=i; j<N; j+=i)if(isprime(j))msp[j].push_back(i);
    }
    for(int x; cin >> x, x != 1;){
        cout << x << ':';
        for(auto v: msp[x])cout << ' ' << v;
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 10896
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#define PI 3.14159265359
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	REP(i, h)cin >> a[i];
	vector<bool> row(h, false);
	vector<bool> col(w, false);

	REP(i, h) {
		REP1(j, w) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}
	REP(i, h) {
		if (row[i]) {
			REP1(j, w) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
	return 0;
}

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

int main(){
    int N; cin>>N;
    vector<int> B(N-1);
    for(int i=0;i<N-1;i++) cin>>B[i];

    int ans=B[0]+B[N-2];
    for(int i=0;i<N-2;i++){
        ans+=min(B[i],B[i+1]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int n, m;
int g[710][710], gg[710];

void init() {

}

void input() {
	cin >> n >> m;
	REP(i, n) REP(j, n) if (i != j) g[i][j] = 1;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a][b] = 0;
		g[b][a] = 0;
	}
}

bool go(int node, int num) {
	if (gg[node] == num) return true;
	if (gg[node] == -num) return false;
	gg[node] = num;
	REP(i, n) if (g[node][i]) {
		if (!go(i, -num)) return false;
	}
	return true;
}

void solve() {
	MSET(gg, 0);
	vector < pair<int, int> > v;
	REP(i, n) {
		if (gg[i] != 0) continue;
		int num = SZ(v) + 1;
		if (!go(i, num)) {
			cout << -1 << endl;
			return;
		}
		int c1 = 0;
		int c2 = 0;
		REP(j, n) {
			if (gg[j] == num) c1++;
			if (gg[j] == -num) c2++;
		}
		v.push_back(make_pair(c1, c2));
	}
	bool b[SZ(v)+1][n+1];
	REP(i, SZ(v)+1) REP(j, n+1) b[i][j] = false;
	b[0][0] = true;
	REP(i, SZ(v)) {
		REP(j, n+1) {
			if (b[i][j]) {
				b[i+1][j+v[i].first] = true;
				b[i+1][j+v[i].second] = true;
			}
		}
	}
	int res = 1<<30;
	REP(i, n+1) if (b[SZ(v)][i]) {
		chmin(res, i*(i-1)/2 + (n-i)*(n-i-1)/2);
	}
	cout << res << endl;
}

int main() {
	init();
	input();
	solve();
	return 0;
}


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

using namespace std;
using ll = long long;

const int N = 55, M = 21;

int n;
vector<pair<int, int>> g[N];
int m;
int pt[N];

bool prec(int st, int en, int id, int par = -1) {
	if(st == en) return true;
	for(auto p : g[st]) if(p.first != par) {
		if(prec(p.first, en, id, st)) {
			pt[p.second] |= 1 << id;
			return true;
		}
	}
	return false;
}

ll dp[N][1 << M];

ll f(int i, int mask) {
	if(i == n - 1) return mask == (1 << m) - 1;
	ll &ans = dp[i][mask];
	if(~ans) return ans;
	return ans = f(i + 1, mask) + f(i + 1, mask | pt[i]);
}

int main() {
	memset(dp, -1, sizeof dp);
	scanf("%d", &n);

	for(int i = 0; i < n - 1; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		g[u].emplace_back(v, i);
		g[v].emplace_back(u, i);
	}

	scanf("%d", &m);
	for(int i = 0; i < m; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		assert(prec(u, v, i));
	}

	printf("%lld\n", f(0, 0));
}


Measured memory_bytes: 901504
//Author Name - Mohammad Shehar Yaar Tausif
#include <bits/stdc++.h>
#include <math.h>
using namespace std;

typedef long long int lld;

int main(){
	long i,calc,n,arr[100000],DP[100000],k,j,mini=100000;
	cin>>n>>k;
	for(i=0;i<n;i++){
		cin>>arr[i];
	}
	DP[0] = 0;
	for(i=1;i<n;i++){
	    mini = 1e9 + 5;
        for(j=i-1;j>=i-k;j--){
            if(j>=0){
            calc = DP[j] + abs(arr[j] - arr[i]);
            mini = min(mini,calc);
            }
        }
        DP[i] = mini;
	}
	cout<<DP[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 1792