akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>

using namespace std;

int main()
{
    int i, j, k;
    vector < vector < int > > A(3, vector<int>(3, 0));
    vector < vector < int > > memo(3, vector<int>(3, 0));
    for (i=0; i<3; i++) {
        for (j=0; j<3; j++) {
            cin >> A[i][j];
        }
    }
    int N;
    cin >> N;
    vector<int> b(N);
    for (i=0; i<N; i++) {
        cin >> b[i];
    }
    
    int tmp;
    for (i=0; i<N; i++) {
        tmp = b[i];
        for (j=0; j<3; j++) {
            for (k=0; k<3; k++) {
                if (A[j][k] == tmp) {
                    memo[j][k] = 1;
                }
            }
        }
    }
    
    for (i=0; i<3; i++) {
        for (j=0; j<3; j++) {
            if(memo[i][0] == 1 && memo[i][1] == 1 && memo[i][2] == 1) {
                cout << "Yes" << endl;
                return 0;
            }
            else if (memo[0][i] == 1 && memo[1][i] && memo[2][i] == 1) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    if (memo[0][0] == 1 && memo[1][1] == 1 && memo[2][2] == 1) {
        cout << "Yes" << endl;
        return 0;
    }
    else if (memo[0][2] == 1 && memo[1][1] == 1 && memo[2][0] == 1) {
        cout << "Yes" << endl;
        return 0;
    }
    
    cout << "No" << endl;
    
    //getline(cin, str);
    //vector < vector < int > > A(x, vector<int>(y, 0));
    //int avg = round((float)accumulate(X.begin(), X.end(), 0.0) / N);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INT long long int
#define MOD 1000000007
#define oo (INT)(6e18)
using namespace std;
bitset<4000001> dt;
int n, s;
int main()
{
    cin>>n;
    dt[0] = 1;
    for(int i = 0, t ; i < n ; i++ )
    {
        cin>>t;
        s+=t;
        dt |= (dt<<t);
    }
    for(int i = (s+1)/2 ; ; i++ )
        if( dt[i] ) return cout<<i<<endl, 0;
}


Measured memory_bytes: 1664
n, x = [int(elem) for elem in input().split()]
ls = [int(elem) for elem in input().split()]
scores = [sum(ls[0:i]) for i in range(0, len(ls)+1)]

cnt = 0
for s in scores:
  if s <= x:
    cnt += 1
  else:
    break
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

Measured memory_bytes: 3068
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string> 
#include <map>
#include <iomanip>
#include <list>
#include <stack>

using namespace std;


typedef int INT;
#define int long long




INT main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	int n, k;
	cin >> n >> k;
	vector <int> a(n);

	int t = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	cout << (n - 1) / (k - 1) + ((n - 1) % (k - 1) != 0);
	return 0;
}

Measured memory_bytes: 1024
import math
n = int(input() )
n+=1
sum = 0
for i in range (1,n):
    for j in range (1,n):
        gcdIJ = math.gcd(i,j)
        for k in range (1,n):
            sum += math.gcd( gcdIJ  ,k )
            #print(i,j,k)

print( sum )

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

typedef long long ll;

#define MAX_N (100000+2)
#define MAX_A (100000+2)

using namespace std;

int main() {
  int n;
  int a[MAX_N];
  // memo1[i]:長さがi+1の増加部分列の末尾の最小値
  int memo1[MAX_N];
  // memo1の更新履歴
  // 逆順になっている列に対してupper_boundを使いたいので*(-1)してある
  vector<int> memo2[MAX_N];
  fill(memo1, memo1+MAX_N, MAX_A);
  
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  for (int i = 0; i < n; i++) {
    int *p = lower_bound(memo1, memo1+n, a[i]);
    *p = a[i];
    memo2[p-memo1].push_back(-a[i]);
  }

  ll ans = 0;
  // 最長増加部分列の末尾から順に見ていく。作れる最大の和を求める。
  // 最長増加部分列の長さ
  ll max_len = lower_bound(memo1, memo1+n, MAX_A)-memo1;
  // 増加部分列の末尾の値(*(-1))
  int end_v = memo2[max_len-1][0];
  ans = -end_v;
  // cout << -end_v << endl;
  for (int i = max_len-1; i >= 1; i--) {
    end_v = *upper_bound(memo2[i-1].begin(), memo2[i-1].end(), end_v);
    // cout << "[";
    // for (int j = 0; j < memo2[i-1].size(); j++) {
    //   cout << -memo2[i-1][j] << " ";
    // }
    // cout << "]" << endl;
    // cout << -end_v << endl;
    ans += -end_v;
  }

  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 9316
import sys
sys.setrecursionlimit(100000)
inf = float('inf')

def dfs(h, s, D, G, pc):
    # 停止条件
    if h == D:
        tmp = 0
        p = 0
        ans = 0
        for i, c in enumerate(s):
            if c == '0':
                tmp = i
            else:
                ans += pc[i][0]
                p += (i+1) * 100 * pc[i][0] + pc[i][1]
        for i in range(pc[tmp][0]-1):
            if p < G:
                p += (tmp + 1) * 100
                ans += 1
        if p < G:
            return inf
        else:
            return ans
    tmp1 = dfs(h+1, s + '0', D, G, pc)
    tmp2 = dfs(h+1, s + '1', D, G, pc)
    return min(tmp1, tmp2)


D, G = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(D)]
print(dfs(0, '', D, G, pc))

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 28 22:12:42 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
X, Y, A, B, C = map(int,input().split())
r = list(map(int,input().split()))
g = list(map(int,input().split()))
n = list(map(int,input().split()))

r.sort()
g.sort()

r = r[-X:]
g = g[-Y:]

all_apple = r+g+n
all_apple.sort()
ans = sum(all_apple[-(X+Y):])

print(ans)




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

ll mpow(ll x, ll n){ //x^n(mod mo) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mo;
        x = x*x % mo;
        n = n >> 1;
    }
    return ans;
}
 
const int mod = 998244353;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
 
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main(){
    ll N,S;
    cin >> N >> S;
    vector<ll> A(N);
    vector<vector<mint>>dp(3010,vector<mint>(3010));
    rep(i,N){
        cin >> A[i];
    }
    dp[0][0] = 1;
    rep(i,N){
        rep(j,S+1){
            if(j-A[i] >= 0){
                dp[i+1][j] = dp[i][j]*2 + dp[i][j-A[i]];
                //cmax(dp[i+1][j], dp[i][j-A[i]]);
                //cmax(dp[i+1][j], dp[i][j-A[i]] + dp[i][j]);
            }else{
                dp[i+1][j] = dp[i][j]*2;
                //cmax(dp[i+1][j], dp[i][j]);
            }
        }
    }
    /*
    vector<mint> memo(N+10);
    memo[0] = 1;
    mint a=2;
    REP(i,1,N+1){
        memo[i] = a*memo[i-1];
    }
    a = 1;
    REP(i,1,N+1){
        memo[i] -= a;
    }
    mint ans = 0;
    rep(i,N){
        ans += mint(dp[i+1][S]-dp[i][S])*(memo[i+1]);
        //cout << dp[i+1][S]-dp[i][S] << endl;
    }*/
    cout << dp[N][S] << endl;
}


Measured memory_bytes: 74272
package main

import (
	"bufio"
	"fmt"
	"os"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	r := bufio.NewReaderSize(os.Stdin, 10000)

	s, _, _ := r.ReadLine()
	t, _, _ := r.ReadLine()

	var dp [3001][3001]int

	n := len(s)
	m := len(t)
	for i := 1; i <= n; i++ {
		for j := 1; j <= m; j++ {
			if s[i-1] == t[j-1] {
				dp[i][j] = dp[i-1][j-1] + 1
			} else {
				dp[i][j] = max(dp[i-1][j], dp[i][j-1])
			}
		}
	}

	//	out(dp[n][m])

	x := n
	y := m
	ans := ""
	for x > 0 && y > 0 {
		if dp[x][y] == dp[x-1][y] {
			x--
		} else if dp[x][y] == dp[x][y-1] {
			y--
		} else {
			x--
			y--
			ans += string(s[x])
		}
	}

	for i := len(ans); i > 0; i-- {
		fmt.Print(string(ans[i-1]))
	}
	fmt.Println("")

}


Measured memory_bytes: 77440
#include <stdio.h>

int main ()
{
	int N;
	double t,c;
	scanf("%d",&N);
	
    if(N%2==0)
	{
		t=N/2;
		c=(double)t/N;
		printf("%0.10lf\n",c);
	}
	else if(N%2!=0)
	{
		t=(N+1)/2;
		c=(double)t/N;
		printf("%0.10lf\n",c);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int v[101],w[101];
int dp[101][10005]; // dp[i][j]:= i 番目まで見て重さがj以下のときの最大の価値

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,W;
    cin >> n >> W;
    rep(i,n){
        cin >> v[i] >> w[i];
    }
    rep(i,n){
        rep(j,W+1){
            dp[i+1][j] = dp[i][j];
            if(j-w[i]>=0)chmax(dp[i+1][j],dp[i][j-w[i]] + v[i]);
        }
    }
    cout << dp[n][W] << endl;
}


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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    cout << (input() * input() & 1 ? "Yes" : "No") << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


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

int main(){
    string O, E;
    cin >> O >> E;

    for(int i=0; i<E.length(); i++) cout << O.at(i) << E.at(i);
    
    if (O.length() != E.length()) cout << O.at(O.length()-1);

    cout << endl;

    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }
  vector<int> C, D;
  for (int i = 0; i < N; i++) {
    if (A[i] < B[i]) {
      C.emplace_back(B[i] - A[i]);
    } else if (A[i] > B[i]) {
      D.emplace_back(A[i] - B[i]);
    }
  }
  int p = 0;
  for (int i = 0; i < (int)D.size(); i++) {
    while (p < (int)C.size() && D[i] > 0) {
      if (C[p] >= 2 * D[i]) {
        C[p] -= 2 * D[i];
        D[i] = 0;
      } else {
        D[i] -= C[p] / 2;
        C[p++] %= 2;
      }
    }
  }
  for (int i = 0; i < (int)D.size(); i++) {
    if (D[i] != 0) {
      cout << "No" << '\n';
      return 0;
    }
  }
  cout << "Yes" << '\n';
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll>Q;

ll ans[200010];

int main(void){
    ll n;
    cin>>n;
    map<ll,ll>cnt,index;
    priority_queue<ll,vector<ll>,less<ll> >pq;
    for(ll i=0;i<n;i++){
        ll a;
        cin>>a;
        if(index[a]==0){
            cnt[a]++;
            index[a]=i+1;
            pq.push(a);
        }
        else cnt[a]++;
    }
    if(pq.size()==1){
        ll t = pq.top();
        for(int i=1;i<=n;i++){
            if(i==1)cout<<t*n<<endl;
            else cout<<0<<endl;
        }
        return 0;
    }
    while(!pq.empty()){
        if(pq.size()==1){
            ll p = pq.top();
            ans[index[p]]+=p*cnt[p];
            break;
        }
        ll f = pq.top();
        pq.pop();
        ll s = pq.top();
        pq.pop();
        ll d = f-s;
        //cout<<index[f]<<" "<<cnt[f]<<endl;
        ans[index[f]]+=d*cnt[f];
        cnt[s]+=cnt[f];
        if(index[s]>index[f])index[s]=index[f];
        pq.push(s);
    }
    for(ll i=1;i<=n;i++)cout<<ans[i]<<endl;
    return 0;
}

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

const int maxn=1e5+9;

int main()
{
    int a;
    cin>>a;
    if(a<=111)
    puts("111");
    else if(a>=112&&a<=222)
    puts("222");
    else if(a>=223&&a<=333)
    puts("333");
    else if(a>=334&&a<=444)
    puts("444");
    else if(a>=445&&a<=555)
    puts("555");
    else if(a>=556&&a<=666)
    puts("666");
    else if(a>=667&&a<=777)
    puts("777");
    else if(a>=778&&a<=888)
    puts("888");
    else if(a>=889&&a<=999)
    puts("999");

    return 0;
}


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

public class Main {
  private static boolean debug = false;
  private static boolean elapsed = false;

  private static PrintWriter _err = new PrintWriter(System.err);

  private int minLen = Integer.MAX_VALUE;
  private boolean isFirst = false;
  private void solve(Scanner sc, PrintWriter out) {
    String s = sc.nextLine();

    int r = s.length() % 2;

    StringBuilder sb = new StringBuilder(s);
    boolean found = false;
    do {
      found = false;
      for (int i = 1; i < sb.length() - 1; ++i) {
        if (sb.charAt(i - 1) == sb.charAt(i + 1)) {
          continue;
        }
        sb.deleteCharAt(i);
        found = true;
        break;
      }
    } while (found);

    if (sb.charAt(0) == sb.charAt(sb.length() - 1)) {
      isFirst = (r == 0);
    } else {
      isFirst = (r != 0);
    }

    out.println(isFirst ? "First" : "Second");
  }
  private long P(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    return res;
  }
  /*
   * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
   * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
   */
  public static void main(String[] args) {
    long S = System.currentTimeMillis();

    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(sc, out);
    out.flush();

    long G = System.currentTimeMillis();
    if (elapsed) {
      _err.println((G - S) + "ms");
    }
    _err.flush();
  }
}

Measured memory_bytes: 14400
#include <cstdio>
#include <algorithm>
using namespace std;
int H, W, Q, a[50009], b[50009], x[50009]; bool used1[50009], used2[50009];
int main() {
	while (scanf("%d%d%d", &H, &W, &Q), H) {
		for (int i = 0; i < Q; i++) scanf("%d%d%d", &a[i], &b[i], &x[i]);
		fill(used1, used1 + H, false);
		fill(used2, used2 + W, false);
		int cnt1 = H, cnt2 = W;
		long long ret = 0;
		while (Q--) {
			if (a[Q] == 0 && !used1[b[Q]]) {
				used1[b[Q]] = true; cnt1--;
				if (x[Q] == 1) ret += cnt2;
			}
			if (a[Q] == 1 && !used2[b[Q]]) {
				used2[b[Q]] = true; cnt2--;
				if (x[Q] == 1) ret += cnt1;
			}
		}
		printf("%lld\n", ret);
	}
	return 0;
}

Measured memory_bytes: 3332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_s(i, s, n) for (int i = (int)(s); i < (int)(n); i++)

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

    int A[N];
    rep(i, N)
    {
        cin >> A[i];
    }

    int res = 0;
    while (true)
    {
        bool is_all_even = true;
        rep(i, N)
        {
            if (A[i] % 2 == 1)
            {
                is_all_even = false;
                break;
            }
            A[i] = A[i] / 2;
        }
        if (is_all_even)
        {
            res++;
        }
        else
        {
            break;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String r;
        switch(N % 10) {
            case 2: case 4: case 5: case 7: case 9:
                r = "hon";
                break;
            case 0: case 1: case 6: case 8:
                r = "pon";
                break;
            case 3:
                r = "bon";
                break;
            default:
                throw new Exception("out of thought");
        }
        System.out.println(r);
    }
}


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

int main(){
	int i,j,n,m,l,f,x,y,z; string s;
	cin >> n >> m;
	int k[40], a[40][40];
	rep(i, n){
		cin >> k[i];
		rep(j, k[i]){
			cin >> a[i][j];
		}
	}
	x = 0;
	int o,p;
	rep(j, k[0]){
		f = 1;
		rep(o, n){
			if(o == 0) continue;
			rep(p, k[o]){	
				if(a[0][j] == a[o][p]) f++;
			}
		}
		if(f == n){
			x++;
		}
	}
	cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    int ans = 0;
    mat cnt(10, vec(10, 0));

    FOR(i, 1, N + 1){
        int x = i % 10;
        int y = i;
        while(y >= 10) y /= 10;
        cnt[x][y]++;
    }
    FOR(i, 1, N + 1){
        int x = i % 10;
        int y = i;
        while(y >= 10) y /= 10;
        ans += cnt[y][x];
    }
    Out(ans);

    return 0;
}


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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s[3];
  while (cin >> s[0], s[0] != "0") {
    cin >> s[1] >> s[2];
    string ans = "NA";
    for (int i = 0; i < 3; i++) {
      if (s[i][0] != '+' && s[i][0] == s[i][1] && s[i][1] == s[i][2]) {
        ans = string(1, s[i][0]);
      }
    }
    for (int i = 0; i < 3; i++) {
      if (s[0][i] != '+' && s[0][i] == s[1][i] && s[1][i] == s[2][i]) {
        ans = string(1, s[0][i]);
      }
    }
    if (s[0][0] != '+' && s[0][0] == s[1][1] && s[1][1] == s[2][2]) {
      ans = string(1, s[0][0]);
    }
    if (s[0][2] != '+' && s[0][2] == s[1][1] && s[1][1] == s[2][0]) {
      ans = string(1, s[0][2]);
    }
    cout << ans << endl;
  }

  return 0;
}


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

int main(){
    long N,A,B;
    cin>>N>>A>>B;

    long sum=0;
    sum+=N/(A+B)*A;

    if(N%(A+B)>=A){
        sum+=A;
    }else{
        sum+=N%(A+B);
    }

    cout<<sum;

}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	A, B, H, M := nextInt(), nextInt(), nextInt(), nextInt()
	var rad float64
	m := H*60 + M
	rad = math.Pi * (float64(m) * 5.5 / 180)
	fmt.Println(math.Sqrt(float64(A*A+B*B) - 2*float64(A*B)*math.Cos(rad)))
}

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


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

int main()
{
    vector<int> vec_1(3);
    vector<int> vec_2 = {5, 5, 7};
    for (int i = 0; i < 3; i++) {
        cin >> vec_1.at(i);
    }
    sort(vec_1.begin(), vec_1.end());

    if (vec_1 == vec_2)
        cout << "YES" << endl;
  else
    cout << "NO" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

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

int main(){
  ll N, A, B; cin >> N >> A >> B;
  vector <ll> x(N);
  rep(i, N) cin >> x[i];
  ll ans = 0;
  rep(i, N-1){
    ans += min(B, A*(x[i+1]-x[i]));
  }
  cout << ans << endl;
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n + 1);

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

    vector<vector<int>> dp(k + 1, vector<int>(n + 1));

    for(int i = 1; i < a[1]; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            dp[i][j] = 2;
        }
    }

    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            dp[a[i]][j] = 1;
        }
    }

    for(int i = 1; i <= k; i++)
    {
        if(dp[i][1] != 0) continue;

        bool hasOne = false;
        
        for(int j = 1; j <= n; j++)
        {
            if(i - a[j] >= 1)
            {
                if(dp[i - a[j]][j] == 1)
                {
                    dp[i][j] = 2;
                }
                else
                {
                    dp[i][j] = 1;
                    hasOne = true;
                    break;
                }      
            }
            else
            {
                dp[i][j] = 2;
            }       
        }

        if(hasOne)
        {
            for(int j = 1; j <= n; j++)
            {
                dp[i][j] = 1;
            }
        }
    }

    // for(int i = 1; i <= k; i++)
    // {
    //     cout << i << ": ";
        
    //     for(int j = 1; j <= n; j++)
    //     {
    //         cout << dp[i][j] << " ";
    //     }

    //     cout << "\n";
    // }

    if(dp[k][n] == 1)
    {
        cout << "First";
    }
    else
    {
        cout << "Second";
    }
    
     
    return 0;
}

Measured memory_bytes: 46300
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
using R = double;

ll C[51][51];

//組合せのテーブルを作る関数
void comb_table(int N) {
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= i; ++j) {

			//両端は1
			if (j == 0 || j == i) {
				C[i][j] = 1LL;
			}
			//1個上の段の2つを足してつくる。
			else {
				C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
			}
		}
	}
}
int main() {

	//境界値受け取り。
	int N, A, B;
	cin >> N >> A >> B;

	//値を受け取って配列に格納
	const int NMAX = 50;
	ll v[NMAX];

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

	//大きい方から選びたいので、降順に並べ替え。
	sort(v, v + N);
	reverse(v, v + N);

	//考察の通り、大きい方からA個とった時の平均が最大。
	//後は等しいか減るかどっちか


	R max_average = 0.0;
	//総和とる。
	for (int i = 0; i < A; ++i) {
		max_average += v[i];
	}
	//Aで割る。
	max_average /= A;
	//平均求まった。

	//A番目に大きい値が配列全体で何個あるか数える。
	//0,…,A-1までにVaが何個あるか数えることで、
	//上位がVaだけで埋まっているかも調べる。
	int a_th_val_num = 0, a_th_va_pos = 0;
	for (int i = 0; i < N; i++) {
		if (v[i] == v[A - 1]) {
			a_th_val_num++;
			if (i < A) {
				a_th_va_pos++;
			}
		}
	}


	comb_table(N);
	ll cnt = 0LL;
	//0からA-1までVaで埋まっている場合。
	//AからBの範囲までのうちVaが続いて範囲のみ対象に
	//Vaの総数のうち、考えている範囲のでVaの個数を選んだ時の組み合わせ。
	//○○○○　|○○×××|
	//仕切り線がABだとすると
	//6個の中から5つを選ぶ組合せ＋6個の中から6つを足す組合せが答え。
	if (a_th_va_pos == A) {
		for (a_th_va_pos = A; a_th_va_pos <= B; ++a_th_va_pos) {
			cnt += C[a_th_val_num][a_th_va_pos];
		}
	}
	//違う場合。Vaの総数のうち、0,…,A-1までにあるVaの数を使って作れる組合せ。
	else {
		cnt += C[a_th_val_num][a_th_va_pos];
	}

	//小数点以下何桁までか設定。
	cout.precision(20);
	//設定どおりに出力するためにfixedオプションつける。
	cout << fixed << max_average << endl;
	//組合せの総数は整数で出力。
	cout << cnt << endl;



	return 0;
}


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

using namespace std;

int MAX_N = 100;

int main()
{
    int a,b,c,d;

    cin >> a >> b >> c >> d;

    while (a>0 && c>0)
    {
        c = c-b;
        a = a-d;
    }
    if (c<=0 && a>0)
    {
        cout << "Yes" << endl;
    }else if(c>0 && a<=0)
    {
        cout << "No" << endl;
    }else
    {
        cout << "Yes" << endl;
    }
    
    return 0;
}

// cout << "Yes" << endl;
// cout << "No" << endl;
// long double pi = 3.14159265358979323;

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

using namespace std;

int main() {

	bool f = false;

	char s[100][100];
	for (int i = 0;i < 100;i++){
		for (int j = 0;j < 100;j++){
			s[i][j] = '.';
		}
	}

	int h,w; cin >> h >> w;

	for (int i = 1;i <= h;i++){
		for (int j = 1;j <= w;j++){
			cin >> s[i][j];
		}
	}	

	for (int i = 1;i <= h;i++){
		for (int j = 1;j <= w;j++){
			if(s[i][j] == '#'){
				if(s[i+1][j] != '#' && s[i][j+1] != '#' && s[i][j-1] != '#' && s[i-1][j] != '#'){f = true;break;}
			}
		}
	}

	if(f) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;

}


Measured memory_bytes: 256
import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)

now = 1
bre = 0

for i in range(n):
    if a[i] == now:
        now += 1
    else:
        bre += 1

if bre == n:
    print(-1)
else:
    print(bre)


Measured memory_bytes: 33932
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;

long long n;
long long a[200010];
long long t1[200010];
long long t2[200010];

int main() {
    cin >> n;
    t2[0] = 0;
    imfor(i, n) {
        cin >> a[i];
        t2[0] += a[i];
    }
    t2[0] -= a[0];
    imfor(i, n) {
        if (i == 0) {
            t1[i] = a[i];
            continue;
        }
        t1[i] = t1[i - 1] + a[i];
        t2[i] = t2[i - 1] - a[i];
    }
    long long min = abs(t1[0] - t2[0]);
    long long mini = 0;
    for (int i = 0; i < n - 1; i++) {
        if (abs(t1[i] - t2[i]) < min) {
            min = abs(t1[i] - t2[i]);
            mini = i;
        }
    }
    cout << min << endl;
}

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

int main(){
    long long n, c, k;
    cin >> n >> c >> k;

    vector<long long> T;

    long long t;
    for(long long i = 0; i < n; i++){
        cin >> t;
        T.push_back(t);
    }

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

    long long left = 0;
    long long right = 0;
    
    long long count = 0;
    long long sum = 0;

    for(long long i = 0; i < n; i++){
        if(T[i] > right){
            left = T[i];
            right = T[i] + k;
            count = 1;
            sum++;
        }

        if(count > c) {
            left = T[i];
            right = T[i] + k;
            count = 1;
            sum++;
        }

        count++;
    }

    printf("%lld\n", sum);

    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

int main(){
	fastio();
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&a==c)cout<<"Yes";
    else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    // Your code here!
    int n;
    scanf("%d",&n);
    long int max=0;
    long int min=10000000000;
    for(int i=0;i<n;i++){
        long int tmp;scanf("%ld",&tmp);
        if(max<tmp) max=tmp;
        if(min>tmp) min=tmp;
    }
    printf("%ld",max-min);
}


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

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

    if (N <= 9) {
        cout << N << endl;
    } else if (N <= 99) {
        cout << 9 << endl;
    } else if (N <= 999) {
        cout << N - 90 << endl;
    } else if (N <= 9999) {
        cout << 909 << endl;
    } else if (N <= 99999) {
        cout << N - 90 - 9000 << endl;
    } else {
        cout << 90909 << endl;
    }

    return 0;
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr double EPS = 1e-10;
constexpr int INF = 1001001001;
//constexpr ll INF = 1001001001001001001ll;


int main() {
    ll a, b, c; cin >> a >> b >> c;
    ll res = 0;
    if (a + b + 1 >= c) {
        res = b + c;
    }
    else {
        res = a + 2 * b + 1;
    }

    cout << res << endl;

}

Measured memory_bytes: 256
def MI(): return map(int, input().split())
import sys
input = sys.stdin.readline
n,w = map(int,input().split())
#wv = [tuple(map(int,input().split())) for i in range(n)]
W=[]
V=[]
for i in range(n):
  a,b=MI()
  W.append(a)
  V.append(b)
dp = [0]*(w+1)
for i in range(n):
    for j in range(w,W[i]-1,-1):
        dp[j] = max(dp[j],dp[j-W[i]]+V[i])
print(max(dp))

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

int main() {
    int a;
    string s,ans="red";
    cin>>a>>s;
    if (a>=3200) ans=s;

    cout<<ans<<endl;
}


Measured memory_bytes: 256
A = input()
B = input()

dA = [-1]*26
dB = [-1]*26
cA = 0
cB = 0
pA = []
pB = []

le = len(A)

for i in range(le):
  v = ord(A[i])-ord("a")
  if ( dA[v]==-1 ):
    dA[v]=cA
    pA.append(cA)
    cA+=1
  else:
    pA.append( dA[v] )

for i in range(le):
  v = ord(B[i])-ord("a")
  if ( dB[v]==-1 ):
    dB[v]=cB
    pB.append(cB)
    cB+=1
  else:
    pB.append( dB[v] )

s = le
for i in range(le):
  if (pA[i]==pB[i]):
    s-=1
if (s==0):
  print ("Yes")
else:
  print ("No")

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

ll lucas(ll num){
    if(num == 0) return 2;
    if(num == 1) return 1;
    return lucas(num - 1) + lucas(num - 2);
}

int main(){
    ll N;
    cin >> N;
    vector<ll> lucas(87);
    lucas.at(0) = 2;
    lucas.at(1) = 1;
    if(N == 0 || N == 1){
        cout << lucas.at(N) << endl;
        return 0;
    }
    for(int i = 2; i <= N; i++){
        lucas.at(i) = lucas.at(i - 1) + lucas.at(i - 2);
    }
    cout << lucas.at(N) << endl;

}



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

using namespace std;

int main()
{
    int x, y, a, b;

    cin >> x >> y;
    b = y / 2 - x;
    a = x - b;

    if (a + b == x and 2 * a + 4 * b == y and a >= 0 and b >= 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> cnt(10101);
    for(int x = 1; x <= 300; x++){
        for(int y = 1; y <= 300-x; y++){
            for(int z = 1; z <= 300-y-x; z++){
                int tmp = x*x + y*y + z*z + x*y + y*z + z*x;
                if(tmp < 10101){
                    cnt[tmp]++;
                }
            }
        }  
    }

    for(int i = 1; i <= n; i++){
        cout << cnt[i] << endl;
    }

}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb(x) (x&-(x))
const int N = 101010;

int G[10][10]; 
void floyd(){
rep(k, 0, 10){
rep(u, 0, 10){
rep(v, 0, 10){
G[u][v]=min(G[u][v], G[u][k]+G[k][v]);
}
}
}
}
int grid[205][205];
int main(){

	int n,m;
	cin>>n>>m;
	
	for(int i=0;i<10;i++)
	for(int j=0;j<10;j++)
	scanf("%d",&G[i][j]);
	floyd();
	
	for(int i=0;i<n;i++)
	for(int j=0;j<m;j++)
	scanf("%d",&grid[i][j]);
	
	int ans=0;
	for(int i=0;i<n;i++)
	for(int j=0;j<m;j++)
	{
		if(grid[i][j]!=-1)
		ans+=G[grid[i][j]][1];
	}
	cout<<ans<<endl;



    return 0;
}


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

/*label[0]~[5]が1~6に対応（ややこしいけど）*/
class Dice{
    public:
        int label[6];
        void North();
        void South();
        void East();
        void West();
};

void Dice::North(){
    int temp=label[0];
    label[0]=label[1];
    label[1]=label[5];
    label[5]=label[4];
    label[4]=temp;
}

void Dice::South(){
    int temp=label[0];
    label[0]=label[4];
    label[4]=label[5];
    label[5]=label[1];
    label[1]=temp;
}

void Dice::East(){
    int temp=label[0];
    label[0]=label[3];
    label[3]=label[5];
    label[5]=label[2];
    label[2]=temp;
}

void Dice::West(){
    int temp=label[0];
    label[0]=label[2];
    label[2]=label[5];
    label[5]=label[3];
    label[3]=temp;
}

int main(){
    Dice dice;
    for(int i=0; i<6; i++){cin >> dice.label[i];}
    string roll;
    cin >> roll;
    for(int i=0; i<roll.size(); i++){
        if(roll[i]=='N'){dice.North();}
        if(roll[i]=='S'){dice.South();}
        if(roll[i]=='E'){dice.East();}
        if(roll[i]=='W'){dice.West();}
    }
    cout << dice.label[0] << endl;

    return 0;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
int main(){
	while(1){
		int H,W;
		cin >> H >> W;
		if(H==0){
			if(W==0) break;
		}
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++) cout << '#';
			cout << endl;;
		}
		cout << endl;
	}
}
		


Measured memory_bytes: 3084
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    string s; cin>>s;
    reverse(s.begin(),s.end());
    string t="";
    for(int i=0;i<s.size();i++){
        if(s.substr(i,5)=="maerd"){
            i+=5;
            t+="maerd";
                if(t==s){
                cout<<"YES"<<endl;
                return 0;
            }
        }
        else if(s.substr(i,7)=="remaerd"){
            i+=7;
            t+="remaerd";
                      if(t==s){
                cout<<"YES"<<endl;
                return 0;
            }
        }
        else if(s.substr(i,5)=="esare"){
            i+=5;
            t+="esare";
                      if(t==s){
                cout<<"YES"<<endl;
                return 0;
            }
        }
        else if(s.substr(i,6)=="resare"){
            i+=6;
            t+="resare";
                      if(t==s){
                cout<<"YES"<<endl;
                return 0;
            }
        }
        else{
            cout<<"NO"<<endl;
            return 0;
        }
        i--;
    }
}


Measured memory_bytes: 640
using System;
using System.Text;

namespace IsitaRightTriangle
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var sb = new StringBuilder();
            for (int i = 0; i < n; i++)
            {
                int[] Input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                Array.Sort(Input);
                double[] Sorted_Input_Squaring = Array.ConvertAll(Input, a => Math.Pow(a, 2));
                if (Sorted_Input_Squaring[2] == Sorted_Input_Squaring[1] + Sorted_Input_Squaring[0])
                {
                    sb.AppendLine("YES");
                }
                else
                {
                    sb.AppendLine("NO");
                }
            }
            sb.Remove(sb.Length - 1, 1);
            Console.WriteLine(sb);
            
            Console.ReadLine();
        }
    }
}



Measured memory_bytes: 9260
h, w = map(int, input().split())
s = [input() for _ in range(h)]
dx = [1, 1, 0, -1, -1, -1, 0, 1]
dy = [0, 1, 1, 1, 0, -1, -1, -1]
for i in range(h):
    s[i] = list(s[i])
    l = ""
    for j in range(w):
        if s[i][j] == "#":
            continue
        cnt = 0
        for k in range(8):
            ii = i + dx[k]
            jj = j + dy[k]
            if ii < 0 or ii > h - 1:
                continue
            elif jj < 0 or jj > w - 1:
                continue
            elif s[ii][jj] == "#":
                cnt += 1
        s[i][j] = str(cnt)
    l = "".join(s[i])
    print(l)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <algorithm>
#include <math.h>
#include<string>
#include<vector>
using namespace std;
using ll = long long;
int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int taka = (a -1)/d;
    int ao = (c -1 )/b;
    if(taka >= ao){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3040
N,M=map(int, input().split())
parent=list(range(N))

def root(val):
    if parent[val]==val:
        return val
    else:
        parent[val]=root(parent[val])
        return parent[val]

def same(x,y):
    return root(x)==root(y)

def unite(x,y):
    xr=root(x)
    yr=root(y)
    if xr==yr :return
    parent[xr]=yr
p=list(map(int, input().split()))
X=[]
Y=[]
for i in range(M):
    x,y=map(int, input().split())
    X.append(x)
    Y.append(y)
    unite(x-1,y-1)
ct=0
for i,pp in enumerate(p):
    ct+=same(i,pp-1)
print(ct)

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

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

    int n, a; cin >> n >> a;
    cout << n * n - a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
    int n;
    scanf("%d", &n);
    switch (n) {
        case 1:
            printf("Hello World\n");
            break;
        case 2:
            int a, b;
            scanf("%d\n%d", &a, &b);
            printf("%d\n", a + b);
            break;
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int d[5001][5001]={0};
int main(){
  int i,j,a[5001],b[5001],A,B,an=0;
  scanf("%d%d",&A,&B);
  for(i=1;i<=A;i++)
    scanf("%d",&a[i]);
  for(i=1;i<=B;i++)
    scanf("%d",&b[i]);
  for(i=1;i<=B;i++){
    for(j=1;j<=A;j++){
      if(a[j]==b[i])
        d[i][j]=d[i-1][j-1]+1;
      d[i][j]=max(d[i][j],d[i][j-1]);
      an=max(d[i][j],an);
    }
  }
    /*for(i=1;i<=B;i++){
    for(j=1;j<=A;j++){
      printf("%d  ",d[i][j]);
    }
      printf("\n");
  }
  */
  printf("%d\n",an);
  return 0;
}



Measured memory_bytes: 100952
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i) // ROF(i,n,0)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define SUM(a) accumulate(all(a),int(0))
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

signed main(){
  int n; cin >> n;
  vvi v(10, vi(10)); // v[i][j] : n以下でi...jという形の数がいくつあるか

  FOR(k,1,n+1) {
    string s = to_string(k);
    v[s.front()-'0'][s.back()-'0']++;
  }

  int ans = 0;
  FOR(i,1,10) FOR(j,1,10) {
    ans += v[i][j] * v[j][i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
N, A = map(int, input().split())
X = list(map(lambda x: int(x) - A, input().split()))
dp = [[0 for j in range(100 * N + 1)] for i in range(N+1)]
dp[0][50 * N] = 1
for i in range(N):
	for j in range(50, 100*N + 1-50):
		dp[i+1][j] = dp[i][j] + dp[i][j - X[i]]
print(dp[N][50 * N] -1)

Measured memory_bytes: 5748
#include <stdio.h>

int main(void){
  int k,n,x[200],sum=0,minsum=1000000000;
  scanf("%d",&n);
  for(int i=0;i<=n-1;i++){
    scanf("%d",&x[i]);
  }
  for(k=1;k<=100;k++){
    for(int i=0;i<=n-1;i++){
      sum+=(k-x[i])*(k-x[i]);
    }
    if(minsum>sum) minsum=sum;
    sum=0;
  }

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

  return 0;

}

Measured memory_bytes: 1712
/*Bichrome_Cells
    ueki takafumi*/
#include <stdio.h>
int main(void){
    //変数の定義(N:マス目の数、A:白色のマスの数)
    int N,A;
    //入力受け取り
    scanf("%d",&N);
    scanf("%d",&A);
    //黒色のマス目の数を計算する
    printf("%d\n",N*N-A);
    
    return 0;
}

Measured memory_bytes: 1696