akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

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

	for(int i=0; i<n; i++){
		cin >> a >> b >> c;
		
		if(a*a==b*b+c*c){
			cout << "YES" << endl;
		}	
		else if(b*b==a*a+c*c){
			cout << "YES" << endl;
		}
		else if(c*c==a*a+b*b){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1156
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A,P,ans;
    A = sc.nextInt();
    P = sc.nextInt();
    A*=3;
    A+=(P%2);
    ans = (A/2)+(P/2);
    System.out.println(ans);
  }
}


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

using namespace std;

int main(){
    long long int W,H,x,y;
    cin >> W >> H >> x >> y;

    int cnt = 0;
    if(x == W / 2.0 && y == H / 2.0){ cnt = 1; }
    cout << (W * H) / 2.0 << " " << cnt;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  ll n;
  cin>>n;
  if(n==1){
    cout<<0<<endl;
    return 0;
  }
  map<ll,ll> memo;
  ll m=n;
  for(int i=2;i<=sqrt(n);i++){
    if(m%i==0){
      while(m%i==0){
        m/=i;
        memo[i]++;
      }
    }
  }
  if(m!=1) memo[m]++;
  int ans=0;
  for(auto itr=memo.begin();itr!=memo.end();itr++){
    ll p=itr->second;
    for(int i=1;;i++){
      if(p>=i*(i+1)/2 and p<(i+1)*(i+2)/2){
        ans+=i;
        break;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
//setprecision(12)
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
#define pll pair<ll,ll>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b , c, k; cin >> a >> b >> c >> k;
    while(a>=b) {
        b*=2;
        k--;
    }
    while(b>=c) {
        c*=2;
        k--;
    }
    if(k>=0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3648
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }

int main() {
	ll N, K;
	cin >> N >> K;
	vec<ll> x(N);
	REP(i, N)cin >> x[i];

	ll ans = numeric_limits<ll>::max();
	for (int l = 0; l + K - 1 < N; ++l) {
		ll r = l + K - 1;
		ans = min(ans, abs(x[l]) + x[r] - x[l]);
		ans = min(ans, abs(x[r]) + x[r] - x[l]);
	}

	OUT(ans);
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {

	long long int N=0,sum=0;

	int i=0;
	
	scanf("%lld",&N);
	
	for(i=1;i<=N;i++){
		
		if(i % 3 != 0 && i % 5 != 0){
			sum += i;
		}
	}
	
	printf("%lld", sum);


	return 0;
}



Measured memory_bytes: 1732
N = gets.to_i
$board = 2.times.map { gets.split.map(&:to_i) }

def dfs(i, j, score)
  score += $board[i][j]
  if i == 1 && j == N - 1
    return score
  end
  if i == 0
    if j < N - 1
      [
        dfs(i, j + 1, score),
        dfs(i + 1, j, score)
      ].max
    else
      dfs(i + 1, j, score)
    end
  else
    dfs(i, j + 1, score)
  end
end
ans = dfs(0, 0, 0)
puts ans


Measured memory_bytes: 1788
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

func abs(i int) int {
	if i < 0 {
		i = i * -1
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	k, n := nextInt(), nextInt()
	var maxLoad int
	var firstHome = nextInt()
	var preHome = firstHome

	for i := 1; i <= n-1; i++ {
		nowHome := nextInt()
		load := nowHome - preHome
		if maxLoad <= load {
			maxLoad = load
		}
		preHome = nowHome
	}
	topLoad := (k - preHome) + firstHome
	if maxLoad <= topLoad {
		maxLoad = topLoad
	}
	fmt.Println(k - maxLoad)
}


Measured memory_bytes: 3392
n = int(input())
a = []
for i in range(2):
    l = list(map(int, input().split()))
    a.append(l)
dp = [[0 for i in range(n)] for j in range(2)]
dp[0][0] = a[0][0]
dp[1][0] = dp[0][0] + a[1][0]
for i in range(1, n):
    dp[0][i] += dp[0][i-1] + a[0][i]
for i in range(1, n):
    if dp[1][i-1] > dp[0][i]:
        dp[1][i] += dp[1][i-1] + a[1][i]
    else:
        dp[1][i] += dp[0][i] + a[1][i]
print(dp[1][n-1])

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
const long double pi = acos(-1.0);
typedef long long LL;
const LL maxn = 400050;
struct P{
	LL x,y;
	bool operator < (const P &t) const{
		return x<t.x;
	}
}p[maxn];
LL h[maxn],Hash[maxn];
LL c[maxn];
long double Ans;
#define lowbit(x) ((x & (-x)))
void update(LL x,LL val){
	for (;x<=Hash[0];x+=lowbit(x)){
		c[x] = max(c[x],val);
	}
}
LL get(LL x){
	LL ans = -0x3fffffff;
	for (;x>0;x-=lowbit(x)){
		ans = max(ans,c[x]);
	}
	return ans;
}
LL find(LL x){
	LL L = 1,R = Hash[0];
	while (L <= R){
		LL mid = (L + R) >> 1;
		if (Hash[mid] > x){
			R = mid-1;
		} else
		if (Hash[mid] < x){
			L = mid+1;
		} else
			return mid;
	}
	return -1;
}
LL X1,Y1,X2,Y2;
LL dp[maxn],n;
void solve1(){
	//从左上角到右下角
	LL tmp = Y1;
	Y1 = Y2;
	Y2 = tmp;
	scanf("%lld",&n);
	h[0] = 0;
	h[++h[0]] = Y1;
	h[++h[0]] = Y2;
	for (LL i=1;i<=n;i++){
		scanf("%lld%lld",&p[i].x,&p[i].y);
		if (p[i].x<X1 || p[i].x>X2 || p[i].y<Y1 || p[i].y>Y2){
			i--;
			n--;
			continue;
		}
		p[i].y = (Y2-Y1)-(p[i].y-Y1)+Y1;
		h[++h[0]] = p[i].y;
	}
	sort(h+1,h+1+h[0]);
	Hash[0] = 0;
	for (LL i=1;i<=h[0];i++){
		if (i == 1 || h[i]!=h[i-1])
			Hash[++Hash[0]] = h[i];
	}
	for (LL i=1;i<=Hash[0];i++) c[i] = -0x3fffffff;
	sort(p+1,p+1+n);
	dp[0] = 0;
	update(find(Y1),0);
	for (LL i=1;i<=n;i++){
		tmp = find(p[i].y);
		dp[i] = get(tmp) + 1;
		update(tmp,dp[i]);
	}
	LL t = get(find(Y2));
	Ans = (abs(X1-X2)+abs(Y1-Y2)) * 100 - 20 * t + t * pi * 5;
	if (t == abs(Y1-Y2)+1 || t == abs(X1-X2)+1) Ans = Ans + pi * 5.0;
	printf("%.20Lf\n",Ans);
}
 
void solve2(){
	//从左下角到右上角 
	scanf("%lld",&n);
	h[0] = 0;
	h[++h[0]] = Y1;
	h[++h[0]] = Y2;
	for (LL i=1;i<=n;i++){
		scanf("%lld%lld",&p[i].x,&p[i].y);
		if (p[i].x<X1 || p[i].x>X2 || p[i].y<Y1 || p[i].y>Y2){
			i--;
			n--;
			continue;
		}
		h[++h[0]] = p[i].y;
	}
	sort(h+1,h+1+h[0]);
	Hash[0] = 0;
	for (LL i=1;i<=h[0];i++){
		if (i == 1 || h[i]!=h[i-1])
			Hash[++Hash[0]] = h[i];
	}
	for (LL i=1;i<=Hash[0];i++) c[i] = -0x3fffffff;
	sort(p+1,p+1+n);
	dp[0] = 0;
	update(find(Y1),0);
	for (LL i=1;i<=n;i++){
		LL tmp = find(p[i].y);
		dp[i] = get(tmp) + 1;
		update(tmp,dp[i]);
	}
	LL t = get(find(Y2));
	Ans = (abs(X1-X2)+abs(Y1-Y2)) * 100.0 - 20.0 * t + t * pi * 5.0;
	if (t == abs(Y1-Y2)+1 || t == abs(X1-X2)+1) Ans = Ans + pi * 5.0;
	printf("%.20Lf\n",Ans);
}
 
void solve3(){
	scanf("%lld",&n);
	Ans = (max(Y1,Y2) - min(Y1,Y2)) * 100.0;
	for (LL i=1;i<=n;i++){
		LL x,y;
		scanf("%lld%lld",&x,&y);
		if ((x == X1) && (y >= min(Y1,Y2) && y<=max(Y1,Y2))){
			Ans = Ans - 10 * 2 + 10.0 * pi;
		}
	}
	printf("%.20Lf\n",Ans);
}
 
void solve4(){
	scanf("%lld",&n);
	Ans = (max(X1,X2) - min(X1,X2)) * 100.0;
	for (LL i=1;i<=n;i++){
		LL x,y;
		scanf("%lld%lld",&x,&y);
		if ((y == Y1) && (x >= min(X1,X2) && x<=max(X1,X2))){
			Ans = Ans - 10 * 2 + 10 * pi;
		}
	}
	printf("%.20Lf\n",Ans);
}
 
int main(){
	scanf("%lld%lld%lld%lld",&X1,&Y1,&X2,&Y2);
	if (X1>X2){
		LL tmp;
		tmp = X1;X1 = X2;X2 = tmp;
		tmp = Y1;Y1 = Y2;Y2 = tmp;
	}
	if (X1 == X2){
		solve3();
		return 0;
	}else
	if (Y1 == Y2){
		solve4();
		return 0;
	}
	if (Y1 > Y2){
		solve1();
		return 0;
	} else{
		solve2();
		return 0;
	}
}


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

using namespace std;

int main(void)
{
	int n, m;
	cin >> n >> m;


	vector<int> x(m);
	vector<int> xx(m-1);
	for (int i = 0; i < m; i++) {
		cin >> x[i];
	}

	if (m == 1) { cout << 0 << endl; return 0; }

	sort(x.begin(), x.end());
	for (int i = 0; i < m-1; i++) {
		xx[i] = x[i+ 1] - x[i];
	}

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

	long long summ = 0;
	for (int i = 0; i < n-1 ; i++) {
		summ += xx.back();
		xx.pop_back();
		if (xx.empty() == true) { break; }
	}
	cout << x[m-1]-x[0]-summ << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  string S;
  cin>>S;
  int ans=0,sc=0;
  for(auto c:S){
    if(c=='S'){
      sc++;
      ans++;
    }else{
      if(sc>0){
        ans--;
        sc--;
      }else{
        ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main() {
    string s;
    cin >> s;
    vector<int> cnt(2, 0);
    for (int i = 0; i < s.size(); ++i) ++cnt.at(s.at(i) - '0');
    printf("%d\n", min(cnt.front(), cnt.back()) * 2);
    return 0;
}


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

using namespace std;
#define rep(i,n) for (int i = 0; i < n; i++)
#define ll long long
#define vl vector<ll>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

int main(){
  int n, p; cin >> n >> p;
  string s; cin >> s;
  ll ans = 0;
  // s[i] = (i桁目の数) となると嬉しいので逆順に
  reverse(s.begin(),s.end());

  // 例外処理
  if(p == 2 || p == 5){
    rep(i,n) {
      int num = s[i]-'0';
      if(num%p == 0){
        // i 桁目の数が p で割り切れるなら、それを先頭にした連続部分列は全部 p で割り切れる
        ans += n-i;
      }
    }
    cout << ans << endl;
    return 0;
  }

  vl a(n);
  ll mul = 1;
  rep(i,n) {
    int num = s[i]-'0';
    a[i] = (num * mul) % p;
    mul = (mul * 10) % p;
  }

  vl sum(n+1);
  rep(i,n) sum[i+1] = (sum[i] + a[i]) % p;
  map<int,int> C;
  rep(i,n+1) {
    ans += C[sum[i]];
    C[sum[i]]++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3972
S=input()
S.split()
if S[0]==S[1]:
    if S[2]==S[3]:
        if not S[1]==S[3]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
elif S[0]==S[2]:
    if S[1]==S[3]:
        if not S[1]==S[2]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

elif S[0]==S[3]:
    if S[2]==S[1]:
        if not S[0]==S[2]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3064
def bubble_sort(c,n)
	for i in 0..n-1
		(i+1..n-1).reverse_each do |j|
			if c[j].to_s[1].to_i < c[j-1].to_s[1].to_i
				c[j],c[j-1] = c[j-1],c[j]
			end
		end
	end
	puts c.join(" ")
	puts "Stable"
end

def selection_sort(c,n)
	array = c.clone
	
	for i in 0..n-1
		minj = i
		for j in i..n-1
			if c[j].to_s[1].to_i < c[minj].to_s[1].to_i
				minj = j
			end
		end
		c[i],c[minj] = c[minj],c[i]
	end
	puts c.join(" ")

	flg = 1
	for i in 0..n-2
		if c[i].to_s[1].to_i == c[i+1].to_s[1].to_i
			for j in 0..n-1
				if array[j]==c[i]
					break
				elsif array[j]==c[i+1]
					flg = 0
					break
				end
			end
		end
	end
	
	if flg == 1
		puts "Stable"
	else
		puts "Not stable"
	end
end

n = gets.chomp.to_i
c = gets.chomp.split(" ")

bubble_sort(c.clone,n)
selection_sort(c.clone,n)

Measured memory_bytes: 8788
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int X[100010];

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

	int N, K;
	cin >> N >> K;
	rep(i, 0, N)
	{
		cin >> X[i];
	}

	int ans = INF;
	rep(i, 0, N - K + 1)
	{
		if (X[i] * X[i + K - 1] < 0)
		{
			chmin(ans, min(abs(X[i]), abs(X[i + K - 1])) * 2 + max(abs(X[i]), abs(X[i + K - 1])));
		}
		else
		{
			chmin(ans, max(abs(X[i]), abs(X[i + K - 1])));
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int N;
ll twopow[20], tenpow[1000000], ninepow;

ll mypow(ll a, ll b) {
  ll tmp;
  ll two;
  ll ans = 1;
  while(b>0) {
    two = 1;
    tmp = a;
    while(2*two<b) {
      two *= 2;
      tmp *= tmp;
      tmp %= mod1;
    }
    b -= two;
    ans *= tmp;
    ans %= mod1;
  }
  return ans;
}

struct SegmentTree {
  vector<pair<ll, ll> > Tree[20];

  void init() {
    for(int i=0;i<20;++i) {
      Tree[i].resize((1<<i));
    }
    for(int i=0;i<N;++i) Tree[19][i] = mp(1, 0);
    ll ten=10;
    for(int pos1=18;pos1>=0;--pos1) {
      for(int pos2=0;pos2<Tree[pos1].size();++pos2) {
        Tree[pos1][pos2].fi = (Tree[pos1+1][2*pos2].fi*ten%mod1+Tree[pos1+1][2*pos2+1].fi)%mod1;
      }
      ten *= ten;
      ten %= mod1;
    }
  }

  void eval(int pos1, int pos2) {
    if(Tree[pos1][pos2].se==0) return;
    if(pos1+1<20) {
      Tree[pos1+1][2*pos2].se = Tree[pos1][pos2].se;
      Tree[pos1+1][2*pos2+1].se = Tree[pos1][pos2].se;
    }
    ll len = twopow[19-pos1];
    Tree[pos1][pos2].fi = Tree[pos1][pos2].se*(tenpow[len]-1)%mod1*ninepow%mod1;
    Tree[pos1][pos2].se = 0;
  }

  void update(int ql, int qr, ll D, int pos1=0, int pos2=0, ll sl=0, ll sr=(1<<19)) {
    eval(pos1, pos2);
    if(qr<=sl || sr<=ql) return;
    if(ql<=sl && sr<=qr) {
      Tree[pos1][pos2].se = D;
      eval(pos1, pos2);
      return;
    }
    update(ql, qr, D, pos1+1, 2*pos2, sl, (sl+sr)/2);
    update(ql, qr, D, pos1+1, 2*pos2+1, (sl+sr)/2, sr);
    ll len = twopow[20-pos1-2];
    ll ten = tenpow[len];
    Tree[pos1][pos2].fi = (Tree[pos1+1][2*pos2].fi*ten%mod1+Tree[pos1+1][2*pos2+1].fi)%mod1;
    return;
  }

  ll find(int ql, int qr, int pos1=0, int pos2=0, int sl=0, int sr=(1<<19)) {
    eval(pos1, pos2);
    if(qr<=sl || sr<=ql) return 0;
    if(ql<=sl && sr<=qr) return (Tree[pos1][pos2].fi*tenpow[N-sr])%mod1;
    return (find(ql, qr, pos1+1, 2*pos2, sl, (sl+sr)/2)+find(ql, qr, pos1+1, 2*pos2+1, (sl+sr)/2, sr))%mod1;
  }

  void check() {
    for(int i=16;i<20;++i) {
      for(int j=0;j<(1<<(i-16));++j) {
        cout<<"("<<Tree[i][j].fi<<","<<Tree[i][j].se<<")"<<" ";
      }
      cout<<endl;
    }
  }
};

int main() {
  for(int i=0;i<20;++i) twopow[i] = mypow(2, i);
  for(int i=0;i<1000000;++i) tenpow[i] = mypow(10, i);
  ninepow = mypow(9, mod1-2);
  int Q;
  cin>>N>>Q;
  SegmentTree tree;
  tree.init();
  ll ans[Q];
  ll L, R, D;
  for(int i=0;i<Q;++i) {
    cin>>L>>R>>D;
    L--;
    tree.update(L, R, D);
    ans[i] = tree.find(0, N);
  }
  for(int i=0;i<Q;++i) cout<<ans[i]<<endl;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }
  int count = 0;
  
  /*for (int i = 1; i < N; i++) {
    count += d[0] * d[i];
  }
  for (int i = 2; i < N; i++) {
    count += d[1] * d[i];
  }*/
  int n = 0;
  for (int n = 0;n < N - 1; n++) {  
    for (int i = n + 1; i < N; i++) {
      count += d[n] * d[i];
    }
  }
  
 cout << count << endl;     
}
 



Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

best_err, best_place = None, None
for i, h in enumerate(H, start=1):
    t = T - 0.006 * h
    err = abs(t - A)
    if best_err is None or err < best_err:
        best_err, best_place = err, i
print(best_place)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, C=0;
  cin >> N;
  vector<int> L(N);
  for (int i=0;i<N;i++) {
    cin >> L.at(i);
  }
  sort(L.begin(),L.end());
  for(int i=0;i<N;i++) {
    for(int j=0;j<N;j++) {
      for(int k=0;k<N;k++) {
        if(L.at(i)<L.at(j)&&L.at(j)<L.at(k)) {
          if(L.at(i)+L.at(j)>L.at(k)) {
            C++;
          }
        }
        else {
          continue;
        }
      }
    }
  }
  cout << C << endl;
}

Measured memory_bytes: 3624
def li():
    return [int(x) for x in input().split()]


INF = 10 ** 60

N, W = li()
L = [li() for i in range(N)]

# 全探索？：全探索は2**NでN=100では間に合わない
# 貪欲法？：貪欲法で常に最もコスパの高い物を入れても、次の一手でめっちゃコスパ悪くなる可能性あるのでダメ
# DP！：同じ重さで複数種類の価値のパターンが出てきた場合、最大価値のパターン以外は切り捨てて良い。

# dp[i][w]: i番目の選択で重さwだった時の最大価値

dp = [[0] * (W+1) for _ in range(N)]
sw, sv = L[0][0], L[0][1]
dp[0][0] = 0
dp[0][sw] = sv
for i in range(1, N):
    cw, cv = L[i][0], L[i][1]
    for w in range(W):
        # 取らない場合
        dp[i][w] = max(dp[i][w], dp[i-1][w])
        # 取る場合
        if w + cw > W:
            continue
        dp[i][w + cw] = max(dp[i][w + cw], dp[i-1][w] + cv)

print(max(dp[N-1]))

Measured memory_bytes: 151576
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int n, k, l[50];
    cin >> n >> k;
    for(int i=0; i<n; i++) cin >> l[i];

    sort(l, l+n);
    reverse(l, l+n);

    int ans = 0;
    for(int i=0; i<k; i++){
        ans += l[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/*
 * aoj/dpl_5_h/main.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int N, K;
void solve() {
  cin >> N >> K;
  if (N>K) {
    cout << 0 << endl;
    return;
  }

  cout << 1 << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;

ll n;
bool check(ll x)
{
    if(x * (x + 1) >= 2 * n)
        return true;
    return false;
}


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

    cin >> n;

    ll x = sqrt(n * 2);
    if(check(x - 1))
        cout << x - 1 << endl;
    else
    if(check(x))
        cout << x << endl;
    else
        cout << x + 1 << endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int build[12][10]={{0}};
 
 int main()
 {
   int N;
   cin>>N;
   while(N--)
   {
     int b,f,r,v;
     cin>>b>>f>>r>>v;
     int i=(b-1)*3+(f-1);
     int j=r-1;
     build[i][j]+=v;          
   }
   for(int i=0;i<12;i++)
   {
     for(int j=0;j<10;j++)
     {
       cout<<" "<<build[i][j];          
     } 
     cout<<endl;
     if((i!=0)&&(i%3==2)) 
     {
       if(i==11) break;
       for(int k=0;k<20;k++) cout<<"#";
       cout<<endl;                     
     }       
   }
   //while(1);
   return 0;
 }
 
 
 

Measured memory_bytes: 3080
// K - Stones
// A. Bacca
#include <bits/stdc++.h>
using namespace std;

int n, k, mm;
vector <int> A;
vector <vector <short int> > Stones;
char res;

void Recibir() {
	int aux;
	cin >> n >> k;
	A.resize(n);
	for (int i=0; i<n; i++) cin >> A[i];
	mm = 100001;
	for (int i=0; i<n; i++) mm = min(mm, A[i]);
	Stones.resize(k+1);
	for (int i=0; i<k+1; i++) Stones[i].assign(2, -1);
}	

int Exec(int lf, int ch) {
	// DP
	if (Stones[lf][ch] != -1) return Stones[lf][ch];
	// Caso base
	if (lf - mm < 0) return Stones[lf][ch] = !ch;
	
	bool flag {false};
	
	// Caso inductivo
	for (int x : A) {
		// Gana
		if (lf - x >= 0) {
			// Gana en el futuro
			if (Exec(lf - x, !ch) == ch) {
				flag = true;
				break;
			}
		}
		// Aun no gana
		else continue;
	}
	
	if (flag) return Stones[lf][ch] = ch;
	else return Stones[lf][ch] = !ch;
}

int main() {
	Recibir();
	cout << (Exec(k, 0) == 0 ? "First" : "Second");
	return 0;
}

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

int main () {
 int a,b,c;
 int cost[6];
 cin >> a >> b >> c;
 cost[0] = abs(b-a)+abs(c-b);
 cost[1] = abs(c-a) + abs(b-c);
 cost[2] = abs(b-a) + abs(a-c);
  cost[3] = abs(c-b) + abs(a-c);
  cost[4] = abs(a-c) + abs(b-a);
  cost[5] = abs(b-c) + abs(a-b);
  int ans = min({cost[0],cost[1],cost[2],cost[3],cost[4],cost[5]});
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
c=list(map(int,input().split()))

dp=[float('inf')]*(n+1)
dp[0]=0
for i in range(n+1):
    if dp[i]==float('inf'):continue
    for j in c:
        if i+j>n:continue
        dp[i+j]=min(dp[i]+1,dp[i+j])
print(dp[-1])


Measured memory_bytes: 7260
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;

int main(){
   int n;cin>>n;
   vector<int> v(n),c(n);
   rep0(i,n){
       cin>>v[i];
   }
   rep0(i,n){
       cin>>c[i];
   }
   int m=0;
   rep0(i,n){
       if(v[i]>c[i]){
           m+=v[i];
           m-=c[i];
     
       }
   }
   cout<<m<<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 ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;

//DONT WASTE YOUR TIME
//prove yourself
//remember....fuck ps&&as hard....show them your are better then them
//Be confident.....dont lose hope.......You can do it.....
//dimaag  khoob h tere meh ....bas concentration ki kami h
//CONCENTRATE
//A,B,C dimaag nhi ...observation h .....zyaada mat sochna unme.....bas observe karna dhyaan se aur implement kar daal jitni jaldi ho sake

//capture it

const ll N= 1e6+55,mod = 1e9+7;

int main() {
 	//freopen("task.in","r",stdin);freopen("task.out","w",stdout);
	string s;
	cin>>s;
	ll c=0;
	if(s[0]=='1')c++;
	if(s[1]=='1')c++;
	if(s[2]=='1')c++;
	cout<<c<<" \n";	

}

Measured memory_bytes: 256
n, m = map(int, input().split())

a=[]
for i in range(n):
  x, y = map(int, input().split())
  a.append(x)
  a.append(y)
  
c=[]
for i in range(m):
  x, y = map(int, input().split())
  c.append(x)
  c.append(y)
  
for i in range(n):
  min = abs(a[2*i]-c[0])+abs(a[2*i+1]-c[1])
  p = 0
  for j in range(1,m):
    d = abs(a[2*i]-c[2*j])+abs(a[2*i+1]-c[2*j+1])
    if d < min:
      min = d
      p = j
  print(p+1)

 

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

using i64 = int64_t;
using u64 = uint64_t;

u64 calc(u64 mask, const u64 n, const vector<pair<u64, u64>> &v){
    u64 sum = 0;
    for(u64 i=0;i<n;++i){
        if((v[i].first|mask) > mask)continue;
        sum += v[i].second;
    }
    return sum;
}

int main(){
    u64 n, k;
    cin >> n >> k;
    vector<pair<u64, u64>> v;
    for(int i=0;i<n;++i){
        u64 a, b;
        cin >> a >> b;
        v.emplace_back(a, b);
    }
    u64 ans = 0;
    for(u64 i=0;(1<<i)<=k;++i){
        if(((1<<i)&k) == 0)continue;
        u64 mask = ((1<<i)-1)|k;
        mask &= ((~0)^(1<<i));
        ans = max(ans, calc(mask, n, v));
    }
    ans = max(ans, calc(k, n, v));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int ans = 0;
        if(n!=1){
            ans = (n * (n - 1))/2;
        }
        if(m!=1){
            ans = ans + (m * (m - 1))/2;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <stdexcept>
#include <cassert>
#include <cmath>
#include <vector>
#include <string>
using namespace std;


long long getHighestScore(vector<long long>& circle, int K) {
  long long ans = -1e18;
  const int L = circle.size();
  long long sum = 0;
  for (int i = 0; i < L; i++) sum += circle[i];

  for (int st = 0; st < L; st++) {
    long long cycleScore = 0;
    for (int k = 1; k <= L; k++) {
      if (k > K) break;
      int j = (st + k - 1) % L;
      cycleScore += circle[j];
      long long recursiveScore = 0;
      if (K - k >= L && sum > 0) {
        long long numRecurse = (K - k) / L;
        recursiveScore = sum * numRecurse;
      }
      ans = max(ans, cycleScore + recursiveScore);
    }
  }

  // debug
  // cout << "circle: ";
  // for (long long c : circle) cout << c << ", ";
  // cout << endl;
  // cout << "ans: " << ans << endl;
  return ans;
}


int main() {
  int N, K;
  cin >> N >> K;

  vector<int> P(N);
  vector<long long> C(N);
  for (int i = 0; i < N; i++) { cin >> P[i]; P[i]--; }
  for (int i = 0; i < N; i++) cin >> C[i];

  long long ans = -1e18;
  vector<bool> visited(N, false);
  for (int i = 0; i < N; i++) {
    if (visited[i]) continue;
    vector<long long> circle;
    int cur = i;
    while (!visited[cur]) {
      circle.push_back(C[cur]);
      visited[cur] = true;
      cur = P[cur];
    }
    ans = max(ans, getHighestScore(circle, K));
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
  int n,i,j,ima=0,kotae=0;
  string s;
  cin>>n;
  cin>>s;
  int a[n],check[10],last[10],tugi[10];
  a[n-1]=0;
  for(i=0;i<10;i++){
    check[i]=0;
    last[i]=0;
    tugi[i]=0;
  }
  for(i=n-1;i>=1;i--){
    if(check[s[i]-'0']==0){
      check[s[i]-'0']=1;
      ima++;
    }
    a[i-1]=ima;
  }
  for(i=0;i<n-2;i++){
    if(last[s[i]-'0']==0){
      last[s[i]-'0']=1;
      for(j=i+1;j<n-1;j++){
        if(tugi[s[j]-'0']==0){
          tugi[s[j]-'0']=1;
          kotae+=a[j];
        }
      }
      for(j=0;j<10;j++){
        tugi[j]=0;
      }
    }
  }
  cout<<kotae;
}

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

#define dump(x) cout << (x) << endl
#define Int int64_t
#define fi first
#define se second
 
Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

int main() {
    string s, t;
    cin >> s >> t;
    if (s.size() < t.size()) {
        dump("UNRESTORABLE");
        return 0;
    }
    vector<string> res;
    for (Int i = 0; i <= s.size() - t.size(); i++) {
        string u = s;
        bool check = true;
        for (Int j = 0; j < t.size(); j++) {
            u[i + j] = t[j];
            if (not(s[i + j] == t[j] or s[i + j] == '?')) {
                check = false;
            }
        }
        if (check) {
            for (Int j = 0; j < u.size(); j++) {
                if (u[j] == '?') {
                    u[j] = 'a';
                }
            }
            res.push_back(u);
        }
    }
    if (res.empty()) {
        dump("UNRESTORABLE");
    }
    else {
        sort(res.begin(), res.end());
        dump(res.front());
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int X;
	
	cin>>X;
	
	X -= 400;
	
	cout<<8 - X/200<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3636
n, t = list(map(int, input().split()))

cost_times = [list(map(int, input().split())) for _ in range(n)]

cost_now = 10000
for i in range(n):
	if cost_times[i][1] > t:
		continue
	elif cost_times[i][0] < cost_now:
		cost_now = cost_times[i][0]

if cost_now == 10000:
	print("TLE")
else:
	print(cost_now)



Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
#define LL long long

int n,w;
int W[105], V[105];
LL dp[105][100005];

LL f( int pos, int cw ){
	if ( pos == n ) return 0;
	LL &ans = dp[pos][cw];
	if ( ans != -1 ) return ans;
	ans = f(pos+1,cw);
	if ( cw + W[pos] <= w ) ans = max( ans, f(pos+1,cw+W[pos]) + V[pos] );
	return ans;
}

int main(){

	scanf("%d%d",&n,&w);
	for ( int i= 0; i < n; i++ ) scanf("%d%d",&W[i],&V[i]);
	memset(dp,-1,sizeof(dp));
	printf("%lld\n",f(0,0));
	return 0;
}

Measured memory_bytes: 83756
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

template <typename T> inline constexpr bool chmin(T &a, T b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> inline constexpr bool chmax(T &a, T b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n + 1);
  for (int i = 0; i <= n; i++)
    cin >> a[i];
  if (n == 0) {
    if (a[0] != 1)
      cout << -1 << endl;
    else
      cout << 1 << endl;
    return 0;
  }
  if (a[0] != 0) {
    cout << -1 << endl;
    return 0;
  }
  vector<ll> max_brunch(n + 1);
  max_brunch[0] = 1;
  for (int i = 1; i <= n; i++) {
    if (2 * max_brunch[i - 1] < a[i]) {
      cout << -1 << endl;
      return 0;
    } else {
      max_brunch[i] = min(2 * max_brunch[i - 1] - a[i], INF);
    }
  }
  vector<ll> vertex(n + 1);
  vertex[n] = a[n];
  for (int i = n - 1; i >= 0; i--) {
    ll x = max(0ll, 2 * (vertex[i + 1] - max_brunch[i]));
    // x:= i+1$BCJ$ND:E@$N$&$A!"$^$H$a$i$l$k$b$N$N8D?t(B
    ll b = x / 2 + (vertex[i + 1] - x);
    vertex[i] = b + a[i];
  }
  ll ans = 0;
  for (auto i : vertex)
    ans += i;
  cout << ans << endl;
}


Measured memory_bytes: 5128
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cctype>

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef pair<int,int> PII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int dp[45] = {1,1};

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	
	for(int i = 2;i < n + 1;i++){
		dp[i] = dp[i - 1] + dp[i - 2];
	}
	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 1192
n, m = map(int, input().split())

A = [[0]*(m+1) for i in range(n+1)]

for i in range(n):
    B = list(map(int, input().split()))
    for j in range(m):
        A[i][j] = B[j]
    
for i in range(n):
    for j in range(m):
        A[i][m] += A[i][j]

for j in range(m+1):
    for i in range(n):
        A[n][j] += A[i][j]
        
for i in range(n+1):
    print(A[i][0], end='')
    for j in range(1, m+1):
        print(' %d'%A[i][j], end='')
    print()


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

#define ll long long
#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define repr(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back
#define debug(x) cout << x << endl;
#define END cout << endl;

int main() {
  int n,k; cin >> n >> k;
  vector<ll> a(n);
  vector<ll> sum(n+1), b(n+1);
  sum[0] = b[0] = 0;
  rep(i,n) {
    cin >> a[i];
    sum[i+1] = a[i] + sum[i];
    b[i+1] = max<ll>(0,a[i]) + b[i];
  }
  ll ans = -10e12;
  for (int i = 0; i <= n - k; ++i) {
    int left = i+1, right = i + k;
    ll mmax, tmp_sum = sum[right] - sum[left-1];
    mmax = tmp_sum + (b[n] - b[right]) + (b[left-1] - b[0]);
    mmax = max(mmax, (b[n] - b[right]) + (b[left-1] - b[0]));
    ans = max(ans, mmax);
  }

  cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define mp make_pair
const long long mod = 1000000007;
const long long High = 1e16;
#define int long long

void solve()
{
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> V(n);
  for(int i=0;i<n;++i)
    cin >> V[i].f >> V[i].s;
  sort(V.begin(),V.end());
  int amt = 0;
  for(int i=0;i<n && m;++i)
  {
    int x = min(m,V[i].s);
    m -= x;
    amt += x*V[i].f;
  }
  cout << amt;
}

main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  int t = 1;
//  cin >> t;
  while(t--)
    solve();
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A.at(i);
    }
    int count=0;
    bool x=true;
    while(x==true){
        for(int i=0;i<N;i++){
         if(A.at(i)%2==1){
              x=false;
            }
            else{
                A.at(i)/=2;
            }
        }
        count++;
    }
    cout << count-1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(void){
  long long int x, buf, ans;

  cin >> x;

  buf = x % 11;

  if ((buf <= 6) && (buf >= 1)) {
    ans = (long long int)(floor(x / 11.) * 2 + 1);
  }
  else {
    ans = (long long int)(ceil(x / 11.) * 2);
  }

  printf("%lld\n", ans);

  return 0;
}

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

#define ll long long
#define rep(i, n) for(i = 0; i < n; i++)

int main(){
    ll W, H, x, y;

    cin >> W >> H >> x >> y;
    cout << W * H / 2.0 << ' ' << (2*x == W && 2*y == H) << endl;

    return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1,
    x=-x;
  }
  while(x){
    f[s++]=x%10,
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int L, N, R, res;
int main(){
  int Lj4PdHRW;
  rd(N);
  for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
    rd(L);
    rd(R);
    res += R-L+1;
  }
  wt_L(res);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20170910-1

// --- original code ---
// int N, L, R, res;
// {
//   rd(N);
//   rep(N){
//     rd(L,R);
//     res += R-L+1;
//   }
//   wt(res);
// }


Measured memory_bytes: 256
from bisect import bisect_left, bisect_right

N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
sumSunuke = 0

for x in range(N):
    ab = bisect_left(A, B[x])
    bc = N - bisect_right(C, B[x])
    sumSunuke += ab * bc
print(sumSunuke)


Measured memory_bytes: 22720
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Data.Sequence (Seq, ViewL ((:<)), (|>))
import qualified Data.Sequence as Seq

main :: IO ()
main = do
  s <- getLine
  t <- getLine
  putStrLn $ if solve s t then "Yes" else "No"

solve :: String -> String -> Bool
solve s t = any (== t') . take n $ iterate rotate s' where
  s' = Seq.fromList s
  t' = Seq.fromList t
  n = Seq.length s'

rotate :: Seq a -> Seq a
rotate xs = ys |> y where
  y :< ys = Seq.viewl xs


Measured memory_bytes: 508
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().execute();
	}

	private void execute() {
		Scanner sc = new Scanner(System.in);
		final String str = sc.next();
		int m = 753;
		for (int i=0; i< str.length()-2; i++) {
			int num = Integer.parseInt(str.substring(i, i+3));
			m = Math.min(m, Math.abs(753-num));
		}
		System.out.println(m);
		sc.close();
	}

}


Measured memory_bytes: 23764
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let A: Vec<i64> = sc.vec(N);
    let mut m = HashMap::new();
    let mut ans = 0usize;
    for i in 0..N {
        ans += m.get(&(A[i]-i as i64)).unwrap_or(&0);
        let e = m.entry(-A[i]-i as i64).or_insert(0);
        *e += 1usize;
    }
    println!("{}", ans);
}


Measured memory_bytes: 10260
#include <bits/stdc++.h>
using namespace std;
vector<int> a;
bool cmp (int i, int j) {
  return a[i] < a[j];
}
int main() {
  int n;
  cin >> n;
  int N = (1 << n);
  a.resize(N);
  vector<int> ret(N), M(N), m(N);
  for (int bs = 0; bs < N; bs++) cin >> a[bs];
  M[0] = 0;
  m[0] = 0;
  vector<int> rpr;
  for (int bs = 1; bs < N; bs++) {
    rpr.clear();
    rpr.push_back(bs);
    for (int i = 0; i < n; i++) if ((bs >> i) & 1) {
      int cs = bs ^ (1 << i);
      rpr.push_back(M[cs]);
      rpr.push_back(m[cs]);
    }
    sort(rpr.begin(), rpr.end(), cmp);
    rpr.resize(unique(rpr.begin(), rpr.end()) - rpr.begin());
    auto it = rpr.end();
    M[bs] = *(--it);
    m[bs] = *(--it);
    ret[bs] = a[M[bs]] + a[m[bs]];
  }
  int now = 0;
  for (int bs = 1; bs < N; bs++) {
    now = max(now, ret[bs]);
    cout << now << endl;
  }
  return 0;
}

Measured memory_bytes: 7168
//In the Name of God
//Ya Ali

#include <bits/stdc++.h>

#define int long long

#define err(A) cout << #A << " = " << (A) << endl

using namespace std;

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

  int h, w, a, b;
  cin >> h >> w >> a >> b;

  for (int x = 0; x < h; cout << "\n", x ++)
    for (int y = 0; y < w; y ++)
      cout << !(x < b xor y < a);
  
  return 0;
}


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

#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define w(x) int x;cin>>x; while(x-->0)
#define memset(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

}

void mysol()
{
	int n = 5;
	int arr[n];
	for (int &a : arr)
		cin >> a;
	int i = 1;
	for (int a : arr)
	{
		if (a == 0)
		{
			cout << i << endl;
			return;
		}
		i++;
	}

}

int32_t main()
{
	fast();
	// w(t)
	{
		mysol();
	}
	//cerr << sizeof(dp)*(1e-6) << " megabytes\n";
	return 0;
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = s[0];
            int x = s[1];

            var ls = new List<int>();
            ls = ReadLine().Split(' ').Select(int.Parse).ToList();

            long ans = 0;
            for (int i = 0; i < n-1; i++)
            {
                int tmp = (ls[i] + ls[i+1]) -x;
                if(tmp >0){
                    if (ls[i+1] > tmp) 
                    {
                        ls[i + 1] -= tmp;
                    }
                    else
                    {
                        ls[i + 1] = 0;
                        tmp -= ls[i + 1];
                        ls[i] -= tmp;
                    }
                    ans += tmp;
                }
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 25820
#include "bits/stdc++.h"

using namespace std;
using LL = long long;

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

	string s, t;
	cin >> s >> t;

	int res = 0;
	for (int i = 0; i < 3; i ++) if (s[i] == t[i]) res ++;
	cout << res << endl;
}

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

int main(){
	int n;
	cin >> n;
	array<array<array<int ,4>,3>,10> data;
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				data[k][j][i] = 0;
			}
		}
	}
	int num1,num2,num3,num4;
	for(int x = 0; x < n; x++){
		cin >> num1 >> num2 >> num3 >> num4;
		data[num3-1][num2-1][num1-1] += num4;
	}
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				cout << " " << data[k][j][i];
			}
			cout << endl;
		}
		if(i != 3) cout << "####################" << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
N, K = map(int, input().split())

data = []
for _ in range(0, K):
    d = int(input())
    data.append(list(map(int, input().split())))

mans = [0 for _ in range(0, N)]
for ds in data:
    for d in ds:
        mans[d-1] = 1

print(len(list(filter(lambda x: x == 0, mans))))


Measured memory_bytes: 67972
# 写経AC
from collections import defaultdict

N = int(input())
A = [int(i) for i in input().split()]

# dp[(i, x, flag)]:= i番目まででx個選んでいる時の最大値
# flag: i番目をとるフラグ
dp = defaultdict(lambda: -float("inf"))

# 初期条件
dp[(0, 0, 0)] = 0

for i, a in enumerate(A, 1):
    for x in range((i // 2) - 1, (i + 1) // 2 + 1):
        dp[(i, x, 0)] = max(dp[(i - 1, x, 0)], dp[(i - 1, x, 1)])
        dp[(i, x, 1)] = dp[(i - 1, x - 1, 0)] + a

print(max(dp[(N, N // 2, 0)], dp[(N, N // 2, 1)]))

Measured memory_bytes: 210716