akhauriyash/Code-Regression huggingface dataset:
// Author : Harshdeep Sharma , IIT Indore
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
#define ll long long
const double PI = atan(1.0) * 4;
// const ll INF = (int)1e9 ;
const int di[4] = { -1, 0, 1, 0} ;
const int dj[4] = {0, -1, 0, 1} ;
const ll INF = (ll)2e18 + 50;
const int maximum  = numeric_limits<int>::min();
const int minimum  = numeric_limits<int>::max();

// function to calculate any numbered power of some number without modulo
ll power(ll a , ll e) {
	ll res = 1LL ;
	while (e > 0) {
		if (e % 2 == 1) res = res * a;
		a =  a * a  ;
		e /= 2 ;
	}
	return res ;
}
// function to check whether a bracketed sequence is balanced or not
bool isBalanced(const string &exp) {
	// Initialising Variables
	bool flag = true;
	int count = 0;

	// Traversing the Expression
	for (int i = 0; i < exp.length(); i++) {

		if (exp[i] == '(') {
			count++;
		}
		else {
			count--;
		}
		if (count < 0) {
			flag = false;
			break;
		}
	}
	if (count != 0) {
		flag = false;
	}

	return flag;
}
// function to sort by second in a set of pairs
bool sortbysec(const pair<pair<int, int>, int> &a,
               const pair<pair<int, int>, int> &b) {
	return (a.second < b.second);
}

void uniformly_distribute_k_numbers_in_a_square_grid(int n , int k ) {
	int p = 0 , q = 0 ;
	vector<vector<int>> a(n, vector<int>(n)) ;
	for (int i = 1 ; i <= k ; ++i ) {
		a[p][q] = 1 ;
		p = p + 1 ;
		q = (q + 1) % n ;
		if (p == n) {
			p = 0  ;
			q = (q + 1) % n ;

		}
	}
}



// main funtion
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t ;
	// cin >> t ;
	// while (t--) {
	int H , W ;
	cin >> H >> W ;
	int h , w ;
	cin >> h >> w ;
	cout << H*W - h*W - (H - h)*w << "\n";









	// }







	return 0 ;
}


Measured memory_bytes: 3628
H, W = map(int, input().split())
def f(H, W):
    ans = H * W
    for h1 in range(1, H // 2 + 1):
        h2 = (H - h1) // 2
        h3 = H - h1 - h2
        ans = min(ans, max(h1, h2, h3) * W - min(h1, h2, h3) * W)

        w1 = W // 2
        w2 = W - w1
        a1 = h1 * W
        a2 = (H - h1) * w1
        a3 = (H - h1) * w2
        ans = min(ans, max(a1, a2, a3) - min(a1, a2, a3))

    return ans

print(min(f(H, W), f(W, H)))

Measured memory_bytes: 3064
//
//  main.cpp
//  Atcoder Beginner Contest 071 D
//
//  Created by luras on 2017/8/20.
//  Copyright © 2017年 luras. All rights reserved.
//

#define ms(x, y) memset(x, y, sizeof(x))
#define mc(x, y) memcpy(x, y, sizeof(x))
#define lson o << 1, l, mid
#define rson o << 1 | 1, mid + 1, r
#define ls o << 1
#define rs o << 1 | 1
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<queue>
#include<map>
#include<stack>
#include<vector>
#include<list>
#include<set>
#include<string>
#include<algorithm>
#pragma comment(linker,"/STACK:102400000,102400000")
template <class T> inline void gmax(T &a, T b){if(b > a) a = b;}
template <class T> inline void gmin(T &a, T b){if(b < a) a = b;}
using namespace std;
const int N = 100 + 10, M = 2e6 + 10, Z = 1e9 + 7, maxint = 2147483647, ms1 = 16843009, ms31 = 522133279, ms63 = 1061109567, ms127 = 2139062143;
const double PI = acos(-1.0), eps = 1e-8;
typedef long long LL;
void fre()
{
    freopen("/Users/luras/Desktop/in.txt", "r", stdin);
    freopen("/Users/luras/Desktop/out.txt", "w", stdout);
}
const int INF = 1e9;
int casenum, casei;

int n;
char s1[N], s2[N];
LL f[N];

void gadd(LL &a, LL b)
{
    a += b;
    if(a >= Z) a %= Z;
}
int main()
{
    scanf("%d", &n);
    scanf("%s%s", s1 + 1, s2 + 1);
    for(int i = 1; i <= n; i ++){
        if(i == 1){
            if(s1[i] == s2[i]) f[1] = 3;
            else {f[2] = 6; i ++;}
            continue;
        }
               
        if(s1[i] == s2[i] && s1[i - 1] == s2[i - 1]){
            gadd(f[i], f[i - 1] * 2);
        }
        else if(s1[i] == s2[i]){
            gadd(f[i], f[i - 1]);
        }
        else if(s1[i - 1] == s2[i - 1]){
            gadd(f[i + 1], f[i - 1] * 2);
            i ++;
        }
        else{
            gadd(f[i + 1], f[i -1] * 3);
            i ++;
        }
    }
    printf("%lld\n", f[n]);
    return 0;
}

/*
 
 
 题意:
 
 类型:
 
 分析:
 
 优化:
 
 trick:
 
 数据:
 
 Sample Input
 
 Sample Output
 
 
 */






Measured memory_bytes: 128
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }
vector<pair<ll, ll>> primeFac(ll n) {
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////

int main() {
  int x;
  cin >> x;
  int kyu = 8 - ((x - 400) / 200);
  cout << kyu << endl;
}

Measured memory_bytes: 3624
#include <cstdio>
const int N=200005;
bool a[N*2];char s[N];
int main(){
	int n,k;scanf("%d%d\n%s",&n,&k,s+1);for (int i=1;i<=n;i++) a[i]=s[i]-'A';
	int l=1,r=n,t=0;for (;k && l<=n;k--)if (a[l]^t) l++,a[++r]=(t^=1);else a[l]^=1;
	if (k&1 && n&1) a[l]^=1;for (int i=l;i<=r;i++) printf("%c",'A'+(a[i]^t));
}

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

int main() {
	int a, b, c, d, e, k;
	while ( cin >> a >> b >> c >> d >> e >> k ) {
		if ( e-a > k ) cout << ":(\n";
		else cout << "Yay!\n";
	}
	return 0;
}

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

bool seat[100001] = {false};

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

  int s, e;
  for(int i=0; i<n; i++){
    cin >> s >> e;

    for(int k=s; k<=e; k++){
      seat[k] = true;
    }
    
  }

  int cnt = 0;
  for (int i=0; i<100001; i++){
    if(seat[i]) cnt++;
  }

  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int graf[114][114];

int main() {
	int n;
	while (cin >> n, n) {
		for (int i = 0; i < 100; i++)
			for (int j = 0; j < 100; j++)graf[i][j] = 0;

		for (int i = 0; i < n; i++) {
			int m;
			cin >> m;
			for (int j = 0; j < m; j++) {
				int a;
				cin >> a;
				graf[i][a-1]=1;
			}
		}

		int k[103];
		int b;
		cin >> b;
		for (int i = 0; i < b; i++)cin >> k[i];

		vector<int>v;
		for (int i = 0; i < n; i++) {
			int flg = 0;
			for (int j = 0; j < b; j++) {
				if (!graf[i][k[j]-1])flg = 1;
			}
			if (flg == 0)v.push_back(i);
		}
		if (v.size() == 1)cout << v[0] +1<< endl;
		else cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

struct piihash {
    size_t operator()(const pii &p) const {
        auto h1 = hash<int>()(p.first);
        auto h2 = hash<int>()(p.second);
        return (h1 << 32) + h2;
    }
};

int main(void)
{
    IOS
    int h, w;
    cin >> h >> w;
    vector<string> v(h);
    int b = 0;
    REP(i,h) {
        cin >> v[i];
        REP(j, v[i].size()) if (v[i][j] == '#') b++;
    }
    unordered_set<pii,piihash> p;
    auto ppush = [&] (int x,int y) {p.insert(make_pair(x,y)); return;};
    ppush(0,0);
    int l = 0;
    bool goal = false;
    auto isroad = [&](int x,int y) {return v[x][y] != '#';};
    while(!p.empty()) {
        unordered_set<pii,piihash> ptmp;
        swap(p,ptmp);
        l++;
        for(auto q:ptmp) {
            //cerr << q.first << " " << q.second << endl;
            if (q.first == h-1 && q.second == w-1) {
                goal = true;
                break;
            }
            v[q.first][q.second] = '#';
            // up
            if (q.first != 0 && isroad(q.first-1,q.second)) ppush(q.first-1,q.second);
            if (q.first != h-1 && isroad(q.first+1,q.second)) ppush(q.first+1,q.second);
            if (q.second != 0 && isroad(q.first,q.second-1)) ppush(q.first,q.second-1);
            if (q.second != w-1 && isroad(q.first,q.second+1)) ppush(q.first,q.second+1);
        }
        if (goal) break;
    }
    //cerr << l << endl;
    int ans = 0;
    if (goal) ans = h*w - b - l;
    else ans = -1;

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 512
import numpy as np

S = input()
N = len(S)
s = np.array([int(i) for i in list(S)])
s1 = np.array([i % 2 for i in range(N)])
s2 = np.array([(i + 1) % 2 for i in range(N)])

print(min(np.sum(np.abs(s - s1)), np.sum(np.abs(s - s2))))

Measured memory_bytes: 18144
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  if(n%2){
    cout << "No" << endl;
    return 0;
  }

  string s;
  cin >> s;
  for(int i=0; i<n/2; i++){
    if(s[i] != s[n/2+i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 105;

int N, D[MAX_N], mx, vis[MAX_N], mn = MAX_N;

int main() {

  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &D[i]), vis[D[i]]++;
    mx = max(mx, D[i]), mn = min(mn, D[i]);
  }

  bool flag = 1;
  if (mn < (mx + 1) / 2) flag = 0;
  
  if ((mx & 1) == 0) {
    for (int i = mx; i >= mn; --i)
      if (i != mx / 2) {
	if (vis[i] < 2) flag = 0;
      } else {
	if (vis[i] != 1) flag = 0;
      }
  } else {
    for (int i = mx; i >= mn; --i)
      if (i != (mx + 1) / 2) {
	if (vis[i] < 2) flag = 0;
      } else {
	if (vis[i] != 2) flag = 0;
      }
  }

  if (flag) puts("Possible");
  else puts("Impossible");
  
  return 0;
}

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

#define ll long long
#define mod 1000000007

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

    if(s=="SUN")
    {
        cout<<"7\n";
    }
    else if(s=="MON")
    {
        cout<<"6\n";
    }
    else if(s=="TUE")
    {
        cout<<"5\n";
    }
    else if(s=="WED")
    {
        cout<<"4\n";
    }
    else if(s=="THU")
    {
        cout<<"3\n";
    }
    else if(s=="FRI")
    {
        cout<<"2\n";
    }
    else cout<<"1\n";


    return 0;
}


Measured memory_bytes: 256
Q = 10**9 + 7
'''
def factorial(n):
    if n == 0:
        return 1
    else:
        return (n * factorial(n-1))%Q
'''
N, M = map( int, input().split())
N, M = min(N, M), max(N, M)
if N == M or N+1 == M:
    NN = 1
    MM = 1
    for i in range(1,N+1):
        NN = (NN*i)%Q
    if N == M:
        ans = (2*NN*NN)%Q
    elif N+1 == M:
        ans = (NN*NN*M)%Q
else:
    ans = 0
print(ans)

Measured memory_bytes: 3064
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int n, cnt, a[13][9], l[13], p[11], used[11], zero[11]; char c[11];
int solve(int depth) {
	if (depth == cnt) {
		int ret = 0;
		for (int i = 0; i < n; i++) {
			int res = 0;
			for (int j = l[i] - 1; j >= 0; j--) res = res * 10 + p[a[i][j]];
			if (i + 1 == n) ret -= res;
			else ret += res;
		}
		return ret ? 0 : 1;
	}
	int ret = 0;
	for (int i = 0; i < 10; i++) {
		if (!used[i]) {
			used[i] = 1, p[depth] = i;
			if(i || zero[depth]) ret += solve(depth + 1);
			used[i] = 0;
		}
	}
	return ret;
}
int main() {
	string s;
	while (cin >> n, n) {
		cnt = 0;
		memset(c, 0, 11);
		memset(zero, -1, 44);
		for (int i = 0; i < n; i++) {
			cin >> s; l[i] = s.size();
			reverse(s.begin(), s.end());
			for (int j = 0; j < s.size(); j++) {
				int flag = 0;
				for (int k = 0; k < cnt; k++) {
					if (s[j] == c[k]) {
						a[i][j] = k, flag = 1;
						break;
					}
				}
				if (!flag) a[i][j] = cnt, c[cnt++] = s[j];
			}
			if(s.size() > 1) zero[a[i][s.size() - 1]] = 0;
		}
		cout << solve(0) << endl;
	}
}

Measured memory_bytes: 3048
x, y = (int(x) for x in input().split())
ans = 100000000000
if x <= y: ans = min(ans, y - x)
if (-1) * x <= y: ans = min(ans, y + x + 1)
if x <= (-1) *y: ans = min(ans, (-1) * y + (-1) * x + 1)
if (-1) * x <= (-1) * y: ans = min(ans, (-1) * y + x + 2)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const string YES = "Yes";
const string NO = "No";

vector<vector<int>> func(int H, int W, int h, int w) {
    vector<vector<int>> v(H, vector<int>(W, -100001LL));
    for(int i = 0; i < H; i += h) {
        for(int j = 0; j < W; j++) {
            v[i][j] = (h - 1) * 100000LL;
        }
    }

    return v;
}

void solve(long long H, long long W, long long h, long long w){
    if (H % h == 0 && W % w == 0) {
        cout << NO << endl;
        return;
    }

    cout << YES << endl;

    vector<vector<int>> v(H, vector<int>(W));
    if (H % h == 0) {
        auto u = func(W, H, w, h);
        for(int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                v[i][j] = u[j][i];
            }
        }
    } else {
        v = func(H, W, h, w);
    }

    int sum = 0;
    for(int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << v[i][j] << (j == W - 1 ? "\n" : " ");
            sum += v[i][j];
        }
    }

    assert(sum > 0);
}

signed main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long h;
    scanf("%lld",&h);
    long long w;
    scanf("%lld",&w);
    solve(H, W, h, w);
    return 0;
}


Measured memory_bytes: 6144
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int i = 1;
		while (s.hasNextInt()) {
			int n = s.nextInt();
			if (n == 0) break;
			System.out.printf("Case %d: %d\n", i, n);
			i++;
		}
	}
}

Measured memory_bytes: 55356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

void solve() {
    vector<pair<str, pair<ll, ll> > > p;
    ll N;
    cin >> N;
    REP(i, N) {
        str s;ll v;
        cin >> s >> v;
        p.push_back({s, {200 - v, i+1}});
    }
    ASC(p);
    REP(i, N) {
        out(p[i].second.second);
    }
}

int main() {
    fast_io;
    cout << setprecision(20) << fixed;
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        // 主処理
        String[] arr = s.split("");
        int result = 0;
        for (String str : arr) {
            result += Integer.parseInt(str);
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 23636
#ifndef TEMPLATE_HPP
#define TEMPLATE_HPP
#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--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())
using namespace std;
using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename U> vector<U> make_vector(T&& n, U&& val) { return vector<U>(forward<T>(n), forward<U>(val)); }
template <typename T, typename... Args> decltype(auto) make_vector(T&& n, Args&&... args) { return vector<decltype(make_vector(forward<Args>(args)...))>(forward<T>(n), make_vector(forward<Args>(args)...)); }
const int INF = 1001001001;
const i64 LINF = 1001001001001001001ll;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
#endif

i64 calc(vi32 a) {
  i64 ret = 0;
  deque<int> q;
  rep(i, sz(a)) q.push_back(a[i]);
  deque<int> r;
  r.push_back(q.back());
  q.pop_back();
  int i = 1;
  while (true) {
    ret += abs(r.front() - q.front());
    r.push_front(q.front());
    q.pop_front();
    if (++i == sz(a)) break;
    ret += abs(r.back() - q.front());
    r.push_back(q.front());
    q.pop_front();
    if (++i == sz(a)) break;
    ret += abs(r.front() - q.back());
    r.push_front(q.back());
    q.pop_back();
    if (++i == sz(a)) break;
    ret += abs(r.back() - q.back());
    r.push_back(q.back());
    q.pop_back();
    if (++i == sz(a)) break;
  }
  return ret;
}

void solve() {
  int n;
  cin >> n;
  vi32 a(n);
  cin >> a;
  sort(all(a));
  i64 ans = 0;
  amax(ans, calc(a));
  reverse(all(a));
  amax(ans, calc(a));
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  solve();
  return 0;
}

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

using ll = long long int;
using P = pair<int, int>;
using P3 = pair<int, P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};

vector<vector<P> > g;
vector<int> d;
vector<bool> visited;
vector<bool> used; 
int maxi = 0;
set<int> st;

void dijkstra(int s, int f=0){
    fill(d.begin(), d.end(), INF);
    d[s] = 0;
    priority_queue<P, vector<P>, greater<P> > que;
    que.push(P(d[s],s));
    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        for(auto &e : g[v]){
            int u = e.first, c = e.second;
            if(d[u] > d[v] + c){
                d[u] = d[v] + c;
                que.push(P(d[u],u));
            }
        }
    }
    if(!f){
        for(int i=0;i<int(g.size());i++){
            if(d[i] > maxi){
                st.clear();
                st.insert(s);
                st.insert(i);
                maxi = d[i];
            }
            else if(d[i] == maxi && !visited[i]){
                st.insert(i);
                st.insert(s);
            }
        }
    }else{
        fill(visited.begin(), visited.end(), false);
        queue<int> q;
        for(int i=0;i<int(g.size());i++){
            if(d[i] == maxi) q.push(i);
        }
        while(!q.empty()){
            int v = q.front();
            q.pop();
            used[v] = true;
            for(auto &e : g[v]){
                int u = e.first , c = e.second;
                if(!visited[u] && d[u]+c == d[v]){
                    visited[u] = true;
                    q.push(u);
                }
            }
        }
    }
}

int main() {
    int N, R;
    cin >> N >> R;
    g.resize(N);
    d.resize(N);
    visited.resize(N);
    used.resize(N);
    for(int i=0;i<R;i++){
        int s, t, c;
        cin >> s >> t >> c;
        s--; t--;
        g[s].emplace_back(P(t,c));
        g[t].emplace_back(P(s,c));
    }
    for(int i=0;i<N;i++){
        dijkstra(i);
    }
    for(auto v : st){
        dijkstra(v, 1);
    }
    vector<int> ans;
    for(int i=0;i<N;i++){
        if(!used[i]){
            ans.push_back(i+1);
        }
    }
    cout << ans.size() << endl;
    for(auto v : ans){
        cout << v << endl;
    }
    return 0;
}



Measured memory_bytes: 3388
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.NoSuchElementException;
public class Main {
	public static void main(String[] args)throws Exception{
		PrintWriter out = new PrintWriter(System.out);
		int N=nextInt();
		long A[]=new long[N];
		long sum[]=new long[N];
		long ans=0,mod=1000000007;
		for(int i=0;i<N;i++){
			A[i]=nextInt();
			sum[i]=A[i];
			if(i!=0){
				sum[i]+=sum[i-1];
			}
			sum[i]%=mod;
		}
		for(int i=N-1;i>=1;i--){
			ans+=sum[i-1]*A[i]%mod;
			ans%=mod;
		}
		System.out.println(ans);
	}
	public static long lmod(long i, long j) {
	     return (i%j)<0?(i%j)+0+(j<0?-j:j):(i%j+0);
	 }
	static boolean isOK(int index,int key,ArrayList<Integer> a){
		if (a.get(index)>=key) return true;
	    else return false;
	}
	static int binary(int key,ArrayList<Integer> a) {
	    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	    while (Math.abs(ok - ng) > 1) {
	        int mid = (ok + ng) / 2;
	        if (isOK(mid,key,a)) ok = mid;
	        else ng = mid;
	    }
	    return ok;
	}
	//FastScanner
	static InputStream in = System.in;
	static  byte[] buffer = new byte[1024];
	static int length = 0, p = 0;
	public static boolean hasNextByte () {
		if (p < length) return true;
		else {
			p = 0;
			try {length = in.read(buffer);}
			catch (Exception e) {e.printStackTrace();}
			if (length == 0) return false;
		}
		return true;
	}
	public static int readByte () {
		if (hasNextByte() == true) return buffer[p++];
		return -1;
	}
	public static boolean isPrintable (int n) {return 33<=n&&n<=126;}
	public static void skip () {
		while (hasNextByte() && !isPrintable(buffer[p])) p++;
	}
	public static boolean hasNext () {skip(); return hasNextByte();}
	public static String next () {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int temp = readByte();
		while (isPrintable(temp)) {
			sb.appendCodePoint(temp);
			temp = readByte();
		}
		return sb.toString();
	}
	public static int nextInt () {return Math.toIntExact(nextLong());}
	public static int[] nextInts (int n) {
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = nextInt();
		return ar;
	}
	public static long nextLong () {
		if (!hasNext()) throw new NoSuchElementException();
		boolean minus = false;
		int temp = readByte();
		if (temp == '-') {
			minus = true;
			temp = readByte();
		}
		if (temp<'0' || '9'<temp) throw new NumberFormatException();
		long n = 0;
		while (isPrintable(temp)) {
			if ('0'<=temp && temp<='9') {
				n *= 10;
				n += temp - '0';
			}
			temp = readByte();
		}
		return minus? -n : n;
	}
}



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


int main(void) {

  int r, c;
  cin >> r >> c;
  vector< vector<int> > m(r, vector<int>(c));
  for(int i=0; i<r; i++){
    for(int j=0; j<c; j++){
      cin >> m[i][j];
    }
  }
  vector<int> s(c+1, 0);
  for(int i=0; i<r; i++){
    for(int j=0; j<c; j++){
      cout << m[i][j] << " ";
      s[j] += m[i][j];
    }
    cout << accumulate(m[i].begin(), m[i].end(), 0) << endl;
    s[c] += accumulate(m[i].begin(), m[i].end(), 0);
  }
  for(int i=0; i<c; i++){
    cout << s[i] << " ";
  }
  cout << s[c] << endl;


  return 0;
}

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

typedef long long ll;

typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;

#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
 
template<class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
    return out <<  "(" << a.first << ", " << a.second << ")";
}
 
template<class A> ostream& operator << (ostream& out, const vector<A> &a) {			
    out << "[";
    for (auto it = a.begin(); it != a.end(); ++it) {
        if (it != a.begin())
            out << ", ";
        out << *it;
    }
    return out << "]";
}
int arr[200001];

void solve(){
    ll n;
    cin >> n;
    string x;
    cin >> x;

    //n = 1
    if(n==1){
        if(x=="0") cout<<1<<"\n";
        else cout<<0<<"\n";
        return;
    }
    arr[0] = 0;

    for(int i=1;i<=200000;i++){
        arr[i] = arr[i%__builtin_popcount(i)]+1; 
    }
    ll curr1 = 0;
    ll curr2 = 0;
    vll pw1={1};
    vll pw2={1}; 
    ll cnt = 0;
    for(auto cc : x){
        if(cc == '1') cnt++;
    }
    if(cnt == 0){
        for(int i=0;i<n;i++)
            cout<<1<<"\n";
        return; 
    }
    for(int i = n-1;i >= 0 ;i--){
        if(x[i] == '1'){
            curr1+=pw1.back();
            curr2+=pw2.back();
            curr2%=cnt+1;
            if(cnt!=1)
            curr1%=cnt-1;
        }
        if(cnt!=1)
            pw1.push_back((2LL*pw1.back())%(cnt-1));
        pw2.push_back((2LL*pw2.back())%(cnt+1));
        // pw1.push_back((2LL*pw1.back()));
        //pw2.push_back((2LL*pw2.back()));
    } 

    reverse(all(pw1));
    reverse(all(pw2));

    for(int i=0;i<n;i++){ 
        if(x[i] == '0'){
            cout<<arr[(curr2 + pw2[i+1])%(cnt+1)]+1<<"\n";
        }
        else{

            if(cnt == 1)
                cout<<0<<"\n";
            else
                cout<<arr[(curr1 - pw1[i+1] + (cnt-1))%(cnt-1)]+1<<"\n";
        }
    }

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
   // cin >> t;
    while(t--){
        solve();
    }

	return 0;
}


Measured memory_bytes: 7596
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
#define lld double
#define vi vector<ll>
#define pii pair<int,int>
#define piii pair<pii, ll>
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define ppb pop_back
#define d0(x) cout<<x<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<x<<" "<<y<<"\n"
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define d5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<endl
using namespace std;
const ll mod = 1e9+7;


int a[100001],b[100001];int mina,minb;
int main()
{
    int A,B,M;
    cin>>A>>B>>M;

    mina = minb = 1e6;

    for(int i=1;i<=A;i++)
    {
        cin>>a[i];
        mina = min(mina,a[i]);
    }

    for(int i=1;i<=B;i++)
    {
        cin>>b[i];
        minb = min(minb,b[i]);
    }

    int ans = mina+minb;

    for(int i=1;i<=M;i++)
    {
        int x,y,z;
        cin>>x>>y>>z;
        ans = min(ans,a[x]+b[y]-z);
    }

    d1(ans);

}

Measured memory_bytes: 1024
from collections import deque
n = int(input())
abc = 'abcdefghij'
s = ''
cnt = 0
ans = deque([s])
while True:
    a = ans.popleft()
    cnt = len(a)
    if cnt == n:
        ans.append(a)
        break
    kind = len(set(a)) + 1
    for i in range(kind):
        ans.append(a + abc[i])

for i in sorted(ans):
    print(i)



Measured memory_bytes: 86348
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  string S;
  int N;
  cin >> N >> S;

  for(int i = 0;i < S.size();i++) {
    cout << (char)((S.at(i)-'A'+N)%26 + 'A');
  } 

  cout << endl;

}


Measured memory_bytes: 256
import itertools
import math
N=int(input())
L=[]
for i in range(N):
    x,y = map(int,input().split())
    L.append([x,y])

a=[]
for j in range(0,N):
    a.append(j)
ans=[]
for v in itertools.permutations(a, N):
    v=list(v)
    K=0
    for j in range(N-1):
        K+=math.sqrt((L[v[j+1]][0]-L[v[j]][0])**2+(L[v[j+1]][1]-L[v[j]][1])**2)
    ans.append(K)
    
print(sum(ans)/len(ans))

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

int Exp(long long int exp_n,long long int exp_e, long long exp_mod);


int main(){
  string S,T;
  int c =0;
  
  cin >> S >> T;
  for(int i=0;i<S.length();i++){
    if(S[i]!=T[i]){
      c++;
    }
  }
  cout << c;
  
  return 0;
  
  

}


int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


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

using namespace std;

int main(){
    int n, t;
    cin >> n;
    vector<int> ar;
    
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
        cin >> t, ar.push_back(t);
    
    sort(ar.begin(), ar.end());

    double rez = ar[0];

    for (int ctr1 = 1; ctr1 < n; ++ctr1)
        rez = (rez + ar[ctr1]) / 2.0;

    printf("%.10f\n", rez);
    return 0;
}

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


int main() {
    int N,K;
    cin >>N>>K;
    vector<int> data(N);
    rep(i,N)cin>>data[i];
    int mx =1000000000;
     sort(data.begin(),data.end());
    for(int i=0;i<N-K+1;i++){
        int a =data[i+K-1]-data[i];
        mx =min(mx,a);
    }
    cout <<mx<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

int n;
s64 a, b;
s64 h[100000];

bool ok(s64 cnt)
{
    s64 ret = 0;
    rep (i, n) ret += CEIL(MAX(0, h[i] - b * cnt), a - b);
    return ret <= cnt;
}

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

    cin >> n;
    cin >> a >> b;

    rep (i, n) cin >> h[i];

    s64 l = 0, r = 1e9;
    while (l + 1 < r)
    {
        s64 m = (l + r) / 2;
        if (ok(m)) r = m;
        else l = m;
    }

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



Measured memory_bytes: 4400
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      x: i64,
      aa: [i64; n],
    }
    let mut aa = aa;
    let mut ans = 0;
    let mut x = x;
    aa.sort();
    for i in 0..n {
        if x < aa[i] {
            x = 0;
            break;
        }
        ans += 1;
        x -= aa[i];
    }
    if x > 0 {
        ans -= 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 &y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 &y) {if (x < y) x = y;}


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e15;
    // const int mod = 2600000069;
    // const int p = 10;
    // const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e15;
    // const int mod = 2600000069;
    // const int p = 179;
    // const ld PI = 3.1415926535;
#endif

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i++) {
        if (s[i] == '?') s[i] = 'D';
    }
    cout << s;
}
/*

*/  

Measured memory_bytes: 3780
'use strict';
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim();
  var S = Number (inputs);
  var h = Math.floor(S/3600);
  var m = Math.floor((S-(h*3600))/60);
  var s = S % 60;
	console.log ([h,m,s].join(':'));
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15540
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        var n = rint();
        var s = rstr();
        int rct = 0, rct2 = 0;
        for (int i = 0; i < n; i++)
            if (s[i] == 'R')
                rct++;
        for(int i = 0; i < rct; i++)
            if (s[i] == 'R')
                rct2++;
        WriteLine(rct - rct2);
    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


Measured memory_bytes: 27912
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vl a(n),b(n),g(n);
  rep(i,n){
    cin >> a[i] >> b[i];
    g[i]=(b[i]+(b[i]-a[i])%b[i])%b[i];
  }
  ll cnt=0;
  for(ll i=n-1;i>=0;i--){
    g[i]=((g[i]-cnt)%b[i]+b[i])%b[i];
    cnt +=g[i];
  }
  cout << cnt << endl;
}

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

const int Max=100005;
int n;
char ch[Max];

int main()
{
	scanf("%s",ch+1),n=strlen(ch+1);
	for(int i=1;i<=n;i++)
	{
	  if(ch[i]==ch[i+1]) {cout<<i<<" "<<i+1<<"\n";return 0;}
	  if(ch[i]==ch[i+2]) {cout<<i<<" "<<i+2<<"\n";return 0;}
	}
	cout<<"-1 -1\n";
	return 0;
}

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

    

    cout << a-b+1 << endl;

   return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	string a,b,c;
	cin >> a >> b >> c;
	cout << a[0] << b[1] << c[2] << "\n";

	return 0;
}


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

const ll INF = 1LL << 60;

int main() {
    ll N, K; cin >> N >> K;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];

    // 1) N == K;
    ll base;
    ll cost = INF;

    for (int i = 0; i < (1 << (N - 1)); i++) {
        // cout << i << endl;
        vector<ll> other;
        ll tmp = 0;
        base = a[0];
        set<ll> st;
        for (int j = 0; j < (N - 1); j++) {
            if (i >> j & 1) {
                // other.push_back(a[j + 1]);
                st.insert(j + 1);
            }
        }
        // cout << endl;
        // cout << "sze:" << other.size() << endl;
        if (st.size() != K - 1) continue;

        ll prev_high = base;
        for (int k = 1; k < N; k++) {
            if (st.count(k)) {
                // 選ぶ
                if (prev_high + 1 <= a[k]) {
                    prev_high = a[k];
                } else {
                    prev_high++;
                    tmp += prev_high - a[k];
                }
            } else {
                // 選ばない
                prev_high = max(prev_high, a[k]);
            }
            // cout << tmp << endl;
        }
        cost = min(cost, tmp);
    }

    cout << cost << endl;
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int K;
    cin >> K;

    if (K % 2 == 0) {
        print(K*K/4);
    } else {
        print((K-1)*(K+1)/4);
    }
}

signed main() {
    solve();
}


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

main(){
int N,H,W;
cin >> N >> H >> W;
int A[N];
int B[N];
for(int ii=0;ii<N;ii++){
cin >> A[ii];
cin >> B[ii];
}
int ans=0;
for(int ii=0;ii<N;ii++){
if(A[ii]>=H && B[ii]>=W)ans++;
}
cout << ans << endl;
}

Measured memory_bytes: 256
N, X, Y, Z = map(int, input().split())
p = 10 ** 9 + 7
m = 1
m <<= X
m += 1
m <<= Y
m += 1
m <<= Z - 1
L = 2 ** (X + Y + Z - 1)
M = [[0 for _ in range(10)] for _ in range(L)]
for i in range(L):
  for j in range(10):
    k =  i << (j + 1)
    k += 1 << j
    M[i][j] = (k % L) if k & m != m else -1
DP = [[0 for _ in range(L)] for _ in range(N + 1)]
DP[0][0] = 1
for i in range(N):
  for j in range(L):
    if DP[i][j] == 0:
      continue
    DP[i][j] %= p
    for k in range(10):
      l = M[j][k]
      if l < 0:
        continue
      DP[i + 1][l] += DP[i][j]
cnt = 10 ** N % p
print((cnt - sum(DP[N]) % p) % p)

Measured memory_bytes: 118876
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cmath>
#include<stack>
using namespace std;
int main()
{
    int n,l;
    while(cin>>n>>l)
    {
        string mapp[105];
        int a[105];
        for(int i=0; i<n; i++)
        {
            cin>>mapp[i];
            a[i] = (int)mapp[i][0];
        }
        sort(mapp, mapp+n);
        for(int j=0; j<n; j++)
            cout<<mapp[j];
        }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)
#define P pair<int,int>
ll n, k,b,c,i,j,x,y,z=0,m=0;
ll xx[100000], yy[100000];
string s;
ll a[505] = {};
bool kkk(ll c) {
	x = 0; y = 0;
	rep(j, n) {
		xx[j] = a[j] % c;
		y += c - xx[j];
	}
	sort(xx, xx + n);
	rep(j, n) {
		if (max(x, y) <= k) {
			return true;

		}
		x += xx[j];
		y -= c - xx[j];
	}

	return false;
}



int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n>>k;
	rep(i, n) {
		cin >> a[i];
		z += a[i];
	}
	for (i = 1; i*i <= z; i++){
		if (z % i != 0)continue;

		if (kkk(i))m = max(m, i);
		if (kkk(z/i))m = max(m, z/i);
	}	
	cout << m;
	aaa:
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define clr(a, x) memset(a, x, sizeof(a))
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define X first
#define Y second
#define fastin                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-6;

const int N = 1 << 17;
bool notprime[N] = {1, 1};
void GetPrime()
{
    for (int i = 2; i < N; i++)
        if (!notprime[i] && i <= N / i) // 筛到√n为止
            for (int j = i * i; j < N; j += i)
                notprime[j] = 1;
}

int cnt[N];
void init()
{
    GetPrime();
    for (int i = 3; i < N; i += 2)
        if (!notprime[i] && !notprime[(i + 1) >> 1]) cnt[i]++;
    for (int i = 1; i < N; i++)
        cnt[i] += cnt[i - 1];
}

int main()
{
#ifndef ONLINE_JUDGE
// freopen("1.in", "r", stdin);
// freopen("1.out", "w", stdout);
#endif
    init();
    int q;
    scanf("%d", &q);
    while (q--)
    {
        int l, r;
        scanf("%d%d", &l, &r);
        printf("%d\n", cnt[r] - cnt[l - 1]);
    }
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

ll n;
vector<ll> a, dp, ans;
vector<ll> to[114514 * 2];

const ll INF = 1e18;

void dfs(ll cv, ll par) {
  auto it = lower_bound(ALL(dp), a[cv]);
  ll idx = it - dp.begin();
  ll bef = dp[idx];
  dp[idx] = min(dp[idx], a[cv]);
  ans[cv] = lower_bound(ALL(dp), INF) - dp.begin() - 1;
  for (ll nv : to[cv]) {
    if (nv == par) {
      continue;
    }
    dfs(nv, cv);
  }
  dp[idx] = bef;
}

int main() {
  cin >> n;
  a = vector<ll>(n);
  ans = vector<ll>(n);
  REP(i, n) { cin >> a[i]; }
  REP(i, n - 1) {
    ll u, v;
    cin >> u >> v;
    u--, v--;
    to[u].push_back(v);
    to[v].push_back(u);
  }

  dp = vector<ll>(n + 2, INF);
  dp[0] = -1;
  // dp[i] = LISの長さがiとなるときの末尾の最小値
  dfs(0, -1);

  REP(i, n) { cout << ans[i] << endl; }
}

Measured memory_bytes: 30888
import sys
input = sys.stdin.readline
import fractions


def main():
    N, M = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]
    ans = 1
    mi = float("inf")
    for a in A:
        if a & 1:
            print(0)
            exit()
        else:
            ans = (ans * (a // 2)) // fractions.gcd(ans, a // 2)
    for a in A:
        if a & 1:
            print(0)
            exit()
        else:
            if ans % a == 0:
                print(0)
                exit()

    print(-(-(M // ans) // 2))



    
    

if __name__ == '__main__':
    main()



Measured memory_bytes: 16268