akhauriyash/Code-Regression huggingface dataset:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    l = 1
    r = n
    while r > l+1:
        m = (l+r) >> 1
        if m*(m+1) >> 1 <= n:
            l = m
        else:
            r = m
    if l*(l+1) >> 1 < n:
        print("No")
        return
    print("Yes")
    f = [[1]]
    for i in range(l-1):
        a = f[-1][-1]+1
        f += [list(range(a,a+i+2))]
    k = l+1
    ans = [[i[-1] for i in f]]
    for i in range(l):
        p = f[i][:i]
        p += [f[j][i] for j in range(i,l)]
        ans += [p]
    print(k)
    for i in ans:
        print(len(i),*i)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 47452
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9

int main(){
    int k,t;
    cin>>k>>t;
    
    int a[t];

    for(int i=0;i<t;i++){
        cin>>a[i];
    }
    
    sort(a,a+t);

    
    cout<<max(0,a[t-1]-(k-a[t-1])-1)<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
    int i,j;
    int n, k;
    cin>>n>>k;
    vi v(n);
    rep(i,n) cin >> v[i];
    int t;
    rep(i,n) if(v[i] == 1)t=i;
    int ans = INF;
    rep(i,k){
        int tmp=1;
        int a = t-i;
        int b = t+(k-i-1);
        while(a>0){
            tmp++;
            a-=k-1;
        }
        while(b<n-1){
            tmp++;
            b+=k-1;
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


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

int main(){
    int x,y,z; cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  int ans=a.at(N-1)-a.at(0);
  cout << ans << endl;
}

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

int main(){
	int N,K;
	cin>>N>>K;
	int ans =0;
	while (true){
		if (N<K){
			ans+=1;
			break;
		}
		N/=K;
		ans+=1;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    long s = 0;
    for(int i = 1; i < N; i++){
      s += i;
    }
    System.out.println(s);
  }
}

Measured memory_bytes: 22996
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::Chars;
use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
use std::cmp::*;
//use std::num;

fn main() {
    input! {
        n:usize,x:Usize1,y:Usize1

    }
    let mut e = vec![0; n];
    //println!("{},{}", x, y);
    for i in 0..n - 1 {
        for j in i + 1..n {
            // println!("{},{}", i, j);
            if j <= x || y <= i {
                //     println!("a");
                e[j - i] += 1;
                continue;
            }
            if i <= x && y <= j {
                //  println!("b");
                e[x - i + j - y + 1] += 1;
                continue;
            }
            if i <= x && j < y {
                //    println!("c");
                e[x - i + min(j - x, y - j + 1)] += 1;
                continue;
            }
            if x < i && y <= j {
                //   println!("d");
                e[j - y + min(i - x + 1, y - i)] += 1;
                continue;
            }
            if x < i && j < y {
                //  println!("e");
                e[min(j - i, i - x + y - j + 1)] += 1;
            }
            // println!("f");
        }
    }
    for i in 0..n {
        //   println! {"{:?}", d[i]}
    }
    for i in e.iter().skip(1) {
        println!("{}", i);
    }
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
typedef unsigned long long ull;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	ll f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=350+10,inf=0x3f3f3f3f,mod=1e9+7;
int n;
ll K;
struct Hash_Table{
	static const int mod1=1e6+7;
	int Begin[mod1],Next[maxn*100],e;
	ull to1[maxn*100],to2[maxn*100];
	ull Pw1[maxn],Pw2[maxn];
	vector<pair<ll,ll> > vc[maxn*100];
	void init(){
		memset(Begin,0,sizeof(Begin));
		e=0;
		Pw1[0]=Pw2[0]=1;
		REP(i,1,n) Pw1[i]=Pw1[i-1]*11ull,Pw2[i]=Pw2[i-1]*29ull;
	}
	void insert(ll *a,ll l,ll r){
		ull x=0,y=0;
		REP(i,1,n) x=x*Pw1[1]+a[i],y=y*Pw2[1]+a[i];
		int i=0;
		for(i=Begin[x%mod1];i;i=Next[i])
			if(to1[i]==x && to2[i]==y){
//				cout<<x<<' '<<y<<' '<<to1[i]<<' '<<to2[i]<<endl;
				break;
			}
		if(!i){
			to1[++e]=x;to2[e]=y;
			Next[e]=Begin[x%mod1];
			Begin[x%mod1]=e;
			i=e;
		}
//		cout<<x<<' '<<y<<endl;
//		cout<<i<<' '<<l<<' '<<r<<endl;
		vc[i].push_back(make_pair(l,r));
	}
	int findans(){
		int ans=0;
		for(int l=0;l<mod1;++l)
			for(int i=Begin[l];i;i=Next[i]){
				ll L=0,R=-1;
				sort(vc[i].begin(),vc[i].end());
				REP(j,0,vc[i].size()-1)
					if(vc[i][j].first>R){
						ans=(ans+(R-L+1)%mod)%mod;
						L=vc[i][j].first,R=vc[i][j].second;
//						cout<<ans<<endl;
//						cout<<vc[i][j].first<<' '<<vc[i][j].second<<endl;
//						cout<<L<<' '<<R<<endl;
					}
					else R=max(R,vc[i][j].second);
//				cout<<L<<' '<<R<<endl;
				ans=(ans+(R-L+1)%mod)%mod;
//						cout<<ans<<endl;
				vc[i].clear();
			}
		return ans;
	}
}Hash;
ll a[maxn];
struct point{
	ll b,c;
	bool operator <(const point &rhs) const{
		return c<rhs.c;
	}
}tmp[maxn];
int Minnum(ll x,ll y){
	if(x>y) return inf;
	int num=0;
	DREP(i,59,0){
		if((x&(1ll<<i))!=(y&(1ll<<i))){
			if(x&((1ll<<i)-1)) num++;
			break;
		}
		else num+=(x>>i)&1;
	}
	return num;
}
ll r[maxn];
void add(int p,ll res){
	if(res<0) return; 
	ll Min=tmp[1].b-(1<p);
	REP(i,1,n){
		r[i]=tmp[i].b-(i<p);
		Min=min(Min,r[i]);
	}
	if(Min<0) return;
	REP(i,1,n) r[i]-=Min;
	sort(r+1,r+n+1);
//	REP(i,1,n) printf("%lld%c",r[i],i==iend?'\n':' ');
//	cout<<Min<<' '<<res<<endl;
//	cout<<Min<<' '<<res<<endl;
	Hash.insert(r,max(Min-res,0ll),Min);
}
int main(){
	int T=1;
	while(T--){
		n=read(),K=readll();
		Hash.init();
		REP(i,1,n) a[i]=readll();
		REP(k,0,60){
			REP(i,1,n)
				tmp[i]=(point){a[i]>>k,a[i]&((1ll<<k)-1)};
			sort(tmp+1,tmp+n+1);
			ll l=0;
			for(int i=1,nxt;i<=n;l=tmp[i].c+1,i=nxt+1){
				nxt=i;
				while(nxt<n && tmp[nxt+1].c==tmp[i].c) ++nxt;
				add(i,K-Minnum(l,tmp[i].c)-k);
			}
		}
		printf("%d\n",Hash.findans());
	}
	return 0;
}

Measured memory_bytes: 5632
# E

# keta
query = 10**9

print('? '+str(query))
res = input()
# res = sunuke(query)

if res == 'Y':
    # N = 10**p
    query *= 2
    # str(query) > str(N)
    for i in range(10):
        query = query // 10
        if query == 0:
            break
        print('? '+str(query))
        res = input()
        # res = sunuke(query)
        
        if res == 'N':
            break
    if query > 0:
        print('! '+str(query*5))
    else:
        print('! 1')
            
else:
    for i in range(9):
        query = query // 10
        
        print('? '+str(query))
        res = input()
        # res = sunuke(query)
        
        if res == 'Y':
            break
    # binary search
    # always query > N
    # query < N < query*10
    # binary search
    # 'N' means query < N
    min_N = query
    max_N = query*10 - 1
    cnt = 0
    
    while cnt < 100:
        query = (min_N + max_N) // 2
        if min_N + 1 >= max_N:
            print("! "+str(max_N))
            break
        
        print('? '+str(query*10))
        res = input()
        # res = sunuke(query)
        cnt += 1
        if res == 'N':
            min_N = query
        else:
            max_N = query

Measured memory_bytes: 3404
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b := nextInt(), nextInt()
	ans := b
	if 6 <= a && a <= 12 {
		ans = b / 2
	} else if a < 6 {
		ans = 0
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>

using namespace std;

int main() {
	int N, K, d; //すぬけ君N人、お菓子K種類、お菓子iを持ってる人数ｄ人
	int x;
	int count = 0;

	cin >> N >> K;	
	vector<bool> S(N, false);

	for (int i = 0; i < K; i++) {
		cin >> d;
		for (int j = 0; j < d; j++) {
			cin >> x;
			S.at(x-1) = true;
		}
	}

	for (int i = 0; i < N; i++) {
		if (!S[i])
			count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int dp[509][509];
int C[509][509];
int recurr(int i,int j){
  if(dp[i][j]!=-1) return dp[i][j];
  if(i==j) {dp[i][j]=C[i][j]; return dp[i][j];}
  // number of line segements b/w i & j = line segement from i to j and line segments b/w i to j-1
  // and line segments b/w i+1 to j - line segments included in both(i to j-1, i+1 to j) range i.e i+1 to j-1
  dp[i][j]=C[i][j]+recurr(i,j-1)+recurr(i+1,j)-recurr(i+1,j-1);
  return dp[i][j];
}
void  solve(){
  int n,m,Q,l,r;
  cin>>n>>m>>Q;
  rep(i,0,m){
    cin>>l>>r;
    C[l][r]++;
  }
  rep(i,1,n+1) rep(j,1,n+1) dp[i][j]=-1;

  recurr(1,n);

  rep(i,0,Q){
    cin>>l>>r;
    cout<<dp[l][r]<<endl;
  }
}
void solve1(){
  int n,m,Q,p,q,l,r;
  cin>>n>>m>>Q;
  vector<vector<int>> dp(n+1,vector<int>(n+1,0));
  rep(i,0,m){
    cin>>l>>r;
    dp[l][r]++;
  }
  rep(i,1,n+1) rep(j,1,n+1)dp[i][j]+=dp[i][j-1];
  rep(i,1,n+1) rep(j,1,n+1)dp[i][j]+=dp[i-1][j];
  rep(i,0,Q){
    cin>>p>>q;
    cout<<dp[q][q]+dp[p-1][p-1]-dp[p-1][q]-dp[q][p-1]<<endl;
  }
}
int main(){
    optimizeIO();
    solve();
    // solve1();
}


Measured memory_bytes: 5676
my ($n, $a, $b) = map {$_-0}split / /, <STDIN>;

my $s = 0;
for(my $i = 1; $i <= $n; $i++) {
    my $all = 0;
    for(my $p = 1; $i > $p / 10; $p *= 10){
        $all += int($i % ($p * 10) / $p);
    }
    next if $all < $a or $all > $b;
    $s += $i;
}
print $s;

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

const int m=200000;

int main(){
  int n;
  cin >> n;
  vi x(n),y(n);
  vector<char> s(n);
  int crush=m*100;
  vector<vector<pair<int,char>>> a(m+1),b(m+1),c(2*m+1),d(2*m+1);
  rep(i,n){
    int p,q;
    char r;
    cin >> p >> q>> r;
    if(r=='U' or r=='D'){
      a[p].push_back(make_pair(q,r));
    }else{
      b[q].push_back(make_pair(p,r));
    }
    c[p+q].push_back(make_pair(p-q,r));
    d[m-p+q].push_back(make_pair(p+q,r));
  }
  rep(i,m+1){
    sort(a[i].begin(),a[i].end());
    int last=-2*m;
    for(auto j : a[i]){
      if(j.second=='U') last=max(last,j.first);
      if(j.second=='D'){
        if(last!=-2*m){
          crush=min((j.first-last)*5,crush);
        }
      }
    }
  }
  rep(i,m+1){
    sort(b[i].begin(),b[i].end());
    int last=-2*m;
    for(auto j : b[i]){
      if(j.second=='R') last=max(last,j.first);
      if(j.second=='L'){
        if(last!=-2*m){
          crush=min((j.first-last)*5,crush);
        }
      }
    }
  }
  rep(i,2*m+1){
    sort(c[i].begin(),c[i].end());
    int last1=-2*m;
    int last2=-2*m;
    for(auto j : c[i]){
      //cout << i <<  j.first << j.second << "\n";
      if(j.second=='R') last1=max(last1,j.first);
      if(j.second=='U'){
        if(last1!=-2*m){
          crush=min((j.first-last1)*5,crush);
        }
      }
      if(j.second=='D') last2=max(last2,j.first);
      if(j.second=='L'){
        if(last2!=-2*m){
          crush=min((j.first-last2)*5,crush);
        }
      }
    }
  }
  rep(i,2*m+1){
    sort(d[i].begin(),d[i].end());
    int last1=-2*m;
    int last2=-2*m;
    for(auto j : d[i]){
      //cout << i <<  j.first << j.second << "\n";
      if(j.second=='R') last1=max(last1,j.first);
      if(j.second=='D'){
        if(last1!=-2*m){
          crush=min((j.first-last1)*5,crush);
        }
      }
      if(j.second=='U') last2=max(last2,j.first);
      if(j.second=='L'){
        if(last2!=-2*m){
          crush=min((j.first-last2)*5,crush);
        }
      }
    }
  }  
  if(crush==m*100) cout << "SAFE";
  else cout << crush;
  return 0;
}

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

using i64 = long long;
using P   = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

const long long mod = 1000000007;

void solve(long long N, std::vector<long long> A) {
    i64 sum          = 0;
    rep(i, 1, N) sum = (sum + A[i]) % mod;
    i64 ans          = 0;
    rep(i, N - 1) {
        ans = (ans + sum * A[i] % mod) % mod;
        sum = (sum + mod - A[i + 1]) % mod;
    }
    cout << ans << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for(int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4848
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

void fin(){
	freopen("test.txt", "r", stdin);
}

int main(){
	int n;
	while(cin >> n, n){
		vector<P> v;
		rep(i, n){
			int w, lim;
			cin >> w >> lim;
			v.push_back(MP(lim, w));
		}
		sort(all(v));
		int sum = 0;
		bool ok = true;
		rep(i, v.size()){
			sum += v[i].second;
			if(sum > v[i].first){
				ok = false;
				break;
			}
		}
		cout << (ok?"Yes":"No") << endl;
	}

	return 0;
}

Measured memory_bytes: 1192
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    
    public static void nibutan(int array[], int length, int num){
        int pos = -1;
        int lower = 0; //最小index番号
        int upper = length - 1; // 最大index番号
        
        while (lower <= upper) {
            int mid = (lower + upper) / 2;
            
            if (array[mid] >= num) {
                upper = mid;
            } else if (array[mid] < num) {
                lower = mid;
            }
            
            if(upper - lower == 1){
                if(array[lower] < num && array[upper] >= num){
                    pos = upper;
                }else if(array[lower] >= num){
                    pos = 0;
                }else{
                    pos = length;
                }
                break;
            }
            
            if(upper == lower){
                if(array[0] < num){
                    pos = length;
                }else{
                    pos = 0;
                }
                break;
            }
        }
        
        int pos2 = 0;
        lower = 0; //最小index番号
        upper = length - 1; // 最大index番号
        
        while (lower <= upper) {
            int mid = (lower + upper) / 2;
            
            if (array[mid] > num) {
                upper = mid;
            } else if (array[mid] <= num) {
                lower = mid;
            }
            
            if(upper - lower == 1){
                if(array[lower] <= num && array[upper] > num){
                    pos2 = upper;
                }else if(array[lower] > num){
                    pos2 = 0;
                }else{
                    pos2 = length;
                }
                break;
            }
            
            if(upper == lower){
                if(array[0] <= num){
                    pos2 = length;
                }else{
                    pos2 = 0;
                }
                break;
            }
        }
        
        System.out.println(pos + " " + pos2);
    }
    
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int a[] = new int[n];
        for(int i = 0; i < n; i++){ 
            a[i] = stdIn.nextInt();
        }
        
        int q = stdIn.nextInt();
        
        for(int i = 0; i < q; i++){
            int k = stdIn.nextInt();
            nibutan(a, n, k); //左から配列、配列の長さ、探索する数字
        }
        
        stdIn.close();
    }
}



Measured memory_bytes: 109276
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef gp_hash_table < int, int > fast;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

void test();

int main() {
    fast_io();
    cout << fixed << setprecision(15);
    test();
    return 0;
}

void test() {
    int n;
    cin >> n;
    int p[n];
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    int ans = 0;
    for (int i = 1; i < n - 1; ++i) {
        vi v;
        v.eb(p[i]);
        v.eb(p[i + 1]);
        v.eb(p[i - 1]);
        sort(all(v));
        ans += (v[1] == p[i]);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>
typedef struct{
  int x;
  int y;
}position;

int main(){
  int h=0;
  int w=0;
  int i=0;
  int j=0;
  char str[100][100] = {};
  int kakutei[100][100] = {};
  position stack[30000] = {};
  int sstart = 0;
  int slast = 0;
  int slastf = 0;
  int movef = 0;
  int depth = 0;
  int wcnt = 0;
  
  scanf("%d %d",&h,&w);
  for(i=0;i<h;i++){
    scanf(" %s",str[i]);
  }
  for(i=0;i<h;i++){
    //printf("%s\n",str[i]);
    for(j=0;j<w;j++){
      kakutei[i][j] = -1;
    }
  }
  
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(str[i][j] == '#'){
        wcnt++;
      }
    }
  }
  //printf("***%d***",wcnt);
  kakutei[0][0] = 0;
  depth = 0;
  stack[0].x = 0;
  stack[0].y = 0;
  sstart = 0;
  slastf = -1;
  slast = 0;
  while(kakutei[h-1][w-1] == -1){
    //printf("*");
    depth++;
    sstart = slastf+1;
    slastf = slast;
    movef = 0;
    for(i=sstart;i<=slastf;i++){
      if( stack[i].x+1 < w && str[stack[i].y][stack[i].x+1] == '.' && kakutei[stack[i].y][stack[i].x+1] == -1){
        kakutei[stack[i].y][stack[i].x+1] = depth;
        movef = 1;
        slast++;
        stack[slast].x = stack[i].x+1;
        stack[slast].y = stack[i].y;

      }
      if(stack[i].x-1 >= 0 && str[stack[i].y][stack[i].x-1] == '.' && kakutei[stack[i].y][stack[i].x-1] == -1){
        kakutei[stack[i].y][stack[i].x-1] = depth;
        movef = 1;
        slast++;
        stack[slast].x = stack[i].x-1;
        stack[slast].y = stack[i].y;
        
      }
      if(stack[i].y+1 < h && str[stack[i].y+1][stack[i].x] == '.' && kakutei[stack[i].y+1][stack[i].x] == -1){
        //printf("_");
        kakutei[stack[i].y+1][stack[i].x] = depth;
        movef = 1;
        slast++;
        stack[slast].x = stack[i].x;
        stack[slast].y = stack[i].y+1;
        
      }
      if(stack[i].x+1 >= 0 && str[stack[i].y-1][stack[i].x] == '.' && kakutei[stack[i].y-1][stack[i].x] == -1){
        kakutei[stack[i].y-1][stack[i].x] = depth;
        movef = 1;
        slast++;
        stack[slast].x = stack[i].x;
        stack[slast].y = stack[i].y-1;
        
      }
    }
    if(!movef){
      break;
    }
  }
  /*for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      printf("%d",kakutei[i][j]);
    }
    printf("\n");
  }*/
  
  if(kakutei[h-1][w-1] == -1){
    printf("-1");
  }else{
    printf("%d",(h*w)-(kakutei[h-1][w-1]+1)-wcnt);
  }
  return 0;
}
        
    
  
  

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  int tot = 0;
  rep(i, n) {
    cin >> l[i];
    tot += l[i];
  }
  sort(l.rbegin(), l.rend());
  string ans;
  if (l[0] < tot - l[0])
    ans = "Yes";
  else
    ans = "No";

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


Measured memory_bytes: 256
using System;
using System.Linq;
namespace AGC008A
{
    class Program
    {
        static long Calc(int a, int b)
        {
            if (a > b)
                return 11451419194545810;
            return b - a;
        }
        static void Main()
        {
            string[] s = Console.ReadLine().Split(' ');
            int x, y;
            x = int.Parse(s[0]);
            y = int.Parse(s[1]);
            long ans = 11451419194545810;
            ans = Math.Min(ans, Calc(x, y));
            ans = Math.Min(ans, Calc(-x, y) + 1);
            ans = Math.Min(ans, Calc(x, -y) + 1);
            ans = Math.Min(ans, Calc(-x, -y) + 2);
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ACB112A
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            if (N == 1)
            {
                Console.WriteLine("Hello World");
            }
            else if(N==2)
            {
                int A = int.Parse(Console.ReadLine());
                int B = int.Parse(Console.ReadLine());
                int C = A + B;
                Console.WriteLine(C);
            }
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
n = int(input())
l = list(map(int,input().split()))
l1 = [0]
for i in l:
  a = l1.pop()
  if i==a+1:
    l1.append(a)
    l1.append(i)
  else:
    l1.append(a)
if len(l1)==1:
  print(-1)
else:
  print(n-len(l1)+1)

Measured memory_bytes: 26140
N = gets.to_i
a_list = gets.split.map(&:to_i)

ans = Array.new(N) { 0 }
N.downto(1) do |i|
  if i + i > N
    ans[i - 1] = a_list[i - 1]
  else
    sum = 0
    ii = i
    while ii <= N
      sum += ans[ii - 1]
      ii += i
    end
    ans[i - 1] = (a_list[i - 1] - (sum % 2)).abs
  end
end
puts ans.count { |n| n == 1 }
ids = ans.map.with_index { |a, i| [a, i] }.select do |a, i|
  a == 1
end.map { |_, i| i + 1 }
puts ids.join(' ')


Measured memory_bytes: 32268
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

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

  ll x;
  cin >> x;
  ll y = 100;
  ll counter = 0;
  while(y < x) {
    y *=1.01;
    ++counter;
  }
  cout << counter << endl;



}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++) {
		ll l;
		cin >> l;
		a[i] = l;
	}
	sort(ALL(a));
	int tmp = 1;
	int ans= 0;
	for(int i = 1; i < n; i++) {
		if(a[i] == a[i - 1]){
			tmp++;
		}
		else{
			ans += tmp%2;
			tmp = 1;
		}
	}
	ans += tmp%2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
//さっきの問題でミスった時のver

#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

int main(){
  int N,W;
  cin >> N >> W;
  //vectorにpair入れる場合は注意
  vector<pair <int,int> > vw(N,make_pair(0,0));
  vector<int> dp(W+1,0);//価値0~Wまでのdpのvector
  for(int i=0;i<N;i++){cin >> vw[i].first >> vw[i].second;}
  //v調べてdpを評価
  for(int i=0;i<N;i++){
    for(int j=0;j<W+1;j++){
      if((j==0 or dp[j]!=0) and j+vw[i].second<W+1){
        dp[j+vw[i].second]=max(dp[j+vw[i].second],dp[j]+vw[i].first);
      }
    }
  }
  //no matching function for call to 'max'は引数の型などのミス
  //functionの使い方の単純なミス
  //for(int i=0;i<W+1;i++){cout << dp[i] << endl;}
  cout << *(max_element(dp.begin(),dp.end())) << endl;
}



Measured memory_bytes: 3132
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	long long int a,b;
	long long int i,s;
	cin>>a>>b;
	if(a%b)
	{
		cout<<a;
	}
	else
	{
		cout<<"-1";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int count = 0;
		for (int i = 0; i <= A; i++) {
			for (int j = 0; j <= B; j++) {
				for (int k = 0; k <= C; k++) {
					if (((500 * i) + (100 * j) + (50 * k)) == X) {
						count++;
					}
				}
			}
			
		}
		System.out.println(count);
	}	
}

Measured memory_bytes: 23892
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<utility>
#include<numeric>
#include<vector>
#include<unordered_map>
 
using namespace std;
 
int par[41234];
 
template<class E>
int find(E &par,int x){
  return (par[x]==x)?x:par[x]=find(par,par[x]);
}
 
template<class E>
void unite(E &par,int a,int b){
  par[find(par,a)]=find(par,b);
}    
 
int main(){
  int n,k;
  cin>>n>>k;
  int q[41234],u[41234],v[41234];
  for(int i=0;i<k;i++){
    cin>>q[i]>>u[i]>>v[i];
  }
  for(int i=0;i<k;){
    int l=min<int>(k,i+sqrt(k));
    set<pair<int,int> > qs;
    set<int> app;
    for(int j=i;j<l;j++){
      app.insert(u[j]);
      app.insert(v[j]);
      if(q[j]!=3){
	qs.insert(make_pair(u[j],v[j]));
      }
    }
    iota(begin(par),end(par),0);
    set<pair<int,int> > reg;
    vector<pair<int,int> >con;
    for(int j=i-1;j>=0;j--){
      if(q[j]!=3&&reg.insert(make_pair(u[j],v[j])).second&&q[j]==1){
	if(!qs.count(make_pair(u[j],v[j]))){
	  unite(par,u[j],v[j]);
	}else{
	  con.emplace_back(u[j],v[j]);
	}
      }
    }
    int ocpar[41234];
    for(auto e:app){
      ocpar[e]=e;
    }
    for(auto e:app){
      for(auto f:app){
	if(find(par,e)==find(par,f)){
	  unite(ocpar,e,f);
	}
      }
    }
    for(int j=i;j<l;j++){
      if(q[j]==3){
	int cpar[41234];
	for(auto e:app){
	  cpar[e]=ocpar[e];
	}
	set<pair<int,int> > used;
	for(int k=j-1;k>=i;k--){
	  if(q[k]!=3&&used.insert(make_pair(u[k],v[k])).second&&q[k]==1){
	    unite(cpar,u[k],v[k]);
	  }
	}
	for(auto e:con){
	  if(!used.count(e)){
	    unite(cpar,e.first,e.second);
	  }
	}
	cout<<((find(cpar,u[j])==find(cpar,v[j]))?"YES":"NO")<<endl;
      }
    }
    i=l;
  }
}

Measured memory_bytes: 5452
n = int(input())
a_li = [[0]*2 for i in range(n)]
for i in range(n):
    a_li[i][1],a_li[i][0] = map(int,input().split())
a_li.sort()
time = 0
for i in range(n):
    time += a_li[i][1]
    if time > a_li[i][0]:
        print("No")
        exit()
print("Yes")

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

int main(void){
	int A,B;
	int count=0;

	cin >> A >> B;

	for(int i=A;i<=B;i++){
		if(i%10==(i/10000)%10 && (i/1000)%10==(i/10)%10)
			count++;
	}

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


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main()	{

	int n, temp, mean, count, res;
	vector<int> a;

	while (true)	{

		scanf("%d", &n);
		if (n == 0)	break;

		count = 0;

		for (int i = 0; i < n; i++)	{
			cin >> temp;
			a.push_back(temp);
		}

		mean = accumulate(a.begin(), a.end(), 0) / n;
		///
		//printf("mean::%d\n", mean);
		///
		sort(a.begin(), a.end());

		for (int i = 0; i < n; i++)	{
			if (a[i] <= mean)	{
				count++;
			} else	{
				break;
			}
		}

		printf("%d\n", count);

		a.clear();
	}

	return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> t(n), x(n), y(n);

    rep(i, n) {
        cin >> t.at(i) >> x.at(i) >> y.at(i);
    }

    int i, tl=0, xl=0, yl=0;
    for (i = 0; i < n; i++) {
        tl = abs(t.at(i) - tl);
        xl = abs(x.at(i) - xl);
        yl = abs(y.at(i) - yl);
        //cout << tl << xl << yl << endl;

        if (xl + yl > tl) {
            break;
        }
        else if (tl % 2 == 0 && (xl+yl) %2 == 0) {
            continue;
        }
        else if (tl % 2 != 0 && (xl+yl) %2 != 0) {
            continue;
        }
        else
            break;
    }

    if (i == n)
        puts("Yes");
    else
        puts("No");
        //cout << i << endl;
    return 0;
}

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

string A,B;

string check(){

  if(A.size()>B.size())return "GREATER";
  if(A.size()<B.size())return "LESS";
  
  for(int i=0;i<A.size();i++){
    if(A[i]>B[i])return "GREATER";
    if(A[i]<B[i])return "LESS";
  }
  return "EQUAL";
}

int main(){

  cin>>A>>B;
  
  cout<<check()<<endl;
  
  return 0;
}


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

using namespace std;

template <typename T>
using vec1 = vector<T>;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename T>
vec1<T> cin2vec(size_t size)
{
    vec1<T> vec1;
    for (size_t i = 0; i < size; ++i) {
        vec1.push_back(cin2var<T>());
    }
    return vec1;
}

template <typename T>
T ToGrayCode(T num)
{
    return num ^ (num >> 1);
}

using bs24 = bitset<24>;

int FindBit(const bs24& bs)
{
    for (size_t i = 0; i < 24; ++i) {
        if (bs.test(i)) {
            return i;
        }
    }
    return -1;
}

int main()
{
    while (true) {
        const auto N(cin2var<size_t>());
        if (!N) break;
        const auto   Ns(cin2vec<int>(N));
        const size_t count     = 1 << N;
        int          sum_a     = 0;
        int          sum_b     = accumulate(Ns.begin(), Ns.end(), 0);
        int          diff_min  = sum_b;
        size_t       prev_gray = 0;
        for (size_t i = 1; i < count; ++i) {
            const size_t gray = ToGrayCode(i);
            const size_t diff = gray ^ prev_gray;
            const bs24 bs_diff(diff);
            const int  diff_pos = FindBit(bs_diff);
            const auto pow = Ns[diff_pos];
            const bs24 bs_gray(gray);
            if (bs_gray.test(diff_pos)) {
                // move A <- B
                sum_a += pow;
                sum_b -= pow;
            }
            else {
                // move A -> B
                sum_a -= pow;
                sum_b += pow;
            }
            const auto diff_ab = abs(sum_a - sum_b);
            if (diff_min > diff_ab) {
                diff_min = diff_ab;
            }
            prev_gray = gray;
        }
        cout << diff_min << endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, K;
    cin >> N >> K;
    vector<P> items(N);
    rep(i, N) cin >> items[i].first >> items[i].second;
    priority_queue<P, vector<P>, greater<>> arr;
    rep(i, N) {
        arr.push(items[i]);
    }
    ll cnt = 0;
    while (!arr.empty()) {
        P p = arr.top();
        arr.pop();
        cnt += p.second;
        if (cnt >= K) {
            cout << p.first << endl;
            return;
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


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

signed main () {
    string str;
    cin >> str;
    int n = str.size();
    stack < char > st;
    for (int i = 0; i < n; ++i) {
        if (st.empty() || !(st.top() == 'S' && str[i] == 'T'))
            st.push(str[i]);
        else
            st.pop();
    }
    cout << st.size() << '\n';
}


Measured memory_bytes: 644
def main():
    N = int(input())
    S = input()

    s = S
    while s.count('()'):
        s = s.replace('()', '')

    if len(s) == 0:
        print(S)
        return

    left = ''
    right = ''
    if s[0] == ')':
        left = '(' * s.count(')')
    if s[-1] == '(':
        right = ')' * s.count('(')

    print('{}{}{}'.format(left, S, right))

main()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

int main()
{

    char in[120];
    pair<pair<string,int>,int>p[110];
    int a;
    scanf("%d", &a);
    for(int i = 0;i<a;i++)
    {
        int t;
        scanf("%s%d", in, &t);
        //string tmp = in;
        p[i] = make_pair(make_pair(in,-t),i);

    }
    sort(p,p+a);
    for(int i = 0;i<a;i++)
    printf("%d\n", p[i].second+1);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
p =map(int, input().split())
l = list(range(1, (n + 1)))
P = list(p)

if P == l:
  print("YES")
else:
  N = 0
  i = []
  for x in range(n):
    if P[N] == l[N]:
      N += 1
    else:
      N += 1
      i.append(N)
  if len(i) == 2:
    P[i[0] - 1], P[i[1] - 1] = P[i[1] - 1], P[i[0] - 1]
    print("YES" if P == l else "NO")
  else:
    print("NO")

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  if ((a == b) || (b == c) || (c == a)) {
    if (!(a == b && b == c)) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;

int main(){
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    vector<ll> u(M,0);
    vector<ll> v(M,0);
    for(ll i=0;i<M;i++){
        cin>>u[i]>>v[i];
        u[i]--;v[i]--;
    ;}
    vector<vector<ll>> hen(3*N, vector<ll>(0));
    for(ll i=0;i<M;i++){
        hen[u[i]].emplace_back(v[i]+N);
        //hen[v[i]].emplace_back(u[i]+N);
        hen[u[i]+N].emplace_back(v[i]+2*N);
        //hen[v[i]+N].emplace_back(u[i]+2*N);
        hen[u[i]+2*N].emplace_back(v[i]);
        //hen[v[i]+2*N].emplace_back(u[i]);
    ;}  
    
    ll S;
    cin >> S;
    ll T;
    cin >> T;
    S--;T--;

    //Sからの各点までの最短距離
    vector<ll> d(3*N,INF);
    d[S]=0;

    //ダイクストラ
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push(P(0,S));
    while(!pq.empty()){
        P x=pq.top();
        pq.pop();
        ll y=x.first;
        ll z=x.second;
        if(y>d[z]){continue;}
        for(ll i=0;i<hen[z].size();i++){
            ll w=hen[z][i];
            if(d[w]>d[z]+1){
                d[w]=d[z]+1;
                pq.push(P(d[w],w));
            }
        ;}
    }

    if(d[T]==INF){cout<<-1<<endl;return 0;}
    cout<<d[T]/3<<endl;
    

    return 0;
}


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

int main(){
int H,N;
cin >> H >> N;
int count = 0;
for(int i = 0;i < N;i++){
  int A[i];
  cin >> A[i];
  count += A[i];
}
 if(H <= count){
   cout << "Yes" << endl;
 }
 else{
   cout << "No" << endl;
 }
 }

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

int main()
{
    ll n,m,i,j;
    cin>>n>>m;
    if(m%n==0)
    {
        cout<<m/n;
    }
    else
    {
        set<ll> facs;
        facs.insert(1);
        for(i=2;i*i<=m;i++)
        {
            if(m%i==0)
            {
                facs.insert(i);
                if(m/i!=i)
                {
                    facs.insert(m/i);
                }
            }
        }
        for(auto it=facs.rbegin();it!=facs.rend();it++)
        {
            if((*it)*n<=m)
            {
                cout<<*it;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
k = gets.chomp.to_i
x = gets.chomp.split.map(&:to_i)

ans = 0

x.each do |i|
  a = (i - 0).abs * 2
  b = (k - i).abs * 2
  ans += (a < b) ? a : b
end

puts ans


Measured memory_bytes: 1788
#include <iostream>
#include <vector>

using namespace std;

class Solver {
public:
	explicit Solver(int N)
		: N(N)
		, next(N, vector<int>(20, 0))
	{}
	void setup(const vector<int>& x, int L){
		int idx = 0;
		for(int i=0;i<N;i++){
			while(idx+1 <= N-1 && x[idx+1] - x[i] <= L) ++idx;
			next[i][0] = idx;
		}
		for(int d=1;d<20;d++){
			next[N-1][d] = N-1;
			for(int i=N-2;i>=0;i--){
				next[i][d] = next[next[i][d-1]][d-1];
			}
		}
	}
	int query(int a, int b){
		--a; --b;
		if(a > b) swap(a, b);
		int res = 0;
		for(int i=19;i>=0;i--){
			if(next[a][i] < b){
				res += 1 << i;
				a = next[a][i];
			}
		}
		return res + 1;
	}
private:
	const int N;
	vector<vector<int>> next;
};

int main(){
	int N;
	while(cin >> N){
		vector<int> x(N);
		for(int& t: x) cin >> t;
		int L; cin >> L;
		Solver solver(N);
		solver.setup(x, L);
		int Q; cin >> Q;
		for(int i=0;i<Q;i++){
			int a, b; cin >> a >> b;
			cout << solver.query(a, b) << endl;
		}
	}
}


Measured memory_bytes: 12928
//submitted by HimJ
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  int t=1;
  //cin>>t;
    while(t--){
            int n;
            cin>>n;
            cout<<1;
            cout.flush();
            cout<<"\n";
             cout.flush();
        string s;
        cin>>s;
        if(s=="Vacant")
            return 0;
        int check=0;
        if(s=="Male")
            check=1;
        cout<<n-1;
        cout.flush();
        cout<<"\n";
        cout.flush();
        cin>>s;
         if(s=="Vacant")
            return 0;
         if((s=="Male"&&check==0)||(s=="Female"&&check==1))
         {
             cout<<0;
             cout.flush();
             cout<<"\n";
             cout.flush();
             return 0;
         }
        int beg=1,last=n-1,mid;
    while(beg<=last)
    {
        mid=(beg+last)/2;
        cout<<mid;
        cout.flush();
        cout<<"\n";
             cout.flush();
        cin>>s;
        if(s=="Vacant")
            return 0;
        if(s=="Male")
        {
            if((mid%2&&check==1)||(mid%2==0&&check==0))
            beg=mid+1;
            else
                last=mid-1;
        }
        else if(s=="Female")
            {
                if((mid%2&&check==1)||(mid%2==0&&check==0))
            last=mid-1;
            else
                beg=mid+1;
            }
    }

  }
  return 0;
  }



Measured memory_bytes: 852
import java.util.Scanner;
   public class Main {
   public static void main(String[] args) {
     
        //sec--1
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        String S = sc.next();
        //String S = sc.nextLine();
        
        //sec--2
        if(S.length() <= K) {
          System.out.println(S);
        } else if (S.length() > K) {
          //System.out.println(S[K] + "...");
          System.out.println(S.substring(0,K) + "...");
        }
   }
}

Measured memory_bytes: 38556
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX =2000007;
const int MOD = 998244353;
//
int modpow(int a, int n, int mod) {
    int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
     signed main(){
  string s;
  cin>>s;
  for(int i=s.size()/2-1;i>=0;i--){
      bool t=true;
      for(int j=0;j<i;j++){
          if(s[j]!=s[i+j])t=false;
      }
      if(t){
          cout<<i*2<<endl;
          return 0;
      }
  }

     }


 


 






    





      

        


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define MN 200005
#define int long long
#define mp make_pair
#define fir first
#define sec second
#define pii pair<int,int>
inline void chkmax(int &a,int b){if(a<b)a=b;}
inline void chkmin(int &a,int b){if(a>b)a=b;}
inline int read(){
	   int a=0,fh=1;char c=getchar();
	   while(c>'9'||c<'0'){if(c=='-')fh=-1;c=getchar();}
	   while('0'<=c&&c<='9'){
		   a=a*10+c-48;
		   c=getchar();
	   }
	   return a*fh;
}
int n,k,a[MN],b[MN];
bool cmp(int a,int b){return a>b;}
signed main(){
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;++i)scanf("%lld",&a[i]),b[i]=a[i];
	sort(a+1,a+1+n);
	sort(b+1,b+1+n,cmp);
	int l=-1e18-1ll,r=1e18;
	while(l+1<r){
		int mid=(l+r)/2,cnt=0;
		for(int i=1;i<=n;++i)
		if(a[i]>=0){
			int L=1,R=n+1;
			while(L+1<R){
				int M=(L+R)>>1;
				if(a[i]*a[M]<=mid)L=M;
					else R=M;
			}
			if(L>1)cnt+=L;
			else cnt+=(a[i]*a[L]<=mid);
			if(a[i]*a[i]<=mid) cnt--;
		}
		else{
			int L=1,R=n+1;
			while(L+1<R){
				int M=(L+R)>>1;
				if(a[i]*b[M]<=mid)L=M;
					else R=M;
			}
			if(L>1)cnt+=L;
			else cnt+=(a[i]*b[L]<=mid);
			if(a[i]*a[i]<=mid) cnt--;
		}
		cnt>>=1;
		if(cnt>=k)r=mid;
			else l=mid;
	}
	printf("%lld",r);
	return 0;
}


Measured memory_bytes: 3328
while True:
  vv = []
  for i in range(8):
    v = [int(e) for e in list(input())]
    vv.append(v)
  for index in reversed(range(len(vv))):
    t = all(x == 0 for x in vv[index])
    #print(t)
    if t == True:
      vv.pop(index)
  height = len(vv)
  for i in reversed(range(len(vv[0]))):
    aa = [vv[h][i] for h in range(height)]
    aa = all([ a==0 for a in aa ])
    if aa == True:
      for h in range(height): 
        del vv[h][i]
  #  print(aa)
  #print(vv)
  obj = { 'A': [[1, 1], [1, 1]] ,
  'B': [[1], [1], [1], [1]],
  'C': [[1, 1, 1, 1]],
  'D': [[0,1],[1,1],[1,0]] ,
  'E': [[1,1,0],[0,1,1]], 
  'F': [[1,0], [1,1], [0,1]], 
  'G': [[0,1,1], [1,1,0]] } 
  #print(obj)
  for k, v in obj.items():
    if v == vv:
      print(k)
      break
  try:
    input()
  except:
    break


Measured memory_bytes: 5624
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
flag = True
for i in range(n):
    t,x,y = iim()
    if x+y > t or t%2 != (x+y)%2:
        flag = False

print('Yes' if flag else 'No')

Measured memory_bytes: 3064