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

using namespace std;

const int maxn = 1e5+10;
const ll oo = 1e18;

int n,m,a[maxn];
ll f[maxn],X[maxn];

int main() {
   // freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>m;
    for (int i=1;i<=n;i++) cin>>a[i];
    for (int i=1;i<n;i++) {
        int l = a[i], r = a[i+1];
        if (l<r) {
            f[0]+=r-l;
            f[l+1]-=r-l;
            f[r+1]+=r-l;

            f[l+1]+=r+1;
            f[r+1]-=r+1;

            X[l+1]--;
            X[r+1]++;
        } else {
            f[r+1]+=m-l+r;
            f[l+1]-=m-l+r;

            f[0]+=r+1;
            f[r+1]-=r+1;
            f[l+1]+=m+r+1;

            X[0]--;
            X[r+1]++;
            X[l+1]--;
        }
    }
    ll ans = oo;
    for (int i=1;i<=m;i++) {
        f[i]+=f[i-1];
        X[i]+=X[i-1];
        ans = min(ans,f[i]+1ll*i*X[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2176
// https://atcoder.jp/contests/abc118/tasks/abc118_c

// http://ctylim.hatenablog.com/entry/2015/08/30/191553
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>

#define ALL(a) (a).begin(), (a).end()
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define MAXINDEX(c) distance((c).begin(), max_element((c).begin(), (c).end()))
#define MININDEX(c) distance((c).begin(), min_element((c).begin(), (c).end()))
#define DEBUG(x) std::cerr << #x << " = " << (x) << " (" << __FILE__ << "::" << __LINE__ << ")" << std::endl;
#define ERROR(s) std::cerr << "Error::" << __FILE__ << "::" << __LINE__ << "::" << __FUNCTION__ << "::" << (s) << std::endl;
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)

#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

template <typename T>
T inputValue()
{
  T a;
  std::cin >> a;
  // scanf("%llu", &a);
  return a;
}

void inputArray(int *p, int a)
{
  rep(i, a)
  {
    std::cin >> p[i];
    // scanf("%d",p+i);
  }
}

template <typename T>
void inputVector(std::vector<T> *p, int a)
{
  rep(i, a)
  {
    T input;
    std::cin >> input;
    // scanf("%llu", &input);
    p->push_back(input);
  }
}

template <typename T>
void output(T a, int precision)
{
  if (precision > 0)
  {
    std::cout << std::setprecision(precision) << a << "\n";
  }
  else
  {
    std::cout << a << "\n";
  }
}

using namespace std;

int gcd(int a, int b)
{
  while (1)
  {
    if (a < b)
      swap(a, b);
    if (!b)
      break;
    a %= b;
  }
  return a;
}

void out(int p){
  if(p==0){
    cout << "First"<< endl;
  } else {
    cout << "Second" << endl;
  }
}

typedef unsigned long long int ulli;
int main(int argc, char **argv)
{
  // int N = inputValue<int>();
  // vector <int> v;
  // inputVector(&v, N);

  

  char c;
  int N = 0;
  char first, last;
  while ((c = getc(stdin)) != EOF && (c >= 'a' && c <= 'z'))
  {
    if (N == 0) {
      first = c;
    }
    N++;
    last = c;
  }

  if (N<=2){
    out(1);
  } else if (first != last) {
    if(N&1){
      out(0);
    }else{
      out(1);
    }
  } else {
    if(N&1){
      out(1);
    }else{
      out(0);
    }
  }


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<set>
#include<vector>
using namespace std;

int solve(){
  int n;
  string s, t;
  cin >> n >> s >> t;
  for(int i=0; i<2*n; i++){
    if(i&1) cout << t[i/2];
    else    cout << s[i/2];
  }
  cout << endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

k = ni()
a, b = na()

flag = False
i = a
while i <= b:
    if i % k == 0:
        flag = True
    i += 1

print("OK" if flag else "NG")

Measured memory_bytes: 9252
#include <stdio.h>

void bubbleSort(int numbers[], int array_size);

int main(void){
    int i, n;
    int line[100] = {0};
    int sum = 0;

    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &line[i]);
    }

    bubbleSort(line, n);

    for(i = 1; i < n; i++){
        sum += line[i];
    }

    if(line[0] < sum) printf("Yes\n");
    else printf("No\n");

    return 0;

}

void bubbleSort(int numbers[], int array_size)
{
  int i, j, temp;

  for (i = 0; i < (array_size - 1); i++) {
    for (j = (array_size - 1); j > i; j--) {
      if (numbers[j-1] < numbers[j]) {
        temp = numbers[j-1];
        numbers[j-1] = numbers[j];
        numbers[j] = temp;
      }
    }
  }
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}

	Scanner cin;

	const int MOD = 1000000007;
	const int INF = int.MaxValue - 10;
	const long INFL = long.MaxValue - 10;
	const double EPS = 1e-8;
	const double PI = 3.1415926536;
	int[,] dir8;
	int[,] dir4;
	


	void prog()
	{
		cin = new Scanner();
		dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		int N = cin.nextInt();
		int A = cin.nextInt();
		int B = cin.nextInt();
		int ans = 0;
		for (int i = 0; i < N; i++)
		{
			int t = cin.nextInt();
			if (t < A || t >= B)
			{
				ans++;
			}
		}
		Console.WriteLine(ans);
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

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

const int MAXN = 310;
int N;
int a[MAXN];
double dp[MAXN][MAXN][MAXN];

int cnt[4];

double solve(int x, int y, int z) {
    double ret;
    if(x==0 && y==0 && z==0) return 0;
    if(dp[x][y][z]>0.0) return dp[x][y][z];
    int sum = x+y+z;
    ret = 1.0*N/sum;
    if(x>0) {
        ret += 1.0*x/sum * solve(x-1, y, z);
    }
    if(y>0) {
        ret += 1.0*y/sum * solve(x+1, y-1, z);
    }
    if(z>0) {
        ret += 1.0*z/sum * solve(x, y+1, z-1);
    }
    return dp[x][y][z] = ret;
}
int main() {
    cin >> N;
    memset(cnt, 0, sizeof(cnt));
    for(int i=1; i<=N; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    cout <<fixed<<setprecision(14) <<solve(cnt[1], cnt[2], cnt[3]) << endl;
    return 0;
}

Measured memory_bytes: 225536
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+20;

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

int n,a[N];ll ans;

int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++)
	{
		ans+=a[i]/2;a[i]%=2;
		if(a[i] && a[i+1]) ans++,a[i+1]--;
	}
	printf("%lld\n",ans);return 0;
}

Measured memory_bytes: 640
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let N = read::<i32>();
    println!("ABC{}", N);

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define lli long long int

int main() {
    int a,b;
    cin>>a>>b;
    int x1 = a + b;
    int x2 = a - b;
    int x3 = a  * b;
    int ans = max(x1, max(x2,x3));
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
    
  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]
  
  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    
    if x == y:
      return
    
    if self.parents[x] > self.parents[y]:
      x, y = y, x
    
    self.parents[x] += self.parents[y]
    self.parents[y] = x
  
  #xが属するグループに含まれる要素数(サイズ)を返す
  def size(self, x):
    return -self.parents[self.find(x)]
  
  def same(self, x, y):
    return self.find(x) == self.find(y)
  
  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]
  
  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]
  
  def group_count(self):
    return len(self.roots)
  
  #根と根の下に属する要素のリスト辞書を返す
  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main(): 
  n, m, k = map(int, input().split())
  uf = UnionFind(n)
  ans = [0] * n
  deg = [0] * n
  for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    uf.union(a,b)
    deg[a] += 1
    deg[b] += 1
  for _ in range(k):
    c,d = map(int, input().split())
    c -= 1
    d -= 1
    if uf.same(c,d):
      deg[c] += 1
      deg[d] += 1
  for i in range(n):
    ans[i] = uf.size(i) - deg[i] - 1
  print(' '.join(map(str,ans)))

if __name__ == "__main__":
  main()

Measured memory_bytes: 18760
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(n):
    if b[i]<a[i]:
        ans+=b[i]
    else:
        ans+=a[i]
        b[i]-=a[i]
        if a[i+1]>b[i]:
            ans+=b[i]
            a[i+1]-=b[i]
        else:
            ans+=a[i+1]
            a[i+1]=0
print(ans)

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    ans += (s[i] == t[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
# input = sys.stdin.readline

N, A, B, C, D = map(int, input().split())
S = list(input())

if C < D:
    cnt_x = 0
    for pos in range(B - 1, D):
        Si = S[pos]
        if Si == '#':
            cnt_x += 1
            if cnt_x > 1:
                print('No')
                sys.exit()
        else:
            cnt_x = 0
    else:
        S[pos] = '#'
    #
    cnt_x = 0
    for pos in range(A - 1, C):
        Si = S[pos]
        if Si == '#':
            cnt_x += 1
            if cnt_x > 1:
                print('No')
                sys.exit()
        else:
            cnt_x = 0
else:
    cnt_o = cnt_x = 0
    for pos in range(A - 1, D):
        Si = S[pos]
        if Si == '#':
            cnt_o = 0
            cnt_x += 1
            if cnt_x > 1:
                print('No')
                sys.exit()
        else:
            cnt_x = 0
            cnt_o += 1
            if pos >= B and cnt_o > 2:
                pos_fnk = pos - 1
                break
    else:
        pos_fnk = pos
    #
    S[pos_fnk] = '#'
    # print("# comment",''.join(S))
    cnt_x = 0
    for pos in range(A - 1, C):
        Si = S[pos]
        if Si == '#':
            cnt_x += 1
            if cnt_x > 1:
                print('No')
                sys.exit()
        else:
            cnt_x = 0
    else:
        S[pos] == '#'
    S[pos_fnk] = '.'
    #
    cnt_x = 0
    for pos in range(pos_fnk, D):
        Si = S[pos]
        if Si == '#':
            cnt_x += 1
            if cnt_x > 1:
                print('No')
                sys.exit()
        else:
            cnt_x = 0

print('Yes')

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


int main(){

	int N;
	cin>>N;
	
	for(int i=1;true;i++){
		if(i*i>N){
			cout<<(i-1)*(i-1)<<endl;
			return 0;
		}
	}
	
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main (void)


{


   int a,b,c;


   int cnt=0;


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


   int i;


   for(i=a;i<=b;i++){


      if(c%i==0){


         cnt++;


      }


   }


   printf("%d\n",cnt);


   return 0;


}

Measured memory_bytes: 596
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int i,j;
        String str;
        int h,w;
        while((h=scan.nextInt())!=0){
            w=scan.nextInt();
            for(i=0;i<h;i++){
                for(j=0;j<w;j++){
                    if(i==0||j==0||j==w-1||i==h-1)System.out.printf("#");
                    else System.out.printf(".");
                }
                System.out.printf("\n");
            }
            System.out.println();
        }
   }
}


Measured memory_bytes: 57192
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

Int n, a[216000];

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

  int res = 0;
  int last = a[0];
  int up = 0;
  for(int i = 1;i < n;i++){
    if(up == 0){
      if(last < a[i])up = 1;
      if(last > a[i])up = -1;
      last = a[i];
    }
    else{
      if(up == 1 && last > a[i] || up == -1 && last < a[i]){
	res++;
	last = a[i];
	up = 0;
      }
      last = a[i];
    }
  }
  cout << res + 1 << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
void ABC150(void);
void ABC151(void);
void ABC152(void);
void ABC153(void);
void ABC154(void);
void ABC155(void);
void ABC156(void);
void ABC157(void);
void ABC158(void);
void ABC159(void);

int main(void){
    ABC153();
}

void ABC153(){
    int h,a;
    cin>>h>>a;
    if(h%a==0)a=h/a;
    else a=h/a+1;
    cout<<a<<endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);

	int n = sca.nextInt();
	int k = sca.nextInt();
	long[] hi = new long[n];
	for(int i = 0; i < n; i++) {
		hi[i] = sca.nextLong();
	}

	Arrays.sort(hi);

	long ans = 0L;

	if(n <= k) {
		ans = 0;
	}
	else {
		for(int i = 0; i <= n-1-k; i++) {
			ans = ans + hi[i];
		}
	}
	System.out.println(ans);

	// 後始末
	sca.close();
	}
}

Measured memory_bytes: 89376
import java.util.*;
public class Main {


    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        int N = Integer.parseInt(scan.next());

        int price = 0;
        int[] priceArray = new int [N];

        for(int i =0; i < N; i++){
            price = Integer.parseInt(scan.next());
            priceArray[i] = price;
        }

        Arrays.sort(priceArray);
        priceArray[N-1] = priceArray[N-1] / 2;

        int ans = 0;
        for(int i =0; i < N; i++){
            ans += priceArray[i];
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
#include <stdio.h>
int main(void){
	int x1,y1,x2,y2,x3,y3,x4,y4;
	scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
	x3 = x2 - (y2-y1);
	y3 = y2+(x2-x1);
	x4 = x1-(y2-y1);
	y4 = y1 + (x2-x1);
	printf("%d %d %d %d",x3,y3,x4,y4);
	return 0;
}

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

using namespace std;

string s;
int N, sol;
vector < int > a;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> N;
    
    while (N) {
        if (N % 10 == 9) {
            cout << "Yes";
            return 0;
        }
        
        N /= 10;
    }
    
    
    
    cout << "No" << '\n';
    return 0;
}


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

int main(){
    int a, b;
    std::cin >> a >> b;
    if(a == 2 || b == 2){
        std::cout << "No" << std::endl;
    }else{
        std::cout << "Yes" << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import math
n = int(input())
ans_list = [0 for _ in range(n)]
ceil_n = math.ceil(n ** 0.5)
for x in range(1, ceil_n):
    for y in range(x, ceil_n):
        for z in range(y, ceil_n):
            value = (x ** 2) + (y ** 2) + (z ** 2) + (x*y) + (y*z) + (z * x)
            if value <= n:
                if (x == y) & (y == z):
                    point = 1
                elif (x == y) | (y == z) | (z == x):
                    point = 3
                else:
                    point = 6
                ans_list[value - 1] += point
for i in range(n):
    print(ans_list[i])

Measured memory_bytes: 9552
#include <stdio.h>

int main(void) {
    int k;
    scanf("%d", &k);
    int count = 0;

    for (int i = 1; i <= k; ++i) {
        if (i % 2 == 0) {
            for (int j = 1; j <= k; ++j) {
                if (j % 2 == 1) {
                    count++;
                }
            }
        }
    }
    printf("%d\n", count);
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string _S;
    cin >> _S;
    if (_S.size() <= 2) {
        cout << 0 << endl;
        return 0;
    }
    string S;
    REP(i,_S.size()) {
        if (i != _S.size()-1 && _S[i] == 'B' && _S[i+1] == 'C') {
            S.pb('D');
            i++;
        }
        else {
            S.pb(_S[i]);
        }
    }
    vector<string> T;
    ll a = 0;
    ll count = 0;
    REP(i,S.size()) {
        if (S[i] == 'A') a++;
        else if (S[i] == 'D') count += a;
        else a = 0;
    } 
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    string s, t; cin >> s >> t;
    ll cnt = 0;
    for(ll i = 0; i < s.size(); i++)
    {
        if(s[i] != t[i])
            cnt++;
    }
    cout <<cnt;
    
    
}

Measured memory_bytes: 3916
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int n = sc.nextInt();
        int[] as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt();
        }
        Arrays.sort(as);
        
        if (n % 2 == 0) {
            int tmp =  1;
            for (int i = 0; i < n; i += 2) {
                if (as[i] != tmp || as[i + 1] != tmp) {
                    System.out.println(0);
                    return;
                }
                tmp +=2;
            }
        } else {
            if (as[0] != 0) {
                System.out.println(0);
                return;
            }

            int tmp =  2;
            for (int i = 1; i < n; i += 2) {
                if (as[i] != tmp || as[i + 1] != tmp) {
                    System.out.println(0);
                    return;
                }
                tmp +=2;
            }
        }

        int ans = 1;
        for (int i = 0; i < n / 2; i++) {
            ans = (ans * 2) % (1_000_000_000 + 7);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 51856
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int a[100010];

int main()
{
	int n;scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for (int i=1;i<=n/2;i++) swap(a[i],a[n+1-i]);
	int k=1;
	while (k<=n&&a[k]>=k) k++;
	k--;
	bool ok=0;
	int j=k;
	while (j<a[k]) j++;
	if ((j-k)%2==1) ok=1;
	j=k;
	while (j<n&&a[j+1]>=k) j++;
	if ((j-k)%2==1) ok=1;
	if (ok) puts("First"); else puts("Second");
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define IOS  cin.tie(0),cout.tie(0); ios::sync_with_stdio(false);
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
 
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main() {
  IOS

  int n, tmp, sum, ans = INT_MAX;
  cin >> n;
  int arr[n];
  for(int i=0; i<n; i++) {
    cin >> arr[i]; 
  }

  for(int i=1; i<=100; i++) {
    sum = 0;
    for(int j=0; j<n; j++) {
      sum += pow(abs(arr[j] - i), 2);
    }
    ans = min(ans, sum);
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;

inline bool isValid(int m,vi& v){
    string s = to_string(m);
    for(int i = 0; i < v.size(); i++){
        int pos = s.find(to_string(v[i]));

        if(pos != std::string::npos) return false;
    }
    return true;
}
int main(){
    int N,K; cin >> N >> K;
    vi d(K); rep(i,K) cin >> d[i];

    int moyenne = N;

    for(;;moyenne++){
        if(isValid(moyenne,d)) break;
    }

    cout << moyenne << endl;
}

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

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int s, w;
  cin >> s >> w;

  if(w >= s){
    cout << "unsafe\n";
  }else{
    cout << "safe\n";
  }
  return 0;
}



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

using namespace std;

vector<int> tree[200];
int cost[200];

int min_cost(int index){
	if(tree[index].size() == 0){
		return cost[index];
	}
	int sum = 0;
	int siz = tree[index].size();
	for(int i = 0; i < siz; i++){
		sum += min_cost(tree[index].at(i));
	}
	return min(sum, cost[index]);
}

int main(){
	
	string name[200];
	
	int n, m;
	
	while(true){
		
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		for(int i = 0; i < n; i++){
			cin >> name[i] >> cost[i];
			tree[i].erase(tree[i].begin(), tree[i].end());
		}
		
		cin >> m;
		
		for(int i = 0; i < m; i++){
			string str;
			int num;
			cin >> str >> num;
			int index = 0;
			for(int j = 0; j < n; j++){
				if(str == name[j]){
					index = j;
					break;
				}
			}
			for(int j = 0; j < num; j++){
				string str2;
				cin >> str2;
				for(int k = 0; k < n; k++){
					if(str2 == name[k]){
						tree[index].push_back(k);
						break;
					}
				}
			}
		}
		
		string str;
		cin >> str;
		int index;
		
		for(int i = 0; i < n; i++){
			if(str == name[i]){
				index = i;
				break;
			}
		}
		
		cout << min_cost(index) << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3164
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n, m;
int x[101010];
vector<int> Group[101010];

int main(){
    cin >> n >> m;
    REP(i, n)cin >> x[i];
    REP(i, n)Group[x[i] % m].emplace_back(x[i]);
    int ans = 0;
    vector<int> v;
    v.emplace_back(0);
    if(m % 2 == 0)v.emplace_back(m/2);
    for(auto i : v){
        ans += (int)Group[i].size() / 2;
    }
    for(int i = 1;i <= (m - 1)/2;i++){
        vector<int> s = Group[i], t = Group[m - i];
        if((int)s.size() < (int)t.size())swap(s, t);
        ans += (int)t.size();
        sort(ALL(s));
        int idx = 0;
        int cnt = (int)s.size() - (int)t.size();
        while(idx < (int)s.size() - 1 && cnt >= 2){
            if(s[idx] == s[idx + 1]){
                idx += 2;
                cnt -= 2;
                ans++;
                continue;
            }
            idx++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6144
import java.util.*;
public class Main 
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int T = in.nextInt();
		int ans = 1001;
		for (int i = 0 ; i < N ; i++)
		{
			int c = in.nextInt();
			int t = in.nextInt();
			if (t <= T)
			{
				if(ans > c)
				ans = c;
			}
		}
		
		if (ans == 1001)
			System.out.println("TLE");
		else
			System.out.println(ans);
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n, m, c;
  int ans=0;
  cin>>n>>m>>c;
  int b[m], a[n][m];
  REP(i, m)cin>>b[i];
  REP(i, n)REP(j, m)cin>>a[i][j];

  REP(i, n){
    int work=0;
    REP(j, m) work+= a[i][j]*b[j];
    work+=c;
    if(work>0) ++ans;
  }
  cout<<ans<<endl;

  return 0;
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

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

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int dp[4004][4004];
int K[4004][4004];

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  vint w(N), sum(N+1);
  rep(i, N) cin >> w[i], sum[i+1] = sum[i]+w[i];

  fill(dp[0], dp[4004], inf);
  rep(i, N) dp[i][i] = 0, K[i][i] = i;
  reps(len, 1, N+1) {
    rep(i, N-len) {
      int j = i + len;
      reps(r, K[i][j-1], K[i+1][j]+1) {
	int cost = dp[i][r]+dp[r+1][j]+sum[j+1]-sum[i];
	if(dp[i][j] > cost) dp[i][j] = cost, K[i][j] = r;
      }
    }
  }

  cout << dp[0][N-1] << endl;

  return 0;
}

Measured memory_bytes: 205980
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h,w;
  cin>>h>>w;
  vector<int>num(h);
  for (int i=0;i<w+2;i++)
    cout << '#';
  cout << endl;
  for (int i=0;i<h;i++){
    cout << '#';
    string c;
    cin>>c;
    cout << c << '#'<<endl;
  }
  for (int i=0;i<w+2;i++)
    cout << '#';
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>

using namespace std;

struct mint{
    static const int MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a){
        return mint(v) *= a;
    }

    mint pow(long long k){
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }
};

int main(){
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);
    mint x(0);
    for(int d = 1; d < n; ++d){
        x += mint(d) * mint(n - d) * mint(m) * mint(m);
    }
    for(int d = 1; d < m; ++d){
        x += mint(d) * mint(m - d) * mint(n) * mint(n);
    }
    x *= mint::comb(n * m - 2, k - 2);
    printf("%lld\n", x.v);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
    int hotel[4][3][10],i,j,k,test,b,f,r,v;
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                hotel[i][j][k]=0;
            }
        }
    }
    scanf("%d",&test);
    for(i=0;i<test;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        hotel[b-1][f-1][r-1]+=v;
    }
    for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d",hotel[0][j][k]);
            }
            printf("\n");
        }
    for(i=1;i<4;i++){
        printf("####################\n");
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d",hotel[i][j][k]);
            }
            printf("\n");
        }
    }
    return 0;
}


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

int main(){
    ll n;
    cin >> n;
    ll count = 0;
    ll c = 0;
    if(n==100000)
        count -= 1;
    if(n>=10000)
    {
        count += n - 10000 +1;
    }
    if(n>=100)
    {
        if(n>=1000)
            count += 900;
        else
        {
            count += n - 100 + 1;
        }
        
    }
    if(n>=10)
        count += 9;
    else
        count += n;
    cout << count;
}


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

int main(){
  while(1){
  int x,h;
  cin>>x>>h;
  if(!x&&!h)break;
  double H=sqrt(h*h+(x/2.0)*(x/2.0));
  double ans=x*x+2*(x*H);
  printf("%.10f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  double a,b,c,d;
  cin>>a>>b>>c>>d;
  printf("%.10f\n",sqrt((a-c)*(a-c)+(b-d)*(b-d)));
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) 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> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }


struct UnionFind{
	vector<int> data;
	
	UnionFind(int n){
		data.assign(n,-1);
	}
	
	bool unite(int x,int y){
		x=find(x),y=find(y);
		if(x==y) return(false);
		if(data[x]>data[y]) swap(x,y);
		data[x]+=data[y];
		data[y]=x;
		return(true);
	}
	
	int find(int k){
		if(data[k]<0) return(k);
		return(data[k]=find(data[k]));
	}
	
	int size(int k){
		return(-data[find(k)]);
	}
};




int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;cin >> n >> m;
	vector<pii> a(m);
	rep(i,m){
		cin >> a.at(i).first >> a.at(i).second;
		a.at(i).first--;
		a.at(i).second--;
	}
	int ans = 0;
	rep(i,m){
		UnionFind uf(n);
		rep(j,m){
			if(j == i) continue;
			uf.unite(a.at(j).first, a.at(j).second);
		}
		if(uf.size(0) != n) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <memory>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {

    ll N, M;

    vector<ll> X;

    cin >> N >> M;
    if(N>M)
    {
        cout<<0<<endl;
        return 0;
    }

    X.resize(M);

    for(ll i=0; i<M; ++i)
        cin >> X[i];

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

    vector<ll> L;
    L.resize(M-1);
    for(int i=0; i<M-1; ++i)
        L[i] = X[i+1]-X[i];

    std::sort(L.begin(), L.end(), std::greater<int>());

    ll acm=0;
    for(ll i=0; i<N-1; ++i)
       acm += L[i];

    ll ans = X[M-1] - X[0] - acm;

    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
typedef long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;

int N, M;
int ans = 0;
vector<int> b;

int main() {
	cin >> N >> M;
	pair<int, int> a[100001];
	rep(i, 0, M)cin >> a[i].second >> a[i].first;
	rep(i, 0, N)b.push_back(1);
	sort(a, a + M);
	vector<int> s;
	b[a[0].first - 1] = 0;
	ans++;
	s.push_back(a[0].first - 1);
	rep(i, 1, M) {
		int q = 0;
		rep(j, 0, s.size()) {
			if (a[i].second <= s[j] && a[i].first > s[j])
				q++;
		}
		if (q == 0) {
			b[a[i].first - 1] = 0;
			ans++;
			s.push_back(a[i].first - 1);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1660
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <ctime>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#ifdef __APPLE__
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...)
#endif

const int N = (int)1e6 + 123;
const int MOD = (int)1e9 + 7;
const int inf = (int)5e8;
const long long infll = (long long)1e17;

void solve() {
    int n;
    cin >> n;
    int cur = 1;
    while (cur * 2 <= n) {
        cur *= 2;
    }
    cout << cur;
}

int main() {
#ifdef __APPLE__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<limits.h>
#include<queue>
#include<string>
using namespace std;

int pop_and_print(priority_queue<int>& qu)
{
	cout << qu.top() << endl;  
	qu.pop();
	return 0;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	int inp;
	priority_queue<int> qu;
	while(1){
		cin >> s;
		if (s=="end"){
			break;
		}else if(s=="insert"){
			cin >> inp;
			qu.push(inp);
		}else{
			pop_and_print(qu);
		}
	}
	
	return 0;
}

Measured memory_bytes: 5468
#include <iostream>
#include <stdio.h>

#include <string>

#include <vector>
#include <list>
#include <map>

#include <algorithm>
#include <utility>

using namespace std;

int main(const int argc, const char **argv){
  int N, T;
  scanf("%d %d", &N, &T);

  int ans = 1000;
  bool find = false;
  for(int i = 0; i < N; i++){
    int c, t;
    scanf("%d %d", &c, &t);

    if(t <= T){
      find = true;
      if(c < ans){
        ans = c;
      }
    }
  }

  if(find){
    printf("%d\n", ans);
  }else{
    printf("TLE\n");
  }

  return 0;
}


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


const long long INF = 1LL << 60;

using namespace std;
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; }

const int MOD = 1000000007;


// 入力
int N, a[22][22];
// dp[i][j] : iのbitが立ってる女性、j番目の男までマッチングが終わってる時の組み合わせの数
int dp[1 << 22][22];


int main() {
    cin >> N;
    for(int i=0;i<N;++i) for(int j=0;j<N;++j) cin >> a[i][j];
    
    dp[0][0] = 1;
    for(int i=0;i<N;++i){ // i人の男性の調査が終わっている。
        for(int bit=0;bit < (1<<N);++bit){ // bitの、1が立ってる女性の調査が終わっている。
            if(i == __builtin_popcount(bit)){ // 調査済みの男性と女性の数が一致する時のみ女性の調査を開始。
                for(int j=0;j<N;++j){ // j人目の女性を調査。
                    if(!(bit & (1<<j))){ // j人目の女性が未調査かつ
                        if(a[i][j]){ // i番目の男とj番目の女性の相性が良かったらマッチングさせる。
                            dp[bit | (1<<j)][i+1] += dp[bit][i];
                            if(dp[bit | (1<<j)][i+1] >= MOD) dp[bit | (1<<j)][i+1] -= MOD;
                        }
                    }
                }
            }
        }
    }


    cout << dp[(1<<N)-1][N] << endl;
    return 0;
}

Measured memory_bytes: 182528
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	if len(res)==0:
		res = [n]
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	data = [2]
	#data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	ans = [x for x in data if x!=0]
	#ans = data[:]
	return ans

x,y = readInts()

if y>=2*x and y<=4*x and y%2==0:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 9608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a,b;
	cin>>a>>b;
	for(ll i=1;i<=1000000;i++){
		ll now=i;
		if(now*8/100==a&&now*10/100==b){
			cout << now;
			return 0;
		}
	}
	cout<<-1;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3580
import sys
input=sys.stdin.buffer.readline

# a1 = 0としてよい

A = [0,None,None]
B = [None,None,None]

bl = True
for i in range(3):
  C = [int(x) for x in input().split()]
  for j,c in enumerate(C):
    if A[i] is None:
      A[i] = c - B[j]
    if B[j] is None:
      B[j] = c - A[i]
    if A[i]+B[j] != c:
      bl = False

answer = 'Yes' if bl else 'No'
print(answer)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;
const int MX = 100005;
int n, m, a, p[MX], t, c, x, y, cnt;
bool used[MX];
ll ans;
queue<int> qu;
P pa[MX];
int find(int x){return (p[x] < 0 ? x : p[x] = find(p[x]));}
void uni(int x, int y){
	x = find(x); y = find(y);
	if(x != y){
		if(p[x] > p[y]) swap(x, y);
		p[x] += p[y];
		p[y] = x;
		cnt--;
	}
}
int main(){
	scanf("%d%d", &n, &m);
	rep(i,n){
		scanf("%d", &a);
		pa[i] = P(a,i);
	}
	fill(p,p+n,-1);
	cnt = n-2;
	rep(i,m){
		scanf("%d%d", &x, &y);
		uni(x,y);
	}
	if(cnt == -1) return 0*puts("0");
	sort(pa,pa+n);
	rep(i,n){
		tie(a,t) = pa[i];
		t = find(t);
		if(!used[t]){
			ans += a;
			used[t] = true;
		}else if(c < cnt){
			ans += a;
			c++;
		}
	}
	if(c < cnt) puts("Impossible");
	else printf("%lld\n", ans);
}

Measured memory_bytes: 1536
N, M, K = map(int, input().split(' '))
A_ls = [0] + list(map(int, input().split(' ')))
for i in range(N):
    A_ls[i + 1] += A_ls[i]
B_ls = [0] + list(map(int, input().split(' ')))
for i in range(M):
    B_ls[i + 1] += B_ls[i]
b_cnt, rst = M, 0
for a_cnt in range(N + 1):
    if A_ls[a_cnt] > K:
        break
    while A_ls[a_cnt] + B_ls[b_cnt] > K and b_cnt >= 0:
        b_cnt -= 1
    rst = max(rst, a_cnt + b_cnt)
print(rst)

Measured memory_bytes: 45176
def main():
    n=int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    counta = 0
    countb = 0
    for i in range(n):
        if a[i] > b[i]:
            countb += a[i] - b[i]
        elif a[i] < b[i]:
            counta += (b[i] - a[i] + 1) // 2
            if (b[i]-a[i]) % 2 == 1:
                countb += 1

    if countb > counta:
        return "No"
    else:
        return "Yes"

print(main())

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for(auto& e: p) cin >> e;
    int res = 0;
    for(int i = 1;i <= n-2;i++){
        if(p[i-1] > p[i] && p[i] > p[i+1] || p[i-1] < p[i] && p[i] < p[i+1]){
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() { 
    long long int x, y;
    cin >> x >> y;
    int res = 0;
    while (x <= y) {
        res++;
        x *= 2;
    }
    cout << res << endl;
}




Measured memory_bytes: 3644