akhauriyash/Code-Regression huggingface dataset:
import java.util.*
import kotlin.math.*
import java.io.BufferedReader
import java.io.InputStreamReader


private var fs = BufferedReader(InputStreamReader(System.`in`))
private fun readLn() = fs.readLine()!! // string line
private fun readStrings() = readLn().split(" ") // list of strings
private fun readLong() = readLn().toLong()
private fun readLongs() = readStrings().map { it.toLong() } // list of ints
private fun readInt() = readLn().toInt() // single int
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main() {
    solve()
}
fun solve() {
    var (x,y) = readInts()
    if(y%2 ==1) println("No")
    else if(y%4==0 && x <= y/2 && x >= y/4) println("Yes")
    else if(y%4==2 && x <= y/2 && x >= (y/4)+1) println("Yes")
    else println("No")
}

Measured memory_bytes: 36416
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
#include <iomanip>
using namespace std;

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


int main(){
    int n ;
    cin >> n ;
    int num = 1 ;
    int ans = 1 ;
    while (1)
    {
        num *= 2 ;
        if (num <= n)
        {
            ans = num ;
        }else
        {
            cout << ans << endl ;
            return 0;
        }
        
        
    }
    
}

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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cout << #a << " = " << a << endl

const ll inf = 1e15;
const ll mod = 1e9+7;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

string S, T;

int main() {
    cin >> S >> T;

    T.pop_back();
    if (S == T) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>


int main() {
	std::string str;
	std::cin >> str;
	
	bool brk{ false };
	auto pr = std::make_pair(0, 0);
	size_t i{ 0 };
	while (!brk && i+1 < str.size()) {
		if (str[i] == str[i + 1]) {
			brk = true;
			pr = std::make_pair(i+1, i + 2);
		}i++;
	}

	i = 0;

	if (brk) { std::cout << pr.first << " " << pr.second << "\n"; }
	else {
		while (!brk && i + 2 < str.size()) {
			if (str[i] == str[i + 2]) {
				brk = true;
				pr = std::make_pair(i+1, i + 3);
			}i++;
		}

		if (!brk) { pr = std::make_pair(-1, -1); }
		std::cout << pr.first << " " << pr.second << "\n";
	}
	//std::cout << (N + 1)*N / 2 << "\n";
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#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)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int ok[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int hoge = 1;
    while(1){
        if(hoge*(hoge-1)/2 >= MAX_N) break;
        ok[hoge*(hoge-1)/2] = hoge;
        hoge++;
    }
    if(ok[n]){
        cout << "Yes\n";
        int cri = ok[n];
        cout << cri << "\n";
        cout << cri-1 << " ";
        rep(i,cri-1){
            cout << i+1 << " ";
        }
        cout << "\n";
        vector<deque<int> > deq;
        deque<int> hoge;
        rep(i,cri-1){
            hoge.pb(i+1);
        }
        deq.pb(hoge);
        int nw = cri;
        rep(i,cri-1){
            cout << cri-1 << " ";
            rep(j,len(deq)){
                cout << deq[j][0] << " ";
                deq[j].pop_front();
            }
            deque<int> hoge;
            rep(j,cri-1-len(deq)){
                cout << nw << " ";
                hoge.pb(nw++);
            }
            deq.pb(hoge);
            cout << "\n";
        }
    }else{
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 2432
import kotlin.comparisons.compareBy
data class XY(var x: Int, var y: Int) {
    constructor(xy: List<Int>): this(xy[0], xy[1])
}
fun main(args: Array<String>) {
    val N = nextInt()
    val R = Array(N) { XY(listOfInt()) }.sortedWith(compareBy({ -it.y }, { -it.x }))
    val B = Array(N) { XY(listOfInt()) }.sortedWith(compareBy({  it.x }, {  it.y }))
    var ans = 0
    for (b in B) {
        for (r in R) {
            if (r.x == -1) continue
            if (r.x < b.x && r.y < b.y) {
                r.x = -1
                ans += 1
                break
            }
        }
    }
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt(d: Int = 0) = listOfString().map { it.toInt() + d }
fun listOfLong(d: Long = 0) = listOfString().map { it.toLong() + d }




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

#define FOR(i, j, k) for(int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for(T &x : vec)
        is >> x;
    return is;
}

struct edge {
    int to, d;
    edge(int __to, int __d) : to(__to), d(__d) {}
};

vector<edge> es[100001];
int colors[100001];
bool used[100001];

void solve(int u, int m) {

    if(used[u])
        return;

    used[u] = true;
    colors[u] = m;

    for(auto e : es[u]) {
        solve(e.to, (m + e.d) % 2);
    }

    return;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int N;
    cin >> N;

    REP(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;

        u--;
        v--;
        es[u].emplace_back(edge(v, w));
        es[v].emplace_back(edge(u, w));
    }

    solve(0, 0);

    REP(i, N) { cout << colors[i] << endl; }

    return 0;
}


Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,m,x,nmin,ans;
  int a[59],b[59],c[59],d[59];
  cin>>n>>m;
  for(int i=0;i<n;i++)cin>>a[i]>>b[i];
  for(int i=0;i<m;i++)cin>>c[i]>>d[i];
  for(int i=0;i<n;i++){
    nmin=1000000000;
    for(int j=0;j<m;j++){
      x=abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(nmin>x){
	ans=j+1;
	nmin=x;
      }
    }
    cout<<ans<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) \
  SORT(var);       \
  REVERSE(var)
#define OPTIMIZE_STDIO         \
  ios::sync_with_stdio(false); \
  cin.tie(0);                  \
  cout.precision(10);          \
  cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
  ll x;
  mint() : x(0) {
  }
  mint(ll x) : x((x % MOD + MOD) % MOD) {
  }
  mint& operator+=(const mint& r) {
    if ((x += r.x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint& operator-=(const mint& r) {
    if ((x -= r.x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint& operator*=(const mint& r) {
    if ((x *= r.x) > MOD) {
      x %= MOD;
    }
    return *this;
  }
  mint& operator++() {
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint operator++(int) {
    mint ret = x;
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return ret;
  }
  mint& operator--() {
    if ((--x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint operator--(int) {
    mint ret = x;
    if ((--x) < 0) {
      x += MOD;
    }
    return ret;
  }
  mint operator+(const mint& r) {
    mint ret;
    return ret = x + r.x;
  }
  mint operator-(const mint& r) {
    mint ret;
    return ret = x - r.x;
  }
  mint operator*(const mint& r) {
    mint ret;
    return ret = x * r.x;
  }
  mint operator-() {
    return mint() - *this;
  }
  bool operator<(const mint& a) {
    return x < a.x;
  }
  bool operator>(const mint& a) {
    return x > a.x;
  }
  bool operator<=(const mint& a) {
    return x <= a.x;
  }
  bool operator>=(const mint& a) {
    return x >= a.x;
  }
  bool operator==(const mint& a) {
    return x == a.x;
  }
  bool operator!=(const mint& a) {
    return x != a.x;
  }
};
ostream& operator<<(ostream& os, const mint& r) {
  os << r.x;
  return os;
}
ostream& operator>>(ostream& os, const mint& r) {
  os >> r.x;
  return os;
}

void solve(istream& cin, ostream& cout) {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll ans;
  if (k <= a) {
    ans = k;
  } else if (k <= a + b) {
    ans = a;
  } else {
    ans = a - (k - a - b);
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


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

#define F(i, a, b) for (int i = a; i <= b; i ++)
#define G(i, a, b) for (int i = a; i >= b; i --)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define mx(a, b) ((a) = max(a, b))
#define mn(a, b) ((a) = min(a, b))
#define mem(a, b) memset(a, b, sizeof a)
#define mec(a, b) memcpy(a, b, sizeof a)
#define sf scanf
#define pf printf

using namespace std;

const int N = 2e2 + 10;

char ch[N][N];
int n, vis[N], S, Ans;
int D[N], h, t;

int main() {
	sf("%d", &n);
	F(i, 1, n)
		sf("%s", ch[i] + 1);

	Ans = - 1;
	F(i, 1, n) {
		mem(vis, 0), h = 0, D[t = 1] = i, vis[i] = 1, S = - 1;
		while (h ++ < t) {
			int k = D[h], v = vis[k];
			mx(S, v);
			F(j, 1, n)
				if (ch[k][j] == '1') {
					if (!vis[j])
						D[++ t] = j, vis[j] = v + 1;
					else {
						if (vis[j] != v - 1 && vis[j] != v + 1) {
							S = - 1;
							break;
						}
					}
				}
			if (S == - 1) break;
		}
		mx(Ans, S);
	}

	pf("%d\n", Ans);
}

Measured memory_bytes: 256
import collections

n = int(input())
v = list(map(int, input().split()))

count_even = collections.Counter(v[0::2])
count_odd =  collections.Counter(v[1::2])

# even
if count_even.most_common()[0][0] != count_odd.most_common()[0][0]:
    ans = n - count_even.most_common()[0][1] -count_odd.most_common()[0][1]
else:
    if len(count_even) == 1 and len(count_odd) == 1:
        ans = n//2
    elif len(count_even) == 1:
        ans = n//2 - count_odd.most_common()[1][1]
    elif len(count_odd) == 1:
        ans = (n+1)//2 - count_even.most_common()[1][1]
    else:
        ans_tmp1 = n - count_even.most_common()[0][1] - count_odd.most_common()[1][1]
        ans_tmp2 = n - count_even.most_common()[1][1] - count_odd.most_common()[0][1]
        ans = min(ans_tmp1, ans_tmp2)

print(ans)


Measured memory_bytes: 18656
#include <stdio.h>
#define LEN 25000
int Terrain(char* ascii, int len, int p, int q){
  int depth = 0, i;
  double b = 0;
  for(i = p; i < q; i++){
    if(ascii[i] == '/'){
      b += (double)depth - 0.5;
      depth--; }
    if(ascii[i] == '\\'){
      b += (double)depth + 0.5;
      depth++;
    }
    if(ascii[i] == '_'){
      b += depth; }
  }
  return b; }
int main(){
  char ascii[LEN];
  int i, len, det;
  int sum = 0, alt = 0, pl = 0, stk = 0;
  int height[LEN] = {0}, ex[LEN] = {0};
  scanf("%s", ascii);
  for(len = 0; ; len++){
    height[len] = alt;
    if(ascii[len] == '/'){
      alt++; }
    if(ascii[len] == '\\'){
      alt--;
    }
    if(ascii[len] == '\0'){
      break; }
  }
  while(pl < len){
    while(ascii[pl] != '\\' && pl < len){
      pl++; }
    det = pl+1;
    while(det <= len && height[det] != height[pl]){
      det++; }
    if(det <= len){
      ex[stk++] = Terrain(ascii, len, pl, det);
      pl = det;
    }else{ pl++;
    } }
  for(i = 0; i < stk; i++){
    sum += ex[i];
  }
  printf("%d\n%d", sum, stk);
  for(i = 0; i < stk; i++){
    printf(" %d", ex[i]);
  }
  printf("\n");
  return 0; }



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i=0; i<(int)(n); i++)
#define REP2(i,x,n) for(int i=x; i<(int)(n); i++)
using ll = long long;
int main(){
    ll N;
    cin >> N;

    vector<ll> card(N);

    REP(i,N){
        cin >> card.at(i);
    }

    sort(card.begin(), card.end());
    reverse(card.begin(), card.end());

    vector<ll> Alice(N);
    vector<ll> Bob(N);

    if(N%2==0){
        REP(i,N/2){
            Alice.at(i) = card.at(2*i);
            Bob.at(i) = card.at(2*i+1);
        }
    }

    if(N%2==1){
        REP(i,N/2){
           Alice.at(i) = card.at(2*i);
           Bob.at(i) = card.at(2*i+1);
        }
        Alice.at(N/2 +1) = card.at(N-1);
    }

    ll sum1,sum2 =0;

    REP(i,N){
        sum1 += Alice.at(i);
        sum2 += Bob.at(i);
    }

    cout << sum1 - sum2 << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#define M 8
#define empty -1
#define in 1

int choice[M][M],tate[M],yoko[M],nanameun[2*M-1],nanameup[2*M-1];

void judge_print(){
  int i,j;
  for(i=0;i<M;i++){
    for(j=0;j<M;j++){
      if(choice[i][j]==in){
	if(tate[i]!=j) return;
      }
    }
  }
  for(i=0;i<M;i++){
    for(j=0;j<M;j++){
      if(tate[i]==j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void put_Queen(int a){
  int i;
  
  if(a==M){
    judge_print();
    return;
  }
  for(i=0;i<M;i++){
    if(yoko[i]==in || nanameun[a+i]==in || nanameup[a-i+M-1]==in){
     continue;
    }
    tate[a]=i;
    yoko[i]=nanameun[a+i]=nanameup[a-i+M-1]=in;
    put_Queen(a+1);
    tate[a]=yoko[i]=nanameun[a+i]=nanameup[a-i+M-1]=empty;
  }
}

int main(){
  int sizi,i,j,a,b;

  for(i=0;i<M;i++){
    tate[i]=empty;
    yoko[i]=empty;
  }
  for(i=0;i<2*M-1;i++){
    nanameun[i]=empty;
    nanameup[i]=empty;
  }
  for(i=0;i<M;i++){
    for(j=0;j<M;j++){
      choice[i][j]=empty;
    }
  }

  scanf("%d",&sizi);

  for(i=0;i<sizi;i++){
    scanf("%d%d",&a,&b);
    choice[a][b]=in;
  }

  put_Queen(0);

  return 0;
}

  



Measured memory_bytes: 2084
#include<stdio.h>

int main(void){
    int n[10000], i = 0;
    do{
         
         scanf("%d", &n[i]);
         if(n[i] == 0){
             break;
         }
         printf("Case %d: %d\n", i+1, n[i]);
         i++;

    }while(1);
        
    return 0;
}


Measured memory_bytes: 2036
import math
n = int(input())

p = [int(s) for s in input().split()]
q = [int(s) for s in input().split()]

num_p = 1
for i in range(n):
    cnt = 0
    for j in range(i+1,n):
        if(p[i] > p[j]):
            cnt += 1
    
    num_p += math.factorial(n-i-1)*cnt

num_q = 1
for i in range(n):
    cnt = 0
    for j in range(i+1,n):
        if(q[i] > q[j]):
            cnt += 1
    #print(cnt)
    num_q += math.factorial(n-i-1)*cnt
    
#print(num_p)
#print(num_q)
print(abs(num_p-num_q))       


Measured memory_bytes: 3064
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int ans = 0;

    int b[105];
    
    for (int i = 0; i < n - 1;i++) {
        cin >> b[i];
        if (i == 0)ans += b[i];
        else ans += min(b[i - 1], b[i]);


    }
    ans += b[n - 2];
    cout << ans << endl;


    
}



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

int main() {
    int n;
    ll ans=0;
    cin>>n;
    int arr[n];
    rep(i,0,n)
    cin>>arr[i];
    sort(arr,arr+n,greater<>());
    int tmp=0;
    rep(i,1,n){
        if(i%2==0){
            tmp++;
        }
        ans+=arr[tmp];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4408
//i ll be the king
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
int main()
{
	sync;
	string s,ans="";
	cin>>s;
	for(ll i=0;i<s.length();i++)
	if(s[i]=='A')
	ans+='T';
	else if(s[i]=='T')
	ans+='A';
	else if(s[i]=='G')
	ans+='C';
	else
	ans+='G';
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	auto a = read.to!long;
	auto b = read.to!long;
	auto c = read.to!long;
	auto d = read.to!long;
	
	bool[] xs = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
	
	xs[a] = 1;
	xs[b] = 1;
	xs[c] = 1;
	xs[d] = 1;
	
	if(xs[1] + xs[9] + xs[7] + xs[4] == 4) "YES".writeln;
	else "NO".writeln;
}


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

int main()
{
    int n,k;
    cin>>n>>k;
    bool b[1000000];
    for(int i=0;i<1000000;i++)b[i]=false;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];

    for(int i=0;i<=k;i++){
        if(b[i]==false){
            for(int j=0;j<n;j++){
                b[i+a[j]]=true;
            }
        }
    }
    if(b[k]==true){
        cout<<"First";
    }
    else{
        cout<<"Second";
    }
}


Measured memory_bytes: 1280
def dijkstra(g, s)

  inf = g.size
  # inf = Float::INFINITY
  dist = Array.new(g.size, inf)
  dist[s] = 0

  # que = PriorityQueue.new
  q = []
  q << [0, s]

  while q.any?

    d, v = q.pop
    # next if dist[v] < d
    
    g[v].each do |(u, c)|
      if dist[u] == inf
        t = d + c
        dist[u] = t
        q.push( [t, u ] )
      end
    end
  end

  # dist.map!{|d| d == inf ? "INF" : d }
  dist
end

n = gets.to_s.to_i
# n = gets.to_s.split.map{|t|t.to_i}

G = Array.new(n){ [] }
(n-1).times do
  s, t, d = gets.to_s.split.map{|t|t.to_i}
  s -= 1
  t -= 1
  G[s] << [t, d]
  G[t] << [s, d]
end

q, k = gets.to_s.split.map{|t|t.to_i}
k -= 1
dist = dijkstra(G, k)
ans = []
q.times do
  x, y = gets.to_s.split.map{|t|t.to_i-1}
  ans << (dist[x] + dist[y])
end

puts ans


# judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A
# http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=4445328


Measured memory_bytes: 29180
//In the Name of Allah Most Gracious, Most Merciful//
/*If you want something you've never had, you have  to do something you never did.*/

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


#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define M 100007
#define INF 1e9
#define INFL 1e18
#define PI acos(-1)
#define mp make_pair

//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
int n;
int dp[100100];
int arr[100100];



int mydp(int i)
{
    if(i>=n)
    {
        return 0;
    }
    if(dp[i]!=-1)
    {
        return dp[i];
    }
    int ret1=INF,ret2=INF;
    if(i+2<=n)
    {
        ret1=abs(arr[i+2]-arr[i])+mydp(i+2);
    }
    if(i+1<=n)
    {
        ret2=abs(arr[i+1]-arr[i])+mydp(i+1);
    }
    dp[i]=min(ret1,ret2);
    return dp[i];
}
int main()
{

   //  #ifndef ONLINE_JUDGE
   //    freopen("input.txt","r",stdin);
   //    freopen("output.txt","w",stdout);
  //   #endif
  cin>>n;
  for(int i=1;i<=n;i++)
  {
      cin>>arr[i];
  }
  dp[0]=0;
  dp[1]=0;
//  for(int i=0;i<=100000;i++)
//  {
//      dp[i]=INF;
//  }
  arr[0]=arr[1];
  dp[0]=0;
  dp[1]=0;
  for(int i=2;i<=n;i++)
  {

      dp[i]=dp[i-1]+abs(arr[i]-arr[i-1]);
      if(i-2>=1)
      {
          dp[i]=min(dp[i],dp[i-2]+abs(arr[i]-arr[i-2]));
      }
  }
  cout<<dp[n]<<endl;


}



Measured memory_bytes: 4392
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
using graph = vector<vector<ll>>;


int main() {
	ll x, y,a,b;
	cin >> x >> y;
	string ans = "Yes";
	if (y % 2 != 0)ans = "No";
	a = 2 * x - y / 2;
	b = y / 2 - x;
	if (a < 0 || b < 0) {
		ans = "No";
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;

const int MX = 100000;

int a[MX];

int main() {
	int n, ans = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
		if (a[i] <= i && a[a[i] - 1] == i + 1) ans++;
	}
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 640
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

template<typename T>
vector <T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e:t) fill_v(e, v);
}

typedef pair<int, int> P;

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

    int N, K;
    cin >> N >> K;
    string s;
    cin >> s;

    string res;
    REP(i, s.size()) {
        if (i + 1 == K) {
            if (s[i] == 'A') res += 'a';
            if (s[i] == 'B') res += 'b';
            if (s[i] == 'C') res += 'c';
        }
        else {
            res += s[i];
        }
    }
    cout << res << endl;
    return 0;
}


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

int main() {
  long long n; cin >> n;
  vector<long long> a(n,0), b(n,0);
  for(int i = 0; i < n; i++){
    cin >> b.at(i);
    a.at(b.at(i)-1)++;
  }
  long long out = 0;
  for(int i = 0; i < n; i++){
    if(a.at(i)>=2) out += a.at(i)*(a.at(i) - 1)/2;
  }
  for(int i = 0; i < n; i++){
    if(a.at(b.at(i)-1)>=2){
      cout << out - a.at(b.at(i)-1)*(a.at(b.at(i)-1)-1)/2 + (a.at(b.at(i)-1)-1)*(a.at(b.at(i)-1)-2)/2 << endl;
    }else{
      cout << out << endl;
    }
  }
}


Measured memory_bytes: 5760
import sys
k = int(input())
a, b = map(int, input().split())

for i in range(1,1000):
  kk=k*i
  if (kk >= a and kk <= b):
    print ('OK')
    sys.exit()
  if (kk > b):
    print ('NG')
    sys.exit()
    

Measured memory_bytes: 9116
#include "bits/stdc++.h"
    #define LF '\n'
    #define ALL(x) x.begin(), x.end()
    #define iostreamBooster() do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
    using namespace std;
    typedef int64_t i64;
    typedef pair<int,int> pii;
    template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
    template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
    constexpr int INF = 0x3f3f3f3f;
    constexpr i64 LINF = 0x3f3f3f3f'3f3f3f3fLL;
     
     
    signed main()
    {
    int N;
    vector<int> a;
    cin >> N;
    for (int i = 0; i < N; ++i) {
    int n;
    cin >> n;
    a.push_back(n);
    }
     
    sort(ALL(a));
    int sum = 0;
    for (int i = 0; i < N-1; ++i) sum += a[i];
     
    if (a.back() < sum) {
    puts("Yes");
    } else {
    puts("No");
    }
    return 0;
    }
     

Measured memory_bytes: 256
N = gets.to_i
V = gets.split(' ').map(&:to_i)
C = gets.split(' ').map(&:to_i)
max = 0
tmp = 0

(1..N).each do |n|
  (0..N - 1).to_a.combination(n).each do |index|
    tmp = index.inject(0) do |sum, i|
      sum + V[i] - C[i]
    end
    max = tmp if tmp > max
  end
end

puts max


Measured memory_bytes: 4092
/*
    CP Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Shortcuts */
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(), x.end()
#define VAL(x) cout << #x << ": " << (x) << endl;
#define LOG(x) cout << (x) << endl;
#define SZ(x) (int)(x.size())
#define REP(i, a, b) for(int i = a; i < b; i++)
#define LOGR(x) for(auto a : (x)) cout << a << '\n';

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n,m;
    cin>>n>>m;

    vector<pair<ll,ll>> a;
    REP(i,0,n){
        ll x, y;
        cin>>x>>y;

        a.PB(MP(x, y));
    }

    sort(ALL(a));

    ll ans = 0;
    ll i = 0;
    while(m > 0){
        if(a[i].second >= m){
            ans += m * a[i].first;
            m = 0;
        } else {
            ans += a[i].second * a[i].first;
            m -= a[i].second;
            a[i].second = 0;
            i++;
        }
    }

    LOG(ans);

    return 0;
}


Measured memory_bytes: 2420
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    long long n;
    long long start=0,end=0,init=0,val=0;
    cin >> n;
    vector<string> s(n);
    for(int i=0; i<n; i++){
        cin >> s[i];
    }
    for(int i=0; i<n; i++){
        if(s[i][0]=='B'&&s[i][s[i].size()-1]=='A')val++;
        else if(s[i][0]=='B')start++;
        else if(s[i][s[i].size()-1]=='A')end++;
        for(int j=1; j<s[i].size(); j++){
            if(s[i][j-1]=='A' && s[i][j]=='B')init++;
        }
    }
    long long ans=0;
    if(val==0){
        cout << init+min(start,end) << endl;
        return 0;
    }
    if(start==0){
        val--;
        start++;
    }
    if(end==0){
        val--;
        end++;
    }
    ans=init+val+min(start,end);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9 + 10;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr istream &operator>>(istream &is, pair<T, U> &p) noexcept
{
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

void solve()
{
  string s, t;
  cin >> s >> t;
  int cnt = 0;
  rep(i, s.length())
  {
    if (s[i] != t[i])
      cnt++;
  }
  cout << cnt << "\n";
}

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


Measured memory_bytes: 3792
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < N; i++) {
           int num = sc.nextInt();
           if(set.contains(num)){
               System.out.println("NO");
               return;
           }
           set.add(num);
        }
        System.out.println("YES");
    }
}

Measured memory_bytes: 98536
import math

n = int(input())
arr = list(map(int, input().split()))
ans = 0
for a in range(n):
    for b in range(a+1, n):
        for c in range(b+1, n):
            if(arr[a]<arr[b]+arr[c] and arr[b]<arr[a]+arr[c] and arr[c]<arr[a]+arr[b]
               and arr[a]!= arr[b] and arr[a]!= arr[c] and arr[b]!= arr[c]):
                ans+=1
print(ans)


Measured memory_bytes: 73992
/*
Author : N_o_o_B
Created : April 22 2020 22:13:13 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;
bool g(string a,string b){
    if(sz(a) > sz(b)) return 1;
    if(sz(a) < sz(b)) return 0;
    return a > b;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;


    string a,b;
    cin >> a >> b;
    if(g(a,b)){
        cout << "GREATER" << endl;
    }
    else if(a==b){
        cout << "EQUAL" << endl;
    }
    else{
        cout << "LESS" << endl; 
    }


    time_taken();
    return 0;
}

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

using namespace std;

const int INF = 0x7FFFFFFF;

using LL = long long int;
// ST {{{
struct ST{

    // RSQ
    // 0-indexed
    //
    // Number, datA, Delay(lazy)
    int N;
    int height = 0;
    vector<LL> A;
    vector<LL> D;

    ST( int _N ):N(_N){
        build(_N);
    }

    ~ST(){
        // for( int i = 0; i < N<<1; i++ ){
        //     printf("A[%2d]:%lld D[%2d]:%lld\n", i, A[i], i, D[i]);
        // }
    }

    void build( int _N ){
        N = 1;
        height = 0;
        while( N < _N ) N <<= 1, height++;
        A.assign( N<<1,0 );
        D.assign( N<<1,0 );
    }

    // (a) -> x
    // Pay Attention Operator Precedence
    // (*,/,,+,-) --> (>>,<<) --> (>=,<=,,==,!=) --> (&,,^,,|) --> (&&,,||) --> ( a?b:c,+=,= )
    // example:
    //   X : A[a<<1+1]
    //   O : A[a<<1|1]
    void upd( int a, LL x){
        a += N;
        A[a] = A[a] + x;
        while( a >>= 1 ) {
            A[a] = A[a<<1|1] + A[a<<1|0];
        }
    }


    // evaluate [k]
    void eval( int k ){
        if( D[k] == 0 ) return;
        A[k] += D[k];
        if( k < N ){
            D[k<<1|1] += D[k] / 2;
            D[k<<1|0] += D[k] / 2;
        }
        D[k] = 0;
    }

    // eval downward until [k]
    void evaldown( int k ){
        for(int i = height; i>=0 ; i--) eval( k>>i );
    }

    void recalc( int k ){
        while( k>>=1 ) 
            A[k] = A[k<<1|1] + D[k<<1|1] + A[k<<1|0] + D[k<<1|0];
    }

    // upd query [a,b) add x
    void upd( int a, int b, LL x ){
        evaldown(a+=N);
        evaldown(b+=N-1);
        for( int t=1,l=a,r=b+1; l<r; l>>=1,r>>=1,t<<=1 ){
            if( l&1 ) D[l++] += x * t;
            if( r&1 ) D[--r] += x * t;
        }
        recalc(a);
        recalc(b);
    }

    // query [l,r)
    LL query(int l, int r){
        evaldown(l+=N);
        evaldown(r+=N-1);
        LL lv=0, rv=0;
        for( l,r++; l<r; l>>=1,r>>=1 ){
            if( l&1 ) lv = lv + A[l] + D[l++];
            if( r&1 ) rv = rv + A[--r] + D[r];
        }
        return lv + rv;
    }


};
// }}}

// solve :
// https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/2/DSL_2_G

int main() {

    int N,Q;
    int q,l,r;
    LL x;

    scanf("%d %d", &N, &Q );

    ST st(N);
    for (int i = 0; i < Q; i++){
        scanf("%d", &q );
        if( q ){
            scanf("%d %d", &l, &r);
            printf( "%lld\n", st.query(--l,r) );
        }else{
            scanf("%d %d %lld", &l, &r, &x);
            st.upd( --l,r,x );
        }
    }

    return 0;
}



Measured memory_bytes: 7052
n = int(input())
p = list(map(int,input().split()))
cnt = 0
for i in range(n - 2):
  if p[i] < p[i +1] < p[i + 2]:
    cnt += 1
  elif p[i] > p[i +1] > p[i + 2]:
    cnt += 1
print(cnt)
  

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

int Board[102][102];    //Board[j, x, w][i, y, h]
bool isOK;              //迷路がOKかNGか
int xs, ys, xg, yg;     //StartとGoalの座標

void DFS(int c, int x, int y){
    if(Board[x][y] != c){
        return;
    }
    else if(x==xg && y==yg){
        isOK = true;    //Goalなら迷路はOK
        return;
    }

    Board[x][y] = 0;

    DFS(c, x+1, y  );
    DFS(c, x  , y+1);
    DFS(c, x-1, y  );
    DFS(c, x  , y-1);
}

int main(){
    int w,h;
    while(true){
        cin >> w >> h;
        if(w==0 && h==0)
            break;
        
        isOK = false;               //初期値をNGに
        for(int i=1;i<=100;i++){    //Boardの初期化
            for(int j=1;j<=100;j++)
                Board[j][i] = -1;
        } 
        cin >> xs >> ys >> xg >> yg;

        int n, c, d, x, y;
        cin >> n;
        for(int t=0;t<n;t++){
            cin >> c >> d >> x >> y;
            int wb = 2+(!d*2);      //d=0なら横長
            int hb = 2+(d*2);       //d=1なら縦長
            for(int i=0;i<hb;i++){
                for(int j=0;j<wb;j++)
                    Board[x+j][y+i] = c;
            }
        }

        DFS(Board[xs][ys], xs, ys);

        if(isOK)
            cout << "OK" << endl;
        else
            cout << "NG" << endl;
        
    }

    return 0;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main() {
  int a, b;
  cin >> a >> b;
  if (a >= 10 || b >= 10)
    cout << -1 << endl;
  else
    cout << a * b << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,m = map(int, input().split())
A = set()
for i in range(m):
    a = int(input())
    A.add(a)
mod = (10**9)+7
dp = [1] + [0]*(n)
for i in range(1,n+1):
    if i in A:
        dp[i] == 0
    else:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
print(dp[-1])

Measured memory_bytes: 11884
#include <stdio.h>

int main(void) {
	int k, n, x = 0;
	int a[100010] = {};

	scanf("%d", &n);

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

	for (int i = 0; i < 100010; i++)
	{
		x = (a[i] > a[x]) ? i : x;
	}
	printf("%d\n", a[x]);

	return 0;
}

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

double solve(int l)
{
  const auto x = l / 3.0;
  return x * x * x;
}

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

  std::cout << std::setprecision(20);
  std::cout << solve(l) << std::endl;
}


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

using namespace std;

const int MAXN = 210000;
const int INF = 1000000000;
 
struct edge {
    int a, b, cap, flow;
};
 
int nv, s, t, d[MAXN], ptr[MAXN], q[MAXN];
vector<edge> e;
vector<int> g[MAXN];
 
void addEdge (int a, int b, int cap) {
    edge e1 = { a, b, cap, 0 };
    edge e2 = { b, a, 0, 0 };
    g[a].push_back ((int) e.size());
    e.push_back (e1);
    g[b].push_back ((int) e.size());
    e.push_back (e2);
}
 
bool bfs() {
    int qh=0, qt=0;
    q[qt++] = s;
    memset (d, -1, nv * sizeof d[0]);
    d[s] = 0;
    while (qh < qt && d[t] == -1) {
        int v = q[qh++];
        for (size_t i=0; i<g[v].size(); ++i) {
            int id = g[v][i],
                to = e[id].b;
            if (d[to] == -1 && e[id].flow < e[id].cap) {
                q[qt++] = to;
                d[to] = d[v] + 1;
            }
        }
    }
    return d[t] != -1;
}
 
int dfs (int v, int flow) {
    if (!flow)  return 0;
    if (v == t)  return flow;
    for (; ptr[v]<(int)g[v].size(); ++ptr[v]) {
        int id = g[v][ptr[v]],
            to = e[id].b;
        if (d[to] != d[v] + 1)  continue;
        int pushed = dfs (to, min (flow, e[id].cap - e[id].flow));
        if (pushed) {
            e[id].flow += pushed;
            e[id^1].flow -= pushed;
            return pushed;
        }
    }
    return 0;
}

vector<bool> visited;
vector<int> via;

void dfs2(int v) {
  visited[v] = true;
  for (int i = 0; i < (int)g[v].size(); ++i) {
    int id = g[v][i];
    int to = e[id].b;
    if (!visited[to] && e[id].flow < e[id].cap) {
      via[to] = v;
      dfs2(to);
    }
  }
}
 
int dinic() {
    int flow = 0;
    for (;;) {
        if (!bfs())  break;
        memset (ptr, 0, nv * sizeof ptr[0]);
        while (int pushed = dfs (s, INF))
            flow += pushed;
    }
    return flow;
}

int main() {
        int n; scanf("%d", &n);
        nv = 2 * n + 1;
        s = nv - 2;
        t = nv - 1;
        vector<int> left(n);
        for (int i = 0; i < n; ++i) {
            left[i] = i;
            addEdge(s, left[i], 1);
        }
        for (int i = 0; i < n - 1; ++i) {
            int cur = n + i;
            int count; scanf("%d", &count);
            addEdge(cur, t, 1);
            for (int j = 0; j < count; ++j) {
                int a; scanf("%d", &a);
                addEdge(left[a - 1], cur, 1);
            }
        }
        int flow = dinic();
        if (flow != n - 1) {
            
                printf("-1\n");
                return 0;
        }
        visited = vector<bool>(nv);
        via = vector<int>(nv);
        dfs2(s);
        for (int v : left) {
            if (!visited[v]) {
                printf("-1\n");
                return 0;
            }
        }
        vector<int> first(n - 1);
        vector<int> second(n - 1);
        for (int v : left) {
            if (via[v] == s) continue;
            int u = via[via[v]];
            first[via[v] - n] = v + 1;
            second[via[v] - n] = u + 1;
        }
        for (int i = 0; i < n - 1; ++i)           {
            printf("%d %d\n", first[i], second[i]);
        }
  
  return 0;
}

Measured memory_bytes: 40804
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
void decimal(int x){cout<<fixed<<setprecision(x);}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
  ll n,k=0; cin>>n;
  REP(i,1,n+1){
    if(i%3!=0&&i%5!=0) k+=i;
  }
  out(k);
}

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


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
const int mod=998244353;
typedef long long ll; 
int n,is[100005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		int x,y;
		cin>>x>>y;
		is[i]=(x==y);
		if(i>2&&is[i]&&is[i-1]&&is[i-2])return puts("Yes"),0;
	}
    return puts("No"),0;;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long

using namespace std;

long long gcd(long long x, long long y){
    if(y == 0) return x;
    return gcd(y, x % y);
}

int main(void){
    int N;
    ll M;
    cin >> N >> M;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];

    ll Cb = 0;
    while(A[0] % 2 == 0){
        Cb++;
        A[0] >>= 1;
    }
    A[0] <<= Cb;
    for(int i = 0; i < N; i++){
        ll Ab = 0;
        while(A[i] % 2 == 0){
            Ab++;
            A[i] >>= 1;
        }
        if(Ab != Cb){
            cout << 0 << endl;
            return 0;
        }
        A[i] <<= Ab;
    }
    ll T = 1;
    for(int i = 0; i < N; i++){
        A[i] >>= 1;
        T = T * A[i] / gcd(T, A[i]);
        // cout << T << endl;
    }

    cout << (M / T + 1) / 2 << endl;    
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
void solve();
int main (){ 
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int t;
    t = 1;
    for (int i = 0; i < t; i++) solve();
    
}
void solve() {
    //we just want to see if the money mod 100 is less than 5 * 100s
    int n;
    cin >> n;
    int huns = n / 100;
    if ((n % 100) <= huns * 5) cout << 1;
    else cout << 0;
}

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

using namespace std;

//#define FILE_IO

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    int A, B, C;
    scanf("%d%d%d", &A, &B, &C);
    if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0)
    {
        printf("0\n");
        return 0;
    }

    if(A > B)   swap(A, B);
    if(B > C)   swap(B, C);
    if(A > B)   swap(A, B);

    printf("%lld\n", 1LL * A * B);

    return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

// 7i+j+1  7i+j+2  7i+j+3
// 7i+j+8  7i+j+9  7i+j+10
// 7i+j+15 7i+j+16 7i+j+17
// = 9(7i+j)+81 = 63i+9j+81
// (63i+9j+81)%11 =(8i+9j+4)%11

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

  int m = (n - 2) / 11;
  int cnt = m * 5;

  for (int i = m * 11; i < n - 2; i++) {
    for (int j = 0; j < 5; j++) {
      int d = ((ll)8 * i + (ll)9 * j + 4) % 11;
      //printf("%3d", d);
      if (d == k) cnt++;
    }
    //putchar('\n');
  }
  
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 256