akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n, a;
    cin >> n >> a;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    rep(i, n) x[i] -= a;

    vector<ll> dp(5000);
    dp[2500] = 1;
    rep(i, n) {
        vector<ll> pre(5000);
        swap(dp, pre);
        rep(j, 5000) {
            dp[j] += pre[j];
            if (0 <= j+x[i] && j+x[i] < 5000) dp[j+x[i]] += pre[j];
        }
    }
    cout << dp[2500] - 1 << endl;
}


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

int main()
{

    int a, b, c;
    int num = 0;

    cin >> num;

    for( int i = 0; i < num; i++)
    {
        cin >> a >> b >> c;

        if( a >= b && a >= c )
        {
            if(a*a == b*b + c*c)
            {
                cout << "YES" << endl;
            }
            else
            {
                cout << "NO" << endl;
            }
        }

        else if( b >= c )
        {
            if(b*b == a*a + c*c)
            {
                cout << "YES" << endl;
            }
                        
            else
            {
                cout << "NO" << endl;
            }
        }

        else
        {
            if(c*c == a*a + b*b)
            {
                cout << "YES" << endl;
            }
                        
            else
            {
                cout << "NO" << endl;
            }
        }

    }   


    return 0;
}


Measured memory_bytes: 3056
s1 = input()
s2 = input()
dp = [[0 for i in range(len(s1) + 1)] for j in range(len(s2) + 1)]
for j in range(1, len(s1) + 1):
    for i in range(1, len(s2) + 1):
        if j == 0 or i == 0:
            dp[i][j] = 0
        elif s1[j-1] == s2[i-1]:
            dp[i][j] = dp[i - 1][j - 1] + 1
        else:
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
x, y = len(s2), len(s1)
ans = []
while x > 0 and y > 0:
    if dp[x][y] == dp[x - 1][y]:
        x = x - 1
    else:
        if dp[x][y] != dp[x][y-1]:
            ans.append(s2[x-1])
        y = y - 1
ans.reverse()
print("".join(ans))


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

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

string S;
int main() {
    while (cin >> S) {
        sort(S.begin(), S.end());
        if (S == "abc") puts("Yes");
        else puts("No");
    }
}

























Measured memory_bytes: 256
n, a, b = map(int, input().split())
if (a-b)%2 == 0:
    print(abs(a-b)//2)
else:
    if a+b>=n+1:
        print(min([n-a, n-b])+1+(abs(a-b)-1)//2)
    else:
        print(min([a, b])+(abs(a-b)-1)//2)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int x; cin >> x;
	if(x < 1200) puts("ABC");
	else puts("ARC");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

ll X, K, D;

int main() {
    cin >> X >> K >> D;
    if (X < 0) X *= -1;
    ll num_move1 = X / D;
    ll pos_move1 = X % D;
    ll num_move2 = num_move1 + 1;
    ll pos_move2 = D - pos_move1;
    double log_D = log((double)D);
    double log_K = log((double)K);
    double log_lim = log(1e15);
    if (log_D + log_K < log_lim && D * K < X) PRINT(X - K * D);
    else if (K % 2 == num_move1 % 2) PRINT(pos_move1);
    else PRINT(pos_move2);
    return 0;
}

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

using namespace std;

long long gcd(long long a, long long b) {
  return b ? gcd(b, a%b) : a;
}
long long lcm(long long a, long long b) {
  return a*b/gcd(a,b);
}

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

  long long N,M; cin>>N>>M;
  vector<long long> A(N);
  for (auto& a : A) {
    cin>>a;
  }
  auto solve = [&]() -> long long {
    int t = 2;
    while ((A[0] & t) == 0)
      t<<=1;
    for (int i = 1; i < N; i++) {
      if (A[i]%t or A[i]/t%2==0)
        return 0;
    }

    auto lcmab = A[0]/2;
    for (int i = 1; i < N; i++) {
      lcmab = lcm(lcmab, A[i]/2);
      if (lcmab > M)
        return 0;
    }
    return (M/lcmab+1)/2;
  };
  cout << solve() << endl;

  return 0;
}


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

int main(){
    string S,T;
    cin >> S >> T;
    long num=S.size();
    bool judge=true;
    for(int i=0; i<num; i++){
        if(S[i]!=T[i]){
            judge=false;
        }
    }
    if(judge){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
k = int(input())
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(A[k-1])

Measured memory_bytes: 9004
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 1e18+10 : 1e9+10;
// int dx[]={0,1,0,-1,1,1,-1,-1};
// int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int dx[]={-1,-1,0,0,1,1};
int dy[]={-1,0,-1,1,0,1};//RDLU
int n,m,out;
vvi in,used;
bool h;
int co;
void dfs(int a,int b){
	co++;
	used[a][b]=1;
	rep(i,6){
		int nx=a+dx[i];
		int ny=b+dy[i];
		if(in[nx][ny]==0)h=false;
		else if(in[nx][ny]==in[a][b]&&used[nx][ny]==0)
			dfs(nx,ny);
	}
}
int f(){
	int sum=0;
	used=vvi(20,vi(20));
	rep(i,20)rep(j,20)if(used[i][j]==0&&in[i][j]>0){
		h=true;co=0;
		dfs(i,j);
		if(h){
			if(in[i][j]==m)sum-=co;
			else sum+=co;
		}
	}
	return sum;
}
int main(){
	while(cin>>n>>m,n){
		in=vvi(20,vi(20,-1));
		rep(i,n)rep(j,i+1)cin>>in[i+1][j+1];
		out=-inf;
		rep(i,20)rep(j,20)if(!in[i][j]){
			in[i][j]=m;
			cmax(out,f());
			in[i][j]=0;
		}
		cout<<out<<endl;
	}
}	
	
	
/*
int main(){
	int n,l,t,co=0;
	cin>>n>>l>>t;
	
	vvi in(n,vi(2));
	rep(i,n)rep(j,2)cin>>in[i][j];
	rep(i,n)if(in[i][1]==2)in[i][1]=-1;
	
	vvi g(n,vi(2));
	rep(i,n){
		if(in[0][1]!=in[i][1]){
			ll w=t;
			co+=w/l;
			w%=l;
			ll dis=(l+in[i][0]-in[0][0])%l;
			if(in[0][1]==-1)dis=(l+in[0][0]-in[i][0])%l;
			if(dis<=2*w)co++;
		}
		g[i]={(in[i][0]+t*in[i][1])%l,in[i][1]};
	}
	if(in[0][1]==-1)co=n-1-co%n;
	else co%=n;
	cout<<co<<endl;
	show2d(in);
	show2d(g);
}	
*/









Measured memory_bytes: 3024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()
cnt = 0
for i in range(A, B+1):
	if str(i) == str(i)[::-1]:
		cnt += 1

print(cnt)

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int n; cin >> n;
	vector<int> A;
	for (int i=0; i<n; i++) {
		int a; cin >> a;
		A.push_back(a);
	}

	vector<int> B(n, 0);
	vector<int> R;
	for (int i=n-1; i>=0; i--) {
		int c = i+1;
		int a = A[i];
		int psum = 0;
		for (int j=2; j*c <= n; j++) {
			psum += B[j*c - 1];
		}
		if ((psum + a)%2==1) {
			B[i] = 1;
			R.push_back(c);
		}
	}
	int m = R.size();
	cout << m << endl;
	if (m==0) return 0;
	for (int i=0; i<m; i++) {
		cout << R[m - i - 1] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3444
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    double ans;
    double a = n;
    if(n%2 == 0){
        ans = a/(2*a);
    }
    else ans = ((n/2)+1)/a;
    cout<<fixed;
    cout<<setprecision(6)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s, t := Scan(), Scan()
	p, q := make([]int, len(s)), make([]int, len(t))
	for i, r := range s {
		p[i] = int(r)
	}
	for i, r := range t {
		q[i] = int(r)
	}
	sort.Ints(p)
	sort.Sort(sort.Reverse(sort.IntSlice(q)))
	x := "Draw"
	for i := 0; i < smaller(len(s), len(t)); i++ {
		if p[i] < q[i] {
			x = "Yes"
			break
		} else if p[i] > q[i] {
			x = "No"
			break
		}
	}
	if x == "Draw" {
		if len(s) >= len(t) {
			x = "No"
		} else {
			x = "Yes"
		}
	}
	fmt.Println(x)
}


Measured memory_bytes: 1776
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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 maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw3(15,1);vector<ll> pw10(19,1);
int main(){
    {rep1(i,14) pw3[i]=3*pw3[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    ll ans=0;
    vector<ll> P(N+1);
    vector<ll> place(N+1); //place[x]:xがある場所
    rep1(i,N){
        cin>>P[i];
        place[P[i]]=i;
    }
    
    multiset<ll> se;
    se.insert(0);
    se.insert(0);
    se.insert(N+1);
    se.insert(N+1);
    se.insert(place[N]);
    rrep1(i,N-1){
        ll X=place[i]; //場所
        // m2 m1 X M1 M2 :座標
        auto it=se.upper_bound(X);
        ll M1=*(it);
        it++;
        ll M2=*(it);
        it--;
        it--;//*(se.lower_bound(M1));
        ll m1=*(it);
        it--;
        ll m2=*(it);
        
        //cout<<m2<<" "<<m1<<" "<<X<<" "<<M1<<" "<<M2<<endl;
        
        ans+=i*((X-m1)*(M2-M1)+(M1-X)*(m1-m2));
        
        se.insert(X);
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 9332
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
int fg(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
signed main(){
  double a;
  cin>>a;
  cout<<setprecision(14)<<a*a*a/27;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m;cin>>n>>m;
    string s,t;cin>>s>>t;
    ll g = __gcd(n,m);
    bool flag = false;
    for(int i=0; i<g; i++){
        if(s[n*i/g]!=t[m*i/g])flag=true;
    }
    if(flag)cout<<-1<<endl;
    else cout<<n/g*m<<endl;


    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <thread>
#include <tuple>
#include <vector>
using namespace std;

struct TreeNode {
    int val;
    TreeNode* left;
    TreeNode* right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};

int main() {
    int s;
    cin >> s;
    switch (s % 10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9: cout << "hon"; break;
        case 0:
        case 1:
        case 6:
        case 8: cout << "pon"; break;
        default: cout << "bon";
    }

    return 0;
}


Measured memory_bytes: 3036
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M;
    cin >> N >> M;
    int a = 0;
    int s = 0;
    for (int i = 0; i < M; i++) {
        cin >> a;
        s += a;
    }
    if (N < s) cout << -1 <<endl;
    else cout<< N - s <<endl;
    return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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

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

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int N = read(), ans = 0;
  vi v, c;
  REP(i, N) { v.PB(read()); }
  REP(i, N) { c.PB(read()); }
  REP(i, N) {
    if (c[i] < v[i]) ans += v[i] - c[i];
  }
  print(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int dp[100007];

int main(){
  ll n, m;
  cin >> n >> m;
  vi a(m);
  rep(i,m){
    cin >> a[i];
  }
  dp[0] = 0;
  dp[1] = 1;
  dp[2] = 2;
  vector<bool> b(n+1, true);
  rep(i,m){
    b[a[i]]=false;
  }
  if(!b[1]){
    dp[1] = 0;
    if(b[2]){
      dp[2] = 1;
    }
  }
  if(!b[2]){
    dp[2] = 0;
  }
  for(ll i = 3; i <= n; i++){
    if(b[i]){
        dp[i] = dp[i - 1] +  dp[i - 2];
      dp[i] %= MOD;
    }
    else{
      dp[i] = 0;
    }
  }
  print(dp[n]);
}


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


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


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


def read_float():
    return float(buff_readline())


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


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


def read_str_n():
    return readline().strip().split()

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


def mt(f):
    import time

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

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

    return wrap


@mt
def slv(H, W, C, D, S):
    C = (C[0]-1, C[1]-1)
    D = (D[0]-1, D[1]-1)
    q = deque()
    q.append((0, C))
    memo = {}
    T = 10**6
    while q:
        c, (x, y) = q.popleft()
        if (x*T + y) in memo:
            continue
        memo[x*T + y] = c

        for nx in range(x-2, x+3):
            for ny in range(y-2, y+3):
                if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == '.':
                    if abs(nx-x) + abs(ny-y) == 1:
                        q.appendleft((c, (nx, ny)))
                    else:
                        q.append((c+1, (nx, ny)))
    g = D[0]*T + D[1]
    return -1 if g not in memo else memo[g]


def main():
    H, W = read_int_n()
    C = read_int_n()
    D = read_int_n()
    S = [read_str() for _ in range(H)]
    print(slv(H, W, C, D, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 254848
fun main(args : Array<String>) {
    val k = readLine()!!.toInt()
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }

    for (i in a..b) {
        if (i % k == 0) {
            println("OK")
            return
        }
    }

    println("NG")
}

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

signed main(void)
{
	string s, t;
	long long k, ans, cnt;
	bool flag;

	cin >> s >> k;
	flag = true;
	rep(i, s.size() - 1)
	{
		if (s[i] != s[i + 1])
			flag = false;
	}
	if (flag)
		ans = s.size() * k / 2;
	else
	{
		ans = 0;
		if (s[0] != s[s.size() - 1])
		{
			rep(i, s.size() - 1)
			{
				if (s[i] == s[i + 1])
				{
					s[i + 1] = '*';
					ans++;
				}
			}
			ans *= k;
		}
		else
		{
			t = s + s;
			cnt = 0;
			rep(i, t.size() - 1)
			{
				if (t[i] == t[i + 1])
				{
					t[i + 1] = '*';
				}
			}
			rep(i, s.size())
			{
				if (s[0] == s[i])
					cnt++;
				else
					break;
			}
			for(int i = s.size(); i < t.size(); i++)
			{
				if (t[i] == '*')
					ans++;
			}
			if (t[s.size()] == '*' && cnt % 2 != 0) flag = true;
			ans *= k;
			if (flag) ans--;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<complex>
#include<unordered_map>

#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-8

#define REP(i, m) for(long long i = 0; i < m; ++i)
#define FOR(i, n, m) for(long long i = n; i < m; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	int n;
	cin>>n;
	int ans=0;
	int cnt=-1;
	FOR(i,1,n+1) {
		int buf=i;
		int res=0;
		while(buf%2==0) {
			buf/=2;
			++res;
		}
		if(res>cnt) {
			ans=i;
			cnt=res;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
#define fi first
#define se second
#define INF 100000000
using namespace std;
typedef pair<int, int> pii;

int N, A[200000];

class SegmentTree {
  int n;
  vector<pii> dat;

public:
  SegmentTree(int size) {
    n = 1;
    while(n < size) n *= 2;
    REP(i, 0, 2 * n - 1) dat.push_back(pii(INF, INF));
  }

  pii query(int a, int b) { return rquery(a, b, 0, 0, n); }

  void update(int k, pii a) {
    k += n - 1;
    dat[k] = a;
    while(k > 0) {
      k = (k - 1) / 2;
      dat[k] = op(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }

private:
  pii rquery(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return pii(INF, INF);
    if(a <= l && r <= b) return dat[k];
    pii vl = rquery(a, b, k * 2 + 1, l, (l + r) / 2);
    pii vr = rquery(a, b, k * 2 + 2, (l + r) / 2, r);
    return op(vl, vr);
  }

  pii op(pii a, pii b) { return min(a, b); }
};

struct segment {
  int l, r;
  pii v;

public:
  bool operator<(const segment &s) const { return v > s.v; }
};

int main(void) {
  cin >> N;
  REP(i, 0, N) cin >> A[i];

  SegmentTree eve(N / 2), odd(N / 2);
  REP(i, 0, N / 2) {
    eve.update(i, pii(A[i * 2 + 0], i * 2 + 0));
    odd.update(i, pii(A[i * 2 + 1], i * 2 + 1));
  }

  priority_queue<segment> q;
  q.push((segment) { 0, N, eve.query(0, N / 2) });
  vector<int> ans;
  while(q.size()) {
    struct segment s = q.top();
    q.pop();

    if(s.l >= s.r) continue;

    pii t = (s.l % 2 == 0 ? odd : eve).query((s.v.se + 1) / 2, (s.r + 1) / 2);
    ans.push_back(s.v.fi);
    ans.push_back(t.fi);
    q.push((segment) { s.l,        s.v.se, (s.l          % 2 == 0 ? eve : odd).query(s.l / 2,          s.v.se / 2) });
    q.push((segment) { s.v.se + 1, t.se,   ((s.v.se + 1) % 2 == 0 ? eve : odd).query((s.v.se + 1) / 2, t.se / 2) });
    q.push((segment) { t.se + 1,   s.r,    ((t.se + 1)   % 2 == 0 ? eve : odd).query((t.se + 1) / 2,   s.r / 2) });
  }

  REP(i, 0, ans.size()) cout << ans[i] << (i + 1 != N ? " " : "\n");
}


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

int main()
{
	int n, k; cin >> n >> k;

	vector<int> x(n);
	
	int ans = 0;

	for (int i = 0; i < n; i++) {
		cin >> x[i];
		ans += 2 * min(x[i], k - x[i]);	
	}

	cout << ans << endl;	
		
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define INF -1000000000

using namespace std;

vector<vi> grafo;
vi indegree(100006,0);
int n,m;

int khan(){
	queue<int> q;
	vi nivel(n,-1);
	for (int i = 0; i < n; ++i){
		if(!indegree[i]) {
			q.push(i);
			nivel[i] = 0;
		}
	}
	while(!q.empty()){
		int u = q.front();q.pop();
		for (int i = 0; i < (int)grafo[u].size(); ++i){
			int v = grafo[u][i];
			indegree[v]--;
			nivel[v] = max(nivel[u]+1,nivel[v]);
			if(!indegree[v]){
				q.push(v);
			}
		}
	}
	sort(nivel.begin(),nivel.end());
	return nivel[n-1];
}

int main(){
	//ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	vi empty;
	grafo.assign(n,empty);
	int u,v;
	for (int i = 0; i < m; ++i){
		cin >> u >> v;
		grafo[u-1].push_back(v-1);
		indegree[v-1]++;
	}
	cout << khan() << '\n';
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<vector<int>>s(n, vector<int>(26,0));
	for (int i = 0; i < n; i++) {
		string v;
		cin >> v;
		for (int j = 0; j < v.length(); j++)s.at(i).at((int)v.at(j) - 'a')++;
	}
	vector<int>a(26,100);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 26; j++) {
			a.at(j) = min(a.at(j), s.at(i).at(j));
		}
	}
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < a.at(i); j++) {
			char x = 'a' + i;
			cout << x;
		}
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(void)
{
    ll n;
    cin >> n;
    string s = to_string(n);
    REP(i,s.size()){
        if(s[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 3696
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

ll t, ti, A, B, C, D;

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

bool check() {
    if (B > D) return false;
    if (B > A) return false;
    if (B <= C) return true;

    if (A > C) {
        ll dif = A - C;
        A = C + (dif % B);
    }

    while (A > C) {
        if (A < B) return false;
        A -= B;
    }

    A += D;
    if (A < B) return false;


    ll dif = D - B;
    if (dif == 0) return true;

    dif = gcd(dif, B);
    A %= B;

    A += max(0LL, dif * ((C - A) / dif));
    A += dif;
    if (A < B) return false;
    return true;
}

int main()
{
 //  freopen("test.in","r",stdin);

    cin >> t;
    for (ti = 1; ti <= t; ti++) {
        cin >> A >> B >> C >> D;
        if (check())
            cout << "Yes\n";
        else
            cout << "No\n";
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int inf = 1001001001;

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

  sort(s.begin(),s.end());
  sort(t.rbegin(),t.rend());

  vector<string> u = {t,s};
  sort(u.begin(),u.end());
  if(u[0] == s && t != s) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <math.h>
#include <string> 
#include <bits/stdc++.h>
using namespace std;

int main(){
    long long n,k;
    cin >> n >> k;
    long long remain;
    remain = n%k;
    if(remain>k-remain){
        cout << k-remain << endl;
    }else{
        cout << remain << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define NMAX 100000

using namespace std;

int n, dp[NMAX+10][5];

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


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

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


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

 int l = str.length();
 int ans = 0;
 rep(i, l){
   if(str[i] == 'R' || str[i] == 'U' || str[i] == 'D') ans++;
   if(str[i+1] == 'L' || str[i+1] == 'U' || str[i+1] == 'D') ans++;
   i++;
 }
 if(ans == l) cout << "Yes" << endl;
 else cout << "No" << endl;
}


/*





















*/


Measured memory_bytes: 256
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

// debug
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG2(x, y) cout << #x << ": " << x << " " << #y << ": " << y << endl
#define DEBUG_VEC(v)   \
  cout << #v << ":";   \
  REP(i, v.size())     \
  cout << " " << v[i]; \
  cout << endl
#define DEBUG_ARR(v, n) \
  cout << #v << ":";    \
  REP(i, n)             \
  cout << " " << v[i];  \
  cout << endl

ll N;
ll L = INF;
ll R = 0;
vector< ll > X;

// ある地点Pでの消費体力 O(N)
ll consume(ll p)
{
  ll sum = 0;
  for (auto x : X)
  {
    sum += (x - p) * (x - p);
  }
  return sum;
}

ll solve()
{
  ll ans = INF;
  FOR(i, L, R)
  {
    ans = min(consume(i), ans);
  }
  return ans;
}

signed main()
{

  cin >> N;
  REP(i, N)
  {
    ll xi;
    cin >> xi;

    L = min(L, xi);
    R = max(R, xi);

    X.push_back(xi);
  }

  cout << solve() << endl;
}

Measured memory_bytes: 256
import math
import itertools
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


K = int(input())
GCD = 0
range_list = list(range(1, K+1))
iterator = itertools.product(range_list, range_list, range_list)
for a in range(1, K+1):
    for b in range(a, K+1):
        for c in range(b, K+1):
            val= gcd(a, b, c)
            if a == b and b == c:
                GCD += val
            elif a == b or b == c:
                GCD += 3 * val
            else:
                GCD += 6 * val

print(GCD)


Measured memory_bytes: 75580
import itertools
import numpy as np
h, w, k = map(int, input().split())

m = []
b_list = []

for i in range(h):
    inc = list(input())
    m.append(inc)
    for j, el in enumerate(inc):
        if el == '#':
            b_list.extend([i*w + j])


# print(m)
# print(b_list)

ans = 0

for bit_h in range(1 << h):
    for bit_w in range(1 << w):
        black = 0
        for i in range(h):
            for j in range(w):
                if m[i][j] == '#' and (bit_h >> i) & 1 and (bit_w >> j) & 1:
                    black += 1
        if black == k:
            ans += 1

print(ans)


Measured memory_bytes: 27116
using System;
using System.Linq;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            var d = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
            Console.WriteLine(d[0] < d[1] && d[1] < d[2] ? "Yes": "No");
        }
    }
}

Measured memory_bytes: 5652
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n,m;
    cin >> n >> m;
    int ans = m * (m-1)/2 + n * (n-1)/2;

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
#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() {
  ll s, w;
  cin >> s >> w;

  if (w >= s) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }

  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(){
    long long n, q;
    cin >> n >> q;
    vector<long long> num(n, (1LL << 31) - 1);
    long long t = sqrt(n);
    vector<long long> divnum(n / t + 1, (1LL << 31) - 1); 
    for(int i = 0; i < q; i++){
        long long a, b, c;
        cin >> a >> b >> c;
        if(a == 0){
            num[b] = c;
            long long temp = (1LL << 31) - 1;
            for(int j = b / t * t; j < min((b / t + 1) * t, n); j++){
                temp = min(temp, num[j]);
            }
            divnum[b/ t] = temp;
        }
        else{
            long long low = (b + t) / t, up = c / t - 1;
            long long ans = (1LL << 31) - 1;
            for(int j = low; j <= up; j++) ans = min(ans, divnum[j]);
            for(int j = b; j <= min(c, low * t - 1); j++) ans = min(ans, num[j]);
            for(int j = max(b, c / t * t); j <= c; j++) ans = min(ans, num[j]);
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 3628
#include<iostream>
#include <vector>
using namespace std;
const int INVALID = -2;
enum node_type {
	root=0,
	internal_node,
	leaf
};
const char * typemsg[3] = {"root","internal node","leaf"};
class btree{
public:
	vector<int> children;
	int sibling;
	int parent;
	int depth;
	int height;
	int type;	//0:root,1:internal node, 2:leaf
	btree():parent(-1),sibling(-1),depth(INVALID),height(0),type(internal_node){
	}
	int degree(){
		return (int)children.size();
	}

	void print(){
		//parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root
		//parent = 1, depth = 2, leaf, []
		cout << "parent = " << parent << ", sibling = " << sibling
			<< ", degree = "  << degree() << ", depth = " << depth << ", height = "  << height 
			<< ", " << typemsg[type];
	}
};

int TraverseSetDepthHeight(vector<btree> & T,int idx,int depth){
	vector<int> & children = T[idx].children;
	int height = 0;
	for(int i=0;i<(int)children.size();++i){
		T[children[i]].depth = depth;
		int h = TraverseSetDepthHeight(T,children[i],depth+1);
		height = std::max(h,height);
	}
	return	(T[idx].height = height)+1;
}

int main(){
	vector<btree> T;
	int n,k;
	int left,right;
	cin >> n;
	T.resize(n);
	for(int i=0;i<n;++i) {
		cin >> k >> left >> right;
		btree & t = T[k];
		int child=0;
		if (left >= 0){
			++child;
		}
		if (right >= 0){
			++child;
		}
		if (child>0) {
			if (child==2){
				T[left].sibling = right;
				T[right].sibling = left;
			}
			t.children.resize(child);
			if (right >= 0){
				t.children[--child] = right;
			}
			if (left >= 0){
				t.children[--child] = left;
			}
		}
		vector<int>& children = T[k].children;
		if (children.size()==0) {
			t.height = 0;
			T[k].type = leaf;
		}
		else {
			for(int j=0;j<(int)children.size();++j){
				T[children[j]].parent = k;
			}
		}
	}
	for(int i=0;i<n;++i) {
		if (T[i].parent == -1){
			T[i].type = root;
			T[i].depth = 0;
			TraverseSetDepthHeight(T,i,1);
			break;
		}
	}
	for(int i=0;i<n;++i) {
		//node 0: parent = -1, depth = 0, root, [1, 4, 10]
		cout << "node " << i << ": ";
		T[i].print();
		cout << std::endl;
	}
}

Measured memory_bytes: 1204
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut a = a;
    let mut op = vec![];
    let mut ok = true;
    while !a.is_empty() {
        let mut ma = 0;
        for i in 0..a.len() {
            if a[i] > i + 1 {
                ok = false;
                break;
            }
            if a[i] == i + 1 {
                ma = max(ma, i + 1);
            }
        }
        if !ok {
            break;
        }
        op.push(ma);
        // remove ma
        let mut na = a[..ma - 1].to_vec();
        na.extend_from_slice(&a[ma..]);
        a = na;
    }
    if ok {
        for i in 0..op.len() {
            puts!("{}\n", op[op.len() - 1 - i]);
        }
    } else {
        puts!("-1\n");
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
X, Y = map(int, input().split())
cranex2 = 4 * X - Y
turtlex2 = Y - 2 * X
print('Yes' if cranex2 % 2 == 0 and cranex2 >= 0 and turtlex2 % 2 == 0 and turtlex2 >= 0 else 'No')

Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
#define mod 1000000007
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    int i,ans=0;
    for(i=0;i<s.size()/2;i++){
        if(s[i]!=s[s.size()-i-1]){
            ans++;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
N, M = gets.split().map(&:to_i)

dp = []
br = []

100010.times do
  dp.push(0)
  br.push(true)
end

M.times do
  br[gets.to_i] = false
end

dp[0] = 1

(1..N).each do |i|
  i1 = 0
  i2 = 0
  if br[i-1]
    i1 = dp[i-1]
  end
  if i > 1
    if br[i-2]
      i2 = dp[i-2]
    end
  end
  dp[i] = i1 + i2
end

puts dp[N] % 1000000007

Measured memory_bytes: 433792
#include <bits/stdc++.h>
#define inf 99999999
using namespace std;

int n;
string s[55];
int mins[26] = {0};

int main() {
  int i, j;
  char ans;
  cin >> n;
  for(i = 0; i < 26; ++i) mins[i] = inf;
  for(i = 0; i < n; ++i) {
    int now[26] = {0};
    cin >> s[i];
    for(j = 0; j < s[i].size(); ++j) ++now[s[i][j] - 'a'];
    for(j = 0; j < 26; ++j) {
      mins[j] = min(mins[j], now[j]);
    }
  }
  for(i = 0; i < 26; ++i)
    for(j = 0; j < mins[i]; ++j) {
      ans = 'a' + i;
      cout << ans;
    }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    vector<int> H(N);
    rep(i,N) {
        cin >> H.at(i);
    }
    for (int i = N-2; i >= 0; i--) {
        int d = H[i] - H[i+1];
        if (d > 1) {
            cout << "No" << endl;
            return 0;
        } else if (d == 1) {
            H[i]--;
        }
    }

    cout << "Yes" << endl;

}


Measured memory_bytes: 640