akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}
Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;
}
Node treeSearch(Node u, int k){
  
  while(u != NIL && k != u->key){
    if(k < u->key){
      u = u->left;}
    else u = u->right;
  }
  return u;
}
Node treeSuccessor(Node x){
Node y;
 
 if(x->right != NIL){
   return  treeMinimum(x->right);
 }
 else return NIL;

 
 y = x->parent;
 while(y != NIL && x == y->right){
   x = y;
   y = y->parent;
 }
 return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || 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;
      
    }
    
    // return y;
}





void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct 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){
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
  }


}
void preorder(Node u){
 if(u!=NIL){
 printf(" %d",u->key);
 
 
 preorder(u->left);
  
  preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
   treeDelete(treeSearch(root, x));
    }
  }

  return(0);
}

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

int main(){
  	string s;
  	cin >> s;
  	
  	rep(i,0,s.size()){
    	rep(j,i+1,s.size()){
          	if(s[i] == s[j]){
             	cout << "no" << endl;
              	return 0;
            }
        }
    }
  	
  	cout << "yes" << endl;
  	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int K = int.Parse(Console.ReadLine());
        int sum = nums.Sum();
        int max = nums.Max();
        int ans = sum - max + (max << K);
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int s;
  cin>>s;
  set<int> S;
  S.insert(s);
  int i;
  for(i=2;i<1000000;++i){
    if(s%2==0) s=s/2;
    else s=3*s+1;
    if(S.count(s)!=0) break;
    S.insert(s);
    //cout<<i<<" "<<s<<endl;
  }
  cout<<i<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;
// get<K>(tuple型の変数)

const int inf=1<<29;
int n;
vector<vector<int>> d(110, vector<int>(110, inf));

void floyd(){
    rep(i, n) d[i][i]=0;
    rep(k, n){
        rep(i, n){
            if(d[i][k]==inf) continue;
            rep(j, n){
                if(d[k][j]==inf) continue;
                chmin(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
}

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

    int m; cin >> n >> m;
    vector<int> a(m), b(m), c(m);
    rep(i, m){
        cin >> a[i] >> b[i] >> c[i];
        --a[i]; --b[i];
        d[a[i]][b[i]]=d[b[i]][a[i]]=c[i];
    }

    floyd();

    int ans=0;
    rep(i, m){
        bool shortest=false;
        rep(s, n) rep(t, n){
            if(shortest) break;
            if(s==t) continue;
            if(d[s][a[i]]+c[i]+d[b[i]][t] == d[s][t]){
                shortest=true;
            }
        }
        if(!shortest) ++ans;
    }
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N=2e5+10;
ll a[N],k,n;
int main()
{
	cin>>k>>n;
	rep(i,1,n)
	{
	    scanf("%lld",&a[i]);
	}
	sort(a+1,a+1+n);
	ll mx=0,ans=0;
	for(int i=2;i<=n;++i){
        ans+=a[i]-a[i-1];
        mx=max(mx,a[i]-a[i-1]);
	}
	ll d=a[1]+k-a[n];
	ans+=d;
	mx=max(mx,d);
	cout<<ans-mx<<endl;
}


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

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

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

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

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

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

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

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

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

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

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

fn main() {
    input!{
        m: usize,
        v: [(usize, usize); m]
    }
    let mut tab = vec![vec![(0, 0); 10]; 10];
    for i in 0..10 {
        for j in i..10 {
            if i + j < 10 {
                tab[i][j] = (i + j, 1);
                tab[j][i] = (i + j, 1);
            } else {
                tab[i][j] = ((i + j) % 10 + 1, 2);
                tab[j][i] = ((i + j) % 10 + 1, 2);
            }
        }
    }
    let mut per = vec![vec![]; 10];
    for i in 1..10 {
        let mut done = vec![false; 10];
        let mut d = i;
        let mut c = 0;
        per[i].push((d, c));
        while !done[d] {
            done[d] = true;
            let (x, y) = tab[d][i];
            d = x;
            c += y;
            per[i].push((d, c));
        }
    }
    let mut ans = 0;
    let mut v2 = vec![];
    for &(d, c) in &v {
        if d == 0 {
            v2.push(0);
            ans += c - 1;
        } else {
            let l = per[d].len();
            ans += (c - 1) / (l - 1) * per[d][l - 1].1;
            let (x, y) = per[d][(c - 1) % (l - 1)];
            ans += y;
            v2.push(x);
        }
    }
    let mut d = v2[0];
    for i in 1..v2.len() {
        let (x, y) = tab[d][v2[i]];
        ans += y;
        d = x;
    }
    println!("{}", ans);
}


Measured memory_bytes: 10620
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            long mx1 = 0;
            long mx2 = 0;
            Arrays.sort(a);
            for (int i = a.length - 1; i > 0; i--) {
                if (a[i].equals(a[i - 1])) {
                    if (mx1 == 0) {
                        mx1 = a[i];
                        i--;
                    } else {
                        mx2 = a[i];
                        break;
                    }
                }
            }
            out.println(mx1 * mx2);
        }

    }
}



Measured memory_bytes: 47648
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  cin >>n;
  while(n--){
    int point = 0,out = 3;
    bool base[3] = {0};
    string order;
    while(cin>>order){
      if(order == "HIT"){
	if(base[2]){point++;}
	for(int i=2; i>0; i--){
	  base[i] = base[i-1];
	}
	base[0] = true;
      }
      if(order == "HOMERUN"){
	point++;
	for(int i=0; i<3; i++){
	  if(base[i]){point++;}
	  base[i] = false;
	}
      }
      if(order == "OUT"){
	out--;
      }
      if(!out){break;}
    }
    cout <<point<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

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

        final int n = sc.nextInt();

        final int[] v = new int[n];
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextInt();
        }

        final int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
        }

        int ans = 0;

        for (int i = 0; i < n; i++) {
            ans += v[i] - c[i] > 0 ? v[i] - c[i] : 0;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 23380
#include <stdio.h>
 
/* 選択ソート (0オリジン) */
int selectionSort(int A[], int N) {
  int i, j, t, sw = 0, mini;
  for(i=0; i<N-1; i++) {
    mini = i;
    for(j=i; j<N; j++) {
      if(A[j] < A[mini]) mini = j;
    }
 
    t = A[i];
    A[i] = A[mini];
    A[mini] = t;
 
    if(i != mini) sw++;
  }
  return sw;
}
 
int main(void) {
  int A[100], N, i, sw;
  scanf("%d", &N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);
 
  sw = selectionSort(A,N);
 
  for(i=0;i<N;i++) {
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n", sw);
 
  return 0;
}


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

int main(void) {
	int K, N;
	int A[200100];
	scanf("%d%d", &K, &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	int gapMax = 0;
	for (int i = 0; i < N; i++) {
		if (i == 0) {
			gapMax = max(gapMax, A[0] + (K - A[N - 1]));
		} else {
			gapMax = max(gapMax, A[i] - A[i - 1]);
		}
	}

	printf("%d", K - gapMax);

	return 0;
}


Measured memory_bytes: 4544
#include <bits/stdc++.h>
using namespace std;
double f(double N, int D) {
	if (D == 0) return 1/N;
	int x = N - D;
	if (x <= 0) return 0;
	return (2*x) / (N*N);
}
int main() {
	int N, M, D;
	cin >> N >> M >> D;
	double r = f(N, D);
	r *= M-1;
	printf("%.7f\n", r);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define ARRAY_SIZE 99

int main()
{
	char inputS[ARRAY_SIZE];
	int inputLength;

	scanf("%s", &inputS);
	inputLength = strlen(inputS);

	if (inputLength % 2 > 0)
	{
		for (int i = 0; i < inputLength / 2; i++)
		{
			if (inputS[i] != inputS[inputLength / 2 + i + 1])
			{
				printf("No \n");
				return 0;
			}
		}
	}
	else
	{
		for (int i = 0; i < inputLength / 2; i++)
		{
			if (inputS[i] != inputS[inputLength / 2 + i])
			{
				printf("No \n");
				return 0;
			}
		}
	}

	printf("Yes \n");

	return 0;
}

Measured memory_bytes: 128
program sample
    implicit none
  
    integer(8) :: i,j,m,n,d
    real(8)::a,b
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) d,n
    i=(n-1)/99

    m=i*100+mod(n-1,99)+1
    write(*,*) m*100**d
  
    stop
end program sample
  



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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i, n) for (ll i = 0; i < (n); i++)
#define forn for (ll i = 0; i < (n); i++)
#define fori(i, k, n) for (ll i = k; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}
template <typename T>
void print(vector<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(deque<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(vector<vector<T>> &a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}
int a[200005];
int flag[200005];

void solve()
{
	// teleport k times
	// 1<=i<=n
	// telep town i -> a[i]
	ll n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	int cur = 1, cnt = 0;
	while (k--)
	{
		cur = a[cur];
		cnt++;
		if (flag[cur])
			k %= (cnt - flag[cur]);
		else
			flag[cur] = cnt;
	}
	cout << cur << en;
}

int main()
{
	fast;
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 5220
n = int(input())
r_list = [int(input()) for i in range(n)]
minv = r_list[0]
maxv= -10**9
for i in range(1,n):
        maxv = max(r_list[i]-minv, maxv)
        minv = min(minv,r_list[i])

print(maxv)




Measured memory_bytes: 13596
#include <iostream>
#define llint long long

using namespace std;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(a != c) cout << 1 << endl;
	else cout << 0 << endl;
	
	return 0;
}

Measured memory_bytes: 256
loop do
    n, m, k = gets.split.map(&:to_i)
    break if n == 0 && m == 0 && k == 0
    sum = 0
    dp = Array.new(n * m + 1, 0)
    dp[0] = 1.0
    n.times do
        dp2 = Array.new(n * m + 1, 0)
        dp.each_with_index do |d, i|
            next if d == 0
            1.upto(m) do |j|
                break if i + j > n * m
                dp2[i + j] += d / m.to_f
            end
            dp = dp2
        end
    end
    dp.each_with_index do |d,i|
        i -= k
        i = 1 if i < 1
        sum += d * i
    end
    puts sum
end

Measured memory_bytes: 6412
#include<iostream>
#include<vector>
#include<string>
#include<map>
using namespace std;

int main(){
  int n;
  map <char, int> mp;
  for(int i=0; i<26; ++i){
    mp[(char)('a'+i)] = i;
  }

  for(int i=0; i<26; ++i){
    mp[(char)('A'+i)] = i+26;
  }

  // for(auto i:mp){
  //cout << i.first << endl;
  //}
  while(cin >> n,n){
    vector<int> v;
    string str;
    
    for(int i=0; i<n; ++i){
      int tmp;
      cin >> tmp;
      v.push_back(tmp);
    }
    cin >> str;

    int cnt = 0;
    for(int i=0; i<str.size(); ++i){
      int tmp = 52 + mp[str[i]] - v[cnt];
      tmp = tmp%52;
      for(auto j:mp){
	if(j.second == tmp)cout << j.first;
      }
      ++cnt;
      if(cnt >= v.size())cnt=0;
    }
    cout << endl;
  }
  return 0;
}
      



Measured memory_bytes: 3196
import java.util.Scanner;

//Doctor's Strange Particles
public class Main{

	static int[][] m;
	static int[][] tmp;
	static boolean[][] ans;
	static int[][] move = {{0,1},{0,-1},{1,0},{-1,0},{0,0}};
	
	static boolean dfs(int k){
		if(k==10){
			tmp = new int[10][10];
			for(int i=0;i<10;i++){
				if(ans[0][i]){
					for(int j=0;j<5;j++){
						int ni = 0+move[j][0];
						int nj = i+move[j][1];
						if(0<=ni&&ni<10&&0<=nj&&nj<10)tmp[ni][nj]++;
					}
				}
			}
			for(int i=1;i<10;i++){
				for(int j=0;j<10;j++){
					if((tmp[i-1][j]+m[i-1][j])%2==1){
						ans[i][j] = true;
						for(int v=0;v<5;v++){
							int ni = i+move[v][0];
							int nj = j+move[v][1];
							if(0<=ni&&ni<10&&0<=nj&&nj<10)tmp[ni][nj]++;
						}
					}
					else ans[i][j] = false;
				}
			}
			for(int i=0;i<10;i++){
				for(int j=0;j<10;j++){
					if((tmp[i][j]+m[i][j])%2==1)return false;
				}
			}
			return true;
		}
		else{
			ans[0][k] = false;
			if(dfs(k+1))return true;
			ans[0][k] = true;
			return dfs(k+1);
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t--!=0){
			m = new int[10][10];
			ans = new boolean[10][10];
			for(int i=0;i<10;i++)for(int j=0;j<10;j++)m[i][j]=sc.nextInt();
			dfs(0);
			for(int i=0;i<10;i++){
				for(int j=0;j<10;j++){
					if(j>0)System.out.print(" ");
					System.out.print(ans[i][j]?"1":"0");
				}
				System.out.println();
			}
		}
	}
}

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

int main(void){
    int n;
    cin >> n;
    int i;
    vector<pair<string, int>> data(n);
    vector<int> data2(n);
    for(i = 0; i < n; i++){
        data2.at(i) = i+1;
    }
    for(i = 0; i < n; i++){
        cin >> data.at(i).first;
        cin >> data.at(i).second;
    }
    bool flg = true;
    int j;
    for(i = 0; i >= 0; i++){
        for(j = 0; j < n-1; j++){
            if(data.at(j).first > data.at(j+1).first){
                swap(data.at(j), data.at(j+1));
                flg = false;
                swap(data2.at(j), data2.at(j+1));
            }
            if(data.at(j).first == data.at(j+1).first){
                if(data.at(j).second < data.at(j+1).second){
                    swap(data.at(j), data.at(j+1));
                    flg = false;
                    swap(data2.at(j), data2.at(j+1));
                }
            }
        }
        if(flg){
            break;
        }
        flg = true;
    }
    for(i = 0; i < n; i++){
        cout << data2.at(i) << endl;
    }
}


Measured memory_bytes: 256
S = input()
#YYMMformat
YYMM_yy = int(S[0]) * 10 + int(S[1])
YYMM_mm = int(S[2]) * 10 + int(S[3])
YYMM = False
MMYY = False
AM = False
NA = False
if YYMM_yy > 12:
    YYMM = True
elif YYMM_mm > 12:
    MMYY = True
elif YYMM_yy != 0 and YYMM_mm != 0:
    AM = True
if YYMM_yy == 0:
    YYMM = True
elif YYMM_mm == 0:
    MMYY = True
if YYMM_yy == 0 and YYMM_mm > 12:
    NA = True
elif YYMM_mm == 0 and YYMM_yy > 12:
    NA = True
elif YYMM_mm == 0 and YYMM_yy == 0:
    NA = True
elif YYMM_mm > 12 and YYMM_yy > 12:
    NA = True

if NA:
    print('NA')
elif AM:
    print('AMBIGUOUS')
elif YYMM:
    print('YYMM')
elif MMYY:
    print('MMYY')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ull x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vp ab(n);
    rep(i, n){
        cin >> ab[i].first >> ab[i].second;
    }
    {
        bool f = 1;
        rep(i, n){
            if(ab[i].first != ab[i].second){
                f = 0;
                break;
            }
        }
        if(f){
            cout << 0 << endl;
            return 0;
        }
    }
    sort(ALL(ab), [&](pll x, pll y){return x.first-x.second < y.first-y.second;});
    dump(ab);
    ll mi = INF;
    ll ans = 0;
    rep(i, n){
        ans += ab[i].first;
        if(ab[i].first > ab[i].second){
            chmin(mi, ab[i].second);
        }
    }
    cout << ans-mi << endl;
    return 0;
}

Measured memory_bytes: 640
h,w=map(int,input().split())
f=range
g=[[c=='.'for c in input()]for _ in f(h)]
a=[[-3]*w for _ in f(h)]
for i in f(h):
  l=r=0
  for j in f(w): l=-~l*g[i][j]; a[i][j]+=l; r=-~r*g[i][~j]; a[i][~j]+=r
for i in f(w):
  d=u=0
  for j in f(h): d=-~d*g[j][i]; a[j][i]+=d; u=-~u*g[~j][i]; a[~j][i]+=u
print(max(a[i][j] for i in f(h) for j in f(w)))

Measured memory_bytes: 112860
#include<stdio.h>
int main()
{
	int x1,x2,x3,x4,x5;
	scanf("%d %d %d %d %d",&x1,&x2,&x3,&x4,&x5);
	if(x1==0){
		printf("1 ",x1);
	}
	else if(x2==0){
		printf("2 ",x2);
	}
	else if(x3==0){
		printf("3",x3);
	}
	else if(x4==0){
		printf("4",x4);
	}
	else{
		printf("5",x5);
	}
	return 0;
}

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

int main() {
  int n;
  ll sum;
  cin >> n;
  
  sum = 0;
  for (int i=1; i<=n; i++) {
    if (i%3 != 0) {
      sum += i;
    }
    if (i%3 != 0 && i%5 == 0) {
      sum -= i;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N-1+M), B(N-1+M), niv(N), S;
    vector<vector<ll>> G(N), H(N);
    rep(i,N-1+M){
        cin >> A[i] >> B[i];
        A[i]--;B[i]--;
        G[A[i]].push_back(B[i]);
        H[B[i]].push_back(A[i]);
    }
    rep(i,N-1+M){
        niv[B[i]]++;
    }
    queue<ll> que;
    rep(i,N){
        if(niv[i] == 0){
            que.push(i);
            S.push_back(i);
        }
    }
    while(!que.empty()){
        ll v = que.front();
        que.pop();
        for(auto& u:G[v]){
            niv[u]--;
            if(niv[u] == 0){
                que.push(u);
                S.push_back(v);
            }
        }
    }
    //PR(S,N);
    vector<ll> note(N);
    rep(i,N){
        note[S[i]] = i;
    }
    vector<ll> ans(N);
    rep(i,N){
        ll Mv = -1;
        ll u = -1;
        for(auto& v:H[i]){
            if(Mv < note[v]){
                Mv = note[v];
                u = v;
            }
        }
        ans[i] = u+1;
    }
    rep(i,N){
        cout << ans[i] << endl;
    }
}

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


int main() {
  int a[3][3];
  int ans[3][3] = {0,0,0,0,0,0,0,0,0};

  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> a[i][j];
    }
  }

  int n; 

  cin >> n;

  vector<int> b(n);

  for(int i=0; i<n; i++){
    cin >> b.at(i);
  }



  for(int k=0; k<n; k++){
    for(int i=0; i<3; i++){
      for(int j=0; j<3; j++){
        if(a[i][j] == b.at(k)){
        ans[i][j] = 1;
        }
      }
    }
  }

  if(ans[0][0] == 1 && ans[0][1] == 1 && ans[0][2] == 1){
    cout << "Yes"; return 0;
  }
  else if(ans[1][0] == 1 && ans[1][1] == 1 && ans[1][2] == 1){
  cout << "Yes"; return 0;
  }
  else if(ans[2][0] == 1 && ans[2][1] == 1 && ans[2][2] == 1){
  cout << "Yes"; return 0;
  }
  else if(ans[0][0] == 1 && ans[1][0] == 1 && ans[2][0] == 1){
  cout << "Yes"; return 0;
  }
  else if(ans[0][1] == 1 && ans[1][1] == 1 && ans[2][1] == 1){
  cout << "Yes"; return 0;
  }
  else if(ans[0][2] == 1 && ans[1][2] == 1 && ans[2][2] == 1){
  cout << "Yes"; return 0;
  }
  else if(ans[0][0] == 1 && ans[1][1] == 1 && ans[2][2] == 1){
  cout << "Yes"; return 0;
  }
  else if(ans[0][2] == 1 && ans[1][1] == 1 && ans[2][0] == 1){
  cout << "Yes"; return 0;
  }
  else
  {
    cout << "No";
  }
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
   int N[4];
   REP(i, 4) cin >> N[i];
   sort(N, N + 4);
   if (N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9) cout << "YES" << endl;
   else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 764
class Number:
  value = '0'
  negative = False
  
  def __init__(self, value, negative):
    self.value = value
    self.negative = negative
    
  def __int__(self):
    x = int(self.value)
    return -x if self.negative else x
  
  def __str__(self):
    x = str(self.value)
    return '-' + x if self.negative else '+' + x
  
correct = []  

def solve(numbers, k):
  global correct
  if k >= len(numbers):
    if sum([int(x) for x in numbers]) == 7:
      correct.append(numbers)      
    return
  
  negative = []
  for i, x in enumerate(numbers):
    if i == k:
      negative.append(Number(x.value, True))
    else:
      negative.append(x)
  
  solve(numbers, k + 1)
  solve(negative, k + 1)
  
numbers = [Number(x, False) for x in input()] 

solve(numbers, 1)

print(''.join([str(x) for x in correct[0]])[1:] + '=7')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n,T;
  cin>>n>>T;
  ll now=0;
  ll ans=0;
  vector<ll> time(1,0);
  for(int i=0;i<n;i++){
    ll tmp;
    cin>>tmp;
    time.push_back(tmp);
  }
  for(int i=0;i<n;i++){
    ll diff=time[i+1]-time[i];
    if(diff<T){
      ans+=diff;
    }
    else ans+=T;
  }
  ans+=T;
  cout<<ans;
}
  

Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int j = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        System.out.println(h - Math.max((j - 1) / x + 1, (m - 1) / y + 1));
    }
}


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

int main(){
	int l,a,b,c,d;
	cin>>l>>a>>b>>c>>d;
	int x = a/c + (a%c ? 1 : 0);
	int y = b/d + (b%d ? 1 : 0);
	cout<<l-max(x,y)<<endl;
}

Measured memory_bytes: 3052
import java.util.*;
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();

		int ans = 0;
		if (N<=K) {
			ans = N*X;
		} else {
			ans = K*X + (N-K)*Y;
		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M;
  cin>>N>>M;
  vector<vector<char>>A(N,vector<char>(N));
  for(int i=0;i<N;i++){
  string a;
    cin>>a;
    for(int j=0;j<N;j++)
      A.at(i).at(j)=a.at(j);
 }vector<vector<char>>B(M,vector<char>(M));
  for(int i=0;i<M;i++){
  string b;
    cin>>b;
    for(int j=0;j<M;j++)
      B.at(i).at(j)=b.at(j);
  }string ans="No";
  for(int i=0;i<=N-M;i++){
  for(int j=0;j<=N-M;j++){
     bool x=true;
    for(int I=0;I<M;I++){
   for(int J=0;J<M;J++)
     if(B.at(I).at(J)!=A.at(i+I).at(j+J)){
       x=false;
     }
   }if(x){ans="Yes"; break;}
  
  }if(ans=="Yes") break;
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

typedef long long int ll;

const int N = 1e5 + 5;

vector < int > cnt (N, 0);

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

  int n;
  cin >> n;
  vector < int > a (n + 1);
  ll sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
    sum += a[i];
  }

  int q;
  cin >> q;
  while (q--) {
    int b, c;
    cin >> b >> c;
    sum += (ll)(c - b) * cnt[b];
    cnt[c] += cnt[b];
    cnt[b] = 0;
    cout << sum << '\n';
  }
}


Measured memory_bytes: 3924
#include<set>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#define ll long long
#define Re register
using namespace std;
const int N = 1e5 + 5;
inline int read(){
	int f = 1, x = 0; char ch;
	do { ch = getchar(); if (ch == '-') f = -1; } while (ch < '0' || ch > '9');
	do {x = (x << 3) + (x << 1) + ch - '0'; ch = getchar(); } while (ch >= '0' && ch <= '9'); 
	return f * x;
}

inline void write(int x) {
	if (x < 0) putchar('-'), x = -x;
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}

set<int> g[N];
set<int> :: iterator it;
map<pair<int, int>, int> s;

pair <int, int> q[N];
int h, t, res;

int n;

int f[N];
inline int find(int x) {
	return (f[x] == x) ? x : f[x] = find(f[x]);
}

int main(){
	n = read();
	for (Re int i = 1;i <= n; ++i) f[i] = i; 
	for (Re int i = 1;i < 2 * n - 1; ++i) {
		int x = read(), y = read();
		g[x].insert(y), g[y].insert(x);
		s[make_pair(x, y)]++, s[make_pair(y, x)]++;
		if (s[make_pair(x, y)] == 2) {
			q[++t] = make_pair(x, y);
		}
	}
	
	while (h < t) {
		++h;
		int u = q[h].first, v = q[h].second;
		u = find(u), v = find(v);
		g[u].erase(v), g[v].erase(u);
		if (g[u].size() > g[v].size()) swap(u, v);
		f[u] = v;
		for (it = g[u].begin();it != g[u].end(); ++it) {
			int to = (*it);
			s[make_pair(to, u)] = s[make_pair(u, to)] = 0;
			s[make_pair(to, v)] ++, s[make_pair(v, to)] ++;
			g[to].erase(u), g[to].insert(v);
			if (s[make_pair(to, v)] == 2) {
				q[++t] = make_pair(to, v);
			}
			g[v].insert(to);
		}
		g[u].clear();
	}
	for (Re int i = 1;i <= n; ++i) res += (f[i] == i);
	if (res == 1) printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 57472
package main

import (
	"fmt"
	"sort"
)

func main() {
	a := make([]int, 2)
	for i := 0; i < 2; i++ {
		fmt.Scan(&a[i])
	}

	sort.Ints(a)

	for i := 0; i < 2; i++ {
		if a[i] != i+1 {
			fmt.Println(i + 1)
			return
		}
	}
	fmt.Println(3)

}

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

bool allLettersAreEqual(string s) {
      for(int i=0; i<s.size(); i++) {
            if(s[i] != s[0]) return false;
      }
      return true;
}

int bruteForce(int N, string str) {
      int res = 1e9;             // max for integer
      for(int i=0; i<N; i++) {      // try out each letter in the string
            char target = str[i];
            string str2 = str;
            int count = 0;


            while(!allLettersAreEqual(str2)) {
                  string str3 = "";
                  for(int i=0; i<str2.size()-1; i++) {
                        if(str2[i] == target || str2[i+1] == target) {
                              str3 += target;
                        }
                        else str3 += str2[i];
                  }
                  str2 = str3;
                  count++;
            }
            res = min(res, count);
      }
            
      return res;
}

int main() {
      string str;
      cin >> str;
      int N = str.length();

      cout << bruteForce(N, str) << endl;
}

Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

bool solve(const vector<ll> &a) {
  REP(i,a.size()) {
    if(a[i] % 2LL != 0LL) return true;
  }
  return false;
}

int main() {
  int N; cin>>N;
  vector<ll> a(N);
  REP(i,N) cin>>a[i];
  bool ans = solve(a);
  cout << (ans ? "first" : "second") << endl;
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
for i in range(N):
    if i == 0:
        P = list(map(int, input().split()))
        continue
    P.append(int(input().split()[1]))

# dpテーブルの用意 minを取るときはinf埋めしておくと処理が楽になるしバグが見つかりやすい
INF = 2**32-1
dp = [[INF]*N for _ in range(N)]

# dpテーブルの初期化
# 対角成分0
for ij in range(N):
    dp[ij][ij] = 0
    
for l in range(1, N):
    for i in range(N-l):
        j = i+l
        for k in range(i,j):
            dp[i][j] = min(dp[i][k] + dp[k+1][j] + P[i]* P[j+1]*P[k+1], dp[i][j])
print(dp[0][-1])


Measured memory_bytes: 5652
# -*- coding:utf-8 -*-

n, m, x, y = map(int, input().split())
lstx = input().split()
lsty = input().split()

xl = []
xl.append(x)
yl = []
yl.append(y)

for i in lstx:
    xl.append(int(i))

for i in lsty:
    yl.append(int(i))

if max(xl) < min(yl):
    print("No War")
else:
    print("War")


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
// using i64 = unsigned long long;
using namespace std;

const int maxn = 2e3;
int n, x, y;
int dist[maxn] = {0};

int calc(int i, int j) {
  int ret = abs(j - i); 
  ret = min(ret, abs(x - i) + 1 + abs(y - j));
  return min(ret, abs(y - i) + 1 + abs(x - j));
}

int main() {
  cin >> n >> x >> y;
  for (int i = 1; i <= n; i++) 
    for (int j = i + 1; j <= n; j++)
      dist[calc(i, j)]++;
  for (int i = 1; i <= n - 1; i++)
    cout << dist[i] << '\n';
}

Measured memory_bytes: 256
fun main(args: Array<String>) {

    val N = readLine()!!.toInt()
    val dList = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()

    var ans = 0
    for (i in 0 until N) {
        for (j in i until N) {
            if (i == j) continue
            ans += dList[i] * dList[j]
        }
    }

    println(ans)
}

Measured memory_bytes: 36036
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}

ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}

int n;

int main(){
	cin>>n;
	ll res=1;
	for(int i=0;i<n;i++){
		ll A;
		cin>>A;
		res=lcm(res,A);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
import bisect
N,Q=[int(i) for i in input().split()]
S=input()
AC=list()
for i in range(len(S)-1):
    if S[i]=='A' and S[i+1]=='C':
        AC.append(i)
#print(AC)
for i in range(Q):
    L,R=[int(i)-1 for i in input().split()]
    R-=1
    ll=bisect.bisect_left(AC,L)
    rr=bisect.bisect_right(AC,R)
    print(rr-ll)


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

int main() {
    ll n,m,h[100010]={-1},a,b,ans=0;
    bool flag[100010];
    cin >> n >> m;
    for(ll i=0;i<n;i++) flag[i] = true;
    for(ll i=0;i<n;i++){
        cin >> h[i];
    }
    for(ll i=0;i<m;i++){
        cin >> a >> b;
        if(h[a-1] < h[b-1]) flag[a-1] = false;
        if(h[a-1] > h[b-1]) flag[b-1] = false;
        if(h[a-1] == h[b-1]){
            flag[a-1] = false;
            flag[b-1] = false;
        }
    }
    for(ll i=0;i<n;i++){
        if(flag[i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4504
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
 
typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};
 
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;}

int N,M;
int S,T;
vector<int> G[100005];
int d[100005][3]; 

void init(){
    for(int i=0;i<100005;++i)for(int j=0;j<3;++j)d[i][j]=-1;
}

void bfs(int s){
    queue<PI> que;
    que.push(PI(s,0));
    d[s][0]=0;
    while(que.size()){
        PI v=que.front();
        que.pop();
        for(auto u:G[v.first]){
            PI n=PI(u,(v.second+1)%3);
            if(d[u][n.second]!=-1)continue;
            que.push(n);
            d[u][n.second]=d[v.first][v.second]+1;
        }
    }
}

signed main(){
    init();
    cin>>N>>M;
    for(int i=0;i<M;++i){
        int u,v;
        cin>>u>>v;
        u--,v--;
        G[u].push_back(v);
    }
    cin>>S>>T;
    S--,T--;
    bfs(S);
    if(d[T][0]==-1)cout<<-1<<endl;
    else cout<<d[T][0]/3<<endl;
}


Measured memory_bytes: 11424
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end());
#define ll long long 
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi <vector<vector<vector<int>>> 
#define vc vector<char> 
#define vvc vector<vector<char>>
#define vvvc vector<vector<vector<char>>> 
#define INF 2000000000

using namespace std;

int main() {
	int n;
	cin >> n;
	cout << (int)sqrt(n)*(int)(sqrt(n)) << endl;
	/*int maxx = 0;
	rep(i, 1, (int)(sqrt(n)*(int)(sqrt(n)))) {
		if (i*i < n) maxx = max(maxx, i*i);
	}

	cout << maxx << endl;*/

	


	return 0;
}


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

int main() {
  long long N, Weight, W1234, Val;
  scanf("%lld %lld", &N, &Weight);
  vector<long long> v(N),w(N);
  vector<vector <long long>> Value(4);
  long long ans = 0;


  scanf("%lld %lld", &w.at(0), &v.at(0));
  Value.at(0).push_back(v.at(0));

  for ( int i = 1; i < N; i++ ){
    scanf("%lld %lld", &w.at(i), &v.at(i));
    if ( w.at(i) == w.at(0) ) Value.at(0).push_back(v.at(i));
    else if ( w.at(i) == w.at(0) + 1 ) Value.at(1).push_back(v.at(i));
    else if ( w.at(i) == w.at(0) + 2 ) Value.at(2).push_back(v.at(i));
    else Value.at(3).push_back(v.at(i));
  }
  for ( int i = 0; i < 4; i++)
    sort(Value.at(i).begin(),Value.at(i).end(), greater<long long>());
/*
  for ( int j = 0; j < 4; j++ ){
    for ( int i = 0; i < Value.at(j).size(); i++ ){
      cout << Value.at(j).at(i) << " ";
    }
    cout << endl;
  } */
  
  for (int w0 = 0; w0 <= Value.at(0).size(); w0++ ){
    for (int w1 = 0; w1 <= Value.at(1).size(); w1++ ){
      for (int w2 = 0; w2 <= Value.at(2).size(); w2++ ){
        for (int w3 = 0; w3 <= Value.at(3).size(); w3++ ){
          W1234 = (w0 + w1 + w2 + w3) * w.at(0) + w1 + 2 * w2 + 3 * w3;
          if ( Weight >= W1234 ){
            Val = 0LL;
            for (int a = 0; a < w0; a++ ) Val += Value.at(0).at(a);
            for (int b = 0; b < w1; b++ ) Val += Value.at(1).at(b);
            for (int c = 0; c < w2; c++ ) Val += Value.at(2).at(c);
            for (int d = 0; d < w3; d++ ) Val += Value.at(3).at(d);
            ans = max(ans, Val);
          }
        }
      }
    }
  }


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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<iomanip>
#define pi 3.14159265358979323846
using namespace std;

int main()
{
	int n,i;
	double a[1000],sum=0.0,m,temp=0.0,std_dev;
	cin>>n;
	while(n!=0){
		sum=temp=0;
		for(i=0;i<n;i++){
			cin>>a[i];
			sum += a[i];
		} 
		m = sum/n;
		for(i=0;i<n;i++){
			temp += (a[i] - m) * (a[i] - m);
		}
		std_dev = sqrt(temp/n);
		cout<<setprecision(9)<<fixed<<std_dev<<endl;
		cin>>n;
	}
}



Measured memory_bytes: 3268
n = int(input())
a = list(map(int, input().split()))
a.sort()
mt = 10 ** 10
for i in range(a[0], a[-1] + 1):
    t = 0
    for j in a:
        t += (j - i) ** 2
    mt = min(mt, t)
print(mt)


Measured memory_bytes: 3064
// マージソート
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_N 500000

int cmp_count = 0;

void mergeSort(int A[], int left, int right);
void merge(int A[], int left, int mid, int right);

int main(void)
{
    int A[MAX_N];
    int n;

    scanf("%d", &n);

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

    // マージソートを実施
    mergeSort(A, 0, n);

    // 結果の表示
    for(int i = 0; i < n; i++)
    {
        if( i )
        {
            printf(" ");
        }

        printf("%d", A[i]);
    }

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

    return 0;
}

// マージソートを実施する関数
void mergeSort(int A[], int left, int right)
{
    // 最小単位まで分割する
    if ( left + 1 < right )
    {
        int mid = ( left + right ) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
  }

  return;
}

// 分割された要素を並び替える関数
void merge(int A[], int left, int mid, int right)
{

    const int INFTY = 2147483647;
    vector<int> L, R;

    int n1 = mid - left;
    int n2 = right - mid;

    // L[0...n1], R[0...n2] を生成
    for(int i = 0; i < n1; i++)
    {
        // 前半部分の配列を作成する
        L.push_back(A[left + i]);
    }

    for(int i = 0; i < n2; i++)
    {
        // 後半部分の配列を作成する
        R.push_back(A[mid + i]);
    }

    L.push_back(INFTY);
    R.push_back(INFTY);

    int i = 0;
    int j = 0;

    for(int k = left; k < right; k++)
    {
        // 前半部分の配列と後半部分の配列を比較する
        if ( L[i] <= R[j] )
        {
            A[k] = L[i];
            i = i + 1;
        }
        else
        {
            A[k] = R[j];
            j = j + 1;
        }

        cmp_count++;
    }
}



Measured memory_bytes: 7448
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  cout<<a[n-1]-a[0] <<endl;
}

Measured memory_bytes: 256
def func(K , A , B) : 
    if B >= A + 3 :
        if (K - A + 1) % 2 == 0 : 
            n = int((K - A + 1) / 2)
            return n * (B - A) + A 
        else : 
            n = int((K - A) / 2)
            return n*(B - A) + A + 1
    else : 
        return K + 1


s = input().split(" ")
print( int(func( int(s[0]) , int(s[1]) , int(s[2]) )) )

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
    int n,ans=0;
    int i,j;
    scanf("%d",&n);
    
    for(i=1;i<=9;i++){
        for(j=1;j<=9;j++){
            if(i*j==n)
            ans = 1;
        }
    }
    
    if(n>81){
        printf("No");
    } else if(ans == 1 ){
        printf("Yes");
    } else {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cctype>
#include <string>
using namespace std;

int main() {
   int size, th; 
   string thing;

   cin >> size >> th >> thing;
 
   for(int i = 0; i < size; i++){
       if(i==th-1){
        putchar(tolower(thing[th-1]));
       }
       else{
       cout << thing[i];
       }
   }

}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;

typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,p;
    string s;
    cin>>n;
    vector<pair<pair<string,int>,int>> d;
    for(int i=0;i<n;i++) {
        cin>>s>>p;
        d.push_back(make_pair(make_pair(s, -p), i));
    }
    sort(d.begin(),d.end());
    
    for(int i=0;i<n;i++) cout<<d.at(i).second+1<<endl;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

#define pb(x) push_back(x)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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;}

int n,w;
ll weight[100],val[100];
ll dp[105][100005]; //imade erannde val jijyou minw

int main() {
  int n;cin >> n;
  cout << n*n*n;
}

Measured memory_bytes: 256