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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

int main() {
    int N;
    long long M;
    cin >> N >> M;
    vector<long long> a(N);
    rep(i, N) cin >> a[i];
    vector<long long> s(N + 1);
    rep(i, N) s[i + 1] = s[i] + a[i];

    map<long long, long long> count;
    rep(i, N + 1) count[s[i] % M]++;

    long long ans = 0;
    for (map<long long, long long>::iterator it = count.begin(); it != count.end(); ++it) {
        ans += it->second * (it->second - 1) / 2;
    }
    cout << ans << endl;
}

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

ll MOD = 1000000007;
ll dp[202020];
ll N;
set<ll>S[202020];

int main(){
    cin >> N;
    vector<int>C(N);
    dp[0] = 1;
    for(int i = 0; i < 202020; i++)S[i].insert(202019);
    for(int i = 0; i < N; i++){
        cin >> C[i];
        S[C[i]].insert(i);
    }
    for(ll i = 0; i < N; i++){
        dp[i+1] = (dp[i+1] + dp[i]) % MOD;
        int nxt = *S[C[i]].upper_bound(i);
        if(nxt > i + 1)dp[nxt] = (dp[nxt] + dp[i]) % MOD;
    }
    cout << dp[N-1] << endl;



    return 0;
}

Measured memory_bytes: 30976
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define FF first
#define SS second
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(x) (int)x.size()
typedef long double f80;
#define all(x) x.begin(), x.end()

const int mod = 1e9 + 7;
const int N = 1e5 + 5;

multiset<int> s;

signed main()
{
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    fr(i, 1, n) {
        int x;
        cin >> x;
        auto it = s.lower_bound(x);
        if(it != s.begin()) {
            it--;
            s.erase(it);
        }
        s.insert(x);
    }
    cout << sz(s);
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> piii;
typedef pair<ll,pii> ipii;
#define MOD 998244353 
#define mod(a) ((a)%MOD)
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define dbg(x) cout<<#x<<" = "<<x<<"\n"
#define dbg2(x,y) cout<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<"\n"
#define dbg3(x,y,z) cout<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<" , "<<#z<<" = "<<z<<"\n"
#define INF (1LL<<60)
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;*/
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(),v.end()
#define endl '\n'
ll gcd(ll a,ll b){if(a==0) return b; return gcd(b%a,a);}
ll powm(ll base,ll exp,ll mod=MOD) {base%=mod;ll ans=1;while(exp){if(exp&1LL) ans=(ans*base)%mod;exp>>=1LL,base=(base*base)%mod;}return ans;}


vector<pii> p;
ll dp[101][100005];
int main(){
      sync;
      ll n,w;
      cin>>n>>w;
      for(ll i=1; i<=n; i++){
            ll w,v;
            cin>>w>>v;
            p.pb({v,w}); 
      }
      
      dp[0][p[0].sd]=p[0].ft;
      for(int i=1;i<n;i++){
      	 for(int j=0;j<=w;j++){
               dp[i][j]=dp[i-1][j];
               if(p[i].sd<=j) dp[i][j]=max(dp[i][j],dp[i-1][j-p[i].sd]+p[i].ft);
      	 }
      }
      ll ans=0;
      for(int i=0;i<=w;i++){
      	  ans=max(ans,dp[n-1][i]);
      }
      cout<<ans<<endl;
} 



Measured memory_bytes: 77568
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.flush();
	int n,k;
    cin >> n >> k;
  	cout<<(n%k!=0);
	return 0;
	// BYE BYE
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int h,w; cin>>h>>w;
    int ch,cw; cin>>ch>>cw;
    ch--; cw--;
    int dh,dw; cin>>dh>>dw;
    dh--; dw--;
    vector<vector<char>> m(h,vector<char>(w,'a'));
    rep(i,h)rep(j,w) cin>>m[i][j];
    vector<vector<int>> gr(h,vector<int>(w,-1));
    int cur=0,sh,sw;
    rep(i,h)rep(j,w){
        if(gr[i][j]!=-1) continue;
        if(m[i][j]=='#') continue;
        queue<pp> que;
        que.push(mk(i,j));
        gr[i][j]=cur;
        while(!(que.empty())){
            tie(sh,sw)=que.front();
            que.pop();
            if(sh>0 && gr[sh-1][sw]==-1 && m[sh-1][sw]=='.'){
                gr[sh-1][sw]=cur;
                que.push(mk(sh-1,sw));
            }
            if(sh<h-1 && gr[sh+1][sw]==-1 && m[sh+1][sw]=='.'){
                gr[sh+1][sw]=cur;
                que.push(mk(sh+1,sw));
            }
            if(sw>0 && gr[sh][sw-1]==-1 && m[sh][sw-1]=='.'){
                gr[sh][sw-1]=cur;
                que.push(mk(sh,sw-1));
            }
            if(sw<w-1 && gr[sh][sw+1]==-1 && m[sh][sw+1]=='.'){
                gr[sh][sw+1]=cur;
                que.push(mk(sh,sw+1));
            }
        }
        cur++;
    }
    vector<set<int>> path(cur);
    rep(i,h)rep(j,w){
        if(m[i][j]=='#') continue;
        for(int di=-2;di<=2;di++)for(int dj=-2;dj<=2;dj++){
            if(i+di<0 || i+di>h-1 || j+dj<0 || j+dj>w-1) continue;
            if(m[i+di][j+dj]=='#') continue;
            if(gr[i][j]!=gr[i+di][j+dj]) path[gr[i][j]].insert(gr[i+di][j+dj]);
        }
    }
    queue<int> que;
    que.push(gr[ch][cw]);
    vector<int> visited(cur,0),dis(cur,0);
    visited[gr[ch][cw]]=1;
    while(!(que.empty())){
        int ss=que.front();
        que.pop();
        for(auto p:path[ss]){
            if(visited[p]==0){
                que.push(p);
                visited[p]=1;
                dis[p]=dis[ss]+1;
            }
        }
    }
    if(visited[gr[dh][dw]]==0){
        cout<<-1<<endl;
        return 0;
    }
    cout<<dis[gr[dh][dw]]<<endl;
}

Measured memory_bytes: 33332
use std::io::{stdout, Write};
use std::str::FromStr;
use std::thread;

fn run() {
    let input = read_input();
    let mut input = input.split_whitespace();
    let in_n: i64 = input.next().unwrap().parse().unwrap();
    let in_x: Vec<u64> = input.map(|s| u64::from_str(s).unwrap()).collect();

    let mut y = in_x.clone();
    y.sort();
    let x1 = y[in_n as usize / 2 - 1];
    let x2 = y[in_n as usize / 2];

    let mut out = stdout();
    for x in in_x {
        writeln!(out, "{}", if x <= x1 { x2 } else { x1 }).unwrap();
    }
}

fn main() {
    thread::Builder::new()
        .stack_size(32 * 1024 * 1024) // 32MB
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

/// ローカル環境なら _in.txt から入力を受ける
fn read_input() -> String {
    use std::fs::File;
    use std::io::Read;
    let mut s = String::new();
    match option_env!("LOCAL") {
        Some(_) => File::open("src/_in.txt")
            .expect("File not found")
            .read_to_string(&mut s)
            .unwrap(),
        None => std::io::stdin().read_to_string(&mut s).unwrap(),
    };
    s
}


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

int main() {
  string S;
  cin >> S;
  if(S=="SUN") cout << 7;
  else if(S=="MON") cout << 6;
  else if(S=="TUE") cout << 5;
  else if(S=="WED") cout << 4;
  else if(S=="THU") cout << 3;
  else if(S=="FRI") cout << 2;
  else cout << 1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  set<string> s;
  for (int i = 0; i < n; i++){
    string t;
    cin >> t;
    
    s.insert(t);
  }
  cout << s.size() << endl;
  

  return 0;
}


Measured memory_bytes: 19260
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;


void calc() {

	Int A, B, C; std::cin >> A >> B >> C;
	std::cout << C << " " << A << " " << B << "\n";

}


int main() {

	calc();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    vector<int> sum(n + 1); sum[0] = 0;
    for(int i = 0; i < n; i++) {
        sum[i + 1] = a[i] + sum[i];
    }

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

    map<int, int> mp;
    for(int i = 0; i < n + 1; i++) {
        mp[sum[i]]++;
    }

    int ans = 0;
    for(auto i = mp.begin(); i != mp.end(); i++) {
        int cnt  = i -> second;
        ans += (cnt * (cnt  -1)) / 2;
    }

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


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

typedef struct{
    int win,lose;
}Score_t;


bool comp(const pair<Score_t,char>& x, const pair<Score_t,char>& y){
    if(x.first.win == y.first.win)return x.first.lose < y.first.lose;
    return x.first.win > y.first.win;
}


int main(){
        
    int n;
    vector<pair<Score_t,char> > score;
    
    while(cin>>n, n!=0){
        score.clear();
        
        
        for(int i=0; i<n; i++){
            char id; cin >> id;
            Score_t tmp={0,0};
            for(int j=0; j<n-1; j++){
                int in;
                cin >>in;
                if(in==0)tmp.win++;
                else if(in==1)tmp.lose++;
            }
        
            score.push_back(make_pair(tmp,id));
        }
        
        sort(score.begin(),score.end(),comp);
        for(int i=0; i<n; i++)cout << score[i].second << endl;
    }
    return 0;
}




Measured memory_bytes: 2992
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef  long long  int ll;
typedef long double db;
#define pb push_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define np(str) next_permutation(str.begin(),str.end())
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define pi 3.1415926535
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for(i=n-1;i>=0;i--)
#define rep(i,n) for( i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll M = 1e9 + 7;
ll inf = 1e18;

ll n, m;
v<ll> fact;
void factorial(ll n)
{
	fact[0] = 1;
	for (ll i = 1; i <= n; i++)
	{
		fact[i] = i * fact[i - 1];
		fact[i] %= M;
	}
}
// modular exponentiation
ll binpow(ll val, ll deg)
{
	if (!deg)
		return 1 % M;
	if (deg & 1)
		return binpow(val, deg - 1) * val % M;
	ll res = binpow(val, deg >> 1);
	return (res * res) % M;
}
//combination
ll C(ll n, ll i)
{
	if (n < i)
		return 0;
	ll res = fact[n];
	ll div = fact[n - i] * fact[i];
	div %= M;
	// using fermat little theorum
	div = binpow(div, M - 2); // modular inverse
	return (res * div) % M;
}

int main() {
	// your code goes here
	IOS;

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll i, j, t, k, x, y, z,  N;
	N = 1e5;
	fact.resize(N + 1);
	factorial(N);
	ll S;
	cin >> S;
	ll nways = 0;
	for (i = 1; i <= 1e4; i++) {
		ll S_ = S - 3 * i;
		if (S_ >= 0) {
			(nways += C(S_ + i - 1, i - 1)) %= M;
		}
	}
	cout << nways;


	return 0;

}
























Measured memory_bytes: 3960
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
		
			int[] mfr= new int[5];
			int sum=0;
			String[] tmpArray;	
			while( true ) {
				String str = kb.readLine();
				tmpArray = str.split( " " );
				if( "-1".equals( tmpArray[0] ) && "-1".equals( tmpArray[1] ) 
						&& "-1".equals( tmpArray[2] ) ) {
					break;
				}
				sum=0;
				for( int i=0; i<3; i++ ) {
					mfr[i]=Integer.parseInt( tmpArray[i] );
					if( -1 != mfr[i] && 2 != i ) {
						sum+=mfr[i];
					}
				}
				if( sum<30 || -1==mfr[0] || -1==mfr[1] ) {
					System.out.println( "F" );
				} else if( 80 <= sum ) {
					System.out.println( "A" );
				} else if( 65<=sum && sum<80 ) {
					System.out.println( "B" );
				} else if( 50<=sum && sum<65 ) {
					System.out.println( "C" );
				} else if( 30<=sum && sum<50 ) {
					if( 50<=mfr[2] ) {
						System.out.println( "C" );
					} else {
						System.out.println( "D" );
					}
				}
			}
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}

Measured memory_bytes: 16936
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let mut v1: Vec<Vec<i32>> = vec![vec![0; 3]; 3];
    for i in 0..3{
	for j in 0..3{
	    let m: i32 = read();
	    v1[i][j] = m;
	}
    }
    let n: i32 = read();
    for _c in 0..n{ 
	let m: i32 = read();
	for i in 0..3{
	    for j in 0..3{
		if v1[i][j]== m{
		    v1[i][j] = -1;
		}
	    }
	}
    }
    for i in 0..3{
	if v1[i][0]==-1&&v1[i][1]==-1&&v1[i][2]==-1 {
	    println!("Yes");
	    return;
	}
    }
    for j in 0..3{
	if v1[0][j]==-1&&v1[1][j]==-1&&v1[2][j]==-1 {
	    println!("Yes");
	    return;
	}
    }
    if v1[0][0]==-1&&v1[1][1]==-1&&v1[2][2]==-1 {
	println!("Yes");
	return;
    }else if v1[0][2]==-1&&v1[1][1]==-1&&v1[2][0]==-1{
	println!("Yes");
	return;
    }
    println!("No");
}


Measured memory_bytes: 4352
#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

s=input().rstrip()
n=len(s)
now=[0]*(n+1)
for i in range(n):
    if s[i]=="B":
        now[i+1]=now[i]+1
    else:
        now[i+1]=now[i]

ans=0
for i in range(n,0,-1):
    if s[i-1]=="W":
        ans+=now[i]
print(ans)

Measured memory_bytes: 11144
#include<bits/stdc++.h>
using namespace std;
#define int long long
bool used[555];
set<int> G[555];
void dfs(int v){
  if(used[v]) return;
  used[v]=1;
  for(int u:G[v]) dfs(u);
}
signed main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int s,t;
    cin>>s>>t;
    s--;t--;
    G[s].insert(t);
  }
  memset(used,0,sizeof(used));
  int cnt=0;
  for(int i=0;i<n;i++){
    if(used[i]) continue;
    cnt++;
    dfs(i);
  }
  cout<<m-n+cnt<<endl;
  return 0;
}

Measured memory_bytes: 3224
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner =new Scanner(System.in);
		int N = scanner.nextInt();

		int streak = 0;
		boolean judge = false;
		for (int i = 0; i < N; i++) {
			int A = scanner.nextInt();
			int B = scanner.nextInt();
			if (A == B) {
				streak++;
			}else{
				streak = 0;
			}
			if (streak >= 3) {
				judge = true;
			}
		}

		if (judge) {
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

		scanner.close();
	}

}


Measured memory_bytes: 27176
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define mod 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

using namespace std;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    string S;
    cin>>S;
    long long ans=0;
    int ren_a=0;
    bool a=false,b=false,c=false;
    rep(i,0,S.size()){
        if(S[i]=='A'){
            if(b)ren_a=0;
            ren_a++;
            a=true;b=false;c=false;
        }
        if(S[i]=='B'){
            if(b)ren_a=0;
            a=false;b=true;c=false;
        }
        if(S[i]=='C'){
            if(a || c)ren_a=0;
            if(b)ans+=ren_a;
            a=false;b=false;c=true;
        }
    }
    cout<<ans;
    return 0;
}

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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  string s; cin >> s;
  
  string ans;
  rep(i, si(s)) {
    if (s[i] == '0') ans += '0';
    else if (s[i] == '1') ans += '1';
    else {
      if (ans.empty()) continue;
      else ans.pop_back();
    }
  }

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

Measured memory_bytes: 3644
N = input()
n=0
if N == "111":
    n = 999
elif N == "119":
    n = 991
elif N == "199":
    n= 911
elif N == "999":
    n = 111
elif N == "911":
    n = 199
elif N == "991":
    n = 119
elif N == "191":
    n = 919
elif N == "919":
    n = 191

print(n)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    cout<<setprecision(10);
    int n,l;
    cin>>n>>l;
    vi a(n);
    cin>>a;
    REP(i,n-1){
        if(a[i]+a[i+1]>=l){
            Poss(1);
            for(int j=n-1;j>i+1;--j)cout<<j<<endl;
            for(int j=1;j<i+1;++j)cout<<j<<endl;
            cout<<i+1<<endl;
            return 0;
        }
    }
    Poss(0);
}


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


/********************************************************************/
#define M1 1000000007
#define M2 998244353
#define ll long long
#define pll pair<ll,ll>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPR(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
/********************************************************************/
// const int mx = 1e7 + 5;
const double pi = 3.1415926535;
/********************************************************************/
//FAST IO//
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}


/********************************************************************/
int main() {
	FAST();
	ll n;
	cin >> n;
	ll ar[n];
	for (int i = 0 ; i < n; i++) {
		cin >> ar[i];
	}
	sort(ar, ar + n);
	if (ar[0] == 0)
		cout << 0;
	else {
		ll ans = 1;
		ll flag = 0;

		for (int i = 0; i < n; i++) {
			// cout << ans << endl;
			if (ans <= 1000000000000000000 / ar[i]) {
				ans *= ar[i];
			}
			else {
				// cout << i << endl;
				flag = 1;
				break;
			}
		}
		if (flag)
			cout << -1 << endl;
		else
			cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4276
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
if(a==b&&c!=a)
    cout<<"Yes"<<endl;
else if(c==a&&b!=c)
    cout<<"Yes"<<endl;
else if(c==b&&c!=a)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;
return 0;}


Measured memory_bytes: 3560
#include <iostream>
#include <algorithm>
using namespace std;
int A[1000000];
int main() {
  int n;
  while(1) {
    cin >> n;
    if(n == 0) break;
    for(int i = 0; i < n; i++) {
      cin >> A[i];
    }
    sort(A, A+n);

    int cnt;
    int maxi = -1;
    int maxA;
    for(int i = 0; i < n; ) {
      int a = A[i];
      cnt = 1;
      for(i++; i < n && A[i] == a; i++) {
	cnt++;
      }
      if(cnt > maxi) {
	maxi = cnt;
	maxA = a;
      }
    }
    if(maxi > n/2) cout << maxA << endl;
    else          cout << "NO COLOR" << endl;
  }
  return 0;
}

Measured memory_bytes: 4772
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int N, K;
	cin >> N >> K;
	int num = 0;
	while (1) {
		if (N < pow(K, num))break;
		num++;
	}
	cout << num;
}

Measured memory_bytes: 256
from itertools import product
 
S = input()
 
patterns = list(product(["-","+"],repeat=len(S)-1))
 
ans = []

for pattern in patterns:
    cnt = 0
    num = ""
    for i in range(len(pattern)+1):
        if i == 0:
            cnt += int(S[i])
            num = num + S[i]
        else:
            if pattern[i-1] == "+":
                cnt += int(S[i])
                num = num + pattern[i-1] + S[i]
            else:
                cnt -= int(S[i])
                num = num + pattern[i-1] + S[i]
    if cnt == 7:
        print(num+"=7")
        break;


Measured memory_bytes: 3064
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, beg, end) for (int i = (beg); i < (end); i++)
 

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

    if(s.length() <= k)
    {
        cout << s;
    }
    else
    {
        s = s.substr(0,k)+"...";
        cout << s;
    }
    
    

}

Measured memory_bytes: 3628
N,K,Q = map(int,input().split())
A = [int(input()) for _ in range(Q)]

ans = [0]*N
for a in A:
    ans[a-1] += 1
for i in range(N):
    if K-Q+ans[i] > 0:
        print("Yes")
    else:
        print("No")

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

#define ll long long
#define pb push_back
#define pr pair<ll, ll>
#define vct vector<ll>
#define vpt vector<pr>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define F(i, n) for (i = 0; i < (1LL*n); i++)
#define Fr(i, n) for (i = n - 1; i >= 0; i--)

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, int, custom_hash>
void prv(vct v)
{
    for (ll i = 0; i < v.size(); i++)
        cout << v[i] << " ";
    cout << "\n";
}
ll poww(ll x, ll y, ll m)
{
    ll res = 1;
    while (y)
    {
        if (y % 2 == 0)
        {
            x = (x * x) % m;
            y = y / 2;
        }
        else
        {
            res = (res * x) % m;
            y--;
        }
    }
    return res;
}
void deb(string s, ll n)
{
    cout << s << " : " << n << "\n";
}
void prn(ll n) { cout << n << "\n"; }
void prs(string n) { cout << n << "\n"; }

mat mt;
void setmtsize(ll m,ll n, ll ini=0){
    mt.resize(m,vector<ll>(n,ini));
}
void prmt(mat m){
    for(ll i=0;i<(1LL*m.size());i++)prv(m[i]);
}
vct divsors(ll n)
{
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++)
    {if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    sort(ans.begin(),ans.end());
    return ans;
}
vct sieve(ll n){
    vct ans(n+1,-1);
    for(ll i=2;i<=n;i++){
        if(ans[i]==-1){
            for(ll j=i;j<=n;j+=i)if(ans[j]==-1)ans[j]=i;
        }
    }
    return ans;
}
ll n, k, m, l, r, x, y, z, ans=0;
ll t, t1, t2;
ll q;
ll i, j;
ll a, b, c;
ll mod = 1000000007;



void solve()
{
    cin>>n;
    vct v(n);
    F(i,n)cin>>v[i];
    vct dp(n+1,0);
    ll cr=v[0];
    for(i=1;i<n;i++){
        if(i==1) dp[i]=abs(v[i]-v[i-1]);
        else dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
    }
    prn(dp[n-1]);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1;
    // cin >> t;
    // stress();
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 4812
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int cnt=1,ans=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]==cnt)
        {
            ans++;
            cnt++;
        }
    }
    if(ans==0)
    {
        cout<<-1<<nl;
    }
    else
    {
        cout<<n-ans<<nl;
    }
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
int main()
{
	int n,m;
	cin>>n>>m;
	ll k;
	cin>>k;
	ll  prea[n+1]={0}, preb[m+1]={0},x;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		prea[i+1]+=prea[i]+x;
	}
	for(int i=0;i<m;i++)
	{
		cin>>x;
		preb[i+1]+=preb[i]+x;
	}
	int i=0,j=0;
	while(prea[i+1]<=k&&i<n)i++;
	int ans=i;
	for(;i>=0;i--)
	{
		while(preb[j+1]+prea[i]<=k&&j<m)j++;
		ans=max(ans,i+j);
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

#define ll long long

//iostream::sync_with_stdio(false);

const int maxn = 2e6+5;

int main()
{
    int t;
    cin >> t;
    string s;
    string s1 = "AC", s2 = "WA", s3 = "TLE", s4 = "RE";
    int h1 = 0,h2 = 0,h3 = 0,h4 = 0;
    for(int i = 0; i < t; i++)
    {
        cin >> s;
        if(s == s1)h1++;
        if(s == s2)h2++;
        if(s == s3)h3++;
        if(s == s4)h4++;
    }
    cout << "AC x " << h1 << endl;
    cout << "WA x " << h2 << endl;
    cout << "TLE x " << h3 << endl;
    cout << "RE x " << h4 << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int HWmax = 10000;
int H, W, N;
int A[HWmax];

int main(){
	cin >> H >> W >> N;
	for(int i=0; i<N; i++) cin >> A[i];

	vector<int> x(H*W);
	int k=0;
	for(int i=0; i<N; i++){
		for(int j=0; j<A[i]; j++) x[k++] = i+1;
	}
	vector<vector<int> > vec(100, vector<int>(100));
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			vec[i][i%2?j:(W-j-1)] = x[W*i+j];
		}
	}

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

	return 0;
}


Measured memory_bytes: 384
s = int(input())
x1 = 0
a = 10**9
c = 1
y1 = 0
b = 0
d = 0
t = s//(10**9)
if s%10**9==0:
  d = s//10**9
  print(x1,y1,a,b,c,d)
  exit()
d = t+1
b = 10**9-s%(10**9)
print(x1,y1,a,b,c,d)


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

int main() {
  string s;
  set<string> sub;
  int k;

  cin >> s >> k;

  for (int i = 0; i < (int)s.length(); i++) {
    for (int j = 1; j <= 5; j++) {
      if (i + j > (int)s.length()) break;
      sub.insert(s.substr(i, j));
    }
  }

  auto itr = sub.begin();
  for (int i = 1; i < k; i++) ++itr;

  cout << *itr;

  return 0;
}

Measured memory_bytes: 1664
// finish date: 2018/12/18

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    //入力と変数宣言
    int N;
    cin >> N;
    vi A(N);
    rep(i, N) cin >> A[i];
    int ans = 0;

    //値の出現回数をmapにカウント
    map<int, int> mp;
    rep(i, N) mp[A[i]]++;
    for (auto e = mp.rbegin(); e != mp.rend(); e++) {
        //cout << e->first << " " << e->second << endl; //確認
        while (e->second > 0) {
            if (log2(e->first) == (int) log2(e->first)) {
                //見てる値が2^nの場合
                if (e->second >= 2) {
                    e->second -= 2;
                    ans++;
                } else break;
            } else {
                //見てる値が2^n以外の場合
                int pow2t = 1 << (int) ceil(log2(e->first));
                if (mp[pow2t - e->first] > 0) {
                    e->second--;
                    mp[pow2t - e->first]--;
                    ans++;
                }else break;
            }
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 19712
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cat X;
	cin >> N >> X;
	vector<cat> pos(N);
	for(int i = 0; i < N; i++) cin >> pos[i];
	vector<cat> S(N+1, 0);
	for(int i = 0; i < N; i++) S[i+1] = S[i] + pos[i];
	cat ans = 2LL * X * N + 10LL * S[N];
	for(int k = 1; k <= N; k++) {
		int cnt = 0;
		cat cur = (k + N) * X;
		for(int i = N-1; i >= 0; i -= k) {
			cat mul = (cnt == 0) ? 5 : (2 * cnt + 3);
			cur += (S[i+1] - S[max(0, i-k+1)]) * mul;
			cnt++;
			if(cur > ans) break;
		}
		ans = min(ans, cur);
	}
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 3328
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        String x = scanner.nextLine();
        while(!x.equals("0")){
            char ch[] = x.toCharArray();
            int sum = 0;
            for(int i=0; i < x.length(); i++){
                sum += Character.getNumericValue(ch[i]);
            }
            System.out.println(sum);
            
            x = scanner.nextLine();
        }
    }
}


Measured memory_bytes: 26476
import numpy as np

def InputToInt():
    A = input().split()
    for i in range(len(A)):
        A[i] = int(A[i])
    return A
    
if __name__ == '__main__':
    N = int(input())
    A = InputToInt()

    s = np.zeros(N)
    for j in range(0,N-2,2):
        s[0] += A[j] - A[j+1]
    s[0] += A[N-1]
    s[N-1] = (A[N-1] - s[0]/2)*2

    for i in range(2,N):
        s[N-i] = (A[N-i] - s[N-i+1]/2)*2
    for i in range(N):
        print(int(s[i]), end=" ")


Measured memory_bytes: 21040
import java.io.*;
import java.util.*;
 
public class Main {
 
    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
 
        Integer num = Integer.parseInt(s.nextLine());
        String input = s.nextLine();
        s.close();
 
        Integer[] seq = new Integer[num];
        if(input.contains("  ")){
            input = input.replace("  ", " ");
            input = input.substring(0, input.length() - 1);
        }
        String[] input_list = input.split(" ");
        for(int i = 0; i < num; i++){
            seq[i] = Integer.parseInt(input_list[i]);
        }
 
        for(int j = 1;j < seq.length; j++){
            print_seq(seq);
            Integer key = seq[j];
            Integer i = j - 1;
            while(i >= 0 && seq[i] > key){
                Integer bkp = seq[i+1];
                seq[i+1] = seq[i];
                seq[i] = bkp;
                i -= 1;
            }
        }
        print_seq(seq);
    }
 
    private static void print_seq(Integer[] seq){
    	String output = "";
        for(int i = 0; i < seq.length; i++){
            if(i == seq.length - 1){
                output = output + seq[i] + "\n";
            }
            else{
                output = output + seq[i] + " ";
            }
        }
        System.out.print(output);
    }
}

Measured memory_bytes: 40700
#include <stdio.h>

int main(void){
	long a=0, b=0;
	long x=0;
	long m=0, n=0;
	while(scanf("%d %d", &a, &b) != EOF){
		if(a<b){
			x=b;b=a;a=x;
		}
		m=a;n=b;
		while(n != 0){
			x = n;
			n = m % n;
			m = x;
		}
		printf("%d %d\n", m, a/m*b);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>

using namespace std;

int main()
{
	string line;
	while(cin >> line)
	{
		replace(line.begin(), line.end(), ',', ' ');
		stringstream stream(line);

		int l[10];
		int path = 0;
		for(auto& i : l)
		{
			stream >> i;
			path += i;
		}

		int v1, v2;
		stream >> v1 >> v2;

		double time = (double)path / (v1 + v2);
		double position = v1 * time;
		int dist = 0;
		for(int i = 0; i < 10; i++)
		{
			dist += l[i];
			if(position <= dist)
			{
				cout << i + 1 << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<string>

using namespace std;

int main() {
	int a, b, c, x, y, g, h, m, n;

	cin >> a >> b >> c >> x >> y;

	g = a * x; //純粋にAを必要枚数買った場合のAの金額
	h = b * y; //純粋にBを必要枚数買った場合のBの金額

	if (x > y) {
		m = c *2* x;
	}
	else {
		m = c * 2*y;
	}					//純粋にABを必要枚数分買った場合のABの金額

	if (x > y) {
		n = c * 2*y + a*(x-y);
	}
	else {
		n = c * 2*x + b*(y-x);
	}					//少ない方の枚数に合わせてABを買った場合のABの金額

	if (g + h < m) {
		if (n < g + h) {
			if (x > y) {
				cout << n << endl;
			}
			else {
				cout << n << endl;
			}
		}
		else {
			cout << g + h << endl;
		}
	}
	else {
		if (n < m) {
			if (x > y) {
				cout << n << endl;
			}
			else {
				cout << n << endl;
			}
		}
		else {
			cout << m << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n;
double sum;
signed main(){
	cin>>n;
	rep(i,n){
		double a;
		cin>>a;
		sum+=1/a;
	}
	printf("%.12lf\n",1/sum);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define i64 long long
#define ui64 unsigned long long
#define all(x) x.begin(), x.end()
#define LB(x,v) lower_bound(all(x),v) - x.begin()
#define maxn (int)(1e5)
using namespace std;

ui64 lcm(ui64 a, ui64 b){
	return a/__gcd(a,b)*b;
}
ui64 cnt(ui64 L, ui64 R, ui64 val){
	return R/val - (L-1)/val;
}

int main() {
	// your code goes here
	
	ui64 A,B,C,D, total;
	scanf("%llu %llu %llu %llu",&A,&B,&C,&D);
	
	total = B - A + 1;
	ui64 nC = cnt(A,B, C); 
	ui64 nD = cnt(A,B, D); 
	ui64 nCD = cnt(A,B, lcm(C,D));
	ui64 ans = total-(nC+nD-nCD);
	printf("%llu\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#define ll long long 
using namespace std;
const int maxn = 2e5 + 100;
ll a[maxn];

int main()
{
	int N; cin >> N;
	for (int i = 1; i <= N; i++)
	{
		cin >> a[i]; a[i] -= i;
	}
	sort(a + 1, a + 1 + N);
	ll k = N / 2 + 1;
	ll ans = 0;
	for (int i = 1; i <= N; i++)
	{
		ans += abs(a[k] - a[i]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1920
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define ff               first
#define ss               second
#define pb               push_back
#define all(x)           (x).begin(), (x).end()
#define mem0(x)          memset(x, 0, sizeof (x))
#define mem1(x)          memset(x, -1, sizeof (x))

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector <ii> vii;
typedef vector<vii> vvii;
typedef vector <ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;


vvi g;
int cmp = 0;
vi vis;

void dfs(int u){
    vis[u] = 1;
    for (int v: g[u]) if (!vis[v]) dfs(v);
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T=1, n, m;
    while (T--){
        cin >> n >> m;
        g.assign(n, vi());
        vis.assign(n, 0);
        for (int i = 0; i < m; ++i) {
            int u, v; cin >> u >> v; u--, v--;
            g[u].pb(v);
            g[v].pb(u);
        }
        for (int j = 0; j < n; ++j) {
            if (!vis[j]){
                cmp++;
                dfs(j);
            }
        }
        cout << cmp-1 << "\n";
    }
}

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

int main(void){
    int n,m,x,y; cin >> n >> m >> x >> y;
    vector<int> A(n), B(m);
    for(int i=0; i<n; i++) cin >> A[i]; A.push_back(x);
    for(int i=0; i<m; i++) cin >> B[i]; B.push_back(y);
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());

    bool flg=true;

    if(A[A.size()-1]>=B[0]) flg=false;

    if(flg) cout << "No War" << endl;
    else cout << "War" << endl;
}

Measured memory_bytes: 256
A,B,M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [tuple(map(int, input().split())) for _ in range(M)]

w_mn = 10**9
for x,y,c in xyc:
    w_mn = min(w_mn, a[x-1] + b[y-1] - c)

ans = min(w_mn, min(a) + min(b))
print(ans)


Measured memory_bytes: 83180
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int N,M;
  cin>>N>>M;
  vector<vector<int> > GRAPH (N);
  for (int i = 0; i < M; i++)
  {
    int A,B;cin>>A>>B;
    A--,B--;
    GRAPH[A].push_back(B);
    GRAPH[B].push_back(A);
  }
  int check = 0;
  set<int> SET;
  for (int i = 0; i < GRAPH[N-1].size(); i++)
  {
    SET.insert(GRAPH[N-1][i]);
  }
  
  for (int i = 0; i < GRAPH[0].size(); i++)
  {
    if(GRAPH[N-1].size() == 0)continue;
    if(SET.find(GRAPH[0][i])!= SET.end()) check = 1;
  }
  if(check)
  {
    cout<<"POSSIBLE"<<endl;
  }
  else
  {
    cout<<"IMPOSSIBLE"<<endl;
  }
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 17512
n, k = map(int, input().split())
pl = list(map(int, input().split()))

pl = [(p+1) / 2 for p in pl]
import itertools

pl_ac = [0] + list(itertools.accumulate(pl))

ans = 0
for i in range(len(pl_ac) - k):
    ans = max(ans, pl_ac[i + k] - pl_ac[i])

print(ans)


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

#define INF 0x3f3f3f3f
#define Size 1050
#define pb push_back
#define mp make_pair
#define X first
#define Y second
using namespace std;

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

inline int read()
{
    int x=0, f=1; char ch=getchar();
    while(ch<'0' || ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

deque<int> f;
int main()
{
    int q=read(),k,x,d;
    while (q--)
    {
        k=read();
        if (k==0) {d=read(); x=read(); if (d==0) f.push_front(x); else f.push_back(x);}
        else if (k==1) {x=read(); printf("%d\n",f[x]);}
        else {d=read();if (d==0) f.pop_front(); else f.pop_back();}
    }
    return 0;
}



Measured memory_bytes: 4644
n, m = list(map(int, input().split()))
light = []
for i in range(m):
    k = list(map(int, input().split()))
    aaaaa = [0 for i in range(n)]
    for i in range(k[0]):
        aaaaa[k[i+1] - 1] = 1
    aaaaa = int("".join(map(str, aaaaa)), 2)
    light.append(aaaaa)
p = list(map(int, input().split()))
ans = 0
for i in range(2**n):
    flag = 1
    for j in range(len(light)):
        #print("i{}, j{} light[j] {}".format(i, j, light[j]))
        k = i & light[j]
        if list(bin(k)).count("1") % 2 != p[j]:
            flag = 0
    if flag:
        ans += 1
print(ans)






Measured memory_bytes: 41328
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
const int inf=1e9+7;

int main(){
    int n;cin>>n;
    vin a(n);
    rep(i,n)cin>>a[i];
    vin l(n+1),r(n+1);
    l[0]=0;
    r[n]=0;
    rep(i,n){
        l[i+1]=__gcd(l[i],a[i]);
        r[n-1-i]=__gcd(r[n-i],a[n-1-i]);
    }
    vin ans(n);
    rep(i,n)ans[i]=__gcd(l[i],r[i+1]);
    sort(all(ans),greater<int>());
    cout<<ans[0]<<endl;
}

Measured memory_bytes: 1792
N, C = map(int, input().split())

imos = [0]*(10**5+1)

pgs = []
for _ in range(N):
    s, t, c = map(int, input().split())
    pgs.append((s, t, c))

pgs = sorted(pgs, key=lambda x: (x[2], x[0]))

for i in range(N):
    s, t, c = pgs[i]
    if i >= 1 and pgs[i-1][2] == pgs[i][2] and pgs[i-1][1] == pgs[i][0]:
        imos[s] += 1
        imos[t] -= 1
    else:
        imos[s-1] += 1
        imos[t] -= 1

ans = 0
a = 0
for i in imos:
    a += i
    ans = max(ans, a)

print(ans)


Measured memory_bytes: 68672