akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MX = 100005;
int n,a,b,m,ans[MX];
vector<P> G[MX];
void dfs(int u, int p, int c){
	int cc = 1;
	for(P nx: G[u]) if(nx.first != p){
		if(cc == c) cc++;
		ans[nx.second] = cc;
		dfs(nx.first,u,cc);
		cc++;
	}
}
int main(){
	scanf("%d", &n);
	rep(i,n-1){
		scanf("%d%d", &a, &b); a--; b--;
		G[a].push_back(P(b,i));
		G[b].push_back(P(a,i));
	}
	rep(i,n) m = max(m,(int)G[i].size());
	dfs(0,0,0);
	printf("%d\n", m);
	rep(i,n-1) printf("%d\n", ans[i]);
}

Measured memory_bytes: 9344
#include<bits/stdc++.h>
#define MAXN 100007

int arr[MAXN];

int cul(int a,int b)
{
	if(a % b == 0) return b;
	else return cul(b,a%b);
}

int main()
{
	int n,x; 
	scanf("%d %d",&n,&x);
	for(int i = 0; i < n; i++) 
	{
		int num; 
		scanf("%d",&num);
		arr[i] = abs(num-x);
	}
	if(n == 1) 
	{
		printf("%d\n",arr[0]);
		return 0;
	}
	
	int ans = cul(arr[0],arr[1]);
	for(int i = 2; i < n; i++)
		ans = cul(arr[i],ans);
	
	printf("%d\n",ans);
	return 0;
} 


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

using namespace std;

int main(){
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	long long ans;
	
	ans = b * d;

	// aとbが正の時
	if ( a >= 0) {
		// dが負の時
		if (d < 0) {
			ans = a * d;
		}
		//　dが正の時
		else {
			ans = b * d;
		}
	}

	// aとbが負の時
	else if ( b < 0) {
		// dが負の時
		if ( d < 0) {
			ans = a * c;
		}
		// dが正の時
		else {
			// cが正の時
			if ( c >= 0) {
				ans = c * b;
			}
			// cが負の時
			else {
				ans = a * c;
			}
		}
	}
	// aが負でbが正の時
	else if ( a < 0 && b >= 0) {
		// dが負の時
		if ( d < 0) {
			ans = a * c;
		}
		// dが正の時
		else {
			// cが正の時
			if ( c >= 0) {
				ans = b * d;
			}
			// cが負の時
			else {
				if ( a * c > b * d) {
					ans = a * c;
				}
				else {
					ans = b * d;
				}
			}
		}	
	}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3632
use std::vec::Vec;
use std::cmp;

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 main() {
    let (N, K) = {
      let v: Vec<usize> = read_vec();
      (v[0], v[1])
    };
    let v: Vec<i64> = read_vec();

    let mut res: i64 = 0;

    //左から抜き取る数
    for l in 0..K+1 {

      // 右から抜き取る数
      for r in 0..K - l + 1{
        if l + r > N {
          continue;
        }

        let mut minus: Vec<i64> = Vec::new();
        let mut now = 0;

        // 実際に右から抜き取る
        for i in 0..l {
          now += v[i];
          if v[i] < 0 {
            minus.push(v[i]);
          }
        }

        // 実際に左から抜き取る
        for j in 0..r {
          now += v[N - 1 - j];
          if v[N - 1 - j] < 0 {
            minus.push(v[N - 1 - j]);
          }
        }
        minus.sort();

        // マイナスのものを残りの捜査回数で戻す
        let d: usize = K - l - r;         // 残りの操作回数
        let ub: usize = cmp::min(minus.len(), d);   // 全て戻せるか戻せないかチェック

        for i in 0..ub {
            now -= minus[i];
        }
        res = cmp::max(res, now);
      }
    }

    println!("{}", res);
}


Measured memory_bytes: 4352
import sys
input = sys.stdin.readline


def main():
    _, K = map(int, input().split())
    X = list(map(int, input().split()))

    def fullsearch():
        for l, r in zip(X, X[K-1:]):
            distance = abs(r - l)
            yield distance + abs(r)
            yield distance + abs(l)

    print(min(fullsearch()))

main()

Measured memory_bytes: 14172
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

const int MAX_N=2e5+5;

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

    // for prime mod
    mint inv() const { return pow(MOD-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct DP {
  mint dp;
  DP(mint dp=1, int t=0):dp(dp){}
  DP operator+(const DP& a) const {
    return DP(dp*a.dp);
  }
  DP addRoot() const {
    return DP(dp+1);
  }
};
 
vector<DP> dp[MAX_N];
DP ans[MAX_N];
vector<int> to[MAX_N];

void addedge(int a,int b){
    to[a].push_back(b);
    to[b].push_back(a);
}
 
DP dfs(int v, int p=-1) {
  DP dpSum;
  dp[v] = vector<DP>(to[v].size());
  rep(i,to[v].size()) {
    int u = to[v][i];
    if (u == p) continue;
    dp[v][i] = dfs(u,v);
    dpSum = dpSum + dp[v][i];
  }
  return dpSum.addRoot();
}
void bfs(int v, const DP& dpP=DP(), int p=-1) {
  int deg = to[v].size();
  rep(i,deg) if (to[v][i] == p) dp[v][i] = dpP;
 
  vector<DP> dpLeft(deg+1);
  rep(i,deg) dpLeft[i+1] = dpLeft[i] + dp[v][i];
  
  vector<DP> dpRight(deg+1);
  for (int i = deg-1; i >= 0; --i)
    dpRight[i] = dpRight[i+1] + dp[v][i];
  
  ans[v] = dpLeft[deg].addRoot();
 
  rep(i,deg) {
    int u = to[v][i];
    if (u == p) continue;
    DP d = dpLeft[i] + dpRight[i+1];
    bfs(u, d.addRoot(), v);
  }
}

void reroot(){
    dfs(0);
    bfs(0);
}

int main(void){
    int N,M;
    cin >> N >> M;
    MOD=M;
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--,b--;
        addedge(a,b);
    }
    reroot();
    rep(i,N) cout << ans[i].dp-1 << endl;
}

Measured memory_bytes: 34432
N,M,C=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(N):
    a=list(map(int,input().split()))
    tmp=0
    for j in range(M):
        tmp+=a[j]*b[j]
    if tmp+C>0: ans+=1

print(ans)

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

struct UnionFind {
  vector<int> par, siz;
  UnionFind (int n) {
    par.resize(n), siz.resize(n);
    for (int i = 0; i < n; i++) {
      par.at(i) = i, siz.at(i) = 1;
    }
  }
  int root(int x) {
    if (par.at(x) == x) return x;
    return par.at(x) = root(par.at(x));
  }
  int size(int x) {
    return siz.at(root(x));
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  bool unit(int x, int y) {
    x = root(x), y = root(y);
    if (x == y) return false;
    if (siz.at(x) > siz.at(y)) {
      par.at(y) = x, siz.at(x) += siz.at(y);
    } else {
      par.at(x) = y, siz.at(y) += siz.at(x);
    }
    return true;
  }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, M, K;
  cin >> N >> M >> K;
  UnionFind UF(N);
  vector<int> V(N);
  for (int i = 0, a, b; i < M && cin >> a >> b; i++) {
    UF.unit(--a, --b);
    V.at(a)++;
    V.at(b)++;
  }
  vector<vector<int>> B(N);
  for (int i = 0, c, d; cin >> c >> d; i++) {
    if (UF.same(--c, --d)) {
      V.at(c)++;
      V.at(d)++;
    }
  }
  for (int i = 0; i < N; i++) {
    int ans = UF.size(i);
    ans--;
    ans -= V.at(i);
    cout << ans << "\n"; 
  }
}

Measured memory_bytes: 4352
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let d = read(&mut stdin_lock, &mut buf, b' ');
    println!("{}", solve(d));
}

fn solve(d: u8) -> String {
    if d == 25 {
        "Christmas".to_owned()
    } else if d == 24 {
        "Christmas Eve".to_owned()
    } else if d == 23 {
        "Christmas Eve Eve".to_owned()
    } else if d == 22 {
        "Christmas Eve Eve Eve".to_owned()
    } else {
        unreachable!()
    }
}

#[test]
fn example1() {
    assert_eq!("Christmas", solve(25))
}

#[test]
fn example2() {
    assert_eq!("Christmas Eve Eve Eve", solve(22))
}


Measured memory_bytes: 4352
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long

#define pn          printf("\n")
#define nl          cout<<'\n'
#define sf(N)       scanf("%lld",&N)
#define pf(N)       printf("%lld",N)
#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define Sec     second
#define ALL(V)  V.begin(),V.end()
#define Dup erase(unique(V.begin(),V.end()),V.end())

#define Inf     1000000000000000
#define mod     1000000007
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    string s;
    cin>>s;
    
    lli N=s.length(),i,cnt=0;
    rep(i,0,N)
    {
        if(s[i]=='p')
        {
            cnt++;
        }
    }
    
    cout<<N/2-cnt;
    









 return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <vector>
//#define ivorysi
#define MAXN 100005
#define eps 1e-7
#define mo 974711
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
char s[55],ans[55];
int N,L;
bool vis[55];
bool dfs(int dep) {
	if(dep > 26) return false;
	if(!vis[s[dep] - 'a']) {
		vis[s[dep] - 'a'] = 1;
		ans[dep] = s[dep];
		if(dfs(dep + 1)) return true;
		vis[s[dep] - 'a'] = 0;
	}	
	for(int i = s[dep] - 'a' + 1 ; i <= 25 ; ++i) {
		if(!vis[i]) {
			L = dep;
			ans[dep] = 'a' + i;
			return true;
		}
	}
	return false;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    scanf("%s",s + 1);
    N = strlen(s + 1);
    if(N != 26) {
    	for(int i = 1 ; i <= N ; ++i) vis[s[i] - 'a'] = 1;
    	for(int i = 1 ; i <= N ; ++i) putchar(s[i]);
    	for(int i = 0 ; i <= 25 ; ++i) {
    		if(!vis[i]) {
    			putchar('a' + i);
    			break;
    		}
    	}
    	putchar('\n');
    }
    else {
    	if(!dfs(1)) puts("-1");
    	else {
    		for(int i = 1 ; i <= L ; ++i) putchar(ans[i]);
    		putchar('\n');
    	}
    }
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define per(i, n) for(int i = (n)-1; i >= 0; --i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}

using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s<<'[';for(size_t i=0;i<v.size();++i){s << v[i];if(i < v.size()-1) s << ", ";}s<<']';return s;
}

int main(){

    ll n;
    scanf("%lld", &n);
    ll a, b, c, d;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);

    rep(i, n){
        if(c*(n-1-i)-d*i <= b-a and b-a <= -c*i+(n-1-i)*d){
            YES(); return 0;
        }
    }
    NO();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <string>
#include <string.h>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main (void)
{
	string a;

	cin >> a;

	if (a == "abc" || a == "bac")
	{
		cout << "Yes" << endl;
	}
	else if (a == "cab" || a == "acb")
	{
		cout << "Yes" << endl;
	}
	else if (a == "bca" || a == "cba")
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;
ll powmod(ll a, ll b) { ll res=1; a%=mod; assert(b>=0); for(;b;b>>=1) { if(b&1) res=res*a%mod; a=a*a%mod; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }

int main() {
    int k, a, b;
    cin >> k;
    cin >> a >> b;
    
    int x=a/k, y=b/k;
    if(a % k == 0 || b % k == 0)
        cout << "OK" << endl;
    else if((x+1)*k <= b || (y-1)*k >= a)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define ll long long
#define pai 3.1415926535897932384626433832795028841971693

int main(){
  int x,n,min=100001,ans=0,k;
  scanf("%d %d",&x,&n);
  int p[n],a[n];
  for(int i=0;i<n;i++){
    scanf("%d",&p[i]);
  }

  for(int i=-1;i<201;i++){
    for(int j=0;j<n;j++){
      if(i==p[j]){
        k=1;
        break;
      }
      k=0;
    }
    if(k==1){
      continue;
    }
    else{
      if(min>abs(x-i)){
        min=abs(x-i);
        ans=i;
      }
      else if(min==abs(x-i)){
        if(ans>i){
          ans=i;
        }
      }
    }
  }
  printf("%d",ans);
   return 0;
}

Measured memory_bytes: 1732
import java.io.*
import java.util.*


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }

    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val (x1, y1, x2, y2) = readLine()!!.split(' ').map { it.toInt() }
    val (a, b) = Pair(x2 - x1, y2 - y1)
    val (x3, y3) = Pair(x2 - b, y2 + a)
    val (x4, y4) = Pair(x1 - b, y1 + a)
    println("$x3 $y3 $x4 $y4")
}



Measured memory_bytes: 38252
N, M = map(int, input().split())
h = list(map(int, input().split()))
ma = [0]*N
for i in range(M):
    a, b = map(int,input().split())
    ma[a-1] = max(ma[a-1],h[b-1])
    ma[b-1] = max(ma[b-1],h[a-1])
ans = 0
for a in range(N):
    if h[a] > ma[a]:
        ans = ans + 1
print(ans)

Measured memory_bytes: 20012
//From Naruto to Hokage
//#include <RJ>
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
#define A 0
#define C 1
#define G 2
#define T 3
void solve(){
    ll n;
    cin>>n;
    ll dp[n+1][4][4][4];
    memset(dp,0,sizeof(dp));
    rep(i,0,3) rep(j,0,3) rep(k,0,3) dp[3][i][j][k]=1;
    dp[3][A][G][C]=dp[3][A][C][G]=dp[3][G][A][C]=0;
    rep(l,4,n){
        rep(i,0,3) {
            rep(j,0,3) {
                rep(k,0,3){
                    rep(m,0,3){
                        if((i==A && j==G  && m==C) ||(i==A && k==G  && m==C)) continue;
                        dp[l][j][k][m]=(dp[l][j][k][m]+dp[l-1][i][j][k])%hell;
                    }
                }
            }   
        }
        dp[l][A][G][C]=dp[l][A][C][G]=dp[l][G][A][C]=0;
    }
    ll ans=0;
    rep(i,0,3) rep(j,0,3) rep(k,0,3) ans=(ans+dp[n][i][j][k])%hell;
    cout<<ans;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<long long, long long> P;
typedef long long ll;
class LazySegTree
{
    int n;
    vector<long long int> node, lazy;

public:
    LazySegTree(vector<long long int> v)
    {
        int s = int(v.size());
        n = 1;
        while (n < s)
        {
            n <<= 1;
        }
        node.resize(2 * n - 1,1e18);
        lazy.resize(2 * n - 1, 1e18);

        for (int i = 0; i < s; i++)
        {
            node[i + n - 1] = v[i];
        }
        for (int i = n - 2; i >= 0; i--)
        {
            node[i] = min(node[i * 2 + 1],node[i * 2 + 2]);
        }
    }
    
    void eval(int k, int l, int r)
    {
        if (lazy[k]<1e18)
        {
            node[k] = min(node[k],lazy[k]);
            if (r - l > 1)
            {
                lazy[2 * k + 1] = min(lazy[k], lazy[2 * k + 1]);
                lazy[2 * k + 2] = min(lazy[k], lazy[2 * k + 2]);
            }
            lazy[k] = 1e18;
        }
    }

    void add(int a, int b, long long int x, int k = 0, int l = 0, int r = -1)
    {
        if (r < 0)
            r = n;
        eval(k, l, r);
        if (b <= l || r <= a)
        {
            return;
        }
        if (a <= l && r <= b)
        {
            lazy[k] = min(lazy[k],x);
            eval(k, l, r);
        }
        else
        {
            add(a, b, x, 2 * k + 1, l, (l + r) / 2);
            add(a, b, x, 2 * k + 2, (l + r) / 2, r);
            node[k] = node[2 * k + 1] + node[2 * k + 2];
        }
    }

    long long int rangeMin(int a, int b, int k = 0, int l = 0, int r = -1)
    {
        if (r < 0)
            r = n;
        eval(k, l, r);
        if (b <= l || r <= a)
        {
            return 1e18;
        }
        if (a <= l && r <= b)
        {
            return node[k];
        }
        long long int vl = rangeMin(a, b, 2 * k + 1, l, (l + r) / 2);
        long long int vr = rangeMin(a, b, 2 * k + 2, (l + r) / 2, r);
        return min(vl,vr);
    }

    void set(int a, long long int x)
    {
        add(a, a + 1, x);
    }

    long long int get(int a)
    {
        return rangeMin(a, a + 1);
    }
};
vector<P> v[100100];
int main()
{
    int n,m;
    cin >> n>>m;
    vector<long long int> as(n+10,1e18);
    LazySegTree seg(as);
    seg.set(0,0);
    for (int i = 0; i < m; i++)
    {
        int l,r,c;
        cin >> l >> r >> c;
        v[l].push_back(P(r,c));
    }
    for(int i=1;i<=n;i++){
        ll val = seg.get(i-1);
        for(auto j:v[i]){
            seg.add(i,j.first,val+j.second);
        }
    }
    if(seg.get(n-1)==1e18){
        cout << -1 << endl;
        return 0;
    }
    cout << seg.get(n-1) << endl;
}

Measured memory_bytes: 10508
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 六  4/28 20:27:31 2018
 * Ended  Time*  : 六  4/28 21:13:04 2018
*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 600;

char a[MAXN+5][MAXN+5];
int n, ans;

void Init(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%s", a[i] + 1);
	/*
	n = 300;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			a[i][j] = 'a';
		}
	}
	*/
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++) a[i][j+n] = a[i][j];
	for(int j = 1; j <= 2*n; j++)
		for(int i = 1; i <= n; i++) a[i+n][j] = a[i][j];
}

bool check(int x, int y){
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(a[x+i][y+j] != a[x+j][y+i]) return false;
		}
	}
	return true;
}


int main()
{
	Init();
	for(int k = 1-n; k <= n - 1; k++){
		int x, y;
		if(k <= 0) {
			y = 1;
			x = y-k;
		}
		else{
			x = 1;
			y = k + x;
		}
		bool flag = true;
		while(x <= n && y <= n){
			if(flag && x != 1 && y != 1) {
				for(int i = 0; i < n; i++){
					if(a[x+n-1][y+i] != a[x+i][y+n-1]){
						x += i+1;
						y += i+1;
						flag = false;
					}
				}
			}
			else{
				flag = true;
				for(int i = 0; i < n && flag; i++){
					for(int j = 0; j < n && flag; j++){
						if(a[x+i][y+j] != a[x+j][y+i]){
							x += i+1;
							y += i+1;
							flag = false;
						}
					}
				}
			}
			if(flag){
				ans++;
				x++, y++;
			}
		}
	}
	printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define fo(i,n)         for(i=0;i<n;i++)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << "," << #y << "=" << y << endl
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int N = 3e5, M = N;
//=======================

vi g[N];

void solve() {
	int i, j, n, m;
	cin >> n;
	int a[n];
	fo(i, n) cin >> a[i];
	int prefix_s[n];
	fo(i, n) {
		prefix_s[i] = a[i] % mod;
		if (i != 0) prefix_s[i] = (prefix_s[i] % mod + prefix_s[i - 1] % mod) % mod;
	}
	int ans = 0;
	Fo(i, 1, n) {
		// deb2(i, ans);
		ans = ((ans % mod) + ((a[i] % mod) * (prefix_s[i - 1] % mod)) % mod) % mod;
		// ans += a[i] * prefix_s[i - 1];
		// deb2(i, ans);

	}
	cout << ans << "\n";
}

int32_t main()
{
	FIO;
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	solve();
	return 0;
}

void ipgraph(int n, int m) {
	int i, u, v;
	while (m--) {
		cin >> u >> v;
		u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par) {
	for (int v : g[u]) {
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 13796
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define N 200005
#define pi 3.14159
#define in insert
#define pb push_back
#define mp make_pair
#define F first
#define pf push_front
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res='1'; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/='2'; } return res;}
ll exp(ll x,ll y){ ll res='1'; while(y) {if(y%2) res=(res*x); x=(x*x); y/='2'; } return res;}



int main(){
    ll r; cin>>r;
    cout<<2*pi*r;
    return 0;
}
 


Measured memory_bytes: 3748
//#include"pch.h"
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<algorithm>

int main() {

	int A, B, C;

	scanf("%d %d %d", &A, &B, &C);

	printf("%d", A*B / 2);


	return(0);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    ios::sync_with_stdio(false);
    int s; cin >>s;
    int h=s/3600;
    int m=(s-h*3600)/60;
    int se=s-h*3600-m*60;
    cout << h<<":"<<m<<":"<<se<<endl;
    return 0;
}


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

void solve(){
	int h1, h2, m1, m2, k;
   cin>>h1>>m1>>h2>>m2>>k;
   int tot, dur;
   tot=h1*60+m1;
   dur=(h2*60+m2)-tot;
   cout<<max(0, dur-k)<<endl;
}
int main() 
{ 
   ios_base::sync_with_stdio(false);
   cin.tie(NULL); 
   #ifndef ONLINE_JUDGE 
   freopen("../input.txt", "r", stdin);
   freopen("../output.txt", "w", stdout); 
   #endif
   solve();
   return 0; 
}

Measured memory_bytes: 3652
#include <iostream>
#include <cassert>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main(void)
{
    bool result = true;
    int cnt;
    string w;
    cin >> w;
    for (int i = 0; i < 26; i++)
    {
        cnt = 0;
        for (int j = 0; j < w.length(); j++)
        {
            if (w[j] == 'a' + i)
            {
                cnt++;
            }
        }
        if (cnt % 2 == 1)
        {
            result = false;
        }
    }

    if (result == true)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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



int main(){
	
	int N;
	cin>>N;
	
	string S;
	cin>>S;
	
	for(int i=0;i<S.size();i++){
		int k = S[i]-'A';
		k += N;
		k %= 26;
		S[i] = (char)('A'+k);
	}
	
	cout<<S<<endl;
	
	return 0;
	
}


Measured memory_bytes: 256
program V1505;
 var
  i,j,u,u1,s1,t1:longint;
  s,t,sp,sk:string;
 begin
  readln(s);
  readln(t);
  s1:=length(s);
  t1:=length(t);
  u:=0;
  sp:='';
  for i:=1 to s1-t1+1 do
   begin
    u1:=0;
    for j:=1 to t1 do
     if (s[i+j-1]<>'?') and (s[i+j-1]<>t[j]) then
      begin
       u1:=1;
       break;
      end;
    if u1=0 then
     begin
      sk:=s;
      for j:=1 to t1 do
       sk[i+j-1]:=t[j];
      for j:=1 to s1 do
       if sk[j]='?' then sk[j]:='a';
      if (sp='') or (sk<sp) then sp:=sk;
     end;
   end;
  if sp='' then writeln('UNRESTORABLE')
           else writeln(sp);
 end.


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int x, a;
    cin >> x >> a;
    if (x < a)
        cout << 0 << "\n";
    else
        cout << 10 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
long long a,b,v,w,t;
long long Abs(long long x){return x<0?-x:x;}
int main()
{
	cin>>a>>v>>b>>w>>t;
	if(Abs(a-b)<=(v-w)*t)cout<<"YES";
	else cout<<"NO";
}

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

int main() {

  string S;
  cin >> S;

  char current = S[0];
  int answer = 0;

  for (int i = 1; i < S.size(); i++) {
    if (current != S[i]) {
      current = S[i];
      answer++;
    }
  }

  cout << answer << endl;
  
  return 0;

}

Measured memory_bytes: 512
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 100005
#define INF (ll)1e18
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define vv vector
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); //cout.tie(0);
#define pi 3.1415926535897
#define db long double  /* print with %Lf */
#define EPS 1e-9
#define flu fflush(stdout)
#define imp {cout<<"0\n"; return 0;}
#define yup {cout<<"YES\n"; return 0;}
#define debug_vec(vec,n) {rep(idxi,n) cout<<vec[idxi]<<" "; cout<<"\n";}
#define debug_pvec(vec,n) {rep(idxi,n) cout<<vec[idxi].fi<<"-"<<vec[idxi].se<<"  "; cout<<"\n";}
#define debug_set(seta) {cout<<seta.size()<<"\n"; for(auto idxi:seta) cout<<idxi<<" "; cout<<"\n";}
#define debug_map(mappa) {cout<<mappa.size()<<"\n";for(auto idxi:mappa) cout<<idxi.fi<<"-"<<idxi.se<<"  "; cout<<"\n";}
#define debug_vecvec(vec,n) {rep(idxi,n) {for(auto idxi2:vec[idxi]) cout<<idxi2<<" "; cout<<"\n";}}
 
// LOOK AT THESE BEFORE SUBMISSION
// LOOK AT THESE BEFORE SUBMISSION
// ============================================================
// Nmax value and is index access offset taking it beyond Nmax.
// Precision error in case of real numbers.
// N vs N2 chosen correctly.
// Modulo applied everywhere.
// Flush in case of interactive.
// Don't erase value in multiset.
// Check for array indices out of bound (in pre or suff sums).
// Correct return value for functions.
// Confirm the letter case of yes and no.
// Dont paste code two times in the text file.
// ============================================================

int main() {

    gets(s); gets(t);
    get2(a,b);
    gets(u);
    if(u==s) printf("%lld %lld\n", a-1,b);
    else printf("%lld %lld\n", a,b-1);


    return 0;
}

Measured memory_bytes: 764
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int ll;

using namespace std;


int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
       
    int i,j,k;
    long n,m,tmp;
    int a[100000];
    int num=0;
    string s[200000];

    cin >> n>>k;
    rep(i,n) cin>>a[i];
    rep(i,n){
        if(a[i]>=k){
            num++;
        }
    }


    cout<< num << endl;

    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define ll long long
using namespace std;
char s[105][105];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++) cin>>s[i][j];
    }
    for(int i=0;i<=n+1;i++){
        for(int j=0;j<=m+1;j++){
            if(i==0||j==0||i==n+1||j==m+1) cout<<"#";
            else cout<<s[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef int keytype;

int gcd(int a, int b){ return (a % b) ? gcd(b, a % b) : b;}
int lcm(int a, int b){ return (a / gcd(a, b)) * b;}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

int main(){
    int x;

    scanf("%d", &x);

    if(x == 7 || x == 5 || x == 3) puts("YES");
    else puts("NO");

    return 0;
}


Measured memory_bytes: 1612
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) ((a).begin(), (a).end())
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1010101010;
// using Graph = vector<vector<int>>;
const int MOD = 1000000007;

int main() {
  double l;
  cin >> l;
  double k = l / 3;
  double t = l - k * 2;
  printf("%.8f\n", k * k * t);
}


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

int main() {
  int K, X;
  cin >> K >> X;
  
  if (500 * K >= X) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll H, W; std::cin >> H >> W;
  if ( H == 1 || W == 1 ) {
    std::cout << 1 << std::endl;
    return 0;
  }
  if ( W % 2 == 0 ) std::cout << H*W/2 << std::endl;
  else {
    ll ans = H*(W/2);
    if ( H % 2 == 0 ) ans += H/2;
    else ans += H/2+1;
    std::cout << ans << std::endl;
  }
  return 0;
}



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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  string s, t;
  cin >> s;
  for (char c : s) {
    switch (c) {
    case '0':
      t += '0';
      break;
    case '1':
      t += '1';
      break;
    case 'B':
      if (!t.empty()) t.pop_back();
      break;
    }
  }
  cout << t << endl;
}


Measured memory_bytes: 256
#include<cstdio>
int n,a[200010];
inline int read(){ 
    register int ret=0;char c=getchar();
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')ret=(ret<<1)+(ret<<3)+(c^48),c=getchar();
    return ret;
}
int main()
{
    n=read();
    for(int i=1;i<=n;++i)a[i]=read();
    for(int i=n;i>0;i-=2)printf("%d ",a[i]);
    for(int i=(n&1)+1;i<=n;i+=2)printf("%d ",a[i]);
    return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <queue>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    ll dp[86];
    dp[0] = 2;
    dp[1] = 1;
    for (int i = 2; i <= 86; i++)
    {
        dp[i] = dp[i-1] + dp[i-2];
    }

    cout << dp[n] << endl;
}

Measured memory_bytes: 256
//#define CCF
#define OLD

#ifndef CCF
    #pragma comment(linker, "/STACK:102400000,102400000")
    #ifdef OLD
        #pragma GCC diagnostic error "-std=c++11"
    #endif
    #pragma GCC optimize ("O3")
    #pragma GCC -mcmodle=large
#endif

#include<bits/stdc++.h>
using namespace std;

int n,m,ans,a[100005],f[100005];

int getf(int o) {
    if (f[o]==o) return o;
    else return f[o]=getf(f[o]);
}

void merge(int v,int u) {
    int t1,t2;
    t1=getf(v);
    t2=getf(u);
    if (t1!=t2) f[t2]=t1;
    return;
}

void find(int v,int u) {
    int t1,t2;
    t1=getf(v);
    t2=getf(u);
    if (t1==t2) ++ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	for(register int i=1;i<=n;++i) cin>>a[i],f[i]=i;
	for(register int i=1;i<=m;++i){
		int x,y;
		cin>>x>>y;
		merge(x,y);
	}
	for(register int i=1;i<=n;++i) find(a[i],i);
	cout<<ans;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	double N;
	cin >> N;
	vector<double>x(N);
	vector<string>u(N);

	for (int i = 0; i < N; i++)
	{
		cin >> x[i] >> u[i];
	}
	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		if (u[i] == "BTC") {
			x[i] = x[i] * 380000.0;
		}
		sum += x[i];
	}
	cout << fixed << setprecision(5) << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<iterator>
#include<iostream>
#include<sstream>
#include<cctype>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<list>
#include<stack>
#include<functional>
#include<utility>
#include<numeric>
#include<bitset>
#include<iterator>
#define INF (int)1e9
#define MOD 1000000007
#define tr(c, it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define debug(x) cout<<#x" = "<<(x)<<endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz size
#define ll long long
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MEM(a, b) memset(a, (b), sizeof(a))
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?"\n":" ")
#define printv(a) printa(a,0,a.size())
#define print2d(a,r,c) for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?"\n":" ")
#define PRE(i, m, n, in) for(int (i)=(m);(i)<(n);i+=in)
#define RFOR(i, n) for(int i=n ; i>=0 ; i--)
#define RPRE(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define ERS(A, P) A.erase(A.begin() + P)
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define INS(A, P, B) A.insert(A.begin() + P, B)
#define rev(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define grtsrt(v) sort(v.begin(),v.end(),greater<int>())
#define mnv(v) *min_element(v.begin(),v.end())
#define mxv(v) *max_element(v.begin(),v.end())
#define countv(v,a) count(v.begin(),v.end(),a)
#define toint(a) atoi(a.c_str())
using namespace std;
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
typedef vector <int> VI;
typedef vector <ll> VL;
typedef vector<string> VS;
typedef vector <VS> VSS;
typedef vector <II> VII;
typedef vector <LL> VLL;
typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VII> VVII;
typedef vector <VLL> VVLL;
typedef map<int,int> MPII;
typedef map<ll,ll> MPLL;
typedef map<string, int>MPSI;
typedef map<string, ll>MPSL;
typedef map<int, string>MPIS;
typedef map<ll, string> MPLS;
typedef map<string, string> MPSS;
typedef set<int> SETI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.txt", "r", stdin);
    int a, b; cin >> a >> b;
    cout << max(2*a - 1, max(2*b - 1, a + b)) << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;


// 2011/10/23

// 0134 oû²¸
public class Main {

	// C return falseÅ¨µÜ¢
	boolean main() throws IOException {

		int size = 0;
		try {
			size = readIntArray()[0];
		} catch(Exception e) {
			return false;
		}
		
		long sum = 0;
		for(int i = 0; i < size; i++) {
			sum += readIntArray()[0];
		}
		System.out.printf("%d\n", sum / size);
		
		return false;
		//return true; // ³íI¹ Ö
	}
	

//	private final static boolean DEBUG = true;  // debug
	private final static boolean DEBUG = false; // release

	public static void main(String[] args) throws IOException {

		if (DEBUG) {
			log = System.out;
			
			String inputStr = "1:15:";

			inputStr = inputStr.replace(":", "\n");

			reader = new BufferedReader(new StringReader(inputStr)); 

		}
		else {
			log = new PrintStream(new OutputStream() { public void write(int b) {} } ); // «ÌÄ
			reader = new BufferedReader(new InputStreamReader(System.in)); // R\[©ç
		}
		
		int N = Integer.MAX_VALUE;
		//int N = readIntArray()[0];

		for(int i = 0; i < N; i++) {
			boolean b = new Main().main();
			if (!b)
				break;
		}		
		
		reader.close();
	}

	
	static PrintStream log;
	static BufferedReader reader;
	

	// WüÍæè1sªÌæØè¶æØèÅÌ®lðÇÞ
	// EOFÌêÍnullðÔ·
	private static int[] readIntArray() throws IOException {

		String s = null;
		for(;;) {
			s = reader.readLine();
//			log.printf("%s\n", s);
			if (s == null)
				return null;
			s = s.trim();
			if (s.length() != 0) // ¦¦¦@Ç¤àËRósðÇÞ±Æª éBÇÝòÎ·Æ¤Ü­¢­çµ¢BBBB
				break;
		}
		
		String[] sp = s.split("[ ,]"); // æØè¶ÍXy[X©J}
		int[] a = new int[sp.length];
		for(int i = 0; i < sp.length; i++) {
			a[i] = Integer.parseInt(sp[i]);
		}
		return a;
	}
		
}

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int b1 = sc.nextInt(), b2 = sc.nextInt(), b3 = sc.nextInt();
		
		if(b1 == 1 && b2 == 1 || b3 == 1){
			System.out.println("Open");
		}else{
			System.out.println("Close");
		}
		
		sc.close();
	}
}

Measured memory_bytes: 17320
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}

int main() {
    string o,e;
    cin >> o >> e;
    string s;
    rep(i,o.size()) {
            s+=o[i];
            if (e.size() == i) {
                break;
            }
            s+=e[i];
    }
    cout << s << "\n";
}

Measured memory_bytes: 256