akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,k;
	cin >> n >> k;
	vector<int> h(n);
	for(int i=0; i<n; ++i) {
		cin >> h[i];
	}
	vector<int> dp(n, INT_MAX);
	for(int i=1; i<=k && i<n; ++i) {
		dp[i] = abs(h[i] - h[0]);
	}
	for(int i=k+1; i<n; ++i) {
		for(int j=i-1; j>=i-k; --j) {
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
		}
	}
	printf("%d", dp[n-1]);
	return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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; }

const long long INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vector<int> t(n);
  int sum = 0;
  rep(i, n){
    cin >> t[i];
    sum += t[i];
  }

  int m; cin >> m;
  rep(i, m){
    int p, x; cin >> p >> x;
    cout << sum - t[p-1] + x << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

void print_a(VI v)
{
    if(v.size()) cout<<v[0];
    loop(i,1,v.size()) cout<<' '<<v[i];
    cout<<'\n';
}

VVI init_vvi(int n, int m, int val)
{
    return VVI(n,VI(m,val));
}

VVL init_vvl(int n, int m, LL val)
{
    return VVL(n,VL(m,val));
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    cin>>n;
    int a[n];
    loop(i,0,n) cin>>a[i];

    LL b = 0, s = 1000, l = 0, b1, l1, s1;
    loop(i,0,n)
    {
        b1 = s/a[i];
        l1 = s % a[i];
        s1 = (b * a[i]) + l;
        if(b < b1)
        {
            b = b1; l = l1;
        }
        else if(b == b1 && l < l1) {b = b1; l = l1;}
        s = max(s,s1);
    }

    cout<<s<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 3568
from collections import deque
N=int(input())
*A,=map(int, input().split())
B=deque([])
S=False
for i in range(N):
    if i==0:
        B.append(A[i])
    else:
        if i%2==1:
            B.appendleft(A[i])
            S=False
        else:
            B.append(A[i])
            S=True
B=list(B)
if S:
    B=reversed(B)

print(*B)

Measured memory_bytes: 25540
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int a,b,c;cin>>a>>b>>c;
	if (a == b && b == c){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

///////////////////////////


	
int main() {
	
	ll a, b;
	cin >> a >> b;

	cout << (1 + b - a)*(b - a) / 2 - b;

	system("PAUSE");
}

Measured memory_bytes: 504
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from collections import Counter
import math
import sys
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def main():
    N = int(input())
    print(N*2*math.pi)


if __name__ == '__main__':
    main()


Measured memory_bytes: 84876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

char c;

int main() {
	fastio; cin >> c;
	if ('a' <= c and c <= 'z') cout << 'a';
	else cout << 'A';
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long int
#define forr(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
#define oo 2000000000000000000LL
using namespace std;


void _sol(){
    int n; cin >> n;
    if(n>=30) cout << "Yes";
    else cout << "No";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    _sol();
}


Measured memory_bytes: 3588
#include <stdio.h>
int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);
	if(a>b){
		printf("a > b\n");
	}else if(a<b){
		printf("a < b\n");
	}else{
		printf("a == b\n");
	}
	return 0;
}

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

long long num[100005];

int main () {
	for (long long i = 1; i <= 9; ++i)
		num[i] = i;
	int pr = 9, pl = 1;
	while (pr <= 100000) {
		long long gw = num[pl] % 10;
		if (gw == 0) {
			num[++pr] = num[pl] * 10 + gw;
			num[++pr] = num[pl] * 10 + gw + 1;
		}
		else if (gw == 9) {
			num[++pr] = num[pl] * 10 + gw - 1;
			num[++pr] = num[pl] * 10 + gw;
		}
		else {
			num[++pr] = num[pl] * 10 + gw - 1;
			num[++pr] = num[pl] * 10 + gw;
			num[++pr] = num[pl] * 10 + gw + 1;
		}
		++pl;
	}
	int n;
	cin >> n;
	cout << num[n] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define lim 1000000007
#define MAX 10001
#define uomap unordered_map
#define uoset unordered_set
#define pb push_back
#define vec vector
#define mkp make_pair
#define fir first
#define sec second
#define LOG(fmt, args...) fprintf(stdout, fmt, ##args);
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
const ld  pi   = 4.0*atanl(1.0);
const int iinf = 1e9 + 10;
const ll  inf  = 1e18 + 10;
using namespace std;

static int max_points = 200; 
ll dis(ll a, ll b, ll c, ll d){ return abs(a-c)+abs(b-d); }

int main() {
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    
    ll a,b,c; cin >> a >> b >> c; 
    if(a == b && b != c){
    	cout << "Yes" << endl;
    }else if(b == c && c != a){
    	cout << "Yes" << endl;
    }else if(c == a && a != b){
    	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }
    
    return 0; 
    
}



/*
 * akina.cpp
 * Copyright 2019 Karan Kanojia <karankanojia@Karans-MacBook-Air.local>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 */


Measured memory_bytes: 256
import numpy as np

n, m, x = list(map(int, input().split()))
a = [list(map(int,input().split())) for l in range(n)]
x_list = [x]*m
s = range(2**n)
ans = 10**10
count = 0
for i in s:
    y = np.zeros(m+1)
    for j in range(n):
        if ((i>>j)&1):
            y = y+np.array(a[j])
    
    if np.all(np.array(y[1:])>=np.array(x_list)):
        count = 1
        ans = min(ans, y[0])  

if count == 1:
    print(int(ans))     
else:
    print(-1)  

Measured memory_bytes: 27236
/* In The Name Of God */
#include <bits/stdc++.h>

# define xx first
# define yy second
# define pb push_back
# define pp pop_back
# define eps 1e-9
# define err(x) cerr << #x << " ::   " << x << endl;

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;

int main(){
	ios_base::sync_with_stdio (0);
	string s;cin>>s;
	if(s.size() < 4){
		cout<<"No\n";
	}
	else if(s.substr(0,4) == "YAKI"){
		cout<<"Yes\n";
	}
	else
		cout<<"No\n";
	return 0;
}



Measured memory_bytes: 256
x,n=list(map(int, input().split()))
if n!=0:
    p=list(map(int, input().split()))
d=0
t=0
if n==0:
    print(x)
if n!=0:
    while t==0:
        if (x-d) not in p:
            print (x-d)
            t=1
        elif (x+d) not in p:
            print (x+d)
            t=1
        else:
            d+=1




Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
int main(){
  long double N;
  int K;
  cin >> N >> K;
  vector<double> A(N);
  long double prob;
  for (int i = 1; i <= N; i++){
    int coin = 0;
    while (i * pow(2, coin) < K){
      coin ++;
    }
    prob = 1 / N;
    A.at(i-1) = prob * pow(0.5, coin);
  }
  cout << fixed << setprecision(15);
  cout << accumulate(A.begin(), A.end(), 0.0) << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<functional>
#include<map>
using namespace std;
int main()
{
	int n, i, j, k,r1=1,r2;
	cin >> n;
	i = 1;
	while (r1 <= n)
	{
		r2 = r1;
		r1 = i*i;
		i++;
	}
	cout << r2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <regex>
#include <string>
#include <cstdlib>
#include <math.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int count = 0;
  int n = 1;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a == n) {
      n++;
    } else {
      count++;
    }
  }

  if (n == 1) {
    cout << -1 << endl;
  } else {
    cout << count << endl;
  }
  return 0;
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  bool ok = false;
  for (ll i = 0; i < s.size(); i+=2) {
    if (s[i] == 'h' && s[i+1] == 'i') ok = true;
  }

  if (ok && s.size() % 2 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
struct Node{
    int key;
    Node *left;
    Node *right;
    Node *parent;
};
Node *NIL;
Node *root = NIL;
bool find(int key){
    Node *x = root;
    bool flag = false;
    while(x!=NIL){
        if(x ->key < key){
            x = x->right;
        }else if(x -> key > key){
            x = x->left;
        }else{
            flag = true;
            break;
        }
    }
    return flag;
}
void insert(int key){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = new Node;
    z -> key = key;
    z -> left = NIL;
    z ->right = NIL;
    while(x!=NIL){
        y = x;
        if(z -> key < x ->key){
            x = x->left;
        }else{
            x = x->right;
        }
        z -> parent = y;
    }
    if(y==NIL){
        root = z ;
    }else if(z -> key < y -> key){
        y -> left = z;
    }else{
        y->right = z;
    }
}
void inorder(Node *p){
    if(p==NIL){
        return;
    }
    inorder(p->left);
    cout << ' ' << p->key;
    inorder(p->right);
}
void preorder(Node *p){
    if(p==NIL){
        return;
    }
    cout << ' ' << p -> key;
    preorder(p->left);
    preorder(p->right);
}
void print(void){
    inorder(root);
    cout << endl;
    preorder(root);
    cout << endl;
}
int main(void){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string command;
        cin >> command;
        if(command[0]=='i'){
            int key;
            cin >> key;
            //cout << key << endl;; 
            insert(key);

        }else if(command[0]=='f'){
            int key;
            bool flag;
            cin >> key;
            flag = find(key);
            if(flag){
                cout << "yes" << endl;
            }else{
                cout << "no" << endl;
            }
        }else{
            print();
        }
    }
    return 0;
}


Measured memory_bytes: 21804
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
#include <string>
#include <limits>
//#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b)//最大公約数
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;
vector<int> v;
class Calc
{
    // 宣言
    long long a;

    public:
        // 素因数分解
        void decompositPrime(long long a);
};

/*
 * 素因数分解
 */
void Calc::decompositPrime(long long n)
{
    // 割る数の初期値
    a = 2;
    // √n ≧ a ( n ≧ a * a ) の間ループ処理
    while (n >= a * a) {
        // a で割り切れたら、a は素因数
        // そして、割られる数を a で割る
        // a で割り切れなかったら、 a を 1 増加させる
        if (n % a == 0) {
            //printf("%d * ", a);
             v.push_back(a);
            n /= a;
        } else {
            a++;
        }
    }
    // 最後に残った n は素因数
    v.push_back(n);
    //printf("%d\n", n);
}
vector<int> divisor(int n) {//約数発見
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    std::sort(ret.begin(), ret.end());
    return ret;
}
long nc2(long n){
    return n*(n-1)/2;
}
template<typename TypeInt>
std::string Itoa(const TypeInt v, int base)
{
	static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	string ret;
	static numeric_limits<TypeInt> t;
	TypeInt n = v;
	if (t.is_signed) {
		if (v < 0) n *= -1;
	}

	while (n >= base) {
		ret += table[n%base];
		n /= base;
	}
	ret += table[n];
	if (t.is_signed) {
		if (v < 0 && base == 10) ret += '-';
	}
	// 文字列の順番を逆にする
	std::reverse(ret.begin(), ret.end());

	return ret;
}

int main(){
    //std::stack<int> stack;
    int h,w,k;
    cin >> h >> w >> k;
    char c[6][6];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> c[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < (int)pow(2,h); i++){
        for(int j = 0; j < (int)pow(2,w); j++){
            int cnt = 0;
            for(int x = 0; x < h; x++){
                for(int y = 0; y < w; y++){
                    if ('#' == c[x][y] && (((i >> x) & 1) == 0 && ((j >> y) & 1) == 0)) {
                        cnt++;
                    }
                }
            }
            if(k == cnt){
                ans ++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}







Measured memory_bytes: 4048
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;
class Node{
public:
    int x,y,cost;
    Node(int x,int y,int cost):x(x),y(y),cost(cost){}
    Node(){}
};
char map[1010][1010];
bool flag[1010][1010];
int h,w,n;
int bfs(char s,char e);
int main()
{
    cin>>h>>w>>n;
    for(int j=0;j<h;++j){
        for(int i=0;i<w;++i){
            cin>>map[i][j];
        }
    }
    int ans=0;
    char f=n+'0';
    ans+=bfs('S','1');
    for(char S='1';S<f;++S){
        ans+=bfs(S,S+1);
    }
    cout<<ans<<endl;
    return 0;
}
int bfs(char s,char e)
{
    int dx[4]={0,0,1,-1},dy[4]={-1,1,0,0};
    memset(flag,0,sizeof(flag));
    queue<Node> q;
    for(int j=0;j<h;++j){
        for(int i=0;i<w;++i){
            if(map[i][j]==s){
                q.push(Node(i,j,0));
            }
        }
    }
    while(!q.empty())
    {
        Node t=q.front();q.pop();
        if(map[t.x][t.y]==e)return t.cost;
        if(flag[t.x][t.y])continue;
        for(int i=0;i<4;++i){
            Node next=t;
            next.cost++;
            next.x+=dx[i];next.y+=dy[i];
            if(next.x>=0&&next.y>=0&&next.x<w&&next.y<h&&map[next.x][next.y]!='X')q.push(next);
        }
        flag[t.x][t.y]=true;
    }
}

Measured memory_bytes: 3204
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}

int main(void){
	int n=nextint();
	int ans=0;
	for(int i=1; i<=n; i++){
		int a=nextint();
		if((a&i&1)==1) ans++;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 1596
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  string s;
  cin >> s;
  sort(all(s));
  if(s[0]==s[2]){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }


return 0;
}
///....


Measured memory_bytes: 256
def gcd(a, b):
    if a > b:
        a, b = (b, a)
    while b:
        a, b = b, a % b
    return a


def main():
    a, b = map(int, input().split())
    ans = round(a * b / gcd(a, b))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import heapq
def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
    lastelt = heap.pop()
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt

n,m,*a = map(int, open(0).read().split())

heapq._heapify_max(a)
s = sum(a)
d = 0
for i in range(m):
  t = _heappop_max(a)
  d += t-t//2
  _heappush_max(a, t//2)

print(s-d)

Measured memory_bytes: 14180
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n = ni()
a = collections.deque(nl())
ans = collections.deque()
if n % 2 == 0:
    for i in range(n):
        if i % 2 == 0:
            ans.append(str(a.popleft()))
        else:
            ans.appendleft(str(a.popleft()))
else:
    for i in range(n):
        if i % 2 == 0:
            ans.appendleft(str(a.popleft()))
        else:
            ans.append(str(a.popleft()))
print(' '.join(ans))


Measured memory_bytes: 26676
#include <stdio.h>

typedef struct List {
	struct List *next;
	int v;
} list;

int main()
{
	int i, N, u, w;
	list *adj[100001] = {}, e[200001];
	scanf("%d", &N);
	for (i = 0; i < N - 1; i++) {
		scanf("%d %d", &u, &w);
		e[i*2].v = w;
		e[i*2+1].v = u;
		e[i*2].next = adj[u];
		e[i*2+1].next = adj[w];
		adj[u] = &(e[i*2]);
		adj[w] = &(e[i*2+1]);
	}
	
	int par[100001] = {}, q[100001], head, tail;
	list *p;
	par[1] = 1;
	q[0] = 1;
	for (head = 0, tail = 1; head < tail; head++) {
		u = q[head];
		for (p = adj[u]; p != NULL; p = p->next) {
			w = p->v;
			if (par[w] == 0) {
				par[w] = u;
				q[tail++] = w;
			}
		}
	}
	
	int ans[100001] = {};
	for (head--; head > 0; head--) {
		u = q[head];
		ans[u]++;
		ans[par[u]] ^= ans[u];
	}
	
	if (ans[1] == 0) printf("Bob\n");
	else printf("Alice\n");
	fflush(stdout);
	return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int n, m;
  cin >> n >> m;

  ll total = 0;

  vector<ll> a(m);
  rep(i, m) cin >> a[i];

  rep(i, m){
    total += a[i];
  }

  if(total > n){
    cout << -1 << endl;
  }else{
    cout << n - total << endl;
  }


  return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
int main()
{

    int a, b;
    cin >> a >> b;
    if(a>=b){
        for(int i=0;i<a;i++){
            cout << b;
        }
    }
    else{
        for(int i=0;i<b;i++){
            cout << a;
        }
    }
    cout << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
const ll INF=1000000000;

int main(){
    ll N;
    cin>>N;
    string S;
    cin>>S;
    int L[5010][5010];
    L[1][1]=0;
    int Max=0;
    for(int i=2; i<=N; i++){
        if(S.at(0)==S.at(i-1)){
            L[1][i]=1;
            L[i][1]=1;
            Max=1;
        }
    }
    
    for(int i=1; i<N; i++){
        for(int j=1; j<N; j++){
            if(S.at(i)==S.at(j)&&j-(i+1)>=L[i][j]){
                L[i+1][j+1]=L[i][j]+1;
                Max=max(Max, L[i+1][j+1]);
            }
            else{
                L[i+1][j+1]=0;
            }
        }
    }
    cout<<Max;
    return 0;
}

Measured memory_bytes: 98176
function Main (input) {
  input = input.split("\n")[0].split(" ");
  var t1 = swap(input[0], input[1]);
  input[0] = t1[0];
  input[1] = t1[1];
  var t2  = swap(input[0], input[2]);
  input[0] = t2[0];
  input[2] = t2[1];
  console.log("%d %d %d", input[0], input[1], input[2]);
  function swap (a, b) {
    return [b, a];
  }
}

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

Measured memory_bytes: 7372
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char c[] = new char[6];
    c = s.toCharArray();
    if(c[2]==c[3]&&c[4]==c[5]){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21716
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  /*  (a+b)m<=60*t+c<=(a+b)*m+a
    0<=60*t+c-(a+b)*m<=a
    0 <= c-(a+b)*m<=a
    c-a<=(a+b)*m
(c-a)/(a+b)<=m


  */
  int a,b,c;
  cin>>a>>b>>c;
  rep(i,1e9){
    if(i==10000000){cout<<-1<<endl;break;}
    double m=(60*i+c-a)/(double)(a+b);
    if(m<0){cout<<c<<endl;break;}
    int mm=(int)(m+0.99999999999999);
    if(0<=60*i+c-(a+b)*mm){cout<<60*i+c<<endl;break;}
  }
}

Measured memory_bytes: 1160
from collections import Counter

N = int(input())
*A, = map(int, input().split())
A.sort()
C = Counter(A)
MAX = 1010101
B = [0]*MAX

ans = 0
for a, cnt in C.items():
    if B[a]:
        continue
    for i in range(2*a, MAX, a):
        B[i] = 1
    if cnt == 1:
        ans += 1

print(ans)


Measured memory_bytes: 38640
#include <stdio.h>

int main(void) {
    int n;
    int p[20];
    int count;

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

    count = 0;
    for (int i = 1; i < n - 1; i++) {
        if (p[i - 1] < p[i] && p[i] < p[i + 1]) {
            count++;
        }
        else if (p[i - 1] > p[i] && p[i] > p[i + 1]) {
            count++;
        }
    }

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

    return 0;
}


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

using namespace std;
#define ll long long
#define r(i, n) for(int i=0;i<n;i++)

int main() {
    int q;
    multiset<int> s;
    cin >> q;
    while (q--) {
        int x, y;
        cin >> x >> y;
        if (x == 1)cout << s.count(y) << endl;
        else if (!x) {
            s.insert(y);
            cout << s.size() << endl;
        } else if (x == 2)s.erase(y);
        else {
            int l = y, r;
            cin >> r;
            set<int>::iterator end, it;
            it = s.lower_bound(l);
            end = s.upper_bound(r);
            for (; it != end; it++) {
                cout << (*it) << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 12360
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {

	ll x, y, z;
	cin >> x >> y >> z;
	cout << (x - z) / (y + z) << endl;
}

Measured memory_bytes: 256
from numpy import sqrt
N,P = map(int,input().split(" "))
lm = pow(P,1/N) + 0.5
if N == 1:
    print(P)
    exit(0)

ans = 1
for i in range(1,int(sqrt(P))+10):
    if P % i == 0:
        if i <= lm and P % pow(i,N) == 0:
            ans = max(i,ans)
        if (P//i) <= lm and P % pow((P//i),N) == 0:
            ans = max(P//i,ans)

print(ans)

Measured memory_bytes: 21664
main :: IO ()
main = do ls <- getContents
          putStr (compose ls)

compose :: String -> String
compose = unlines . fmap unlines . rects . fmap (toTupleofInts . take 2 . words) . lines
          where
            toTupleofInts =  (\[x,y] -> (x,y)) . fmap (\x -> read x::Int)

rects :: [(Int, Int)] -> [[String]]
rects [] = []
rects ((m, n):xs) | m == 0 && n == 0 = []
                  | otherwise = rect m n m : rects xs

rect :: Int -> Int -> Int -> [String]
rect 0 _ _ = []
rect m n l | m == 1 || m == l = replicate n '#' : rect (m - 1) n l
           | otherwise = ("#" ++ replicate (n - 2) '.' ++ "#") : rect (m - 1) n l

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<ll, int> ll_i;

double f(ll N){
    ll n, dig;
    n = N;
    ll sum = 0;

    while(n){
        dig = n % 10;
        sum = sum + dig;
        n = n / 10;
    }
    return (double)N / sum;
}

int main() {
    ll K;
    cin >> K;
    ll a = 1, order=1;
    for(int i = 0; i < K; i++){
        cout << a << endl;
        if (f(a + pow(10, order-1)) > f(a + pow(10, order))){
            order++;
        }
        a += pow(10, order-1);
    }
    return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> A(n);
    vector<vector<int>> X(n, vector<int>(0));
    vector<vector<int>> Y(n, vector<int>(0));
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        X[i] = vector<int>(A[i]);
        Y[i] = vector<int>(A[i]);
        for (int j = 0; j < A[i]; j++) {
            cin >> X[i][j] >> Y[i][j];
            X[i][j]--;
        }
    }

    vector<int> b(n);
    int out = 0;
    for (int i = 0; i < (1 << n); i++) {
        int k = i;
        for (int j = 0; j < n; j++) {
            b[j] = k % 2;
            k /= 2;
        }

        bool is_ok = true;
        for (int j = 0; j < n; j++) {
            if (b[j] == 0) continue;
            for (int k = 0; k < A[j]; k++) {
                if (b[X[j][k]] != Y[j][k]) {
                    is_ok = false;
                    break;
                }
            }
            if (!is_ok) break;
        }

        if (is_ok) out = max(out, accumulate(b.begin(), b.end(), 0));
    }

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	string a, b, c;
	cin >> a >> b >> c;
	printf("%c%c%c\n", a[0]+'A'-'a',b[0]+'A'-'a',c[0]+'A'-'a');
	//cout << max(a*b,c*d) << endl;
	//printf((a+b==c||b+c==a||c+a==b) ? "Yes\n" :"No\n");
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		return F?n:-n;
	}
}
const int M=998244353;
int f[222222][3][4][2];
char s[222222],t[222222];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1),sum=0;
	for(register int i=1;i<=n;++i)sum+=s[i]-'a';
	strcpy(t+1,s+1);
	std::sort(t+1,t+n+1);
	if(t[1]==t[n])puts("1"),exit(0);
	if(n==2)puts("2"),exit(0);
	if(n==3)
	{
		if(s[1]!=s[2]&&s[1]!=s[3]&&s[2]!=s[3])puts("3"),exit(0);
		if(s[1]==s[2]||s[2]==s[3])puts("6");
		if(s[1]==s[3])puts("7");
		exit(0);
	}
	f[0][0][3][0]=1;
	for(register int i=0;i<n;++i)
		for(register int j=0;j<=2;++j)
			for(register int la=0;la<=3;++la)
				for(register int k=0;k<=1;++k)
					for(register int d=0;d<=2;++d)
						(f[i+1][(j+d)%3][d][k|(la==d)]+=f[i][j][la][k])%=M;
	int ans=0;
	int fl=0;
	for(register int i=1;i<n;++i)if(s[i]==s[i+1])fl=1;
	if(fl==0)ans=1;
	for(register int la=0;la<=2;++la)(ans+=f[n][sum%3][la][1])%=M;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 20608
#![allow(unused_imports)]
#![allow(unused_variables)]
use proconio::input;
use proconio::marker::*;
use std::cmp::{min, max};
use std::collections::{HashSet, HashMap, BinaryHeap};

fn main() {
    input! {
        a: isize,
        b: isize,
    }
    println!("{}", a * b);
}


Measured memory_bytes: 2148
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
h,w=map(int,input().split())
s=[input() for _ in range(h)]
seen=[[0]*w for _ in range(h)]
p=[(1,0),(-1,0),(0,1),(0,-1)]
cnt=0
for i in range(h):
    cnt+=s[i].count(".")
d=deque()
d.append((0,0))
seen[0][0]=1
res=0
while True:
    if not d:
        break
    i,j=d.pop()
    for idx in p:
        x,y=idx
        if 0<=i+x<h and 0<=j+y<w and seen[i+x][j+y]==0 and s[i+x][j+y]==".":
            d.appendleft((i+x,j+y))
            seen[i+x][y+j]=seen[i][j]+1
    if seen[h-1][w-1]!=0:
        break
if seen[h-1][w-1]==0:
  print(-1)
else:
  print(cnt-seen[h-1][w-1])

Measured memory_bytes: 40304
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            //var line = consoleReader.SplitInt();
            var N = consoleReader.Int();
            var w = consoleReader.Repeat(N).ToArray();
            var set = new HashSet<string> { w[0] };
            for (int i = 1; i < N; i++)
            {
                if (w[i - 1][w[i - 1].Length - 1] != w[i][0]) return "No";
                if(!set.Add(w[i])) return "No";
            }
            return "Yes";
        }


        public const int mod = 1000000007;
        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc());
        public static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

    #region Console
    public class ConsoleReader { public virtual string String() => Console.ReadLine(); public int Int() => int.Parse(String()); public long Long() => long.Parse(String()); public ulong ULong() => ulong.Parse(String()); public double Double() => double.Parse(String()); public string[] Split() => String().Split().ToArray(); public int[] SplitInt() => String().Split().Select(int.Parse).ToArray(); public long[] SplitLong() => String().Split().Select(long.Parse).ToArray(); public ulong[] SplitULong() => String().Split().Select(ulong.Parse).ToArray(); public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray(); public IEnumerable<string> Repeat(int count) { for (int i = 0; i < count; i++) yield return String(); } public IEnumerable<int> RepeatInt(int count) { for (int i = 0; i < count; i++) yield return Int(); } public IEnumerable<long> RepeatLong(int count) { for (int i = 0; i < count; i++) yield return Long(); } public IEnumerable<string[]> RepeatSplit(int count) { for (int i = 0; i < count; i++) yield return Split(); } public IEnumerable<int[]> RepeatSplitInt(int count) { for (int i = 0; i < count; i++) yield return SplitInt(); } }
    #endregion
}

Measured memory_bytes: 13280
#include<cstdio>
#include<stdlib.h>

using namespace std;

//#define MAX_N 100
#define MAX_N 200

int N,L;
//char R[MAX_N][MAX_M];
int A[MAX_N];

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

  int sum=0;
  
  for(int i=0;i<N;i++){
    A[i]=L+i-1+1;
  }

  for(int i=0;i<N;i++){
    sum=sum+A[i];
  }
  
  if((A[0]>0)){
    sum=sum-A[0];
  }

  if((A[N-1]<0)){
    sum=sum-A[N-1];
  }

  printf("%d",sum);
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<int> VI;
typedef vector<ll> VLL;

int main(){
    int a,b,ans;
    cin >> a >> b;

    if(a > b)ans = a+a-1;
    else if(b > a)ans = b + b-1;
    else ans = 2*a;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    int A, B, X;
    std::cin >> A >> B >> X;

    if (A <= X && X <= A+B) {
        std::cout << "YES" << std::endl;
    }
    else {
        std::cout << "NO" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
// AOJ 1228: Beehives
// 2017.12.5 bal4u@uu

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

#define BASE 128
char t[102], h[102];
int pos[102], n;
int mv[6][2] = {{1,0},{1,1},{0,1},{-1,0},{-1,-1},{0,-1}};
char chk[65536];

int main()
{
	int cno, i, k, r, c, d, e, ans;
	char buf[10], *p;

	fgets(buf, 10, stdin), cno = atoi(buf);
	while (cno--) {
		memset(chk, 0, sizeof(chk));

		fgets(t, 102, stdin);
		fgets(h, 102, stdin);
		fgets(buf, 10, stdin);
	
		ans = 0;
		if (strlen(t) != strlen(h)) goto done;
		r = c = BASE;
		pos[0] = k = (r << 8) | c, chk[k] = 1;
		n = 1;
		for (p = t; *p >= 'a'; p++) {
			d = (*p & 0xf) - 1;
			r += mv[d][0], c += mv[d][1];
			pos[n++] = k = (r << 8) | c, chk[k] = 1;
		}

		for (i = 0; i < n; i++) for (d = 0; d < 6; d++) {
			r = pos[i] >> 8, c = pos[i] & 0xff;
			for (p = h; ; p++) {
				if (*p < 'a') { ans = 1; goto done; }
				e = d + ((*p & 0xf) - 1);
				if (e >= 6) e -= 6;
				r += mv[e][0], c += mv[e][1];
				k = (r << 8) | c;
				if (!chk[k]) break;
			}
		}
done:	puts(ans ? "true" : "false");
	}
	return 0;
}

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

int main(){
    long long int l;
    long long int r;
    long long int min;
    cin >> l >> r;
    if(r-l>=2019){
        min = 0;
    }else{
        min = 2019;
        for(int i=l; i<r; i++){
            for(int j=i+1; j<=r; j++){
                if(((i%2019)*(j%2019))%2019 < min){
                    min = ((i%2019)*(j%2019))%2019;
                }
            }
        }
    }
    cout << min << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
	int n, m;
	while(scanf("%d %d\n", &n, &m), n || m){
		long double g[n][n];
		/* dp[a][b]??????a?????????b?????\?????????????????????a?????§????????????????????§??? */
		long double dp[m][n];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				scanf("%Lf", &g[i][j]);
			}
		}
		for(int i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				dp[i][j] = 0;
			}
		}
		for(int i = 0; i < n; i++) dp[0][i] = 1;
		
		for(int i = 1; i < m; i++){
			for(int j = 0; j < n; j++){
				for(int k = 0; k < n; k++){
					dp[i][j] = max(dp[i][j], dp[i - 1][k] * g[k][j]);
				}
			}
		}
		long double res = 0;
		for(int i = 0; i < n; i++){
			res = max(res, dp[m - 1][i]);
		}
		printf("%.2Lf\n", res);
	}
	
	return 0;
}

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

using namespace std;

#define make_unique(a) (a.erase(unique(a.begin(),a.end()),a.end()))
#define allof(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define exists(s, e) (s.find(e)!=s.end())
#define INF 0x3f3f3f3f
#define endl '\n'
#define mp make_pair
#define readln(x) (getline(cin, x))
#define watch(x) cout << (#x) << " is " << (x) << endl;

typedef pair<int, int> pii;
typedef long long ll;

ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

const int MAXN = 1e5 + 5;

ll dp[MAXN];

void solve() {
    int n; cin >> n;
    vector<int> h(n+1);
    for(int i=1; i<=n; i++) cin >> h[i];
    dp[1] = 0;
    dp[2] = abs(h[2]-h[1]);
    for(int i=3; i<=n; i++) {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
//    for(int i=1; i<=4; i++) {
//        watch(dp[i]);
//    }
    cout << dp[n] << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    solve();
    return 0;
}



Measured memory_bytes: 1408
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;

      bool flag=false;

       cin>>a>>b>>c>>k;

        l=min(a,k);

       k-=l;

       sum=l;

       if(k)
       {
            l=min(b,k);

            k-=l;

            if(k)
                sum-=k;
       }
       cout<<sum<<endl;





}



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

int main()
{
    std::string s;
    std::cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '7') {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }

    std::cout << "No" << std::endl;
    return 0;
}


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

using namespace std;

int main() {
	int n;
	cin>>n;
	map<pair<int, int>, int> mp;
	for(int i = 1; i <= n; i++) {
		string x = to_string(i);
		int f = x[0] - '0', l = x[x.length()-1] -'0';
		mp[make_pair(f, l)]++;
	}
	long int ans = 0;
	for(int i = 1; i <= n; i++) {
		string x = to_string(i);
		int f = x[0]-'0', l = x[x.length()-1]-'0';
		ans += mp[make_pair(l, f)];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256