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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()
#define VEC(TYPE, A, NAME, INIT) vector<TYPE> NAME(A, INIT)
#define VEC2(TYPE, A, B, NAME, INIT) vector<vector<TYPE>> NAME(A, vector<TYPE>(B, (INIT)))

class UnionFind
{
  public:
	explicit UnionFind(int size)
		: mParent(size, -1)
		, mRank(size, 0)
        , mData(size, 0)
		{}
	bool unionSet(int x, int y)
	{
		if ((x = root(x)) == (y = root(y)))
			return false;
		if( mRank[x] < mRank[y] )
		{
			mParent[y] += mParent[x];
			mParent[x] = y;
            unionData( mData[y], mData[x] );
		}
		else
		{
			mParent[x] += mParent[y];
			mParent[y] = x;
			if( mRank[x] == mRank[y] ) ++mRank[x];
            unionData( mData[x], mData[y] );
		}
		return true;
	}
	bool isEqualSet(int x, int y)
	{
		return root(x) == root(y);
	}
	int root(int x)
	{
		return mParent[x] < 0 ? x : mParent[x] = root(mParent[x]);
	}
	int size(int x)
	{
		return -mParent[root(x)];
	}

    void unionData( int& parent, int& child )
    {
        parent += child;
    }
    void setData( int x, int data )
    {
        mData[root(x)] = data;
    }
    int getData( int x )
    {
        return mData[root(x)];
    }

  public:
	vector<int> mParent; // = mSize
	vector<int> mRank;
	vector<int> mData;
};

int main()
{
	int n, m;
	cin >> n >> m;
	
	struct Edge{ int a, b; };
	vector< Edge > edge(m);
	REP( i, m )
	{
		ull a, b;
		cin >> a >> b;
		edge[i].a = a-1;
		edge[i].b = b-1;
	}

	vector<ull> ans( m, 0 );
	UnionFind uf( n );
	BREP( i, m )
	{
		auto& e = edge[i];
		if( !uf.isEqualSet( e.a, e.b ) )
		{
			ans[i] += ull( uf.size( e.a ) * uf.size( e.b ) );
			uf.unionSet( e.a, e.b );
		}
	}

	ull tmp = 0;
	REP( i, ans.size() )
	{
		tmp += ans[i];
		cout << tmp << endl;
	}
	return 0;
}

Measured memory_bytes: 4096
import java.util.ArrayDeque;
import java.util.Scanner;

/**
 * AtCoder Beginner Contest 158
 * D - String Formation
 * https://atcoder.jp/contests/abc158/tasks/abc158_c
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        ArrayDeque<String> deque = new ArrayDeque<>();
        for (int i = 0; i < s.length(); i++) {
            deque.addLast(s.substring(i, i + 1));
        }
        int q = sc.nextInt();
        boolean isAsc = true;
        for (int i = 0; i < q; i++) {
            int t = sc.nextInt();
            if (t == 1) {
                isAsc = !isAsc;
            } else {
                int f = sc.nextInt();
                if (f == 1) {
                    if (isAsc) {
                        deque.addFirst(sc.next());
                    } else {
                        deque.addLast(sc.next());
                    }
                } else {
                    if (isAsc) {
                        deque.addLast(sc.next());
                    } else {
                        deque.addFirst(sc.next());
                    }
                }
            }
        }
        int size = deque.size();
        if (isAsc) {
            for (int i = 0; i < size; i++) {
                System.out.print(deque.pollFirst());
            }
        } else {
            for (int i = 0; i < size; i++) {
                System.out.print(deque.pollLast());
            }
        }

    }
}


Measured memory_bytes: 174340
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;

int main(void){
    while (1) {
        string s;
        int a, b, c, d;
        cin >> s;
        if (s == "#") return 0;
        cin >> a >> b >> c >> d;
        a--;  b--;  c--;  d--;
        
        bool board[10][10];
        int bw, bh;
        for (int i = 0; i < 100; i++) board[i/10][i%10] = false;
        int w = 0, h = 0;
        for (int i = 0; i < s.size(); i++) {
            if (char(s[i]) == 'b') board[w][h] = true;
            else if (char(s[i]) == '/') {
                bh = h;
                w++;  h = -1;
            }
            else {
                for (int j = 0; j < int(s[i] - '0') - 1; j++) h++;
            }
            h++;
        }
        bw = w + 1;
        
        board[a][b] = false;
        board[c][d] = true;
        
        int i = 0, j = 0;
        while (i < bw) {
            j = 0;
            while (j < bh) {
                if (board[i][j]) cout << "b";
                else {
                    int idx = 0;
                    while (j + idx < bh && !board[i][j + idx]) idx++;
                    cout << idx;
                    j += idx - 1;
                }
                j++;
            }
            if (i != bw - 1) cout << "/";
            i++;
        }
        cout << endl;
        
    }
}



Measured memory_bytes: 3140
#include <stdio.h>
int judge(int w,int h,int x,int y,int r);
int main(void){
    int w,h,x,y,r;
    int result;
    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
    result = judge(w,h,x,y,r);
    switch(result){
        case 0:
            printf("No\n");
            break;
        case 1:
            printf("Yes\n");
            break;
    }
}

int judge(int w,int h,int x,int y,int r){
    int result;
    if(x>=r && x<=w-r && y>=r && y<=h-r ){
       result =1; 
    }else{
       result =0; 
    }
   return result; 
}


Measured memory_bytes: 2148
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4
1 2 3 5

output:
30
"""

import sys
from functools import reduce


def gcd(x, y):
    if x < y:
        x, y = y, x

    while y > 0:
        r = x % y
        x = y
        y = r

    return x


def lcm(a, b):
    return a * b // gcd(a, b)


def solve(_n_list):
    return reduce(lcm, _n_list)


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    cnt = int(_input[0])
    n_list = list(map(int, _input[1].split()))
    print(solve(n_list))

Measured memory_bytes: 8304
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	int A, B; scanf("%d%d", &A, &B);
	if (1 <= A&&A <= 9 && 1 <= B&&B <= 9){
		printf("%d", A*B);
	}
	else{
		printf("-1");
	}

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	string s;
	int ans = 0;

	cin >> s;

	for (int x : s) {
		ans += x - '0';
	}

	if (ans % 9 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 3756
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>

using namespace std;

struct tdata{
	int x;
	int y;
}data[1000001];

bool compareData(tdata x, tdata y){
	return x.y < y.y;
}

int main(){
	int loop;
	int count=0;
	int startTimes=0;
	scanf("%d",&loop);
	for(int i=0; i<loop;i++){
		scanf("%d %d", &data[i].x, &data[i].y);
	}
	sort(data, data+loop, compareData);
	for(int k=0; k<loop; k++){
		if(data[k].x > startTimes){
			startTimes = data[k].y;
			count++;
		}
	}
	printf("%d\n", count);
	
	return 0;
}


Measured memory_bytes: 3548
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let m: usize = sc.cin();
    let h: Vec<i64> = sc.vec(n);
    let mut g = vec![vec![]; n];
    for _ in 0..m {
        let a = sc.cin::<usize>() - 1;
        let b = sc.cin::<usize>() - 1;
        g[a].push(b);
        g[b].push(a);
    }
    put!((0..n).filter(|&i| g[i].iter().all(|&j| h[j] < h[i])).count());
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int w,h,n;
	int a,b;
	int y,x;
	cin>>w>>h>>n;
	int k;
	cin>>y>>x;
	int cnt=0;
	int i,j;
	for(k=0;k<n-1;k++){
		cin>>a>>b;
		i=a-y;
		j=b-x;
		if(j<0&&i>=0||j>=0&&i<0){
			i=abs(a-y);
			j=abs(b-x);
			cnt+=(i+j);
		}
		else{
			i=abs(a-y);
			j=abs(b-x);
			cnt+=max(i,j);
		}
		//cout<<cnt<<endl;
		y=a;
		x=b;
	}
	cout<<cnt<<endl;
	return 0;
}
			


Measured memory_bytes: 3108
package main

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

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

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

func main() {
	sc.Split(bufio.ScanWords)
	 x := scanInt()
	 a := scanInt()

	 if x < a {
		 fmt.Println(0)
	 } else {
		 fmt.Println(10)
	 }
}


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

using namespace std;

using int64 = long long;

int main() {
  int H, W, V[500][500];
  cin >> H >> W;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cin >> V[i][j];
    }
  }
  vector< tuple< int, int, int, int > > tt;
  for(int i = H - 1; i >= 0; i--) {
    if(i % 2 == 0) {
      for(int j = 0; j < W; j++) {
        if(V[i][j] % 2 == 1) {
          V[i][j]--;
          if(j + 1 == W) {
            if(i > 0) {
              tt.emplace_back(i, j, i - 1, j);
              V[i - 1][j]++;
            }
          } else {
            tt.emplace_back(i, j, i, j + 1);
            V[i][j + 1]++;
          }
        }
      }
    } else {
      for(int j = W - 1; j >= 0; j--) {
        if(V[i][j] % 2 == 1) {
          V[i][j]--;
          if(j == 0) {
            if(i > 0) {
              tt.emplace_back(i, j, i - 1, j);
              V[i - 1][j]++;
            }
          } else {
            tt.emplace_back(i, j, i, j - 1);
            V[i][j - 1]++;
          }
        }
      }
    }
  }
  cout << tt.size() << endl;
  for(auto &p : tt) {
    int a, b, c, d;
    tie(a, b, c, d) = p;
    cout << a + 1 << " " << b + 1 << " " << c + 1 << " " << d + 1 << endl;
  }
}

Measured memory_bytes: 5104
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
/*================Header Template==============*/
int a,b;
char mp[105][105];
int main() {
	read(a),read(b);
	for(int i=1;i<=50;i++)
		for(int j=1;j<=100;j++)
			mp[i][j]='.';
	for(int i=51;i<=100;i++)
		for(int j=1;j<=100;j++)
			mp[i][j]='#';
	b--;
	for(int i=1;i<=50&&b;i+=2)
		for(int j=1;j<=100&&b;j+=2)
			mp[i][j]='#',b--;
	a--;
	for(int i=100;i>50&&a;i-=2)
		for(int j=1;j<=100&&a;j+=2)
			mp[i][j]='.',a--;
	puts("100 100");
	for(int i=1;i<=100;i++,puts(""))
		for(int j=1;j<=100;j++)
			printf("%c",mp[i][j]);
}


Measured memory_bytes: 256
a=[0,0,0]
for i in range (3):
  a[i] = list(map(int,input().split()))
n = int(input())
for i in range(n):
  b = int(input())
  
  for j in range(3):
    for k in range(3):
      if a[j][k] == b:
        a[j][k] = 0

done = 0
for i in range(3):
  if (a[i][0] == a[i][1] == a[i][2] == 0 or a[0][i] == a[1][i] == a[2][i] == 0) and done == 0:
    done = 1
    print('Yes')

if done == 0 and (a[0][0] == a[1][1] == a[2][2] == 0 or a[0][2] == a[1][1] == a[2][0] == 0) :
  print('Yes')
  done = 1

if done == 0:
  print('No')


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

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

	c = b*(pow((b - 1), (a - 1)));

	cout << c << endl;

}

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define maxn 200010

using namespace std;

long long n,k,a[maxn],f[maxn];

inline bool cmp(long long x,long long y)
{
	return x>y;
}
 
inline bool check(long long x)
{
	long long limit=0;
	for(register int i=1;i<=n;++i)
	{
		if(a[i]*f[i]>x) limit+=a[i]-(x/f[i]);
	}
	return limit<=k;   
} 
 
int main()
{
	scanf("%lld%lld",&n,&k);
	for(register int i=1;i<=n;++i)
	    scanf("%lld",&a[i]);
	for(register int i=1;i<=n;++i)
	    scanf("%lld",&f[i]);
	sort(a+1,a+n+1);
	sort(f+1,f+n+1,cmp); 
	long long head=0,tail=1e12+10,ans;
	while(head<=tail)
	{
		long long mid=(head+tail)>>1;
		if(check(mid)) ans=mid,tail=mid-1;
		else head=mid+1;
	}
	printf("%lld",ans);
	return 0;
} 

Measured memory_bytes: 3328
#16 ABC130B
n,x=map(int,input().split())
l=list(map(int,input().split()))
a=[0]
for i in range(n):
    a.append(a[-1]+l[i])
j=True
for i in range(len(a)):
    if a[i]>x:
        print(i)
        j=False
        break
if j:
    print(n+1)

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

int main(){
  int x,y,z;
  cin >> x >> y >> z;
  
  int n = (x-z)/(y+z);
  
  cout << n << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;


int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M;
	int num[100001] = {};
	bool flag[100001] = {};
	for (int i = 1; i <= N; i++) {
		num[i] = 1;
	}
	flag[1] = true;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		if (flag[a])flag[b] = true;
		num[a]--;
		num[b]++;
		if (!num[a])flag[a] = false;
	}
	for (int i = 1; i <= N; i++)ans += flag[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<pair<int, int>>>;

int	main()
{
	int	V, E;
	cin >> V >> E;
	Graph	graph(V);
	int	s, t, d;
	for (int i = 0; i < E; ++i) {
		cin >> s >> t >> d;
		graph.at(s).push_back(make_pair(d, t));
	}	
	int	cost[(1<<15)][15] = {};
	for (int i = 0; i < (1 << V); ++i) {
		for (int j = 0; j < V; ++j)
			cost[i][j] = -1;
	}
	cost[1][0] = 0;
	for (int i = 0; i < (1 << V); ++i) {
		bitset<15>	bs(i);
		for (int j = 0; j < V; ++j) {
			if (!bs.test(j)) continue;
			if (cost[i][j] == -1) continue;
			for (auto pr : graph.at(j)) {
				d = pr.first;
				t = pr.second;
				if (bs.test(t)) continue;
				int	tmp = cost[i][j] + d;
				if (cost[i | (1 << t)][t] == -1 ||
						cost[i | (1 << t)][t] > tmp)
					cost[i | (1 << t)][t] = tmp;
			}
		}
	}
	int	min_cost = cost[(1 << V) - 1][0];
	for (int i = 1; i < V; ++i) {
		for (auto pr : graph.at(i)) {
			if (pr.second != 0) continue;
			if (cost[(1 << V) - 1][i] == -1) continue;
			int	tmp_cost = cost[(1 << V) - 1][i] + pr.first;
			if (min_cost == - 1 || min_cost > tmp_cost)
				min_cost = tmp_cost;
		}
	}
	cout << min_cost << endl;
}



Measured memory_bytes: 5020
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>

#define in std::cin
#define out std::cout

int kind, station;

const int MAX_STATION = 300000+1;
// セグメント木を持つグローバル配列
int n;
int BIT[MAX_STATION + 1];
void init(int n_param) {
	n = 1;
	while (n < n_param) {
		n <<= 1;
	}
}
void add(int index, int value)
{
	++index;
	while (index <= n) {
		BIT[index] += value;
		index += (index & -index);
	}
}
int sum(int index)
{
	int value = 0;
	++index;
	while (index > 0) {
		value += BIT[index];
		index -= (index & -index);
	}
	return value;
}


int kind_in[MAX_STATION];
std::vector<int> kind_out[MAX_STATION +1];
std::vector<int> tr_on[MAX_STATION +1];
int count[MAX_STATION +1];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> kind>>station;
	init(station);


	//区間入力
	for (int i = 0; i < kind; ++i)
	{
		int l, r;
		in >> l >> r;
		++kind_in[l];
		kind_out[r].push_back(l);
	}
	//倍数構成
	for (int i = 1; i <= station; ++i)
	{
		for (int p = i; p <= station; p += i)
		{
			tr_on[p].push_back(i);
		}
	}

	for (int i = 1; i <= station; ++i)
	{
#ifdef _DEBUG
		std::cout << "--------------------" << '\n';
		std::cout << kind_in[i] << '\n';
		for (auto p : tr_on[i]) { std::cout << p << ' '; }std::cout << '\n';
		for (auto p : kind_out[i]) { std::cout << p << ' '; }std::cout << '\n';
		std::cout << "--------------------" << '\n';
#endif
		add(i-1, kind_in[i]);
#ifdef _DEBUG
		std::cout << "--------------------" << '\n';
		for (int p = 1; p <= station; ++p) { std::cout << sum(p-1) << ' '; }std::cout << '\n';
		std::cout << "--------------------" << '\n';
#endif
		for (auto p : tr_on[i]) {
			if (i - p > 0) { count[p] -= sum(i - p - 1); }
			count[p] += sum(i-1);
		}
		for (auto p : kind_out[i]) {
			add(p-1, -1);
		}
	}

	for (int p = 1; p <= station; ++p)
	{
		std::cout << count[p] << std::endl;
	}

	return 0;
}
#endif


Measured memory_bytes: 27392
#include<bits/stdc++.h>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

signed main() {
	ll n, a, mae = 0, ato = 0; cin >> n;
	vector<string> v(n + 1);
	rep(i, n) {
		cin >> a; string s;
		for (int h = 20; h >= 0; h--) {
			if (a >= pow(2, h)) { a -= pow(2, h); s.push_back('1'); }
			else { s.push_back('0'); }
		}
		v[i] = s;
		//cout << s << endl;
	}
	vector<ll> ans(n), ok(21);
	while (true) {//[mae, ato)
		//cout << mae << ' ' << ato << endl;
		if (ato == n) {
			ans[mae] = ato - mae; mae++;
		}
		else {
			bool ng = false;
			rep(i, v[ato].size()) {
				if (v[ato][i] == '1' && ok[i] == 1) { ng = true; }
			}
			if (ng) {
				rep(i, v[mae].size()) {
					if (v[mae][i] == '1') { ok[i] = 0; }
				}
				ans[mae] = ato - mae; mae++;
			}
			else {
				rep(i, v[ato].size()) {
					if (v[ato][i] == '1') { ok[i] = 1; }
				}
				ato++;
			}
		}
		if (mae == n && ato == n) { break; }
	}
	ll qwerty = 0;
	rep(i, n) {
		//cout << ans[i] << endl;
		qwerty += ans[i];
	}
	cout << qwerty << endl;
	return 0;
}

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

int main() {
  
  int c[3][3];
  bool ok = 1;

  for (int j = 0; j < 3; j++) {
    for (int i = 0; i < 3; i++) {
      cin >> c[i][j];
    }
  }

  for (int j = 0; j < 2; j++) {
    for (int i = 0; i < 2; i++) {
      if((c[i][j] - c[i + 1][j]) != (c[i][j + 1] - c[i + 1][j + 1])) ok = 0;
    }
  }
  
  if (ok == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            int count = 0;
            for(int i = 0; i < s.Length/2; i++)
            {
                if (s[i] != s[s.Length - i - 1])
                {
                    count++;
                }
            }

            Console.WriteLine(count);


            //ここまで
        }
    }
}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c>=22) puts("bust");
    else puts("win");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ll N, Y; cin >> N >> Y;

  constexpr ll SEN   = 1000LL;
  constexpr ll GOSEN = 5000LL;
  constexpr ll MAN   = 10000LL;
  for (ll man = 0; man <= N; ++man)
  {
    for (ll gosen = 0; gosen <= N; ++gosen)
    {
      auto sen = N - (man + gosen);
      if(sen < 0)
        continue;
      auto y = man * MAN + gosen * GOSEN + sen * SEN;
      if(y == Y)
      {
        cout
          << man << SPACE
          << gosen << SPACE
          << sen << CRLF;
        return;
      }
    }
  }
  cout
    << -1 << SPACE
    << -1 << SPACE
    << -1 << CRLF;

  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 4005

struct Info{
	Info(){
		P = D = 0;
	}
	Info(ll arg_P,ll arg_D){
		P = arg_P;
		D = arg_D;
	}
	bool operator<(const struct Info &arg) const{
		return P < arg.P;
	}
	ll P,D;
};

int N;
ll LEFT[NUM],RIGHT[NUM];
ll dp[NUM];
Info info[2];
vector<Info> Over2,One;
vector<ll> A,B;

void func(){

	Over2.clear();
	One.clear();

	ll tmp_P,tmp_D;

	for(int loop = 0; loop < N; loop++){

		scanf("%lld %lld",&tmp_P,&tmp_D);
		if(loop < 2){
			info[loop].P = tmp_P;
		}

		if(tmp_D == 1){

			One.push_back(Info(tmp_P,tmp_D));

		}else{

			Over2.push_back(Info(tmp_P,tmp_D));
		}
	}

	if(N == 2){

		printf("%lld\n",abs(info[0].P-info[1].P));
		return;
	}

	sort(One.begin(),One.end());
	sort(Over2.begin(),Over2.end());

	for(int i = 0; i < Over2.size(); i++){

		if(i-1 >= 0){

			Over2[i].D--;
		}
		if(i+1 < Over2.size()){

			Over2[i].D--;
		}
	}

	A.clear();
	B.clear();

	for(int i = 0; i < Over2.size(); i++){
		for(int k = 0; k < Over2[i].D; k++){
			A.push_back(Over2[i].P);
		}
	}

	if(A.size() < One.size()){

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

	for(int i = 0; i < One.size(); i++){

		B.push_back(One[i].P);
	}

	ll num_A = A.size();
	ll num_B = B.size();

	ll minimum,min_index,left,right,mid,loc;

	for(int i = 0; i < One.size(); i++){

		minimum = HUGE_NUM;
		for(int k = 0; k < Over2.size(); k++){
			if(Over2[k].D == 0)continue;

			if(minimum > abs(One[i].P-Over2[k].P)){

				minimum = abs(One[i].P-Over2[k].P);
				min_index = k;
			}
		}

		left = 0,right = num_A-1,mid = (left+right)/2;

		while(left <= right){

			if(A[mid] >= Over2[min_index].P){

				loc = mid;
				right = mid-1;
			}else{

				left = mid+1;
			}
			mid = (left+right)/2;
		}

		LEFT[i] = max(0ll,loc-num_B);
		RIGHT[i] = min(num_A-1,loc+num_B);
	}

	dp[0] = 0;
	for(int i = 1; i <= num_B; i++){

		dp[i] = HUGE_NUM;
	}

	left = 0,right = 0;

	for(int i = 0; i < num_A; i++){

		while(left < num_B && RIGHT[left] < i)left++;
		while(right < num_B && LEFT[right] < i)right++;

		for(int k = right; k >= left; k--){
			if(k >= num_B)continue;
			dp[k+1] = min(dp[k+1],dp[k]+abs(A[i]-B[k]));
		}
	}

	printf("%lld\n",dp[num_B]+Over2[Over2.size()-1].P-Over2[0].P);
}

int main(){

	while(true){

		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 134212
#include <bits/stdc++.h>
#define N 100001
#define M 1001
#define ll long long
#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define prob "G"
#define fast ios_base:: sync_with_stdio(1); cin.tie(nullptr); cout.tie(nullptr);
#define io freopen(prob".inp","r",stdin); freopen(prob".out","w",stdout);
using namespace std;
int n,m;
vector<int>dsk[N];
int res[N],bac[N];
void read()
{
  cin>>n>>m;
  int u,v;
  while(m--)
  {
    cin>>u>>v;
    dsk[u].pb(v);
    bac[v]++;
  }
}
queue<int>q;
int ans=0;
void solve()
{
  for(int i=1;i<=n;i++) if(!bac[i]) q.push(i);
  int u,v;
  while(q.size())
  {
    u=q.front();
    q.pop();
    for(int i=0;i<dsk[u].size();i++)
    {
      v=dsk[u][i];
      res[v]=max(res[v],res[u]+1);
      ans=max(ans,res[v]);
      bac[v]--;
      if(!bac[v]) q.push(v);
    }
  }
  cout<<ans;
}
int main()
{
  fast
 // io
  read();
  solve();
}


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

using namespace std;

const int MAX = 1010000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {

	long long x, y;
	cin >> x >> y;

	if ((x + y) % 3 != 0) {
		cout << 0 << endl;;
	}
	else {
		long long a = min((2 * y - x) / 3, (2 * x - y) / 3);
		combinit();
		cout << comb((x + y) / 3, a) << endl;
	}



	return 0;
}

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

using namespace std;


int main() {
	int n;
	string s;
	cin >> n >> s;
	vector<int> cntE(n+1);
	vector<int> cntW(n+1);
	for (int i = 1; i <= n; i++) {
		cntE[i]=cntE[i-1]+(s[i-1]=='E');
		cntW[i]=cntW[i-1]+(s[i-1]=='W');
	}
	int bestV = n;
	for (int i = 1; i <= n; i++) {
		int tot = cntW[i-1]+cntE[n]-cntE[i];
		bestV = min(bestV, tot);
	}
	cout << bestV << "\n";
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter("\\s");
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = 0;
		for (int i = a; b >= i; i++) {
			if (c % i == 0) {
				x++;
			}
		}
		System.out.println(x);

	}

}

Measured memory_bytes: 26340
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define alll(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define endl '\n'

int main()
{
    int n,k;
    cin>>n>>k;
    if(k&1)
    {
        ll tmp = n / k;
        cout << tmp * tmp * tmp << endl;
    }
    else
    {
        ll tmp = n / (k/2);
        ll a = tmp / 2, b = tmp - a;
        cout << a*a*a+b*b*b << endl;
    }
}

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

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int main(){
	int k,m,n,A,B,C;
	A=read();B=read();C=read();
	printf("%d\n",max(0,B+C-A));
	return 0;
}

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

int main() {
    int a1,a2,a3;
    cin >> a1 >> a2 >> a3;
    int sum = a1 + a2 + a3;
    cout << (sum >= 22 ? "bust" : "win") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cmath>

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

  int x[n];
  int y[n];

  for(int i = 0; i < n; i++){
    std::cin >> x[i];
  }
  for(int i = 0; i < n; i++){
    std::cin >> y[i];
  }

  double d1 = 0, d2 = 0, d3 = 0, dc = 0;
  for(int i = 0; i < n; i++){
    int diff = std::abs(x[i] - y[i]);
    d1 += diff;
    d2 += pow(diff, 2);
    d3 += pow(diff, 3);
    dc = fmax(dc, diff);
  }
  
  printf("%f\n", d1);
  printf("%f\n", sqrt(d2));
  printf("%f\n", pow(d3,  1./ 3));
  printf("%f\n", dc);

  return 0;
}



Measured memory_bytes: 3336
import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().split()]
ab = []
for _ in range(N):
    ab.append([int(x) for x in input().split()])
cd = []
for _ in range(M):
    cd.append([int(x) for x in input().split()])
for i in ab:
    a, b = i
    ans = [10 ** 9, 0]
    for j in range(M):
        c, d = cd[j]
        j += 1
        if abs(a - c) + abs(b - d) < ans[0]:
            ans = [abs(a - c) + abs(b - d), j]
    print(ans[1])

Measured memory_bytes: 3064
#include<stdio.h>
#include <math.h>

int main(void){
  int n , m , x;
  scanf("%d %d %d",&n,&m,&x);
  
  int  c[n] , a[n][m];
  
  for(int i = 0;i < n;i ++){
    scanf("%d",&c[i]);
    for(int j = 0;j < m;j ++){
      scanf("%d",&a[i][j]);
    }
  }
  
  int k = (int)pow(2,n);
  int kumi[k][n];
  
  for(int i = 0;i < k;i ++){
     int temp = i;
     int count  = 0;
    while(count < n){
      kumi[i][count] = temp%2;
      temp /= 2;
      count ++;
    }
  }
  
  long X[13] = {0} , C = 0 , min = 9999999;
  
  for(int i = 0;i < k;i ++){
    for(int j = 0;j < n;j ++){
      if(kumi[i][j] == 1){
        for(int l = 0;l < m;l ++){
          X[l] += a[j][l];
        }
        C += c[j];
      }
    }
    for(int p = 0;p < m;p ++){
      if(X[p] < x){
        C = -1;
      }
    }
    if(C >= 0 &&C < min){
      min = C;
    }
    C = 0;
    for(int i = 0;i < m;i ++){
      X[i] = 0;
    }
  }
 if(min == 9999999){
   printf("-1\n");
 }
  else{
  printf("%d\n",min);
  }
  
  return 0;
}


Measured memory_bytes: 2784
#include<iostream>
#include "string"

using namespace std;
long int N,a[200000],A,B,ans;

int abs(int x){
	if(x<0){
		return -x;
	}
	return x;
}
 
int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> a[i];
		A+=a[i];
	}
	ans=10000000000000;
	for(int i=0;i<N-1;i++){
		B+=a[i];
		if(abs(A-(2*B))<ans){
			ans=abs(A-(2*B));
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#include <random>
//#include <chrono>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define MotoHaiyaku ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
int main()
{
    MotoHaiyaku
    ll x;
    cin>>x;
    if(x>=30) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
#define ld long double
#define pii pair <int,int>
#define pll pair <ll,ll>
#define pil pair <int,ll>
#define pli pair <ll,int>
#define ull unsigned long long
#define pdd pair <double,double>
#define pb push_back
#define mp make_pair
#define puu pair<ull,ull>
#define pvv pair<vector<int>, vector<int> >
#define _bp __builtin_popcount
#define ptt pair <Tree*,Tree*>
#define all(v) v.begin(),v.end()
#define en "\n"
const long double pi = acos(-1);
void boos()
{
     ios_base :: sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
}
void file()
{
   freopen("max.in","r",stdin);
   freopen("max.out","w",stdout);
}
const ll INF = 1e9 + 7;
const ll INF1 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTmx = (int)1e9;
const ld EPS = (ld)1e-9;
const int N = 3e5 + 100;
ll a[N];
ll b[N];
ll c[N];
int main()
{
    //file();
    boos();
    int x,y;
    int n,m,k;
    cin >> x >> y >> n >> m >> k;
    for(int i = 1;i <= n;i++)
    {
    	cin >> a[i];
	}
	for(int i = 1;i <= m;i++)
	{
		cin >> b[i];
	}
	for(int i = 1;i <= k;i++)
	{
		cin >> c[i];
	}
	ll sum = 0;
	sort(a + 1,a + n + 1);
	sort(b + 1,b + m + 1);
	sort(c + 1,c + k + 1);
	int l = n - x + 1;
	int l1 = m - y + 1;
	int r = k;
	for(int i = n - x + 1;i <= n;i++)sum += a[i];
	for(int i = l1;i <= m;i++)sum += b[i];
	while((l <= n || l1 <= m) && r >= 1)
	{
		if(l > n)
		{
			if(b[l1] < c[r])
			{
				sum += c[r--] - b[l1++];
			}else {
				break;
			}
			continue;
		}else if(l1 > m)
		{
			if(a[l] < c[r])
			{
				sum += c[r--] - a[l++];
			}else {
				break;
			}
			continue;
		}else {
			if(a[l] < b[l1])
			{
				if(c[r] > a[l])
				{
					sum += c[r--] - a[l++];
				}else {
					break;
				}
			}else {
				if(c[r] > b[l1])
				{
					sum += c[r--] - b[l1++];
				}else {
					break;
				}
			}
		}
	}
	cout << sum;
}

Measured memory_bytes: 5120
#include<stdio.h>
int main(void){
    char op;
    int a, b, r;
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        switch (op) {
            case '?':
                return 0; 
                break;
            case '+':
                r = a + b;
                break;
            case '-':
                r = a - b;
                break;
            case '*':
                r = a * b;
                break;
            case '/':
                r = a / b;
                break;
        }
        printf("%d\n", r);
    }
    return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  int n,m; cin >> n >> m;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];
  vector<vector<int>> path(n,vector<int>());
  rep(i,m){
    int a,b; cin >> a >> b;
    a--,b--;
    path[a].pb(b);
    path[b].pb(a);
  }
  int ans=0;
  rep(i,n){
    ll obj=h[i];
    bool ok=true;
    for(auto v:path[i]){
      if(obj<=h[v]) {
        ok=false; break;
      }
    }
    if(ok) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9056
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>

#define MAX_N 3000
#define MAX_X 5000
#define MAX_Y 5000

using namespace std;

typedef pair<int ,int > P;

int N;
bool field[MAX_X + 1][MAX_Y + 1];
vector<P> paul;

P edge;

bool search(P o,P p1,P v,int mode){
	bool result = false;
	P _p1,_v;
	_p1 = P(p1.first + v.first,p1.second + v.second);
	if(_p1.first > MAX_X || _p1.first < 0) return false;
	if(_p1.second > MAX_Y || _p1.second < 0) return false;
	if(field[_p1.first][_p1.second] == false) return false;
	if(_p1.first == o.first && _p1.second == o.second) return true;
	if(mode != 2){
		_v = P(v.second,v.first * -1);
		if(search(o,_p1,_v,1)) result = true;
	}
	if(mode != 1){
		_v = P(v.second * -1,v.first);
		if(search(o,_p1,_v,2)) result = true;
	}
	
	return result;
}

void solve(){
	for(int i = 0;i <= MAX_X;i++){
		for(int j = 0;j <= MAX_Y;j++){
			field[i][j] = false;
		}
	}
	for(int i = 0;i < paul.size();i++){
		P p = paul[i];
		field[p.first][p.second] = true;
	}

	edge = P(0,0);
	for(int i = 0;i < paul.size();i++){
		P p1 = paul[i];
		for(int j = i + 1;j < paul.size();j++){
			P p2 = paul[j];
			P v = P(p2.first - p1.first,p2.second - p1.second);
			if(search(p1,p1,v,0)){
				if(pow(edge.first,2) + pow(edge.second,2) < pow(v.first,2) + pow(v.second,2)){
					edge = P(v.first,v.second);
				}
			}
		}
	}
	return ;
}

int main(){
	
	while(true){
		scanf("%d",&N);
		if(N == 0) break;
		paul.clear();
		int _x,_y;
		for(int i = 0;i < N;i++){
			scanf("%d%d",&_x,&_y);
			paul.push_back(P(_x,_y));
		}
		
		solve();

		int ans = pow(edge.first,2) + pow(edge.second,2);
		printf("%d\n",ans);
	}

	return 0;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if (a % 2 || b % 2 || c % 2) {
        cout << 0 << endl;
        return 0;
    }
    rep (i, 1000) {
        int ta, tb, tc;
        ta = a, tb = b, tc = c;
        a = (tb + tc) / 2;
        b = (ta + tc) / 2;
        c = (ta + tb) / 2;
        if (a % 2 || b % 2 || c % 2) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
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;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll K, X;
  cin >> K >> X;

  cout << ((500 * K >= X) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

public static void main(String[] args){
String a,b;
String m;
Scanner sc = new Scanner(System.in);
a= sc.next();
b= sc.next();

a=a+b;
int c =Integer.parseInt(a);


m="No";
for(int i=1; i<=1000; i++){
if((c-(i*i))==0){
m="Yes";
break;
}
}
 System.out.println(m);
}
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM = 1000000007;

int main()
{
    // 整数の入力
    ll N;
    cin >> N;
    ll min_v = BASE_NUM;
    ll count = 0;
    for(int i = 0;i< N;i++){
        ll p;
        cin >> p;
        if (p < min_v){
            count++;
        }
        min_v = min(p,min_v);
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <string>
#include <algorithm>

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

  std::vector<std::tuple<std::string, int, int>> R;
  R.reserve(n);

  for (int i=0; i<n; i++) {
    std::string s;
    int p;
    std::cin >> s >> p;
    R.emplace_back(s, 100-p, i);
  }

  std::sort(R.begin(), R.end());

  for (auto const& r : R) {
    std::cout << std::get<2>(r)+1 << '\n';
  }

  return 0;
}


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

using namespace std;

int f(int a) {
  if (!a) {
    return 0;
  }
  return 1 + f(a % (__builtin_popcount(a)));
}

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

  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    cnt += s[i] == '1';
  }
  reverse(s.begin(), s.end());
  int a[2] = {0};
  a[0] = cnt - 1;
  a[1] = cnt + 1;
  vector<int> p[2];
  int kek[2] = {0};
  for (int i = 0; i < 2; ++i) {
    if (a[i] <= 0) {
      continue;
    }
    p[i].resize(n + 1);
    p[i][0] = 1 % a[i];
    for (int j = 1; j <= n; ++j) {
      p[i][j] = (p[i][j - 1] * 2) % a[i];
    }
    for (int j = 0; j < n; ++j) {
      kek[i] += (s[j] - '0') * p[i][j];
      kek[i] %= a[i];
    }
  }
  vector<int> ans(n);
  for (int i = n - 1; i >= 0; --i) {
    int j = 1;
    int z = 1;
    if (s[i] == '1') {
      j = 0;
      z = -1;
    }
    if (a[j] == 0) {
      ans[n - i - 1] = 0;
      continue;
    }
    int kk = kek[j] + z * p[j][i];
    while (kk < 0) {
      kk += a[j];
    }
    kk %= a[j];
    ans[n - i - 1] = 1 + f(kk);
  }
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << '\n';
  }

  return 0;
}


Measured memory_bytes: 5984
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

struct edge{
    uint64 to;
    uint64 cost;
};

vector<uint64> dijkstra(const vector<vector<edge>>& graph, uint64 s){
    using P = pair<uint64,uint64>;
    
    vector<uint64> vCost(graph.size(), UINT64_MAX); vCost[s]=0ull;
    priority_queue<P,vector<P>,greater<P>> que; que.push( P(0,s) );
    
    while(!que.empty()){
        P p=que.top(); que.pop();
        uint64 cost = p.first;
        uint64 idx  = p.second;
        if(vCost[idx] < cost){ continue; }
        for(uint i=0; i<graph[idx].size(); ++i){
            edge e = graph[idx][i];
            if(vCost[e.to] <= vCost[idx] + e.cost){ continue; }
            vCost[e.to] = vCost[idx] + e.cost;
            que.push( P(vCost[e.to], e.to) );
        }
    }
    return vCost;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int H, W; cin >> H >> W;
    vector<vector<edge>> graph(10);
    for(uint row=0; row<10; ++row){
        for(uint col=0; col<10; ++col){
            uint c; cin >> c;
            graph[col].push_back( edge{row, c} ); // reversed direction
        }
    }
    vector<uint64> vCost = dijkstra(graph, 1); // search reversed direction
    
    int64 sum=0ll;
    for(int h=0; h<H; ++h){
        for(int w=0; w<W; ++w){
            int a; cin >> a;
            if(a==-1){ continue; }
            sum += vCost[a];
        }
    }
    
    cout << sum << endl;
    
    return 0;
}

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

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


Measured memory_bytes: 256
//ABC166 A

import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);

    String S;
    S=sc.nextLine();

    if(S.equals("ABC")){
      System.out.println("ARC");
    }if(S.equals("ARC")){
      System.out.println("ABC");
    }


  }
}


Measured memory_bytes: 35620
#include<bits/stdc++.h>
using namespace std;
long long a[200005],mod=1e9+7;
long long qpow(long long a,long long b){
    long long res=1;
    while(b){
        if(b&1) res=res*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return res%mod;
}
int main(){
    long long n;
    cin>>n;
    for(long long i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    long long num=qpow(4,n-1),sum=0;
    for(long long i=1;i<=n;i++){
        sum+=num%mod*(n-i+2)%mod*a[i]%mod;
        sum%=mod;
    }
    cout<<sum%mod<<endl;
}

Measured memory_bytes: 1792