akhauriyash/Code-Regression huggingface dataset:
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=1000005;
int n,ans;
char s[maxn],t[maxn]; 
namespace Queue{
	int dt;
	queue<int>q;
	void sub(){dt++;}
	bool empty(){return q.empty();}
	void push(int x){q.push(x+dt);}
	int front(){return q.front()-dt;}
	int size(){return q.size();}
	void pop(){q.pop();}
}

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d%s%s",&n,s,t);
	if(string(s)==string(t)){
		puts("0");
		return 0; 
	}
	int j=n;
	for(int i=n-1;i>=0;i--){
		int oldj=j;
		j=min(j,i);
		while(j>=0&&s[j]!=t[i])j--;
		if(j<0){
			puts("-1");
			return 0;
		}
		if(j==oldj)continue;
		//current segment is [j,i]
		Queue::sub();
		while(!Queue::empty()&&Queue::front()>=i)Queue::pop();
		Queue::push(j);
		ans=max(ans,Queue::size());
	}
	printf("%d\n",ans);
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


Measured memory_bytes: 6232
a,b,c=map(int,input().split())
if a==b==c:
    if a%2==b%2==c%2==0:
        print(-1)
    else:
        print(0)
    exit()
cnt=0
while a%2==b%2==c%2:
    A=a//2
    B=b//2
    C=c//2
    a,b,c=B+C,A+C,A+B
    cnt+=1
print(cnt)

Measured memory_bytes: 9100
from collections import Counter as D, defaultdict as dd
from math import factorial as ft, ceil as aron
from fractions import gcd as pg 
from bisect import insort as ins, bisect_left as bl, bisect_right as br
import sys

#sys.stdin=open("./testfile.txt","r")
raw_input=sys.stdin.readline

f1=lambda : map(int,raw_input().split())
f2=lambda : map(int,list(raw_input()))
f3=lambda : int(raw_input())
f4=lambda : raw_input().rstrip()

f1=lambda : map(int,raw_input().split())
n,p= f1()
l= f1()
d=[0]*(n+1)
for i in xrange(1,n+1):
	d[i]=d[i-1]+l[i-1]
ans=-1
for i in xrange(1,n+1):
	if d[i]>p:
		ans=i
		break
	elif d[i]==p:
		ans=i+1
		break
if ans==-1:
	ans=n+1
print ans

Measured memory_bytes: 34792
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a,b) for(int i=int(a);i>int(b);--i)
using namespace std;
using ll = long long;

int main()
{
  int H,W,K;
  cin >> H >> W >> K;

  char S[330][330];
  int A[330][330];

  rep(h,H) rep(w,W) cin >> S[h][w];

  int cnt=1;
  rep(h,H) rep(w,W)
    if(S[h][w]=='#') A[h][w] = cnt++;
    else A[h][w] = 0;

  rep(h,H) rep(w,1,W) if(A[h][w] == 0) A[h][w] = A[h][w-1];
  rep(h,H) rrep(w,W-2,-1) if(A[h][w] == 0) A[h][w] = A[h][w+1];
  rep(h,1,H) rep(w,W) if(A[h][w] == 0) A[h][w] = A[h-1][w];
  rrep(h,H-2,-1) rep(w,W) if(A[h][w] == 0) A[h][w] = A[h+1][w];

  rep(h,H) rep(w,W) cout << A[h][w] << (w==W-1 ? "\n" : " ");
}


Measured memory_bytes: 1280
#include<cstdio>
#define rep(i,n) for(int i=1;i<=n;i++)
using namespace std;
int main(){
  int m,n,x,y,num[30],g[30][30];
  scanf("%d%d",&m,&n);
  rep(i,m){num[i]=0; rep(j,m)g[i][j]=0;}
  rep(i,n){
    scanf("%d%d",&x,&y);
    g[x][y]=1; num[y]++;
  }
  rep(i,m)rep(j,m){
    if(!num[j]){
      rep(k,m)num[k]-=g[j][k];
      num[j]--; printf("%d\n",j); break;
    }
  }
}

Measured memory_bytes: 1028
using System;
using System.Linq;
using CompLib.Util;

public class Program
{
    int N;
    long[] A, B;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        A = new long[N];
        B = new long[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = sc.NextLong();
            B[i] = sc.NextLong();
        }

        if (N % 2 == 0)
        {
            for (int i = 0; i < N; i++)
            {
                A[i] *= 2;
                B[i] *= 2;
            }
        }

        // 下限
        // m以下の値がceil(N/2)以上 最小

        // m以上の値が　以上 最大
        Array.Sort(A);
        Array.Sort(B);
        long min = N % 2 == 0 ? (A[N / 2] + A[N / 2 - 1]) / 2 : A[N / 2];
        long max = N % 2 == 0 ? (B[N / 2] + B[N / 2 - 1]) / 2 : B[N / 2];

        Console.WriteLine(max - min + 1);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 43680
N,K=map(int,input().split())
A=[[] for i in range(0,N)]
for i in range(0,N):
    A[i]=list(map(int,input().split()))

mod=10**9+7

dp=[[[0 for i in range(0,N)] for j in range(0,N)] for k in range(0,62)]

for j in range(0,N):
    for k in range(0,N):
        dp[0][j][k]=A[j][k]

for i in range(1,62):
    for j in range(0,N):
        for k in range(0,N):
            dp[i][j][k]=sum(dp[i-1][j][l]*dp[i-1][l][k] for l in range(0,N))%mod

ans=[[[0 for i in range(0,N)] for j in range(0,N)] for k in range(0,63)]

for i in range(0,N):
    ans[0][i][i]=1

for k in range(0,62):
    if K>>k & 1==1:
        for i in range(0,N):
            for j in range(0,N):
                ans[k+1][i][j]=sum(dp[k][i][l]*ans[k][l][j] for l in range(0,N))%mod

    else:
        for i in range(0,N):
            for j in range(0,N):
                ans[k+1][i][j]=ans[k][i][j]

print(sum(ans[62][i][j] for i in range(0,N) for j in range(0,N))%mod)

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

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

main(){
  string b;
  cin >> b;
  if (b=="A") cout << "T" << endl;
  else if (b=="C") cout << "G" << endl;
  else if (b=="G") cout << "C" << endl;
  else  cout << "A" << endl;
}

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

int main() {
  
  int N, M;
  cin >> N >> M;
  
  vector<int> Mi(M);
  
  vector<vector<int>> Aij; //Aiさんの好きな食べ物
  Aij.resize(N);
  
  for(int i=0; i<N; i++){
    int Ki;
    cin >> Ki;
    Aij.at(i).resize(Ki);
    for(int j=0; j<Ki; j++){
      cin >> Aij.at(i).at(j);
    }
    
    for(int j=0; j<Ki; j++){
      Mi.at(Aij.at(i).at(j)-1)++;
    }
    
  }
  

  int count;
  for(int j=0; j<M; j++){
    if(Mi.at(j)==N){
      count++;
    }
  }

  cout << count << endl;

}


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

int p = 1000000007;
vector<vector<int> >dp;
int helper(vector<vector<int> >&pairs,int i,int ans,int n){
	if(dp[i][ans] > -1){
		return dp[i][ans];
	}
	//cout<<ans<<" "<<i<<" "<<endl;
	if(i == pairs.size()){
		if(__builtin_popcount(ans) == n){
		dp[i][ans] = 1;
		return 1;
	}
		else{
		dp[i][ans] = 0;
		return 0;
	}
	}
	else{
		int res = 0;
		for(int j=0;j<n;j++){
			if(pairs[i][j] == 1 && (ans&(1<<j)) == 0){
				ans = ans|(1<<j);
				res = (res%p + helper(pairs,i+1,ans,n)%p)%p;
				ans = ans & ~(1 << (j));	
			}
		}
		dp[i][ans] = res;
		return res;
	}
}
int main(){
	int n;cin>>n;
	vector<vector<int> >pairs(n,vector<int>(n));
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>pairs[i][j];
		}
	}
	dp = vector<vector<int> >(n+1,vector<int>(pow(2,n)+1,-1));
	cout<<helper(pairs,0,0,pairs.size());
	return 0;
}


Measured memory_bytes: 188800
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
ll field[4019][4019];
void addrang(ll x,ll y, ll k){
	field[x][y]++;
	field[x+k][y]--;
	field[x][y+k]--;
	field[x+k][y+k]++;
	return;
}
int main(){
	ll n,k;
	cin>>n>>k;
	vector<ll> x,y;
	for(int i=0;i<n;i++){
		ll tx,ty;
		string ts;
		cin>>tx>>ty>>ts;
		if(ts=="B"){
			x.pb(tx%(2*k));
			y.pb(ty%(2*k));
		}
		else{
			x.pb(tx%(2*k));
			y.pb((ty+k)%(2*k));
		}
	}
	for(int i=0;i<n;i++){
		addrang(x[i],y[i],k);
		addrang(x[i]+k,y[i]+k,k);
	}
	for(int i=0;i<4*k;i++){
		for(int j=1;j<4*k;j++){
			field[i][j] += field[i][j-1];
		}
	}
	for(int i=0;i<4*k;i++){
		for(int j=1;j<4*k;j++){
			field[j][i] += field[j-1][i];
		}
	}
	ll ans = -1;
	for(int i=0;i<2*k;i++){
		for(int j=0;j<2*k;j++){
			ll tmp = field[i][j] + field[i+2*k][j] + field[i][j+2*k] + field[i+2*k][j+2*k];
			if(tmp>ans)ans=tmp;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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


int main(){
	int n;cin>>n;
  	map<ll,ll> m1;
  	ll a[n];
  	ll ans=0;
  	for(int i=0;i<n;i++){
      cin>>a[i];
      if(m1.count(i-a[i])>0)ans+=m1[i-a[i]];
      m1[i+a[i]]++;
    }
  cout<<ans;
}


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

int main() {
    int n; cin >> n;
    string s; cin >> s;

    int now = 0;
    int ans = 0;
    rep(i, s.size()) {
        if (s.at(i) == 'I')
            now++;
        else
            now--;
        ans = max(ans, now);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
const main = stdin => {
  const input = stdin.trim().split('\n')

  const a = parseInt(input[0])
  const s = input[1]

  if (a >= 3200) {
    console.log(s)
  } else {
    console.log('red')
  }

}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


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

int main(){
  int N,K,total;
  cin >> N >> K;
  total=0;
  for(int i=0;i<N;i++){
    int B,x;
    cin >> x;
    if(x-K<=0){
      if(-2*(x-K)>=x*2)total+=x*2;
      else total+=-2*(x-K);
    }
    else{ if(2*(x-K)>=x*2)total+=x*2;
          else total+=2*(x-K);
        }
  }
  cout << total << endl;
}

Measured memory_bytes: 3632
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        k: usize
    }
    println!("{}", k * (k - 1).pow((n - 1) as u32));
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
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;
}
const long long INF = 1LL << 60;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && b == c) {
        cout << 1;
    }else if(a == b || b == c || c == a) {
        cout << 2;
    }else {
        cout << 3;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

template <class U>
inline void dkstr(vector<vector<pair<int,U>>>& v,int n,int s,vector<U>& d,U inf){
    d.assign(n,inf);
    d[s]=0;
    queue<pair<U,int>> pq;
    pq.emplace(0,s);
    while(!pq.empty()){
        pair<U,int> p=pq.front();pq.pop();
        U D=p.first;
        int i=p.second;
        if(d[i]<D) continue;
        for(auto q:v[i]){
            if(d[q.first]<=D+q.second) continue;
            d[q.first]=D+q.second;
            pq.emplace(D+q.second,q.first);
        }
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n,u,v,a,b;
    in>>n>>u>>v;
    --u,--v;
    vector<vector<pair<int,int>>> e(n);
    fr(i,n-1){
        in>>a>>b;
        e[--a].emplace_back(--b,1);
        e[b].emplace_back(a,1);
    }
    vector<int> d(n),D(n);
    dkstr(e,n,u,d,INT_MAX);
    dkstr(e,n,v,D,INT_MAX);
    int ans{0},f{},K{};
    if((d[0]+D[0])%2){
        fr(i,n) if(d[i]<D[i]){
            ans=max(ans,D[i]-1);
        }
    }
    else{
        fr(i,n) if(d[i]<D[i]) ans=max(ans,D[i]-1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7296
import sys

import numpy as np


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


N = ii()
H = ii()
W = ii()
print((N - H + 1) * (N - W + 1))


Measured memory_bytes: 21660
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
	string n;
	int s=0;
	cin>>n;
	for(int i=1;i<n.length();i++)
	{
		if(n[i]!=n[i-1])
			s++;
	}
	cout<<s<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;

string binary(lli bina){
    lli ans = 0;
    for (lli i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return to_string(ans);
}

int main() {

    int N, M;
    cin >> N >> M;

    vector<int> kVec;
    vector<vector<int >> sVec;
    vector<int> pVec;

    for (int i = 0; i < M; ++i) {
        int k;
        cin >> k;
        kVec.push_back(k);

        vector<int > sVecRow;
        for (int j = 0; j < k; ++j) {
            int s;
            cin >> s;
            sVecRow.push_back(s);
        }
        sVec.push_back(sVecRow);
    }

    for (int i = 0; i < M; ++i) {
        int p;
        cin >> p;
        pVec.push_back(p);
    }

    
    // スイッチの状態に合わせて回す
    int result = 0;
    lli count = (lli)pow(2.0, N);
    for (lli i = 0; i < count; ++i) {

        string nishin = binary(i);
        lli length = (lli)nishin.length();

        for (int j = 0; j < N - length; ++j) {
            nishin = "0" + nishin;
        }

        vector<bool> swVec;
        length = (lli)nishin.length();
        for (lli j = 0; j < length; ++j) {
            string are = nishin.substr(length - j - 1, 1);
            if (are == "1") {
                swVec.push_back(true);
            } else {
                swVec.push_back(false);
            }
        }

        bool isLight = true;
        for (lli j = 0; j <M ; ++j) {
            int k = kVec[j];
            vector<int> vecvec = sVec[j];
            int counter = 0;
            for (int l = 0; l < k; ++l) {
                int index = vecvec[l];
                bool isOn = swVec[index - 1];
                if (isOn) {
                    ++counter;
                }
            }

            int p = pVec[j];
            if (counter % 2 == p) {
                // ついた
            } else {
                isLight = false;
                break;
            }
        }

        if (isLight) {
            ++result;
        }

    }

    cout << result << endl;
    
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    map<string, int> m;
    vector<int> a(n);
    vector<int> c;
    vector<int> d;
    vector<string> s(n);
    vector<string> b;
    rep(i,n){
        cin >> s[i] >> a[i];
        m[s[i]] = 0;
    }
    b = s;
    sort(b.begin(),b.end());
    for(auto x:m){
        rep(i,n){
            if(x.first == s[i]) c.pb(a[i]);
        }
        sort(c.begin(),c.end(),greater<int>());
        rep(i,c.size()){
            rep(j,n){
                if(c[i] == a[j]) d.pb(j+1);
            }
        }
        c.clear();
    }
    rep(i,d.size()) cout << d[i] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>


double distance(double x1, double y1, double x2, double y2) {
  double x, y;
  x = x1 - x2;
  y = y1 - y2;
  return sqrt(x * x + y * y);
}


int main() {
  double x1, y1, x2, y2;
  std::cin >> x1 >> y1 >> x2 >> y2;

  std::cout << std::fixed << std::setprecision(8) << distance(x1, y1, x2, y2) << std::endl;

  return 0;
}



Measured memory_bytes: 3256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main(){
  int A,B,ans=0;
  cin >> A >> B;
  if(A>=B){
  	ans += A;
  	A--;
  }else{
  	ans += B;
  	B--;
  }

  if(A>=B){
  	ans += A;
  	A--;
  }else{
  	ans += B;
  	B--;
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
/// Kazuki Hoshino
/// Lost July

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000000000000
#define mx 1000000000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

ll n, m, s, t, dist[101010], diss[101010], x, y, a, b, ans[101010];
vector<pll> adj[101010], g[101010];
bool vis[202020];
vector<pll> v;

void djikstra(int u)
{

    rep(i, 1, n){
    vis[i]=false;
    dist[i]=inf;
    }
    dist[u]=0;
    priority_queue<pll> q;
    q.push({0,u});

    while(!q.empty()){

        tie(a,b) = q.top();q.pop();
        if(vis[b])continue;
        vis[b]=true;

        for(auto t: adj[b]){

            if(dist[t.f] >= dist[b]+t.ss ){
                dist[t.f] = dist[b]+t.ss;
                q.push({-dist[t.f], t.f});
            }

        }

    }


}


void djikstra1(int u)
{

    rep(i, 1, n){
    vis[i]=false;
    diss[i]=inf;
    }
    diss[u]=0;
    priority_queue<pll> q;
    q.push({0,u});

    while(!q.empty()){

        tie(a,b) = q.top();q.pop();
        if(vis[b])continue;
        vis[b]=true;

        for(auto t: g[b]){

            if(diss[t.f] >= diss[b]+t.ss ){
                diss[t.f] = diss[b]+t.ss;
                q.push({-diss[t.f], t.f});
            }

        }

    }


}


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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


cin >> n >> m >> s >> t;

rep(i, 1, m){
cin >> x >> y >> a >> b;
adj[x].pb({y,a});
adj[y].pb({x,a});
g[x].pb({y,b});
g[y].pb({x,b});

}

djikstra(s);
djikstra1(t);

rep(i, 1, n){
ll temp = mx - (dist[i]+diss[i]);
v.pb({temp,i});
//cout << dist[i] << " " << diss[i] << endl;
}
ll pre = 0;
sort(all(v));
reverse(all(v));

for(auto t: v){
    //cout << t.f << " " << t.ss << endl;
    if(t.ss>pre){
        rep(i, pre+1, t.ss){
        ans[i]=t.f;
        }
        pre = t.ss;
    }

}

rep(i, 1, n){
cout << ans[i] << endl;
}


return 0;}


Measured memory_bytes: 20860
#include <stdio.h>
#define rep(i, n) for (i = 0; i < n; i++)

int main() {
    long long x;
    scanf("%lld", &x);

    long long ans = x / 11 * 2;
    if (x % 11 > 6) ans += 2;
    else if (x % 11 > 0) ans++;

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;


int main(void){
    int N, M; cin >> N >> M;
    vector<vector<int>> AB(M);
    for(int i = 0; i < N; i++)
    {
        int A, B; cin >> A >> B;
        if(A > M) continue;
        AB[A-1].push_back(B);
    }
    priority_queue<int> que;
    int ans = 0;
    for (int i = 0; i < M; i++)
    {
        for (int b: AB[i]) {
            que.push(b);
        }
        if(!que.empty()){
            ans += que.top();
            que.pop();
        }
    }
    cout << ans << endl;
}


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

int main(){
	int num;
	int score[2]={0, 0};
	char T[256], H[256];
	int i, j;
	int flag = 0;

	scanf("%d", &num);
	for(i=0; i< num; i++){
		scanf("%s %s", T, H);
		flag = 0;
		for(j=0; j< strlen(T); j++){
			if(T[j] > H[j]){
				flag = -1;
				break;
			}
			else if(T[j] < H[j]){
				flag = 1;
				break;
			}
			else if(H[j] == '\0'){
				flag = -1;
				break;
			}
		}
		if((flag == 0) && (strlen(T) < strlen(H)))
			flag = 1;

		if(flag == -1){
			score[0] = score[0] + 3;
		}
		else if(flag == 1){
			score[1] = score[1] + 3;
		}
		else{
			score[0] += 1;
			score[1] += 1;
		}
	}
	printf("%d %d\n", score[0], score[1]);

	return 0;

}


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

/// --- Graph Template {{{ ///

template<class T>
struct Edge {
  int from, to; T cost;
  Edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  Edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};
template<class T>
using WeightedGraph = vector< vector< Edge<T> > >;
using UnWeightedGraph = vector< vector<int> >;

/// }}}--- ///


// SCC(UnWeightedGraph)
// must build(renew)
/// --- Strongly Connected Component {{{ ///

struct SCC {
  int n;
  vector< vector<int> > g, rev;
  vector<int> topo;
  vector<int> used;
  vector<int> comp;
  SCC(int n): n(n), g(n), rev(n) {}
  SCC(UnWeightedGraph ig): n(ig.size()), g(n), rev(n) {
    for(int from = 0; from < n; from++)
      for(int to : ig[from]) addEdge(from, to);
  }
  void addEdge(int a, int b) {
    g[a].emplace_back(b);
    rev[b].emplace_back(a);
  }
  int operator[](int i) {
    return comp[i];
  }
  void build(vector< vector<int> > &renew) {
    used.resize(n, 0);
    comp.resize(n, -1);
    for(int i = 0; i < n; i++) if(!used[i]) dfs1(i);
    reverse(begin(topo), end(topo));
    int k = 0;
    for(int i : topo) if(comp[i] == -1) dfs2(i, k++);

    renew.resize(k);
    set<pair<int, int>> connect;
    for(int i = 0; i < n; i++) {
      for(int j : g[i]) {
        int x = comp[i], y = comp[j];
        if(x == y) continue;
        if(connect.count(make_pair(x, y))) continue;
        connect.emplace(x, y);
        renew[x].emplace_back(y);
        // f[x].emplace_back(y);
        // f[y].emplace_back(x);
      }
    }
  }
private:
  void dfs1(int i) {
    if(used[i]) return;
    used[i] = 1;
    for(int j : g[i]) dfs1(j);
    topo.emplace_back(i);
  }
  void dfs2(int i, int num) {
    if(comp[i] != -1) return;
    comp[i] = num;
    for(int j : rev[i]) dfs2(j, num);
  }
};

/// ---}}} ///


int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n, m;
  cin >> n >> m;
  SCC ecas(n);
  for(int i = 0; i < m; i++) {
    int s, t;cin >> s >> t;
    ecas.addEdge(s, t);
  }
  UnWeightedGraph g;
  ecas.build(g);
  int k = g.size();
  if(k == 1) {
    cout << 0 << endl;
    return 0;
  }
  vector<int> ins(k);
  for(int i = 0; i < k; i++) {
    for(int j : g[i]) ins[j] = 1;
  }
  // vector<int> gr(k, -1);
  // function<void(int, int, int)> dfs = [&](int i, int p, int t) {
  //   gr[i] = t;
  //   for(int j : f[i]) if(j != p) {
  //     dfs(j, i, t);
  //   }
  // };
  // int t = 0;
  // for(int i = 0; i < n; i++) if(gr[i] == -1) dfs(i, -1, t++);
  // にゅうじ0の頂点がわかる
  // vector<int> I(n), O(n);
  int I = 0, O = 0;

  for(int i = 0; i < k; i++) if(ins[i] == 0) {
    I++;
  }
  for(int i = 0; i < k; i++) if(g[i].size() == 0) {
    O++;
  }
  ll ans = max(I, O);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 10448
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};

int main() {
    int a, b; cin >> a >> b;
    vector<int> v;
    rep(i, 2) {
        v.push_back(a); a--;
        v.push_back(b); b--;
    }
    sort(v.begin(), v.end());
    cout << v[3] + v[2] << endl;
}
    


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>

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

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}
void check(long long a,long long b,long long c,long long d){
    long long same=a;
    a = a-b;
    while(same != a && a >= 0){
        cout << a << endl ;
        if(a <= c){
            a += d;
            if(a == same){
                cout << "Yes" << endl;
                return;
            }
        }
        a = a-b ;
    }

    if(a<0)
        cout << "No" << endl;
    return;
}


int main(int argc, const char * argv[]) {
    
    // source code
    int H,W;
    cin >> H;
    cin >> W;
    char a[H][W];
    rep(i,H){
        rep(j,W)
            cin >> a[i][j];
    }

int checki[H];
int checkj[W];

    rep(i,H){
        checki[i]=0;
        if(a[i][0] == '.'){
            rep(j,W){
                if(a[i][j] == '#')
                    checki[i]=1;
            }
        }else{
            checki[i] = 1;
        }
    }



    rep(j,W){
        checkj[j]=0;
        if(a[0][j] == '.'){
            rep(i,H){
                if(a[i][j] == '#')
                    checkj[j]=1;
            }
        }else{
            checkj[j]=1;
        }
    }


    rep(i,H){
        rep(j,W){
            if(checki[i]==1 && checkj[j]==1){
                cout << a[i][j];
            }
        }
        if(checki[i]==1)
            cout << endl;
    }




}

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

double get_distance( double xa, double ya, double xb, double yb )
{
	return sqrt( ( xb - xa ) * ( xb - xa ) + ( yb - ya ) * ( yb - ya ) );
}

bool is_collision( double xa, double ya, double ra, double xb, double yb, double rb )
{
	double distance = get_distance( xa, ya, xb, yb );
	return distance <= ra + rb ? true : false;
}

int check( double xa, double ya, double ra, double xb, double yb, double rb )
{
	double distance = get_distance( xa, ya, xb, yb );
	if ( distance + rb < ra ) return 2;
	else if ( distance + ra < rb ) return -2;
	else return 1;
}

int main( void )
{
	double xa, ya, ra, xb, yb, rb;
	int n; cin >> n;
	for ( int i = 0; i < n; i++ )
	{
		cin >> xa >> ya >> ra >> xb >> yb >> rb;

		if ( is_collision( xa, ya, ra, xb, yb, rb ) )
		{
			cout << check( xa, ya, ra, xb, yb, rb ) << endl;
		}
		else
		{
			cout << 0 << endl;
		}

	}
	return 0;
}

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

using namespace std;
using ll = long long;

#define MOD 1000000007
struct Mcomb {
    vector<ll> fac;
    vector<ll> inv;
    vector<ll> finv;
    //nCnまで対応できる
    Mcomb(int n) {
        fac.resize(n + 1), inv.resize(n + 1), finv.resize(n + 1);
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for(int i = 2; i <= n; 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;
        }
    }

    ll ncr(int n, int r){
        if (n < r) return 0;
        if (n < 0 || r < 0) return 0;
        return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
    }

    ll npr(int n, int r){
        if(n < r)return 0;
        if(n < 0 || r < 0)return 0;
        return (fac[n] * inv[n - r]) % MOD;
    }

};

int main()
{
    Mcomb comb(10000);
    int n, blue;
    cin >> n >> blue;
    int red = n - blue;

    for(int i = 1; i <= blue; i++){
        
        ll cur = comb.ncr(blue - 1, i - 1);
        cur %= MOD;
        //cerr << "cur : " << cur << " curred : " << red - (i - 1) << endl; 
        cur *= comb.ncr(red - (i - 1) + i, i);
        cur %= MOD;
        cout << cur << endl;
    }
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n, x;
    cin >> n >> x;

    i64 l = max(x, n - x), s = min(x, n - x);
    i64 ans = 0;
    while (s > 0) {
        ans += l / s * s * 3;
        i64 pl = l;
        l = s, s = pl % s;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define pb push_back
#define mp make_pair
const int MOD=1e9+7;
const int INF=1e15;

typedef pair<int,int> P;
int H,W;
int cou=0;
vector<vector<char>>MAZE(50,vector<char>(50));
vector<vector<int>>D(50,vector<int>(50,INF));
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int bfs(){
    queue<P>que;
    que.push(P(0,0));
    D[0][0]=0;
    while(que.size()){
        P p=que.front();
        que.pop();
        if(p.first==H-1&&p.second==W-1)break;
        REP(i,4){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(0<=nx&&nx<H&&0<=ny&&ny<W&&MAZE[nx][ny]!='#'&&D[nx][ny]==INF){
                D[nx][ny]=D[p.first][p.second]+1;
                que.push(P(nx,ny));
            }
        }
    }
  	return D[H-1][W-1];
}

void solve(){
    cin>>H>>W;
    REP(i,H){
        REP(j,W){
            cin>>MAZE[i][j];
            if(MAZE[i][j]=='#'){
                cou++;
            }
        }
    }
    int ans=H*W-cou-bfs()-1;
    if(ans<0)ans=-1;
    cout<<ans<<endl;
}

signed main(){
    solve();
}

Measured memory_bytes: 256
//package atcoder;
 
import java.util.*;
//import java.math.BigDecimal;
 
public class Main{
	static boolean[] targetNumbers;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		printPrimeNumbers2(1000000);
		for(int i=X;i<=1000000;i++) {
			if(targetNumbers[i]) {
				System.out.println(i);
				System.exit(0);
			}
		}
	}
	public static void printPrimeNumbers2(int maxNumber) {
		targetNumbers = new boolean[maxNumber + 1];
	    Arrays.fill(targetNumbers, true);
	    targetNumbers[0] = false;
	    targetNumbers[1] = false;
	    // 素数リスト
	    List<Integer> primeNumbers = new ArrayList<Integer>();

	    int sqrt = (int) Math.sqrt(maxNumber);

	    // ステップ3：探索リストの先頭の値が、引数の平方根に達するまでふるい落とし操作を続ける。
	    for(int i=2; i<=sqrt; i++) {
	        // ステップ2：探索リストの先頭の数を素数とし、その倍数を探索リストから篩い落とす。
	        // ※この時、既に篩い落とされた数（false）は除外する。
	        //int firstNum = i;
	        if (targetNumbers[i]) {
	            for (int j=2;i*j<=maxNumber;j++) {
	                targetNumbers[i*j] = false;
	            }
	        }
	    }

	    // ステップ4：探索リストに残った値を素数リストに移して処理終了。
	    for (int i=2; i<targetNumbers.length; i++) {
	        if (targetNumbers[i]) {
	            primeNumbers.add(i);
	        }
	    }

	    // 素数の表示
//	    int size = primeNumbers.size();
//	    for(int i = 0; i < size; i++)
//	    {
//	        Integer value = primeNumbers.get(i);
//	        System.out.println(value);
//	    }
	    
	     
	}
	
}

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


struct node{
    node *left, *right, *parent;
    int key;
};

node *root, *NIL;

node* find(node *x, int k){
    while(x != NIL and k != x->key){
        if(k < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    return x;
}

void insert(int a){
    node *y = NIL;
    node *x = root;
    node *z;

    z = (node *)malloc(sizeof(node));
    z->key = a;
    z->left = NIL;
    z->right = NIL;

    y = NIL;
    x = root;

    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }

    z->parent = y;

    if(y == NIL){
        root = z;
    }else if(z->key < y->key){
        y->left = z;
    }else{
        y->right = z;
    }



}

node* getMinimum(node *a){

    while(a->left != NIL){
        a = a ->left;

    }

    return a;
}

node* getSuccessor(node *a){
    if(a->right != NIL){
        return getMinimum(a->right);
    }

    /*
    node *y = a->parent;
    while(y != NIL && a == y->right){
        a = y;
        y = y->parent;
    }
    return y;
    */
}

void deleteNode(node *a){
    node *y = NIL;
    node *x;

    if(a->left == NIL || a->right == NIL){
        y = a;
    }else{
        y = getSuccessor(a);
    }

    if(y->left != NIL){
        x = y->left;
    }else{
        x = y->right;
    }

    if(x != NIL){
        x->parent = y->parent;
    }


    if(y->parent == NIL){
        root = x;
    }else if(y == y->parent->left){
        y->parent->left = x;
    }else{
        y->parent->right = x;
    }
    if(y != a){
        a->key = y->key;
    }

    free(y);

}

int perParse(node *a){
    if(a == NIL){
        return 0;
    }
    std::cout << " " << a->key;
    perParse(a->left);
    perParse(a->right);
}

int inOrder(node *a){
    if(a == NIL){
        return 0;
    }
    
    inOrder(a->left);
    std::cout << " " << a->key;
    inOrder(a->right);
}

int main(void){
    int n;
    int a;
    std::string str;
    std::cin >> n;
    for(int i = 0; i < n; i++){
        std::cin >> str;
        if(str == "insert"){
            std::cin >> a;
            insert(a);
        }else if(str == "find"){
            std::cin >> a;

            if(find(root, a) == NIL){
                std::cout << "no" << std::endl;
            }else{
                std::cout << "yes" << std::endl;
            }
        }else if(str == "delete"){
            std::cin >> a;

            node *tmp = find(root, a);
            deleteNode(tmp);
            
        }else{
            inOrder(root);
            std::cout << std::endl;
            perParse(root);
            std::cout << std::endl;

        }
    }
    return 0;
}


Measured memory_bytes: 21916
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;


typedef pair<int, int> PP;

double EPS = 1e-10;

double add(double a, double b){
	if(abs(a + b) < EPS * (abs(a) + abs(b))){
		return 0;
	}
	return a + b;
}

struct P{
	double x, y;
	P(){}
	P(double x, double y) : x(x), y(y){}
	P operator + (P p){
		return P(add(x, p.x), add(y, p.y));
	}
	P operator - (P p){
		return P(add(x, -p.x), add(y, -p.y));
	}
	P operator * (double d){
		return P(x * d, y * d);
	}
	double dot(P p){
		return add(x * p.x, y * p.y);
	}
	double det(P p){
		return add(x * p.y, -y * p.x);
	}
};

// x -> y の順で比較
bool cmp_x(const P& p, const P& q){
	if(p.x != q.x){
		return p.x < q.x;
	}
	return p.y < q.y;
}

bool cmp_y(const P& p, const P& q){
	if(p.y != q.y){
		return p.y < q.y;
	}
	return p.x < q.x;
}

// P* ps に対し、破壊的な操作を行う点に注意
vector<P> convex_hull(P* ps, int n){
	sort(ps, ps + n, cmp_x);
	int k = 0; // 凸包の頂点数
	vector<P> qs(n * 2); // 構築中の凸包
	
	// 上側凸包の作成
	for(int i = 0; i < n; i++){
		while(k > 1 && (qs[k - 1] - qs[k - 2]).det(ps[i] - qs[k - 1]) <= -EPS){
			k--;
		}
		qs[k++] = ps[i];
	}
	
	// 下側凸包の作成
	for(int i = n - 2, t = k; i >= 0; i--){
		while(k > t && (qs[k - 1] - qs[k - 2]).det(ps[i] - qs[k - 1]) <= -EPS){
			k--;
		}
		qs[k++] = ps[i];
	}
	qs.resize(k - 1);
	return qs;
}

P ps[110000];

int main(){
	
	int N;
	cin >> N;
	
	for(int i = 0; i < N; i++){
		cin >> ps[i].x >> ps[i].y;
	}
	
	vector<P> qs = convex_hull(ps, N);
	
	int sz = qs.size();
	cout << sz << endl;
	
	int id = 0;
	P p = qs[0];
	for(int i = 0; i < sz; i++){
		if(cmp_y(qs[i], p)){
			p = qs[i];
			id = i;
		}
	}
	
	for(int i = 0; i < sz; i++){
		cout << qs[(i + id) % sz].x << " " << qs[(i + id) % sz].y << endl;
	}
	
	return 0;
}



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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long A;
	scanf("%lld",&A);
	long long B;
	scanf("%lld",&B);
	long long C;
	scanf("%lld",&C);

	if ((A == B && A != C) || (A == C && A != B) || (B == C && A != B))
	{
		cout << "Yes" << endl;
	}
	else {
		cout << "No" <<endl;
	}

	return 0;
}


Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    I, O, T, J, L, S, Z = map(int, input().split())
    #I * 2: 4; O * 1: 2, J, L * 2: 4, I + J + L: 6 
    Ans = O * 2
    six = min([I, J, L])
    Ans += six * 6
    I -= six
    J -= six
    L -= six
    Ans += 4 * (I // 2 + J // 2 + L // 2)
    rem = I % 2 + J % 2 + L % 2
    if six > 0 and rem == 2: Ans += 2
    print(Ans // 2)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
int main(){
  std::vector<int> A(9);
  for (int i=0; i<9; i++){
    scanf("%d", &A[i]);
  }
  int N;
  scanf("%d", &N);
  std::vector<int > b(N);
  for (int i=0; i<N; i++){
    scanf("%d", &b[i]);
  }
  std::vector<bool > hit(9, false);
  for (int i=0; i<N; i++){
    auto itr = std::find(A.begin(), A.end(), b[i]);
    int index = itr - A.begin();
    hit[index] = true;
  }
  bool bingo = false;
  if ((hit[0]&&hit[1]&&hit[2])||
      (hit[3]&&hit[4]&&hit[5])||
      (hit[6]&&hit[7]&&hit[8])||
      (hit[0]&&hit[3]&&hit[6])||
      (hit[1]&&hit[4]&&hit[7])||
      (hit[2]&&hit[5]&&hit[8])||
      (hit[0]&&hit[4]&&hit[8])||
      (hit[2]&&hit[4]&&hit[6])){
    bingo = true;
  }
  printf("%s\n",bingo?"Yes":"No");
  return 0;
}


Measured memory_bytes: 888
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N, D;
    in >> N >> D;

    ll v[N][D];
    REP(i,N){
        REP(j,D){
            in >> v[i][j];
        }
    }
    ll c=0;
    REP(i,N){
        REP_AB(j,i+1,N){
            ll n = 0;
            REP(k,D){
                n += pow(v[i][k]-v[j][k], 2);
            }
            if(double(pow(n, 0.5)) == int(pow(n, 0.5))){
                c++;
            }
        }
    }
    
    out << c << endl;
}

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


int main() {

	int q;
	cin >> q;
	
	set<long long> st;
	for(int i = 0; i < q; ++i){
		int order, num;
		cin >> order >> num;
		
		if(order == 0){
			st.insert(num);
			cout << st.size() << endl;
		}else if(order == 1){
			cout << (st.find(num) != st.end() ? 1 : 0) << endl;
		}else{
			st.erase(num);
		}
	}

	return 0;
}


Measured memory_bytes: 12440
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long 
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define N ((ll)(2e6+100))
#define MAX ((ll)(1e16+100))
#define ARRS ((ll)(3e5+100))
#define MOD ((ll)(1e9+7))
#define M1 ((ll)(1001783))
#define M2 ((ll)(1001941))
#define M3 ((ll)(1002073))
#define pb push_back
 
 
ll n,m;
ll a[ARRS];
ll pr[ARRS];
ll b[ARRS];
ll f[ARRS];
string s;
vector<ll> v[ARRS];
ll k,p,c,d,t;
 
ll pas;
ll go(ll x,ll p,ll e=0){

	ll r=e;
	if(f[x]>2)r=1;
	ll cr=(1^e);

	ll k=0;
	for(auto y:v[x]){
		if(y==p)continue;

		ll t=go(y,x,r);
		cr+=(1^t);
		k|=t;

	}

	//cout<<x<<" "<<cr<<endl;
	if(r)pas+=max(0ll,cr-1);
	k|=f[x]>2;

	return k;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	if(n==1){
		cout<<0;
		return 0;
	}

	for(int i=0; i<n-1; i++){

		cin>>k>>p;

		f[k]++;
		f[p]++;

		v[k].pb(p);
		v[p].pb(k);
		//cout<<k<<" "<<p<<" "<<f[k]<<" "<<f[p]<<endl;

	}

	ll s=-1;
	for(int i=0; i<n; i++)
		if(f[i]==1)s=i;
	if(s==-1){
		cout<<1;
		return 0;
	}

	pas=0;
	go(s,-1);
	cout<<max(1ll,pas)<<endl;

}


Measured memory_bytes: 16640
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int num[5];
  cin >>num[0]>>num[1]>>num[2]>>num[3]>>num[4];
  sort(num,num+5);
  cout <<num[4]<<" "<<num[3]<<" "<<num[2]<<" "<<num[1]<<" "<<num[0]<<endl;
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  ll n, x[110], sum = 0, p;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x[i];

  for (int i = 0; i < n; i++) sum += x[i];
  p = (int)round((double)sum / n);

  sum = 0;
  for (int i = 0; i < n; i++) sum += (int)pow(x[i] - p, 2);

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
int n,m;
char s[2010][2010];



int main()
{
    cin>>n>>m;
    int ans=0;
    REP(i,n+1)REP(j,m+1){if(j==m||i==n)s[i][j]='#';else cin>>s[i][j];}
    vector<vector<int> >l(n,vector<int>(m,0));
    vector<vector<int> >r(n,vector<int>(m,0));
    REP(i,n){
        int ac=0;
        REP(j,m+1)
        {
            if(s[i][j]=='#'){
                rep(k,j-ac,j)l[i][k]=ac;
                ac=0;}
            else ac++;
        }   
    }
    REP(i,m){
        int ac=0;
        REP(j,n+1)
        {
            if(s[j][i]=='#'){
                 rep(k,j-ac,j)r[k][i]=ac;
                ac=0;}
            else ac++;
        }   
    }
    REP(i,n)REP(j,m)if(s[i][j]=='.')ans=max(ans,l[i][j]+r[i][j]-1);
    cout<<ans<<endl;
    //REP(i,n){REP(j,m)cout<<l[i][j]<<" ";cout<<endl;}
}


Measured memory_bytes: 35584