akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		double n = saori.Hayamin();
		double k = saori.Hayamin();
		double ans = 0;
		for(int i = 0;i < n;i++){
			double tmp = 1/n;
			int num = i+1;
			while(num < k){
				num *= 2;
				tmp *= 0.5;
			}
			ans += tmp;
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 20820
package main
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)
//-------------------------------------入力マクロ
var sc = bufio.NewScanner(os.Stdin)

func lstr() string {
    sc.Scan()
    return sc.Text()
}
func lint() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}
//-------------------------------------wtf入力マクロend
/*************************************
*    スペースで文字列を区切る        *
*    sc.Split(bufio.ScanWords)       *
*                                    *
*************************************/

func main(){
//-------------------------------------出力マクロ
out:=func(i interface{}){fmt.Println(i)}
//-------------------------------------出力マクロ
    sc.Split(bufio.ScanWords)
    n:=lint()
    four:=0
    two:=0
    els:=0
    for i:=0;i<n;i++{
        tmp:=lint()
        div:=0
        for tmp%2==0{
            tmp/=2
            div++
        }
        if div>1{
            four++   
        }else if div==1{
            two++
        }else{
            els++
        }
    }
    if four>=els || ((els-four==1 && four>=1) && two==0){
        out("Yes")
    }else{
        out("No")
    }
}


Measured memory_bytes: 3316
#!/usr/bin/env python3

S = input()
K = int(input().split()[0])

# 連続する文字が奇数かどうか
# 先頭と末尾が異なる場合はシンプル
# 先頭と末尾が同じ場合は、
count_seq_start = 1  # 先頭からの連続文字数
count_seq_end = 1  # 末尾の連続文字数agca

# 先頭からの連続文字数を数える
for i in range(1, len(S)):
    if S[i] == S[0]:
        count_seq_start += 1
    else:
        break

# 末尾からの連続文字数を数える
count_seq_end = 1  # 末尾の連続文字数

for i in range(1, len(S)):
    if S[-1 - i] == S[-1]:
        count_seq_end += 1
    else:
        break

unit_c = 0
count_seq = 1
for i in range(1, len(S)):
    if S[i] == S[i - 1]:
        count_seq += 1
    else:
        # count_seqの偶奇判定
        if count_seq % 2 == 0:
            unit_c += count_seq // 2
        else:
            unit_c += (count_seq - 1) // 2
        count_seq = 1

# 末尾まで連続していた時の処理
# 末尾が1文字だけの場合は、unit_cには0が足されるのでOK
# 末尾が2文字以上の場合、まだunit_cにはカウントされていないのでここで足してOK
if count_seq % 2 == 0:
    unit_c += count_seq // 2
else:
    unit_c += (count_seq - 1) // 2

c = 0
c += unit_c * K

if S[0] == S[-1] and count_seq_start % 2 == 1 and count_seq_end % 2 == 1:
    c += K - 1

is_all = True
for i in range(1, len(S)):
    if S[i] == S[0]:
        pass
    else:
        is_all = False
        break

if is_all:
    if (len(S) * K) % 2 == 0:
        c = len(S) * K // 2
    else:
        c = (len(S) * K - 1) // 2

ans = int(c)
print(ans)


Measured memory_bytes: 3064
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

use std::vec;

struct UnionFind {
    par: vec::Vec<i32>,
}

impl UnionFind {
    fn new(n: usize) -> UnionFind {
        let mut res = UnionFind { par: vec::Vec::with_capacity(n), };
        for _i in 0..n {
            res.par.push(-1);
        }
        res
    }
    fn root(&mut self, x: i32) -> i32 {
        let x_id = x as usize;
        if self.par[x_id] < 0 {
            x
        } else {
            let p = self.par[x_id];
            self.par[x_id] = self.root(p);
            self.par[x_id]
        }
    }

    fn unite(&mut self, x: i32, y: i32) -> bool {
        let x = self.root(x);
        let y = self.root(y);
        if x == y {
            false
        } else {
            let x_id = x as usize;
            let y_id = y as usize;
            if self.size(x) < self.size(y) {
                self.par[y_id] = self.par[y_id] + self.par[x_id];
                self.par[x_id] = y;
            } else {
                self.par[x_id] = self.par[x_id] + self.par[y_id];
                self.par[y_id] = x;
            }
            true
        }
    }

    fn same(&mut self, x: i32, y: i32) -> bool {
        self.root(x) == self.root(y)
    }

    fn size(&mut self, x: i32) -> i32 {
        let r = self.root(x) as usize;
        -self.par[r]
    }
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n: usize = sc.read();
    let q: i32 = sc.read();
    let mut uf = UnionFind::new(n);
    for _q in 0..q {
        let com: i32 = sc.read();
        let x: i32 = sc.read();
        let y: i32 = sc.read();
        if com == 0 {
            uf.unite(x, y);
        } else {
            println!("{}", uf.same(x, y) as i32);
        }
    }
}


Measured memory_bytes: 5048
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=1e5+7;

int a[N],n;
ll b[N],sum,val;

int main(){
//	fileio("test");
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",a+i),sum+=a[i];
	val=(ll)n*(n+1)/2;
	if(sum%val!=0) return puts("NO"),0;
	ll tot=sum/val;
	rep(i,1,n){
		int pre=a[i==1?n:i-1];
		if(tot-a[i]+pre<0||(tot-a[i]+pre)%n!=0) return puts("NO"),0;
		b[i]=(tot-a[i]+pre)/n;
	}
	ll tot2=0;
	rep(i,1,n) tot2+=b[i];
	puts(tot2==tot?"YES":"NO");
	return 0;
} 

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << end
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,q; cin >> n >> q;
    vvl g(n);
    rep(i,n-1){
        int a,b; cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vl cost(n); 
    vector<bool> is_alre(n);
    rep(i,q){
        int p,x; cin >> p >> x;
        p--;cost[p]+=x;
    }
    queue<ll> que;
    que.push(0);
    is_alre[0]=true;
    while(!que.empty()){
        auto v = que.front();
        que.pop();
        for(auto nv:g[v]){
            if(is_alre[nv])continue;
            cost[nv]+=cost[v];
            is_alre[nv] = true;
            que.push(nv);
        }
    }
    rep(i,n){
        if(i)cout << " ";
        cout << cost[i];
    }
    cout << endl;
}


Measured memory_bytes: 17904
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ll k,x,s,d,m;
  cin>>k>>x;
  for(s=1;s<k;s++)
  {
    cout<<x-k+s<<" ";
  }
  cout<<x<<" ";
  for(s=1;s<k;s++)
  {
    cout<<x+s<<" ";
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll freq[200008];
ll nc(ll a)
{
	if(a<2)return 0;
	return (a*(a-1))/2;
}
int main()
{
 	set<int> s;
 	int n;
 	cin>>n;
 	int a[n];
 	for(int i=0;i<n;i++)
 	{
 		cin>>a[i];
 		s.insert(a[i]);
 		freq[a[i]]++;
 		
 	}
 	ll tot=0;
 	for(auto x:s)
 	{
 		tot=tot+nc(freq[x]);
 	}
 	vector<ll> ans;
 	for(int i=0;i<n;i++)
 	{
 		cout<<(tot-nc(freq[a[i]])+nc(freq[a[i]]-1))<<"\n";
 		
 	}
}

Measured memory_bytes: 11776
n,m = map(int,input().split())
sortsecond = lambda val:val[0]
shop = [[0]*2 for i in range(n)]
for i in range(n):
    dum = list(map(int,input().split()))
    shop[i] = dum
shop.sort(key=sortsecond)
ans = 0
for i in range(n):
    if m < shop[i][1]:
        ans += m*shop[i][0]
        m = 0
    else:
        ans += shop[i][0]*shop[i][1]
        m -= shop[i][1]
    if m == 0:
        break
print(ans)

Measured memory_bytes: 28964
def partition(a, p, r):
    x = a[r]
    i = p - 1
    for j in range(p, r):
        if a[j] <= x:
            i = i + 1
            esc = a[i]
            a[i] = a[j]
            a[j] = esc
    esc = a[i + 1]
    a[i + 1] = a[r]
    a[r] = esc
    return i + 1


n = int(input())
A = list(map(int, input().split()))

index = partition(A, 0, n - 1)
left = A[:index]
center = A[index]
right = A[index + 1:]
print(*left, '[' + str(center) + ']', *right)



Measured memory_bytes: 16388
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> G(n);
    vector<int> indeg(n);
    REP(i,n + m - 1){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        G[a].emplace_back(b);
        indeg[b]++;
    }
    int s;
    REP(i,n){
        if(indeg[i] == 0){
            s = i;
            break;
        }
    }
    vector<int> ans(n);
    queue<int> que;
    que.emplace(s);
    while(!que.empty()){
        int now = que.front();
        que.pop();
        for(auto v : G[now]){
            indeg[v]--;
            if(indeg[v] == 0){
                que.emplace(v);
                ans[v] = now + 1;
            }
        }
    }
    REP(i,n){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
 
 
int main()
{
 
    int n;
    cin>>n;

    bool flg=true;
    for(int i=0;i<n;i++){
        int t,x,y;
        cin>>t>>x>>y;

        if(t%2!=(x+y)%2 || t<x+y){
            flg=false;
            break;
        }
    }
 

    if(flg)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    
    return 0;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 29;

int maxTime(int x) {
	return (x+9) / 10 * 10;
} 
int remTIme(int x) {
	return maxTime(x) - x;
}
int main() {
	//int a,b,c,d,e;
	//cin >> a >> b >> c >> d >> e;
	int ans = 0;
	int time[5];
	int rem = 0;
	rep(i,5) {
		cin >> time[i];
		ans += maxTime(time[i]);
		rem = max(rem, remTIme(time[i]));
	}
	cout << ans - rem << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int cnt[2][3001][3001];

int calc(int a,int b,int c,int d,int x){
	a--;b--;c--;d--;
	if(c < 0 || d < 0) return 0;
	int ret = cnt[x][c][d];
	int e = 0,f = 0,g = 0,h = 0;
	if(a >= 0 && b >= 0) ret += cnt[x][a][b];
	if(a >= 0) ret -= cnt[x][a][d];
	if(b >= 0) ret -= cnt[x][c][b];
	return ret;
}

signed main(){
	int n,k,ma = 0;
	cin >> n >> k;
	for(int i = 0;i < n;i++){
		int x,y;
		char c;
		cin >> x >> y >> c;
		if(c == 'B') cnt[0][x % (2 * k)][y % (2 * k)]++;
		else cnt[1][x % (2 * k)][y % (2 * k)]++;
	}
	for(int i = 0;i <= k * 3;i++){
		for(int j = 0;j <= k * 3;j++){
			for(int l = 0;l < 2;l++){
				if(i) cnt[l][i][j] += cnt[l][i - 1][j];
				if(j) cnt[l][i][j] += cnt[l][i][j - 1];
				if(i && j) cnt[l][i][j] -= cnt[l][i - 1][j - 1];
			}
		}
	}
	for(int i = -k;i < 0;i++){
		for(int j = -k;j < 0;j++){
			for(int l = 0;l < 2;l++){
				int ans = 0;
				for(int x = 0;x < 3;x++){
					for(int y = 0;y < 3;y++){
						ans += calc(i + x * k,j + y * k,i + k + x * k,j + k + y * k,(x + y + l) % 2);
					}
				}
				ma = max(ma,ans);
			}
		}
	}
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 140928
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll mod=1000000007; // 998244353 = (119<<23)+1
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
// head
string s,g;
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
		cin>>s;
		g=s;
		g[0]='0';
		rep(i,1,sz(s)) g[i]=g[i-1]^1;
		int ans=0;
		int ans2=0;
		rep(i,0,sz(s)) {
			if(s[i]!=g[i]) ans++;
			else ans2++;
		}
//		cout<<ans<<' '<<ans2<<'\n';
		cout<<min(ans,ans2);

		return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if(a == b) {
    cout << "Draw" << endl;
  }
  else {
    if(a == 1) {
      cout << "Alice" << endl;
    }
    if(b == 1) {
      cout << "Bob" << endl;
    }
   if(a == 1 || b == 1) {

   } else {
     if(a>b) {
       cout << "Alice" << endl;
     } else {
       cout << "Bob" << endl;
     }
   }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    ll n, a, b, ans = 0;
    cin >> n >> a >> b;
    vector<ll> x(n);
    rep(i, n) cin >> x[i];
    rep(i, n - 1)
    {
        if ((x[i + 1] - x[i]) * a >= b)
            ans += b;
        else
            ans += (x[i + 1] - x[i]) * a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
 
int asc(const void *a, const void *b) {
    char *left_char = (char *)a;
    char *right_char = (char *)b;
    return strcmp( left_char, right_char );
}

int main(){
    int n,i,j,c=1;
    scanf("%d",&n);
    char s[200001][12];
    for(i=0;i<n;i++){
        scanf("%11s",s[i]);
    }
    //for(i=0;i<n;i++){ printf("%s\n",s[i]); }
    qsort(s, n, sizeof(*s), asc);
    //for(i=0;i<n;i++){ printf("%s\n",s[i]); }
    for(i=0;i<n-1;i++){
        if(strcmp(s[i],s[i+1])!=0){ c++; }
    }
    printf("%d",c);
    return 0;
}

Measured memory_bytes: 6264
/********************/
/* K B G D E L T A */
/*     DA-IICT      */
/********************/
 
#include<bits/stdc++.h>
using namespace std;
using   ll=long long;
using   ld=long double;
#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define F(i,n)         for(ll i=0;i<n;i++)
#define rep(i,a,b)     for(ll i=a;i<b;i++)
#define repp(i,a,b)    for(ll i=a;i>=b;i--)
#define pb             push_back
#define mp             make_pair
#define vll            vector<ll>
#define f              first
#define s              second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323
#define mod            1000000007
#define N              1e5+1
 
void solve()
{
	ll n;
	
	string s;
	
	cin>>n>>s;
	
	if(n%2)
	{
		cout<<"No";
		
		return;
	}
	
	string tt=s.substr(0,n/2),pp=s.substr(n/2,n/2);
	
	if(tt==pp)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
}
 
signed main(){
 
    fast;
 
    ll t=1;
 
    while(t--)
    {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-ffloat-store")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define endl "\n"
#define f(i,a,b) for(int i=a;i<b;i++)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define mod 1000000007
#define inf  1e18
#define ps(x,y)   fixed<<setprecision(y)<<x
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define inp(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N = 2e3 + 10;
int main() 
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
    FIO;
    ll a,b,c,d;
    cin >>a >>b>>c>>d;
    ll ans = max({a*d,a*c,b*c,b*d});
    cout<<ans<<endl;
return 0;   
}

Measured memory_bytes: 3548
import java.util.*;

class Main {


	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		for(;;){
			int n = in.nextInt();
			if(n==0) return ;
			int a[] = new int[n];
			for(int i=0; i<n; i++) a[i] = in.nextInt();
			System.out.println(solve(a));
		}
	}
	
	static int solve(int[] a){
		int cnt=0;
		
		for(int i=a.length-1; i>0; i--)
			for(int j=0; j<i; j++){
				if(a[j] > a[j+1]){
					cnt++;
					int tmp = a[j];
					a[j] = a[j+1];
					a[j+1] = tmp;
				}
			}
		
		return cnt;
	}
}

Measured memory_bytes: 12000
#    0, 1, 2, 3, 4, 5, 6, 7, 8, 9
P = [0, 1, 2, 3, 4, 0, 0, 0, 0, 0]
C = [0, 0, 0, 0, 0, 5, 4, 3, 2, 1]
X = [0, 1, 2, 3, 4, 5, 4, 3, 2, 1]
import sys
def solve(N):
    N = [int(c) for c in N]
    N = N[::-1]
    p = 0
    b = 0
    s = []
    for i in range(len(N)):
        c = N[i]
        c += b
        if c == 10:
            c = 0
            b = 1
            p += X[c]
            #s.append(P[c])
        elif c == 5:
            if i == len(N)-1:
                p += 5
                #s.append(5)
                b = 0
            else:
                if N[i+1] < 5:
                    p += 5
                    b = 0
                    #s.append(5)
                else:
                    p += 5    
                    b = 1
                    #s.append(0)
        elif c > 5:
            b = 1
            p += X[c]
            #s.append(P[c])
        else:
            b = 0
            p += X[c]
            #s.append(P[c])
    if b:
        s.append(b)
        pass
    #print(b, file=sys.stderr)
    return p + b, s[::-1]

def count(n):
    return sum([int(x) for x in str(n)])

def test(N):
    m = 10e10
    p = 0
    for P in range(N, N*10):
        n = count(P) + count(P - N)
        if n < m:
            p = P
            m = n
    e,s = solve(str(N))
    if e != m:
        print("N=%d"%N, "expected=%d"%m, p, "actual=%d"%e, "".join(str(c) for c in s))

N = [int(x) for x in input()]
a,_ = solve(N)
print(a)
if 1==0:
    for i in range(1, 1000):
        test(i)
    test(159)
    test(149)
    test(449)
    test(959)
    test(949)
    test(939)
    test(539)
    test(569)



Measured memory_bytes: 124340
import java.util.Scanner;

public class Main {
	
	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			int n = sc.nextInt();
			if(n == 0) break;
			else calc(n);
		}
	}
	public void calc(int e){
		int m = e;
		for(int z = 0; z < e + 1; z++){
			if(z*z*z > e) break;
			int e2 = e - z*z*z;
			for(int y = 0; y < e2 + 1; y++){
				if(y*y > e2) break;
				int x = e2 - y*y;
				if(z + y + x < m) m = x + y + z;
			}
		}
		System.out.println(m);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 26292
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
 
const double PI=acos(-1.0);
int main(){
	double r;
	scanf("%lf",&r);
	printf("%.5lf",2.0*r*PI);
    return 0;
}

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


const int mod = 1e+9 + 7;

long mod_pow( long x, long y ){

    if( y == 0 ) return 1;
    else if( y == 1 ) return x % mod;
    else if( y % 2 == 0 ) return mod_pow(x, y/2) * mod_pow(x, y/2) % mod;
    else return mod_pow(x, y/2) * mod_pow(x, y/2) % mod * x % mod;

}

long combination( int n, int r ){

    if( r == 0 ) return 1;
    
    long numerator = 1, denominator = 1;
    for( int i = 1; i <= r; i++ ){
        numerator *= n - i + 1;
        numerator %= mod;
        denominator *= i;
        denominator %= mod;
    }
    
    return numerator * mod_pow( denominator, mod-2 ) % mod;

}

int main(){

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


    // Mが与えられた時にその約数となりうる素数の最大値以外の素数を求める
    vector<int> prime = {2};

    for( int i = 3; i*i <= M; i += 2 ){
        bool devide = true;
        for( int j = 3; j*j <= i; j += 2 ){
            if( i % j == 0 ){
                devide = false;
                break;
            }
        }
        if( devide ) prime.push_back( i );
    }

    // Mの約数のそれぞれの個数を数える
    vector<int> count( prime.size() );

    for( int i = 0; i < prime.size(); i++ ){
        while( M % prime[i] == 0 ){
            M /= prime[i];
            count[i]++;
        }
        if( M == 1 ) break;
        else if( i == prime.size()-1 ){
            prime.push_back( M );
            count.push_back( 1 );
            break;
        }
    }

    // 計算
    long sol = 1;

    for( int i = 0; i < prime.size(); i++ ){
        //cout << prime[i] << " " << count[i] << endl;
        sol *= combination( N-1+count[i], count[i] ) % mod;
        sol %= mod;
    }

    cout << sol << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[5],i,j,k,maxx,mini,res;
    for(i=0;i<3;i++)
    {
        cin>>a[i];
    }
    sort(a,a+3);
    res=(a[2]*10)+a[1]+a[0];
    cout<<res<<'\n';
    return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int N,K;
    cin>>N>>K;
    int ok[101]={0};
    int ans=N;
    for(int i=0;i<K;i++){
        int d;
        cin>>d;
        for(int j=0;j<d;j++){
            int A;
            cin>>A;
            if(ok[A]==0){
                ok[A]=1;
                ans--;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3164
#include <iostream>
#include <cstring>
using namespace std;
long long a,b,c,k,sum;
int main(void)
{
    cin>>a>>b>>c>>k;
    if(k>=a)
    {
        sum+=a;
        k-=a;
    }
    else
    {
        cout<<k;
        return 0;
    }
    if(k>=b)
    {
        k-=b;
    }
    else
    {
        cout<<sum;
        return 0;
    }
    sum-=k;
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,k;
Vi a;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	std::cout<<std::fixed<<std::setprecision(30);
	cin>>n>>k;
	a.resize(n);
	map<int,vector<int>> ma;
	rep(i,n){
		cin>>a[i];
		ma[a[i]].pb(i);
	}
	vector<PLL> phi;
	phi.pb(mp(1,0));
	while(1){
		ll id = phi[phi.size()-1].second;
		ll sum = phi[phi.size()-1].first;
		ll ind = upper_bound(all(ma[a[id]]),id)-ma[a[id]].begin();
		if(ind==ma[a[id]].size()){
			ind = ma[a[id]][0];
			sum += n-id+1;
			sum += ind;
			id = ind+1;
			id %= n;
		}else{
			ind = ma[a[id]][ind];
			sum += ind-id+1;
			id = ind+1;
			id %= n;
		}
		phi.pb(mp(sum,id));
		if(id==0)break;
	}
	ll lop = phi[phi.size()-1].first-1;
	ll ckn = (n%lop)*(k%lop);
	ckn %= lop;
	if(ckn==0){
		print("");
		return 0;
	}
	ll id = upper_bound(all(phi),mp(ckn,INF))-phi.begin();
	id--;
	ckn -= phi[id].first;
	id = phi[id].second;
	rep(i,n){
		a.pb(a[i]);
	}
	vi ans;
	ans.pb(a[id]);
	ll idd = upper_bound(all(ma[a[id]]),id)-ma[a[id]].begin();
	if(idd==ma[a[id]].size()){
		idd = ma[a[id]][0];
		idd += n;
	}
	repi(i,id+1,id+1+ckn){
		ll idn = upper_bound(all(ma[a[i]]),i%n)-ma[a[i]].begin();
		if(idn==ma[a[i]].size()){
			idn = ma[a[i]][0] + n;
		}else{
			idn = ma[a[i]][idn];
		}
		if(id+1+ckn <= idn)ans.pb(a[i]);
		else i = idn;
	}
	rep(i,ans.size()){
		princ(ans[i]);
	}
	print("");
	return 0;
}

Measured memory_bytes: 31440
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<list>

using namespace std;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    int a, b;
    in(a); in(b);
    out(a*(a-1)/2+b*(b-1)/2);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


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

ll gcd(ll x, ll y)
{
  if(x<y)
  {
    swap(x,y);
  }
  while(y>0)
  {
    ll r=x%y;
    x=y;
    y=r;
  }
  return x;
}

int main(){
  ll a,b;
  cin>>a>>b;
  ll d=gcd(a,b);
  ll ans=a*b/d;
  cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(long long i=(a);((a)<(b)?i<=(b):i>=(b));((a)<(b)?++i:--i))
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

int main(){
	llong x,k,d;
	cin>>x>>k>>d;
	if(x<0) x=-x;
	
	llong tmp=x%d;
	llong tmpp=abs(tmp-d);
	llong n=x/d;
	
	if(k<=n) cout<<x-k*d<<endl;
	else{
		//debug(-1);
		k-=n;
		if(k&1) cout<<tmpp<<endl;
		else cout<<tmp<<endl;
	}
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    string S;
    ll w;
    cin >> S >> w;
    for (ll i = 0; i < S.size(); i += w) {
        cout << S[i];
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  vector<P> box(0);
  int counter = 1;
  for(int i = 0; i < N-1; i++){
    if(S.at(i) != S.at(i+1)){
      box.push_back(P(S.at(i), counter));
      counter = 1;
    }
    else{
      counter++;
    }
  }
  box.push_back(P(S.at(N-1), counter));

  ll ans = 0;
  ll now = 0;
  int right = 0;
  int zero = 0;
  for(int left = 0; left < box.size(); left++){
    if(left > 0){
      if(box.at(left-1).first == '0') zero--;
      now -= box.at(left-1).second;
    }

    while(right < box.size()){
      if(box.at(right).first == '0' && zero >= K) break;
      if(box.at(right).first == '0') zero++;
      now += box.at(right).second;
      right++;
    }
    chmax(ans, now);
  }
  cout << ans << endl;
}

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

namespace AtCoder.Abc
{
    class B_159_TheNumberOfEvenPairs
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var nArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long N = nArray[0];
            long K = nArray[1];

            long evenC = 1;

            for (long i = N; i > N-2; i--)
            {
                evenC *= i;
            }

            long oddC = 1;
            for (long i = K; i > K-2; i--)
            {
                oddC *= i;
            }

            long result = evenC / 2 + oddC / 2;

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28204
n = int(input())
h = list(map(int,input().split()))


cnt=1 # h[0]
for i in range(1,n):
    flag=0
    for j in range(n):
        if i>j:
            # print(i,j,h[i],h[j])
            if h[i]>=h[j]:
                pass
            else:
                flag=1
    if flag == 0:
        cnt+=1

print(cnt)

Measured memory_bytes: 38384
import sys
import math
import heapq
mod=10**9+7
inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict, OrderedDict
#すべてのkeyが用意されてる defaultdict(int)で初期化
#順序を保ったdict
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########
n=int(input())
A=[]
# ans=0
for i in range(n):
    a=list(map(int,input().split()))
    A.append(a)
    # ans+=sum(a)

#ans//=2
miti=[[] for i in range(n)]
for i in range(n):
    miti[i]=A[i][:]
    
for k in range(n):
    for j in range(k):
        for i in range(j):
            q=A[i][j]
            w=A[j][k]
            e=A[k][i]
            #print(i,j,k,"\t",q,w,e)
            # q,w,e=sorted([[q,i,j],[w,j,k],[e,k,i]])
            # if max(q,w,e)==inf: continue
            if q+w==e and q!=inf and w!=inf: miti[k][i]=inf;miti[i][k]=inf;continue
            if q+w<A[k][i] and q!=inf and w!=inf: print(-1);exit()
            if w+e==q and e!=inf and w!=inf: miti[i][j]=inf;miti[j][i]=inf;continue
            if w+e<A[i][j]  and e!=inf and w!=inf : print(-1);exit()
            if e+q==A[j][k] and q!=inf and e!=inf: miti[j][k]=inf;miti[k][j]=inf;continue
            if e+q<A[j][k] and q!=inf and e!=inf: print(-1);exit()
            
            
                
            
ans=0
for i in range(n):
    for j in range(n):
        if miti[i][j]!=inf:
            ans+=miti[i][j]

print(ans//2)


Measured memory_bytes: 80744
#include<bits/stdc++.h>
using namespace std;
void print(string s1,string s2)
{
    int n=s1.length();
    int m=s2.length();
    int dp[n+1][m+1];
    char dpc[n+1][m+1];
    for(int i=0;i<=n;i++)
    {
        dp[i][0]=0;
        dpc[i][0]='\0';
    }
    for(int i=0;i<=m;i++)
    {
        dp[0][i]=0;
        dpc[0][i]='\0';
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s1[i-1]==s2[j-1])
            {
                dp[i][j]=1+dp[i-1][j-1];
                dpc[i][j]=s1[i-1];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                dpc[i][j]='\0';
            }
        }
    }
    stack<char> s;
    if(dp[n][m]!=0)
    {
        int i=n,j=m;
        while(i>=0&&j>=0)
        {
          if(dpc[i][j]!='\0')
          {
            s.push(dpc[i][j]);
            i--;
            j--;
          }
         else{
             if(dp[i][j-1]>=dp[i-1][j])
             {
                j--;
             }
             else
                i--;
            }
        }
        while(!s.empty())
        {
            cout<<s.top();
            s.pop();
        }
    }
}
int main()
{
  string s1,s2;
  cin>>s1>>s2;
  print(s1,s2);
  return 0;
}

Measured memory_bytes: 44288
#include<bits/stdc++.h>
#define STIZE(x) fprintf(stderr, "STIZE%d\n", x);
#define PRINT(x) fprintf(stderr, "%s = %d\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mid (l+r)/2
#define endl '\n'
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF 1000000000000000LL
#define INF 1000000000
#define EPS 1e-9
using namespace std;
#define MAXN 100010
int N, M, degin[MAXN], idx[MAXN];
vector<int> adj[MAXN], topo, tp, ul[MAXN];
bool cmp(int a, int b) {
    return idx[a] > idx[b];
}
int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cerr.tie(0);
    cin >> N >> M;
    for(int i = 0; i < N+M-1; i++) {
        int A, B; cin >> A >> B;
        adj[A].pb(B);
        ul[B].pb(A);
        degin[B]++;
    }
    for(int i = 1; i <= N; i++) {
        if(degin[i] == 0) tp.pb(i);
    }
    while(!tp.empty()) {
        int node = tp.back(); tp.pop_back();
        topo.pb(node);
        for(auto x : adj[node]) {
            degin[x]--;
            if(degin[x] == 0) tp.pb(x);
        }
    }
    for(int i = 0; i < N; i++) {
        idx[topo[i]] = i;
    }
    for(int i = 1; i <= N; i++) {
        if(!ul[i].empty()) {
            sort(all(ul[i]), cmp);
            cout << ul[i][0] << endl;
        } else {
            cout << 0 << endl;
        }
    }
}


Measured memory_bytes: 13052
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

//#define int long long
//#define endl "\n"
#define fi first
#define se second
#define fr front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}




int main() {
	int n, t = 0;
	cin >> n;
	vector<int> vec(n);
	vecin(vec);
	for (int i = 0; i < n - 2; i++) {
		if ((vec[i] < vec[i + 1] && vec[i + 1] < vec[i + 2]) || (vec[i] > vec[i + 1] && vec[i + 1] > vec[i + 2])) {
			t++;
		}
	}
	cout << t << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int x,y;
    while(cin>>x){
        cin>>y;
        if(x==0&&y==0)break;
 
        if(x < y ){
            cout << x << " " << y << endl;
        }else{
            cout << y << " " << x << endl;
        }
    }
return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main (){
  long long i,j,k,n,mx=0,mn=100000000;
  cin>>k>>n;
  vector<long long> a(n);
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  for(i=0;i<n-1;i++){
    mx=max(mx,llabs(a[i]-a[i+1]));
  }
  mx=max(mx,k-a[n-1]+a[0]);
  cout<<k-mx<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;

const int size=102;
const int wMax=10e5+2;
int sizeC;
int maxiW;
int arrW[size];
int arrV[size];
ll state[size][wMax];

ll maxi(int n,int w){

  if(n<0)
    return 0;

  if(state[n][w])
    return state[n][w];

  if(w-arrW[n]<0)
    return state[n][w]=1ll*maxi(n-1,w);
  else
    return state[n][w]=max(maxi(n-1,w-arrW[n])+1ll*arrV[n],maxi(n-1,w));
}

int main(){

  cin>>sizeC;
  cin>>maxiW;

  for(int i=0;i<sizeC;i++)
    cin>>arrW[i]>>arrV[i];

  cout<<maxi(sizeC-1,maxiW)<<endl;

  return 0;
}


Measured memory_bytes: 281600
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
#define PI 3.1415926535
using namespace std;
map<string, int> nya;
int main() {
	nya["Male"] = 0;
	nya["Female"] = 1;
	int n;
	cin >> n;
	cout << 0 << endl;
	string s;
	cin >> s;
	if (s == "Vacant") return 0;
	int now = nya[s];
	int bot = 0, top = n;
	while (top - bot > 1) {
		int mid = (top + bot) / 2;
		cout << mid << endl;
		string c;
		cin >> c;
		if (c == "Vacant") return 0;
		int geko = nya[c];
		geko += (mid - bot) % 2;
		geko %= 2;
		if (geko == now) {
			//ok
			bot = mid;
			now = nya[c];
		}
		else {
			//something is wrong
			top = mid;
		}
	}
	cout << bot << endl;
	string te;
	cin >> te;
	if (te != "Vacant") {
		cout << top << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 852
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 H,W,h,w;
	cin >> H >> W;
	cin >> h >> w;

	i64 white = H * W;
	i64 black = h * W + w * H - h * w;

	cout << white - black << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			long n = -1;
			List<long> list = new List<long>();
			while (n != 0) {
				n = long.Parse(Console.ReadLine());
				if (n == 0) {
					break;
				}
				list.Add(n);
			}

			int count = 1;
			foreach (var item in list) {
				Console.WriteLine($"Case {count}: {item}");
				++count;
			}

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 22116