akhauriyash/Code-Regression huggingface dataset:
//    .------------------------------------------------------------.
//    |   _  __   ___    ___    ___   _  _    ___     _     _  _   |
//    |  | |/ /  / _ \  |   \  |_ _| | \| |  / __|   /_\   | \| |  |
//    |  | ' <  | (_) | | |) |  | |  | .` | | (_ |  / _ \  | .` |  |
//    |  |_|\_\  \___/  |___/  |___| |_|\_|  \___| /_/ \_\ |_|\_|  |
//    |             ___    ___     _     _  _    ___               |
//    |            / _ \  | _ \   /_\   | \| |  / __|              |
//    |           | (_) | |   /  / _ \  | .` | | (_ |              |
//    |            \___/  |_|_\ /_/ \_\ |_|\_|  \___|              |
//    |                 ___   ___    ___    ___                    |
//    |                | _ ) | __|  / __|  / _ \                   |
//    |                | _ \ | _|  | (_ | | (_) |                  |
//    |                |___/ |___|  \___|  \___/                   |
//    |                                                            |
//    |------------------------------------------------------------|
//    |                      .------------.                        |
//    |                      | KerakTelor |                        |
//    |                      |------------|                        |
//    |                      | 2019-10-08 |                        |
//    |                      '------------'                        |
//    '------------------------------------------------------------'

#include <bits/stdc++.h>

#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("tune=native")

#define vec vector
#define prq priority_queue
#define fi first
#define se second

using namespace std;

using ll=long long;
using ld=long double;

//    .-----------------------------------------.
//    |        ___   _   _    ___   ___         | 
//    |       | _ ) | | | |  / __| / __|        | 
//    |       | _ \ | |_| | | (_ | \__ \        | 
//    |       |___/  \___/   \___| |___/        | 
//    |  ___   ___    ___    ___    _  _   ___  | 
//    | | _ ) | __|  / __|  / _ \  | \| | | __| |
//    | | _ \ | _|  | (_ | | (_) | | .` | | _|  | 
//    | |___/ |___|  \___|  \___/  |_|\_| |___| |
//    |                                         | 
//    '-----------------------------------------'

int main()
{
    int n;
    scanf("%d",&n);
    vec<vec<int>> x(n,vec<int>(3));
    for(auto &i:x)
        for(auto &j:i)
            scanf("%d",&j);
    vec<vec<ll>> dp(n+1,vec<ll>(3));
    for(int i=1;i<=n;++i)
        for(int j=0;j<3;++j)
            for(int k=0;k<3;++k)
            {
                if(j==k)
                    continue;
                dp[i][j]=max(dp[i][j],dp[i-1][k]+x[i-1][j]);
            }
    ll res=0;
    for(int i=0;i<3;++i)
        res=max(res,dp[n][i]);
    printf("%lld\n",res);
}



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

int Euclidean(int A, int B){
	int C = 0;
	if(A == B)return A;
	if(A > B){
		C = A % B;
		if(C == 0) return B;
		else return Euclidean(B, C);
	}
	else{
		C = B % A;
		if(C == 0) return A;
		else return Euclidean(A, C);
	}
}

int main(){
	int K;
	cin >> K;
	int ans = 0;
	for(int x = 1;x<=K;x++){
		for(int y = 1;y<=K;y++){
			for(int z = 1;z<=K;z++){
				int gcd = Euclidean(x, Euclidean(y, z));
				ans += gcd;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
// #define ll long long
typedef long long ll;
typedef pair<int, int> P;

const int V = 100005;
vector<int> to[V*2];
bool visited[V*2];
vector<int> cnt;

void dfs(int v){
  if (visited[v]) return;
  visited[v] = true;
  cnt[v/V]++;
  for (int u : to[v]) dfs(u);
}

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

    int n;
    cin >> n;
    rep(i,n){
      int x, y;
      cin >> x >> y;
      y+= V;
      to[x].push_back(y);
      to[y].push_back(x);
    }
    ll ans = 0;
    rep(i, V*2){
      if (visited[i]) continue;
      cnt = vector<int>(2);
      dfs(i);
      ans += (ll)cnt[0]*cnt[1];
    }
    ans -= n;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10240
// -------- START : snippet -------- //

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

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

// -------- START : macro -------- //

#define ll long long
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define len(c) (ll)c.size()
#define all(v) (v).begin(),(v).end()
#define lb(v,x) (lower_bound(all(v),x)-v.begin())
#define ub(v,x) (upper_bound(all(v),x)-v.begin())
#define has(c,x) (c.find(x) != c.end())
#define uniq(v) v.erase(unique(all(v)),v.end())
#define bit(k) (1LL<<(k))
#define INF int(1e9)

template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

// -------- END : macro -------- //

// -------- START : debug macro -------- //

template<class T,class U> ostream& operator<<(ostream& ost, const pair<T,U> &p) { ost << "(" << p.first << ", " << p.second << ")"; return ost; }
#define ostream_container { ost << "{"; for(const auto &t : v) { if (&t != &*v.begin()) ost << ", "; ost << t; } ost << "}"; return ost; }
template<class T> ostream& operator<<(ostream &ost, const vector<T> &v) ostream_container
template<class T> ostream& operator<<(ostream &ost, const set<T> &v) ostream_container
template<class T,class U> ostream& operator<<(ostream &ost, const map<T,U> &v) ostream_container

template<class H> void recursive_debug(string s, H h) {
    cerr << "\033[33m" << s << " = " << h << endl << "\033[m";
}
template<class H,class... T> void recursive_debug(string s, H h, T... t) {
    int comma = s.find(',');
    cerr << "\033[33m" << s.substr(0,comma) << " = " << h << ", ";
    recursive_debug(s.substr(comma+1), t...);
}
#define debug(...) recursive_debug(#__VA_ARGS__, __VA_ARGS__)

// -------- END : debug macro -------- //

// -------- END : snippet -------- //

int main(void) {
    int x;
    cin >> x;
    cout << ((x >= 30) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3600
import java.util.*;
import java.lang.*;


public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] B = new int[N+1];
        for(int n=1; n<N; n++) B[n]=sc.nextInt();
        B[0] = B[1];
        B[N] = B[N-1];

        long ans = 0;

        for(int n=0; n<N; n++) ans += Math.min(B[n], B[n+1]);

        System.out.println(ans);

    }
}


Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<sstream>
#include<numeric>
#include<queue>
#include<cstdio>
#include<iterator>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb(x) push_back(x)
ll mod = 1e9 + 7;
ll inf = 1e9 + 7;
template<typename T, typename U>
T binpow(T a, U n) {
    if (n == 0)
        return 1;
    if (n % 2 == 1)
        return (binpow(a, n - 1) * a) % mod;
    else {
        ll b = binpow(a, n / 2) % mod;
        return (b * b) % mod;
    }
}
template<typename T>
T gcd(T a, T b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
template<typename T>
istream& operator>>(istream& str, vector<T>& vec) {
    for (auto& w : vec) str >> w;
    return str;
}
template<typename T>
ostream& operator<<(ostream& str, vector<T>& vec) {
    for (auto& w : vec) str << w << ' ';
    return str;
}





int main() {
    ll t = 1;
    //cin >> t;
    while (t--) {
        ll n, x, t;
        cin >> n >> x >> t;
        ll k = (n + x - 1) / x;
        cout << t * k;
        
    }
}

Measured memory_bytes: 3192
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N = II()
D, X = ISI()
A = [II() for i in range(N)]
cnt = 0
for i in range(N):
    cnt += (D-1)//A[i]+1
print(cnt+X)

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

const __int128 rh_mod = 10000000000000061;
const ll rh_b = 1009;

class rolling_hash {
	const int n;
	vector<ll> R, H;
public:
	rolling_hash(const string& s)
		: n(s.size()), R(n + 1), H(n + 1) {
		R[0] = 1;
		for (int i = 0; i < n; i++) {
			R[i + 1] = (__int128)R[i] * rh_b % rh_mod;
			H[i + 1] = ((__int128)H[i] * rh_b + s[i]) % rh_mod;
		}
	}
	ll get(int l, int r) {
		assert(0 <= l && l <= r && r <= n);
		return (H[r] - (__int128)H[l] * R[r - l] % rh_mod + rh_mod) % rh_mod;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	string T, P;
	cin >> T >> P;
	int n = T.size(), m = P.size();
	rolling_hash rh(T);
	ll h = rolling_hash(P).get(0, m);
	for (int i = 0; i + m <= n; i++) if (rh.get(i, i + m) == h) {
		printf("%d\n", i);
	}
	return 0;
}



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

int main() {
    
    int n;
    cin >> n;
    int temp = n;
    string s = to_string(n);
    
    int len = s.length(), sum=0;
    
    for(int i=0; i<len; i++){
        int d = n%10;
        sum += d;
        n = n/10;
        
    }
    
    if(temp%sum==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    
    
	return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <istream>
#include <sstream>
using namespace std;

int main()
{
	string a;
	string b;
	int i;
	vector<int> c;
	stringstream ss;
	cin >> a;
	ss.str(a);
	while (getline(ss, b, '/')) {
		i = atoi(b.c_str());
		c.push_back(i);
	}

	if (c[0]<2019) {
		cout << "Heisei" << endl;
	}
	else if(c[0]>2019)
	{
		cout << "TBD" << endl;
	}
	else
	{
		if(c[1]>4)
		{
			cout << "TBD" << endl;
		}
		else
		{
			cout << "Heisei" << endl;
		}
	}
}

Measured memory_bytes: 256
num1 = int(input())
a1 = list(map(int,input().split()))

num2 = int(input())
a2 = list(map(int,input().split()))

count = 0

for i in range(num2):
    left = 0
    right = num1
    
    while left < right:
        mid = int((left + right) /2)
        
        if a1[mid] == a2[i]:
            count +=1
            break
        
        elif a2[i] < a1[mid]:
            right = mid
        else:
            left = mid +1
        

print(count)


Measured memory_bytes: 16704
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll= long long;
using ld= long double;
using P =pair<ll,ll>;


//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<=(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define sort(a) sort(ALL(a))//sortの省略
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define in(T, x) T x;cin >> x;//Tは型,xが入力値
#define vec(T,a,n,x) vector<T> a(n,x);
#define vec2(T,a,n,m) vector<vector<T>> a(n,vector<T>(m));
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define out(x) cout << x << endl//出力
#define bout(b) if(b){out("Yes");}else{out("No");}//真偽問題に対する出力
#define ain(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}//配列の宣言と入力
#define a2in(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}//2つの配列を同時宣言、入力

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }//dp表とかで最大値更新するやつ
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }//最小値更新


signed main(){
  in(ll,N);
  ain(ll,d,N);
  set<ll> S;
  REP(i,N-1){
    S.insert(d[i]);
  }
  out(S.size());

}


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

using namespace std;

int main(){
	string s[101];
  	int n,l; cin>>n>>l;
  	for(int i=0; i < n; ++i){
    	cin>>s[i];
    }
  	sort(s,s+n);
  	string res;
  	for(int i=0; i < n; ++i){
    	res+=s[i];
    }
  	cout<<res<<"\n";
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int n; cin >> n;
    vector<int> p(n);
    int out=0;
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    for(int i=1;i<n-1;i++){
        if(p[i]<p[i-1] && p[i]>p[i+1]) out++;
        if(p[i]<p[i+1] && p[i]>p[i-1]) out++;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
#define REP(i,b,e) for(int i=b;i<(int)e;i++)
typedef long long ll;
typedef map<ll,ll> mll;
typedef vector<ll> vll;
ll INF=1e18;
int inf=1e9+1000;

string alpha="abcdefghijklmnopqrstuwvxyz";

int a,b;


int main(){
    cin>>a>>b;
    int n=b-a;
    cout<<((n+1)*n)/2 -b<<endl;


    return 0;
}

Measured memory_bytes: 256
n = int(input())

def b(x):
    return format(x,'04b')

for i in range(1,n+1):
    for j in range(i+1,n+1):
        tmp = i ^ j
        bit = format(tmp, 'b')[::-1]
        # print(bit)
        for k in range(len(bit)):
            # print(bit[k])
            if int(bit[k]) == 1:
                # print(bit, bit[k],k+1)
                print(k+1, end = ' ')
                break
    print()

        # print(b(i),b(j),b(tmp))



Measured memory_bytes: 58328
#include<stdio.h>

int main() {
	int w, n, i, ai, bi, tmp;
	scanf("%d", &w);
	scanf("%d", &n);
	int a[30];
	for (i = 1; i <= w; i++) {
		a[i] = i;
	}
	for (i = 0; i < n; i++) {
		scanf("%d,%d", &ai, &bi);
		tmp = a[ai];
		a[ai] = a[bi];
		a[bi] = tmp;
	}
	for (i = 1; i <= w; i++) {
		printf("%d\n",a[i]);
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
vector<int> S[15];
int P[15],N,M;
int main()
{
	cin>>N>>M;
	for(int i=0;i<M;i++)
	{
		int x;
		cin>>x;
		for(int j=0;j<x;j++)
		{
			int y;
			cin>>y;
			S[i].push_back(y);
		}
	}
	for(int i=0;i<M;i++)
		cin>>P[i];
	int res=0;
	for(int state=0;state<(1<<N);state++)
	{
		bool f=true;
		for(int i=0;i<M;i++)
		{
			int cnt=0;
			for(int j=0;j<S[i].size();j++)
				if(state>>(S[i][j]-1)&1)
					cnt++;
			if(cnt%2!=P[i])
				f=false;
		}
		res+=f;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const input = stdin.split('\n')

const n = Number(input[0])
const a = input[1].split(' ').map(Number)
const b = input[2].split(' ').map(Number)
const c = input[3].split(' ').map(Number)

const ans = () => {
  let prevFood = -100
  let count = 0
  for (let i = 0; i < n; i++) {
    const food = a[i] - 1

    const m = b[food]

    const additionalM = food === prevFood + 1 ? c[food - 1] : 0

    count += m + additionalM

    prevFood = food
  }

  console.log(count)
}

ans()


Measured memory_bytes: 7372
#include <stdio.h>
#include <string.h>

void mD(char C, int *D) {
  switch (C) {
    int t;
  case 'N':
    t=D[0];D[0]=D[1];D[1]=D[5];D[5]=D[4];D[4]=t;
    break;
  case 'S':
    t=D[0];D[0]=D[4];D[4]=D[5];D[5]=D[1];D[1]=t;
    break;
  case 'E':
    t=D[0];D[0]=D[3];D[3]=D[5];D[5]=D[2];D[2]=t;
    break;
  case 'W':
    t=D[0];D[0]=D[2];D[2]=D[5];D[5]=D[3];D[3]=t;
    break;
  case 'R':
    t=D[1];D[1]=D[3];D[3]=D[4];D[4]=D[2];D[2]=t;
    break;
  case 'L':
    t=D[1];D[1]=D[2];D[2]=D[4];D[4]=D[3];D[3]=t;
    break;
  }
  return;
}

/* サイコロが一致していたら1、それ以外は0 */
int cD(int *D1, int *D2) {
  int d;
  /* すべての面が必ず1度は上面にくる回転 */
  char C[]={' ','N','N','N','E','E','E'}; int c;
  /* 必ずC[]の要素数だけ繰り返す。 
     同じ数字が複数の面に存在する可能性があるので */
  for (c=0;c<7;c++) {
    mD(C[c], D2);
    /* サイコロ1と2の上面の数字が一致したら…… */
    if (D1[0]==D2[0]) {
      /* サイコロを右回転させて、すべての面の数字が一致する
	 ポジションがないか調べる */
      for(d=0;d<6;d++) {
	mD('R', D2);
	/* ポジションがあったらフラグを立てる */
	if (D1[1]==D2[1]) {
	  if ((D1[2]==D2[2]) && (D1[3]==D2[3])
	      && (D1[4]==D2[4]) && (D1[5]==D2[5]))
	    return 1;
	}
      }
    }
  }
  return 0;
}

int main(void) {
  int D[101][6],d,N,n;
  scanf("%d\n",&N);
  /* サイコロ初期値の設定 */
  for(n=0;n<N;n++)
    for(d=0;d<6;d++)
      scanf("%d",&D[n][d]);

  /* サイコロの一致判定 */
  for(n=0;n<(N-1);n++) {
    int m;
    for(m=n+1;m<N;m++) {
      if (cD(D[n],D[m])) {
	printf("No\n");
	return 0;
      }
    }
  }
  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 584
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;
	using BigNum = std::vector<long long>;

	class InputData {
	public:
		void getInput(void);
		void skipInput(void);
		Str getStr(void);
		Num getNum(void);
		BigNum getBigNum(void);
	private:
		Str str;
		Num num;
		BigNum bNum;
	};
	Str AtCoder::InputData::getStr(void) {
		return this->str;
	}
	Num AtCoder::InputData::getNum(void) {
		return this->num;
	}
	BigNum AtCoder::InputData::getBigNum(void) {
		return this->bNum;
	}
	void AtCoder::InputData::skipInput(void) {
		std::string buf = "";
		std::getline(std::cin, buf);
	}
	void AtCoder::InputData::getInput(void) {
		this->str.clear();
		this->num.clear();
		this->bNum.clear();

		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				this->str.push_back(row);
				this->num.push_back(std::atoi(row.c_str()));
				this->bNum.push_back(std::atoll(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		this->str.push_back(row);
		this->num.push_back(std::atoi(row.c_str()));
		this->bNum.push_back(std::atoll(row.c_str()));
	}

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(long long);
		void decrement(void);
		void decrement(long long);
		long long getResult(void);
	private:
		long long result;
	};
	void Ans::showResult(void) {
		printf("%lld\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(long long value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(long long value) {
		this->result -= value;
	}
	long long AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::InputData* data = new AtCoder::InputData();
	data->getInput();

	AtCoder::BigNum big = data->getBigNum();

	const long long int x = big[0], k = big[1], d = big[2];

	AtCoder::Ans* ans = new AtCoder::Ans();

	if (1 == k) {
		if (std::abs(x - d) < std::abs(x + d)) {
			ans->increment(std::abs(x - d));
		} else {
			ans->increment(std::abs(x + d));
		}
	} else {
		long long int nx = 0 > x ? x * -1 : x;
		const long long int bs = nx / d;
		long long int nk = k;
		if (k >= bs) {
			nx -= bs * d;
			nk -= bs;
		} else {
			nx -= k * d;
			nk -= k;
		}
		if (0 == nk || 0 == nk % 2) {
			ans->increment(nx);
		} else {
			if (std::abs(nx - d) < std::abs(nx + d)) {
				ans->increment(std::abs(nx - d));
			} else {
				ans->increment(std::abs(nx + d));
			}
		}

	}
	
	ans->showResult();

	delete(ans);
	delete(data);

	return 0;
}

Measured memory_bytes: 3252
#include<stdio.h>
#include<stdbool.h>

long long int N,i,min;

int main(void){

    scanf("%lld",&N);

    for(i = 1;i*i <= N;i++){
        if(N % i == 0) min = i;
    }
     

    printf("%lld\n",min+(N/min)-2);
    return 0;
}



Measured memory_bytes: 128
import static java.lang.Math.*;
import static java.util.Arrays.*;

import java.util.*;
import java.io.*;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] a = new int[n][3];
		for(int i=0;i<n;i++) for(int j=0;j<3;j++) a[i][j] = sc.nextInt();
		for(int i=0;i<3;i++) for(int j=0;j<n;j++) {
			boolean f = false;
			for(int k=j+1;k<n;k++) if(a[j][i] == a[k][i]) { a[k][i] = 0; f = true; }
			if(f) a[j][i] = 0;
		}
		for(int i=0;i<n;i++) System.out.println((a[i][0]+a[i][1]+a[i][2]));
		
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main() {
  int a, b, h, m;
  double PI = acos(-1);
  cin >> a >> b >> h >> m;
  double th = double(60 * h + m) / 720 * 2 * PI;
  double tm = double(m) / 60 * 2 * PI;
  double xh = a*cos(th), yh = a*sin(th);
  double xm = b*cos(tm), ym = b*sin(tm);
  double dx = xh-xm, dy = yh-ym;
  double ans = sqrt(dx*dx + dy*dy);
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 3988
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

using namespace std;
using ll = long long;

#define coutendl() (std::cerr << std::endl)
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabCout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headCout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabHeadCout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
//#define int long long
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divUp(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

int Main()
{
	int N;
	cin >> N;
	vector<int> h(N);
	rep(i, N)	cin >> h.at(i);

	vector<int> s(N);
	s.at(0) = 0;
	s.at(1) = abs(h.at(1) - h.at(0));

	for (int i = 2; i < N; i++)
	{
		int max = INF;
		chmin(max, s.at(i - 1) + abs(h.at(i) - h.at(i - 1)));
		chmin(max, s.at(i - 2) + abs(h.at(i) - h.at(i - 2)));
		s.at(i) = max;
		debug_cout(max);
	}

	for (int i = 0; i < N; i++)
	{
		debug_cout(i);
		debug_tabCout(1, s.at(i));
	}

	cout << s.at(N - 1) << endl;

	return 0;
}

/*****/

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

	//std::cout << std::fixed << std::setprecision(10);

	Main();

	return 0;
}


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

double dp[2][111];
double g[111][111];

int main(){
    int n,m;
    while(cin >> n >> m && n){
        rep(i,n)rep(j,n) cin >> g[i][j];
        rep(i,111) dp[0][i] = 1;
        rep(i,111) dp[1][i] = 0;
        m--;
        rep(i,m){
            auto cur = dp[i&1], nx = dp[(i&1)^1];
            rep(i,111) nx[i] = 0;
            rep(i,n){ // cur
                rep(j,n){ // use
                    nx[j] = max(nx[j], cur[i]*g[i][j]);
                }
            }
            // rep(i,m) cout << nx[i] << " ";
            // cout << endl;
        }
        double ans = 0;
        rep(i,111) ans = max(ans, dp[m&1][i]);
        // ans *= 100;
        // int d = (int)(ans)%10;
        // ans = floor(ans);
        // if(d >= 5) ans += 1;
        // ans /= 100;
        printf("%.2lf\n", ans);
    }
}

Measured memory_bytes: 1324
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        List<Restaurant> restaurants = new ArrayList<>();
        for (int i = 1; i <= n; i++){
            String s = sc.next();
            int p = sc.nextInt();
            Restaurant restaurant = new Restaurant();
            restaurant.id = i;
            restaurant.name = s;
            restaurant.score = p;
            restaurants.add(restaurant);
        }

        Collections.sort(restaurants);

        for (Restaurant restaurant: restaurants){
            System.out.println(restaurant.id);
        }

    }

    private static class Restaurant implements Comparable{
        public int id;
        public String name;
        public int score;

        @Override
        public int compareTo(Object o) {
            Restaurant restaurant = (Restaurant)o;

            if (!this.name.equals(restaurant.name)){
                return this.name.compareTo(restaurant.name);
            }
            return restaurant.score - this.score;
        }
    }

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()

int main() { 
    int N;
    cin >> N;
    //積の最大値を"int64_t"型で定義する。1e18のままだとdouble型になる
    int64_t MX = 1e18;
    int64_t ans = 1;
    bool ng = false;
    
    rep(i, N) {
        int64_t a;
        cin >> a;
        //もし0が含まれていたら、0を出力
        if (a == 0) {
            cout << 0 << endl;
            return 0;
        }
        //もし、積が1e18より大きくなるような場合-1出力のフラグを立てる
        //ngがtrueの場合はそのまま
        if (ng || MX/ans < a) {
            ng = true;
        }
        ans *= a;
    }
    if (ng) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
n = int(input())
A = list(map(int, input().split()))

m = max(A)
B = [0] + [0] * m
result = [None] * n

for a in A:
  B[a] += 1

for i in range(1, m+1):
  B[i] += B[i-1]

for i in range(n-1, -1, -1):
  a = A[i]
  index = B[a] - 1
  result[index] = a
  B[a] -= 1
  
print(*result)


Measured memory_bytes: 224380
import sys

input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def func(N, mod):
    F = [1]
    for i in range(1, N + 1):
        F.append(F[-1] * i % mod)
    return F


INV = {}


def inv(a, mod):
    if a in INV:
        return INV[a]
    r = pow(a, mod - 2, mod)
    INV[a] = r
    return r


def C(F, a, b, mod):
    return F[a] * inv(F[b], mod) * inv(F[a - b], mod) % mod


def main():
    N = int(input())
    F = [0] * N
    for i in range(N):
        P = int(input()) - 1
        F[P] = i

    res = 0
    tmp = 0
    pre = -1
    for f in F:
        if pre < f:
            tmp += 1
        else:
            res = max(res, tmp)
            tmp = 1
        pre = f
    res = max(res, tmp)
    print(N - res)


if __name__ == "__main__":
    main()



Measured memory_bytes: 10964
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

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

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    long long x;
    scanf("%ld",&x);

    for(long long i=-1000;i<=1000;i++){
        for(long long j=-1000;j<=1000;j++){
            if(i*i*i*i*i-(j*j*j*j*j)==x){
                printf("%d %d",i,j);
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1700
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
int main()
{
    int n,a,b,c,y,z,x,s[3];
    while(~scanf("%d %d",&a,&b))
    {
        x=-999999999;
        s[0]=a+b;
        s[1]=a-b;
        s[2]=a*b;
        for(c=0;c<3;c++)
        {
            if(s[c]>=x)
            {
                x=s[c];
            }
        }
        printf("%d\n",x);

    }
    return 0;
}


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

using namespace std;


void solve() {
    int K; cin >> K;
    queue<long long> que;
    for (int i = 1; i < 10; i++) que.push(i);
    for (int i = 0; i < K-1; i++) {
        long long s = que.front();
        que.pop();
        for (int i = -1; i <= 1; i++) {
            long long add = (s % 10) + i;
            if (add >= 0 && add <= 9) que.push(s * 10 + add);
        }
    }
    cout << que.front() << endl;
}


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

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

int main(void) {
  string S;
  cin >> S;
  vector<string> mask = {"dream", "dreamer", "erase", "eraser"};
  bool ans = true;
  for (int i = S.length() - 1; i >= 0;) {
    bool flag = false;
    int j = 0;
    for (j = 0; j < 4; j++) {
      int mask_len = mask[j].length();
      if (i - mask_len + 1 < 0) continue;
      if (S.substr(i - mask_len + 1, mask_len) == mask[j]) {
        flag = true;
        i -= mask_len;
        break;
      }
    }
    if (!flag) {
      ans = false;
      break;
    }
  }
  cout << (ans ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
	int W, H, N; cin >> W >> H >> N;
	int xl = 0, xr = W, yl = 0, yr = H;
	rep(i, N) {
		int x, y, a; cin >> x >> y >> a;
		if (a == 1) xl = max(xl, x);
		else if (a == 2) xr = min(xr, x);
		else if (a == 3) yl = max(yl, y);
		else yr = min(yr, y);
	}
	cout << max(xr - xl, 0) * max(yr - yl, 0) << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {	

	private static void solve(){
		//Implement solution here.
		int N = ni();
		int AC = 0;
		int WA = 0;
		int TLE = 0;
		int RE = 0;
		for(int i = 0; i < N; i++) {
			String v = next();
			if("AC".equals(v)) {
				AC++;
			} else if("WA".equals(v)) {
				WA++;
			} else if("TLE".equals(v)) {
				TLE++;
			} else {
				RE++;
			}
		}
		System.out.println("AC x " + AC);
		System.out.println("WA x " + WA);
		System.out.println("TLE x " + TLE);
		System.out.println("RE x " + RE);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


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

using namespace std;

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

	int a, b, n;
	cin >> a >> b;
	cin >> n;
	bool re[1000] = { false };
	for( int i = 0; i < n; i++ )
	{
		int s, f;
		cin >> s >> f;
		for( int j = s; j < f; j++ )re[j]=true;
	}
	bool check = true;
	for( int i = a; i < b; i++ )if( re[i] )check = false;
	cout << ( check ? 0 : 1 ) << endl;

	return 0;
}



Measured memory_bytes: 3112
n,t = map(int,input().split())
ct = [list(map(int,input().split())) for i in range(n)]
c = [1001]
for i in range(n):
  if ct[i][1] <= t:
    c = [min(c),ct[i][0]]
print(min(c)) if min(c) < 1001 else print('TLE')

Measured memory_bytes: 3060
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = pow(10, 5) + 1;//+1しないとREになる(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };
int main(void) {
	int H, W;
	cin >> H >> W;
	vector<string> maze(H);
	for (int i = 0; i < H; i++) cin >> maze[i];

	VVI far(H, vector<int>(W, INF));
	far[0][0] = 0;
	queue<P> q;
	q.push(P(0, 0));
	while (!q.empty()) {
		int now_x = q.front().first;
		int now_y = q.front().second;
		q.pop();
		for (int i = 0; i < 4; i++) {
			int next_x = now_x + dx[i];
			int next_y = now_y + dy[i];
			if (next_x < 0 || H <= next_x || next_y < 0 || W <= next_y) continue;
			if (maze[next_x][next_y] == '#') continue;
			if (far[next_x][next_y] != INF) continue;
			far[next_x][next_y] = far[now_x][now_y] + 1;
			q.push(P(next_x, next_y));
		}
	}

	//int ans = 0;
	//int forcus_num = 1;//forcus_num
	//for (int forcus_num = 1; forcus_num <= H * W; forcus_num++) {
	//	int count = 0;
	//	for (int i = 0; i < H; i++) {
	//		for (int j = 0; j < W; j++) {
	//			if (far[i][j] == forcus_num) {
	//				count++;
	//				if (count >= 2) {
	//					ans++;
	//					//far[i][j] = -1*ans;
	//				}
	//			}
	//		}
	//	}
	//}

	int num_sharp = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (maze[i][j] == '#') num_sharp++;
		}
	}
	int ans = H * W - num_sharp - far[H - 1][W - 1]-1;

	if (far[H - 1][W - 1] == INF) {
		cout << "-1" << endl;
		return 0;
	}
	cout << ans << endl;
/*
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << maze[i][j] << "        ";
		}
		cout << endl;
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << far[i][j] << "        ";
		}
		cout << endl;
	}*/
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
typedef pair<int,int> P;
char maze[1000][1000];
int N,M;
int sx,sy;
int gx,gy;
int d[1000][1000];
int dx1[4] = {-1,0,1,0};
int dy1[4] = {0,-1,0,1};

int dx2[5] = {-2,-1,0,1,2};
int dy2[5] = {-2,-1,0,1,2};


int bfs(){
  deque<P> que;
  for(int i = 0;i<N;i++){
    for(int j = 0;j<M;j++){
      d[i][j] = MOD;
    }
  }
  que.push_front(P(sx,sy));
  d[sx][sy] = 0;
  while(que.size()){
    P p = que.front();
    que.pop_front();
   // if(p.first == gx && p.second == gy){
   //   break;
  // }
    for(int i = 0;i<4;i++){
      int nx = p.first+dx1[i],ny = p.second+dy1[i];
      if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[nx][ny] != '#' && (d[nx][ny] >d[p.first][p.second])){
        que.push_front(P(nx,ny));
        d[nx][ny] = d[p.first][p.second];
      }
    }
    for(int i = 0;i<5;i++){
      for(int k = 0;k<5;k++){
      int nx = p.first+dx2[i],ny = p.second+dy2[k];
        if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[nx][ny] != '#'){
          if(d[nx][ny]>(d[p.first][p.second]+1)){
            que.push_back(P(nx,ny));
            d[nx][ny] = d[p.first][p.second]+1;
          }
        }
      }   
    }
  }
  return d[gx][gy];
}
  
  
int main(){
  cin>>N>>M;
  cin>>sx>>sy>>gx>>gy;
  sx--;
  sy--;
  gx--;
  gy--;
  for(int i = 0;i<N;i++){
    for(int k = 0;k<M;k++){
      cin>>maze[i][k];
    }
  }
  int res = bfs();
  if(res!=MOD){
    cout << res << endl;
  }
  else{
    cout << "-1" << endl;
  }
 /* for(int i = 0;i<4;i++){
    for(int k = 0;k<5;k++){
       cout << d[i][k];
    }
    cout << endl;
  }*/
  return 0;
}

Measured memory_bytes: 8508
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{    
	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
    ll N;
    ll W;
    cin>>N>>W;
    ll a,b,s=0,g=0;
    ll w[N],v[N];
    for(ll i=0;i<N;i++){
        cin>>a>>b;
        w[i]=a;
        v[i]=b;
        s+=v[i];
        g=__gcd(g,v[i]);
    }
    ll dp[s+1];
    for(ll i=0;i<=s;i++)
        dp[i]=LLONG_MAX/2;
    dp[0]=0;
    s=0;
    for(ll i=0;i<N;i++) {
        s+=v[i];
        for(ll j=s;j>=v[i];j-=g) 
            dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
    }
    for (ll i=s;i>=0;i--)
        if (dp[i]<=W){
            cout<<i;
            break;
        }
}

Measured memory_bytes: 1024
s = input()
s_bin = bin(int(s, 2))

text_10 = ''
text_01 = ''

for i in range(len(s)):
    j = i % 2
    k = (i + 1) % 2
    text_10 += str(j)
    text_01 += str(k)

x = bin(int(s, 2) ^ int(text_10, 2)).count("1")
y = bin(int(s, 2) ^ int(text_01, 2)).count("1")

print(min(x, y))


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;


int main() {
        string s;
        cin >> s;
        set<char> st;
        rep(i,3){
                 st.insert(s.at(i));
        }
        if(st.size() == 2) cout <<"Yes" << endl;
        else cout <<"No"<< endl;
                 
        
        return 0;
}




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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main(){
  int a,b;
  cin >> a >> b;

  a = a+b;

  if(a > 9){
    printf("error\n");
  }
  else printf("%d\n", a);
  return 0;
}

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


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

Measured memory_bytes: 256
def main():
    n = int(input())
    a = set([int(a) for a in input().split()])
    m = int(input())
    b = set([int(a) for a in input().split()])

    c = a.symmetric_difference(b)
    sorted_c = sorted(c)
    for i in sorted_c:
        print(i)
main()



Measured memory_bytes: 69080
import java.util.*;

class Main
{
    public static void main(String args[])
    {
	int n, q, C=0;
	long S[] = new long[100000];
	long k;
	int left, right, mid=0;
	Scanner read = new Scanner(System.in);

	//read
	n=read.nextInt();
	for(int i=0; i<n; i++)S[i]=read.nextInt();

	//search
	q=read.nextInt();
	for(int i=0; i<q; i++)
	    {
		left=0;
		right=n;
		k=read.nextInt();
		while(left<right)
		    {
			mid=(left+right)/2;
			if(S[mid]==k)
			    {
				C++;
				break;
			    }
			else if(S[mid]<k)left=mid+1;
			else right=mid;
		    }
	    }

	//print
	read.close();
	System.out.println(C);


    }
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int k, s; cin >> k >> s;
    int ans = 0;
    for(int i = 0; i <= k; ++i){
        for(int j = 0; j <= k; ++j){
            int z = s - i - j;
            if(z <= k && z >= 0) ans++;
        }
    }
    cout << ans << endl;
}

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

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long int;
using vi = vector<ll>;

ll n, m, k;
ll ans = 0, sum = 0;

/*--------------------template--------------------*/

vi combs;
vi a(50), b(50), c(50), d(50);

void dfs(ll j, const ll& n, const ll& m, const ll& k, ll& ans) {
	if(combs.size() == n) {
      sum = 0;
      REP(i,k) {
      	if(combs[b[i]-1] - combs[a[i]-1] == c[i])
          sum+=d[i];
      }
      ans = max(ans, sum);
      combs.pop_back();
      return;
    }
    for(ll jj = j; jj <= m; ++jj) {
      combs.push_back(jj);
      dfs(jj,n,m,k,ans);
    }
	combs.pop_back();
	return;
}

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

    cin >> n >> m >> k;
	
	REP(i,k){
      cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
	dfs(1,n,m,k,ans);
  
    cout << ans << endl;
}


Measured memory_bytes: 3656
#include<stdio.h>
#include<string.h>

int main()
{
  char s[11];
  scanf("%s",s);

  if(strcmp(s,"hi") == 0){
    puts("Yes");
    return 0;
  }
  if(strcmp(s,"hihi") == 0){
    puts("Yes");
    return 0;
  }
  if(strcmp(s,"hihihi") == 0){
    puts("Yes");
    return 0;
  }
  if(strcmp(s,"hihihihi") == 0){
    puts("Yes");
    return 0;
  }
  if(strcmp(s,"hihihihihi") == 0){
    puts("Yes");
    return 0;
  }  
  
  puts("No");
  return 0;

}



Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
#include<iostream>

using namespace std;

int main ()
{
    long long int n,a,b;
    long long int tmp[100001];
    while (scanf ("%lld",&n)!=EOF)
    {
        bool flag=true , find_2=false;
       for (long long int i=0;i<n;i++)
        scanf ("%lld",&tmp[i]);
       if (tmp[n-1]>2) { printf ("-1\n"); continue ;}
       else if (tmp[n-1]==2) find_2= true;
       long long int ans =3 ,ans1 =2 ;
       for (long long int i=n-2;i>=0;i--)
       {
           if (!find_2)
           {
               if (tmp[i]>2) { printf ("-1\n"); flag = false ; break ;}
               else if (tmp[i]==2){ find_2 = true ; continue; }
               else continue;
           }
           if (ans / tmp[i]==0) {printf ("-1\n");  flag = false ;break;}
           else
           {
               ans =  ans/tmp[i] * tmp[i] + tmp[i]-1;

           }
               if (ans1%tmp[i])
               ans1 = ans1/tmp[i] * tmp[i] + tmp[i];
              if (ans1<tmp[i]) ans1=tmp[i];
       }
       if (flag)
       if (ans1 > ans) printf ("-1\n");
        else
       printf ("%lld %lld\n",ans1,ans);

    }
    return 0;
}


Measured memory_bytes: 1024