akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

double C[1010][1010];
double ps[1010], qs[1010];
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  LL x, p; cin >> x >> p;
  cout << fixed << setprecision(9) << ((x+1)/2) * 100. / p << endl;
  return 0;
  /*
  if(p == 100){
	cout << (x+1)/2 << endl;
	return 0;
  }
  if(x > 10) return 1;

  ps[0] = qs[0] = 1.;
  REP(i,1000){
	ps[i+1] = ps[i] * p / 100.;
	qs[i+1] = qs[i] * (100-p) / 100.;
  }
  for(int i=1;i<1000;++i){
	C[i][0] = ps[i];
	C[i][i] = qs[i];
	for(int j=1;j<i;++j)
	  C[i][j] = C[i-1][j] * qs[1] + C[i-1][j-1] * ps[1];
  }

  const int MAX = 10020;
  vector<vector<double>> xs(2, vector<double>(MAX));
  int crt = 0, nxt = 1;
  xs[crt][MAX/2+x] = 1.;

  int px = MAX/2;
  double ans = 0.;
  REP(t,MAX/2-20){
	fill(ALL(xs[nxt]), 0);
	REP(a,MAX){
	  if(a-1 >= 0)
		xs[nxt][a-1] += xs[crt][a] * p / 100.;
	  if(a+1<MAX)
		xs[nxt][a+1] += xs[crt][a] * (100.-p) / 100.;
	}
	swap(crt, nxt);

	if(xs[crt][px] < EPS && xs[crt][px-1] < EPS && xs[crt][px+1] < EPS)
	  ++px;
	else if(xs[crt][px] > xs[crt][px-1] && xs[crt][px] > xs[crt][px+1])
	  ;
	else if(xs[crt][px-1] > xs[crt][px] && xs[crt][px-1] > xs[crt][px+1])
	  --px;
	else if(xs[crt][px+1] > xs[crt][px-1] && xs[crt][px+1] > xs[crt][px])
	  ++px;
	ans += (t+1) * xs[crt][px];
	xs[crt][px] = 0.;
  }

  cout << fixed << setprecision(9) << ans << endl;
  */  
  return 0;
}


Measured memory_bytes: 256
# include<iostream>
 using namespace std;
 
int main()
{
	long long int a,b,c,d,x,y,z,r,s;
	cin>>a>>b>>c>>d;
	if(a%c!=0){
		x=b/c-a/c;
	}
	else{
		x=b/c-a/c+1;
	}
	if(a%d!=0){
		y=b/d-a/d;	
	}
	else{
		y=b/d-a/d+1;
	}
	int min, max;
 	int t;
	max=c>d?c:d;
 	min=c<d?c:d;
	while(max%min!=0)
 	{
  	t=max%min;
  	max=min;
  	min=t;
	}
 	s=c*d/min;
	if(a%s!=0){
		z=b/s-a/s;	
	}
	else{
		z=b/s-a/s+1;
	}
	r=b-a+1-x-y+z;
	cout<<r;
 } 

Measured memory_bytes: 256
open Printf
open Scanf

module L =
  struct
    include List
  
    let init n f =
      let rec loop x =
        if x = n then []
        else let y = f x in y :: loop (x + 1)
      in loop 0

    let rec map2 f xs ys =
      match xs, ys with
        [], _ -> []
      | _, [] -> []
      | x :: xs, y :: ys -> f x y :: map2 f xs ys

    let sum xs =
      fold_left (+) 0 xs

    let maximum xs =
      fold_left max 0 xs
  end

let id x = x

let solve k n =
  let la = L.init n @@ fun _ -> scanf "%d " id in
  let ld = L.map2 (-) (L.tl la) la in
  k - L.maximum ((k - L.sum ld) :: ld)

let () =
  scanf "%d %d " solve |> printf "%d\n"


Measured memory_bytes: 21760
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();
		System.out.print(a/b+" "+a%b+" ");
		double a_=(double)a;
		double b_=(double)b;
		System.out.println(String.format("%.8f",a_/b_));
	}
}



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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

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

    int N;
    cin >> N;

    vvi adj(N);
    vi adjrow(N, 10*N);
    vvi adjmat(N, adjrow);
    for(int i=0;i<N;i++) {
        string row;
        cin >> row;
        for (int j=0;j<N;j++){
            if (row[j] == '1') {
                adj[i].push_back(j);
                adjmat[i][j] = 1;
            }
        }
    }

    vi depths(N, -1);
    depths[0] = 0;
    
    queue<int> bfs;
    bfs.push(0);

    while (!bfs.empty()) {
        int cur = bfs.front();
        bfs.pop();

        for (int nbr : adj[cur]) {
            if (depths[nbr] == -1) {
                depths[nbr] = depths[cur] + 1;
                bfs.push(nbr);
            } else {
                int diff = depths[cur] - depths[nbr];
                if ((diff % 2) == 0) {
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }

    // apsp
    vvi dists(adjmat);
    for (int i=0;i<N;i++) dists[i][i] = 0;

    for (int k=0;k<N;k++) {
        for (int i=0;i<N;i++) {
            for (int j=0;j<N;j++) {
                dists[i][j] = min (dists[i][k] + dists[k][j], dists[i][j]);
            }
        }
    }

    int max_dist = 0;
    for (int i=0;i<N;i++) {
        for (int j=0; j<N; j++) {
            max_dist = max(dists[i][j], max_dist);
        }
    }

    cout << max_dist+1 << endl;

    return 0;
}

Measured memory_bytes: 640
import bisect

def main():
    S = list(input())
    r_idx = [i for i, s in enumerate(S) if s == 'R']
    l_idx = [i for i, s in enumerate(S) if s == 'L']
    ans = [0] * len(S)
    for i, s in enumerate(S):
        if s == 'R':
            idx = bisect.bisect_left(l_idx, i)
            if (l_idx[idx] - i) % 2 == 0:
                ans[l_idx[idx]] += 1
            else:
                ans[l_idx[idx] - 1] += 1
        else:
            idx = bisect.bisect_left(r_idx, i) - 1
            if (i - r_idx[idx]) % 2 == 0:
                ans[r_idx[idx]] += 1
            else:
                ans[r_idx[idx] + 1] += 1
    print(" ".join([str(v) for v in ans]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 87676
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << "\n"; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "tmp.cpp"

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

  int n;
  cin >> n;
  vector<string> s(n);
  REP(i, n) { cin >> s[i]; }

  int ans = 0;

  REP(k, n) {
    bool ok = true;
    REP(i, n) {
      REP(j, n) {
        if (s[(i + k) % n][j] != s[(j + k) % n][i])
          ok = false;
      }
    }
    if (ok)
      ans += n;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
N,K,Q = map(int,input().split())
Answer_List = {}
for i in range(Q):
    CA = int(input())
    if CA in Answer_List:
        Answer_List[CA] += 1 
    else:
        Answer_List[CA] = 1
 
Lose_Status = K - Q
if Lose_Status > 0:
    for j in range(N):
        print("Yes")
else:
    Standard = abs(Lose_Status) + 1
    for j in range(N):
        if j + 1 in Answer_List:
            if Answer_List[j + 1] >= Standard:
                print("Yes")
            else:
                print("No")
        else:
                print("No")
            


Measured memory_bytes: 14240
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define ff first
#define ar array
#define ss second
#define ll long long int
#define mem(x) memset(x,0,sizeof(x))
#define setbits(x)  __builtin_popcount(x)
#define ull unsigned long long int
#define all(c) (c).begin(),(c).end()
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define db double
#define endl "\n"
#define  fbo(x) find_by_order(x)
#define  ook(x) order_of_key(x)
 
using namespace __gnu_pbds;
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair<ll,ll > iil;
typedef pair<ll,int> li;
typedef pair<int,int> ii;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os1;
typedef tree<int, null_type, greater<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os2;

inline void fast()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
const ll pi=31;
const ll MOD[2] = {1187278649, 1149736019};//for double hashing
const ll mod=(ll)(1e9)+7;
ll pmod(ll x,ll n){
  ll r=1;
  while(n>0)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
    n%=mod;
  }
  return r;
}
ll pMod(ll x,ll n,ll mod)
{ ll r=1;
  while(n>0)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
    n%=mod;
  }
  return r;
 
}
 
//think recursively also;

void solve()
{ 
  ll x,k,d;
  cin>>x>>k>>d;
  x=abs(x);
  ll val=x+d*k;
  ll op=2*d;
  ll div=min((x/(2*d))+(k/2),k);
  ll ans=LLONG_MAX;
  //cout<<val<<" "<<op*div;
  //debug2(val,op);
  //debug2(div,k);
  if(div<=k)
  {
    ans=min(ans,abs(val-op*div));
  }
  if(div+1<=k){
    ans=min(ans,abs(val-op*(div+1)));
  }
  cout<<ans;
}
int main()
{
  fast();
   // int t;
   // cin>>t;
   // for(int casee=1;casee<=t;casee++)
  {//cout<<"Case #"<<casee<<": ";
    solve();
  }
 
 
 
}

Measured memory_bytes: 3580
#include<iostream>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
char a[20]={"CODEFESTIVAL2016"},x[500];
int m;
int main()
{
	int sum=strlen(a);
	for(int i=0;i<sum;i++)
	{
		cin>>x[i];
		if(x[i]!=a[i]) m++;
	}
	cout<<m;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define       pb(a)             push_back((a))
#define       mp(a,b)           make_pair((a),(b))
#define       REP(a,b)          for(ll i=(a);i<(b);i++)
#define       REP2(a,b)         for(ll j=(a);j<(b);j++)
#define       REPE(a,b,c,d)     REP(a,b)for(ll j=(c);j<(d);j++)
#define       REPV(a,b,c)       for(ll (a)=b;(a)<(c);(a)++)
#define       IREP(a,b)         for(ll i=(a);i>=(b);i--)
#define       IREP2(a,b)        for(ll j=(a);j>=(b);j--)
#define       IREPV(a,b,c)      for(ll (a)=b;(a)>=(c);(a)--)
#define       all(v)            (v).begin(),(v).end()
#define       Trvs(c)           for (auto it = (c).begin(); it != (c).end(); it++)
#define       INF               INT_MAX
#define       sz(x)             x.size()
#define       flash             ios_base::sync_with_stdio(false);cin.tie(NULL);
#define       F                 first
#define       S                 second
#define       MOD               1000000007
 
using         ll     = long long;
using         vi     = vector<int>;
using         vvi    = vector<vi>;
using         vll    = vector<ll>;
using         vvll   = vector<vll>;
using         vb     = vector<bool>;
using         vd     = vector<double>;
using         vs     = vector<string>;
using         pii    = pair<int, int>;
using         pll    = pair<ll, ll>;
using         pdd    = pair<double, double>;
using         vpii   = vector<pii>;
using         vvpii  = vector<vpii>;
using         vpll   = vector<pll>;
using         vvpll  = vector<vpll>;
using         vpdd   = vector<pdd>;
using         vvpdd  = vector<vpdd>;
 
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

void solve(){
	ll a,b,k;
	cin>>a>>b>>k;
	//cout<<a<<b<<k;
	if(k>=a){
		k-=a;
		cout<<"0 ";
		if(k>=b)cout<<"0";
		else cout<<b-k;
	}
    else
	cout<<a-k<<" "<<b;
}
 
 
int main(){
 
	flash
	/*
    #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("output.txt","w",stderr);
	#endif
 	*/
   
	//ll t;cin>>t;while(t--)
	solve();
 
 
	return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let s : String = read();
    let cs: Vec<char> = s.chars().collect();
    let mut sub = cs.clone();
    sub.sort();
    sub.dedup();
    let ans = if (sub.len() == cs.len()){
        "yes"
    } else {
        "no"
    };
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN=200005;
int N,a[MAXN],s[MAXN],f[MAXN];
LL ans;
int main(){
	scanf("%d",&N);
	for (int i=1;i<=N;i++){
		scanf("%d",&a[i]);
		s[i]=s[i-1]+a[i],f[i]=f[i-1]^a[i];
	}
	for (int i=1,j=1;i<=N;i++){
		while (s[i]-s[j-1]!=(f[i]^f[j-1])) j++;
		ans+=(LL)(i-j+1);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

vector<vector<P>> G;
vl height;
bool ok = true;

void dfs(ll v, ll h) {
    // 行きの処理はこのへんに書く
    if(ok == false) {
        return;
    }
    if(height[v] == -INF) {
        height[v] = h;
    }
    else {
        if(height[v] != h) {
            ok = false;
        }
        return;
    }
    for(auto p : G[v]) { 
        ll u = p.first;
        ll cost = p.second;
        dfs(u, h + cost);
        // 帰りの処理はこのへんに書く
    }
}

int main() {
    ll n, m;
    cin >> n >> m;    
    
    G.resize(n);
    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;  b--;
        G[a].pb(make_pair(b, c));
        G[b].pb(make_pair(a, -c));
    }

    height.assign(n, -INF);
    rep(v, n) {
        if(height[v] == -INF) {
            dfs(v, 0);
        }
    }

    if(ok) {
        out("Yes");
    }
    else {
        out("No");
    }

    re0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;

///#define int long long
#pragma GCC optimize ("O3")
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define maa 1000000007
#define Eps 1e-9
#define PI 3.14159265359

typedef tree<pii,null_type,less <pii>,rb_tree_tag,tree_order_statistics_node_update>ind_set;
///*X.find_by_order("index")
///X.order_of_key("key")

///----------------------------------------------------------------------------------

int n;double arr[3000],DP[3000][3000];

double fun(int ind=0,int hct=0)
{
    if (hct>n/2)return 1;
    if (ind==n)return 0;

    if (DP[ind][hct]!=-1)return DP[ind][hct];

    return DP[ind][hct]=(arr[ind]*fun(ind+1,hct+1)+(1-arr[ind])*fun(ind+1,hct));
}
void solve()
{
	cin>>n;rep(i,0,n)cin>>arr[i];rep(i,0,3000)rep(j,0,3000)DP[i][j]=-1;
    cout<<fixed<<setprecision(15)<<fun();

}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);

///freopen("input.txt","r",stdin);
///freopen("output.txt","w",stdout);

    int t=1;
///cin>>t;
    rep(a,0,t)
    {
        ///cout<<"Case "<<a+1<<": ";
        solve();
    }
}


Measured memory_bytes: 70784
s=input()
k=int(input())
num=[(123-ord(s[i]))%26 for i in range(len(s))]
ans=""
for i in range(len(s)-1):
    if num[i]<=k:
        ans+="a"
        k-=num[i]
    else:
        ans+=s[i]
k%=26
if num[-1]<=k:
    ans+=chr(97+k-num[-1])
else:
    ans+=chr(ord(s[-1])+k)
print(ans)


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

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

  if (a*b % 2 == 0) {
    cout << "Even" << endl;
  }
  if (a*b % 2 == 1) {
    cout << "Odd" << endl;
  }
}

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

using namespace std;

constexpr int N = 1e5 + 10;
constexpr int MOD = 1e9 + 7;

long long n, ans, a[N];
vector <int> v;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        v.push_back (a[i]);
    }
    sort (v.begin(), v.end());
    for (int i = 0; i < n; i += 2) {
        int p = lower_bound (v.begin(), v.end(), a[i]) - v.begin();
        if ((i & 1) != (p & 1))
            ans++;
    }
    cout << ans << '\n';
    return 0;
}


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

#define int long long
#define pii pair<int,int>
#define F first
#define S second

using namespace std;

const int N = 3e3 + 123;

int n, t;

int a[N], b[N], dp[N],can[N], ans;

pii p[N];

main () {
    cin >> n >> t;
    for (int i = 1;i <= n;i ++) {
        cin >> p[i].F >> p[i].S;
    }sort (p + 1, p + n + 1);
    can[0] = 1;
    for (int i = 1;i <= n;i ++) {
        a[i] = p[i].F;
        b[i] = p[i].S;
        for (int j = t - 1;j >= 0;j --) {
            if (can[j]) {
                can[j + a[i]] = 1;
                dp[j + a[i]] = max (dp[j + a[i]], dp[j] + b[i]);
                ans = max (dp[j + a[i]], ans);
            }
        }
    }
    cout << ans;
}


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

int main() {
	int s = 0;
	for (int i = 0; i < 5; i++) {
		int a;
		cin >> a;
		s += (a < 40) ? 40 : a;
	}
	cout << s / 5 << endl;
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,flag=0;
    cin>>n;
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            if(i*j == n){
                flag=1;
                break;
            }
        }
        if(flag==1)break;

    }
    (flag==1)?cout<<"Yes":cout<<"No";
    cout<<endl;
    return 0;
}


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

int main()
{   int n,total;
    scanf("%d%d",&n,&total);
    for (int i=0;i<=n;i++)
    {
        for(int j=0;j<=n-i;j++)
        {
               int t = n-i-j;
                if(10000*i+5000*j+1000*t ==total)
                {
                    printf("%d %d %d\n",i,j,t);
                    return 0;
                }

        }
    }
    printf("-1 -1 -1\n");

    return 0;
}


Measured memory_bytes: 256
/*==============================================*\
ID:          shahidul_brur
 
Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh
 
 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int logn = 20;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    ll k;
    
        cin>>s;
        cin>>k;
        ll n = s.size();
        set<char> st;
        f0(i,n) st.insert(s[i]);
        if(st.size()==1){
            cout << (k*n)/2 << "\n";
            //continue;
            return 0;
        }
        ll last = 0, first = 0;
        ll mid = 0LL;
        f0(i,n)
        {
            int cur = 1;
            int b = i;
            while(i+1<n && s[i+1]==s[i]){
                cur++;
                i++;
            }
            if(i==n-1)
                last = cur;
            else if(b==0)
                first = cur;
            else
                mid+=cur/2;
        }
        ll ans;
        if(s[0]==s[n-1])
            ans = first/2 + last/2 + mid*k + ((first+last)/2)*(k-1);
        else
            ans = (first/2 + last/2 + mid)*k ;
        cout << ans << "\n";
    
    return 0;
}


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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("fibsubseq.in","r",stdin)
#define write()         freopen("fibsubseq.out","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long int
#define endll           pf("\n")
#define pf              printf
#define pi              acos(-1.0)
#define eps             1e-10
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())

bool Check(unsigned int  N,int pos){return (bool)(N & (1LL<<pos));}
ll  Set(unsigned int N,int pos){    return N=N | (1LL<<pos);}
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MX 100005
#define mod  1000000007
#define mod1 1000000009
#define var    int ii,i,j,n,k,m,z=0,c=0,t,x,y,l,r,mid
//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};

ll dp[3005][3008];
string s,a;

ll fn(ll n,ll m)
{
    if(n==0 || m==0)return 0;

    ll &z=dp[n][m];
    if(z!=-1)return z;
    z=0;
    if(s[n-1]==a[m-1])
    {
        z=1+fn(n-1,m-1);
    }
    else
    {
        z=max(fn(n-1,m),fn(n,m-1));
    }
    return z;
}

void print(ll n,ll m,ll c)
{
    if(n==0 || m==0)return ;
    if(s[n-1]==a[m-1] && dp[n][m]==c)
    {
        print(n-1,m-1,c-1);
        cout<<s[n-1];
    }
    else
    {
        if(dp[n-1][m]>=dp[n][m-1])print(n-1,m,c);
        else print(n,m-1,c);
    }
}

int main()
{
    SPEED;
    ll var;
    mem(dp,-1);
    cin>>s>>a;
    n=s.size(),m=a.size();
    c=fn(n,m);
    print(n,m,c);
    //cout<<c<<endl;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> q;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        q.push(a);
    }
    for (int i = 0; i < m; i++) {
        int a = q.top(); q.pop();
        q.push(a/2);
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        ans += q.top(); q.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
/* _________________________________________________________________________________________________
  |                                                                                                 |
  |                             Author      : Aditya Ahuja                                          |
  |                             Date        : Mon,  3rd June 2019                                   |
  |_________________________________________________________________________________________________|
*/
 
#include<bits/stdc++.h>
using namespace std;

#define pb          push_back
#define F           first
#define S           second
#define rep(i,a,b)  for(int i=a; i<b; i++)
#define all(a)      (a).begin(),(a).end()
#define wa(x)       cout << (#x) << " -------- " << (x) << endl
#define line1	    printf("---------------------------\n")

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;

void pvi(auto v){
	for(auto it:v) cout << it << " ";
	cout << endl;
}

void solve();
signed main() {
	//ios_base::sync_with_stdio(false); cin.tie(NULL);
	////cout << fixed << setprecision(10);

	int t=1; 
	//cin>>t;
	while(t--) solve();
	return 0;
}

//___________________________________________________________________________________________________

void solve() {

	int n;
	cin>>n;

	vi a(n,0);
	rep(i,0,n) cin>>a[i];

	vi b(n,0);
	b[0]=0;
	b[1]=abs(a[1]-a[0]);

	rep(i,2,n) b[i] = min(b[i-1] + abs(a[i]-a[i-1]), b[i-2] + abs(a[i]-a[i-2]));
	// pvi(a);
	// pvi(b);

	cout << b[n-1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  in6 n,k;
  cin >> n >> k;
  vi data(n);
  rep(i,n) cin >> data[i];
  sort(all(data));
  in6 ans = 0;
  rep(i,k) ans += data[i];
  cout << ans;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;

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

  string a, b;
  cin >> a >> b;
  if(a < b){
    rep(i, stoi(b)){
      cout << a;
    }
    cout << endl;
  }
  else{
    rep(i, stoi(a)){
      cout << b;
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef _GLIBCXX_DEBUG
int c_;
#define dbg(...) {if(!c_)cerr<<"\033[96;1m";++c_; \
__VA_ARGS__;--c_;if(!c_)cerr<<"\033[0m";}
#else
#define dbg(...)
#endif
#define st first
#define nd second
#define flg() __LINE__, __PRETTY_FUNCTION__
#define mkp(...) make_pair(__VA_ARGS__)
#define prt(...) print(cout, __VA_ARGS__)
#define dprt(...) dbg(print(cerr, __VA_ARGS__))
#define dmp(...) dprt(#__VA_ARGS__, __VA_ARGS__)
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
using namespace std; using ll = long long;
template< typename t > using V = vector< t >;
template< typename t > void print(ostream& os, const t& a){os<<a<<'\n';}
template< typename t, typename... v > void print(ostream& os, const t& a, 
v&&... b){os << a << ' '; print(os, b...);}

constexpr int maxn = 1e5 + 1;

int n, l;
int tb[maxn];

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

    cin >> n >> l;

    for (int i = 0; i < n; ++i)
        cin >> tb[i];

    int v = -1;
    for (int i = 0; i < n - 1; ++i)
        if (tb[i] + tb[i + 1] >= l)
            v = i;

    if (v == -1)
        return prt("Impossible"), 0;

    prt("Possible");

    for (int i = 1; i < v + 1; ++i)
        prt(i);

    for (int i = n - 1; i >= v + 1; --i)
        prt(i);
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

//block linked list
#define Bsize 900 /*2sqrt(n)*/
typedef struct block{
	int cnt;
	ll a[Bsize+1];
	struct block*pre;
	struct block*nxt;
}block;
void Bpush(block*b,ll x){
	//リストにxを追加する
	if((*b).nxt&&(*(*b).nxt).a[0]<x){
		//次へ
		Bpush((*b).nxt,x);
		return;
	}
	int i=(*b).cnt;
	for(;i>0&&(*b).a[i-1]>x;i--)(*b).a[i]=(*b).a[i-1];
	(*b).a[i]=x;
	(*b).cnt++;
	if((*b).cnt>=Bsize){
		//分割
		block*nn=(block*)malloc(sizeof(block));
		(*nn).cnt=Bsize-Bsize/2;
		rep(i,0,Bsize-Bsize/2)(*nn).a[i]=(*b).a[i+Bsize/2];
		(*nn).pre=b;
		(*nn).nxt=(*b).nxt;
		if((*b).nxt)(*(*b).nxt).pre=nn;
		(*b).cnt=Bsize/2;
		(*b).nxt=nn;
	}
}
ll Bans(block*b,int k){
	//リストのk番目を返す
	//リストにk個未満しかなければ適当に返す
	if((*b).cnt<=k){
		if((*b).nxt)return Bans((*b).nxt,k-(*b).cnt);
		else return -1;
	}
	return (*b).a[k];
}
void con(block*p,block*q){
	//qをpにマージしてqを消す
	rep(i,0,(*q).cnt)(*p).a[(*p).cnt+i]=(*q).a[i];
	(*p).cnt+=(*q).cnt;
	(*p).nxt=(*q).nxt;
	if((*q).nxt)(*(*q).nxt).pre=p;
	free(q);
}
int Bdel(block*b,int k){
	//リストからkを(存在すれば)1個削除する
	//存在すれば1、しなければ0を返す
	if((*b).cnt==0||(*b).a[(*b).cnt-1]<k){
		if((*b).nxt)return Bdel((*b).nxt,k);
		else return 0;
	}
	int i=0;
	for(;(*b).a[i]<k;i++);
	if((*b).a[i]!=k)return 0;
	for(;i<(*b).cnt-1;i++)(*b).a[i]=(*b).a[i+1];
	(*b).cnt--;
	
	if((*b).cnt==0&&(*b).pre)con((*b).pre,b);
	else if((*b).pre&&(*(*b).pre).cnt+(*b).cnt<Bsize/4)con((*b).pre,b);
	else if((*b).nxt&&(*(*b).nxt).cnt+(*b).cnt<Bsize/4)con(b,(*b).nxt);
	return 1;
}


ll a[400010],x[200010];
int c(const void*p,const void*q){
	if(a[*(ll*)p]<a[*(ll*)q])return -1;
	return 1;
}
block b;
ll idx[400010];
int main(){
	ll n,q;
	scanf("%lld%lld",&n,&q);
	rep(i,0,n){
		ll s,t;
		scanf("%lld%lld%lld",&s,&t,x+i);
		a[2*i  ]=s-x[i];
		a[2*i+1]=t-x[i];
	}
	rep(i,0,2*n)idx[i]=i;
	qsort(idx,2*n,sizeof(ll),c);
	
	ll crr=0;
	rep(_,0,q){
		ll d;
		scanf("%lld",&d);
		while(crr<2*n&&a[idx[crr]]<=d){
			if(idx[crr]%2)Bdel(&b,x[idx[crr]/2]);
			else Bpush(&b,x[idx[crr]/2]);
			crr++;
		}
		printf("%lld\n",Bans(&b,0));
	}
}


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

using namespace std;

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;

#ifdef WIN32
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	ll ans = 2e18;
	if (a % 2 == 0) ans = 0;
	else ans = min(ans, (ll)b * c);
	if (b % 2 == 0) ans = 0;
	else ans = min(ans, (ll)a * c);
	if (c % 2 == 0) ans = 0;
	else ans = min(ans, (ll)b * a);
	cout << ans << endl;
	return 0;
}

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

#define ll long long
const int MOD = 1e9 + 7;
#define INF 2e9

#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20)

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; }

ll n,m,k;
string s;
int main() {
    INIT();

    cin >> n >> m;
    cout << n * m;
}

Measured memory_bytes: 3636
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
    while(true)
    {
      string[] input = Console.ReadLine().Split(' ');
      int h = int.Parse(input[0]);
      int w = int.Parse(input[1]);
      if(h == 0) break;

      long[] height = new long[h];
      long[] width = new long[w];
      for(int i = 0; i < h; i++) height[i] = long.Parse(Console.ReadLine());
      for(int i = 0; i < w; i++) width[i] = long.Parse(Console.ReadLine());
      Console.WriteLine(Answer(height,width));
    }
	}

  static long Answer(long[] height, long[] width)
  {
    long answer = 0;
    int h = height.Length;
    int w = width.Length;

    long[] heights = new long[h*(h+1)/2];
    long[] widths = new long[w*(w+1)/2];

    long[] heightSum = new long[h+1];
    long[] widthSum = new long[w+1];
    int heightCount = 0;
    int widthCount = 0;
    int sameCount = 1;
    for(int i = 0; i < h; i++) heightSum[i+1] = heightSum[i] + height[i];
    for(int i = 0; i < w; i++) widthSum[i+1] = widthSum[i] + width[i];

    for(int i = 0; i <= h; i++)
    {
      for(int j = i+1; j <= h; j++)
      {
        heights[heightCount] = heightSum[j]-heightSum[i];
        //Console.WriteLine(heights[heightCount]+"a");
        heightCount++;
      }
    }

    for(int i = 0; i <= w; i++)
    {
      for(int j = i+1; j <= w; j++)
      {
        widths[widthCount] = widthSum[j]-widthSum[i];
        //Console.WriteLine(widths[widthCount]);
        widthCount++;
      }
    }

    Array.Sort(heights);
    Array.Sort(widths);
    widthCount = 0;

    for(int i = 0; i < heightCount; i++)
    {
      while(widths[widthCount] < heights[i])
      {
        if(widthCount < w*(w+1)/2-1) widthCount++;
        sameCount = 1;
        if(widthCount == w*(w+1)/2-1) break;
      }

      while(widths[widthCount] == heights[i])
      {
        if(widthCount < w*(w+1)/2-1)
        {
          if(widths[widthCount+1] == heights[i])
          {
            if(widthCount < w*(w+1)/2-1)
            {
              widthCount++;
              sameCount++;
              continue;
            }
          }
        }
        break;
      }
      
      if(widths[widthCount] == heights[i])
      {
        answer += sameCount;
        //Console.WriteLine(answer+"t");
      }
    }
    return answer;
  }
  
}


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


#define base 1000000007LL
#define ll long long
// unsigned long long int t = 10000000000000000003ULL;
#define ulint unsigned long long int
#define ld long double
#define X first
#define Y second
#define pb push_back
#define EPS 1e-15
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())

#define ms(s, n) memset(s, n, sizeof(s))

#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define sqr(a) (a)*(a)

#define foru(i,a,b) for (ll i = (a); i <= (b); i++)
#define ford(i,a,b) for (ll i = (a); i >= (b); i--)
#define cbit(a) __builtin_popcount(a)
#define uni(a) (a).resize(unique(all(a)) - (a).begin())
#define cprint(n) printf("%.6lf + %.6lfi\n", (n).real(), (n).imag())

#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it !=(a).end(); it++)


using namespace std;
typedef pair<ll, ll> II;
typedef pair<int, int> ii;



struct Edge{
    ll u,v,w;
    Edge(ll u=0, ll v=0, ll w=0): u(u),v(v),w(w) {}
    bool operator < (Edge a){return w<a.w;}
};

const int M=1e5+7;
const int MM=4*M;
const ll MOD=base;
const int MAX=1e9;


inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll power(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = r * n % p; n = n * n % p;} return r;}
inline ll inverse(ll n, ll p=MOD){return power(n,p-2);}
ll search(ll a[], ll N, ll x){ ll l = 0, r = N - 1; while (l <= r){ ll mid = (l + r) / 2; if (x == a[mid]){ return 1; } else if (x < a[mid]){ r = mid - 1; } else if (x > a[mid]){ l = mid + 1; } } return -1; }
ll find_greater_equal(ll a[], ll N, ll x){ int q = lower_bound(a, a + N, x) - a; if(q == N){ return -1; } return q; }
ll find_greater(ll a[], ll N, ll x){ int q = upper_bound(a, a + N, x) - a; if(q == N){ return -1; } return q; }

ll n, m;
ll x, y;
ll a[103];
ll b[103];

int main(){
    ios::sync_with_stdio(0);
    cin >> n >> m;
    cin >> x >> y;
    for (int i = 0; i < n; i++){
    	cin >> a[i];
	}
	for (int i = 0; i < m; i++){
		cin >> b[i];
	}
	sort(a, a + n);
	sort(b, b + m);
	bool ok = false;
	for (int z = x + 1; z <= y; z++){
		if(a[n-1] < z && b[0] >= z){
			ok = true;
			break;
		}
	}
	if(ok){
		cout << "No War"; return 0;
	}
	cout << "War";
    return 0;
}





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

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

int main() {

    int a, p;
    cin >> a >> p;

    cout << (a * 3 + p) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
D,N = map(int,input().split())
if D == 0:
    if N == 100:
        print(101)
    else:
        print(N)
elif D == 1:
    if N == 100:
        print(10100)
    else:
        print(N*100)
else:
    if N == 100:
        print(1010000)
    else:
        print(N*10000)

Measured memory_bytes: 3060
#define debug_switch
#ifdef debug_switch
#define debug if(1) puts("debug");
#define dout if(1) cout
#else
#define debug if(0) puts("debug");
#define dout if(0) cout
#endif
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

const int N = 1e6 + 7;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-7;
using namespace std;
bool vis[N];
int prime[N],pnum=0,mu[N];//,sum[N];
void Mobius()
{
	//memset(vis,0,sizeof vis);
	vis[0] = vis[1] = mu[1] = 1;
	for(int i = 2; i < N; i++){
		if(!vis[i]){
			prime[++pnum] = i;
			mu[i] = -1;
		}
		for(int j = 1;j <= pnum && prime[j]*i < N; j++){
			vis[prime[j]*i] = 1;
			if(i % prime[j] == 0){
				mu[prime[j]*i] = 0;
				break;
			}
			mu[prime[j]*i] = -mu[i];
		}
	}
//	for(int i = 1;i < N; i++)  //求前缀和，用于分块优化
//		sum[i] = sum[i-1] + mu[i];
}
int cnt[N];
int nn = 1e6;
ll cal(int x){
	ll res=0;
	for(int i=x;i<=nn;i+=x){
		res = (res + 1ll * (i/x) * cnt[i] % mod) % mod;
	}
//	for(int i=1;i<=nn/x;i++){
//		res = (res + 1ll * i * cnt[i*x] % mod) % mod;
//	}
	return res * res % mod;
}
ll qpow(ll a, int n){
	ll res=1;
	while(n){
		if(n&1)res=res*a%mod;
		a = a*a%mod;
		n >>= 1;
	}
	return res;
}
int main()
{
	int n,x;
	ll sum=0;
	Mobius();
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		sum += x; 
		cnt[x]++;
	}
	sum %= mod;
	ll ans=0;
	for(int i=1;i<=nn;i++){
		ll tmp=0;
		for(int j=1;j<=nn/i;j++){
			tmp = (tmp + 1ll * mu[j] % mod * j % mod * j % mod * cal(1ll*i*j) % mod) % mod;
		}
		//cout<<tmp<<endl;
		ans = (ans + tmp * i % mod) % mod;
		//cout<<ans<<endl;
	}
	ans = ((ans - sum) % mod + mod) % mod;
	cout<<(ans * qpow(2, mod-2) % mod)<<endl;
	return 0;
}






Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    int a, p;
    cin >> a >> p;
    cout << (3 * a + p) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

ll n, k, q;
VLL a, ans;

int main()
{
    cin>>n>>k>>q;
    a.resize(q);
    ans.resize(n, 0);
    REP(i,q) {
        cin>>a[i];
        ans[a[i]-1]++;
    }
    REP(i,n) {
        Yes(k + ans[i] - q > 0);
    }

    return 0;
}


Measured memory_bytes: 2176
n = int(input())
s = input().rstrip()
def check(is_sheep, s, i, n):
  a = i - 1 if i != 0 else n-1
  b = i + 1 if i != n - 1 else 0
  if (s[i] == 'o') == is_sheep[i]:
    return is_sheep[a] == is_sheep[b]
  else:
    return is_sheep[a] != is_sheep[b]

def solve(n, s):
  # SS
  for x, y in [(True, True), (True, False), (False, True), (False, False)]:
    is_sheep = [None] * n
    is_sheep[0] = x
    is_sheep[1] = y
    for i in range(2, n):
      if is_sheep[i-1]:
        if s[i-1] == 'o':
          is_sheep[i] = is_sheep[i-2]
        else:
          is_sheep[i] = not is_sheep[i-2]
      else:
        if s[i-1] == 'o':
          is_sheep[i] = not is_sheep[i-2]
        else:
          is_sheep[i] = is_sheep[i-2]
    if check(is_sheep, s, 0, n) and check(is_sheep, s, n - 1, n):
      return is_sheep
  return None

result = solve(n, s)

if result:
  print("".join(["S" if b else "W" for b in result]))
else:
  print(-1)


Measured memory_bytes: 5460
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

string s;

pair<int,int> f()
{
    int i = 0, j = 0;
    REP(k,s.size() - 2) {
        if (s[k+1] == 'O' && s[k+2] == 'I') {
            if (s[k] == 'J')
                j++;
            if (s[k] == 'I')
                i++;
        }
    }
    return {j,i};
}

int main()
{
    while (cin>>s) {
        auto p = f();
        cout<<p.fst<<endl;
        cout<<p.scd<<endl;
    }
    return 0;
}



Measured memory_bytes: 3044
using System;
using System.Linq;

namespace Algo
{
    class Program
    {
        static void Main()
        {
            var n = long.Parse(Console.ReadLine()!);
            var a = Console.ReadLine()?.Split().Select(long.Parse).ToArray();
            var b = new long[n + 1];
            for (var i = 0; i < n; i++)
            {
                b[i + 1] = b[i] + a[i];
            }

            var ans = long.MaxValue;
            for (var i = 1; i < n; i++)
            {
                var x = b[i];
                var y = b[n] - x;
                ans = Math.Min(ans, Math.Abs(x - y));
            }
            Console.WriteLine(ans);
        }
    }
}


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

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

    vector<int> a(n);
    int tmp;
    for (int i = 1; i <= n; i++) {
        cin >> tmp;
        a.at(tmp-1) = i;
    }

    for (int i = 0; i < n; i++) {
        cout << a.at(i) << (i == n-1 ? "" : " ");
    }

    cout << endl;

    return 0;
}


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


int main(){
    string s;
    cin >> s;
    string ans = "";
    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] == 'B'){
            if ((int)ans.size() == 0) continue;
            ans.erase(--ans.end(), ans.end());
        }else {
            ans += s[i];
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long int ll;

ll lcm(ll a,ll b){
    if(a<b)swap(a, b);
    ll gcd=a%b;
    ll x=a*b;
    while (gcd!=0) {
        a=b;
        b=gcd;
        gcd=a%b;
    }
    return x/b;
}

ll gcd(ll a,ll b){
    ll gcd=a%b;
    while (gcd!=0) {
        a=b;
        b=gcd;
        gcd=a%b;
    }
    return b;
}

int main(){
    int n;
    while (1) {
        cin>>n;
        if(n==0)break;
        vector<pair<ll, ll> >dv(n);
        int d,v;
        for (int i=0; i<n; i++) {
            cin>>d>>v;
            ll r=gcd(d,v);
            d/=r;
            v/=r;
            dv[i]=make_pair(d, v);
        }
        ll l=dv[0].first;
        for (int i=0; i<n-1; i++) {
            l=lcm(l, dv[i+1].first);
        }
        ll a[n];
        for (int i=0; i<n; i++) {
            a[i]=l*dv[i].second/dv[i].first;
        }
        ll g=gcd(a[0],a[1]);
        for (int i=2; i<n; i++) g=gcd(g, a[i]);
        for (int i=0; i<n; i++) cout<<a[i]/g<<endl;
    }
    return 0;
}


Measured memory_bytes: 2952
N = int(input())
a = [0]+list(map(int,input().split()))
b = [0]*(N+1)
b[-1] = a[-1]
for i in range(N-1,0,-1):
    hoge = a[i]
    for j in range(i,N+1,i):
        hoge += b[j]
    b[i] = hoge%2
print(sum(b))
for i in range(N+1):
    if b[i] == 1:
        print(i,end = " ")

Measured memory_bytes: 7220
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

const int NMAX = 100005;

vector<int> G[NMAX];
int dp[NMAX];

void dfs(int node) {
    for (int to: G[node]) {
        dfs(to);
    }
    sort(G[node].begin(), G[node].end(), [](const int a, const int b) -> bool {
        return dp[a] > dp[b];
    });
    for (int i = 0; i < SZ(G[node]); ++i) {
        dp[node] = max(dp[node], dp[G[node][i]] + i + 1);
    }
}

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    for (int i = 2; i <= n; ++i) {
        int f;
        cin >> f;
        G[f].push_back(i);
    }
    dfs(1);
    cout << dp[1] << '\n';
}


Measured memory_bytes: 10752