akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>

#define rep(i, n)     for (int (i) = 0; (i) < (n); (i)++)
#define rep1(i, n)    for (int i = 1; i <= (int)(n); i++)

using namespace std;
typedef long long ll;

int n, A[50];

int solve(int i, int m) {
   if (m == 0) return(true);
   else if (i >= n) return(false);

   int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
   return(res);
}

int main() {
   int q, m;

   cin >> n;
   rep(i, n) cin >> A[i];
   cin >> q;
   rep(i, q) {
      cin >> m;
      if (solve(0, m)) cout << "yes" << endl;
      else cout << "no" << endl;
   }
   return(0);
}



Measured memory_bytes: 3080
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 1e6 + 6, mod = (int) 0;
int a[N];
int main() {
	int n;
	cin >> n;
	for (int j = 0; j < n; ++j) cin >> a[j];
	long long res = 0;
	for (int j = 1; j < n; ++j) if (a[j] - a[j - 1] > 1) {
		cout << -1 << endl;
		return 0;
	}
	for (int j = 0; j < n; ++j) {
		int last = j - a[j];
		if (last < 0) {
			cout << -1 << endl;
			return 0;
		} else {
			if (j + 1 == n || a[j + 1] != a[j] + 1) {
				res += a[j];
			}
		}
	}
	cout << res << endl;
}








Measured memory_bytes: 1152
#include <iostream>
#include <stdio.h>
using namespace std;
 int an[4][2],n,i,j;
 int main() {
  double ey[2];
  while(cin >> ey[0] >> ey[1]) {
	  for (i=0;i<2;i++) {
		  if (ey[i]>=1.1) j=0;
		  if (ey[i]>=0.6 && ey[i]<1.1) j=1;
		  if (ey[i]>=0.2 && ey[i]<0.6) j=2;
		  if (ey[i]<0.2) j=3;
		  an[j][i]++;
	  }
   }
  for (i=0;i<4;i++) cout << an[i][0] << ' ' << an[i][1] << endl;
  return 0;
 }

Measured memory_bytes: 1224
class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
 
    def to_sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= (i & -i)
        return s
 
    def add(self, i, x):
        while i <= self.n:
            self.data[i] += x
            i += (i & -i)
 
    def get(self, i, j):
        return self.to_sum(j)-self.to_sum(i-1)

import sys
input = sys.stdin.readline
N,Q = map(int,input().split())
C = list(map(int,input().split()))
#print(C)
LR = []
ans = [0 for _ in range(Q)]
for i in range(Q):
  temp= list(map(int,input().split()))
  LR.append((temp,i)) #クエリとID
LR.sort(key=lambda x : x[0][1]) #右端で昇順にソート
#print(LR)
CMAX = max(C)
Tree = BIT(N)
last = [-1 for _ in range(CMAX)] #色を0index
left,right = LR[0][0]
for j in range(right):
  mae = last[C[j]-1]
  last[C[j]-1] = j
  if mae !=-1:
    Tree.add(mae+1,-1) #BITは1から
  Tree.add(last[C[j]-1]+1,1) #BITは1から
  #print(Tree.get(left,right))
#print(last)
D = []
#for i in range(1,N+1):
#  detemp = Tree.get(i,i)
#  D.append(detemp)
#print(D)

temp = Tree.get(left,right)
ID = LR[0][1]
ans[ID] = temp
lastright = right  
#print(Tree.get(left,right))
for i in range(1,Q):
  left,right = LR[i][0]
  #print(right,lastright)
  if lastright < right:
    for j in range(lastright,right):
      mae = last[C[j]-1]
      last[C[j]-1] = j
      #print(C[j],mae,j,last[C[j]-1] )
      if mae !=-1:
        #rint(C[j],"A")
        Tree.add(mae+1,-1) #BITは1index
      Tree.add(j+1,1) #BITは1index
  temp = Tree.get(left,right)
  ID = LR[i][1]
  ans[ID] = temp
  lastright = max(right,lastright)
  #print(last)


print(*ans,sep="\n")



Measured memory_bytes: 227768
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      long a = sc.nextLong();
      long b = sc.nextLong();
      long c = sc.nextLong();
      long d = sc.nextLong();
      long xa = a-1-((a-1)/c+(a-1)/d-(a-1)/lcm(c,d));
      long xb = b-(b/c+b/d-b/lcm(c,d));
      System.out.println(xb-xa);
    }
    public static long lcm(long x,long y){
      return x*y/gcd(x,y);
    }
    public static long gcd(long x,long y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}

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

using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int x = 0;
  int a[n];

  for(int i = 0; i < n; i++) {
    if(s[i] == 'I') x++;
    else if(s[i] == 'D') x--;
    a[i] = x;
  }
  cout << max(0,*max_element(a,a+n)) << endl;
  return 0;
}

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

int main(){
  int antena[5],k;
  int flag = 0;

  for (int i=0;i<5;i++){
    cin >> antena[i];
  }
  cin >> k;
  for (int i=0;i<5;i++){
    for (int l=0;l<5;l++){
      if(i==l)continue;
      if(antena[i]-antena[l]>=0){
        if(antena[i]-antena[l]>k){
          flag++;
        }
      }else{
        if(antena[l]-antena[i]>k){
          flag++;
        }
      }
    }
  }
  if(flag != 0){
    cout << ":(" << endl;
  }else{
    cout << "Yay!" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

const ll MAX_N = 1e5 + 10;

int main(int argc, char const *argv[])
{
    ll n, a[MAX_N], b[MAX_N], c[MAX_N];

    cin >> n;
    for (int i = 0; i <= n; ++i) {
        scanf("%lld", &a[i]);
        c[i] = a[i];
    }
    for (int i = 0; i < n; ++i) {
        scanf("%lld", &b[i]);
    }

    for (int i = 0; i < n; ++i) {
        ll x = min(c[i], b[i]);
        c[i] -= x;
        b[i] -= x;
        x = min(c[i+1], b[i]);
        c[i+1] -= x;
        b[i] -= x;
    }
    ll sum = 0;
    for (int i = 0; i <= n; ++i) {
        sum += a[i] - c[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int ans;

int main(){
    string s;cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='+')ans++;
        else ans--;
    }
    cout<<ans<<endl;
    return 0;
}

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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll N, X, Y;
ll ans[2010];
int main(){
	cin >> N >> X >> Y;
	X--; Y--;
	REP(i,0,N){
		REP(j, i+1, N){
			ans[j-i]--;
			ll diff1, diff2;
			if(i > X){
				diff1 = i-X;
			}else{
				diff1 = X-i;
			}
			if(j > Y){
				diff2 = j-Y;
			}else{
				diff2 = Y-j;
			}
			ans[min(diff1+diff2+1, j-i)]++;

		}
	}
	REP(i,1,N){
		p(ans[i] + N-i);
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int[] a = new int[3];
		a[0] = scanner.nextInt();
		a[1] = scanner.nextInt();
		a[2] = scanner.nextInt();
		
		for(int i=0; i<a.length-1; i++)
		{
			for(int j=1; j<a.length; j++)
			{
				if(a[i] > a[j])
				{
					int buf = a[i];
					a[i] = a[j];
					a[j] = buf;
				}
			}
		}
		
		for(int i=0; i<a.length; i++)
		{
			System.out.print(a[i]+(i<a.length-1?" ":"\n"));
		}
	}
}

Measured memory_bytes: 26196
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <memory>
#include <numeric>
#include <type_traits>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
typedef long long ll;
const int VMAX = 50;
stack<pair<int, int> > s;
bool g[VMAX][VMAX]; int cost[VMAX][VMAX];

void dikstra(pair<int, int> p){
  s.pop();
  int x = p.first, y = p.second;
  if (x+1 < VMAX){
    if (g[x+1][y] && cost[x][y]+1 < cost[x+1][y]){
      cost[x+1][y] = cost[x][y]+1;
      s.push(make_pair(x+1,y));
    }
  }
  if (x-1 >= 0){
    if (g[x-1][y] && cost[x][y]+1 < cost[x-1][y]){
      cost[x-1][y] = cost[x][y]+1;
      s.push(make_pair(x-1,y));
    }
  }
  if (y+1 < VMAX){
    if (g[x][y+1] && cost[x][y]+1 < cost[x][y+1]){
      cost[x][y+1] = cost[x][y]+1;
      s.push(make_pair(x,y+1));
    }
  }
  if (y-1 >= 0){
    if (g[x][y-1] && cost[x][y]+1 < cost[x][y-1]){
      cost[x][y-1] = cost[x][y]+1;
      s.push(make_pair(x,y-1));
    }
  }
  if(!s.empty()) dikstra(s.top());
}


int main(){
  int h, w;
  cin >> h >> w;
  string st[h];
  int wcounter = 0;
  rep(i,h) cin >> st[i];
  rep(i,h){
    rep(j,w){
      if (st[i][j] == '.') {
        g[i][j] = true;
        ++wcounter;
      }
    }
  }
  rep(i,VMAX){
    rep(j,VMAX){
      cost[i][j] = 1e5;
    }
  }

  
  s.push(make_pair(0,0));
  cost[0][0] = 0;
  dikstra(s.top());
  
  int res;
  if (st[0][0] == '#' || st[h-1][w-1] == '#' || cost[h-1][w-1] == 1e5) res = -1;
  else{
    res = wcounter-cost[h-1][w-1]-1;
  }
  cout << res << endl;

  return 0;
}

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

int main()
{
	int k;
	cin>>k;
	string s;
	cin>>s;
	int l=s.length();
	if(l<=k)
	{
		cout<<s<<endl;
	}
	else
	{
		cout<<s.substr(0,k)<<"..."<<endl;
	}
	return 0;
}

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<double> p(N);
  double sum = 0;
  for(int i=0;i<K;i++){
    cin >> p[i];
    sum += p[i];
  }
  
  double ans = sum;
  for(int i=K;i<N;i++){
    cin >> p[i];
    sum = sum + p[i] - p[i-K];
    ans = max(sum,ans);
  }
  
  double kotae = (ans + K)/2.0;
  
  cout << fixed << setprecision(8) << kotae << endl;
    
}


Measured memory_bytes: 1792
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let (h1, m1, h2, m2, k) = (line[0], line[1], line[2], line[3], line[4]);
    let diff = if m2 > m1{
        (m2-m1) + (h2-h1) * 60
    }else{
        (h2-h1-1) * 60 + (60-m1 + m2)
    };

    if k > diff{
        println!("0");
    }else{
        println!("{}", diff-k);
    }
}


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

int E;
int cnt = 0;
int solve(int e) {
	
		int m = 0x3f3f3f3f;
		for (int z = 0; z*z*z <= e; z++) {
			for (int y = 0; y*y <= e - z * z*z; y++) {
				int x = e - y * y - z * z*z;
				m = min(m, x + y + z);
				++cnt;
			}
		}
		return m;
}
int main() {
	while (cin >> E && E>0) {
		cout << solve(E) << endl;

	}

}


Measured memory_bytes: 3060
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N, M;
    scan(N, M);
    long f(long x)
    {
        long ans = 1;
        foreach (i; 1 .. x + 1)
        {
            ans = (ans * i) % MOD;
        }
        return ans;
    }

    if (N == M)
    {
        writeln((f(N) ^^ 2 % MOD) * 2 % MOD);
    }
    else if (abs(N - M) == 1)
    {
        writeln(f(N) * f(M) % MOD);
    }
    else
    {
        writeln(0);
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  int x,y;
  cin >> x >> y;
  if( (x<0) xor (y<=0) ){
    cout << abs(abs(x)-abs(y)) + 1 << endl;
  }else if(x<=y){
    cout << y-x << endl;
  }else{
    cout << abs(abs(x)-abs(y)) + 2 << endl;
  }
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

/**
 * @author takahiro 問題文 √a+√b<√c ですか？<br>
 *     制約 1 ≤ a,b,c ≤ 10^9 入力は全て整数である。
 */
public class Main {

  public static void main(final String[] args) throws IOException {
    try (final Scanner scanner = new Scanner(System.in)) {
      final Input input = new Input(scanner);
      execute(input);
    }
  }

  private static void execute(final Input input) {
    Result.toResult(calculate(input)).answer();
  }

  /**
   * √a+√b < √c <br>
   * = a + 2√ab + b < c <br>
   * = 2√ab < c - a - b <br>
   * = 2√ab < minused <br>
   * = 4 * a * b < minused^2
   */
  private static boolean calculate(final Input input) {
    final long a = input.getA();
    final long b = input.getB();
    final long c = input.getC();
    final long minused = c - a - b;
    if (minused < 0) {
      return false;
    }
    return 4 * a * b < minused * minused;
  }

  private static class Input {

    private Input(final Scanner scanner) {
      a = scanner.nextInt();
      b = scanner.nextInt();
      c = scanner.nextInt();
    }

    public int getA() {
      return a;
    }

    public int getB() {
      return b;
    }

    public int getC() {
      return c;
    }

    private final int a, b, c;
  }

  private enum Result {
    Yes,
    No;

    private static Result toResult(final boolean calculate) {
      return calculate ? Yes : No;
    }

    private void answer() {
      System.out.println(this.toString());
    }
  }
}


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


int main(void) {
    string s;
    cin >> s;
    int ans = 10000;
    rep(i, s.size()-2){
        int tmp = abs(753 - stoi(s.substr(i,3)));
        ans = min(ans, tmp);
    }  
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <stack>
#include <queue>

using namespace std;

int main(void) {
	while(1) {
		int n, r;
		int p, c;
		stack<int> deck, deck_p, deck_c;

		scanf("%d %d", &n, &r);
		if(n == 0 && r == 0) break;
		for(int i = 1; i <= n; i++) {
			deck.push(i);
		}
		for(int i = 0; i < r; i++) {
			scanf("%d %d", &p, &c);
			for(int j = 0; j < p - 1; j++) {
				deck_p.push(deck.top());
				deck.pop();
			}
			for(int j = 0; j < c; j++) {
				deck_c.push(deck.top());
				deck.pop();
			}
			for(int j = 0; j < p - 1; j++) {
				deck.push(deck_p.top());
				deck_p.pop();
			}
			for(int j = 0; j < c; j++) {
				deck.push(deck_c.top());
				deck_c.pop();
			}
		}

		printf("%d\n", deck.top());
	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A+B, R = C+D;
  if(L < R){
    cout << "Right" << endl;
  } else if(L == R){
    cout << "Balanced" << endl;
  } else {
    cout << "Left" << endl;
  }
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
#[allow(unused)]
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()
}
#[allow(unused)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(unused)]
fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
    let v: Vec<T> = read_vec();
    assert_eq!(v.len(), 2);
    (v[0], v[1])
}
fn main() {
    input!(n: usize, m: usize);
    input!(mut x: [i64; m]);
    if n >= m {
        println!("0");
        return;
    }
    x.sort();
    let mut l = vec![0; m];
    for i in 0..m - 1 {
        l[i] = x[i + 1] - x[i];
    }
    l.sort_by(|a, b| b.cmp(&a));
    let ans: i64 = x[m - 1] - x[0] - l.iter().take(n - 1).sum::<i64>();
    println!("{}", ans);
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
ll a[200005];
map<ll, int> mp;
void solve() {
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        ++mp[a[i]];
    }

    sort(a, a + n, greater<>());

    int ans = 0;
    rep(i, n) {
        if (mp[a[i]] == 0) continue;
        auto tmp = 1;
        while (tmp <= a[i]) {
            tmp <<= 1;
        }

        auto y = tmp - a[i];
        if (a[i] == y && mp[a[i]] >= 2 || a[i] != y && mp.count(y) > 0 && mp[y] > 0) {
            --mp[a[i]]; --mp[y];
            ++ans;
        }
    }

    cout << ans << endn;

}

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


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

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

    if (n == 1){
        if (m == 1){
            cout << "1" << endl;
        }
        else{
            cout << m - 2 << endl;
        }
    }
    else if (m == 1){
        cout << n - 2 << endl;
    }
    else{
        cout << (n - 2ll) * (m - 2) << endl;
    }

    //cout << count << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 
 
fn main() {
    input! {
        n: usize,
        k: usize,
        v: [u64; n],
    }
    let mut ans :u64 = 0;
    if n > k {
        let mut vv = v;
        vv.sort();
        vv.reverse();
        let mut i = k;
        while i < vv.len() {
            ans += vv[i];
            i += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
using namespace std;

#include <cstdio>
#include <cstdint>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

int main(
){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string  S;
    string  T;
    string  ans;
    cin >> S;
    cin >> T;

    if(T.substr(0,T.length()-1) == S){
        ans = "Yes";
    }else{
        ans = "No";
    }

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

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  cout << (n + x - 1) / x * t << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

// LazyUpdateSegmentTree
template<typename T>
class LazyUpdateSegTree{
public:
    int n;
    T defaultValue;
    vector<T> dat;
    vector<T> lazy;
    vector<bool> isSetLazy;

    LazyUpdateSegTree(vector<T>& v, T defaultValue){
        n = 1;
        int vSize = (int)v.size();
        while(n < vSize){
            n *= 2;
        }
        dat.assign(2 * n - 1, defaultValue);
        lazy.assign(2 * n - 1, 0);
        isSetLazy.assign(2 * n - 1, false);
        this->defaultValue = defaultValue;

        for(int i = 0; i < vSize; i++){
            dat[i + n - 1] = v[i];
        }
        for(int i = n - 2; i >= 0; i--){
            dat[i] = ope(dat[2 * i + 1], dat[2 * i + 2]);
        }
    }

    T update(int a, int b, T value, int k = 0, int l = 0, int r = -1){
        if(r < 0){
            r = n;
        }
        propagate(k);

        if(r <= a || b <= l){
            return dat[k];
        }

        if(a <= l && r <= b){
            lazy[k] = lazyUpdate(value, l, r);
            isSetLazy[k] = true;
            propagate(k);
            return dat[k];
        }
        else{
            T vl = update(a, b, value, 2 * k + 1, l, (l + r) / 2);
            T vr = update(a, b, value, 2 * k + 2, (l + r) / 2, r);
            dat[k] = ope(vl, vr);
            return dat[k];
        }
    }

    T query(int a, int b, int k = 0, int l = 0, int r = -1){
        if(r < 0){
            r = n;
        }

        if(r <= a || b <= l){
            return defaultValue;
        }
        propagate(k);

        if(a <= l && r <= b){
            return dat[k];
        }
        else{
            T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
            T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return ope(vl, vr);
        }
    }

private:

    void propagate(int k){
        if(isSetLazy[k]){
            dat[k] = lazy[k];
            if(k <= n - 2){
                T value = lazyPropUpdate(lazy[k]);
                lazy[2 * k + 1] = value;
                lazy[2 * k + 2] = value;
                isSetLazy[2 * k + 1] = true;
                isSetLazy[2 * k + 2] = true;
            }

            isSetLazy[k] = false;
        }
    }

    T ope(T a, T b){
        return min(a, b);
    }

    T lazyUpdate(T value, int l, int r){
        return value;
    }

    T lazyPropUpdate(T value){
        return value;
    }
};

int main(){

    int n, q;
    cin >> n >> q;
    vector<long long> v(n, (1LL << 31) - 1);
    LazyUpdateSegTree<long long> segTree(v, 1LL << 60);
    for(int i = 0; i < q; i++){
        int type;
        cin >> type;
        if(type == 0){
            int s, t, x;
            cin >> s >> t >> x;
            segTree.update(s, t + 1, x);
        }
        else{
            int s, t;
            cin >> s >> t;
            cout << segTree.query(s, t + 1) << endl;
        }
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
    int n;
    // cin >> n;
    scanf("%d",&n);
    int amari = n % 10;
    if (amari == 2 || amari == 4 || amari == 5 || amari == 7 || amari == 9){
        // cout << "hon" << endl;
        printf("hon\n");
    } else if (amari == 0 || amari == 1 || amari == 6 || amari == 8)
    {
        // cout << "pon" << endl;
        printf("pon\n");
    } else
    {
        // cout << "bon" << endl;
        printf("bon\n");
    }
    
    return 0;
}


Measured memory_bytes: 3684
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;


const int MAX_N = 1000;
int par[MAX_N];
int rnk[MAX_N];

void init(int n){
    for(int i=1; i<=n; i++){
        par[i] = i;
        rnk[i] = 0;
    }
}

int find(int x){
    if(par[x] == x){
        return x;
    }
    else{
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y){
    x = find(x);
    y = find(y);

    if(x == y) return;

    if(rnk[x] < rnk[y]){
        par[x] = y;
    }
    else{
        par[y] = x;
        if(rnk[x] == rnk[y]) rnk[x]++;
    }
}

bool same(int x, int y){
    return find(x) == find(y);
}


int main(){

    int n, m; cin >> n >> m;

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

    int cnt = 0;
    for(int k=0; k<m; k++){

        init(n);
        for(int i=0; i<m; i++){
            if(i != k){
                unite(a[i], b[i]);
            }
        }

        bool exitflag = false;
        for(int i=1; i<=n-1; i++){
            for(int j=i+1; j<=n; j++){
                if(!same(i, j)){
                    cnt++;
                    exitflag = true;
                    break;
                }
            }
            if(exitflag) break;
        }
    }

    cout << cnt;


    return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
	public static int findMax(int line0, int line1, int line2){
		int max;
		int num;
		if(line0 >= line1){
			max = line0;
			num = 0;
		}else{
			max = line1;
			num = 1;
		}
		
		if(max < line2){
			max = line2;
			num = 2;
		}
		return num;
	}
	
	public static void main(String[] argv) throws NumberFormatException, IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int lineNum = Integer.parseInt(br.readLine());
		for(int i=0; i<lineNum; i++){
			String[] line = br.readLine().split(" ");
			int max = findMax(Integer.parseInt(line[0]), Integer.parseInt(line[1]), Integer.parseInt(line[2]));
			int[] lineInt = {Integer.parseInt(line[0]), Integer.parseInt(line[1]), Integer.parseInt(line[2])};
			int sum = 0;
			for(int j=0; j<3; j++){
				if(j != max){
					sum += (lineInt[j] * lineInt[j]);
				}
			}
			String out;
			if((lineInt[max] * lineInt[max]) == sum){
				out = "YES";
			}else{
				out = "NO";
			}
			System.out.print(out+"\n");
		}
	}
}

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

int main() {
  string X;
  cin >> X;
  stack<char> s;
  s.push(X[0]);
  for (int i = 1; i < X.size(); i++) {
    if (X[i] == 'S')
      s.push(X[i]);
    else {
      if (s.size() > 0 && s.top() == 'S') {
        s.pop();
      } else {
        s.push(X[i]);
      }
    }
  }
  cout << s.size() << endl;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    VI a(n); cin >> a;

    int sum = accumulate(all(a), 0);
    int ans = -1, b = INF;
    FOR(i, 0, n) {
        if (chmin(b, abs(sum - a[i] * n)))ans = i;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
from math import ceil, floor
n, m = map(int, raw_input().split())
scc = 0
while n > 0 and m >= 2:
	if m >= 2*n:
		scc += n
		m -= 2*n
		n = 0
	elif n > 0 and m >= 2 and m < 2*n:
		scc += m/2
		n -= m/2
		m = m%2 
	if n == 0 and m >= 4:
		n += m/4
		m = int(ceil(float(m)/2))
print scc

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

#define mp make_pair

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef pair<i64,int> pli;
typedef pair<int,i64> pil;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<i64> vl;

template <typename T>
T id(T b) {return b;};
template <class It>
bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It>
bool any(It f,It l){return std::any_of(f,l,id<bool>);}

const int MAX_N = 100000;
int q;
int is_like_2017[MAX_N+1];

vector<bool> is_prime(MAX_N+1);
void sieve() {
  fill(is_prime.begin(),is_prime.end(),true);
  is_prime[0] = is_prime[1] = false;

  for (long long i = 2; i <= MAX_N; i++) {
    if (is_prime[i]) {
      for (long long j = i*i; j <= MAX_N; j+=i) {
        is_prime[j] = false;
      }
    }
  }
}

int main()
{
  sieve();
  for (int x = 0; x <= MAX_N; x++) {
    if (x % 2 == 0) is_like_2017[x] = 0;
    else is_like_2017[x] = is_prime[x] && is_prime[(x+1)/2] ? 1 : 0;
  }

  for (int x = 1; x <= MAX_N; x++)
    is_like_2017[x] += is_like_2017[x-1];

  cin >> q;
  int l,r;
  while (q--) {
    cin >> l >> r;
    cout << is_like_2017[r] - is_like_2017[l-1] << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

stack<int> st;

char s[10000],t[20];

int main(void){
    int k = 0,l,a,b;
    fgets(s,10000,stdin);
    while(1){
        l = k;
        while(s[k] != ' ' && s[k] != '\0'){
            t[k - l] = s[k];
            k++;
        }

        t[k - l] = '\0';
        if(s[l] >= '0' && s[l] <= '9')
            st.push(atoi(&s[l]));
        else{
            a = st.top();
            st.pop();
            b = st.top();
            st.pop();
            if(s[l] == '+')
                st.push(b + a);
            else if(s[l] == '-')
                st.push(b - a);
            else if(s[l] == '*')
                st.push(b * a);
            else if(s[l] == '/')
                st.push(b / a);
        }

        if(s[k] == '\0')
            break;
        k++;
    }
    printf("%d\n",st.top());
    return 0;
}

Measured memory_bytes: 3204
#include<iostream>
using namespace std;
int main()
{ 
    int a,b;
    cin>>a;
    b=a%10;
    if(b==2||b==4||b==5||b==7||b==9)
	cout<<"hon";
    if(b==0||b==1||b==6||b==8)
	cout<<"pon";
    if(b==3)
	cout<<"bon";
}  

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std; 
int main()
{
	string a;
	cin>>a;
	int b=0,c=0;
	for(int i=0;i<a.size();i++)
	if(a[i]=='A')
	b++;
	else
	c++;
	if(b==0 || c==0)
	cout<<"No";
	else
	cout<<"Yes";
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
/******************************************
* AUTHOR : PANDRAVISAM SHIVA SANTHOSH *
* Handle : santhosh_80 *
* INSTITUTION : IIT Palakkad *
******************************************/
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
#define ll long long int 
#define mod 1000000007
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define S(x) scanf("%d",&(x))
#define P(x) printf("%d\n",(x))
#define Sl(x) scanf("%lld",&(x))
#define Pl(x) printf("%lld\n",(x))
#define pb push_back
#define f first
#define s second


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	double r ;
	cin >> r ;
	double pi = 3.14159 ;
	cout << setprecision(9) << 2*pi*r;
 	return 0;
}

Measured memory_bytes: 3800
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 160000;
const int K = 5000;
int dp[51][K];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, a;
    cin >> n >> a;
    dp[0][0] = 1;
    for (int i = 1; i <= 50; i++){
        for (int j = 1; j < K; j++){
            for (int l = 1; l <= j; l++){
                dp[i][j] = max(dp[i][j], dp[i - 1][j - l] * l);
                if (dp[i][j] > n) dp[i][j] = n;
            }
        }
    }
    int ans = n;
    for (int i = 2; i * i <= 2 * n + 200; i++){
        ans = min(ans, a + i + (n - 1) / i + 1);
    }
    for (int i = 2; i * i * i <= 2 * n + 200; i++)
        for (int j = i; j * j * j <= 2 * n + 200; j++){
            ans = min(ans, a + a + i + j + (n - 1) / (i * j) + 1);
    }
    for (int i = 3; i <= 50; i++){
        for (int j = 1; j < K; j++){
            if (dp[i][j] == 0) continue;
            ans = min(ans, i * a + j + (n - 1) / dp[i][j] + 1);
        }
    }
    cout << ans;
}


Measured memory_bytes: 2304
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// input
		String s = sc.next();
		// ３文字確定だからAAAかBBBの二択なはず
		if(s.matches("AAA") || s.matches("BBB")) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}
}

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

int main() {
  char a;
  cin >> a;
  char ans;
  if (a == 'A') ans = 'T';
  else if (a == 'T') ans = 'A';
  else if (a == 'G') ans = 'C';
  else if (a == 'C') ans = 'G';
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := getInts(N * 3)
	sort.Slice(a, func(i, j int) bool {
		return a[i] > a[j]
	})
	ans := 0
	// out(a)
	for i := 0; i < N; i++ {
		ans += a[1+i*2]
	}

	out(ans)
}


Measured memory_bytes: 6708
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Disjoint Set Union
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

struct UFT {
  int links[MAX_N], ranks[MAX_N], sizes[MAX_N];
  UFT() {}

  void init(int n) {
    for (int i = 0; i < n; i++) links[i] = i, ranks[i] = sizes[i] = 1;
  }

  int root(int i) {
    int i0 = i;
    while (links[i0] != i0) i0 = links[i0];
    return (links[i] = i0);
  }

  int rank(int i) { return ranks[root(i)]; }
  int size(int i) { return sizes[root(i)]; }
  bool same(int i, int j) { return root(i) == root(j); }

  int merge(int i0, int i1) {
    int r0 = root(i0), r1 = root(i1), mr;
    if (r0 == r1) return r0;
    if (ranks[r0] == ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      ranks[r0]++;
      mr = r0;
    }
    else if (ranks[r0] > ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      mr = r0;
    }
    else {
      links[r0] = r1;
      sizes[r1] += sizes[r0];
      mr = r1;
    }
    return mr;
  }
};

/* global variables */

UFT uft;

/* subroutines */

/* main */

int main() {
  int n, q;
  scanf("%d%d", &n, &q);

  uft.init(n);

  while (q--) {
    int op, u, v;
    scanf("%d%d%d", &op, &u, &v);

    if (op == 0)
      uft.merge(u, v);
    else
      printf("%d\n", uft.same(u, v) ? 1 : 0);
  }
  return 0;
}


Measured memory_bytes: 5996
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	string rsl = "";
	rep(i, 0, tx - sx) rsl += 'R';
	rep(i, 0, ty - sy) rsl += 'U';
	rsl += 'R';
	rep(i, 0, ty - sy + 1) rsl += 'D';
	rep(i, 0, tx - sx + 1) rsl += 'L';
	rsl += "UL";
	rep(i, 0, ty - sy + 1) rsl += 'U';
	rep(i, 0, tx - sx + 1) rsl += 'R';
	rsl += 'D';
	rep(i, 0, tx - sx) rsl += 'L';
	rep(i, 0, ty - sy) rsl += 'D';
	
	cout << rsl << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

int main(){
  int N, M;
  cin >> N >> M;
  int A[M], B[M];
  rep(i, M)
    cin >> A[i] >> B[i];
  //

  vector<vector<int> > G(N+1);
  rep(i, M){
    G[A[i] ].push_back(B[i] );
    G[B[i] ].push_back(A[i] );
  }
  
  int visit[N+1];
  rep(i, N+1)
    visit[i] = false;

  int ans[N+1];
  rep(i, N+1)
    ans[i] = -1;
  
  queue<int> q;
  int now, next;
  q.push(1);
  visit[1] = true;
  while(q.empty() != 1){
    now = q.front();
    q.pop();
    int size = G[now].size();
    rep(i, size ){
      next = G[now][i];
      if(visit[next ] == false){
	visit[next] = true;
	ans[next] = now;
	q.push(next);
      }
    }
  }

  for(int i=2; i<=N; i++)
    if(ans[i] == -1){
      cout << "No" << endl;
      return 0;
    }
      
  cout << "Yes" << endl;
  for(int i=2; i<=N; i++)
    cout << ans[i] << endl;
  
  return 0;
}


Measured memory_bytes: 12236
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    int n, a; cin >> n;
    double res{0.0};
    for (int i = 0; i < n; ++i) {
        cin >> a;
        res += 1.0/static_cast<double>(a);
    }
    
    cout << setprecision(12) << 1.0/res << endl;
}

Measured memory_bytes: 3208
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int n;
    cin >> n;
    int current;
    int prev;
    int res = 0;
    FOR(i, 1, n) {
        cin >> current;
        if (i == 1) {
            res += current;
        } else if (i == n) {
            res += prev;
        } else {
            res += min(current, prev);
        }
        prev = current;
    }
    cout << res << endl;
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define rep(i,n,z) for(int i=z;i<n;i++)
#define rrep(i,z) for(int i=z;i>=0;i--)
#define nl cout<<endl
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vvlli vector<vlli>
#define umap unordered_map
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ipair pair <int,int>
#define llipair pair <lli,lli>
#define pq priority_queue
#define displaymatrix(a,m,n) for(int i=0;i<m;i++){for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vlli a(n);rep(i,n,0)cin>>a[i]
#define ainput(a,n) rep(i,n,0)cin>>a[i]
#define SO(a) sort(a.begin(),a.end())
#define all(x) (x).begin(),(x).end()
#define SOP(a,comp) sort(a.begin(),a.end(),comp)
#define inf INT_MAX
#define endl '\n'


vector<int> vis;
vector<vector<int>> adj;
vector<long double > dis;
lli val;
lli paths;

void dfs(int v, int p, int lev){
    // vis[v] = 1;
    // cout<<"NODE STARTED "<<v<<endl;
    int flag = 0;
    for(auto u: adj[v]){
        if(u!= p){
            flag ++;
            dfs(u, v, lev+1);
            dis[v] += dis[u];
        }
    }
    if(flag == 0){
        dis[v] = 0;
    }
    else{
        dis[v] = (dis[v]/flag) + 1;
    }
}



void solve(){
    string a;
    cin>>a;
    if(a.back() == 's'){
        cout<<a<<"es"<<endl;
    }
    else cout<<a<<'s'<<endl;
    return ;
}


int main()
{
    fastio;
    int t;
    t = 1;
    // cin>>t;
    while(t--)solve();

}

Measured memory_bytes: 3664