akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll x;
    cin>>x;
    ll a[110010]={};
    a[100]=1;
    a[101]=1;
    a[102]=1;
    a[103]=1;
    a[104]=1;
    a[105]=1;
    rep(i,100010){
        if(a[i]==1){
            a[i+100]=1;
            a[i+101]=1;
            a[i+102]=1;
            a[i+103]=1;
            a[i+104]=1;
            a[i+105]=1;
        }
    }
    if(a[x]==1) cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 1152
#include<cstdio>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
        double a, b;
        int c;
        int i, j ;
        while(scanf("%lf%lf", &a, &b) != EOF){
                c = a + b;
                for(i = 0; c != 0; i++){
                        c /= 10;
                }
                printf("%d\n", i);
        }
        return 0;
}

Measured memory_bytes: 1052
if __name__ == "__main__":
    S = input()
    ok = True
    if S[0] != 'A':
        ok = False
    cnt = 0
    for x in S[2:-1]:
        if x == "C":
            cnt += 1
    if cnt != 1:
        ok = False
    cnt = 0
    for x in S:
        if x.isupper():
            cnt += 1
    if cnt != 2:
        ok = False
    if ok:
        print ("AC")
    else:
        print ("WA")

Measured memory_bytes: 38256
Module Module1
    Sub main()
        Dim userInput As Long
        Dim total As Long

        ' データの入力
        userInput = Console.ReadLine()
        Dim num As Long = CLng(userInput)

        total = num + num ^ 2 + num ^ 3

        '' 処理結果を返す
        Console.WriteLine(total)
    End Sub
End Module

Measured memory_bytes: 28716
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 7 * 17 * (1 << 23) + 1;
const ll inf = 1e18 + 69;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll fact[300100], inv[300100];
ll bp(ll a, ll p) {
	ll r = 1;
	while (p) {
		if (p & 1)
			r = (r * a) % mod;
		p >>= 1;
		a = (a * a) % mod;
	}
	return r;
}
ll setup() {
	fact[0] = 1;
	for (int i = 1; i < 300100; i++) {
		fact[i] = (fact[i - 1] * i) % mod;
	}
	inv[300100 - 1] = bp(fact[300100 - 1], mod - 2);
	for (int i = 300100 - 1; i--;)
		inv[i] = (inv[i + 1] * (i + 1)) % mod;
}
ll nck(ll n, ll k) {
	if(k>n) return 0;
	ll r = (fact[n] * inv[n - k]) % mod;
	return (r * inv[k]) % mod;
}
ll n, a, b, k;
int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	setup();
	cin >> n >> a >> b >> k;
	ll ans = 0;
	for(ll i = 0; i*a <= k; i++) {
		if((k-i*a)%b) continue;
		ll j = (k-i*a)/b;
		ans = (ans + nck(n, i)*nck(n, j))%mod;
	}
	cout << ans;
}


Measured memory_bytes: 4992
N = int(input())
print(0,flush=True)
s = input().strip()
if s[0]!="V":
    x = s[0]
    low = 0
    high = N
    while high-low>1:
        mid = (high+low)//2
        print(mid,flush=True)
        s = input().strip()
        if s[0]=="V":
            break
        elif mid%2==0 and s[0]==x:
            low = mid
        elif mid%2==0 and s[0]!=x:
            high = mid
        elif mid%2==1 and s[0]==x:
            high = mid
        elif mid%2==1 and s[0]!=x:
            low = mid

Measured memory_bytes: 62040
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int maxW = sc.nextInt();
		int weight[] = new int[num];
		long value[] = new long[num];
		for(int i = 0; i < num; i ++) {
			weight[i] = sc.nextInt();
			value[i] = sc.nextLong();
		}

		long dp[][] = new long[num + 1][maxW + 1];
		for(int i = 0; i <= num; i ++) {
			dp[i][0] = 0;
		}
		for(int j = 0; j <= maxW; j ++) {
			dp[0][j] = 0;
		}
		for(int i = 1; i <= num; i ++) {
			for(int j = 1; j <= maxW; j ++) {
				if(j < weight[i - 1]) {
					dp[i][j] = dp[i - 1][j];
				}else {
					dp[i][j] = Math.max(dp[i - 1][j - weight[i - 1]] + value[i - 1], dp[i - 1][j]);
				}
			}
		}

		long max = 0;
		for(int i = 0; i <= num; i ++) {
			for(int j = 0; j <= maxW; j ++) {
				max = Math.max(max, dp[i][j]);
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 128468
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s,t;
    cin>>s>>t;
    int cnt=INF;
    for (int i = 0; i <= s.size() - t.size(); i++)
    {
        int tmp=0;
        for (int j = 0; j < t.size(); j++)
        {
            if(s[i+j] !=t[j]) tmp++;
        }
        chmin(cnt,tmp);        
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3600
//F5で実行 Shift+F5で停止
//F9でブレークポイント
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
//Ctrl+PageUpで上部の大半を選択できる

int N;

void _main() {

	map<int, int> mp;

	//数字一覧（１～９、１～９をループ)
	rep(i, 1, 10) {
		rep(j, 1, 10) {
			mp[i*j] = 1;
		}
	}

	cin >> N;
	
	cout << (mp[N] == 1 ? "Yes" : "No") << endl;

}

Measured memory_bytes: 256
n=int(input())
mat=[[0]*30 for _ in range(30)]
ary=[]
op=0
a=[]
for _ in range(n):
  t=list(input().split('.'))
  if len(t)==1:
    c=int(t[0])*pow(10,9)
  else:
    c=int(t[0])*pow(10,9)
    r=int((t[1]+'0'*10)[:9])
    c+=r
  n2,n5=0,0
  while (c//pow(2,n2))%2==0:
    n2+=1
  while (c//pow(5,n5))%5==0:
    n5+=1
  n2=min(n2,9+9)
  n5=min(n5,9+9)
  mat[n2][n5]+=1
  a.append((c,n2,n5))
  ary.append((n2,n5))
#for x in a:
#  print(x)
summat=[[0]*31 for _ in range(31)]
for i in range(30):
  for j in range(30):
    summat[i+1][j+1]=summat[i+1][j]+mat[i][j]
for i in range(30):
  for j in range(30):
    summat[i+1][j+1]+=summat[i][j+1]

ans=0
for n2,n5 in ary:
  t2,t5=n2,n5
  t2-=9
  t2*=-1
  t2+=9
  t5-=9
  t5*=-1
  t5+=9
  #print(n2,n5,t2,t5)
  ans+=summat[-1][-1]-summat[t2][-1]-summat[-1][t5]+summat[t2][t5]
  if n2>=9+op and n5>=9+op:ans-=1
print(ans//2)


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

int main() {
  int n;
  string s;
  set<string> ss;
  cin >> n;
  REP(i, n) {
    cin >> s;
    ss.insert(s);
  }
  cout << (ss.size() == 3 ? "Three" : "Four") << endl;
  return 0;
}

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

int choice(int m, vector<int>& p1, vector<int>& p2) {
	int n = p1.size();
	vector<vector<int>>dp(n + 1, vector<int>(m + 1, 0));
	for (int i = 0; i <= m; ++i) {
		dp[n][i] = i;
	}
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j <= m; ++j) {
			int ma = dp[i + 1][j];
			for (int k = 0; k <= j / p1[i]; ++k) {
				ma = max(ma, dp[i + 1][j - p1[i] * k] + p2[i] * k);
			}
			dp[i][j] = ma;
		}
	}
	return dp[0][m];
}

int main() {
	int n, d, x;
	cin >> n >> d >> x;
	int money = x;
	vector<vector<int>>p(d, vector<int>(n));
	for (int i = 0; i < d; ++i)
		for (int j = 0; j < n; ++j) cin >> p[i][j];
	for (int i = 0; i < d - 1; ++i)money = choice(money, p[i], p[i + 1]);
	cout << money << endl;
}

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

ll ans=0;

void dfs(ll node, vector<ll>adj[],ll dp[], bool vis[])
{
    vis[node]=true;
    ll i;
    for(i=0;i<adj[node].size();i++)
    {
        if(!vis[adj[node][i]])
        dfs(adj[node][i],adj,dp,vis);
        dp[node] = max(dp[node], 1 + dp[adj[node][i]]);
        if(dp[node]>ans)
        ans=dp[node];
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,i,j,a,b;
    cin>>n>>m;
    ll dp[n+1]={0};
    vector<ll>adj[n+1];
    for(i=0;i<m;i++)
    {
        cin>>a>>b;
        adj[a].push_back(b);
    }
    bool vis[n+1]={false};
    for(i=1;i<=n;i++)
    {
        if(!vis[i])
        dfs(i,adj,dp,vis);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9984
w, h, n = map(int, input().split())
xa = 0
xb = w
ya = 0
yb = h
for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        xa = max(x, xa)
    if a == 2:
        xb = min(x, xb)
    if a == 3:
        ya = max(y, ya)
    if a == 4:
        yb = min(y, yb)
        
print(max(max(xb - xa, 0) * max(yb - ya, 0), 0))

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
const int INF = 1e9;
const llint llINF = 1e18;

int main () {
    int t, x; cin >> t >> x;
    cout << (double)t / x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <omp.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

int main()
{
	int n, q;
	cin >> n >> q;
	vector<int> t(q), u(q), v(q);
	for (int i = 0; i < q; ++i) {
		cin >> t.at(i) >> u.at(i) >> v.at(i);
	}
	dsu d(n);
	for (int i = 0; i < q; ++i) {
		if (t.at(i) == 0) {
			d.merge(u.at(i), v.at(i));
		} else {
			if (d.same(u.at(i), v.at(i))) {
				cout << 1 << endl;
			} else {
				cout << 0 << endl;
			}
		}
	}
}

Measured memory_bytes: 5860
import sys

n, m = (int(x) for x in sys.stdin.readline().split())
city_list = [[int(x) for x in sys.stdin.readline().split()] for y in range(m)]
print_list = [0] * m
count = 0
pref_dic = {}
for i in range(len(city_list)):
    city_list[i].append(i)
city_list.sort(key=lambda x: (x[0], x[1]))
for i in city_list:
    pref = i[0]
    pref_id = "0" * (6 - len(str(pref))) + str(pref)
    city_id = ""
    if pref in pref_dic:
        pref_dic[pref] += 1
        city = pref_dic[pref]
        city_id = "0" * (6 - len(str(city))) + str(city)
    else:
        pref_dic[pref] = 1
        city_id = "0" * (6 - len(str(1))) + str(1)
    print_list[i[2]] = pref_id + city_id

for i in print_list:
    print(i)

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

const int MAX_W = 50, MAX_H = 50;

int w, h, c[MAX_H][MAX_W];

bool visited[MAX_H][MAX_W];

void dfs(int, int);

int main() {
    while (true) {
        // input
        cin >> w >> h;
        
        if (w == 0 && h == 0) break;

        REP(i, h) {
            REP(j, w) cin >> c[i][j];
        }

        // init visited
        REP(i, h) {
            REP(j, w) visited[i][j] = false;
        }

        // count island by DFS 
        int cnt_island = 0;
        REP(i, h) {
            REP(j, w) {
                if (visited[i][j] == false && c[i][j] == 1) {
                    dfs(i, j);
                    cnt_island++;
                }
            }
        }

        // output
        PRINT(cnt_island);
    }
    return 0;
}

void dfs(int x, int y) {
    visited[x][y] = true;
    for (int dx = -1; dx <= 1; dx++) {
        for (int dy = -1; dy <= 1; dy++) {
            int nx = x + dx;
            int ny = y + dy;
            if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
            if (visited[nx][ny] || c[nx][ny] == 0) continue;
            dfs(nx, ny);
        }
    }
}


Measured memory_bytes: 3244
import sys
import numpy as np
N, W = map(int, input().split())
it = iter(map(int, sys.stdin.read().split()))
dp = np.zeros(W + 1, dtype=np.int64)
for w, v in zip(it, it):
    np.maximum(dp[:-w] + v, dp[w:], out=dp[w:])
print(dp[-1])

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

using namespace std;

int main()
{
    int visited[201]={0};
    int x,n;
    cin>>x>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        visited[a[i]]=1;
    }
    int mini=9999;
    int minbr=9999;
    for(int i=0;i<=2*x;i++)
    {
        if(visited[i]==0)
        {
            if(abs(x-i)<mini)
            {
                mini=abs(x-i);
                minbr=i;
            }
            if(abs(x-i)==mini)
            {
                if(i<minbr)
                {
                    minbr=i;
                }
            }
        }
    }
    cout<<minbr<<endl;
}


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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    for (int i = 0; i < N; i++)
        cin >> H[i];
    sort(H.begin(), H.end());
    cout << H.end() - lower_bound(H.begin(), H.end(), K) << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
class Main 
{
  public static void main(String[] args) 
  {
    Scanner input=new Scanner(System.in);
    int a=input.nextInt();
    int b=input.nextInt();
    int c=input.nextInt();
    if(b>=1 && b<=1000 && c>=1 && c<=1000 && a>=(b+c) && a<=10000)
    {
     a=a-b;
     int temp=a%c;
     System.out.println(temp);
    }
  }
}

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

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define mp make_pair
#define pb push_back
#define all(name) (name.begin(), name.end())
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) power(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;

class Dsu {
	vector<int> drr;
	vector<int> size_arr;
	public :
	Dsu (int n) {
		rep(i, 0, n+1){
			drr.pb(i);
			size_arr.pb(1);
		}
	}

	int f_p (int a) {
		return drr[a] == a ? a : f_p(drr[a]);
	}

	ll size (int a) {
		return (ll)size_arr[f_p(a)];
	}

	void uni(int a, int b) {
		int ap = f_p(a);
		int bp = f_p(b);
		if(ap == bp)return;
		if(!size_arr[ap] > size_arr[bp])swap(ap,bp);
		drr[bp] = ap;
		size_arr[ap] += size_arr[bp];
	}
};



vector<ll> ft(1, 1LL);
vector<bool> is_prime(1000000, 1);

void sieve();
ll power(ll x, ll y);

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	int t = 1;
	// cin >> t;
	while(t--)
	{
		ll n;
        cin >> n;
        cout << (n/500LL)*(1000LL) + ((n%500LL)/5LL)*5LL << endl;
	}
}
//
//
//
//
//
//important funct
ll power(ll x, ll y) {
    ll res = 1;x %= mod;
    while (y > 0) {
        if (y & 1)res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
void sieve(){
	is_prime[0] = is_prime[1] = 0;
	for(int i = 2; i*i <= 1000000; i++)
		if(is_prime[i])
			repc(j, i*i, 1000000, i)is_prime[j] = 0;
}

Measured memory_bytes: 384
l=map(int,raw_input().split())
n=raw_input()
ans=chk=0


def rolling(word,dice):
    if word=='S':
        dice[0],dice[1],dice[5],dice[4]=dice[4],dice[0],dice[1],dice[5]
    elif word=='N':
        dice[0],dice[1],dice[5],dice[4]=dice[1],dice[5],dice[4],dice[0]
    elif word=='W':
        dice[0],dice[2],dice[5],dice[3]=dice[2],dice[5],dice[3],dice[0]
    else:
        dice[0],dice[2],dice[5],dice[3]=dice[3],dice[0],dice[2],dice[5]
    return dice

for i in n:
    l=rolling(i,l)
print l[0]

Measured memory_bytes: 4264
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    ll a[n];
    for(int i=0;i<n;i++){
    	cin >> a[i];
    }
    for(int i=k;i<n;i++){
    	if(a[i-k] < a[i]){
    		cout << "Yes" << endl;
    	}else{
    		cout << "No" << endl;
    	}
    }
    return 0;
}

Measured memory_bytes: 5200
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd); FUNC(printde);
#endif

struct Node{
    vector<Node*> dests;
    void add(Node* n){
        dests.push_back(n);
    }
    void add2(Node* n){
        add(n);
        n->add(this);
    }
    void dfs(unordered_set<Node*> & ts, unordered_set<Node*>& fs, Node* from = nullptr){
        if(ts.count(this)){ return; }
        ts.insert(this);
        for(Node* d : dests){
            // if(d == from){ continue; }
            d -> dfs(fs, ts, this);
        }
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    vector<Node> nodes(n);
    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        a--; b--;
        nodes[a].add2(&nodes[b]);
    }
    unordered_set<Node*> ts, fs;
    nodes[0].dfs(ts, fs);
    prints(ts.size(), fs.size());
    ll ans;
    if((ll)ts.size() == n){
        ans = n * (n - 1) / 2;
    }else{
        // ans = ts.size() * (ts.size() - 1) / 2;
        // ans += fs.size() * (fs.size() - 1) / 2;
        ans = ts.size() * fs.size();
    }
    ans -= m;
    cout << ans << '\n';
}


Measured memory_bytes: 15936
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n,m,a,b;
  cin>>n>>m>>a>>b;
  vector<ll> vok;
  vector<ll> vng;
  rep(i,0,n){
    ll c;
    cin>>c;
    if(c>=a)vng.pb(c);
    else{
      vok.pb(c);
      break;
    }
  }
  reverse(all(vng));
  ll count = 0;
  if(n-vng.sz>=m){
    cout << vng.sz << endl;
    return 0;
  }
  rep(i,0,vng.sz){
    if(vng[i]<=b){
      count++;
    }
    else{
      break;
    }
  }
  cout << vng.sz-count << endl;
  return 0;
}

Measured memory_bytes: 3152
m, d = list(map(int, input().split()))
ans = 0
for i in range(m+1):
    if i < 4:
        continue
    for j in range(d+1):
        d1 = j % 10
        d10 = j // 10
        if d1 <2 or d10 < 2:
            continue
        if d1 * d10 == i:
            ans += 1
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    int sec = 0 ;
    int m = 0 ;
    int s = 0 ;

    for ( int i = 0 ; i < 4 ; i++ )
    {
        cin >> sec ;
        s += sec ;
    }

    m = s / 60 ;
    s = s % 60 ;
    cout << m << endl << s << endl ;

    return 0 ;
}

Measured memory_bytes: 3092
from collections import deque
import sys, copy,itertools
input = sys.stdin.readline

n, k = map(int,input().split())
#P = list(map(int,input().split()))
P = list(map(lambda x : int(x) - 1, input().split())) #ひとつづつずらす
C = list(map(int,input().split()))
SCORE = [0]*(n+1)

max_score = -10**12
for i in range(n):
  x = i
  TEMPMAX = [-10**9] * (n+1)
  for j in range(1, n+1):
    SCORE[j] = SCORE[j-1] + C[P[x]]
    TEMPMAX[j]= max(TEMPMAX[j-1], SCORE[j])
    x = P[x]
    if x == i:
      break
  if j >= k:
    max_score = max(max_score,TEMPMAX[k])
  elif SCORE[j] < 0:
    max_score = max(max_score, TEMPMAX[j])
  else:
    m = k//j
    a = SCORE[j] *(m-1) + TEMPMAX[j]
    b = SCORE[j] *m + TEMPMAX[k % j]
    max_score = max(max_score, a, b)
print(max_score)

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

int main() {
  int A,B,M;
  int ans;
  int mf = 300000,mr = 300000;
  
  cin >> A >> B >> M;
  vector<int> fr(A);
  vector<int> ra(B);
  for(int i=0;i<A;++i){
    cin >> fr.at(i);
    if(fr.at(i) < mf) mf = fr.at(i);
  }
  for(int i=0;i<B;++i){
    cin >> ra.at(i);
    if(ra.at(i) < mr) mr = ra.at(i);
  }

  ans = mf + mr;
  for(int i=0;i<M;++i){
    int x,y,c;
    cin >> x >> y >> c;
    int p = fr.at(x-1) + ra.at(y-1) - c;
    if(p < ans) ans = p;
  }
  cout << ans << endl;
  return 0;
}


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

//少数を考えるときはdouble!!!intだけ使うと引っかかるぞ！！

int main(){
  int a,b,c,counter=0;
  cin >> a >> b >> c;
  int total=a+b+c;
  int ma=max(max(a,b),c);
  int res=3*ma-total;
  if(res%2==0){
    counter=res/2;
  }else{
    counter=(3*ma-total+3)/2;
  }
  cout << counter << endl;
}


Measured memory_bytes: 256
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
ll maxl(ll a, ll b){ return ((a<b)?b:a);}
ll minl(ll a, ll b){ return ((a>b)?b:a);}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int arr[n];
    for (int i=0;i<n;i++){
        cin >> arr[i];
    }
    int M = 1e9 + 7;
    vector<int> suffix(n,0);
    suffix[n-1] = arr[n-1];
    for (int i=n-2;i>=0;i--){
        ll temp = (ll)(arr[i] + suffix[i+1]);
        temp = temp%M;
        suffix[i] = temp;
    }
    ll ans = 0;
    for (int i=0;i<n-1;i++){
        ll temp = arr[i];
        ll temp2 = suffix[i+1];
        temp = (temp*temp2)%M;
        ans = (ans + temp)%M;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 4780
import time
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    ans = 1
    inf = 10**18
    t = time.time()

    if 0 in A:
        print(0)
        exit()

    for i in range(len(A)):
        ans *= A[i]
        if ans > inf :
            print(-1)
            exit()

    print(ans)
    
if __name__ == "__main__":
    main()

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

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, ll>> xl(n);
  rep(i, n) cin >> xl[i].first >> xl[i].second;

  sort(xl.begin(), xl.end());

  ll k = xl[0].first + xl[0].second;
  ll ans = n;
  for (ll i = 1; i < n; i++) {
    if (k + xl[i].second <= xl[i].first) {
      k = xl[i].first + xl[i].second;
    } else {
      if (k > xl[i].first + xl[i].second) {
        k = xl[i].first + xl[i].second;
      }
      ans--;
    }
  }

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


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] n = in.nextString().toCharArray();
			if (n[0] == n[2]) {
				out.println("Yes");
			} else {
				out.println("No");
			}

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 21460
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
struct Node{
	int y,next;
}a[100010];int len=0,last[100010];
int dis[100010][3];
struct node{
	int x,c;
	node() {}
	node(int A,int B) {x=A;c=B;}
};
queue<node> q;
void ins(int x,int y)
{
	a[++len].y=y;
	a[len].next=last[x];last[x]=len;
}
int n,m,st,ed;
int main()
{
	memset(dis,63,sizeof(dis));
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;scanf("%d %d",&x,&y);
		ins(x,y);
	}
	scanf("%d %d",&st,&ed);
	dis[st][0]=0;q.push(node(st,0));
	while(!q.empty())
	{
		node t=q.front();q.pop();
		int x=t.x,c=t.c,d=dis[x][c];
		for(int i=last[x];i;i=a[i].next)
		{
			int y=a[i].y,t=(c+1)%3;
			if(dis[y][t]>d+1)
			{
				dis[y][t]=d+1;
				q.push(node(y,t));
			}
		}
	}
	if(dis[ed][0]<1e8) printf("%d",dis[ed][0]/3);
	else printf("-1");
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define inf 1<<31

#define MX 100100

bool mark[MX+4];
int prime[10000];
int nprime=0;

void sive()
{
    int n = MX;
    int limit = sqrt(n*1.0)+2;
    mark[0]=true;  mark[1]=true;
    for(int i=4;i<=n;i+=2) mark[i]=true;
    prime[nprime++]=2;
    for(int i=3;i<=n;i+=2)
    {
        if(!mark[i])
        {
            prime[nprime++]=i;
            if(i<=limit)
                for(int j=i*i;j<=n;j+=i*2) mark[j]=true;
        }
    }
}

int ans[MX];

int main()
{
    //freopen("input.txt","r",stdin);

    sive();
   // cout<<nprime<<endl;

    for(int i=0;i<nprime;i++)
    {
        int p = prime[i];
        int y =(p+1)/2;
        if(!mark[y])ans[p]=1;

        //cout<<p<<" "<<y<<" "<<mark[y]<<endl;
    }

    for(int i=1;i<MX;i++)
    {
        ans[i]+=ans[i-1];
    }

    int t;
    cin>>t;
    while(t--)
    {
        int l,r;
        cin>>l>>r;

        if(r<l)swap(r,l);

        int sl = ans[r]-ans[l-1];
        cout<<sl<<endl;
    }






    return 0;
}




Measured memory_bytes: 1152
import Control.Monad (replicateM)

main :: IO ()
main = do
    getLine
    [vs,cs] <- replicateM 2 getInts
    print $ solve vs cs

getInts :: IO [Int]
getInts = map read . words <$> getLine

solve :: [Int] -> [Int] -> Int
solve = sum .: filter (0<) .: zipWith (-)

infixr 9 .:
(.:) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
(f .: g) x y = f (g x y)


Measured memory_bytes: 636
import java.util.*;
public class Main{

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int k = Integer.parseInt(scan.next());
		String s = scan.next();
		if(s.length() <= k){
			System.out.print(s);
		}else{
			for(int i = 0;i < k; ++i){
				System.out.print(s.charAt(i));
			}
			System.out.print("...");
		}
	}
}



Measured memory_bytes: 35684
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int main(){
	ll a,b,c,d,N;
	cin>>a>>b>>c>>d>>N;
	chmin(b,a*2);
	chmin(c,b*2);
	chmin(d,c*2);
	cout<<(N/2)*d + (N%2)*c<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<cstdlib>

using namespace std;

char s[10010];
const char *p;

int rec() {
    priority_queue<int, vector<int>, greater<int> > pq;

    bool flag = true;

    while(*(++p) != ']') {
        if(*p == '[') pq.push(rec());
        else if(flag) {
            pq.push(atoi(p)/2+1);
            flag = false;
        }
    }
    
    int t = pq.size()/2+1, res=0;
    for(int i=0; i<t; i++) {
        res += pq.top();
        pq.pop();
    }
    return res;
}

int main(void) {
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++) {
        scanf("%s",s);
        p = s;
        printf("%d\n", rec());

    }
    return 0;
}

Measured memory_bytes: 1092
#include <bits/stdc++.h>
using namespace std;
int n,r;
double d,x,y;
int main()
{ cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin>>n>>d;
  for(int i=1;i<=n;i++)
  { cin>>x>>y;
    if(sqrt(x*x+y*y)<=d)
       r++;
  }
  cout<<r<<'\n';
  return 0;
}


Measured memory_bytes: 3856
package main

import (
	"fmt"
	"os"
)

func main() {
	var k, a, b int
	fmt.Scanf("%d", &k)
	fmt.Scanf("%d %d", &a, &b)

	for i := a; i <= b; i++ {
		if i%k == 0 {
			fmt.Println("OK")
			os.Exit(0)
		}
	}
	fmt.Println("NG")
}

Measured memory_bytes: 1820
from collections import deque
n, m = map(int, input().split())
x = deque(sorted(list(map(int, input().split()))))
popleft = x.popleft
work = [0 for i in range(m-1)]
for i in range(m-1):
    temp = popleft()
    work[i] = x[0] - temp
work.sort(reverse=True)
print(sum(work[n-1:]))


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

int N;
int Y;

void input() {
    cin >> N;
    cin >> Y;
}

int main() {
    input();
    int n1000 = 0;
    int n5000 = 0;
    int n10000 = 0;
    int diff = 0;

    // 一番少ない枚数で算出
    n10000 = Y / 10000;
    n5000 = (Y - n10000 * 10000) / 5000;
    n1000 = (Y - n10000 * 10000 - n5000 * 5000) / 1000;
    
    if((n10000 + n5000 + n1000) == N){
        // 何もしない
    } else if ((n10000 + n5000 + n1000) > N){
        n10000 = -1;
        n5000 = -1;
        n1000 = -1;
    } else{
        diff = N - (n10000 + n5000 + n1000);

        while(1){
            // 最優先 5000 -> 1000 * 5
            if (n5000 > 0 && diff >= 4){
                n5000--;
                n1000 += 5;
            } else if (n10000 > 0 && diff >= 1){
                n10000--;
                n5000 += 2;
            } else{
                n10000 = -1;
                n5000 = -1;
                n1000 = -1;
                break;
            }
                        
            diff = N - (n10000 + n5000 + n1000);
            if (diff == 0 || diff < 0){
                break;
            }
        }
    }

    cout << n10000 << " " << n5000 << " " << n1000 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmpArray = br.readLine().split(" ");
		int a = Integer.parseInt(tmpArray[0]);
		int b = Integer.parseInt(tmpArray[1]);
		int c = Integer.parseInt(tmpArray[2]);
		if(a < b && b < c){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 24172
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000000
#define mod 1000000007
int H,W;
int hw[50][50];
void dfs(int x,int y){
	hw[x][y]=0;
	for(int dx=-1;dx<=1;dx++){
		for(int dy=-1;dy<=1;dy++){
			int nx=x+dx,ny=y+dy;
			if(0<=nx && nx<H && 0<=ny && ny<W && hw[nx][ny]==1) dfs(nx,ny);
		}
	}
	return;
}

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

	st:
	int ans=0;
	cin>>W>>H;
	if(H==0 && W==0) return 0;
	REP(i,H){
		REP(j,W){
			cin>>hw[i][j];
		}
	}
	REP(i,H){
		REP(j,W){
			if(hw[i][j]==1){
				ans++;
				//cout<<i<<" "<<j<<endl;
				dfs(i,j);
			}
		}
	}
	
	cout<<ans<<endl;
	goto st;
		
	return 0;
}


Measured memory_bytes: 3372
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <map>

int main(void) {
	int n, h, w;

	std::cin >> n >> h >> w;

	int count = 0;

	for (size_t i = 0; i < n; i++) {
		int a, b;
		std::cin >> a >> b;
		if (a >= h && b >= w) {
			count++;
		}
	}

	std::cout << count << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<math.h>
#include <cstdio>
#include<iomanip>
#include <stdio.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,m,n) for(int i=m;i<(int)(n);i++)
const int inf = 10e9 + 7;
using namespace std;
int a[100005];
signed main() {
	int n, m;
	cin >> n >> m;
	rep(i, m)cin >> a[i];
	sort(a, a + m);
	rep(i,m- 1) {
		a[i] = a[i + 1] - a[i];
	}
	sort(a, a + m - 1);
	int ans = 0;
	rep(i,(m-n)) {
		ans += a[i];
	}
	if (m<=n)cout << 0 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	LLONG A, B, C;
	get(A, B, C);

	int sa = A % 2;
	int sb = B % 2;
	int sc = C % 2;
	LLONG ans = 0;
	if (sa && sb && sc) {
		ans = std::min({ A * B, B * C, C * A });
	}
	printf("%lld\n", ans);
}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;
#define MAXN 202020
using namespace std;



int n;
vector<vi> t(2 , vi(2 * MAXN , INF));


void build(int par){
    for(int i = n - 1 ; i > 0 ; --i){
        t[par][i] = min(t[par][2 * i] , t[par][2 * i + 1]);
    }
}
 
void modify(int par , int p , int val){
    for(t[par][p += n] = val ; p > 1 ; p /= 2){
        t[par][p / 2] = min(t[par][p] , t[par][p ^ 1]);
    }
}
 
int query(int par , int l , int r){//[l , r)
    int res = INF;
    for(l += n , r += n ; l < r ; l /= 2 , r /= 2){
        if(l % 2){
            res = min(res, t[par][l]);
            ++l;
        }
        if(r % 2){
            --r;
            res = min(res , t[par][r]);
        }
    }
    return res;
}

int last = 0;
map<int , pii> code;
map<pii , int> rcode;
vi pos;

vi g[MAXN / 2];

void solve(vi & p , int l , int r , int prev = -1){
	if(r - l < 1)return;
	if(r >= sz(p) || l < 0)return;
	if(r - l == 1){
		code[last] = {p[l] , p[r]};
		rcode[{p[l] , p[r]}] = last;
		
		if(prev != -1){
			g[prev].pb(last);
		}
		prev = last;
		++last;
	}else{
		pii o = {0 , 0};
		
		int par = l % 2;
		o.fi = query(par , l , r + 1);
		
		int pos1 = pos[o.fi];
		o.se = query((pos1 + 1) % 2 , pos1 + 1 , r + 1);
		
		code[last] = o;
		rcode[o] = last;
		
		if(prev != -1){
			g[prev].pb(last);
		}
		prev = last;
		++last;
		

		int pos2 = pos[o.se];
		
	//	modify(pos1 % 2 , pos1 , INF);
	//	modify(pos2 % 2 , pos2 , INF);

		solve(p , pos1 + 1 , pos2 - 1 , prev);
		solve(p , l , pos1 - 1 , prev);
		solve(p , pos2 + 1 , r  , prev);
		
	}
}

vi restore(){
	vi res;
	priority_queue<pii , vector<pii> , greater<pii>> q; 
	q.push(code[0]);
	
	while(!q.empty()){
		pii u = q.top();
		q.pop();
		
		res.pb(u.fi);
		res.pb(u.se);
		
		for(int c : g[rcode[u]]){
			q.push(code[c]);
		}
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 


	cin >> n;
	
	pos.resize(n + 1);
	
	vi p(n);
	rep(i , n){
		cin >> p[i];
		pos[p[i]] = i;
		
		int par = i % 2;
		
		t[par][n + i] = p[i];
		t[par ^ 1][n + i] = INF;
	}

	
	build(0);
	build(1);
	
	solve(p , 0 , n - 1);
	
	for(int e : restore()){
		cout << e << " ";
	}
	
	return 0;
}

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    if(s == "a")
    {
        cout << "vowel" <<endl;
    }
    else if(s == "e")
    {
        cout << "vowel" <<endl;
    }
    else if(s == "i")
    {
        cout << "vowel" <<endl;
    }
    else if(s == "o")
    {
        cout << "vowel" <<endl;
    }
    else if(s == "u")
    {
        cout << "vowel" <<endl;
    }
    else
    {
        cout << "consonant" <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n,m,a[3];
bool edge[50][50];
int dist[50];
vector<int>d[50][101];
main()
{
	cin>>n>>m;
	for(int i=0;i<3;i++)cin>>a[i];
	for(int i=0;i<m;i++)
	{
		int u,v;cin>>u>>v;
		u--,v--;
		edge[u][v]=1;
	}
	for(int i=0;i<n;i++)dist[i]=1e9,d[i][0].push_back(i);
	dist[n-1]=0;
	for(int i=0;i<100;i++)for(int j=0;j<n;j++)
	{
		for(int k=0;k<n;k++)if(edge[j][k])for(int l=0;l<d[k][i].size();l++)
			d[j][i+1].push_back(d[k][i][l]);
		sort(d[j][i+1].begin(),d[j][i+1].end());
		d[j][i+1].erase(unique(d[j][i+1].begin(),d[j][i+1].end()),d[j][i+1].end());
	}
	for(;;)
	{
		bool flag=0;
		for(int i=0;i<n;i++)
		{
			int ans=0;
			for(int j=0;j<3;j++)
			{
				int now=1e9;
				for(int k=0;k<d[i][a[j]].size();k++)
				{
					now=min(now,dist[d[i][a[j]][k]]+1);
				}
				ans=max(ans,now);
			}
			if(dist[i]>ans)
			{
				dist[i]=ans;
				flag=1;
			}
		}
		if(!flag)break;
	}
	if(dist[0]<1e9)cout<<dist[0]<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
}


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

using namespace std;

#define int long long
#define sz(x) (int)x.size()
#define yes cout << "Yes\n"
#define  no cout << "No\n"
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ft first
#define sd second
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<int> vi;
typedef vector<bool> vb;
mt19937_64 rnd(time(0));

void start() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(10);
    // cerr << fixed << setprecision(10);
#ifdef MY
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}

signed main() {
    start();
    int n, k;
    cin >> n >> k;
    vi a(n), d(n, 1e18);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    d[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i - 1; j >= i - k; --j) {
            if (j < 0)
                break;
            d[i] = min(d[i], d[j] + abs(a[i] - a[j]));
        }
    }
    cout << d[n - 1];


}


Measured memory_bytes: 4756
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  int n;cin>>n;
  if(n%2==0)cout<<n<<endl;
  else cout<<n*2<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n, W;
ll weight[100005];
ll value[100005];
ll dp[101][100005];
ll ans(ll index,ll v){
    if(v == 0 ){
        return 0;
    }
    if(index > n){
        return 1e10;
    }
    if(dp[index][v] != -1){
        return dp[index][v];
    }
    ll left = 1e10;
    if(v - value[index] >= 0){
        left = weight[index] + ans(index+1,v-value[index]);
    }
    ll right = ans(index+1,v);
    return dp[index][v] = min(left,right);
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>W;
    ll total = 0;
    memset(dp,-1,sizeof(dp));
    for(ll i=1;i<=n;i++){
        cin>>weight[i]>>value[i];
        total += value[i];
    }
    for(ll i=total;i>=0;i--){
        ll k = ans(1,i);
        if(k <= W){
            cout<<i<<"\n";
            break;
        }
    }
}


Measured memory_bytes: 80256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

const ll MOD = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

ostream& operator << (ostream& os, const mint a) {
    os << a.x;

    return os;
}

const int NMAX = int(1e7);

struct Comb {
    vector<ll> fact, finv, inv;

    Comb(int nmax): fact(nmax + 1), finv(nmax + 1), inv(nmax + 1) {
        REP(i, 2) {
            fact[i] = 1;
            finv[i] = 1;
            inv[i] = 1;
        }

        FOR(i, 2, nmax + 1) {
            fact[i] = fact[i-1] * i % MOD;
            inv[i] = MOD - MOD / i * inv[MOD % i] % MOD;
            finv[i] = finv[i-1] * inv[i] % MOD;
        }
    }

    mint operator()(int n, int k) {
        if (n < k || n < 0 || k < 0) return 0;

        return mint(fact[n]) * finv[k] * finv[n-k];
    }

    mint perm(int n, int k) {
        if (n < k || n < 0 || k < 0) return 0;

        return mint(fact[n]) * finv[n-k];
    }

} comb(NMAX);

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll n, k;
    cin >> n >> k;

    FOR(i, 1, k + 1) print(comb(k - 1, i - 1) * comb(n - k + 1, i));
    
}


Measured memory_bytes: 237452