akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
// clang-format on

vector<int> ans;
void calc(string &s, int st, int ed) {
    int a = 0;
    REP(i, st, ed) {
        if (s.substr(i, 2) == "RL") {
            a = i;
        }
    }
    int r = a - st + 1;
    ans[a] += (r + 1) / 2;
    ans[a + 1] += r / 2;
    int l = ed - a;
    ans[a + 1] += (l + 1) / 2;
    ans[a] += l / 2;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    int st = 0;
    s += "R";
    ans.resize(n, 0);
    REP(i, 0, n) {
        if (s.substr(i, 2) == "LR") {
            calc(s, st, i);
            st = i + 1;
        }
    }
    REP(i, 0, n) {
        cout << ans[i] << " \n"[i + 1 == n];
    }
    return 0;
}


Measured memory_bytes: 1104
#include<stdio.h>

int main(void)
{
    int n,i,j,tem,count;
    int num[100];

    while(scanf("%d",&n),n){

        count=0;
        for(i=0;i<n;i++){
            scanf("%d",&num[i]);
        }
        for(j=1;j<n;j++){
            for(i=0;i<n-j;i++){
                if(num[i]>num[i+1]){
                    tem=num[i];
                    num[i]=num[i+1];
                    num[i+1]=tem;
                    count++;
                }
            }
        }

        printf("%d\n",count);
    }
    return 0;
}

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

int main() {
    int A, B, C, K, sum;

    cin >> A >> B >> C >> K;

    int take;

    sum = 0;

    take = min(A, K);
    sum += take;
    K -= take;

    take = min(B, K);
    sum += 0;
    K -= take;

    take = min(C, K);
    sum -= take;
    K -= take;

    cout << sum << endl;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int health=sc.nextInt();
		int damage=sc.nextInt();
		
		int no=health/damage;
		int rem=health%damage;
		if(rem==0)
		{
			System.out.println(no);
		}
		else
		{
			System.out.println(++no);
		}
	}
}

Measured memory_bytes: 23252
# -*- coding: utf-8 -*-
# case.rb

#puts '0~10の間の数字を入力してください。(範囲の外に出たら終了。)'
loop{ # 無限ループをするメソッド
  a, op, b = STDIN.gets.split(' ')
  a = a.to_i
  b = b.to_i

  case op
  when  "+" then
    puts a + b
  when "-" then
    puts a - b
  when "*" then
    puts a * b
  when "/" then
    puts a / b
  else
    break
  end
}

Measured memory_bytes: 8652
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <sstream>
using namespace std;

typedef long long LL;
#define lowbit(x) ((x)&(-x))
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a))
#define	GE() printf(">----------\n")
#define	IN() freopen("in.txt","r",stdin)
#define	OUT() freopen("out.txt","w",stdout)
const int mod=1000000007;
const int inf=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-8;
const int maxn=105;

int n,data[maxn];

int main()
{
    while(~scanf("%d", &n)){
        int ans=0, x, rem=inf;
        for(int i=0;i<n;i++){
            scanf("%d", &data[i]);
            ans+=data[i];
        }
        sort(data, data+n);
        if(ans%10==0){
            for(int i=0;i<n;i++){
                if((ans-data[i])%10){
                    ans-=data[i];
                    break;
                }
            }
        }
        printf("%d\n", ans%10?ans:0);
    }
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll y[101010];
ll a[201010];
ll k[101010];
ll b[201010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};
ll num[11][11];
int main() {
    ans=0;
    cin>>N>>D;
    rep(i,0,N){
        rep(j,0,D){
            cin>>num[i][j];
        }
    }
    rep(i,0,N){
        rep(j,i+1,N){
            ll tmp=0;
            rep(k,0,D){
                tmp += (num[i][k]-num[j][k])*(num[i][k]-num[j][k]);
            }
            rep(k,0,1000){
                if(tmp == k*k){
                    ans++;
                    break;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 1000000000000

int main() {
	
	string S;
	cin>>S;
	
	vector<vector<int>> dp(S.size()*2+1,vector<int>(S.size()*2+1,0));
	
	dp[0][0] = 1;
	
	int R = 0;
	int B = 0;
	
	for(int i=0;i<2*S.size();i++){
		if(i<S.size()){
			B += S[i]-'0';
			R += 2-(S[i]-'0');
		}
		for(int j=0;j<=2*S.size();j++){
			if(dp[i][j]==0)continue;
			if(j+1<=R){
				dp[i+1][j+1] = mod(dp[i+1][j+1] + dp[i][j]);
			}
			if((i+1)-j <= B){
				dp[i+1][j] = mod(dp[i+1][j] + dp[i][j]);
			}
		}
	}
	
	int ans = 0;
	for(int i=0;i<S.size()*2+1;i++)ans = mod(ans + dp.back()[i]);
	
	cout<<ans<<endl;
	
    return 0;
}


Measured memory_bytes: 62976
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265358979323846264338
int main(){
    long double a,b,h,m;
    cin>>a>>b>>h>>m;
    long double hr,mi,t;
    hr = 30*h + m/2;
    mi = 6*m;
    if(hr>mi){
        t=hr-mi;
    }else{
        t=mi-hr;
    }
    if(t>180){
        t=360-t;
    }
    cout<<fixed<<setprecision(20)<<(long double)sqrt(a*a + b*b - 2*a*b*cos(t*pi/180))<<'\n';
return 0;
}



Measured memory_bytes: 4168
def g;gets.split.map &:to_i;end
n,q=g
l=[-i=1]+[m=0]*n
q.times{a,v=g
j=l[a]+=v
v>0?m<j ?(i,m=a,j):m==j&&i>a&&i=a :a==i&&(m=l.max;i=l.index m)
puts [i,m]*" "}

Measured memory_bytes: 21740
from collections import Counter
n = int(input())
A = sorted(Counter([int(i) for i in input().split()]).most_common())

flag = 0
for i in range(len(A) - 1):
    if A[i + 1][0] - A[i][0] != 2:
        flag = 1

cnt = 0
for a in A:
    if a[0] == 0 and a[1] == 1:
        pass
    elif a[0] != 0 and a[1] == 2:
        cnt += 1
    else:
        flag = 1
        break
        
if flag == 1:
    print(0)
else:
    print(2 ** cnt % (10 ** 9 + 7))       

Measured memory_bytes: 15312
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
    is >> p.first >>p.second ;
    return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
    rep(i, v.size()) {
        is >> v[i];
    }
    return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    ll n,a,b;
    ll ans=0LL;
    cin >>n>>a>>b;
	ans = n / (a + b) * a + min(n % (a + b), a);
	cout<<ans<<endl;
}

Measured memory_bytes: 3616
/*input
4 3
CABA




*/
/*
<!--> 		^_^  ^_^  ^_^
		   _____________
		  /				/
AUTHOR  :/ thesyncoder /
		/_____________/
			T_T   T_T
YOU yourself can be less noob than the one 
you are right now 
just with a little coffee.
<!-->
*/
#include <bits/stdc++.h>
using namespace std;

// ALL DEFFINES HERE
#define ll long long int
#define ii pair<int, int>
#define mp make_pair
#define N 100005
#define rep(i, n) for(int i=0; i < n; i++)
#define Rep(i, k, n) for(int i=k; i < n; i++)
#define pb push_back
#define vi vector<int>
#define vii vector< vector<int> >
#define vl vector<ll>
#define F first
#define S second

// ALL declarations here const ints etc
const  ll mod =1000000000+7; 

// IMPORTANT FUNCTION DECLARATIONS , 
//SORRY FOR THE BAD PRESENTATION
ll gcd(ll a, ll b)
{
	if ( b==0)
		return a;
	return gcd(b, a%b);
}
ll absl(ll a )
{
	return  a>= 0 ?a:-a;
}
ll maxl(ll a, ll b)
{
	return a >= b? a:b;
}
// --->>> main starts here
int primes[100000];
void seive()
{
	primes[0]=1;primes[1]=1;
	for ( int i=2; i*i <= 100000; i++)
	{
		for ( int j=i*2; j <= 100000; j+=i)
		if ( !primes[j])
		{
			primes[j] =1; 
		}
	}
}
int main()
{
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	s[k-1] = (char)(s[k-1] -'A' +'a');
	cout << s;
	
}

		








Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define outl2(x,y) cout<< (x) << ' ' << (y) << '\n'
using pii = pair<int,int>;
using ll = long long;
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
static constexpr int INF = 0x3f3f3f3f;

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

    auto f = [](ll n){return n*n*n;};
    int N,K;
    cin >>N >> K;


    ll ans = f(N/K);
    if (K % 2 == 0) {
        ll cnt = 0;
        for (int i=1; i<=N; ++i) {
            if (i % K == K/2) ++cnt;
        }
        ans += f(cnt);
    }

    outl(ans);

    return 0;
}



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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;
typedef unordered_map<int,int> uoii;
typedef unordered_map<string,int> uosi;

const int MOD = 1e9+7;

const int INF = 1e10;
bool palli(string a){
   // cout<<a<<'\n';
    for(int i=0;i<a.length()/2;i++){
        if(a[i]!=a[a.length()-1-i])
            return false;
    }
    return true;
}



int32_t main()
{
   
    IOS
    string s;
    cin>>s;
    int n=s.length();
    if(n%2&&palli(s)&&palli(s.substr(0,(n-1)/2))&&palli(s.substr((n+1)/2))){
        cout<<"Yes";
    }else{
        cout<<"No";
    }


    return 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let s: String = input();

    let t = s.chars().filter(|&c| c == 'o').count();
    println!("{}", 700 + t * 100);
}


Measured memory_bytes: 4352
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans ,a[220000], b[220000];
double dp[400][400][400];
string str, ss;
bool f[220000];
char c[4000][4000];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>vec,rvec;
vector<edge>ed;
vector<LL>v;
map<string, LL>ma;
set<LL>st;

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
double func(int i, int j, int k) {
	if (dp[i][j][k] > -1.0)return dp[i][j][k];
	double res = n;
	res += (i > 0 ? func(i - 1, j, k)*i : 0.0) +
		(j > 0 ? func(i + 1, j - 1, k)*j : 0.0) +
		(k > 0 ? func(i, j + 1, k - 1)*k : 0.0);
	dp[i][j][k] = res * 1.0 / (double)(i + j + k);
	return dp[i][j][k];
}
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		b[a[i]]++;
	}
	rep(i, 310)rep(j, 310)rep(k, 310)dp[i][j][k] = -1.0;
	dp[0][0][0] = 0;
	printf("%.15f\n",func(b[1],b[2],b[3]));
	return 0;
}


Measured memory_bytes: 393472
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  if(S.at(2)==S.at(3) && S.at(4)==S.at(5)){
    
    cout << "Yes" << endl;
    
  }
  
  else{
    
    cout << "No" << endl;
    
  }
  
}

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> x(n,0);
    rep(i,n) cin >> x.at(i);
    int ans = INF;
    for(int i=0;i+(k-1)<n;i++){
        ans = min (ans, abs(x.at(i)) + abs(x.at(i) - x.at(i+k-1)));
        ans = min (ans, abs(x.at(i+k-1)) + abs(x.at(i+k-1) - x.at(i)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

template<int mod>
struct mi {
	int val;
	mi() { val = 0; }
	mi(const LL& v) {
		val = (-mod <= v && v <= mod) ? v : v % mod;
		if(val < 0) val += mod;
	}

	friend ostream& operator<<(ostream &os, const mi &a) {
		return os << a.val;
	}
	friend istream& operator>>(istream &is, mi &a) {
		return is >> a.val;
	}

	friend bool operator==(const mi &a, const mi &b) {
		return a.val == b.val;
	}
	friend bool operator!=(const mi &a, const mi &b) {
		return !(a == b);
	}
	friend bool operator<(const mi &a, const mi &b) {
		return a.val < b.val;
	}
	friend bool operator<=(const mi &a, const mi &b) {
		return a.val <= b.val;
	}

	mi operator-() const { return mi(-val); }
	mi& operator+=(const mi &m) {
		if((val += m.val) >= mod) val -= mod;
		return *this;
	}
	mi& operator-=(const mi &m) {
		if((val -= m.val) < 0) val += mod;
		return *this;
	}
	mi& operator*=(const mi &m) {
		val = (LL) val * m.val % mod;
		return *this;
	}
	friend mi qpow(mi a, LL n) {
		if(n == 0) return 1;
		if(n % 2 == 1) return qpow(a, n - 1) * a;
		return qpow(a * a, n / 2);
	}
	friend mi inv(const mi &a) {
		assert(a != 0); return qpow(a, mod - 2);
	}
	mi& operator /=(const mi &m) { 
		return (*this) *= inv(m); 
	}

	friend mi operator+(mi a, const mi &b) { return a += b; }
	friend mi operator-(mi a, const mi &b) { return a -= b; }
	friend mi operator*(mi a, const mi &b) { return a *= b; }
	friend mi operator/(mi a, const mi &b) { return a /= b; }
};
using MI = mi<int(1e9 + 7)>;

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

	int n;
	cin >> n;

	MI fac = 1;
	vector<MI> dp(n);
	dp[0] = 0;
	FOR(i, 1, n - 1) {
		dp[i] = dp[i - 1] * i + fac;
		fac *= i;
	}

	int x;
	cin >> x;
	MI ans = 0;
	FOR(i, 1, n - 1) {
		int y;
		cin >> y;
		fac /= i;
		ans += dp[i] * (y - x) * fac;
		swap(x, y);
	}
	cout << ans << "\n";
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double k;
        k = Math.sqrt(N);
        double sq = Math.floor(k);
        int ans = (int) Math.pow(sq, 2);
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = /*1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 500'001;
const int LOGN = 19;

int n, m, k;

void solve(int test)
{
  cin >> m >> n;
  int ans = 0;
  for (int i = 1; i <= m; ++i) {
    for (int d = 1; d <= n; ++d) {
      int v1 = d / 10;
      int v2 = d % 10;
      if (v1 > 1 && v2 > 1 && v1 * v2 == i) {
        ++ans;
      }
    }
  }
  cout << ans << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
bool isPrime(int raw) {
	if (raw == 1) { return false; }
	if (raw == 2) { return true; }
	if (raw % 2 == 0) { return false; }
	for (int j=3; j < sqrt((double)raw)+1; j += 2) {
		if (raw%j == 0) { return false; }
		
	}
	return true;
}

int main() {
	int a, d, n,i,raw,c=0;
	while (1) {

		cin >> a >> d >> n;
		if (a == 0) { break; }
		for (i = 0; c < n; i++) {
			raw = a + d*i;
			if (isPrime(raw) == true) {
				c += 1;
			}
			}
			cout << raw<< endl;
			c = 0;
		
	}
	return 0;
}

Measured memory_bytes: 3088
n = int(input())
S = [int(s) for s in input().split()]
q = int(input())
T = [int(t) for t in input().split()]

def binary_search(A, key, n):
    left = 0
    right = n
    while left < right:
        mid = (left + right)//2
        if A[mid] == key:
            return True
        elif key < A[mid]:
            right = mid
        else:
            left = mid + 1
    return False

count = 0
for i in T:
    if binary_search(S, i, n):
        count += 1
print(count)

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  vector<ll> B(N);
  REP(i, N) cin >> B[i];
  vector<ll> C(N);
  REP(i, N) cin >> C[i];
  ll ans = 0;
  sort(A.begin(), A.end());
  sort(C.begin(), C.end());

  for(ll i = 0; i < N; i++) {
    auto a = lower_bound(A.begin(), A.end(), B[i]);
    ll d_a = distance(A.begin(), a);
    auto c = upper_bound(C.begin(), C.end(), B[i]);
    ll d_c = N - distance(C.begin(), c);
    ans += d_a * d_c;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#define N 1000001
using namespace std;

int main(){
	bool hamming[N]={false};
	hamming[1] = true;
	for(int j=2;j<N;j++){
		int i=j;
		while(i%2==0) i /= 2;
		while(i%3==0) i /= 3;
		while(i%5==0) i /= 5;
		if(i==1) hamming[j] = true;
	}

	int m,n;
	while(1){
		cin>>m;
		if(m == 0) break;
		cin>>n;

		int count=0;
		for(int i=m;i<=n;i++)
			if(hamming[i])
				count++;
		
		cout<<count<<endl;
	}

	return 0;
}

Measured memory_bytes: 2144
//

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    char a;cin>>a;
    if(a>96)cout<<"a"<<nnn;
    else cout<<"A"<<nnn;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

void self_add(int& a ,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
//int dp[(1<<21)]={0};//2^n

//If N is 20/21 it is preferably bitmasking
int main(int argc, char const *argv[])
{
	sync;
	int n;
	cin>>n;
	int can[n+5][n+5]={0};
	rep(i,n)
	{
		rep(j,n)
		{
			cin>>can[i][j];
		}
	}
	int dp[(1<<21)]={0};//2^n
	dp[0]=1;
	for(int mask=0;mask<(1<<n)-1;mask++)
	{
		int a=__builtin_popcount(mask);
		for(int b=0;b<n;b++)
		{
			if(can[a][b] && !(mask&(1<<b)))
			{
				int m=mask^(1<<b);
				self_add(dp[m],dp[mask]);
			}
		}
	}
	cout<<dp[(1<<n)-1]<<endl;
	return 0;
}


Measured memory_bytes: 8448
#include<stdio.h>
int main(void){
int H,W,i,j;
while(1){
scanf("%d%d",&H,&W);
if(H==0 && W==0) break;

for(i=0;i<H;i++){
 for(j=0;j<W;j++){
if(i%2==0)
  if(j%2==0)
  printf("#");
  else
  printf(".");
else
  if(j%2==1)
  printf("#");
  else
  printf(".");
}
 printf("\n");
}
 printf("\n");
}
}


Measured memory_bytes: 2084
N = int(input())
sp_list = list(map(int, input().split()))
stock = 0
money = 1000
for i in range(N-1):
    p_today = sp_list[i]
    p_tomorrow = sp_list[i+1]
    if p_tomorrow > p_today:
        stock += money // p_today
        money -= p_today * (money // p_today)
    if p_tomorrow < p_today:
        money += p_today * stock
        stock = 0

money += sp_list[N-1] * stock

print(money)


Measured memory_bytes: 9176
public class Hello{
    public static void Main(){
        // Your code here!
        string x = System.Console.ReadLine();
        string[] y = x.Split(' ');
        int a1 = int.Parse(y[0])*int.Parse(y[1]);
        int a2 = (int.Parse(y[0])+int.Parse(y[1]))*2;
        System.Console.WriteLine(a1+" "+a2);
    }
}


Measured memory_bytes: 9156
import java.util.*;
import java.math.*;

public class Main {

  // // 最大公約数
  // public static long gcd (long m,long n) {
  //   if (m < n) return gcd(n,m);
  //   if (n == 0) return m;
  //   return gcd(n,m%n);
  // }
  //
  // // 最小公倍数
  // public static long lcm (long m,long n) {
  //   return m*n/gcd(m,n);
  // }
  //
  // // 素数判定
  // public static boolean isPrime (long n) {
  //   if (n == 2) return true;
  //   if (n < 2 || n%2 == 0) return false;
  //   double d = Math.sqrt(n);
  //   for (int i = 3; i <= d; i+=2) {
  //     if (n%i == 0) {
  //       return false;
  //     }
  //   }
  //   return true;
  // }

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

    for (int i = 0; i < n.length(); i++) {
      if (n.charAt(i) == '7') {
        System.out.println("Yes");
        return;
      }
    }

    System.out.println("No");

  }

}


Measured memory_bytes: 35648
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vi a(n+1);
		for(int i=1;i<=n;i++) scanf("%d", &a[i]);

		map<int,int> m;
		ll ans=0;
		for(int i=n;i>=1;i--)
		{
			ans+=m[-(a[i]+i)];
			m[a[i]-i]++;
		}
		printf("%lld\n", ans);
	}
	return 0;
}


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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;
const long long MOD = 1000000007LL;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int findGCD(int arr[], int n) { 
    int result = arr[0]; 
    for (int i = 1; i < n; i++) 
        result = __gcd(arr[i], result); 

    return result; 
}

int main(void){

    int n;
    cin >> n;

    int a[n];
    FOR(i, n){
        cin >> a[i];
    }

    float mul = findGCD(a, n);
    float sum = 0;
    FOR(i, n){
        sum += mul/a[i];
    }

    cout << mul/sum;
    return 0;
}




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

int main() {
	while (true) {
		int n, ans = 0;
		cin >> n;
		if (n == 0) return 0;
		for (int i = 1; i <= 1000; i++) {
			int sum = 0;
			for (int j = i; j <= 1000; j++) {
				sum += j;
				if (sum == n) {
					ans++;
					continue;
				}
			}
		}
		cout << ans-1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3036
#include"bits/stdc++.h"
using namespace std;
using ll = long long;

vector<vector<int>> loser;

int dfs(int curr) {
	if (loser[curr].empty()) {
		return 0;
	}

	vector<int> nums;
	for (int l : loser[curr]) {
		nums.push_back(dfs(l));
	}
	sort(nums.begin(), nums.end(), greater<int>());
	for (int i = 0; i < nums.size(); i++) {
		nums[i] += (i + 1);
	}

	return *max_element(nums.begin(), nums.end());
}

int main() {
	int N;
	cin >> N;
	vector<int> a(N, 0);
	loser.resize(N);
	for (int i = 1; i < N; i++) {
		cin >> a[i];
		a[i]--;
		loser[a[i]].push_back(i);
	}

	cout << dfs(0) << endl;
}

Measured memory_bytes: 13952
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h> 
using namespace std;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define INF 1e18L+5
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef vector<int> vi;
typedef pair<int,int>ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<long long > vl;
template<typename T>
void show(vector<T> v){
    bool ok=true;
for(auto it:v){

    
   cout<<it<<" ";
    //cout<<it;
}
cout<<"\n";
}
 int main() { ios_base::sync_with_stdio(false); cin.tie(0);
 string s;cin>>s;
 if(s.end()[-1]=='s')s+="es";
 else s+='s';
 cout<<s;
return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int n,l,q,u,v;
int a[100055];
int P[100055][20];
signed main(){
//	freopen(".inp","r",stdin);
//	freopen(".out","w",stdout);
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	cin>>l;
	for(int i=1;i<=n;i++){
		int far=a[i]+l;
		int k=lower_bound(a+1,a+1+n,far)-a;
		if(a[k]>far||k==n+1) k--;
		P[i][0]=k;
	}
	for(int j=1;1<<j<=n;j++) for(int i=1;i<=n;i++) P[i][j]=P[P[i][j-1]][j-1];
	cin>>q;
	while(q--){
		cin>>u>>v;
		if(v<u) swap(u,v);
		int lg=log2(n),ans=0;
		for(int i=lg;i>=0;i--){
			if(P[u][i]<v){
				ans+=(1<<i);
				u=P[u][i];
			}
		}
		cout<<ans+1<<endl;
	}
}

Measured memory_bytes: 9088
import java.util.*;

public class Main {
	public Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new aoj1172().doIt();
	}
	class aoj1172{
		int prime[] = new int [300001];
		boolean is_prime[] = new boolean [300002];
		void sieve(int n){
			int p = 0;
			for(int i  =0;i <= n;i++) is_prime[i] = true;
			is_prime[0] = is_prime[1] = false;
			for(int i = 2;i < n;i++){
				if(is_prime[i]){
					prime[p++] = i;
					for(int j = 2 * i;j <= n;j += i)is_prime[j] = false;
				}
			}
 		}
		void doIt() {
			sieve(300000);
			while (true) {
				int n = sc.nextInt();
				if(n == 0)break;
				int ans = 0;
				for(int i = n + 1;i <= 2*n;i++){
					if(is_prime[i])ans++;
				}
				System.out.println(ans);
			}
		}
	}
}

Measured memory_bytes: 23108
#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<char>afk(0);
    vector<char>afkk(0);
    int x;
    cin>>x;
    string s;
    int cnt;

    cin>>s;
    bool oh=false;
    string g=s.substr(0,x/2);
    string h=s.substr(x/2,s.size()-1);
    if(x%2!=0)
    {cout<<"No"<<endl;
    return 0;
    }

/*for(int i=0;i<x/2;i++)
{

afk.at(i)=s[i];

}
for(int j=x/2;j<x;j++)
{

   afkk.at(j)==s[j];
}
//////////////////////////////////////////

for(int i=0;i<x/2;i++)
{


    if(afk.at(i)==afkk.at(i)) cnt++;

/*for(int j=x/2;j<x;j++)
{

   if(afk[i]==afkk[j])cnt++;
}

*/
//}


if(g==h) cout<<"Yes"<<endl;

 else cout<<"No"<<endl;










    return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
  int n, co, i, j;
  cin >> n >> co;
  vector<pii> s(n), t(n);
  vi c(n);
  for (i = 0; i < n; i++) {
    cin >> s[i].first >> t[i].first >> c[i];
    s[i].first *= 2;
    t[i].first *= 2;
    s[i].second = t[i].second = i;
  }
  sort(s.begin(), s.end());
  vi rokuga;
  int cnt = 0;
  for (i = 0; i < n; i++) {
    bool flag = false;
    for (j = 0; j < rokuga.size(); j++) {
      if (s[i].first == t[rokuga[j]].first && c[s[i].second] == c[t[rokuga[j]].second]) {
	rokuga[j] = s[i].second;
	flag = true;
	break;
      }
      if (s[i].first > t[rokuga[j]].first) {
	rokuga[j] = s[i].second;
	flag = true;
	break;
      }
    }
    if (!flag) {
      cnt++;
      rokuga.push_back(s[i].second);
    }
  }
  cout << cnt << endl;
}
/*
3 2
1 7 2
7 8 1
8 12 1

3 4
1 3 2
3 4 4
1 4 3

9 4
56 60 4
33 37 2
89 90 3
32 43 1
67 68 3
49 51 3
31 32 3
70 71 1
11 12 3
*/


Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = int.Parse(Console.ReadLine());

        long ans = 0;

        for (var i = 1; i < input + 1; i++) 
        {
            if (i % 3 != 0 && i % 5 != 0)
            {
                ans += i;
            }
        }

        Console.WriteLine(ans);
        
        Console.ReadLine();

    }
}

Measured memory_bytes: 17616
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
int a, b, t;

//inputします
void input() {
    cin >> a >> b >> t;
}

//ライブラリ置き場


//main
int main() {
    input();
    int ans = t / a;
    ans *= b;
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	bool a[26] = {false};

	int n;
	cin >> n;
	for(int i=0 ; i<n ; i++)
	{
		char ch;
		cin >> ch;
		a[ch-'A'] = 1;
	}
	int ans = 0;
	for(int i=0 ; i<26 ; i++)
	{
		if(a[i])	ans++;
	}

	if(ans == 3)
		cout << "Three";
	else
		cout << "Four";

	return 0;
}

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

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

const long long INF = 1LL << 60;
typedef pair<ll,int> pii;
#define fi first
#define se second
#define mp make_pair

int main(){
  ll x;
  cin >> x;

  vector<pii> a(2000);
  rep(i, 1000){
    ll n = pow((ll)i, 5);
    a[i] = mp(n, i); 
    a[i+1000] = mp(-n, -i);
  }

  rep(i, 2000){
    rep(j, 2000){
      if(a[i].fi-a[j].fi == x){
        cout << a[i].se << " " << a[j].se << endl;
        return 0;
      }
    }
  }

  return 0;
}


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

int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            int remain = x -i*500 - j*100;
            if(remain>=0&&remain%50==0&&remain/50<=c){
                //cout << i << " " << j << endl;
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define ff first
#define ss second
#define p pair<int,int>
#define pb push_back
#define endl '\n'
#define w(t) ll test;cin>>test;while(test--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define pi acos(-1)

int main()
{
    fast;
    ll n,sum=1000;
    cin>>n;
    vector<ll> vec(n);
    for(auto &i:vec)
    {
        cin>>i;
    }
    for(int i=0;i<n-1;i++)
    {
        if(vec[i]<vec[i+1])
        {
            ll tmp=sum/vec[i];
            sum+=(vec[i+1]-vec[i])*tmp;
        }
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def main():
    n = int(input())
    color = [None]*(n-1)
    color[0] = -1

    con = [[] for _ in range(n)]
    for i in range(n-1):
        a, b = map(int, input().split())
        con[a-1].append((b-1, i))
        con[b-1].append((a-1, i))

    def dfs(now=0, prev=-1, mycolor=-1):
        in_use = {mycolor}
        i = 0

        for tup in con[now]:
            if tup[0] != prev:
                while True:
                    if i not in in_use:
                        color[tup[1]] = i
                        in_use.add(i)
                        break
                    i += 1
                dfs(tup[0], now, i)

    dfs()

    print(max(color)+1)
    for i in color:
        print(i+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 99448
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 200001;

int main(){
    ll n, k;
    scanf("%lld%lld", &n, &k);
    ll an = min({n, abs(k - (n % k)), n % k});
    printf("%lld\n", an); 
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n; cin >> n;
  vector<int> a(n + 1), b(n);
  for (auto &i : a) cin >> i;
  for (auto &i : b) cin >> i;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (b[i] >= a[i]) {
      ans += a[i];
      ans += min(a[i + 1], b[i] - a[i]);
      a[i + 1] = max(0LL, a[i + 1] - b[i] + a[i]);
    } else {
      ans += b[i];
    }
  }
  cout << ans << '\n';
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

template<typename ST=string>
struct SuffixArray {
	int N; vector<int> rank,lcp,sa,rsa; ST S;

	void build(ST S){
		this->S=S;
	}
	
	SuffixArray(ST S) : S(S){
		int i,h=0; vector<int> tmp;
		N=S.size(); rank.resize(N+1); sa.resize(N+1); tmp.resize(N+1);
		FOR(i,N+1) sa[i]=i, rank[i]=i==N?-1:S[i];
		
		for(int k=1; k<=N; k<<=1) {
			auto pred2 = [k,this](int& a,int &b)->bool{ return (((a+k<=N)?rank[a+k]:-1)<((b+k<=N)?rank[b+k]:-1));};
			auto pred = [pred2,k,this](int& a,int &b)->bool{ return (rank[a]!=rank[b])?(rank[a]<rank[b]):pred2(a,b);};
			int x=0;
			if(k!=1) for(i=1;i<N+1;i++) if(rank[sa[i]]!=rank[sa[x]]) sort(sa.begin()+x,sa.begin()+i,pred2), x=i;
			sort(sa.begin()+x,sa.end(),pred);
			FOR(i,N+1) tmp[sa[i]]=(i==0)?0:tmp[sa[i-1]]+pred(sa[i-1],sa[i]);
			swap(rank,tmp);
		}
		lcp.resize(N+1); rsa.resize(N+1);
		FOR(i,N+1) rsa[sa[i]]=i;
		FOR(i,N) {
			int j=sa[rsa[i]-1];
			for(h=max(h-1,0);i+h<N && j+h<N; h++) if(S[j+h]!=S[i+h]) break;
			lcp[rsa[i]-1]=h;
		}
	}
};

int N;
string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	N=S.size();
	SuffixArray sa(S);
	
	ll ret=0;
	for(i=1;i<=N;i++) {
		x=sa.sa[i];
		y=sa.lcp[i-1];
		ret+=(N-x)-y;
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 14560
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	solve(){}
	ll operator()() {
		return 0;
	}
};

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

	for(;;)
	{
		int n, k;
		cin >> n >> k;
		if(cin.fail()) break;
		vi a(n);
		for(auto&m:a) cin >> m;

		for(int i=k;i<n;i++)
		{
			bool ans=(a[i]>a[i-k]);

			cout << (ans?"Yes":"No") << "\n";
		}
	}
	return 0;
}


Measured memory_bytes: 3984
require 'pp'

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N = gets_i
a_list = gets_i_list

a_total = 0
b_total = 0

a_list.sort.reverse.each_with_index do |a, i|
    if i.even?
      a_total += a
    else
      b_total += a
    end
end
puts a_total - b_total


Measured memory_bytes: 2172
#include<iostream>
#include<vector>
#include<cmath>
#include<cstdlib>
using namespace std;

int main()
{
	int N,K;
	std::cin >> N >> K;
	vector<int>X(N);
	int Ans = 0;
	for (int i = 0; i < N; ++i) {
		std::cin >> X[i];
		if (std::abs(X[i] - K) > X[i])Ans += (X[i] * 2);
		else Ans += (std::abs(X[i] - K) * 2);
	}
	std::cout << Ans;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, K;

  std::cin >> N >> K;

  long long xm = INF;

  for (int i = 0; i <= N; i ++) {
    std::string s(std::string(i, 'A') + std::string(N - i, 'B'));

    do {
      long long x = 1;
      
      for (int i = 0; i < N; i ++)
        if (s[i] == 'A') {
          x *= 2;
        }
        else {
          x += K;
        }

      xm = std::min(x, xm);
          
    } while (std::next_permutation(ALL(s)));
  }

  std::cout << xm << std::endl;

  return 0;
}


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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	if (a==1&&b==2||a==2&&b==1) cout<<"3";
	else if (a==1&&b==3||a==3&&b==1) cout<<"2\n";
	else cout<<"1\n";
	return 0;
}


Measured memory_bytes: 256