akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2012;
char s[maxn];int n;
int g[maxn][maxn],vis[maxn];
void work(){
	puts("-1");
	exit(0);
}
void pre_dfs(int x,int c){
	if(vis[x]!=-1){
		if(vis[x]!=c)work();
		return ;
	}
	vis[x] = c;
	for(int i=1;i<=n;i++)
		if(g[x][i])
			pre_dfs(i,c^1);
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%s",s+1);
		for(int j=1;j<=n;j++){
			if(s[j]=='1')g[i][j] = 1;
			else g[i][j] = 0;
		}
	}
	memset(vis,-1,sizeof(vis));
	for(int i=1;i<=n;i++)
		if(vis[i]==-1)
			pre_dfs(i,0);
	if(n==2){
		puts("2");
		return 0;
	}
	int ans = 0;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
		if(g[i][j]==0)g[i][j] = 1024;
	for(int k=1;k<=n;k++)
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
		g[i][j] = min(g[i][j],g[i][k]+g[k][j]);
/*	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)
			cout<<g[i][j]<<" ";
		cout<<endl;
	}*/ 
	for(int i=1;i<=n;i++)
	for(int j=i+1;j<=n;j++)
	ans = max(ans,g[i][j]);
	cout << ans+1 << endl;
}

Measured memory_bytes: 1280
#include <iostream>
#include <math.h>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
//#include <bits/stdc++.h>

using namespace std;

int main()
{
	bool j1, j2, j3;
	j1 = true;
	j2 = true;
	j3 = true;
	string ss;
	cin >> ss;
	int n;
	n = ss.size();
	vector<char> s;
	for (int i = 0; i<n; i++)
	{
		s.push_back(ss[i]);
	}
	//条件1
	for (int i = 0; i < n/2; i++)
	{
		if (s[i] != s[n-1-i])
		{
			j1 = false;
		}
	}
	//条件2
	for (int i = 0; i < n/2; i++)
	{
		if (s[i] != s[n/2-1-i])
		{
			j2 = false;
		}
	}
	//条件3
	for (int i = n/2+1; i < n; i++)
	{
		if (s[i] != s[n-1-i])
		{
			j3 = false;
		}
	}
	if (j1 && j2 && j3)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    import numpy as np

    CARD = np.array(A,dtype=np.int8)

    for i in range(N):
        CARD[CARD==b[i]] = 0   

    CARD = CARD==0

    # 行が揃っているかチェック
    if np.all(CARD,axis=0).sum() > 0:
        print(YES)
        return
    
    if np.all(CARD,axis=1).sum()>0:
        print(YES)
        return
    
    if np.all(np.diag(CARD)):
        print(YES)
        return
    
    if np.all(np.diag(np.fliplr(CARD))):
        print(YES)
        return
    
    print(NO)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(A, N, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12100
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
char beat(char car){
    if(car=='r')return 'p';
    if(car=='s')return 'r';
    return 's';
}
char priv(char c1,char c2){
    vector<char> t={'r','s','p'};
    for(auto it:t){
        if((it!=c1)&&(it!=c2))return it;
    }
}
int32_t main(){
    boost;
    int n,k;
    cin>>n>>k;
    int r,s,p;
    cin>>r>>s>>p;
    vector<char> ans(n);
    char car;
    map<char,int> mymap;
    mymap['r']=r,mymap['s']=s,mymap['p']=p;
    string ph;
    cin>>ph;
    int c=0;
    for (int i = 0; i < n; ++i)
    {
        car=ph[i];
        if(i<k)ans[i]=beat(car),c+=mymap[beat(car)];
        else{
            if(ans[i-k]==beat(car)){
                char f='*';
                if((i+k)<n)f=beat(ph[i+k]);
                ans[i]=priv(beat(car),f);
            }
            else ans[i]=beat(car),c+=mymap[beat(car)];
        }
    }
    cout<<c;
    return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 640
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int N;
	cin>>N;
	int r=0,b=0;
	for (int i = 0; i < N; ++i)
	{
		char a;
		cin>>a;
		if(a=='R')
		{
			r++;
		}
		else
		{
			b++;
		}
	}
	if(r>b)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	

	return 0;
}

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

int main() {
    int n; cin >> n;
    int imos[101010] = {};
    for (int i = 0; i < n; i++) {
        int a, b; cin >> a >> b;
        imos[a]++;
        imos[b + 1]--;
    }
    for (int i = 1; i < 101010; i++) {
        imos[i] += imos[i - 1];
    }
    for (int i = 101010 - 1; i > 0; i--) {
        if (imos[i] >= i - 1) {
            cout << i - 1 << endl;
            break;
        }
    }
}



Measured memory_bytes: 3496
N = int(input())
nums = sorted(map(int, input().split()))
if nums[0] == 0:
    print(0)
else:
    ans = 1
    for num in nums:
        ans = ans * num
        if ans > 10**18:
            break
    if ans > 10**18:
        print('-1')
    else:
        print(ans)


Measured memory_bytes: 84796
n = gets.to_i
h = gets.split.map(&:to_i)
total = h.inject(:+)
sum = 0
count = 0
while sum < total do
  i = 0
  while i < n && h[i] == 0 do
    i += 1
  end
  while i < n && h[i] > 0 do
    h[i] -= 1
    sum += 1
    i += 1
  end
  count += 1
end
puts count


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

const ll mod=1000000007;

int main() {
 int a,b;
  cin >> a >> b;
  cout<<a*b<<endl;
}

Measured memory_bytes: 3624
# ARC069c
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

    n, m = map(int, input().split())
    if m > n*2:
        print(n+(m-n*2)//4)
    else:
        print(m//2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N, T;
    std::cin >> N >> T;
    std::map<int64_t, int64_t> B;
    int64_t cheapest = INT64_MAX;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;

        if (cheapest < t) {
            B[t - cheapest] += 1;
        }
        cheapest = std::min(t, cheapest);
    }

    std::cout << B.rbegin()->second << std::endl;

    return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
#define pff(a,b) printf("%d  %d\n",a,b);
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];

	int mx = 0;
	int cnt = 0;
	rep(i, n) {
		if (h[i] >= mx) cnt++;
		mx = max(h[i], mx);
	}
	pf(cnt);

	return 0;
}

Measured memory_bytes: 3704
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/19/20 20:59:59
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  ll n; int x,m; cin>>n>>x>>m;
  vector<ll> A={x};
  A.reserve(m);
  int s = 0;
  {
    vector<int> used(m, -1);
    used[x] = 0;
    while (true) {
      ll a = A.back()*A.back()%m;
      if (used[a] == -1) {
        used[a] = A.size();
        A.push_back(a);
      } else {
        s = used[a];
        break;
      }
    }
  }
  int f = A.size();
  for (int i = 1; i < s; i++) {
    A[i] += A[i-1];
  }
  for (int i = s+1; i < f; i++) {
    A[i] += A[i-1];
  }
  ll ans = 0;
  if (s > 0)
    ans += A[min((ll)s-1, n-1)];
  if (n > s) {
    ll l = n-s;
    ll k = f-s;
    ll c = l/k;
    ll d = l%k;
    ans += c * A[f-1] + (d > 0 ? A[s+d-1] : 0);
  }
  cout << ans << endl;

  return 0;
}


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

class dice{
public:
	int init_label[6];
    int label[6];
    int tmp1, tmp2;
    int order[4] = {1,2,4,3};
	void setnumber(){
		for(int i=0; i<6; i++)
			cin >> init_label[i];
    }

    int check(int over, int front, int right, int left, int back, int bottom){
    	for(int i=0; i<4; i++){
    		if(over == label[0] && front == label[order[i]] && right == label[order[(i+1)%4]] && back == label[order[(i+2)%4]] && left == label[order[(i+3)%4]] && bottom == label[5]){
            cout << "No" << endl;
    		return 1;
    		}
    	}
    	return 0;
    }
    	
    void rotation(string sign){
            tmp1 = label[0];
            tmp2 = label[5];
            if(sign == "N"){
                label[0] = label[1];
                label[5] = label[4];
                label[1] = tmp2;
                label[4] = tmp1;
            }
            if(sign == "S"){
                label[0] = label[4];
                label[5] = label[1];
                label[4] = tmp2;
                label[1] = tmp1;
            }
            if(sign == "W"){
                label[0] = label[2];
                label[5] = label[3];
                label[2] = tmp2;
                label[3] = tmp1;
            }
            if(sign == "E"){
                label[0] = label[3];
                label[5] = label[2];
                label[3] = tmp2;
                label[2] = tmp1;
            }
            if(sign == "NN"){
            	label[0] = tmp2;
            	label[5] = tmp1;
            	int tmp3 = label[4];
            	label[4] = label[1];
            	label[1] = tmp3;
            }
        }

    void initialization(void){
    	for(int i=0; i<6; i++){
    		label[i] = init_label[i];
    	}
    }
};

int main(){
    int n; cin >> n;
	vector<dice> d(n);
	for(int i=0; i<n; i++){
        d[i].setnumber();
    }
	string rot_info[6] = {"","N","W","E","S","NN"};
	int flag=0;
        for(int i=0; i<n; i++){
            d[i].initialization();
            for(int k=i+1; k<n; k++){
    		      for(int j=0; j<6; j++){
                        d[k].initialization();
                        d[k].rotation(rot_info[j]);
                        flag = d[k].check(d[i].label[0],d[i].label[1],d[i].label[2],d[i].label[3],d[i].label[4],d[i].label[5]);
                        if(flag == 1)
				            break;
                }
                if(flag == 1)
                    break;
            }
            if(flag == 1)
                break;
        }
    if(flag == 0)
        cout << "Yes" << endl;
	
    return 0;
}

Measured memory_bytes: 3160
#include <iostream>
using namespace std;
void ABC100(void);
void ABC101(void);
void ABC102(void);
void ABC103(void);
void ABC104(void);
void ABC105(void);
void ABC106(void);
void ABC107(void);
void ABC108(void);
void ABC109(void);

int main(void){
    ABC107();
}

void ABC107(){
    int n,i;
    cin>>n>>i;
    cout<<n-i+1<<endl;
}

Measured memory_bytes: 256
a, b = [int(x) for x in input().split()]
num = '0123456789'
S = input()
flg = True
for i in range(len(S)):
  if i == a:
    if not S[i] == '-':
      flg = False
  else:
    if not S[i] in num:
      flg = False
print('Yes' if flg else 'No')


Measured memory_bytes: 2940
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ x, n ] <- readInts
	ps <- readInts
	print $ snd $ head $ sort $ do
		i <- [ 0 .. 101 ]
		guard $ not $ i `elem` ps
		return ( abs ( i - x ), i )

Measured memory_bytes: 3736
w, h, n = map(int, input().split())

d = l = 0
u = h
r = w

for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        l = max(l, x)
    elif a == 2:
        r = min(r, x)
    elif a == 3:
        d = max(d, y)
    else:
        u = min(u, y)

print(max(0, u - d) * max(0, r - l))

Measured memory_bytes: 3064
package main

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

const Mod = 1e9 + 7

func main() {
	H, W := ReadInt(), ReadInt()
	grid := make([]string, H)
	for i := 0; i < H; i++ {
		grid[i] = ReadString()
	}
	dp := make([][]int, H)
	for i := 0; i < H; i++ {
		dp[i] = make([]int, W)
	}
	dp[H-1][W-1] = 1
	for i := H - 1; i >= 0; i-- {
		for j := W - 1; j >= 0; j-- {
			if grid[i][j] == '#' {
				continue
			}
			for k := 0; k < 2; k++ {
				ni, nj := i+k, j+(1-k)
				if ni >= H || nj >= W {
					continue
				}
				dp[i][j] = (dp[i][j] + dp[ni][nj]) % Mod
			}
		}
	}
	fmt.Println(dp[0][0])
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }


Measured memory_bytes: 11424
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int d, n;

  cin >> d  >> n;

  if(n == 100) n = 101;
  
  for(int i=0;i<d;i++) n *= 100;
  
  
  cout << n << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>

const static int INF = 1001001001;

int main(void){
    int n, m;
    std::string s;
    std::cin >> n >> m >> s;
    std::queue<int> q;
    std::vector<int> dp(n+1, INF);
    
    dp[n] = 0;
    q.push(0);
    for(int i = n-1; i >= 0; i--){
	while(1){
	    if(q.empty()){
		std::cout << -1 << std::endl;
		return 0;
	    }
	    int cur = q.front();
	    // std::cout << cur << " " << q.size() << std::endl;
	    if(q.front() != INF && q.size() <= m) break;
	    q.pop();
	}
	if(s[i] == '0') dp[i] = q.front() + 1;
	q.push(dp[i]);
    }

    int x = 0;
    std::vector<int> ans;
    while(x < n){
	int res = dp[x];
	res--;
	int i = 1;
	while(dp[x + i] != res) i++;
	x += i;
	ans.push_back(i);
    }
    for(int i = 0; i < ans.size(); i++){
        std::cout << ans[i] << " ";
    }
    std::cout << std::endl;

    
    return 0;
}



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


//defines...
#define ll long long
#define tata return;
#define pb push_back
#define mp make_pair
#define in insert
#define run ios_base::sync_with_stdio(false);cin.tie(NULL);
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define vec vector<ll>
#define setl set<ll>
#define mapl map<ll,ll>
#define shunno cout<<0<<endl;
#define pi 2*acos(0.0)1
#define hobena cout<<-1<<endl;








void oka()
{
        ll n,i,j,k,sum=0,mod=1e9+7;
        cin>>n;
        ll a[n];
        for(i=0;i<n;i++)
            cin>>a[i],sum+=a[i];
        ll ans=0;
        for(i=0;i<n;i++)
        {
            sum-=a[i];
            ans+=((a[i]%mod)*(sum%mod))%mod;
            ans%=mod;
        }
        cout<<ans<<endl;





}






int main()
{
   //string g="abcd";
    //g.erase(g.begin()+3);
    //cout<<g<<endl;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    run
    ll i,t;
    t=1;
   //cin>>t;


    for(i=1;i<=t;i++)
    {


    oka();
    }






}


Measured memory_bytes: 5216
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine());

        int count = 0;
        if( n < 10 ) {
            System.out.println(n);
            return;
        }
        if( n < 100 ){
            System.out.println( 9 );
            return;
        }
        if( n < 1000 ){
            System.out.println( n - 99 + 9 );
            return;
        }
        if( n < 10000 ){
            System.out.println( 999 - 99 + 9);
            return;
        }
        if( n < 100000 ){
            System.out.println( n - 9999 + 999 - 99 + 9);
            return;
        }
        System.out.println( 90909 );

    }

}


Measured memory_bytes: 21716
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_C&lang=jp
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int a,b;
  while(cin>>a>>b){
    if(a==0&&b==0)break;
    if(a>b)swap(a,b);
    cout<<a<<" "<<b<<endl;
  }
  return 0;
}



Measured memory_bytes: 3024
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    let c=read::<i32>();
    println!("{}",if a+b>=c{"Yes"}else{"No"})
}


Measured memory_bytes: 4352
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}


fun main() {
    val S = next()
    val T = next()
    val map1 = HashMap<Char, Char>()
    val map2 = HashMap<Char, Char>()
    for (i in S.indices) {
        val s = S[i]
        val t = T[i]
        if (map1.contains(s) && map1[s] != t) {
            println("No")
            return
        }
        if (map2.contains(t) && map2[t] != s) {
            println("No")
            return
        }
        map1[s] = t
        map2[t] = s
    }
    println("Yes")
}

Measured memory_bytes: 41200
#include <stdio.h>

int main(){
  int i,j,q,N,k,a[3][3],c=0,s[3],t[3],x=0,y=0;
  
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      scanf("%d",&a[i][j]);
    }
  }
  
 scanf("%d",&N);
  int b[N];
  for(i=0;i<N;i++){
    scanf("%d",&b[i]);
 
  }
  for(k=0;k<N;k++){ 
   for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      if(a[i][j]==b[k])
        a[i][j]=0;
    }
   }
  }
  for(i=0;i<3;i++){
    t[i]=0;s[i]=0;
  }
  
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      s[i]+=a[i][j];
    }
  }
    if(s[1]==0||s[0]==0||s[2]==0)
      c++;
   for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      t[i]+=a[j][i];
    }
   }
      if(t[1]==0||t[0]==0||t[2]==0)
         c++;
   for(i=0;i<3;i++){
     x+=a[i][i];
     y+=a[i][2-i];
   }
     if(x==0||y==0)
    c++;

     if(c>0)
  printf("Yes");
     else
       printf("No");
}


Measured memory_bytes: 128
#include <algorithm>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> P;
lli MOD = 1000000007;
int main()
{
    lli n, m;
    cin >> n >> m;
    lli a;
    lli mod[100005] = {};
    lli x[100005] = {};
    rep(i, n)
    {
        cin >> a;
        mod[a % m]++;
        x[a]++;
    }
    lli ans = 0;
    rep(i, m)
    {
        if (i == 0) {
            ans += mod[i] / 2;
            mod[i] = mod[i] % 2;
        } else if (m % 2 == 0 && i == m / 2) {
            ans += mod[i] / 2;
            mod[i] = mod[i] % 2;
        } else if (i != 0 && !(m % 2 == 0 && i == m / 2)) {
            ans += min(mod[i], mod[(m - i) % m]);
            lli del = min(mod[i], mod[(m - i) % m]);
            mod[i]
                -= del;

            mod[(m - i) % m] -= del;
        }
    }
    rep(i, 100005)
    {
        if (x[i] < 2)
            continue;
        else {
            int l = i % m;
            int ma = mod[l] / 2;
            int use = x[i] / 2;
            if (ma >= use) {
                mod[l] -= use * 2;
                ans += use;
            } else {
                mod[l] = 0;
                ans += ma;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
n = int(input())
nums = list(map(int,input().split()))
dic = {}

for i in nums:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

dic_sort = sorted(dic.items(),reverse=True)

side1 = 0

for side,num in dic_sort:
    if num>=4:
        if side1==0:
            print(side**2)
            exit()
        else:
            print(side1*side)
            exit()
    elif num >=2:
        if side1 ==0:
            side1=side
        else:
            print(side1*side)
            exit()
print(0)

Measured memory_bytes: 21028
N=int(input())

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

ans=0
ans+=B[0]
for i in range(N-2):
    if B[i]<B[i+1]:
        ans+=B[i]
    else:
        ans+=B[i+1]
ans+=B[N-2]
print(ans)





Measured memory_bytes: 38384
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  long long H,W,M;
  cin>>H>>W>>M;
  int yoko[300000],tate[300000];
  pair<int,int> bom[300000];
  for(int i=0;i<H;i++) yoko[i]=0;
  for(int i=0;i<W;i++) tate[i]=0;
  for(int i=0;i<M;i++){
    int h,w;
    cin>>h>>w;
    bom[i]=make_pair(h-1,w-1);
    yoko[h-1]++;
    tate[w-1]++;
  }
  pair<int,int> hol[300000],ver[300000];
  for(int i=0;i<H;i++) hol[i]=make_pair(yoko[i],i);
  for(int i=0;i<W;i++) ver[i]=make_pair(tate[i],i);
  sort(hol,hol+H);
  sort(ver,ver+W);
  long long Y=hol[H-1].first;
  long long T=ver[W-1].first;
  long long hnum=0;
  long long vnum=0;
  int hju[300000],vju[300000]; //爆弾数が最大の縦横を１とする
  for(int i=0;i<H;i++) hju[i]=0;
  for(int i=0;i<W;i++) vju[i]=0;
  for(int i=H-1;i>=0;i--){
    if(hol[i].first==Y){
      hju[hol[i].second]++;
      hnum++;
    }
    else break;
  }
  for(int i=W-1;i>=0;i--){
    if(ver[i].first==T){
      vju[ver[i].second]++;
      vnum++;
    }
    else break;
  }
  long long l=0;
  for(int i=0;i<M;i++){
    if(hju[bom[i].first]!=0&&vju[bom[i].second]!=0) l++;
  }
  if(l<hnum*vnum) cout<<Y+T<<endl;
  else cout<<Y+T-1<<endl;
  
  return 0;
}

Measured memory_bytes: 14900
#include <bits/stdc++.h>
#define INF (1LL<<55)
#define INF2 (1LL<<55)
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;

struct edge{
    int u,v;
    ll c;
    edge(){}
    edge(int uu,int vv,ll cc){
        u=uu;
        v=vv;
        c=cc;
    }
    bool operator<(const edge &e)const{
        return c<e.c;
    }
};

struct uftree{
    int par[200005];
    int rank[200005];
    uftree(){
    }
    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
        }
    }
    int find(int x){
        if(par[x]==x)return x;
        return par[x]=find(par[x]);
    }

    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y)return;
        if(rank[x]<rank[y]){
            par[x]=y;
        }else{
            if(rank[x]==rank[y])rank[x]++;
            par[y]=x;
        }
    }

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

int n;
ll d;
ll a[200005];
uftree uf;
vector<edge> e;

void dfs(int l,int r){
    if(l>=r)return;
    int mid=(l+r)/2;
    int lv=mid,rv=mid;
    for(int i=l;i<=mid;i++){
        if((a[mid]+a[lv]+d*(mid-lv))>(a[mid]+a[i])+d*(mid-i)){
            lv=i;
        }
    }
    for(int i=mid;i<r;i++){
        if((a[mid]+a[rv]+d*(rv-mid))>(a[mid]+a[i])+d*(i-mid)){
            rv=i;
        }
    }
    for(int i=l;i<=mid;i++){
        e.push_back(edge(i,rv,a[i]+a[rv]+d*(rv-i)));
    }
    for(int i=mid;i<r;i++){
        e.push_back(edge(i,lv,a[i]+a[lv]+d*(i-lv)));
    }
    if(l+1==r)return;
    dfs(l,mid);
    dfs(mid,r);
}

int main(void){
    scanf("%d%lld",&n,&d);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    if(n==1){
        printf("0\n");
        return 0;
    }
    dfs(0,n);
    ll ans=0;
    uf.init(n);
    sort(e.begin(),e.end());
    for(int i=0;i<e.size();i++){
        if(!uf.same(e[i].u,e[i].v)){
            //printf("%d %d %lld\n",e[i].u,e[i].v,e[i].c);
            uf.unite(e[i].u,e[i].v);
            ans+=e[i].c;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 69472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, k;
    cin >> a >> b >> k;
    rep(i, k) {
        if (i % 2 == 0) {
            b = b + a / 2;
            a = a / 2;
        }
        else {
            a = a + b / 2;
            b = b / 2;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

int keta(int x) {
	int y = 0;
	while (x > 0) {
		y++;
		x /= 10;
	}
	return y;
}

ll dx[8] = { 0,0,-1,1 };
ll dy[8] = { -1,1,0,0 };
ll dp[101010];

//long longしか使わない
int main() {
	ll k;
	cin >> k;
	string s;
	cin >> s;
	ll n = s.length();
	if (n <= k) {
		cout << s << endl;
	}
	else {
		string ans = s.substr(0, k);
		cout << ans;
		cout << "...";
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int n,z,w,a[2005],f[2005][2005],g[2005][2005],sf[2005],sg[2005];
int main(){
	scanf("%d%d%d",&n,&z,&w);
	for (int i=3;i<=n+2;i++) scanf("%d",&a[i]);
	a[1]=z;a[2]=w;n+=2;
	sf[n-1]=sg[n-1]=f[n-1][n]=g[n-1][n]=abs(a[n-1]-a[n]);
	for (int i=n-1;i;i--){
		g[i][n]=f[i][n]=abs(a[i]-a[n]);
		for (int j=n-1;j>i;j--){
			f[i][j]=sg[j];
			g[i][j]=sf[j];
		}
		sf[i]=1000000000;
		for (int j=n;j>i;j--){
			sg[i]=max(sg[i],g[i][j]);
			sf[i]=min(sf[i],f[i][j]);
		}
	}
	printf("%d",f[1][2]);
}

Measured memory_bytes: 31360
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


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

  int cnt = 0, s = 0;
  rep(i,N){
    if (i==N-1) cnt++;
    else if (A[i+1]>A[i]){
      if (s==0) s = 1;
      else if (s==1) continue;
      else {
        cnt++;
        s = 0;
      }
    }
    else if (A[i+1]<A[i]){
      if (s==0) s = -1;
      else if (s==-1) continue;
      else {
        cnt++;
        s = 0;
      }
    }
  }
  cout << cnt << endl;

  // cout << fixed << setprecision(10);
  
  return 0;
}



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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

struct FenwickTree{
    std::vector<int> data;
    int numNodes;
    
    FenwickTree(int n) : data(n + 1, 0), numNodes(n) {}

    void add(int k, int v){
        k += 1;
        while(k > 0){
            data[k] += v;
            k -= k & -k;
        }
    }

    int sum(int k){
        k += 1;
        int s = 0;
        while(k <= numNodes){
            s += data[k];
            k += k & -k;
        }
        return s;
    }
};

int N;
int A[100100];

bool can(int x){ // m の中央値が x 以上か判定する
    std::vector<int> B(N + 1);

    B[0] = 0;

    for(int i=1;i<=N;++i){
        if(A[i] >= x){
            B[i] = +1;
        }else{
            B[i] = -1;
        }

        B[i] += B[i - 1];
    }

    std::vector<int> C(B.begin() + 1, B.end());
    std::sort(C.begin(), C.end());
    C.erase(std::unique(C.begin(), C.end()), C.end());

    FenwickTree t[2] = {{(int)C.size()}, {(int)C.size()}};

    for(int i=1;i<=N;++i){
        t[i & 1].add(std::lower_bound(C.begin(), C.end(), B[i]) - C.begin(), +1);
    }

    ll y = 0;

    for(int i=1;i<=N;++i){
        int i1 = std::lower_bound(C.begin(), C.end(), B[i - 1] + 1) - C.begin(),
            i2 = std::lower_bound(C.begin(), C.end(), B[i - 1]) - C.begin(),
            i3 = std::lower_bound(C.begin(), C.end(), B[i]) - C.begin(),
            v1 = t[i & 1].sum(i1),
            v2 = t[!(i & 1)].sum(i2);
        
        y += v1;
        y += v2;

        t[i & 1].add(i3, -1);
    }

    ll m = 1ll * N * (N + 1) / 2;

    return y >= (m + 1) / 2;
}

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

    std::cin >> N;

    for(int i=1;i<=N;++i){
        std::cin >> A[i];
    }

    int lb = 0, ub = 1'000'000'001;
    while(ub - lb > 1){
        int m = (lb + ub) / 2;

        if(can(m)){
            lb = m;
        }else{
            ub = m;
        }
    }

    std::cout << lb << std::endl;
}


Measured memory_bytes: 2276
package main

import "fmt"

func main() {
        var n, prefixNum, suffixNum int
        var s string
        fmt.Scan(&n)
        fmt.Scan(&s)
        nested := 0
        for i := 0; i < n; i++ {
                cur := s[i]
                if cur == '(' {
                        nested++
                } else {
                        nested--
                }
                if nested < 0 {
                        prefixNum++
                        nested = 0
                }
        }
        if nested > 0 {
                suffixNum += nested
        }
        for i := 0; i < prefixNum; i++ {
                fmt.Print("(")
        }
        fmt.Printf("%s", s)
        for i := 0; i < suffixNum; i++ {
                fmt.Print(")")
        }
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, x;
	cin >> n >> x;
	vl v(n);
	REP(i, n)cin >> v[i];
	sort(ALL(v));
	REP(i, n-1) {
		if (x < v[i]) {
			cout << i << endl;
			return 0;
		}
		x -= v[i];
	}
	if (x == v.back()) {
		cout << n << endl;
	}
	else {
		cout << n - 1 << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void A_task();

int main()
{
	A_task();
	fflush(stdout);
	return 0;
}

static void A_task()
{
	int r;
	get1int(r);

	printf("%d\n", r * r);
}


Measured memory_bytes: 256
N=int(input())
F=[]
for i in range(N):    
    F.append(list(map(int,input().split())))
P=[]
for i in range(N):
    P.append(list(map(int,input().split())))

ans=-10**10
for k in range(1,1<<10):
    op=[k>>j&1 for j in range(10)]
    res=0
    for i in range(N):
        c=sum([F[i][j]&op[j] for j in range(10)])
        res+=P[i][c]
    ans=max(ans,res)

print(ans)

Measured memory_bytes: 42092
s = list(input())

if s[0]!="A":
  print("WA")
  exit()

frag = True
for i in range(2,len(s)-1):
  if s[i]=='C':
    frag = False
    del s[i]
    break

if frag:
  print("WA")
  exit()
  
if not "".join(s[1:]).islower():
  print("WA")
else:
  print("AC")

Measured memory_bytes: 3060
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n,m;
    while(cin>>n>>m,n+m){
        vi v(n); rep(i,n)v[i]=i+1;
        int now=0;
        while(true){
            if(v.size()==1)break;
            now+=m;
            while(now>(int)v.size())now-=(int)v.size();
            //cout<<v[now-1]<<endl;
            v.erase(v.begin()+now-1);
            --now;
            
        }
        cout<<v[0]<<endl;
    }
}

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

using namespace std;

int h, w;
string c[310];
int dp[310][310], len[310][310];

int cmp(int x, int i, int j) {
	if (i == 0 || j == 0) return len[i][j] = 0;
	if (len[i][j] != -1) return len[i][j];
	len[i][j] = cmp(x, i - 1, j - 1) 
	          + (c[i - 1][x] == c[j - 1][x + 1]);
	//cout<<x<<" "<<i<<" "<<j<<" "<<cnt<<endl;
	return len[i][j]; 
}

int search(int x, int i, int j) {
	if (dp[i][j] != -1) return dp[i][j];
	if (i == 0 || j == 0) return dp[i][j] = 0;
	dp[i][j] = min(search(x, i - 1, j), search(x, i, j - 1))
	         + cmp(x, i, j);
	return dp[i][j];
}

int work(int x) {
	memset(dp, -1, sizeof(dp));
	memset(len, -1, sizeof(len));
	return search(x, h, h);
}

int main() {
	while (cin>>h>>w) {
		for (int i = 0; i < h; ++ i) {
			cin>>c[i];
		}
		int ans = 0;
		for (int i = 0; i < w - 1; ++ i) {
			ans += work(i);
			//cout<<i<<" "<<work(i)<<endl;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	cout<<(read()-read())%read()<<endl;
	return 0;
}



Measured memory_bytes: 256
package main

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

type node struct{
	value int
	prev *node
	next *node
}

var first, last *node

func main(){
	var(
		n int
		nd *node
	)
	fmt.Scan(&n)
	first, last = new(node), new(node)
	first.next, last.prev = last, first
	var sc = bufio.NewScanner(os.Stdin)
	for i:=0; i<n; i++{
		sc.Scan()
		input_ := sc.Text()
		switch input_{
		case "deleteFirst":
			first.next = first.next.next
			first.next.prev = first
		case "deleteLast":
			last.prev = last.prev.prev
			last.prev.next = last
		default:
			arr := strings.Split(input_, " ")
			num, _ := strconv.Atoi(arr[1])
			switch arr[0]{
			case "insert":
				insert(num)
			case "delete":
				delete(num)
			}
		}
	}
	nd = first.next
	fmt.Print(nd.value)
	for{
		nd = nd.next
		if nd == last{
			fmt.Print("\n")
			break
		}else{
			fmt.Print(" ", nd.value)
		}
	}
}

func insert(num int){
	nd := new(node)
	nd.value = num
	nd.prev = first
	nd.next = first.next
	first.next.prev = nd
	first.next = nd
}

func delete(num int){
	nd := first.next
	for{
		if nd == last{
			break
		}else if nd.value == num{
			nd.prev.next = nd.next
			nd.next.prev = nd.prev
			break
		}else{
			nd = nd.next
		}
	}
}


Measured memory_bytes: 63572
import java.io.*;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int k = in.nextInt();

        if (k <= a) {
            out.println(k);
        } else if (k <= a + b) {
            out.println(a);
        } else {
            k -= (a + b);
            out.println(a - k);
        }
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 25380
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import collections

n = ni()

if n == 1:
    print(1)
    exit()

balls = []
dis = []

for i in range(n):
    x,y = na()
    for b in balls:
        k = '_1' if (b[0]-x)*(b[1]-y) > 0 else '_0'
        dis.append(str(abs(b[0]-x))+'_'+str(abs(b[1]-y))+k)
    balls.append([x,y])

c = collections.Counter(dis)
m = c.most_common()

if len(m) == 1:
    print(1)
    exit()

u = m[0][1]

print(n-u)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pair<int, int> x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e7;
const int MX = 100001; //check the limits, dummy

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

    array<int ,3> a;
    cin >> a[0] >> a[1] >> a[2];
    sort(begin(a), end(a));
    cout << (a[0] != a[1] && a[1] == a[2] || a[0] == a[1] && a[1] != a[2] ? "Yes" : "No") << endl;
}

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

int main(){
    int N, M;
    int k[10];
    int s[10][10];
    int p[10];
    cin >> N >> M;
    for(int i=0;i<M;i++){
        cin >> k[i];
        for(int j=0;j<k[i];j++){
            cin >> s[i][j];
        }
    }
    for(int i=0;i<M;i++){
        cin >> p[i];
    }
    int sum = 0;
    int cnt = 0;
    for(int b=0;b < (1<<N); b++){
        for(int i=0;i<M;i++){
            sum=0;
            for(int j=0; j<k[i]; j++){
                if(b & (1 << (s[i][j]-1))){
                    sum++; 
                }
            }
            if(sum % 2 != p[i]){
                //cout << p[i] <<" "<<i<<" "<<" "<< b << endl;
                break;
            }
            if(i == M-1){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

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

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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 <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

vector<vector<P>> graph;
vector<ll> dist;
vector<bool> used;
void dfs (int i) {
    for (auto p : graph[i]) {
        if (used[p.second]) continue;
        used[p.second] = true;
        dist[p.second] = p.first + dist[i];
        dfs(p.second);
    }
}
int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    graph.resize(n);
    dist.resize(n);
    rep (i, m) {
        int l, r, d; cin >> l >> r >> d; l--; r--;
        graph[l].emplace_back(d, r);
        graph[r].emplace_back(-d, l);
    }
    used.resize(n);
    rep (i, n) {
        if (!used[i]) {
            used[i] = true;
            dfs(i);
        }
    }
    rep (i, n) {
        for (auto p : graph[i]) {
            if (dist[p.second] - dist[i] != p.first) {
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 12416