akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        String stations = scanner.nextLine();
        if (stations.contains("AB") || stations.contains("BA")) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }

}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

int a[100010];
signed main(){
    int n,l;
    cin>>n>>l;
    ll length=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
      
    }
    int index;
    bool ok=false;
    for(int i=0;i<n-1;i++){
        if(a[i]+a[i+1]>=l){
            ok=true;
            index=i;
            break;
        }
    }
    if(ok){
        cout<<"Possible"<<endl;
    for (int i = 0; i < index; i++)
    {
        cout<<i+1<<"\n";
    }
    for (int i = n-1; i >index; i--)
    {
        cout<<i<<"\n";
    }
    }
    else cout<<"Impossible"<<endl;
    
    
    return 0;
}

Measured memory_bytes: 1664
import itertools
import math

n = int(input())
dots = [list(map(int, input().split())) for _ in range(n)]
cities = list(range(n))

res = 0
cnt = 0
for pattern in itertools.permutations(cities, len(cities)):
    cnt += 1
    for i in range(n - 1):
        res += math.sqrt(
            (dots[pattern[i]][0] - dots[pattern[i + 1]][0]) ** 2
            + (dots[pattern[i]][1] - dots[pattern[i + 1]][1]) ** 2)

print(res / cnt)


Measured memory_bytes: 9140
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;


void main() {
    immutable long MAX = 2*10^^5+1;
    immutable long MOD = 10^^9+7;

    auto modinv = new long[](MAX);
    modinv[0] = modinv[1] = 1;
    foreach(i; 2..MAX) {
        modinv[i.to!int] = modinv[MOD % i.to!int] * (MOD - MOD / i) % MOD;
    }

    auto f_mod = new long[](MAX);
    auto f_modinv = new long[](MAX);
    f_mod[0] = f_mod[1] = 1;
    f_modinv[0] = f_modinv[1] = 1;

    foreach(i; 2..MAX) {
        f_mod[i.to!int] = (i * f_mod[i.to!int-1]) % MOD;
        f_modinv[i.to!int] = (modinv[i.to!int] * f_modinv[i.to!int-1]) % MOD;
    }

    long nck(int n, int k) {
        if (n < k) return 0;
        if (k == 0) return 1;
        return f_mod[n] * f_modinv[n-k] % MOD * f_modinv[k] % MOD;
    }

    
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;
    
    int l, r;
    auto B = new int[](N+1);
    B.fill(-1);
    foreach (i; 0..N+1) {
        if (B[A[i]] != -1) {
            l = B[A[i]];
            r = i;
            break;
        } else {
            B[A[i]] = i;
        }
    }

    foreach (i; 1..N+2) {
        long a = nck(N+1, i);
        long b = nck(l + N - r, i - 1);
        writeln(((a - b) % MOD + MOD) % MOD);
    }
}


Measured memory_bytes: 10684
#include <bits/stdc++.h>
#define MAX_LOOP (2)
using namespace std;
int main()
{
  int ABCD;
  cin >> ABCD;
  int a = ABCD / 1000;
  ABCD -= 1000 * a;
  int b = ABCD / 100;
  ABCD -= 100 * b;
  int c = ABCD / 10;
  ABCD -= 10 * c;
  int d = ABCD;
  char op1, op2, op3;
  for (int i = 0; i < MAX_LOOP; i++)
  {
    if ((i % 2) == 0) { op1 = '+'; }
    else { op1 = '-'; }
    for (int j = 0; j < MAX_LOOP; j++)
    {
      if ((j % 2) == 0) { op2 = '+'; }
      else { op2 = '-'; }
      for (int k = 0; k < MAX_LOOP; k++)
      {
        int sum = a;
        if ((k % 2) == 0) { op3 = '+'; }
        else { op3 = '-'; }

        if (op1 == '+') { sum += b; }
        else if (op1 == '-') { sum -= b; }
        if (op2 == '+') { sum += c; }
        else if (op2 == '-') { sum -= c; }
        if (op3 == '+') { sum += d; }
        else if (op3 == '-') { sum -= d; }
        if (sum == 7)
        {
          cout << a << op1 << b << op2 << c << op3 << d << "=7" << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
	int N,K;
		cin >> N >> K;
	int r;
	for(int i=0;i<N;i++)
		cin >> r;
	int ans=1;
	N-=K;
	K--;
	ans+=(N+K-1)/K;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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()
using namespace std;
typedef long long ll;

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int a, b;
    cin >> a >> b;
    rep(i, 100000) {
        if(i * 8 / 100 == a && i / 10 == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string n;
    cin >> n;
   if(n[1]==n[2] && (n[0]==n[1] || n[2] == n[3])){
       cout << "Yes" << endl;
   }
   else{
       cout << "No" << endl;
   }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <ios>
using namespace std;
int main(void){
  string s;
  cin >> s;
  int n;
  cin >> n;
  int l;
  l = s.length();
  
  for(int i=0;i<l;i+=n){
    cout << s[i];
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

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

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

x = n_in()

res = (x//500)*1000
x -= (x//500)*500
res += (x//5)*5
print(res)


Measured memory_bytes: 38256
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created:  2016-10-10
#

# Usage
#
"""

def inputs():
    return input()

def check_wrong_strs(inputed):
    """

    >>> check_wrong_strs("C0DEFESTIVAL2O16")
    2
    >>> check_wrong_strs("FESTIVAL2016CODE")
    16
    """
    num = 0
    RIGHT = "CODEFESTIVAL2016"

    for i, n in zip(inputed, RIGHT):
        if i != n:
            num += 1
    return num



if __name__ == "__main__":
    print(check_wrong_strs(inputs()))


Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#include <list>

using namespace std;

int main()
{
	int X, A;


	cin >> X >> A;

	if (X < A)
	{
		cout << 0;
	}
	else
	{
		cout << 10;
	}


	return 0;
}


Measured memory_bytes: 384
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

#define POSSIBLE cout<<"POSSIBLE"<<endl; return 0;
#define IMPOSSIBLE cout<<"IMPOSSIBLE"<<endl; return 0;

LL gcd(LL a,LL b){
    if(a<b){swap(a,b);}
    if(b==0) return a;
    return gcd(b,a%b);
}

LL mod_pow(LL x, LL n, LL mod){
    LL res=1ULL;
    while(n>0LL){
        if(n&1LL) res=res*x%mod;//最下位bitが立っている時だけresをかける
        x=x*x%mod;//xを2乗していく
        n>>=1LL;
    }
    return res;
}

LL mod=1000000007LL;

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d)<<endl;
}

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

using namespace std;
vector<string> ans;
int main(){
		int k;
  	string s;
  	cin >> k>>s;
  	int sz = s.size();
  	if(sz <= k){
			for(int i = 0; i<sz; i++)
				cout << s[i];
			cout <<endl; 
		}
  	else{
    	  for(int i = 0; i<k; i++)
					cout << s[i];
				cout << "...";
				cout << endl;
   }
     
return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> haveSweet(110, 0);

    for (int i = 0; i < k; i++)
    {
        int d; cin >> d;
        for (int j = 0; j < d; j++)
        {
            int a; cin >> a;
            haveSweet[a-1]++;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (haveSweet[i] == 0)  ans++;
    }
    cout << ans;
    /*for (int i = 0; i < n; i++)
    {
        cout << haveSweet[i] << " ";
    }*/
    
    return 0;
}

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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 3e5 + 5, M = 1e6 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e18 + 7;
const ll infll = 1e18 + 7;

int n, m, k;
int x, y, z;
int ans, cnt, tmp, idx, mx = -inf, mn = inf;
string s, t;
int a[N], b[N];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> x >> y;
    ans = n / (x + y) * x;
    n %= (x + y);
    cout << ans + min(n, x);
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 256
s = input()

a = int(s[0:2])
a_mm_flag = 1 <= a <= 12

b = int(s[2:4])
b_mm_flag = 1 <= b <= 12

if a_mm_flag:
    if b_mm_flag:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"
else:
    if b_mm_flag:
        ans = "YYMM"
    else:
        ans = "NA"

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e-a<=k){
    cout << "Yay!" << endl;
  }
  else {
    cout << ":(" << endl;
  }
}

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

int main() {
    long n;
    cin >> n;
    deque<long long> b;
    for (long i=0; i<n; i++) {
        long long a;
        cin >> a;
        if (i%2 == 0)
            b.push_back(a);
        else
            b.push_front(a);
    }
    if (n%2)
        reverse(b.begin(), b.end());
    for (long long bi: b)
        printf("%lld ", bi);
    puts("");
    return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

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

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

    map <int, int> M;
    M[1] = 1;
    int count = 0;
    int b = a[0];
    for (int i = 0; i < N; i++){
        M[b] ++;
        count ++;
        if (M[2] == 1){
            break;
        }else if(M[b] > 1){
            count = -1;
            break;
        }
        b = a[b - 1];
    }
    
    cout << count << endl;
    

    
    return 0;
}

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

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}

signed main(void) {
    int a,b,c,n;
    cin >> a >> b >> c >> n;
    vi x(n),y(n),z(n);
    rep(i,n)cin >> x[i] >> y[i] >> z[i];
    int ans = a*b*2 + a*c*2 + b*c*2;
    rep(i,n){
        int t = 0;
        if(x[i] == 0)t++;
        if(x[i] == a-1)t++;
        if(y[i] == 0)t++;
        if(y[i] == b-1)t++;
        if(z[i] == 0)t++;
        if(z[i] == c-1)t++;
        rep(j,i){
            int diff = abs(x[i]-x[j]) + abs(y[i]-y[j]) + abs(z[i]-z[j]);
            if(diff == 1)t++;
        }
        ans += -t + (6-t);
    }
    cout << ans << endl;
}



Measured memory_bytes: 3128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  char a, b;
  cin >> a >> b;
  if ((a == 'H' && b == 'H') || (a == 'D' && b == 'D') ) cout << "H" << endl;
  else cout << "D" << endl;
}



Measured memory_bytes: 256
for i in range(int(input())):
    x1, y1, x2, y2, x3, y3 = list(map(float,input().split()))

    a = x2 - x1
    b = y2 - y1
    c = (x1**2 - x2**2) + (y1**2 - y2**2)

    d = x3 - x1
    e = y3 - y1
    f = (x1**2 - x3**2) + (y1**2 - y3**2)

    l = (e*c - b*f) / (a*e - b*d)
    m = (c*d - f*a) / (b*d - a*e)
    n = -(x1**2 + y1**2 + l*x1 + m*y1)

    import math
    px = round(-l/2, 3)
    py = round(-m/2, 3)
    r = round(math.sqrt(l**2 + m**2 - 4*n ) / 2, 3)
    print("{:.3f} {:.3f} {:.3f}".format(px, py, r))

Measured memory_bytes: 7668
n, k = map(int, input().split())
x = list(map(int, input().split()))
l = 0

ans = 10 ** 18
for r in range(k-1, len(x)):
    ans = min(ans, abs(x[l]) + abs(x[r] - x[l]))
    ans = min(ans, abs(x[r]) + abs(x[r] - x[l]))
    l += 1
print(ans)


Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;

bool check(vector<int> a, vector<int> b, int c) {
	int sum = 0;
	for(int i = 0; i < a.size(); i++) {
		sum += a[i] * b[i];
	}
	sum += c;
	
	return sum > 0;
}

int main()
{
	int n, m, c;
	cin >> n >> m >> c;
	
	vector<int> b = vector<int>(m, 0);
	for(int i = 0; i < m; i++) {
		cin >> b[i];
	}

	vector<vector<int>> a = vector<vector<int>>(n, vector<int>(m, 0));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	
	int ans = 0;
	for(int i = 0; i < n; i++) {
		if(check(a[i], b, c)) {
			ans++;
		}
	}
	
	cout << ans << endl;
	
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int n, A[20];

int solve(int, int);

int main()
{
  int i, q, p;

  scanf("%d",&n);

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

  scanf("%d",&q);
  for(i = 0; i < q; i++) {
    scanf("%d",&p);
    if( solve(0, p) == 1) printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}

int solve(int i, int m)
{
  int res;
  if(m == 0) return 1;
  if(i >= n) return 0;
  res = solve(i+1,m) || solve(i+1, m - A[i]);
  return res;
}

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

using namespace std;
int main() {
  //  std::cout << "Hello, World!" << std::endl;
vector<vector<int>> c(3,vector<int>(3,0));
int i[6];
int b[3];
int j,k,max=0;
int maxs;
bool ans=false,flag;
for(k=0;k<3;k++){
    for(j=0;j<3;j++){
        cin>>c[j][k];
        if(c[j][k]>max)max=c[j][k];
    }
}

for(i[0]=0;i[0]<=max;i[0]++){
    for(i[1]=0;i[1]<=max;i[1]++){
        for(i[2]=0;i[2]<=max;i[2]++){
flag=true;
for(j=0;j<3;j++){
    b[j]=c[0][j]-i[0];
}
for(k=1;k<3;k++) {
    for (j = 0; j < 3; j++) {
        if (b[j] != c[k][j] - i[k]){
            flag=false;
            break;
        }
    }
}

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

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 金  2/22 10:17:52 2019

# Usage
#
"""
def s(a, b):
    """
    >>> s(1,2)
    3
    >>> s(1,1)
    2
    >>> s(8,20)
    12
    >>> s(4,12)
    16
    """
    if b % a == 0:
        print(a+b)
    else:
        print(b-a)
        
def i():
  return [int(i) for i in input().split()]


if __name__ == '__main__':
  s(*i())

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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

#define MAX_LEN 2001
#define MOD 1000000007
int s1[MAX_LEN], s2[MAX_LEN];
int N1;
int N2;
int dp[MAX_LEN][MAX_LEN];
int GetCommomSubsequencesCount()
{
	for (int i = 0; i <= N1; i++){//N1 is size of 1st string
		for (int j = 0; j <= N2; j++){//N2 is size of 2nd string
			dp[i][j] = 0;
		}
	}
	for (int i = 1; i <= N1; i++){
		for (int j = 1; j <= N2; j++){
			if (s1[i - 1] == s2[j - 1]){
				dp[i][j] = (1 + dp[i][j - 1] + dp[i - 1][j]) % MOD;                    
			}
			else{
				dp[i][j] =  ((dp[i][j - 1] + dp[i - 1][j]) % MOD - dp[i-1][j-1]) % MOD;
				if(dp[i][j] < 0) dp[i][j] += MOD;
			}
		}
	}
	return (dp[N1][N2] + 1) % MOD;
}

int main(void)
{
	cin >> N1 >> N2;
	rep(i, N1) cin >> s1[i];
	rep(i, N2) cin >> s2[i];
	cout << GetCommomSubsequencesCount() << endl;
	return 0;
}

Measured memory_bytes: 15872
#pragma GCC optimize ("-O3","unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<typeinfo>
#include<typeindex>
#include<type_traits>
#include<utility>
#include<valarray>
#include<vector>
#include<array>
#include<forward_list>
#include<random>
#include<ratio>
#include<tuple>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
 
using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int(i)=0; i<n; ++i)
#define rer(i,l,r) for(int i=l; i<=r; ++i)
#define gnr(i,l,r) for(int i=r; i>=l; --i)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

Int n,m,q,_,x,y;
string s,sb;
bool ok;
char ch;

template<class T,class F>
struct SegTree{
	V(T) seg;
	size_t size;
	const F f;
	const T e;
	SegTree(const V(T)& d,F f,T e):f(f),e(e){
		int n=d.size();
		size=1;
		while(size<n)size<<=1;
		seg.resize(size*2-1,e);
		rep(i,n)seg[i+size-1]=d[i];
		gnr(i,0,size-2)u(i);
	}

	void u(int i){
		seg[i]=f(seg[i*2+1],seg[i*2+2]);
	}

	void set(int i,T x){
		i+=size-1;
		seg[i]=x;
		while(i){
      i=(i-1)/2;
      u(i);
    }
	}
	T get(int a,int b,int i,int l,int r){
		if(r<=a||b<=l)return e;
		if(a<=l&&r<=b)return seg[i];
		int m=(l+r)/2;
		return f(get(a,b,i*2+1,l,m),get(a,b,i*2+2,m,r));
	}
	T get(int a,int b){
		return get(a,b,0,0,size);
	}
  T operator[](const int &i)const{
    return seg[i+size-1];
  }
};
template<class T,class F>
SegTree<T,F> segtree(const V(T)& d,F f,T e){
	return SegTree<T,F>(d,f,e);
}

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

  cin>>n>>q; V(Int)a(n,0);
  auto seg=segtree(a,plus<Int>(),0LL);
  rep(i,q){
    cin>>_>>x>>y; x--;
    if(!_)seg.set(x,seg[x]+y);
    else pri1(seg.get(x,y));
  }
}


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

char A[100][100];

int main() {
    int D; cin >> D;
    while(D--) {
        int N; cin >> N;
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < N; j++) {
                A[i][j] = ' ';
            }
        }
        int x = 0, y = N;
        const int dx[] = { 0, 1, 0, -1 };
        const int dy[] = { -1, 0, 1, 0 };
        int dir = 0;
        for(int i = 0; i < N; i++) {
            int k;
            if(i == 0) k = N;
            else k = N + 1 - (i + 1) / 2 * 2;

            for(int j = 0; j < k; j++) {
                x += dx[dir]; y += dy[dir];
                A[y][x] = '#';
            }
            (dir += 1) %= 4;
        }
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < N; j++) {
                cout << A[i][j];
            }
            cout << endl;
        }
        if(D != 0) cout << endl;
    }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll con(ll a) {
  return (a * (a - 1) / 2);
}

int main() {
  ll N; cin >> N;
  map<ll, ll> dp;
  vector<ll> A(N), B(N, 0);
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
    A.at(i)--;
    B.at(A.at(i))++;
  }
  ll s = 0;
  for(int i = 0; i < B.size(); i++) {
    s += con(B.at(i));
  }
  //cout << s << "s" << endl;
  for(int i = 0; i < N; i++) {
    if(dp.count(A.at(i))) {
      cout << dp.at(A.at(i)) << endl;
    } else {
      ll b = B.at(A.at(i));
      ll d = con(b);
      dp[A.at(i)] = (s - d + (d * (b - 2) / b));
      cout << dp.at(A.at(i)) << endl;
    }
  }
}

Measured memory_bytes: 12672
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <bitset>
#include <ctime>
using namespace std;

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

void solve()
{
    vector<int> dis(N-1);
    for (int i = 0; i < N-1; ++i) dis[i] = a[0] ^ a[i+1];
    int sum = 0;
    for (int i = 0; i < N-1; ++i) sum ^= dis[i];

    int ans = sum ^ a[0];
    cout << ans << " ";
    for (int i = 0; i < N-1; ++i){
        int ans2 = ans ^ dis[i];
        cout << ans2 << " ";
    }
    cout << endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    // int ti = clock();
    input();
    solve();
    // printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
    return 0;
}

Measured memory_bytes: 4776
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    char c;
    char clist[52];
    int cnt = 0;
    for (c = 'A'; c <= 'Z'; c++) {
        clist[cnt] = c;
        clist[cnt+26] = c;
        ++cnt;
    }
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    rep(i,S.size()) {
        char tmp = S[i];
        rep(j,26) {
            if (tmp == clist[j]) 
                cout << clist[j+N];
        }
    }
    cout << endl;
    return 0;
}














Measured memory_bytes: 256
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__



void solve(void){
  
  int N;
  cin >> N;
  
  vector<int> V(N);
  priority_queue<double, vector<double>, greater<double>> Q;
  
  REP(i,N){
    cin >> V[i];
    Q.push(V[i]);
  }
  
  while(Q.size()>1){
    double tmp1 = Q.top();
    Q.pop();
    double tmp2 = Q.top();
    Q.pop();
    Q.push((tmp1+tmp2)/2);
  }

  cout << fixed << setprecision(15);
  cout << Q.top() << endl;

  return;
   
}


int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VL;
typedef vector<pair<ll, ll>> VPI;
typedef pair<ll, ll> PLL;
typedef map<ll, ll> MLL;
#define EPS 1e-9
#define pb push_back
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector<double> p(n + 1);
    FOR(i, 1, n + 1)
    {
        cin >> p[i];
    }
    double dp[n + 1][n + 1] = {1.0};

    FOR(i, 1, n + 1)
    {
        FOR(j, 0, i + 1)
        {
            if (j == 0)
            {
                dp[i][j] = dp[i - 1][j] * (1.0 - p[i]);
            }
            else
            {
                dp[i][j] = dp[i - 1][j] * (1.0 - p[i]) + dp[i - 1][j - 1] * p[i];
            }
        }
    }
    double ans = 0.0;
    for (ll i = (n + 1) / 2; i <= n; i += 1)
        ans += dp[n][i];
    cout << fixed << setprecision(10) << ans;

    return 0;
}


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

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

    sort(S.begin(), S.end());
    string target = S[0];
    int max_count =0;
    int count =0;
    
    for(int i=0; i<N; i++){
        if(target == S[i]){
            count++;
        }

        if(i==(N-1) || target != S[i]){
            if(max_count < count){max_count=count;}
            target = S[i];
            count = 1;
        }
    }

    count = 0;
    target = S[0];
    for(int i=0; i<N; i++){
        if(target == S[i]){
            count++;
        }

        if(i==(N-1) || target != S[i]){
            if(count == max_count){
                cout << target << "\n";
            }
            target = S[i];
            count = 1;
        }
    }

    if(count == max_count){
        cout << target << "\n";
    }


    return 0;

}

Measured memory_bytes: 9568
#include <iostream>
#include <cmath>

using namespace std;
typedef long long ll;
ll N, X;

ll dfs(ll n, ll x) {
  if (x == 0) {
    return 0;
  }

  if (n == 0) {
    return 1;
  }
  ll ret = 0;
  // left ban
  x--;
  // if we eat all left n-1 burger
  if (x >= pow(2, n + 1) - 3) {
    ret += pow(2, n) - 1;
    x -= pow(2, n + 1) - 3;
  } else {
    return dfs(n-1, x);
  }
  // middle patty
  if (x > 0) {
    ret++;
    x--;
  }
  // right n-1 burger
  return ret + dfs(n-1, x);
}

void solve() {
  cout << dfs(N, X) << endl;
}

int main() {
  cin >> N >> X;
  solve();
}


Measured memory_bytes: 512
ans :: Int -> Int -> Int -> Int -> String
ans sx sy tx ty =
  let s1 = take (ty-sy) $ repeat 'U'
      s2 = take (tx-sx) $ repeat 'R'
      s3 = take (ty-sy) $ repeat 'D'
      s4 = take (tx-sx+1) $ repeat 'L'
      s5 = take (ty-sy+1) $ repeat 'U'
      s6 = take (tx-sx+1) $ repeat 'R'
      s7 = take (1)     $ repeat 'D'
      s8 = take (1)     $ repeat 'R'
      s9 = take (ty-sy+1) $ repeat 'D'
      s10= take (tx-sx+1) $ repeat 'L'
      s11= take (1) $ repeat 'U'

  in
    s1 ++ s2 ++ s3 ++ s4 ++ s5 ++ s6 ++ s7 ++ s8 ++ s9 ++ s10 ++ s11

main = do
  l <- getLine
  let (sx:sy:tx:ty:_) = map read $ words l :: [Int]
      o = ans sx sy tx ty
  putStrLn o
  


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

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
using namespace std;

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

string S;
int K;

signed main()
{
    cin >> S >> K;

    int ans = 1;

    rep(i, K)
    {
        if (S[i] != '1')
        {
            ans = S[i] - '0';
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    if (v.size() > 0) {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

int main() {
  string s;
  cin>>s;
  cout << s[0] << s[1] << s[2] << endl;
}

Measured memory_bytes: 3596
A, B = list(map(int, input().split()))

print(100,100)
for r in range(50):
    if r%2==1: print('#'*100)
    else:
        for c in range(100):
            if c%2==0 and A>1:
                print('.', end='')
                A-=1
            else:
                print('#', end='')
        print()

for r in range(50):
    if r%2==0: print('.'*100)
    else:
        for c in range(100):
            if c%2==0 and B>1:
                print('#', end='')
                B-=1
            else:
                print('.', end='')
        print()

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 505

ll gcd(ll a, ll b)
{
	return (b == 0 ? a : gcd(b, a % b));
}

ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}

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

	int n;
	cin >> n;
	pair<int, int> po[n];

	for (int i = 0; i < n; ++i)
	{
		cin >> po[i].ff >> po[i].ss;
	}
	
	sort(po, po + n);
	ll max = 0; pair<ll, ll> max_in;
	ll p, q;
	ll ans = n;
	map<pair<ll, ll>, ll> mi;

	for (int i = 0; i < n; ++i)
	{
		for (int j = i + 1; j < n; ++j)
		{
			mi[{po[j].ff - po[i].ff, po[j].ss - po[i].ss}]++;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		for(int j = i + 1; j < n; ++j)
		{			
			p = po[j].ff - po[i].ff,
			q = po[j].ss - po[i].ss;
			ll no = 0;
			// for(int k = 0; k < n; ++k)
			// {
			// 	ll px = po[k].ff + p, py = po[k].ss + q;
			// 	for(int l = k + 1; l < n; ++l)
			// 	{
			// 		if(px == po[l].ff && py == po[l].ss)
			// 		{
			// 			no++;
			// 		}
			// 	}
			// }
			// if(no > max)
			// {
			// 	max = no;
			// 	max_in = {p, q};
			// }
			if(mi[{p, q}] > max)
				max = mi[{p, q}];
		}
	}	
	// cout << max << "\n";
	ans -= max;

	cout << ans << "\n";
	return 0;
}

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

long long sum1toA(long long a){
    return a / 2 * (a + 1) + (a % 2) * (1 + a / 2);
}

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

    std::vector<std::string> strs(n);
    for(int i = 0; i < n; ++i){
        std::cin >> strs.at(i);
        std::sort(strs.at(i).begin(), strs.at(i).end());
//        std::cout << strs.at(i) << std::endl;
    }

    std::sort(strs.begin(), strs.end());

    int i = n - 1, flg = i - 1;
    long long count = 0;
    while(0 < i){
        if(flg == -1 || strs.at(flg) != strs.at(i)){
            count += sum1toA((i - flg) - 1);
            i = flg;
            flg = i - 1;
        }else{
            --flg;
        }
    
    }
 
    std::cout << count << std::endl;
 
    return 0;
}

Measured memory_bytes: 2560
let m = 1039999

let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i -> doit (sub s 0 i) (sub s (i + 1) (length s - i - 1) :: acc) in
  doit str []

let to_x = Array.make 128 0

let to_key s =
  let n = String.length s in
  let rec doit i p acc =
    if i = n then acc
    else doit (i + 1) (5*p) (acc + p*(to_x.(Char.code s.[i]))) in
  doit 0 1 0

let to_h1 k = k mod m
let to_h2 k = 1 + (k mod (m - 1))

let insert s t =
  let k = to_key s in
  let h1 = to_h1 k in
  let h2 = to_h2 k in
  let rec doit i =
    let h = (h1 + h2*i) mod m in
    if t.(h) = s then ()
    else if t.(h) = "\000" then t.(h) <- s
    else doit (i + 1) in
  doit 0

let find s t =
  let k = to_key s in
  let h1 = to_h1 k in
  let h2 = to_h2 k in
  let rec doit i =
    let h = (h1 + h2*i) mod m in
    if t.(h) = s then true
    else if t.(h) = "\000" then false
    else doit (i + 1) in
  doit 0

let () =
  to_x.(Char.code 'A') <- 1;
  to_x.(Char.code 'C') <- 2;
  to_x.(Char.code 'G') <- 3;
  to_x.(Char.code 'T') <- 4;
  let n = read_int () in
  let t = Array.make m "\000" in
  let rec doit i =
    if i < n then begin
      begin match split (read_line ()) ' ' with
      | ["insert"; s] -> insert s t
      | ["find"; s] -> print_endline (if find s t then "yes" else "no")
      | _ -> ()
      end;
      doit (i + 1)
    end in
  doit 0

Measured memory_bytes: 20640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, b) for (int i = a; i < b; i++)
typedef long long ll;
using namespace std;

int main(){
  int n, x, y;
  cin >> n >> x >> y;
  --x, --y;
  vector<int> ans(n);
  rep(i, n-1){
    for(int j = i+1; j < n; j++){
      int md = min(abs(i-j), abs(x-i)+abs(y-j)+1);
      ans.at(md-1)++;
    }
  }
  rep(i, n-1) cout << ans.at(i) << endl;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int>a(n),b(n),c(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i] >> c[i];
  }
  vector<vector<int>>dp(n + 1, vector<int>(3, 0));
  for (int i = 1; i <= n; ++i) {
    dp[i][0] = max(dp[i-1][1] + a[i-1], dp[i-1][2] + a[i-1]);
    dp[i][1] = max(dp[i-1][0] + b[i-1], dp[i-1][2] + b[i-1]);
    dp[i][2] = max(dp[i-1][0] + c[i-1], dp[i-1][1] + c[i-1]); 
  }
  cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
  return 0;
}

Measured memory_bytes: 6912
#include<iostream>
using namespace std;
long long mem[90];
long long lucas(int n){
  if(mem[n]!=-1)
    return mem[n];
  if(n==0)
    return mem[n]=2;
  if(n==1)
    return mem[n]=1;
  return mem[n]=lucas(n-1)+lucas(n-2);
}
int main(){
  int n;
  for(int i=0;i<90;i++)
    mem[i]=-1;

  cin >> n;
  cout << lucas(n) << endl;
  return 0;
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n,l; cin >> n >> l;
	int mn = 1000;
	int sum=0;
	bool neg = 0;
	for(int i=0; i<n; i++){
		int now = l+i;
		sum += now;
		if(abs(now)<mn){
			mn=abs(now);
			if(now<0)neg=1;
		}
	}
	if(neg)mn*=-1;
	cout << sum-mn << '\n';
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    vector<ll> a(n+1),b(n+1);
    rep(i,n)cin>>a[i+1];
    rep(i,n)cin>>b[i];
    vector<ll> h(n,inf);
    vector<int> fix(n);
    rep(i,n){
        h[i]=min(h[i],a[i+1]);
        if(a[i]<a[i+1])fix[i]=1;
    }
    rep(i,n){
        if(fix[i]&&b[i]<h[i]){
            cout<<0<<endl;
            return 0;
        }
        if(b[i]>b[i+1]&&b[i]>h[i]){
            cout<<0<<endl;
            return 0;
        }
        h[i]=min(h[i],b[i]);
        if(b[i]>b[i+1])fix[i]=1;
    }
    ll ans=1;
    rep(i,n){
        if(fix[i])continue;
        ans=ans*h[i]%mod;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 2944
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if (A == B) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21844
n, k = map(int, input().split())
diff = []
ti = int(input()) + 1
for _ in range(n - 1):
  ti1 = int(input())
  diff.append(ti1 - ti)
  ti = ti1 + 1

if n <= k:
  print(n)
else:
  diff.sort()
  print(n + sum(diff[:n - k]))


Measured memory_bytes: 10100
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int N;
    cin >> N;
    map<string,int> mp;
    rep(i,N){
        string S;
        cin >> S;
        mp[S]++;
    }
    int mx = 0;
    for(auto p : mp) mx = max(mx, p.second);
    for(auto p : mp){
        if(p.second != mx) continue;
        cout << p.first << endl;
    }
}

Measured memory_bytes: 19108
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#define FUP(i,x,y) for(int i=(x);i<=(y);i++)
#define FDW(i,x,y) for(int i=(x);i>=(y);i--)
#define MAXN 100010
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define ll long long
#define db double
using namespace std;
int read(){
    int w=0,flg=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')flg=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){w=w*10-'0'+ch,ch=getchar();}
    return w*flg;
}
int a,b,c;
int main(){
	a=read(),b=read(),c=read();
	printf("%d %d %d\n",c,a,b);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	LL n,a,b,ans=0;
	cin>>n>>a>>b;
	if(a==b)ans=1;
	else if(a>b)ans=0;
	else if(n==1){
		ans=0;
	}else{
		n--;
		ans=n*b+a-(n*a+b)+1;
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <utility>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define ll long long
#define rep(i,rept) for (ll i = 0; i < rept; i++)
#define Yes(b) std::cout<< (b ? "Yes" : "No")<<std::endl
#define YES(b) std::cout<< (b ? "YES" : "NO")<<std::endl
using namespace std;

int main() {
	int a[3] = {};
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[2] - a[0];
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
  A[i] -= i+1
A.sort()
#print(A)

def calc(b):
  res = 0
  for i in range(N):
    res += abs(A[i]-b)
  return res

if N % 2 == 1:
  print(calc(A[N//2]))
else:
  print(min(calc(A[N//2]),calc(A[(N-1)//2])))


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

int main() {
  int N, i, d, sum, p, a;
  cin >> N;
  i = N;
  d = 1;
  sum = 0;
  p = 1;
  a = 0;
  while (i > 10) {
    i /= 10;
    d++;
  }
  
  for (int j = 0; j < d; j++) {
    p*=10;
    a = (N-a)%p;
    sum += a / (p/10);
  }
  if (N%sum == 0)
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;

}


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

int main() {
  uint32_t a, b;
  std::cin >> a >> b;
  if (a < b) std::swap(a, b);

  while (b != 0) {
    uint32_t r = a % b;
    a = b;
    b = r;
  }

  std::cout << a << std::endl;

  return 0;
}


Measured memory_bytes: 3112