akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;

const int N_MAX = 1e5;
int n;
long m;
int a[N_MAX];
long b[N_MAX];

bool C(long x) {
    long s = 0;
    for (int i = n - 1; i >= 0; i--) {
        int j = lower_bound(a, a + n, x, [&](const int &i1, const int &i2) {
            return i1 + a[i] < i2;
        }) - a;
        s += n - j;
    }
    return s >= m;
} 

int main() {
    scanf("%d %ld", &n, &m);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    sort(a, a + n);
    b[n - 1] = a[n - 1];
    for (int i = n - 2; i >= 0; i--) b[i] = b[i + 1] + a[i];

    int d;
    for (int ra = 2 * a[n - 1] + 1, la = 1; ;) {
        int mid = (la + ra) / 2;
        if (!C(mid)) ra = mid;
        else la = mid;
        if (ra - la == 1) {
            d = la;
            break;
        }
    }

    long ans = 0, sum = 0;
    for (int i = n - 1; i >= 0; i--) {
        int j = lower_bound(a, a + n, d, [&](const int &i1, const int &i2) {
            return i1 + a[i] < i2;
        }) - a;
        if (j == n) break;
        sum += n - j;
        ans += static_cast<long>(a[i]) * (n - j) + b[j];
    }
    ans -= (sum - m) * d;
    printf("%ld\n", ans);
    return 0;
}


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

int main()
{

int brojN;
cin >> brojN;

int brojA;
cin >> brojA;

int brojB;
cin >> brojB;

int (brojN * brojA);
if ((brojN * brojA) > brojB){
	cout << (brojB);
}
else {
	cout << (brojN * brojA);
}

}

Measured memory_bytes: 256
using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading;
using System.IO;

namespace Sweet
{
    class Program
    {
        static void Main(string[] args)
        {
            
            TextReader input;
            //TextWriter output;
            StreamWriter writer = null;

            /*output = Console.Out;*/
            if (args.Length == 0)
            {
                // ???????????????????¨??????\???
                input = Console.In;
            }
            else
            {
                // Redirect standard input from the console to the input file.
                //Console.SetIn(new StreamReader(args[0]));
                input = new StreamReader(args[0],
                          System.Text.Encoding.GetEncoding("Shift_JIS"));
                if (args.Length == 2)
                {
                    // Attempt to open output file.
                    writer = new StreamWriter(args[1]);
                    // Redirect standard output from the console to the output file.
                    Console.SetOut(writer);

                }
            }
            Sweep(input);
            input.Dispose();
            if (writer != null)
                writer.Close();
            //Console.WriteLine("{0}", Sweep(a, b));
            Console.ReadLine();
        }
        
       private static int Sweep(TextReader tr)
       {
            Int32 a, r, c; short n;
            string str = tr.ReadLine();
      
            a = str.IndexOf(" ");
            r = int.Parse(str.Substring(0, a));
            c = int.Parse(str.Substring(a));
                Int32[,] ary = new Int32[r+1,c+1];
            for (int i = 0; i < r; i++)
            {
                str = tr.ReadLine();
                for (int j = 0; j < c; j++)
                {
                    a = str.IndexOf(" ");
                    if (0 <= a)
                        n = short.Parse(str.Substring(0, a));
                    else
                        n = short.Parse(str);
                    ary[i, j] = n;
                    ary[i, c] += n;
                    ary[r, j] += n;
                    str = str.Substring(a + 1);
                }
            }
            for (int i = 0; i < c; i++)
                 ary[r, c] += ary[r, i];
            for (int i=0; i<=r; i++)
            {
                 for (int j = 0; j <= c; j++)
                 {
                      Console.Write("{0}", ary[i, j]);
                      if (j != c)
                          Console.Write(" ");
                      else
                          Console.WriteLine();
                 }
            }
            return 0;
       }/*
       private static int Sweep(int a, int b)
       {
       }*/
    }
}

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

    
int main()
{
    string s;
    cin>>s;
    char pr=s[0];
    for(int i=1;i<s.size();i++){ 
        if(s[i]!=pr) pr=s[i];
        else { 
            cout<<"Bad"<<endl; 
            return 0;
        } 
    } 
    cout<<"Good"<<endl; 

    return 0;
}


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


def main():
    # n = int(input())
    a = [[0] * 3 for i in range(3)]
    a[0] = list(map(int, input().split()))
    a[1] = list(map(int, input().split()))
    a[2] = list(map(int, input().split()))

    # print(a)

    for i in range(3):
        minum = min(a[i])
        for j in range(3):
            a[i][j] = a[i][j] - minum
    # print(a)

    ans = True

    for i in range(3):
        if a[0][i] != a[1][i] or a[1][i] != a[2][i]:
            ans = False
    # print(ans)

    if ans:
        print('Yes')
    else:
        print('No')


main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,M,K;
    cin>>N>>M>>K;
    int A[N],B[M];
    int am[N+1]{};
    int bm[M+1]{};
    am[0]=0;
    bm[0]=0;
    rep(i,N){
        cin>>A[i];
        am[i+1]=am[i]+A[i];
    }
    rep(i,M){
        cin>>B[i];
        bm[i+1]=bm[i]+B[i];
    }
    int ans=0;
    rep(i,N+1){
        if(am[i]>K)break;
        for(int j=max(0LL,ans-i-1);j<M+1;j++){
            if(am[i]+bm[j]<=K){
                ans=max(ans,i+j);
            }else break;
        }
    }
    cout << ans << endl;




    



}


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

int main() {
  int H,W;
  cin >> H >> W;
  
  int i;
  vector<string> str(H);
  for(i = 0;i<H;i++){
  	cin >> str.at(i);
  }
  
  for(i = 0; i<W+2 ; i++){
  	cout << '#';
  }
  cout << endl;
  for(i = 0;i<H;i++){
  	cout << '#' << str.at(i) << '#' << endl;
  }
    for(i = 0; i<W+2 ; i++){
  	cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 256
int main(void){
  int N,T,i,ans=10000;
  scanf("%d %d",&N,&T);
  int c[N],t[N];
  for(i=0;i<N;i++){
    scanf("%d %d",&c[i],&t[i]);
  }
  for(i=0;i<N;i++){
    if(c[i]<=ans && t[i]<=T){
      ans=c[i];
    }
  }
  if(ans==10000){
    printf("TLE");
  }
  else{
    printf("%d",ans);
  }
  return 0;
}


Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n, x, y := nextInt(), nextInt(), nextInt()
	x--
	y--

	ans := make([]int, n)

	for i := 0; i < n; i++ {
		for j := (i + 1); j < n; j++ {

			distance := j - i
			if !((i >= y) || (j <= x)) {
				shortcut := abs(x-i) + abs(y-j) + 1
				if shortcut < distance {
					distance = shortcut
				}
			}

			ans[distance]++
		}
	}

	for i := 1; i < n; i++ {
		fmt.Println(ans[i])
	}
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func nextInt() int {
	i, _ := strconv.Atoi(nextText())
	return i
}

func nextText() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 640
# -*- coding utf-8 -*-
import math

MOD = 10 ** 9 + 7
n = int(input())

ans = 10**13
for x in range(1, int(math.sqrt(n)) + 1):
    if n % x == 0:
        y = n // x
        ans = min(ans, x + y - 2)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int M = 1e9+7;
#define F(i,a,b) for(int i=a;i<b;i++)


int main() {
  int n,k;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin>>n>>k;
  vector<ll> dp(k+1,0);
  vector<ll>prefix(k+1,0);
  prefix[0] = 1;
  int maxcandies;
  for(int child=0;child<=n;child++) dp[0] = 1;
  for(int candies=1;candies<=k;candies++) prefix[candies] += prefix[candies-1];
  for(int child=1;child<=n;child++)
  {
    cin>>maxcandies;
    for(int candies=1;candies<=k;candies++)
    {
      ll left=0;
      if(candies-maxcandies>0)
        left = prefix[candies-maxcandies-1];
      dp[candies] = (prefix[candies] - left+M)%M;
    }
    for(int candies=1;candies<=k;candies++)
    {
        prefix[candies] = (prefix[candies-1] + dp[candies])%M; 
    }
  }
  
  cout<<dp[k];
  return 0;
}


Measured memory_bytes: 4772
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N = 0,M = 0,count = 0;
  cin >> N;
  vector<int>A(N);
  rep(i,N){
    cin >> A[i];
  }
  rep(i,N){
    M = A[i];
    if(i == A[M - 1] - 1 && M == A[i]){
      count++;
    }
  }
    cout << count / 2;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
  int h, n, i, j;
  int a[200001];
  
  scanf("%d %d", &h, &n);
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
    h -= a[i];
  }
  
  if(h <= 0) printf("Yes");
  else printf("No");
  
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cstdint>

using i64 = int64_t;
using i32 = int32_t;

void run() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    i32 n;
    std::cin >> n;
    const i64 m = 60;
    std::vector<i64> cnt(60, 0);
    for (i32 i = 0; i < n; ++i) {
        i64 a;
        std::cin >> a;
        for (i64 j = 0; j < m; ++j) {
            cnt.at(j) += (a >> j) & 1;
        }
    }
    const i64 mod = 1000000000 + 7;
    i64 ans = 0;
    for (i64 j = 0; j < m; ++j) {
        i64 c = cnt.at(j);
        ans = (ans + ((i64)1 << j) % mod * c % mod * (n - c)) % mod;
    }
    std::cout << ans << '\n';
}

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

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

typedef long long ll;
typedef unsigned long long ull;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

struct P{
  ll x,y,z;
  P(ll a,ll b,ll c):x(a),y(b),z(c){}
};
bool operator<(const P& a,const P& b){
  if(a.x!=b.x)return a.x < b.x;
  else if(a.y!=b.y)return a.y < b.y;
  else return a.z < b.z;
}

ll n;
ll x[2],y[2],z[2];
map<P,int> dist;
map<P,bool> vis;

ll calc(ll sx,ll sy,ll sz){
  queue<P> que;
  que.push(P(sx,sy,sz));
  dist.clear(); vis.clear();
  dist[P(sx,sy,sz)]=0;
  vis[P(sx,sy,sz)]=true;
  ll res=INF;
  while(que.size()){
    P p=que.front(); que.pop();
    {

      if(p.z!=z[1]&&!vis[P(n-1-p.y,p.x,p.z)]){ // xy
        dist[P(n-1-p.y,p.x,p.z)]=dist[p]+1;
        que.push(P(n-1-p.y,p.x,p.z));
        vis[P(n-1-p.y,p.x,p.z)]=true;
      }
      if(p.z!=z[1]&&!vis[P(p.y,n-1-p.x,p.z)]){ // xy
        dist[P(p.y,n-1-p.x,p.z)]=dist[p]+1;
        que.push(P(p.y,n-1-p.x,p.z));
        vis[P(p.y,n-1-p.x,p.z)]=true;
      }

      if(p.y!=y[1]&&!vis[P(n-1-p.z,p.y,p.x)]){ // xz
        dist[P(n-1-p.z,p.y,p.x)]=dist[p]+1;
        que.push(P(n-1-p.z,p.y,p.x));
        vis[P(n-1-p.z,p.y,p.x)]=true;
      }
      if(p.y!=y[1]&&!vis[P(p.z,p.y,n-1-p.x)]){ // xz
        dist[P(p.z,p.y,n-1-p.x)]=dist[p]+1;
        que.push(P(p.z,p.y,n-1-p.x));
        vis[P(p.z,p.y,n-1-p.x)]=true;
      }

      if(p.x!=x[1]&&!vis[P(p.x,n-1-p.z,p.y)]){ // yz
        dist[P(p.x,n-1-p.z,p.y)]=dist[p]+1;
        que.push(P(p.x,n-1-p.z,p.y));
        vis[P(p.x,n-1-p.z,p.y)]=true;
      }
      if(p.x!=x[1]&&!vis[P(p.x,p.z,n-1-p.y)]){ // yz
        dist[P(p.x,p.z,n-1-p.y)]=dist[p]+1;
        que.push(P(p.x,p.z,n-1-p.y));
        vis[P(p.x,p.z,n-1-p.y)]=true;
      }
    }
  }
  for(auto p : dist){
    minch(res,abs(p.fi.x-x[1])+abs(p.fi.y-y[1])+abs(p.fi.z-z[1])+p.se);
  }
  return res;
}

int main(){
  cin>>n;
  rep(i,2){
    cin>>x[i]>>y[i]>>z[i];
  }
  ll res=INF;
  for(ll xx=x[0]-1;xx<=x[0]+1;xx++){
    for(ll yy=y[0]-1;yy<=y[0]+1;yy++){
      for(ll zz=z[0]-1;zz<=z[0]+1;zz++){
        if(xx<0||xx>=n||yy<0||yy>=n||zz<0||zz>=n)continue;
        //dbg(calc(xx,yy,zz)); dbg(xx); dbg(yy); dbg(zz);
        minch(res,calc(xx,yy,zz)+abs(xx-x[0])+abs(yy-y[0])+abs(zz-z[0]));
      }
    }
  }
  cout<<res<<endl;
  return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        v.push_back(a);
    }

    int q;
    cin >> q;
    for (int l = 0; l < q; ++l) {
        int m;
        cin >> m;

        vector<bool> dp(m + 1);
        for (int i : v) {
            vector<int> pos;
            for (int j = 0; j < dp.size(); ++j) {
                if (dp[j]) {
                    pos.push_back(j);
                    pos.push_back(j + i);
                }
                else if (i == j) {
                    pos.push_back(j);
                }
            }
            dp = vector<bool>(m + 1);
            for (int j : pos) {
                if (j < dp.size()) {
                    dp[j] = true;
                }
            }
        }

        if (dp[m]) {
            cout << "yes" << endl;
        }
        else {
            cout << "no" << endl;
        }
    }
}

Measured memory_bytes: 3144
#include<stdio.h>
#include<string.h>
int main(){
	char a[10];
	while(scanf("%s",a)!=EOF){
		int flag=0;
		if(a[0]==a[1]&&a[1]==a[2])flag=1;
		if(a[1]==a[2]&&a[2]==a[3])flag=1;
		if(a[0]==a[1]&&a[1]==a[2]&&a[2]==a[3])flag=1;
		if(flag)printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;

bool judge(string s) {
	int n = s.length();
	rep(i, 0, n / 2) {
		if (s[i] != s[n - 1 - i]) {
			return false;
		}
	}
	true;
}

int main(void)
{
	string S; cin >> S;
	string left = S.substr(0, S.length() / 2);
	string right = S.substr(S.length() / 2 + 1, S.length() / 2);
	bool flag1 = judge(S), flag2 = judge(left), flag3 = judge(right);
	if (flag1 && flag2 && flag3)cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}


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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b, int mod)
{
    int res = 1;

    while (b)
    {
        if (b & 1) res = (res * a) % mod;

        a = (a * a) % mod; 
        b >>= 1;
    }
    return res;
}

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

#define N 100010
#define MOD 1000000007

struct comp {
    bool operator() (const pair<int, int> a, const pair<int, int> b) const
    {
        return a.ss > b.ss;
    }
};

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int n, w;
    cin >> n >> w;

    pair<int, int> wv[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> wv[i].ff >> wv[i].ss;
    }

    vector<vector<int>> dp = vector<vector<int>> (2, vector<int>(w + 1, 0));

    dp[0][wv[0].ff] = wv[0].ss;

    for (int i = 1; i < n; ++i)
    {
        for (int j = 0; j <= w; ++j)
        {
            if (wv[i].ff <= j)
                dp[i % 2][j] = max(dp[(i - 1) % 2][j - wv[i].ff] + wv[i].ss, dp[(i - 1) % 2][j]);
            else
                dp[i % 2][j] = dp[(i - 1) % 2][j];
        }
    }

    cout << *max_element(dp[(n - 1) % 2].begin(), dp[(n - 1) % 2].end()); 
    return 0;
}

Measured memory_bytes: 5544
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

ll func(ll a, ll b) {
  if (a > b)
    swap(a, b);
  if (a == 0) {
    return 0;
  } else if (b % a == 0) {
    return (b * 2LL) - a;
  }
  return (2LL * (b / a) * a) + func(a, b % a);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, X;
  cin >> N >> X;
  cout << N + func(N - X, X) << endl;

  return 0;
}


Measured memory_bytes: 256
#ベルマンフォード法
#https://atcoder.jp/contests/abc061/submissions/6001032
N, M = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(M)]
INF = -float("inf")
dist = [INF]*N
dist[0] = 0
d_tmp = 0

for abci in abc: #
    if dist[abci[1] - 1] < dist[abci[0] - 1] + abci[2]:
         dist[abci[1] - 1] = dist[abci[0] - 1] + abci[2]

d_tmp = dist[-1]
for abci in abc:
    if dist[abci[0]-1] != INF and dist[abci[1] - 1] < dist[abci[0] - 1] + abci[2]:
         dist[abci[1] - 1] = dist[abci[0] - 1] + abci[2]    


print(dist[-1]) if d_tmp == dist[-1] else print("inf")

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  if((s[0]=='0'&&s[1]!='0') || (s[0]=='1'&&s[1]=='0') || (s[0]=='1'&&s[1]=='1') || (s[0]=='1'&&s[1]=='2')){
    if((s[2]=='0'&&s[3]!='0') || (s[2]=='1'&&s[3]=='0') || (s[2]=='1'&&s[3]=='1') || (s[2]=='1'&&s[3]=='2')){
      cout << "AMBIGUOUS" << endl;
    }else{
      cout << "MMYY" << endl;
    }
  }else{
    if((s[2]=='0'&&s[3]!='0') || (s[2]=='1'&&s[3]=='0') || (s[2]=='1'&&s[3]=='1') || (s[2]=='1'&&s[3]=='2')){
      cout << "YYMM" << endl;
    }else{
      cout << "NA" << endl;
    }
  }
  return 0;
}

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

using namespace std;

const int mod = 1e9 + 7;
const int N = 105;

int n, h[N];
int p[N], l[N], r[N];
int f[N][2], sz[N], H[N], visit[N][N];
vector<int> G[N];

int binPow(int x, int y) {
	if (!y) return 1;
	int ret = binPow(x, y >> 1); 
	ret = 1LL * ret * ret % mod;
	if (y & 1) ret = 1LL * ret * x % mod; 
	return ret;
}

void dfs(int u) {
	int tmp = sz[u];
	f[u][0] = f[u][1] = 1;
	for (auto v : G[u]) {
		dfs(v), tmp -= sz[v];
		f[u][0] = 1LL * f[u][0] * f[v][0] % mod;
		f[u][1] = 1LL * f[u][1] * (2LL * f[v][0] + f[v][1]) % mod;
	}
	f[u][0] = 2 * f[u][0] % mod;
	f[u][1] = 1LL * f[u][1] * binPow(2, tmp) % mod;
	f[u][1] = (f[u][1] + mod - f[u][0]) % mod;
	f[u][0] = 1LL * f[u][0] * binPow(2, H[u] - 1) % mod;
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> h[i];
	for (int i = 1; i <= n; ++i) {
		l[i] = i;
		while (l[i] > 1 && h[l[i] - 1] >= h[i]) l[i] = l[l[i] - 1];
	}
	for (int i = n; i >= 1; --i) {
		r[i] = i;
		while (r[i] < n && h[r[i] + 1] >= h[i]) r[i] = r[r[i] + 1];
	}
	for (int i = 1; i <= n; ++i) p[i] = i;
	sort(p + 1, p + 1 + n, [&] (int x, int y) {
		return h[x] < h[y];
	});
	int cnt = 0;
	visit[1][n] = ++cnt, sz[1] = n, H[1] = h[p[1]];
	for (int i = 1; i <= n; ++i) {
		int L = l[p[i]], R = r[p[i]];
		if (visit[L][R]) continue;		
		visit[L][R] = ++cnt, sz[cnt] = R - L + 1;
		H[cnt] = h[p[i]] - max(h[L - 1], h[R + 1]);
		int par = 0;
		if (L > 1 && R < n) {
			if (h[L - 1] > h[R + 1]) par = visit[l[L - 1]][r[L - 1]];
			else par = visit[l[R + 1]][r[R + 1]];
		}
		else if (L > 1) par = visit[l[L - 1]][r[L - 1]];
		else par = visit[l[R + 1]][r[R + 1]];
		G[par].push_back(cnt);
		// cout << cnt << ' ' << par << ' ' << H[cnt] << ' ' << sz[cnt] << ' ' << L << ' ' << R << '\n';
	}
	dfs(1);
	// for (int i = 1; i <= cnt; ++i) cout << f[i][0] << ' ' << f[i][1] << '\n';
	cout << (f[1][0] + f[1][1]) % mod;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
typedef long long int ll;
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define m0(x) memset(x,0,sizeof(x))

int main(void){

	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b && b==c) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    unordered_map<string, int> umap;
    string ans = "Yes";
    string pre;
    cin >> pre;
    umap[pre]++;
    for (int i = 1; i < n; i++) {
        string w;
        cin >> w;

        if (pre.at(pre.length() - 1) != w.at(0)) {
            ans = "No";
        }

        if (umap[w] > 0) {
            ans = "No";
        }
        pre = w;
        umap[w]++;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
  int s,w;
  cin >> s >> w;
  
  if(s<=w)
  {
    cout << "unsafe" << endl;
  }
  else
  {
        cout << "safe" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <map>
 
using namespace std;

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

    int N;

    cin >> N;

    vector<pair<string, int>> test(N);
    vector<pair<string, int>> cities(N);

    for(int i = 0; i < N; i++)
    {
        string name;
        int point;

        cin >> name >> point;

        test[i] = make_pair(name, point);
        cities[i] = make_pair(name, point);
    }

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

    for(int k = 0; k < N; k++){
    for(int i = 0; i < N - 1; i++)
    {
        if(cities[i].first == cities[i + 1].first)
        {
            if(cities[i].second < cities[i + 1].second)
            {
                int past = cities[i].second;
                cities[i].second = cities[i + 1].second;
                cities[i + 1].second = past;
            }
        }
    }
    }

    for(int i = 0; i < N; i++)
    {
        int count = 0;
        for(int j = 0; j < N; j++)
        {
            count++;
            if(cities[i].first == test[j].first)
            {
                if(cities[i].second == test[j].second)
                {
                    cout << count << endl;
                    count = 0;
                    break;
                }
            }
        }
    }
}

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

int main() {
    char a[10];
    scanf ("%s", a);
    int sum = 0;

    for (int i = 0; a[i] != '\0'; i++) {
        sum += a[i] - '0';
    }

    if ( sum == 1)  cout << 10 << endl;
    else cout << sum << endl;
    return 0;
}


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

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        out.println(Math.max(Math.max(a*10+b+c, b*10+a+c), c*10+a+b));

        out.flush();

    }

    static class Toi {
        public int x;
        public int y;

        public Toi(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }

            if (this == obj) {
                return true;
            }

            if (this.getClass() != obj.getClass()) {
                return false;
            }

            Toi toi = (Toi) obj;
            return x == toi.x && y == toi.y;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

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

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

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define ff(i, c, n) for (ll i = c; i < n; i++)
#define fr(i, c, n) for (ll i = c; i >= n; --i)
#define INF 1e9 + 7

ll modpow(ll a, ll b, ll c)
{ //a^b%c in O(logb)
	ll res = 1;
	while (b > 0)
	{
		if (b & 1)
		{
			res = (res * a) % c;
		}
		a = (a * a) % c;
		b >>= 1;
	}
	return res;
}
ll modinv(ll m, ll n)
{ //modular inverse of n w.r.t m provided 1<=n<=(m-1) in O(logn) and m is prime
	ll inv[n + 1];
	inv[1] = 1;
	for (int i = 2; i < n + 1; ++i)
		inv[i] = (m - (m / i) * inv[m % i] % m) % m;
	return inv[n];
}

//a+b=a^b+2*(a&b)
int main()
{
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll x,y,z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <vector>
#include <queue>
#include <bitset>
#include <cmath>
#include <time.h>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <deque>
#include <iomanip>
#include <complex>
//#include <ext/rope>

using namespace std;
//using namespace __gnu_cxx;

//defines
typedef long long ll;
typedef long double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define fast_read cin.sync_with_stdio(0)
#define PREX(number) cout << fixed << setprecision(number)
#define nul point(0, 0)
#define random srand(time(NULL))
#define rand_int abs((rand() << 15) | rand())
#define str_to_int(stroka) atoi(stroka.c_str())
#define str_to_ll(stroka) atoll(stroka.c_str())
#define str_to_double(stroka) atof(stroka.c_str())
#define what_is(x) cerr << #x << " is " << x << endl
#define solve_system int number; cin >> number; forn(i, 0, number) solve()
#define solve_system_scanf int number; scanf("%d", &number); forn(i, 0, number) solve()

//easy functions
template< typename T >
T gcd(T a, T b) { return a ? gcd(b % a, a) : b; }
template< typename T >
T lcm(T a, T b) { return (a / gcd(a, b)) * b; }
bool is_down(char x) { return ('a' <= x && x <= 'z'); }
bool is_upper(char x) { return ('A' <= x && x <= 'Z'); }
bool is_digit(char x) { return ('0' <= x && x <= '9'); }

//constants
const ld pi = 3.141592653589793238462643383279;
const ld log23 = 1.58496250072115618145373894394781;
const ld eps = 1e-8;
const ld zero = 0;
const ll INF = 1e18;
const int COUT = 30;
const int prost = 239;
const ll prost64 = 239;
const int two = 2;
const ll sr = 31;
const int MOD = 1e9 + 7;
const int BIG = 2 * 1e9 + 1;
const int alf = 26;
const int MAX_N = 101;
const int MAX_M = (1 << 20);
const int MAX_T = (1 << 22);
const int BLOCK = trunc(sqrt(MAX_N)) + 1;
const int MAX_LOG = 18;
const int km = (1 << 18);
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int bit_max = 32;
const int dig = 10;
const string str_alf = "abcdefghijklmnopqrstuvwxyz";
const string str_alf_big = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int bt = 31;

// Code starts here

int main()
{   /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif /**/
    fast_read;
    int n, a, b;
    cin >> n >> a >> b;
    if ((b - a) % 2 == 0)
        cout << "Alice";
    else
        cout << "Borys";
    return 0;
}


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

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

    map<int, int> ps;
    auto decompositPrime = [&](int n, map<int, int> &mp) {
        int a = 2;
        while (n >= a * a) {
            if (n % a == 0) {
                mp[a]++;
                n /= a;
            } else {
                a++;
            }
        }
        if (n > 1) mp[n]++;
    };

    rep(i, N + 1) {
        decompositPrime(i, ps);
    }

    int over74 = 0;
    int over24 = 0;
    int over14 = 0;
    int over4  = 0;
    int over2  = 0;
    for (auto e : ps) {
        if (e.second >= 74) {
            over74++;
            over24++;
            over14++;
            over4++;
            over2++;
        } else if (e.second >= 24) {
            over24++;
            over14++;
            over4++;
            over2++;
        } else if (e.second >= 14) {
            over14++;
            over4++;
            over2++;
        } else if (e.second >= 4) {
            over4++;
            over2++;
        } else if (e.second >= 2)
            over2++;
    }
    cout << over74 + over24 * (over2 - 1) + over14 * (over4 - 1)
                + over4 * (over4 - 1) * (over2 - 2) / 2
         << endl;
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi A1(n);
  Vi A2(n);
  VIN(A1)
  VIN(A2)
  FOR(i,0,n-1){
    int sum = 0;
    REP(j,n){
      if(j < i) {
        sum += A1[j];
      } else if (j == i) {
        sum += (A1[j] + A2[j]);
      } else {
        sum += A2[j];
      }
    }
    z = max(z,sum);
  }
  if(n!=1) OUT(z);
  else OUT(A1[0]+A2[0]);
}

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

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7; // change if needed

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

const int MAX_N = 2e5 + 5;

Modint fact [MAX_N];
Modint invfact [MAX_N];

vector<int> adj [MAX_N];

int sz [MAX_N];
void calc_sz (int u, int p) {
  sz[u] = 1;
  for (int nxt : adj[u]) {
    if (nxt != p) {
      calc_sz(nxt, u);
      sz[u] += sz[nxt];
    }
  }
}

Modint dp [MAX_N];
void calc_dp (int u, int p) {
  dp[u] = fact[sz[u] - 1];
  for (int nxt : adj[u]) {
    if (nxt != p) {
      calc_dp(nxt, u);
      dp[u] *= dp[nxt] * invfact[sz[nxt]];
    }
  }
}

int n;
Modint over [MAX_N];
void calc_over (int u, int p) {
  Modint prod = over[u] * invfact[n - sz[u]];
  for (int nxt : adj[u]) {
    if (nxt != p) {
      prod *= dp[nxt] * invfact[sz[nxt]];
    }
  }

  for (int nxt : adj[u]) {
    if (nxt != p) {
      over[nxt] = prod * inv(dp[nxt]) * fact[sz[nxt]] * fact[n - sz[nxt] - 1];
    }
  }

  for (int nxt : adj[u]) {
    if (nxt != p) {
      calc_over(nxt, u);
    }
  }
}

int main () {
  ios::sync_with_stdio(false);

  fact[0] = Modint(1);
  for (int i = 1; i < MAX_N; i++) {
    fact[i] = fact[i - 1] * Modint(i);
  }

  for (int i = 0; i < MAX_N; i++) {
    invfact[i] = inv(fact[i]);
  }

  cin >> n;

  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;

    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  calc_sz(1, 1);
  calc_dp(1, 1);
  over[1] = Modint(1);
  calc_over(1, 1);

  /*
  for (int i = 1; i <= n; i++) {
    cout << i << " " << dp[i] << endl;
  }
  cout << endl;
  for (int i = 1; i <= n; i++) {
    cout << i << " " << over[i] << endl;
  }
  */
  
  for (int i = 1; i <= n; i++) {
    cout << dp[i] * over[i] * fact[n - 1] * invfact[sz[i] - 1] * invfact[n - sz[i]] << '\n';
  }
}


Measured memory_bytes: 21108
while(True):
    d,w,h = map(int, input().split())
    if d == 0 and w == 0 and h == 0:
        break
    l = min(d*d+w*w,w*w+h*h,h*h+d*d)
    n = int(input())
    for i in range(n):
        r = int(input())
        if 4*r*r > l:
            print("OK")
        else:
            print("NA")


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

using namespace std;

double process(int N, int K, vector<int> p) {
    // Calc mean
    vector<double> mean = vector<double>(N);
    for (int i = 0; i < N; i++){
        mean[i] = (double)(p[i] + 1) / 2;
    }

    // Calc ans
    double max_sum;
    double current_sum = 0;
    
    for (int i = 0; i < K; i++) current_sum += mean[i];
    max_sum = current_sum;
    for (int i = K; i < N; i++){
        current_sum += (mean[i] - mean[i - K]);
        if (current_sum > max_sum) max_sum = current_sum;
    }

    return max_sum;
}

int main() {
    // Input
    int N, K;
    vector<int> p;

    cin >> N >> K;
    p = vector<int>(N);
    for (int i = 0; i < N; i++) cin >> p[i];

    // Process
    double ans = process(N, K, p);

    // Output
    printf("%.8lf\n", ans);

    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n, k;
	string s;
	cin >> n >> k >> s;

	vector<int> a;
	if (s[0] == '0') {
		a.emplace_back(0);
	}
	a.emplace_back(1);
	for (int i = 1; i < n; i++) {
		if (s[i] == s[i - 1]) {
			a[a.size() - 1]++;
		} else {
			a.emplace_back(1);
		}
	}
	if (s[n - 1] == '0') {
		a.emplace_back(0);
	}

	if (a.size() / 2 <= k) {
		cout << n << endl;
	} else {
		int mx = 0;
		int sum = 0;
		for (int i = 0; i <= 2 * k; i++) {
			mx += a[i];
		}
		sum = mx;

		for (int i = 0; i < a.size() / 2 - k; i++) {
			sum -= a[i * 2];
			sum -= a[i * 2 + 1];
			sum += a[i * 2 + 2 * k + 1];
			sum += a[i * 2 + 2 * k + 2];

			mx = max(mx, sum);
		}
		cout << mx << endl;
	}

	return 0;
}

Measured memory_bytes: 1020
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main(void)
{
     int i,j,k,n,m;
     scanf("%d",&n);
     k=0;
     while(n>10)
     {
          m=n%10;
          n=n/10;
          if(m==9)
          {
               k=1;
               break;
          }
     }
     if(n==9)
          k=1;
     if(k==1)
          printf("Yes\n");
     else
          printf("No\n");
     return 0;
}


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

#define N 100

string w[N];
string wss[N];

int main() {
	int n;

	cin >> n;
	for( int i = 0; i < n; i++ ) {
		string ww;
		cin >> ww;
		w[i] = ww;
		wss[i] = ww;
	}
	sort( wss, wss + n );
	int ans = 0;
	for( int i = 0; i < n - 1; i++ ) {
		if( wss[i] == wss[i+1] ) {
			ans = 1;
		}
	}
	for( int i = 0; i < n - 1; i++ ) {
		if(w[i][w[i].size() - 1] != w[i+1][0] ) {
			ans = 1;
		}
	}

	if( ans == 0 ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

const int MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    if(s.at(s.size() - 1) == 's') {
        cout << s << "es" << endl;
    } else {
        cout << s << "s" << endl;
    }
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
 
using namespace std;
 
#define MAX 100000
 
struct TRAMP{
    char mark;
    int number,inputed_order;
};
 
TRAMP cards[MAX];
 
int n;
 
int Partition(int left,int right){
    int i = left-1,pivot = cards[right].number;
    for(int start = left; start < right; start++){
        if(cards[start].number <= pivot){
                i++;
                std::swap(cards[i],cards[start]);
        }
    }
 
    std::swap(cards[i+1],cards[right]);
 
    return i+1;
}
 
void quickSort(int left,int right){
    if(left < right){
        int q = Partition(left,right);
        quickSort(left,q-1);
        quickSort(q+1,right);
    }
}
 
 
int main(){
 
    bool stableFLG = true;
    scanf("%d",&n);
 
    for(int i = 0; i < n; i++){
        scanf("%s %d",&cards[i].mark,&cards[i].number);
        cards[i].inputed_order = i;
    }
 
    quickSort(0,n-1);
 
    for(int i = 1; i < n; i++){
        if(cards[i].number == cards[i-1].number && cards[i].inputed_order < cards[i-1].inputed_order){
            stableFLG = false;
            break;
        }
    }
 
    if(stableFLG){
        printf("Stable\n");
    }else{
        printf("Not stable\n");
    }
 
    for(int i = 0; i < n; i++)   printf("%c %d\n",cards[i].mark,cards[i].number);
}


Measured memory_bytes: 4328
#include<iostream>
#include<cmath>

using namespace std;

bool is_room(int S){

  for(int i=1;2*(i*i+i)<=S;i++)
    if((S-i)%(2*i+1)==0)return true;
  return false;
}

int main(void){

  int n,S,cnt=0;

  cin >> n;
  while(n--){
    cin >> S;
    if(!is_room(S))cnt++;
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
constexpr int MAX = 200001;
lint fact[MAX], finv[MAX], inv[MAX];
void cominit() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  FOR(i, 2, MAX){
    fact[i] = fact[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
lint power(lint x, lint n, lint mod) {
  lint ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}
lint ncr(lint n, lint r, lint mod) {
  if(n < 0 || r < 0 || n-r < 0) return 0;
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N, M;
  cin >> N >> M;
  cominit();
  vector<lint> fact;
  for(lint i=2; i*i<=M; i++) {
    if(M%i != 0) continue;
    lint ex = 0;
    while(M%i == 0) {
      M /= i;
      ex++;
    }
    fact.push_back(ex);
  }
  if(M > 1) fact.push_back(1);
  lint ans = 1;
  REP(i, fact.size()) ans = ans * ncr(N-1+fact[i], fact[i], MOD) % MOD;
  cout << ans << endl;
  
}

Measured memory_bytes: 4992
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
#define N 300010
#define gc getchar()
#define lb(x) (x&-x)
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
inline int inn()
{
    int x,ch;while((ch=gc)<'0'||ch>'9');
    x=ch^'0';while((ch=gc)>='0'&&ch<='9')
        x=(x<<1)+(x<<3)+(ch^'0');return x;
}
int l[N],r[N],b[N],ans[N];vector<int> v[N];
inline int update(int x,int n,int v) { for(;x<=n;x+=lb(x)) b[x]+=v;return 0; }
inline int update(int x,int y,int n,int v) { return update(x,n,v),update(y+1,n,-v); }
inline int query(int x,int v=0) { for(;x;x-=lb(x)) v+=b[x];return v; }
int main()
{
    int n=inn(),m=inn();
    for(int i=1;i<=n;i++)
        l[i]=inn(),r[i]=inn(),v[r[i]-l[i]+1].push_back(i);
    for(int d=1;d<=m;d++)
    {
        for(int i=d;i<=m;i+=d) ans[d]+=query(i);
        for(int i=0,id;i<(int)v[d].size();i++)
            id=v[d][i],update(l[id],r[id],m,1);
    }
    for(int d=m,cnt=0;d;d--)
        cnt+=(int)v[d].size(),ans[d]+=cnt;
    for(int i=1;i<=m;i++) printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 15744
N,K,Q= [int(s) for s in input().split()]

temp=[0]*N

for i in range(Q):
  A = int(input())
  temp[A-1]=temp[A-1]+1
          
ans=[K - (Q- d) for d in temp]


for t in ans:
  if t>0:
    print("Yes")
  else:
    print("No")

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

using namespace std;

void solve() {
    string S; cin >> S;
    int N = S.length();
    long long ans = 0;
    for (int bit = 0; bit < (1<<(N-1)); bit++) {
        long long tmp = 0;
        for (int i = 0; i < N-1; i++) {
            tmp *= 10;
            tmp += S[i] - '0';
            if (bit & (1<<i)) {
                ans += tmp;
                tmp = 0;
            }
        }
        tmp *= 10;
        tmp += S.back() - '0';
        ans += tmp;
    }

    cout << ans << endl;
}


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

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

#define o(output) cout << output << endl

using namespace std;

string s,t,u;
int a,b,c,d;
char A,B;
priority_queue<int,vector<int>,greater<int> >small;

int main(){
  cin>>a>>b>>c;
  o((a+b)*c/2);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <set>
#include <queue>

using namespace std;

typedef long long ll;

int A, B, C;
int main() {
  scanf("%d %d %d", &A, &B, &C);
  int m = max(A, max(B, C));
  int res = 3 * m - A - B - C;
  if (res % 2) {
    res += 3;
  }
  printf("%d\n", res / 2);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	vector<int> v(9);
	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;

		if (n < 3200) v.at(n / 400)++;
		else v.at(8)++;
	}

	int sum = 0;
	for (int i = 0; i < 8; i++) {
		if (v.at(i)) sum++;
	}

	if (v.at(8)) {
		if (!sum) cout << 1 << ' ';
		else cout << sum << ' ';
		cout << sum + v.at(8) << endl;
	}
	else {
		cout << sum << ' ' << sum << endl;
	}
}

Measured memory_bytes: 3604
import java.util.Scanner;
public class Main{
	public static void main(String[]args) {
		Scanner input=new Scanner(System.in);
		int a;
		int b;
		int h;
		do {
			a=input.nextInt();
			b=input.nextInt();
			h=input.nextInt();
		}while(a<=1&&a>100&&b<=1&&b>100&&h<=1&&h>100&&h%2!=0);
		System.out.println((a+b)*h/2);
	}
}

Measured memory_bytes: 27064