akhauriyash/Code-Regression huggingface dataset:
use std::cmp;
use std::collections::VecDeque;

fn main() {
    let (n, m) = {
        let v = read_values::<usize>();
        (v[0], v[1])
    };

    let mut map: Vec<Vec<(usize, i64)>> = (0..n).map(|_| Vec::new()).collect::<Vec<_>>();
    for _ in 0..m {
        let v: Vec<usize> = read_values::<usize>();
        let l = v[0] - 1;
        let r: usize = v[1] - 1;
        let d = v[2] as i64;
        map[l].push((r, d));
        map[r].push((l, -d));
    }


    let mut x = vec![0; n];
    let mut checked = vec![false; n];
    let mut queue = VecDeque::new();

    for v in 0..n {
        if !checked[v] {
            queue.push_back(v);
            checked[v] = true;
        }

        while !queue.is_empty() {
            let i = queue.pop_front().unwrap();
            for t in &map[i] {
                let (to, d) = *t;
                if checked[to] {
                    if x[to] != x[i] + d {
                        println!("No");
                        return;
                    }
                } else {
                    checked[to] = true;
                    x[to] = x[i] + d;
                    queue.push_back(to);
                }
            }
        }
    }


    let mut min = 0;
    let mut max = 0;
    for d in &x {
        min = cmp::min(min, *d);
        max = cmp::max(max, *d);
    }
    if max - min > 1000000000 {
        println!("No");
    } else {
        println!("Yes");
    }
}

fn read_line() -> String {
    let stdin = std::io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}

fn read_values<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    read_line()
        .split(' ')
        .map(|a| a.trim().parse().unwrap())
        .collect()
}


Measured memory_bytes: 18684
#include "iostream"

using namespace std;

int F[46];

int fib( int n ) {

	if (F[n] != 0) return F[n];

	if (n == 0 || n == 1) F[n] = 1;

	else F[n] = fib(n - 1) + fib(n - 2);

	return F[n];
}

int main() {


	int n;

	cin >> n;

	cout << fib(n) << endl;

	return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,x;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	if(a<0){
		x=(a*-1*c)+d+(b*e);
	}
	if(a>0){
		x=(b-a)*e;
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 2752
#include <stdio.h>
#include <stdbool.h>

int main() {
    char s[4];
    int i = 0;
    scanf("%s", &s);
    bool isgood = true;
    if (s[0] == s[1]) isgood = false;
    if (s[1] == s[2]) isgood = false;
    if (s[2] == s[3]) isgood = false;

    if (isgood) {
        puts("Good");
    }else{
        puts("Bad");
    }
        return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;

int main() {
    ll N;
    cin>>N;
    cout<<(N-1)*N/2<<endl;
}



Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import sys


def std_in():
    return sys.stdin.readline().strip()


def main():
    k = int(std_in())
    c = std_in()
    counter = 0
    while 1:
        l = c.find("W")
        r = c.rfind("R")
        if l == -1 or r == -1:
            break
        elif l < r:
            c = c[:l] + c[r] + c[l+1: r] + c[l] + c[r+1:]
            counter += 1
        else:
            break
    print(counter)


if __name__ == "__main__":
    main()


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

using namespace std;
const int maxn = 100005;

int a[maxn];
double b[maxn];

int main() {
	int n, maxa = -1;

	cin >> n;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
	}

	sort(a + 1, a + 1 + n);
	double mid = 1.0 * a[n] / 2, m1 = 1000000009.0;

	int ans;

	for (int i = 1; i < n; ++i) {
		if (fabs(mid - (1.0 * a[n] - 1.0 * a[i])) < m1) {
			ans = a[i];
			m1 = fabs(mid - (1.0 * a[n] - 1.0 * a[i]));
		}
	}
    printf("%d %d\n",a[n],ans);

}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int w,h,c1,c2,b,d;
char a[51][51];
int dfs(int i,int j){
    if(i==h||j==w||i<0||j<0||a[i][j]=='#')return 0;
    if(a[i][j]=='W'){d++;return 0;}
    else if(a[i][j]=='B'){b++;return 0;}
    int s=1;
    a[i][j]='#';
    s+=dfs(i+1,j);
    s+=dfs(i-1,j);
    s+=dfs(i,j+1);
    s+=dfs(i,j-1);
    return s;
}
int main(){
    int i,j,ans;
    while(cin>>w>>h,w!=0&&h!=0){
        c1=c2=0;
    for(i=0;i<h;i++)cin>>a[i];
    for(i=0;i<h;i++)for(j=0;j<w;j++)if(a[i][j]=='.'){
        d=0;b=0;
        ans=dfs(i,j);
        if(b>0&&d>0)continue;
        else if(b>d)c1+=ans;
        else if(b<d)c2+=ans;
    }
        cout<<c1<<" "<<c2<<endl;
}}

Measured memory_bytes: 1356
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;
template<class T>
void show(vector<T>v){
    for (int i = 0; i < v.size(); i++)
    {
        cerr<<v[i]<<" ";
    }
    cerr<<"\n";
}

int main(){
    int n;
    string s1,s2;
    cin>>n>>s1>>s2;
    ll mod=1e9+7;
    if(n==1){
        cout<<3<<endl;
        return 0;
    }
    int cnt=0;
    ll ans=1;
    bool flag=false;
    if(s1[0]==s1[1]){
        ans=6;
    for (int i = 1; i < n; i++)
    {
        if(s1[i]==s1[i+1] && i<n-1){
            if(s1[i-1]!=s2[i-1]){
                cnt++;
                ans*=3;
                ans%=mod;

            }
            else {
                ans*=2;
                ans%=mod;
            }            
        }
        if(s1[i]==s2[i]){
            if(s1[i-1]==s2[i-1]){
                ans*=2;
                ans%=mod;
            }    
        }
        

    }
    }
    else{
        ans=3;
     for (int i = 1; i < n; i++)
    {
        if(s1[i]==s1[i+1] && i<n-1){
            if(s1[i-1]!=s2[i-1]){
                cnt++;
                ans*=3;
                ans%=mod;

            }
            else {
                ans*=2;
                ans%=mod;
            }            
        }
        if(s1[i]==s2[i]){
            if(s1[i-1]==s2[i-1]){
                ans*=2;
                ans%=mod;
            }    
        }
       
    }
    }
    cout<<ans<<endl;
    




    

    
    return 0;
}

Measured memory_bytes: 256
K=int(input())
A=list(map(int,input().split()))
mb=Mb=2
t=1
for i in A[::-1]:
    if Mb//i*i>=mb:
        Ma=(Mb//i+1)*i-1
    else:
        t=0
        break
    if mb%i==0:
        ma=mb
    elif (mb//i+1)*i<=Mb:
        ma=(mb//i+1)*i
    else:
        t=0
        break
    mb=ma
    Mb=Ma
if t:
    print(ma,Ma)
else:
    print(-1)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B,C;

  cin >> A >> B;

  C = A / 500;
  
  if(A - 500 * C <= B ){
      cout << "Yes" << endl;
  }
  else{
      cout << "No" << endl;
  }


}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s= sc.next();
		int a[] = new int[4];
		for (int i=0;i<4;i++) {
			a[i] = s.charAt(i)-'0';
		}
		if (a[0]+a[1]+a[2]+a[3]==7) {
			System.out.println(a[0]+"+"+a[1]+"+"+a[2]+"+"+a[3]+"=7");
			return;
		}
		if (a[0]+a[1]+a[2]-a[3]==7) {
			System.out.println(a[0]+"+"+a[1]+"+"+a[2]+"-"+a[3]+"=7");
			return;
		}
		if (a[0]+a[1]-a[2]+a[3]==7) {
			System.out.println(a[0]+"+"+a[1]+"-"+a[2]+"+"+a[3]+"=7");
			return;
		}
		if (a[0]+a[1]-a[2]-a[3]==7) {
			System.out.println(a[0]+"+"+a[1]+"-"+a[2]+"-"+a[3]+"=7");
			return;
		}
		if (a[0]-a[1]+a[2]+a[3]==7) {
			System.out.println(a[0]+"-"+a[1]+"+"+a[2]+"+"+a[3]+"=7");
			return;
		}
		if (a[0]-a[1]+a[2]-a[3]==7) {
			System.out.println(a[0]+"-"+a[1]+"+"+a[2]+"-"+a[3]+"=7");
			return;
		}
		if (a[0]-a[1]-a[2]+a[3]==7) {
			System.out.println(a[0]+"-"+a[1]+"-"+a[2]+"+"+a[3]+"=7");
			return;
		}
		if (a[0]-a[1]-a[2]-a[3]==7) {
			System.out.println(a[0]+"-"+a[1]+"-"+a[2]+"-"+a[3]+"=7");
			return;
		}
	}
}

Measured memory_bytes: 21844
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n; cin >> n;
	map<int, bool> mp;
	while (n--)
	{
		int a; cin >> a;
		if (mp[a])
		{
			cout << "NO" << endl;
			return 0;
		}
		mp[a] = true;
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 9600
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  while (true) {
    int n, m, t, p;
    cin >> n >> m >> t >> p;
    if (n == 0) break;
    vector<int> x, y;
    for (int i = 0; i < m; ++i) {
      for (int j = 0; j < n; ++j) {
        x.emplace_back(j);
        y.emplace_back(i);
      }
    }
    for (int i = 0; i < t; ++i) {
      int d, c;
      cin >> d >> c;
      for (int& k : (d == 1 ? x : y)) k = abs(k - c + 0.5) - 0.5;
    }
    for (int i = 0; i < p; ++i) {
      int xi, yi, c = 0;
      cin >> xi >> yi;
      for (int k = 0; k < n * m; ++k) {
        if (x[k] == xi && y[k] == yi) ++c;
      }
      cout << c << endl;
    }
  }
}



Measured memory_bytes: 3068
#include "bits/stdc++.h"
using namespace std;

int main() {
    int N;
    cin >> N;

    vector<string> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (vec.at(i) == "Y") {
            cnt++;
        }
    }

    if (cnt > 0) {
        cout << "Four" << endl;
    }
    else {
        cout << "Three" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

j = 0
r = 0
for i in range(len(B)):
  cnt = i
  j = i
  while j <= cnt+1:

    if  j == len(A):
      break

    if B[i] >= A[j]:
      B[i] -= A[j]
      r += A[j]
      A[j] = 0
      j+=1
    else:
      A[j] -= B[i]
      r +=  B[i]
      break
print(r)

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=505;
int n;
int a[maxn][maxn];

void solve(int l,int r,int d){
	if(l==r)return;
	int mid=l+r>>1;
	for(int i=l;i<=mid;i++)for(int j=mid+1;j<=r;j++)a[i][j]=d;
	solve(l,mid,d+1);
	solve(mid+1,r,d+1);
} 

int main(){
	scanf("%d",&n);
	solve(1,n,1);
	REP(i,n-1)for(int j=i+1;j<=n;j++)printf("%d%c",a[i][j],j==n?'\n':' ');
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

const int MOD = 1000000007;

class UnionFind{
public:
  //親の番号を格納する変数。数値がマイナスの場合は親であり、その絶対値のサイズのグループを持っている
  vector<int> Parent;
  
  //コンストラクタ。-1で初期化する。
  UnionFind(int N){
    Parent = vector<int>(N,-1);
  }
  
  //Aが何処のグループに属しているか返す
  int root(int A){
    if(Parent[A] < 0) return A; //0以下の時は自分が親。自分のグループなので自分を返す
    return Parent[A] = root(Parent[A]); //根でなかった場合は再帰的に関数を呼ぶ。ついでにParent[A]を更新して次の時高速化する。
  }
  
  //自分の親の頂点数を返す。マイナスでグループのサイズを持っているので反転して返す。
  int size(int A){
    return -Parent[root(A)];
  }
  
  //AとBを連結する関数
  bool connect(int A, int B){
    A = root(A); //Aの親を持ってくる
    B = root(B); //Bの親を持ってくる
    if (A==B){ //親が同じだったらくっつけない
      return false;
    }
    
    //Aが必ず大きい数にする
    if (size(A) < size(B)) swap(A,B);
    
    //AにBのグループをくっつける。
    Parent[A] += Parent[B];
    //Bの親をAにする。
    Parent[B] = A;
    
    return true;
  }
};

int main(){
  ll n,m; cin >> n >> m;
  UnionFind uf(n);
  vector<ll> v(m),A(m),B(m);
  ll cnt = n * (n-1) / 2;
  
  rep(i,m){
    int a,b; cin >> a >> b;
    a--,b--;
    A[i] = a; B[i] = b;
  }
  
  reverse(A.begin(),A.end());
  reverse(B.begin(),B.end());
  
  rep(i,m){
    int a = A[i], b = B[i];
    v[i] = cnt;
    if(uf.root(a) != uf.root(b)){
      ll tmp = uf.size(a) * uf.size(b);
      cnt -= tmp;
    }
    uf.connect(a,b);
  }
  
  reverse(v.begin(),v.end());
  for(int i = 0; i < m;i++){
    cout << v[i] << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 4096
using System;

namespace noteCsharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] A = new int[n];
            string[] inputstr = Console.ReadLine().Split(char.Parse(" "));
            for(int cycle = 0; cycle < n; cycle++)
            {
                A[cycle] = int.Parse(inputstr[cycle]);
            }
            int min = A[0];
            int Max = A[0];
            long sum = A[0];
            for(int cycle = 1; cycle < n; cycle++)
            {
                sum += A[cycle];
                min = Math.Min(min, A[cycle]);
                Max = Math.Max(Max, A[cycle]);
            }
            Console.WriteLine(min + " " + Max + " " + sum);
        }
    }
}



Measured memory_bytes: 17976
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
#include<ctime>
#include<cassert>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<bitset>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
map<ll,int> vis;
int main()
{	int n,x;ll sum=0,ans=0;vis[0]=1; cin>>n;
	for(rint i=1;i<=n;i++) scanf("%d",&x),sum+=x,ans+=vis[sum],vis[sum]++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 12800
package main

import (
	"fmt"
)

type P struct {
	t int
	x int
	y int
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func main() {
	var n int
	fmt.Scan(&n)
	pp := P{0, 0, 0}
	for i := 0; i < n; i++ {
		cp := P{}
		fmt.Scan(&cp.t, &cp.x, &cp.y)
		dt := abs(pp.t - cp.t)
		dx := abs(pp.x - cp.x)
		dy := abs(pp.y - cp.y)
		if dt < dx+dy {
			fmt.Println("No")
			return
		}
		if dt%2 != (dx+dy)%2 {
			fmt.Println("No")
			return
		}
		pp = cp
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 5504
from itertools import permutations

n = int(input())
pi = list(map(int, input().split()))
qi = list(map(int, input().split()))

for i, p in enumerate(permutations(list(range(1,n+1)))):
    if "".join(map(str, pi)) == "".join(map(str, p)):
        a = i+1
    if "".join(map(str, qi)) == "".join(map(str, p)):
        b = i+1
print(abs(a-b))


Measured memory_bytes: 3060
/*input
45 28 53
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma GCC optimize "-O3"
//order_of_key #of elements less than x
// find_by_order kth element 
#define ll long long 
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb emplace_back
#define REP(i,n) for(int i=0;i<n;i++)
#define sz(_a) (int)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const int maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=acos(-1);
const ld eps=1e-9;
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
vector<int> ans[maxn];
int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll arr[3];
	cin>>arr[0]>>arr[1]>>arr[2];
	sort(arr,arr+3);
	cout<<(arr[0]*arr[1])/2;
}

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

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		if(x < y) {
			int temp1 = x;
			x = y;
			y = temp1;
		}
		int temp;
		temp = -1;
		while(temp != 0) {
		    temp = x % y;
			x = y;
			y = temp;
		}
		System.out.println(x);
	}

}



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

using namespace std;

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

  string s,t;
  cin >> s >> t;
  s += s;
  auto ret = s.find(t);
  cout << (ret != std::string::npos ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		String str = sc.next();
		
		if(str.compareTo("2019/04/30")<=0)System.out.println("Heisei");
		else System.out.println("TBD");
	}

}

Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<int> L(N);
    int sum = 0;
    for(int i = 0; i < N; i++){
        cin >> L[i];
        sum += L[i];
    }
    int M = *max_element(L.begin(), L.end());
    if(sum - M > M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

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

Node *root,*NIL;

Node *treeMinimum(Node *x) {
  while (x->left!=NIL) {
    x=x->left;
  }
  return x;
}
Node *find(Node *u,int k) {
  while (u!=NIL and k!=u->key) {
    if (k<u->key) {
      u=u->left;
    }
    else {
      u=u->right;
    }
  }
  return u;
}
Node *treeSuccessor(Node *x) {
  if (x->right!=NIL) {
    return treeMinimum(x->right);
  }
  Node *y=x->parent;
  while (y!=NIL and x==y->right) {
    x=y;
    y=y->parent;
  }
  return y;
}
void treeDelete(Node *z) {
  Node *y;
  Node *x;
  if (z->left==NIL or z->right==NIL) {
    y=z;
  }
  else {
    y=treeSuccessor(z);
  }
  if (y->left!=NIL) {
    x=y->left;
  }
  else {
    x=y->right;
  }
  if (x!=NIL) {
    x->parent=y->parent;
  }
  if (y->parent==NIL) {
    root=x;
  }
  else {
    if (y==y->parent->left) {
      y->parent->left=x;
    }
    else {
      y->parent->right=x;
    }
  }
  if (y!=z) {
    z->key=y->key;
  }
  free(y);
}
void insert(int k) {
  Node *y=NIL;
  Node *x=root;
  Node *z;
  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while (x!=NIL) {
    y=x;
    if (z->key<x->key) {
      x=x->left;
    }
    else {
      x=x->right;
    }
  }
  z->parent=y;
  if (y==NIL) {
    root=z;
  }
  else {
    if (z->key<y->key) {
      y->left=z;
    }
    else {
      y->right=z;
    }
  }
}
void inorder(Node *u) {
  if (u==NIL) {
    return ;
  }
  inorder(u->left);
  cout<<" "<<u->key<<flush;
  inorder(u->right);
}
void preorder(Node *u) {
  if (u==NIL) {
    return ;
  }
  cout<<" "<<u->key<<flush;
  preorder(u->left);
  preorder(u->right);
}
int main() {
  int n;
  cin>>n;
  for (int i=0; i<n; i++) {
    string com;
    cin>>com;
    if (com=="insert") {
      int x;
      cin>>x;
      insert(x);
    }
    else if (com=="print") {
      inorder(root);
      cout<<endl;
      preorder(root);
      cout<<endl;
    }
    else if (com=="find") {
      int x;
      cin>>x;
      Node *t=find(root,x);
      if (t!=NIL) {
        cout<<"yes"<<endl;
      }
      else {
        cout<<"no"<<endl;
      }
    }
    else {
      int x;
      cin>>x;
      treeDelete(find(root,x));
    }
  }
  return 0;
}


Measured memory_bytes: 21780
#include <stdio.h>

int main() {
    char s[5]="";
    int a=0;
    scanf("%s",&s);
    if(s[0]=='1')
    {
        a++;
    }
    if(s[1]=='1')
    {
        a++;
    }
    if(s[2]=='1')
    {
        a++;
    }
    printf("%d\n",a);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
          if(n/i==i)
            c++;
          else
            c+=2;
        }

    }

    
    return  c;
}
int func(int n)
{
    return (n*(n+1))/2;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   
   string str;
   cin>>str;
   if(str.length()%2==0)
   {
      str=str.substr(0,str.length()-2);
      while(str.length())
      {
        string s,s1;
        s=str.substr(0,str.length()/2);
        s1=str.substr(str.length()/2,str.length()/2);
        if(s==s1)
        {
            cout<<str.length();
            return 0;
        }
        str=str.substr(0,str.length()-2);
      }
   }
   else
   {
      str=str.substr(0,str.length()-1);
      while(str.length())
      {
        string s,s1;
        s=str.substr(0,str.length()/2);
        s1=str.substr(str.length()/2,str.length()/2);
        if(s==s1)
        {
            cout<<str.length();
            return 0;
        }
        str=str.substr(0,str.length()-2);
      }
   }


 return 0;
}








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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			long x = cin.Long();
			long y = cin.Long();
			if (Math.Abs(x - y) <= 1) {
				Console.WriteLine("Brown");
			} else {
				Console.WriteLine("Alice");
			}
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 13140
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int[] ABC = new int[3];
		for(int i = 0; i < 3; i++) ABC[i] = sc.nextInt();
		Arrays.sort(ABC);
		
		
		System.out.println(ABC[2] * 10 + ABC[1] + ABC[0]);
	}
}

Measured memory_bytes: 21844
def resolve():
    # 後手必勝になる移動個数の最小を求める
    # 移動して A1xorA2 == A3~AN xor になるか
    # 移動個数を1つずつ試すとTLE なのでA1+A2を2つに分けて条件を満たす方法を探す
    N = int(input())
    A = list(map(int, input().split()))

    # A1 + A2
    S = A[0] + A[1]

    # 3～N番目のxor
    xor = 0
    for a in A[2:]:
        xor ^= a

    # S == A1xorA2 + 2(A1&A2) -> 2(A1&A2) == S - A3~AN xor
    # 2で割れなければ不可能
    S -= xor
    if S%2 == 1:
        return print(-1)

    S //= 2
    # A1&A2 と A1xorA2が同じ箇所のビットが立っていたら不可能
    if (S&xor) != 0 or S > A[0]:
        return print(-1)

    # A1 に残す個数は最低A1&A2であり、A1xorA2を上の桁から貪欲に、
    # i桁目が1かつ、減らす個数に加えてもAi以上にならないように加えていく
    b = S
    for i in range(41, -1, -1):
        if xor>>i & 1 == 1:
            if b + (1<<i) <= A[0]:
                b += 1<<i

    if b == 0:
        print(-1)
    else:
        print(A[0] - b)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9236
# usr/bin/python
# coding: utf-8
################################################################################
#Write a program which prints multiplication tables in the following format:
#
#1x1=1
#1x2=2
#.
#.
#9x8=72
#9x9=81
#
################################################################################

if __name__ == "__main__":
    for i in range(1, 10):
        for j in range(1, 10):
            print("{0}x{1}={2}".format(i,j,i*j))
    exit(0)

Measured memory_bytes: 5536
/*input
7
1 2 3 4 5 6
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    vector<int> freq(n);
    for(int i = 0; i < n - 1; i++)
    {
    	int a; cin >> a;
    	a--;
    	freq[a]++;
    }
    for(int i = 0; i < n; i++) cout << freq[i] << endl;

    return 0;
}

Measured memory_bytes: 3992
import java.util.Scanner;

public class Main {

	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();

		System.out.println(Math.min(k, n)*x + Math.max(0, n - k)*y);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <cmath>

using namespace std;

#define FAST_IO() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define USE_DB() cout << fixed; cout.precision(10);

#define pqu priority_queue
#define que queue
#define stk stack
#define vec vector

typedef long long ll;
typedef double db;
typedef string str;

#define in(x) cin >> x
#define ini(x) int x; cin >> x
#define inl(x) ll x; cin >> x
#define ins(x) str x; cin >> x

#define out(x) cout << x
#define outb(x) cout << x << ' '
#define outn(x) cout << x << '\n'

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) x.size()
#define all(x) x.begin(), x.end()

#define forn(i, s, e) for (int i = s; i < e; i++)
#define forr(i, s, e) for (int i = s; i >= e; i--)
#define ford(i, s, e, d) for (int i = s; i < e; i += d)
#define fors(i, n) for (int i = 1; i*i <= n; i++)

int main() {
	FAST_IO();

	ini(n);
	int ans = 0;
	forn(i, 1, n+1) {
        if (i % 2 == 0) continue;
        int cnt = 0;
        forn(j, 1, i+1) if (i % j == 0) cnt++;
        if (cnt == 8) ans++;
        //cout << i << ' ' << cnt << '\n';
    }
    outn(ans);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;

#include <math.h>
#define PI 3.14159265358979323846264338327950L


int main() {
    int N;
    cin >> N;
    vector<vector<pair<int, int>>> persons(N);
    for (int i = 0; i < N; i++) {
        int m;
        cin >> m;
        while (m--) {
            int x, y;
            cin >> x >> y;
            x--;
            persons[i].push_back({ x, y });
        }
    }
    int mx = 0;
    for (int b = 0; b < (1 << N); b++) {
        vector<bool> honest(N);
        bool ok = true;
        int cnt = 0;
        for (int i = 0; i < N; i++) {
            if (b & (1 << i)) {
                honest[i] = true;
                cnt++;
            }
        }
        for (int p = 0; p < N; p++) {
            for (int s = 0; s < (int)persons[p].size(); s++) {
                if (honest[p] && honest[persons[p][s].first] != persons[p][s].second) {
                    ok = false;
                    break;
                }
            }
        }
        if (ok)
            mx = max(mx, cnt);
    }
    cout << mx;
    return 0;
}

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

using namespace std;

void solve() {
    int N;
    cin >> N;
    string s;
    map<string, long long> ana;
    for (int i = 0; i < N; i++)
    {
        cin >> s;
        sort(s.begin(), s.end());
        ana[s] += 1;
    }
    
    long long ans = 0;
    for (const auto& [key, value] : ana) {
        ans += value * (value - 1) / 2;
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 11384
a,b,c,d = map(int, input().split())
count = 0
while a > 0 and c > 0:
    if count % 2 == 0:
        c -= b
        count += 1
    else:
        a -= d
        count += 1
if count % 2 == 1:
    print('Yes')
else:
    print('No')

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

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

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}


int main(){
    migmig
    string s;	
  	cin  >> s;
  if(s[2] == s[3] and s[4] == s[5]){
    cout << "Yes";
  }
    else{
    cout << "No";
    }




    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


Measured memory_bytes: 256
from sys import stdin

cnt = {}
for line in stdin:
    for c in line:
        d = chr(ord(c)|0x20)
        if 'a'<=d<='z':
            cnt[d] = cnt.get(d, 0) + 1

for i in range(ord('z')-ord('a')+1):
    c = chr(ord('a')+i)
    print(c, ':', cnt.get(c, 0))


Measured memory_bytes: 5568
#include <iostream>
#include <string>
#include <fstream>
#include <cmath>
#include <iomanip>


using namespace std;

int main() {
   
    int x;
    int i = 1;
    do{
        cin >> x;
        if (x != 0) {
            cout << "Case " << i++ << ": " << x << "\n";
        }

    }while(x!=0);
}



Measured memory_bytes: 2976
fun main(args: Array<String>) {
    val S = readLine()!!
    val N = S.length
    val S1 = S.take((N - 1) / 2)
    val S2 = S.takeLast((N - 1) / 2)
    println(if (S == S.reversed() && S1 == S1.reversed() && S2 == S2.reversed()) "Yes" else "No")
}

Measured memory_bytes: 33716
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    int a[Q],b[Q],c[Q],d[Q];
    for(int i = 0; i < Q; ++i) cin >> a[i] >> b[i] >> c[i] >> d[i];
    
    int mx = 0;

    //M以下の数N個でなる数列Aでループ
    int A[10];
    for(int i0 = 1; i0 <= M; ++i0){
    for(int i1 = i0; i1 <= M; ++i1){
    for(int i2 = i1; i2 <= M; ++i2){
    for(int i3 = i2; i3 <= M; ++i3){
    for(int i4 = i3; i4 <= M; ++i4){
    for(int i5 = i4; i5 <= M; ++i5){
    for(int i6 = i5; i6 <= M; ++i6){
    for(int i7 = i6; i7 <= M; ++i7){
    for(int i8 = i7; i8 <= M; ++i8){
    for(int i9 = i8; i9 <= M; ++i9){
        A[0]=i0;
        A[1]=i1;
        A[2]=i2;
        A[3]=i3;
        A[4]=i4;
        A[5]=i5;
        A[6]=i6;
        A[7]=i7;
        A[8]=i8;
        A[9]=i9;
        
        int dsum = 0;
        //点数計算
        for(int i = 0; i < Q; ++i){
            if(A[b[i]-1] - A[a[i]-1] == c[i]){
                dsum += d[i];
            }
        }
        mx = max(dsum,mx);
    }}}}}}}}}}
    cout << mx << endl;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,m;  cin >> n >> m;
  vector<int> v(n+1),w(n+2);
  for(int i = 0; i < m; ++i){
    int a,b; cin >> a >> b;
    w[a]++; w[b]--;
  }
  for(int i = 1; i <= n; ++i){    
    v[i] = v[i-1] + w[i];
    debug(w[i]);
    debug(v[i]);
    if(v[i] % 2 != 0){cout << "NO" << endl; return 0;}
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
typedef long long ll;
ll k, n=1, d=1;

ll f(ll p) {
	ll s=0;
	for(; p; p/=10) s += p%10;
	return s;
}

int main() {
	scanf("%lld", &k);
	puts("1");
	while(--k) {
		if((n+d*10) * f(n+d) < (n+d) * f(n+d*10)) d*=10;
		printf("%lld\n", n+=d);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	string S;;
	cin>>S;
	string ans = "Good";
	rep(i,int(S.size())){
		rep(j,int(S.size())){
			if(S[i] == S[j]&&i+1 == j){
				ans = "Bad";
			} 
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1001001001
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
    ll X; cin >> X;
    ll value=0;
    value += X/500*1000;
    X %= 500;
    value += X/5*5;
    cout << value << endl;
}

Measured memory_bytes: 3572
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		for(int i=1;i<=N;i++){
			if((int)(i*1.08)==N){
				System.out.println(i);
				System.exit(0);
			}
		}
		System.out.println(":(");
	}
}


Measured memory_bytes: 23764
// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main(){
	ios_base::sync_with_stdio(false);
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k%2==0){
		k=1;
	}
	else{
		k=-1;
	}
	cout<<k*(a-b)<<endl;
	return 0;
}

Measured memory_bytes: 256
abcd = input('')
a = int(abcd.split(' ')[0])
b = int(abcd.split(' ')[1])
c = int(abcd.split(' ')[2])
d = int(abcd.split(' ')[3])
while True:
    c-=b
    if c <=0:
        break
    a-=d
    if a <=0:
        break

if a > 0:
    print('Yes')
else:
    print('No')


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

int main(){
  int N; cin >> N;
  vector<int> up(N), down(N);
  for(int i = 0; i < N; i++){
    cin >> up[i];
  }
  for(int i = 0; i < N; i++){
    cin >> down[i];
  }
  
  int ans = 0;
  
  for(int i = 0; i < N; i++){
    int tmp = accumulate(up.begin(), up.begin() + i + 1, 0)
      + accumulate(down.begin() + i, down.end(), 0);
    ans = max(ans, tmp);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int n;

	while(cin >> n && n)
	{
		vector<string> field(n + 1);
		vector<vint>   table(n + 1, vint(n + 1));
		int x, y, i, lim;


		field[0] = "*";
		rep(x, n)
			field[0] += "*";

		for(y = 1; y <= n; y++)
		{
			string line;
			cin >> line;
			field[y] = "*" + line;
		}

		for(y = 0; y <= n; y++) for(x = 0; x <= n; x++)
		{
			if(y == 0 && x == 0)
				table[y][x] = field[y][x] == '*';
			else if(y == 0)
				table[y][x] = table[y][x-1] + (field[y][x] == '*');
			else if(x == 0)
				table[y][x] = table[y-1][x] + (field[y][x] == '*');
			else
				table[y][x] = table[y][x-1] + table[y-1][x] - table[y-1][x-1] + (field[y][x] == '*');
		}

		int res = 0;
		for(y = 0; y <= n; y++) 
		{
			for(x = 0; x <= n; x++)
			{
				lim = min(n-y, n-x) + 1;
				REP(i, 1, lim)
				{
					if(table[y + i][x + i] - table[y][x + i] - table[y + i][x] + table[y][x] == 0)
					{
						chmax(res, i);
					}
					else break;
				}
			}
		}

		cout << res << endl;
	}
}

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

int main() {
	double H, W, h, w, x, y;
	cin >> W >> H >> w >> h >> x >> y;
	
	double a = x - w/2, b = y - h/2;
	double c = min(W/2, x+w/2), d = min(H/2, y+h/2);
	
	double X = (a+c)/2, Y = (b+d)/2;
	printf("%.9lf\n", Y/X);
}


Measured memory_bytes: 3280
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
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;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;
//using namespace atcoder;

void solve(){
	int n;
	cin>>n;
	vector<int>v;
	rep(i,n){
		int x,y;
		cin>>x>>y;
		if(x==y)v.eb(i);
	}
	bool ok=false;
	rep(i,v.size()-2){
		if(v[i]+1==v[i+1]&&v[i+1]+1==v[i+2]){
			ok=true;
		}
	}
	if(ok)cout<<"Yes\n";
	else cout<<"No\n";
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3648
def main():
    input()
    t = list(map(int, input().split()))
    ans = 0
    c = 0
    for i in range(len(t) - 1):
        if t[i] >= t[i + 1]:
            c += 1
        else:
            ans = c if ans < c else ans
            c = 0
    print(max(ans, c))

if __name__ == '__main__':
    main()

Measured memory_bytes: 14252
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pli = std::pair<long long, int> ;

using namespace std;

const long long MOD = 1000000007;

template<typename T>
constexpr std::vector<std::pair<T, T>> primeFactorization(T number) noexcept {
	std::vector<std::pair<T, T>> primeFactors;
	T quotient = number;
	for (T i = 2; i*i <= quotient; ++i) {
		if (quotient%i == 0) {
			T prime = i, power = 1;

			quotient /= i;
			while (quotient%i == 0) {
				++power;
				quotient /= i;
			}

			primeFactors.push_back(std::pair<T, T>(prime, power));
		}
	}
	if (quotient != 1) primeFactors.push_back(std::pair<T, T>(quotient, 1));

	return primeFactors;
}

template<typename T>
constexpr T binaryPow_mod(T radix, T index, T mod) noexcept {
	radix %= mod;
	T rtv = 1;
	while (index > 0) {
		if (index & 1) {
			rtv *= radix;
			rtv %= mod;
		}

		radix *= radix;
		radix %= mod;

		index = index >> 1;
	}

	return rtv;
}

template<typename T>
constexpr std::pair<T, T> eea(T a, T b) noexcept {
	T x = 1, y = 0, p = 0, q = 1;
	while (b != 0) {
		T s = a;
		a = b;
		T t = s / b;
		b = s % b;

		T i = x, j = y;
		x = p;
		y = q;
		p = i - t * p;
		q = j - t * q;
	}

	return pair<T, T>(x, y);
}

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

	int n;
	cin >> n;
	ll* a;
	a = new ll[n];
	rep(i, n) cin >> a[i];

	map<ll, ll> lcm;
	rep(i, n) {
		vector<pll> primes = primeFactorization(a[i]);
		
		rep(j, primes.size()) {
			auto p = lcm.find(primes[j].first);

			if (p != lcm.end()) {
				p->second = max(p->second, primes[j].second);
			}
			else {
				lcm.insert(primes[j]);
			}
		}
	}

	ll lcmNum = 1;
	for (auto i = lcm.begin(); i != lcm.end(); ++i) {
		lcmNum *= binaryPow_mod(i->first, i->second, MOD);
		lcmNum %= MOD;
	}

	ll ans = 0;
	rep(i, n) {
		ll inva = eea(a[i], MOD).first;
		if (inva < 0) inva += MOD;

		ans += (lcmNum*inva) % MOD;
		ans %= MOD;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1024
n = int(input())
hantei_list = [1 for _ in range(n)]
moji_list = [str(input()) for _ in range(n)]
prime_number = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101]
for i in range(n):
  for j in range(10):
    hantei_list[i] *= prime_number[ord(moji_list[i][j])- ord('a')]

# unique = set(hantei_list)
appeared = dict()

counter = 0
for i in hantei_list:
  if not i in appeared:
    appeared[i] = 1
  else:
    counter += appeared[i]
    appeared[i] += 1
print(counter)


Measured memory_bytes: 24152
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    VI a(5);
    REP(i,0,5) cin >> a[i];
    sort(all(a), [](auto &l, auto &r) {
        return (l % 10 != 0 ? l % 10 : 10) < (r % 10 != 0 ? r % 10 : 10);
    });
    int ans = 0;
    REP(i,0,5) {
        if (a[i] % 10 != 0 && i > 0) ans += 10 - a[i] % 10;
        ans += a[i];
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 256
A,B = map(int,input().split())
c = [2,3,4,5,6,7,8,9,10,11,12,13,1]
if c.index(A) < c.index(B):
    print("Bob")
elif c.index(A) > c.index(B):
    print("Alice")
else:
    print("Draw")

Measured memory_bytes: 3060