akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  map<string, int> m;
  for(int i = 0; i < n; ++i) {
  	string s;
    cin >> s;
    ++m[s];
  }
  cout << "AC x " << m["AC"] << endl;
  cout << "WA x " << m["WA"] << endl;
  cout << "TLE x " << m["TLE"] << endl;
  cout << "RE x " << m["RE"] << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++ )
#define dump(x) cerr << #x << " = " << (x) << endl;
#define int long long
#define mod (1000000007);
signed main(void){
    int N; cin >> N;
    string S[2];
    cin >> S[0];
    cin >> S[1];
    int ans = 1;
    int k = 3;
    vector<int> v;
    rep(i, N) {
        if (S[0][i] == S[1][i]) {
            v.push_back(1);
        } else {
            v.push_back(2);
            i++;
        }
    }
    rep(i, v.size()) {
        if (i == 0) {
          ans *= 3;
          if (v[i] == 2) ans *= 2;
        }
        else if (v[i - 1] == 1 && v[i] == 2) ans *= 2;
        else if (v[i - 1] == 1 && v[i] == 1) ans *= 2;
        else if (v[i - 1] == 2 && v[i] == 1) ans *= 1;
        else ans *= 3;
        ans %= mod;
        //cout << v[i] << " " << ans << endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  int N,ans=0,count=0;
  cin >> N;
  int A[N+1];
  rep(i,N) cin >> A[i];
  A[N]=INF;
  sort(A,A+N);
  int now=A[0];
  rep(i,N+1){
    if(A[i]==now) count++;
    else{
      if(count<now) ans+=count;
      else ans+=count-now;
      count=1;
      now=A[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int a,b,c,d,e,f,g,h,i,j,k;
    cin>>a;
    cin>>b;
    cin>>c;
    cin>>d;
    cin>>e;
    f=abs(a);
    g=f*c;
    h=b-a;
    i=h*e;
    j=b*e;
    if(a<0){
        k=g+d+j;
        cout<<k<<endl;
    }
    else if(a>0){
        cout<<i<<endl;
    }
}


Measured memory_bytes: 3076
import sys
n,k=map(int,input().split())
x=list(map(int,input().split()))
left=[]
right=[]
origin=0
for u in x:
  if u<0:
    left.append(abs(u))
  elif u==0:
    origin+=1
  else:
    right.append(u)
left.sort()
k-=origin
if k==0:
  print(0)
  sys.exit()
r=len(right)
l=len(left)
ans=float('inf')
if k<=r:
  ans=right[k-1]
if k<=l:
  ans=min(ans,left[k-1])
for i in range(k-1):
  if i<r and k-i-2<l:
    y=right[i]+left[k-i-2]+min(right[i],left[k-i-2])
    ans=min(ans,y)
print(ans)

Measured memory_bytes: 20068
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let mut value: i32 = read();
    while value - 1000 > 0 {
        value = value - 1000;
    }
    println!("{}", 1000 - value);
}

Measured memory_bytes: 2132
#include <bits/stdc++.h>
#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 sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    vector<ll> a(n),b(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    ll ta=0,tb=0;
    rep(i,n){
        if(a[i]>b[i])ta+=(a[i]-b[i]);
        else tb+=(b[i]-a[i])/2;
    }
    //cout<<ta<<" "<<tb<<endl;
    if(ta<=tb)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3792
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;cin>>a>>b;
  cout<<2*b-a<<endl;
  return 0;
}


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

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define FOR(i, a, b) for(int i = a;i < b;++i)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999

#define lint long long


int main()
{
  lint n; cin>>n;
  lint sum;
  if(n==1) {
    sum = 0;
  }else{
    sum = n*(n-1)/2;
  }
  cout <<sum<< "\n";
  return 0;
}




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

using namespace std;
typedef long long ll;

#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359

int main(void) {
  ll x, y;
  cin >> x >> y;
  if (x > 0 && y > 0) {
    if (x < y) {
      cout << y - x << endl;
      return 0;
    } else if (x > y) {
      cout << x - y + 2 << endl;
      return 0;
    } else if (x == y) {
      cout << '0' << endl;
      return 0;
    }
  } else if (x < 0 && y < 0) {
    if (x > y) {
      cout << x - y + 2 << endl;
      return 0;
    } else if (x < y) {
      cout << y - x << endl;
      return 0;
    } else if (x == y) {
      cout << '0' << endl;
      return 0;
    }
  } else if (x > 0 && y < 0) {
    if (abs(x) < abs(y)) {
      cout << abs(y) - x + 1 << endl;
      return 0;
    } else {
      cout << x - abs(y) + 1 << endl;
      return 0;
    }
  } else if (x < 0 && y > 0) {
    if (abs(x) < y) {
      cout << y - abs(x) + 1 << endl;
      return 0;
    } else {
      cout << abs(x) - y + 1 << endl;
      return 0;
    }
  } else if (x == 0 && y > 0) {
    cout << y << endl;
    return 0;
  } else if (x == 0 && y < 0) {
    cout << abs(y) + 1 << endl;
    return 0;
  } else if (x == 0 && y == 0) {
    cout << '0' << endl;
    return 0;
  } else if (x > 0 && y == 0) {
    cout << x + 1 << endl;
    return 0;
  } else if (x < 0 && y == 0) {
    cout << abs(x) << endl;
  }

  return 0;
}

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

int main()
{
    long long n,total=0,i,l,r;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>l>>r;
        total+=(r-l+1);
    }
    cout<<total<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using namespace atcoder;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    int N,M; cin >> N >> M;
    vector<ll> A(N),B(M);
    rep(i,N) cin >> A[i];
    rep(i,M) cin >> B[i];

    vector<ll> C = convolution(A,B);
    rep(i,N + M - 1) cout << C[i] << ' ';
    cout << '\n';
    return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<string> a(n),b(m);
  REP(i,n) cin >> a[i];
  REP(i,m) cin >> b[i];

  REP(i,n-m+1) REP(j,n-m+1) {
    bool match = true;
    REP(_i,m) {
      REP(_j,m) {
        if (a[i+_i][j+_j] != b[_i][_j]) match = false;
      }
      if (!match) break;
    }
    if (match) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s = in.readLine();
    int min = 1000;
    int size = 0;
    if(s.length()%3==0)
      size = s.length()/3*3-2;
    else if(s.length()%3==1)
      size = s.length()/3*3-1;
    else
      size = s.length()/3*3;
    
    for(int i=0; i<size; i = i+1){
      int num = Integer.parseInt(s.substring(i,i+3));
      min = Math.min(min,Math.abs(753-num));
    }
    System.out.println(min);
  }
}

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

class Main{

    
    public static void solver(String[] grid, int H, int W){
        
        final long MOD = (long) 1e9+7;
        long[][] dp = new long[H][W];

        int initialVal = 1;
        for(int i = 0; i < H; i++){
            if(grid[i].charAt(0) == '#')
                initialVal = 0;
            dp[i][0] = initialVal;
        }
        initialVal = 1;
        for(int i = 0; i < W; i++){
            if(grid[0].charAt(i) == '#')
                initialVal = 0;
            dp[0][i] = initialVal;
        }

        for(int i = 1; i < H; i++){
            for(int j = 1; j < W; j++){
                long up = grid[i - 1].charAt(j) == '.' ? dp[i - 1][j]: 0;
                long left = grid[i].charAt(j - 1) == '.' ? dp[i][j - 1]: 0;
                dp[i][j] = (up + left) % MOD;
            }
        }
        System.out.println(dp[H - 1][W - 1]);        

    }

    public static void main(String[] args){
        
        Scanner in = new Scanner(System.in);
        int H = in.nextInt();
        int W = in.nextInt();
        in.nextLine();

        String[] grid = new String[H];
        for(int i = 0; i < H; i++){
            grid[i] = in.nextLine();
        }
        solver(grid, H, W); 
    }
}


Measured memory_bytes: 49620
<?php
fscanf(STDIN, "%d", $n);
for ($i = 1; $i <= $n; $i++) {
	fscanf(STDIN, "%s %d", $s, $p);
	$k = sprintf("%s%03d", $s, 100 - $p);
	$x[$k] = $i;
}
ksort($x);
echo implode("\n", $x);

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rrep1(i,n) for(ll i=n;i>=1;i--)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
vector<ll> divisor(ll x){vector<ll> div;for(ll i=1;i*i<=x;i++){if(x%i==0){div.pb(i);if(i*i!=x)div.pb(x/i);}}sort(div.bg,div.ed);return div;}
map<ll,ll> prime_factor(ll x){map<ll,ll> ret;ll tmp=x;for(ll i=2;i*i<=x;i++){while(tmp%i==0){ret[i]++;tmp/=i;}}if(tmp!=1) ret[tmp]++;return ret;}
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 main(){
	ll N; cin>>N;
	string s; cin>>s;
	if(s[0]!='B' || s[sz(s)-1]!='B'){
		cout<<0;
		return 0;
	}
	ll SIZE=0;//保留
	ll ans=1;
	rep(i,sz(s)){
		if(s[i]=='B'){
			if(SIZE%2==0) SIZE++;
			else{
				ans*=SIZE;
				ans%=MOD;
				SIZE--;
			}
		}
		else{
			if(SIZE%2==1) SIZE++;
			else{
				ans*=SIZE;
				ans%=MOD;
				SIZE--;
			}
		}
	}
	if(SIZE!=0){
		cout<<0;
	}
	else{
		rep1(i,N){
			ans*=i;
			ans%=MOD;
		}
		cout<<ans;
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d", &n);
	switch (n % 10)
	{
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		printf("hon\n");
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		printf("pon\n");
		break;
	case 3:
		printf("bon\n");
		break;
	}
	return 0;
}

Measured memory_bytes: 3668
import java.math.*

fun main(args: Array<String>) {
    val n = readInputLine().toInt()
    val ws = readInputLine().split(" ").map { it.toInt() }

    var l = 0
    var r = ws.sum()
    
    var ans = Int.MAX_VALUE
    
    for (i in 0 until n) {
        if (Math.abs(r - l) < ans) {
            ans = Math.abs(r - l)
        }
        
        l += ws[i]
        r -= ws[i]
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 36024
object Main extends App {
	val n = scala.io.StdIn.readInt
	val a = scala.io.StdIn.readLine.split(" ").map(_.toInt)

	var mapOdd  = Map[Int, Int]()
	var mapEven = Map[Int, Int]()

	for(i<-0 until n by 2){
		mapOdd.get(a(i)) match {
			case None    => mapOdd = mapOdd + (a(i)->1)
			case Some(z) => mapOdd = mapOdd.updated(a(i), z+1)
		}
	}

	for(i<-1 until n by 2){
		mapEven.get(a(i)) match {
			case None    => mapEven = mapEven + (a(i)->1)
			case Some(z) => mapEven = mapEven.updated(a(i), z+1)
		}
	}

	val odd  = mapOdd.toArray.sortBy(_._2).reverse
	val even = mapEven.toArray.sortBy(_._2).reverse

	val o1 = odd(0)._1
	val e1 = even(0)._1
	var o2 = -1
	var e2 = -1

	if(odd.size  >= 2) o2 = odd(1)._1
	if(even.size >= 2) e2 = even(1)._1

	if(o1 != e1) println(n - mapOdd.get(o1).get - mapEven.get(e1).get)
	else {
		val t1 = n - mapOdd.get(o1).get - mapEven.getOrElse(e2, 0)
		val t2 = n - mapOdd.getOrElse(o2, 0)- mapEven.get(e1).get
		println(math.min(t1, t2))
	}





} 


Measured memory_bytes: 68440
#include<stdio.h>
int selectionSort(int A[],int N){
    int i,j,t,sw=0,minj;
    for(i=0;i<N-1;i++){
        minj=i;
        for(j=i;j<N;j++){
            if(A[j]<A[minj])minj=j;}
         t=A[i];A[i]=A[minj];A[minj]=t;
         if(i!=minj)sw++;
        }
    return sw;
    }
    int main(){
    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: 2732
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;

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

  int ans;
  int h, m, s;
  h = a / 3600;
  m = a % 3600 / 60;
  s = a % 60;
  
  //cout << ans << endl;
  cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3104
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var D = parseInt(input[0].split(" ")[1]);
  input.shift();
  var X = input.map(i => i.split(" ").map(i => parseInt(i)));
  X.splice(N,X.length-N);
  var ans=0;
  for(var i = 0;i<N;i++){
    for(var j=i+1;j<N;j++){
      var sum=0;
      for(var k=0;k<D;k++){
        sum+=Math.pow(X[j][k]-X[i][k],2)
      }
      if(Math.sqrt(sum)==Math.floor(Math.sqrt(sum))){
        ans++;
      }
    }
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
/*
memo for solution
*/
#include <cstdlib> 
#include <numeric>
#include <cstring>
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <cmath> 
#include <climits> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <iomanip>
#include<sys/time.h>
using namespace std; 
double e_time(void){static struct timeval now;gettimeofday(&now, NULL);return (double)(now.tv_sec  + now.tv_usec/1000000.0);}
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
#define fe(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr != (c).end();itr++)
#define BITSHIFT(X)     ( (1<<(X)) )
#define CONTAIN(S,X) ( ((S)&BITSHIFT(X)) != 0)
typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 
typedef vector<int> vint;
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  
template<class T> T ceilUp(const T& a,const T& b){return (a+b-1)/b;}
const ll mod =   1000000009;
inline ll modadd(ll a,ll b){a %= mod;b %= mod;return (a+b)%mod;}
inline ll modsub(ll a,ll b){a %= mod;b %= mod;a-=b;a%=mod;if (a<0)a+=mod;return a;}
inline ll modmul(ll a,ll b){a %= mod;b %= mod;return (a*b)%mod;}
inline ll modeq(ll a,ll b,ll m){a = (a%m+m)%m; b = (b%m+m)%m;return a == b;}
//ll modpow(ll n,ll p){if (p == 0)return 1;if (p == 1)return n;ll ret=mypow(n,p/2);ret=ret*ret%mod;if (p&1)ret=ret*n%mod;return ret;}
//ll getinv(ll a){return mypow(a,mod-2);}
ll mypow(ll n,ll p){
  if (p == 0)return 1;
  if (p == 1)return n;
  ll ret=mypow(n,p/2);
  ret=ret*ret;
  if (p&1)ret=ret*n;
  return ret;
}


int main(){
  int r, d, x;
  cin >> r>> d>>x;
  rep(i,10){
    x = r * x - d;
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 256
using System;

namespace A
{
	class Program
	{
		static void Main(string[] args)
		{
			var line = Console.ReadLine();
			// var lineSplited = line.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);

			var D = Int32.Parse(line);

			switch (D) {
				case 22:
					Console.WriteLine("Christmas Eve Eve Eve");
					break;
				case 23:
					Console.WriteLine("Christmas Eve Eve");
					break;
				case 24:
					Console.WriteLine("Christmas Eve");
					break;
				case 25:
					Console.WriteLine("Christmas");
					break;
				default:
					break;
			}
		}
	}
}

Measured memory_bytes: 11092
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		for(int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if(i == 0 || i % 2 == 0) System.out.print(c);
		}

	}

}


Measured memory_bytes: 30924
t=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a=int(input())
print(t[a-1])

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int N,S;

int main() {
  while (cin >> N && N > 0) {
    int sum = 0, M = 0, m = 1e9;
    for (int i = 0; i < N; i++) {
      cin >> S;
      sum += S;
      if (M < S) M = S;
      if (m > S) m = S;
    }
    cout << (sum - M - m)/(N-2) << endl;
  }
}

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

using namespace std;

int main(){
    int x,y;
    char a[100];
    scanf("%d %d",&x,&y);
    for(int i=0;i<y+2;i++)  printf("#");
    printf("\n");
    for(int i=0;i<x;i++)
        for(int j=0;j<3;j++){
            if(j==0)    printf("#");
            else if(j==2)    printf("#\n");
            else {
                scanf("%s",a);
                printf("%s",a);
            }
        }
    for(int i=0;i<y+2;i++)  printf("#");
    printf("\n");
    return 0;
}


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

using namespace std;

namespace std {
template <>
class hash<pair<int64_t, int64_t>> {
 public:
  size_t operator()(const pair<int64_t, int64_t>& d) const {
    return hash<int64_t>()(d.first) + hash<int64_t>()(d.second);
  }
};
}  // namespace std

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

  int64_t h, w, n;
  cin >> h >> w >> n;
  unordered_map<pair<int64_t, int64_t>, int64_t> pieces;
  for (int64_t i = 0; i < n; ++i) {
    int64_t a, b;
    cin >> a >> b;
    for (int64_t x = 0; x < 3; ++x) {
      for (int64_t y = 0; y < 3; ++y) {
        auto p = make_pair(b - x, a - y);
        if (p.first < 1 || p.second < 1 || w - 2 < p.first || h - 2 < p.second) {
          continue;
        }
        pieces[p] += 1;
      }
    }
  }
  vector<int64_t> ans(10);
  int64_t whites = (w - 2) * (h - 2);
  for (auto& e : pieces) {
    ans[e.second]++;
  }
  for (auto& elm : ans) {
    whites -= elm;
  }
  ans[0] = whites;
  for (auto& elm : ans) {
    cout << elm << "\n";
  }
  cout << "\n";
}


Measured memory_bytes: 50704
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int N,x = 0,maxi = 0;
string S;
cin >> N >> S;
for (int i = 0;i < N;i++) {
    if (S.at(i) == 'I') x += 1;
    else x -= 1;
    if (maxi < x) maxi = x;

}

cout << maxi << endl;


return 0;
}

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

#define ll long long
#define ull unsigned long long
#define mii make_pair<int, int>
#define mll make_pair<ll, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define all(v) (v).begin(), (v).end()

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

    string s, t;
    cin >> s >> t;
    ll c = 0;
    for (int i = 0; i < s.size(); ++i)
        if (s[i] != t[i])
            ++c;
    cout << c << '\n';
}

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

ll calc(int x,int y){
  ll cnt = y/x;
  return (x+y)*cnt/2;
}
int main(){
  int n;
  cin >> n;
  unsigned long long ans = 0;
  rep(i,n+1,1){
  ans += calc(i,(n/i)*i);
  //cout << ans << endl;
  }
  cout << ans << endl;
}

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

int main(){
	int N,W;
	int v[100],w[100];
	
	cin >> N >> W;
	for(int i=0; i<N; ++i){ 
        cin >> v[i] >> w[i];
    }

	int dp[101][10001]={0};
	
	for(int i=0; i<N; ++i){
		for(int j=0; j<=W; ++j){
			if(j<w[i]){
                dp[i+1][j] = dp[i][j];
            }
            else{
                dp[i+1][j] = max( dp[i+1][j-w[i]]+v[i], dp[i][j] );
            } 
		}
	}

	cout << dp[N][W] << endl;
}


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

int main() {
    bool N = false, W = false, S = false, E = false;

    char c;
    while(std::cin >> c) {
        if(c == 'N')       N = true;
        else if (c == 'W') W = true;
        else if (c == 'S') S = true;
        else if (c == 'E') E = true;
    }

    bool NS = (!N && !S) || (N && S);
    bool WE = (!W && !E) || (W && E);
    std::cout << (NS && WE ? "Yes" : "No") << std::endl;
}

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

using namespace std;

#define int int64_t

void fail()
{
    cout << -1 << endl;
    exit(0);
}

signed main()
{
    // freopen("input.txt", "r", stdin);
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    int n;
    cin >> n;
    int a[n][n];
    vector<int> A, B, C;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
        {
            cin >> a[i][j];
            A.push_back(i);
            B.push_back(j);
            C.push_back(a[i][j]);
        }
    bool use[n][n] = {0};
    for(int k  = 0; k < n; k++)
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                if(a[i][j] > a[i][k] + a[k][j])
                    fail();
                else if(j != k && i != k && a[i][j] == a[i][k] + a[k][j])
                    use[i][j] = 1;
    int ans = 0;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < i; j++)
            ans += !use[i][j] * a[i][j];
    cout << ans << endl;
    return 0;
}


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

struct edge{
    int to;
    long long int weight;

    /* initialize */
    edge(int t, long long int w) : to(t), weight(w) {}
};

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

    vector<vector<edge>> graph(n);
    for (int i=0; i<n-1; i++) {
        long long int u, v, w;
        cin >> u >> v >> w;
        u -= 1;
        v -= 1;
        graph[u].push_back(edge(v, w));
        graph[v].push_back(edge(u, w));
    }

    vector<int> depth(n,0);
    queue<int> que;

    vector<int> color(n,0);

    // root
    depth[0] = 1;
    que.push(0);

    while(!que.empty()){
        int current = que.front();
        que.pop();

        for(edge adjacent : graph[current]){
            if(depth[adjacent.to]!=0) continue;// already visited

            if(adjacent.weight % 2 == 0){
                color[adjacent.to] = color[current];
            }else if(adjacent.weight % 2 == 1){
                color[adjacent.to] = color[current] + 1;
            }

            que.push(adjacent.to);
            depth[adjacent.to] = depth[current] + 1;
        }
    }

    for(int i=0; i<n; i++){
        cout << color[i] % 2 << endl;
    }
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    for (int i = 0; i < N; i++) cin >> P[i];
    for (int i = 0; i < N; i++) cin >> Q[i];

    vector<int> v;
    for (int i = 1; i <= N; i++) v.push_back(i);
    int cnt = 0, a, b;
    do {
        cnt++;
        bool check = true;
        for (int i = 0; i < N; i++) {
            if (P[i] != v[i]) check = false;
        }
        if (check) a = cnt;
        check = true;
        for (int i = 0; i < N; i++) {
            if (Q[i] != v[i]) check = false;
        }
        if (check) b = cnt;
    } while (next_permutation(v.begin(), v.end()));

    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

void swap (long long int *x, long long int *y) {
  long long int temp;    

  temp = *x;
  *x = *y;
  *y = temp;
}

int partition (long long int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
     if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);

  return j;
}

void quick_sort (long long int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);
    quick_sort(array, pivot+1, right);
  }
}

int main() {
    int N, K;
    scanf("%d %d", &N, &K);

    long long int H[N];
    int i, j;
    for(i = 0; i < N; i++) {
        scanf("%lld", &H[i]);
    }    

    quick_sort(H, 0, N - 1);

    long long count = 0; 
    for(i = 0; i < N - K; i++) {
        count += H[i];
    }

    printf("%lld", count);
    return 0;
}

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

ll N, L;
vector<pair<ll, ll>> rl, lr;

signed main() {

    cin >> N >> L;

    set<ll> st;

    REP(i, N) {
        ll l, r;
        cin >> l >> r;
        rl.emplace_back(make_pair(-r, l));
        st.insert(l);
        st.insert(r);
        lr.emplace_back(make_pair(l, r));
    }

    sort(rl.begin(), rl.end());

    int res = 0;
    int p = -1, q = -1, tmp = -1;
    REP(i, N) {
        // cerr << i << " : " << rl[i].second << ' ' << -rl[i].first << endl;
        int l = rl[i].second;
        int r = -rl[i].first;
        if (i == 0) {
            ++res;
            p = l;
            q = r;
        } else {
            if (r < p) {
                ++res;
                p = tmp;
                tmp = l;
            } else {
                if (tmp == -1) tmp = l;
                else {
                    tmp = min(tmp, l);
                }
            }
        }
        // cerr << i << ' ' << p << ' ' << q << endl;
    }
    if (tmp != -1 and p != 0) {
    // if (tmp < p) {
        ++res;
    }

    map<ll, ll> mp;
    int idx = 0;
    for (auto& e: st) {
        mp[e] = idx++;
    }

    vector<int> imos(3 * N, 0);
    for (int i = 0; i < N; ++i) {
        pair<ll, ll> p = lr[i];
        ll l = mp[p.first], r = mp[p.second];
        imos[l]++; imos[r]--;
    }
    REP(i, 3 * N - 1) {
        imos[i + 1] += imos[i];
    }
    idx = 0;
    ll mn = -1;
    while (true) {
        if (imos[idx] == 0) break;
        if (mn == -1) mn = imos[idx];
        else {
            mn = min<ll>(mn, imos[idx]);
        }
        // cerr << zidx << ' ' << imos[idx] << endl;
        idx++;
    }
// cerr << endl;
    cout << res << ' ' << N - mn + 1 << endl;

}


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

int main(void){
    int h,w;
    int i,j;
    char chara[100];
    int flug;

    scanf("%d %d",&h,&w);

    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            scanf("%s",chara);
            if(strcmp(chara,"snuke")==0){
                printf("%c%d\n",65+j,i+1);
            }
        }
    }



    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int a1,a2,a3;
	cin >> a1 >> a2 >> a3;
	if(a1+a2+a3 >= 22)cout << "bust" << "\n";
	else cout << "win" << "\n";
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k, s;
	cin >> k >> s;
	int ans = 0;
	for(int x = 0; x <= k; x++){
		for(int y = 0; y <= k; y++){
			int z = s - x - y;
			if(0 <= z && z <= k) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[3][3],b[3][3]={0};
int main()
{
	int i,j,c;
	for(i=0;i<3;i++)for(j=0;j<3;j++)cin>>a[i][j];
	int n;cin>>n;
	while(n--)
	{
		scanf("%d",&c);
		for(i=0;i<3;i++)
			for(j=0;j<3;j++)
				if(a[i][j]==c)
					{b[i][j]=1;goto loop;}
		loop: ;
	}
	for(i=0;i<3;i++)if(b[i][0]&&b[i][1]&&b[i][2])goto l2;
	for(i=0;i<3;i++)if(b[0][i]&&b[1][i]&&b[2][i])goto l2;
	if(b[0][0]&&b[1][1]&&b[2][2])goto l2;
	if(b[0][2]&&b[1][1]&&b[2][0])goto l2;
	cout<<"No";return 0;
	l2:cout<<"Yes";
	return 0; 
} 

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


int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    if(n%3!=0){
        if(a[n-1]==0) cout << "Yes" << endl; 
        else cout << "No" << endl;
        return 0;
    }
    int t = n/3;
    if(a[0]==a[t-1] && a[t]==a[2*t-1]&&a[2*t]==a[n-1]) {
        int b = a[0];
        int c = a[t];
        int d = a[2*t];
        int e = b^c;
        if(d==e) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else cout << "No" << endl;
    return 0;
}


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

int k;
bool vis[200000];
pair<int,int>p;
deque<pair<int,int>>q;

int main()
{
	cin>>k;
	q.push_front(make_pair(1,0));
	while(q.size())
	{
		p=q.front();
		q.pop_front();
		if(vis[p.first])
			continue;
		vis[p.first]=1;
		if(p.first==0)
		{
			cout<<p.second+1;
			return 0;
		}
		q.push_back(make_pair((p.first+1)%k,p.second+1));
		q.push_front(make_pair((p.first*10)%k,p.second));
	}
}

Measured memory_bytes: 1152
#include<stdio.h>
int main()
{
	int m,f,b;
	scanf("%d %d %d",&m,&f,&b);
	if(m>=b){
		printf("0\n");
	}
	else if(f>=b){
		printf("%d\n",b-m);
	}
	else if(m+f>=b){
		printf("%d\n",b-m);
	}
	else printf("NA\n");
	return 0;
}


Measured memory_bytes: 2692
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    vector<int> arr(n+1);
    vector<int> b(n+1,0);
    FOR(i,1,n+1)
        cin >> arr[i];
    int ind;
    int cnt;
    for(int i=n;i>0;i--)
    {
        ind=2*i;
        cnt=0;
        while(ind<=n)
        {
            cnt+=b[ind];
            ind+=i;
        }
        if(arr[i]==0)
        {
            if(cnt%2!=0)
                b[i]=1;
        }
        if(arr[i]==1)
        {
            if(cnt%2==0)
                b[i]=1;
        }
    } 
    int sum=0;
    FOR(i,1,n+1)
        sum+=b[i];
    cout << sum << endl;
    FOR(i,1,n+1)
    {
        if(b[i])
            cout << i << " ";
    }

    return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;  cin >> n >> k;
    vector<int> x(n);
    rep(i, n) {
      cin >> x[i];
    }
    int ans = Inf;
    rep(i, n - k + 1) {
      int d = min(abs(x[i]) + abs(x[i + k - 1] - x[i]), abs(x[i + k - 1]) + abs(x[i + k - 1] - x[i]));
      ans = min(ans, d);
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int in_num = Integer.parseInt(sc.next());
        int[] l = new int[in_num];
        for(int i = 0;i < in_num ; i++){
            l[i] = Integer.parseInt(sc.next());
        }
        int count = 0;
        int mi = Integer.MAX_VALUE;
        for(int i = 0;i < in_num ; i++){
            if(l[i] <= mi){
                count++;
                mi = l[i];
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 49976
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int main(){
  long int N,x; cin >> N >> x;
  long int a[N]; REP(i,N){cin>>a[i];}
  sort(a,a+N);
  long int r = 0;
  long int okasi = x;
  while(r<N){
    okasi -= a[r];
    if(okasi>=0){r++;}
    else{break;}
  }
  if(okasi>0){r--;}
  cout << r << "\n";
}

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

int main() {
	static int H[100000];
	int n;
	int cnt = 0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> H[i];
	}

	int j = 0;
	int max = 0;

	while (j < n) {
		for (int k = 0; k < n - j - 1; k++) {
			if (H[j + k] >= H[j + k + 1]) {
				cnt++;
			}
			else {
				break;
			}
		}

		if (cnt > max) {
			max = cnt;
		}

		j += cnt + 1;
		cnt = 0;
	}

	cout << max << "\n";

	return 0;
}


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

int main(){
    string str;
    cin >> str;

    vector<int> num(2);
    for (int i = 0; i < str.length(); i++)
        if (str[i] == 'A')
            num[0]++;
        else
            num[1]++;

    if (num[0] && num[1])
        cout << "Yes";
    else
        cout << "No";
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define FD(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define pii pair<int,int>
#define reset(x,y) memset(x, y,sizeof(x))
#define MIN(x,y) if (x > (y)) x = (y)
#define MAX(x,y) if (x < (y)) x = (y)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define EL putchar('\n');
#define mod 1e9+7
#define oo 1000006
int read()
{
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
void write(int x)
{
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}
int n;
int a[oo];
int f[oo];
void ReadInPut()
{
    n=read();
    F(i,1,n)a[i]=read();
}
void Solve()
{
    FD(i,n-1,1)
    {
        f[i]=f[i+1]+abs(a[i]-a[i+1]);
        if(i!=n-1)
        {
            MIN(f[i],f[i+2]+abs(a[i]-a[i+2]));
        }
    }
    cout<<f[1];
}
main()
{
//    freopen("t.INP","r",stdin);
  //  freopen(".OUT","w",stdout);
    int sotest=1;
    //cin>>sotest;
    for(int i=1;i<=sotest;i++)
    {
        ReadInPut();
        Solve();
    }
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n,m;
    cin>>n>>m;
    if((n*500)>=m)
    {
        cout<<"Yes"<<nl;
    }
    else
    {
        cout<<"No"<<nl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <cmath>
#include <memory.h>
#include <iomanip>
#include <cassert>
using namespace std;

#define maxn 100002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<int, int> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n, nChild[maxn], par[maxn];
vector<int> a[maxn];

int fixRoot(int u) {
    nChild[u] = 1;
    REP(i, a[u].sz()) {
        int v = a[u][i];
        if (v!=par[u]) {
            par[v] = u;
            nChild[u] += fixRoot(v);
        }
    }
    return nChild[u];
}

int main() {
    //freopen("snukegame.inp", "r", stdin);
    //freopen("", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    FOR(i, 1, n) {
        int u, v; cin >> u >> v;
        a[u].push_back(v);
        a[v].push_back(u);
    }
    fixRoot(1);
    int u = n, cnt = -1;
    while (u!=1) {
        ++cnt;
        u = par[u];
    }
    u = n;
    FOR(i, 1, cnt/2) {
        u = par[u];
    }
    if (nChild[u]<n-nChild[u]) cout << "Fennec";
    else cout << "Snuke";
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007
//#define harmonic(n) 0.57721566490153286l+log(n)

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; ///4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};///8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};///Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; ///Hexagonal Direction

inline int in() { int x; scanf("%d", &x); return x; }
inline ll inl() { ll x;scanf("%I64d",&x); return x;}
inline double ind() { double x;scanf("%lf",&x);return x;}

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline bool isLeapYear(ll year) { return (year%400==0) || (year%4==0 && year%100!=0); }
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

int gcd(int a,int b) { return b==0 ? a:gcd(b,a%b);}
int power( int x, int n)
{
    if(n==0)return 1;
    else if(n%2==0)
    {
        int y=power(x,n/2);
        return y*y;
    }
    else
        return x*power(x,n-1);
}
//abcdefghijklmnopqrstuvwxyz//
int x,y;
int f1,f2;
main()
{
    #ifdef CP
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif // CP
    f1=0,f2=0;
    int n=in();
    for(int i=0;i<n;i++)
    {
        x=in(),y=in();
        if(x==y)
        {
            if(f1==1&&f2==1)
            {
                printf("Yes\n");
                return 0;
            }
            if(f1==1)
            {
                f2=1;
            }
            f1=1;
        }
        else
        {
            f1=0,f2=0;
        }

    }
    printf("No\n");
    return 0;
}




Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <string>
#include <map>
#include <list>
using namespace std;

// int main() {
//   int n;
//   cin >> n;
//   string w[n],s[n];
//   bool can=true;
//   for(int i = 0; i < n; ++i){
//     cin >> w[i];
//     s[i]=w[i];
//     if(i != n-1){
//       if(w[i].back() != w[i+1].front()){
//         can=false;
//         break;
//       }
//     }
//   }
//   for(int i = 0; i < n; ++i){
//     for(int j = 0; j < n; ++j){
//       if(i != j){
//         if(s[j]==w[i]){
//           can=false;
//           break;
//         }
//       }
//     }
//   }
//   if(can){
//     cout << "Yes" << endl;
//   }else{
//     cout << "No" << endl;
//   }
// }

bool solve ( const vector < string >& W ) {
  const int n = W . size ();
  // condition 1
  for ( int i = 0; i < n -1; ++ i ) {
    if ( W [ i ]. back () != W [ i +1]. front ()) {
      return false ;
    }
  }
  // condition 2
  for ( int i = 0; i < n ; ++ i ) {
    for ( int j = i +1; j < n ; ++ j ) {
      if ( W [ i ] == W [ j ]) {
        return false ;
      }
    }
  }
  return true ;
}

vector < string > input () {
int n; cin >> n ;
vector < string > W ( n );
for ( int i = 0; i < n ; ++ i ) {
  cin >> W [ i ];
}
  return W ;
}

int main () {
  const vector < string > W = input ();
  if ( solve ( W )) {
    cout << " Yes " << endl ;
  }
  else {
    cout << "No" << endl ;
  }
}

Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    ll h, w;
    cin >> h >> w;
 
    ll s = h*w;
 
    ll hans = 1000000000000;
    for(int i = 1; i < h; i++){
        ll s1 = i*w;
        ll s2, s3;
        if(w%2 == 0)s2 = s3 = (h-i)*(w/2);
        else {
            s2 = (h-i)*(w/2);
            s3 = (h-i)*(w/2 + 1);
        }
        // cout << "s1:" << s1 << " s2:" << s2 << " s3:" << s3 << endl;
        hans = min(hans, (max(s1, max(s2, s3))-min(s1, min(s2, s3))));
        if((h-i)%2 == 0)s2 = s3 = ((h-i)/2)*w;
        else {
            s2= ((h-i)/2)*w;
            s3= ((h-i)/2 + 1)*w;
        }
        hans = min(hans, (max(s1, max(s2, s3))-min(s1, min(s2, s3))));
    }
    ll wans = 1000000000000;
    for(int i = 1; i < w; i++){
        ll s1 = i*h;
        ll s2, s3;
        if(h%2 == 0)s2 = s3 = (w-i)*(h/2);
        else {
            s2 = (w-i)*(h/2);
            s3 = (w-i)*(h/2 + 1);
        }
        // cout << "s1:" << s1 << " s2:" << s2 << " s3:" << s3 << endl;
        wans = min(wans, (max(s1, max(s2, s3))-min(s1, min(s2, s3))));
        if((w-i)%2 == 0)s2 = s3 = ((w-i)/2)*h;
        else {
            s2= ((w-i)/2)*h;
            s3= ((w-i)/2 + 1)*h;
        }
        wans = min(wans, (max(s1, max(s2, s3))-min(s1, min(s2, s3))));
    }
 
    cout << min(hans, wans);
}

Measured memory_bytes: 256