akhauriyash/Code-Regression huggingface dataset:
S = input()
T = input()
memo_ls = [[] for i in range(len(S)+1)]
res = ""
for i in range(len(T) + 1):
    memo_ls[0].append(0)
path = dict()
for i in range(len(S)):
    memo_ls[i+1].append(0)
    for j in range(len(T)):
        if S[i] == T[j]:
            cost = max(memo_ls[i][j] + 1, memo_ls[i][j+1], memo_ls[i+1][j])
            memo_ls[i+1].append(cost)
        else:
            memo_ls[i+1].append(max(memo_ls[i][j+1], memo_ls[i+1][j]))

x_ind = len(T)
y_ind = len(S)
while x_ind * y_ind > 0:
    if memo_ls[y_ind][x_ind] == memo_ls[y_ind-1][x_ind]:
        y_ind -= 1
    elif memo_ls[y_ind][x_ind] == memo_ls[y_ind][x_ind-1]:
        x_ind -= 1
    else:
        res += T[x_ind-1]
        x_ind -= 1
        y_ind -= 1
print(res[::-1])

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
signed main() {
    cin >> N;
    if(N==1){
        cout<<"Hello World"<<endl;
    }else{
        int A,B;
        cin>>A>>B;
        cout<<A+B<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
 int main(){

 	int n,m,x;
 	cin>>n>>m>>x;

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

    int sum=0,sum1=0;

 	for(int i=0;i<m;i++)
 		if(arr[i]>x)
 			sum++;
 		else
 			sum1++;

 	cout<<min(sum,sum1)<<'\n';
 	return 0;
 }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
#include <map>
using namespace std;

map<int, vector<int> > edges;

// ?????¢?????????
int s2t[100001];
int t2s[100001];

// ???????????¢???????????°
int s2t_kinds[100001];
int t2s_kinds[100001];

void bfs(int s, int* kyori) {
    queue<pair<int, int> > q;
    q.push( make_pair(s,0) );

    while (!q.empty()) {
        pair<int,int> p = q.front(); q.pop();
        int curr = p.first;
        int step = p.second;
        for (int i=0; i<edges[curr].size(); i++) {
            int next = edges[curr][i];
            if (*(kyori + next) != -1) continue;
            *(kyori + next) = step + 1;
            q.push( make_pair(next, step + 1) );
        }
    }
}

int main() {
    int n,m,s,t; cin >> n >> m >> s >> t;
    for (int i=0; i<m; i++) {
        int x,y; cin >> x >> y;
        if (edges.count(x) == 0) {
            vector<int> v; v.push_back(y);
            edges[x] = v;
        } else {
            edges[x].push_back(y);
        }
        if (edges.count(y) == 0) {
            vector<int> v; v.push_back(x);
            edges[y] = v;
        } else {
            edges[y].push_back(x);
        }
    }

    // init
    for (int i=0; i<=n; i++) s2t[i] = t2s[i] = -1;
    s2t[s] = t2s[t] = 0;

    bfs(s,s2t);
    bfs(t,t2s);

    for (int i=1; i<=n; i++) {
        if (s2t[i] != -1) {
            s2t_kinds[ s2t[i] ] += 1;
        }
        if (t2s[i] != -1) {
            t2s_kinds[ t2s[i] ] += 1;
        }
    }

    int dist = s2t[t];
    long long ans = 0;
    for (int i=0; i<=dist-2; i++) {
        ans += (long long)s2t_kinds[i] * (long long)t2s_kinds[dist - 2 - i];
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 15812
#include <bits/stdc++.h>
#define int long long
#define N 2000011

using namespace std;

const int MOD = (int)1e9 + 7;

int n;
int dp[N][2];
string s;

int f(int idx, int x) {
	if(idx == n) return 1;
	if(dp[idx][x] != -1) return dp[idx][x];
	int res = 0;
	if(x) res = (3 * f(idx+1, x)) % MOD;
	else {
		if(s[idx] == '0') res = f(idx+1, 0);
		else res = (f(idx+1, 1) + 2 * f(idx+1, 0)) % MOD;
	}
	return dp[idx][x] = res;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> s;
	n = (int)s.length();
	memset(dp, -1, sizeof dp);
	cout << f(0,0) << endl;
	return 0;
}


Measured memory_bytes: 36432
#include<bits/stdc++.h>
using namespace std;
#define f(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define d(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ri register int
#define ll long long
#define il inline
int max(int x, int y) {return x>y?x:y;} int min(int x, int y) {return x<y?x:y;}
int x,y,z;
int main(){
  scanf("%d%d%d", &x, &y, &z);
  printf("%d %d %d\n", z, x, y);
  return 0;
}
// sto wyxkk orz


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for ( k = left; k < right; k++ ) {
    if ( L[i].value <= R[j].value )
      A[k] = L[i++];
    else
      A[k] = R[j++];
  }
}

void mergeSort(struct Card A[], int left, int right) {
  int mid;
  if ( left + 1 < right ) {
    mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int partition(struct Card A[], int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ ){
    if ( A[j].value <= x.value ) {
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;   //i番目のカードとj番目のカードを入れ替える
    }
  }
  t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;  //i+1番目のカードとr番目のカードを入れ替える
  return i + 1;
}

void quickSort(struct Card A[], int p, int r) {
  int q;
  if ( p < r ) {
    q = partition(A, p, r);
    quickSort(A, p, q - 1);    //前半グループをソート
    quickSort(A, q + 1, r);    //後半グループをソート
  }
}

int main() {
  int num_card;               // カードの枚数
  int value_card;             // カードの数字
  char S[10];                 // カードのアルファベット
  struct Card A[MAX], B[MAX]; //Aの山札，Bの山札
  int stable = 1;             // 安定であれば１

  scanf("%d", &num_card);     // カードの枚数を入力

  for (int i = 0; i < num_card; i++ ) {
    scanf("%s %d", S, &value_card); // カードのアルファベット、数字を入力
    A[i].suit = B[i].suit = S[0];          // アルファベット登録
    A[i].value = B[i].value = value_card;  // 数字登録
  }

  mergeSort(A, 0, num_card);
  quickSort(B, 0, num_card - 1);

  for (int i = 0; i < num_card; i++ )
    if ( A[i].suit != B[i].suit ) stable = 0;

  if ( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for (int i = 0; i < num_card; i++ )
    printf("%c %d\n", B[i].suit, B[i].value);

  return 0;
}


Measured memory_bytes: 4048
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on
int A, B, C, D;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> A >> B >> C >> D;

  int ans = max(min(B, D) - max(A, C), 0);
  cout << ans << endl;

  return 0;
}


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

	public static void main(String[] args) {
		int INF = Integer.MAX_VALUE/2;
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int[] c = new int[26];
		Arrays.setAll(c, i -> sc.nextInt());
		int[][] s = new int[D][26];
		for(int i = 0; i < D; i++)
			Arrays.setAll(s[i], x -> sc.nextInt());
		int[] last = new int[26];
		for(int d = 1; d <= D; d++) {
			int max = -INF, now = 0;
			for(int i = 0; i < 26; i++) {
				int temp = 0;
				temp += s[d-1][i];
				for(int j = 0; j < 26; j++)
					if(i != j)
						temp -= c[j] * (d - last[j]);
				if(max < temp) {
					max = temp;
					now = i;
				}
			}
			System.out.println(now+1);
			last[now] = d;
		}
	}

}


Measured memory_bytes: 46796
#include <iostream>
#include <algorithm>
#include <iterator>
#include <vector>

using namespace std;

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int result = ((K <= A) ? K : (K <= A + B) ? A : (A - (K - A - B)));
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3636
n = int(input())
a = [int(x) for x in input().split()]

c = 0

for i in range(n):
    for j in range(1, n):
        if a[j - 1] > a[j]:
            tmp = a[j - 1]
            a[j - 1] = a[j]
            a[j] = tmp
            c += 1

print(" ".join([str(x) for x in a]))
print(c)

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

int N, M;
bool graph[8][8];

int dfs(int v, int N, bool visited[8]) {

    bool all_visited = true;

    for (int i = 0; i < N; i++) {
        if (visited[i] == false) {
            all_visited = false;
        }
    }

    if (all_visited) return 1;

    int ret = 0;

    for (int i = 0; i < N; i++) {
        if (visited[i] == true) continue;
        if (graph[v][i] == false) continue;

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}

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

    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b;
        graph[a-1][b-1] = graph[b-1][a-1] = true;
    }

    bool visited[8];
    visited[0] = true;
    cout << dfs(0, N, visited) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  string s;
  cin >> s;
  int n = s.length();
  int l = 0, r = n - 1;
  int ans = 0;
  while (l < r) {
    if (s[l] == s[r]) {
      l++, r--;
    } else if (s[l] == 'x') {
      l++, ans++;
    } else if (s[r] == 'x') {
      r--, ans++;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3752
use proconio::input;

#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::*;

fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize,
    }
 
    println!("{} {} {}", c, a, b);
}


Measured memory_bytes: 2080
#include <iostream>
#include <string>
using namespace std;
int main( void )
{
	string input;
	while ( cin >> input )
	{
		bool at = false;
		for ( string::iterator it = input.begin(); it != input.end(); it++ )
		{
			if ( *it == '@' )
			{
				at = true;
			}
			else if( at )
			{
				int n = (int)((*it)-'0');
				it++;
				while( n-- )
				{
					cout << *it;
				}
				at = false;
			}
			else
			{
				cout << *it;
			}
		}
		cout << endl;
	}
	return 0;
}

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

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  
  if (A[A.size()-1] == B[0] && B[B.size()-1] == C[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3624
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

S = np.array(list(sys.stdin.readline().rstrip()))
a = np.any(S[::2] == 'L') or np.any(S[1::2] == 'R')
if not a:
    print('Yes')
else:
    print('No')




Measured memory_bytes: 23248
N, K = map(int,input().split())
A = list(map(int,input().split()))

def get_gcd(a,b):
    if b > a:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b

gcd  = A[0]
max_a = A[0]
for i in range(1, N):
    a = A[i]
    if a == K:
        print("POSSIBLE")
        exit()
    if a > max_a:
        max_a = a
    gcd = get_gcd(gcd, a)

if max_a < K:
    print("IMPOSSIBLE")
    exit()
else:
    if K % gcd == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Measured memory_bytes: 14224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static int sum;
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        addList(1, n, 3 , new List<int>());
        Console.WriteLine(sum);
    }

    static void addList(int start, int end, int len, List<int> list)
    {
        if (list.Count() == len)
        {
            sum += culcKouyaku(list);
            return;
        }
        for (int i = start; i <= end; i++)
        {
            List<int> copyList = new List<int>(list);
            copyList.Add(i);
            addList(i, end, len, copyList);
        }
    }

    static int culcKouyaku(List<int> list)
    {
        int rate = list.Distinct().Count();
        if (rate == 2) rate = 3;
        else if (rate == 3) rate = 6;
        int kouyaku = Gcd(Gcd(list[0],list[1]),list[2]);
        return rate * kouyaku;

    }

    public static int Gcd(int a, int b)
    {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }



}



Measured memory_bytes: 22704
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl; 
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a,LL b){LL s=1;while(b>0){if(b&1)s=s*a%mod;a=a*a%mod;b>>=1;}return s;}
LL gcd(LL a,LL b) {return b?gcd(b,a%b):a;}
int dr[2][4] = {1,-1,0,0,0,0,-1,1};
typedef pair<int,int> P;
int main(void)
{
    int a;cin>>a;
    cout<<3*a*a<<endl;

   return 0;
}

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

#define pii pair<int, int>;
#define pll pair<long long, long long>;

using namespace std;

vector<int> used(20100);
long long n, y;

int main() {
    cin >> n >> y;
    for (int a = 0; a <= n; a++){
        for (int b = 0; b <= n - a; b++){
            int c = n - a - b;
            if (a * 1000LL + b * 5000LL + c * 10000LL == y){
                cout << c << ' ' << b << ' ' << a << endl;
                return 0;
            }
        }
    }
    cout << -1 << ' ' << -1 << ' ' << -1;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	vector<Int> a(N);
	for (Int i = 0; i < N; i++) {
		cin >> a[i];
	}

	vector<Int> yama(N);
	Int sum = 0;
	for (Int i = 0; i < N; i++) {
		sum += a[i];
	}

	Int odd = 0;
	for (Int i = 1; i < N-1; i+=2) {
		odd += a[i];
	}

	yama[0] = (sum - 2*odd) / 2;
	for (Int i = 1; i < N; i++) {
		yama[i] = a[i - 1] - yama[i - 1];
	}

	for (Int i = 0; i < N; i++) {
		printf("%ld ", 2 * yama[i]);
	}
}

Measured memory_bytes: 2944
#define _CRT_SECURE_NO_vARNINGS
#include <vector>
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <queue>
#include <string>
#include <climits>
#include <list>
#include <cmath>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> v(n, 0);
	for (int i = 0; i < n; i++) cin >> v[i];
	// dp[i] = min(dp[i-1]+ abs(v[i]-v[i-1]), dp[i-2]+abs(v[i]-v[i-2]))
	vector<int> dp(n, 0);
	dp[0] = 0;
	dp[1] = abs(v[1] - v[0]);
	for (int i = 2; i < n; i++) {
		dp[i] = min(dp[i - 1] + abs(v[i] - v[i - 1]), dp[i - 2] + abs(v[i] - v[i - 2]));
	}
	cout << dp[n - 1];
	return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
from fractions import gcd
from string import ascii_lowercase as ABC
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
H = int(input())
W = int(input())
N = int(input())
X = max(H, W)
print(-(-N//X))

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  int N;
  cin>>N;
  vector<ll> A(N),B(N),C(N);
  for(int i = 0; i < N;i++) cin>>A[i];
  for(int i = 0; i < N;i++) cin>>B[i];
  for(int i = 0; i < N;i++) cin>>C[i];
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  ll ans = 0LL;
  for(int i = 0; i < N; i++) {
    int t = B[i];
    auto ia=lower_bound(A.begin(),A.end(),t);
    auto ic=upper_bound(C.begin(),C.end(),t);
    ans+=((ll)(ia-A.begin()))*(ll)(C.end()-ic);
  }
  cout<<ans<<endl;
}

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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve(){
    ll x, n;
    cin >> x >> n;
    ll a[n], s = 0;
    rep(i, n){
    	cin >> a[i];
    	s += a[i];
    }
    if(x > s){
    	cout << "No\n";
    }
    else{
    	cout << "Yes\n";
    }
}

int main(){
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        solve();
    }
    return 0;
}


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

int main() {
  int A, B, sum, x;
  cin >> A >> B;
  sum = 0;
  x = A;
  
  for(int i = 0; i <= B - A; i++ ){
    int a, b, c, d;  
    a = x / 10000;
    b = (x % 10000) / 1000; 
    c = (x % 100) / 10;
    d = x % 10;
    if(a == d && b == c  ){
      sum = sum + 1; 
    }
    x = x + 1;
  }
  cout << sum << endl;
  
}

Measured memory_bytes: 3608
#include<stdio.h>
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,j,n) for((i)=(j) ; (i)<(n) ; (i)++)
#define pl(format,var) p(format "\n",var)
#define p(format,var) printf(format,var)
#define asizeof(array) (sizeof(array)/sizeof(array[0]))

/*
[履歴]
・ちょっと調べた。探索方法を簡易できることを発見。オーダn^3からn^2に
・できたんでsubmit→TLE / 総当りはダメなのかあ. 無限ループから抜けれないわけじゃないし…

[メモ1]
5000 * 100000 = 500000000 (5億)
→intで収まる範囲

1.全パターンを調べる
X X X の場合
o
o o
o o o
  o
  o o
    o
3+2+1=7
→nコの並びなら, n+(n-1)+…+1 = n(n+1)/2
  公式忘れてたけど、ガウスの逸話のおかげで助かった。
これならO(n^2)。
イケそうだが…別案も考えてみよか。

別案、思いつかないんで、とりあえずこれで。

[メモ2]
よく見たら制限時間1secやん。
こりゃあアルゴリズム変えるしか無さそうだ。

それまでの最大値と, 自分と, 自分とそれまでの最大値
→この中の最大値を新たな最大値にするってのはどや。
  ⇒ダメ。連続しない項の和が入るわ…

だったら、これをアレンジして、連続しない和にならないように選択してく。
例. 3, 1000, -200, 201と入力した場合

  1000 (MIN_VAL, 1000, 1000+MIN_VAL) … 最大値は1000
  -200 (1000, -200, 1000-200) … 最大値は800(1000を)
  201 (800, 201, 800+201) … 最大値は1001

あーこれもダメ。1000, -200, -1 だと狂う。

[メモ3]
簡略化アプローチ

・正が連続する部分
  a b c → a+b+c

あとは、正と負が交互に来るパターンと、負が何個か並ぶパターンとに分かれる。
ここからさらに簡略化できないか。負の項が何とかできそうな気がするが…

12/12/10はここで降参。。。

[メモ4]
ちょっと調べた。
探索方法を簡易に出来ることを発見。
今までO(n^3)だったけど、O(n^2)にまで減らせる。
→つーか、メモ1で書いてるじゃん、そのアルゴリズム…

*/

#define MAX_TERM 5000
#define MAX_VAL 100000
int data[MAX_TERM]; //各項の値を入れておく配列

int main(){
  char line[80]; //入力行
  int i,j,k; //カウンタ変数
  int n; //各データセットの項数
  int maxsum; //連続する項の和の最大値
  int cursum; //現在の項の和
  
  while(1){ //無限ループbegin
    //項数の入力を受け付ける
    fgets(line, sizeof(line), stdin);
    sscanf(line, "%d", &n);
    
    //項数が0なら終了する
    if(n==0)
      break;
    
    //項数だけ入力を受け付けて, 配列に格納
    rep2(i,n){
      fgets(line, sizeof(line), stdin);
      sscanf(line, "%d", &data[i]);
    }
    
    //最大値は, 最小値で初期化しておく
    //→最大値がこの値を下回ることはない
    maxsum = -1 * MAX_VAL;
    
    //最大値を計算する
    rep2(i,n){
      cursum = 0;
      rep3(j,i,n){
        cursum += data[j];
        if(maxsum < cursum)
          maxsum = cursum;
      }
    }

    //↓のように走査して, 和を求めて, 最大値を比較していく
    // XXX(項の長さが1のとき, 和は3つ)
    // o
    //  o
    //   o
    //
    // XXX(項の長さが2のとき, 和は2つ)
    // oo
    //  oo
    //
    // XXX(項の長さが3のとき, 和は1つ)
    // ooo
    // これはn^3。遅い。
    /*
    rep2(i,n){
      rep2(j,n-i){
        cursum = 0;
        rep3(k,j,j+i+1){
          cursum += data[k];
        }
        if(maxsum < cursum)
          maxsum = cursum;
      }
    }
    */
    
    //最大値を出力
    pl("%d",maxsum);
  }//無限ループend
  return 0;
}

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


int main() {
  string s;
  cin>>s;
  ll mod=1e9+7,sum;
  ll n=s.size();
  ll dp[1000000][13];
  dp[0][0]=1;
  
  for(ll i=0; i<n; i++){
    ll c=0;
    if(s[i]=='?'){
      c=-1;
    }else{
      c=s[i]-'0';
    }
    for(ll j=0; j<10; j++){
      
      if(c!=-1&&c!=j)
        continue;
      for(ll k=0; k<13; k++){
        dp[i+1][(k*10+j)%13]+=dp[i][k];
      }
    }
    for(ll j=0; j<13; j++)
        dp[i+1][j]%=mod;
  }
     sum=dp[n][5]; 
   cout<<sum<<endl; 
  
}

Measured memory_bytes: 12544
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i,n) for(int i = 0; i < int(n);++i)
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define sz(x) (int)x.size()

void solve(){

}

int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    /* ll t;
    cin >> t;
    while(t--){
    	solve();
    }*/
    string s;
    ll n;
    cin >> n;
    cin >> s;
    int ans = 0;
    forn(i,sz(s)-1){
        if(s[i] != s[i+1]){
            ans++;
        }
    }
    cout << ans+1;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<cstring>
//#define Mfc_Tanzim
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ff first
#define ss second
#define all(v) (v.begin(), v.end())
#define pi acos(-1.0)
#define FastRead ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define bug(a) cerr << #a << " : " << a << endl
using namespace std;
const ll mx = 4010;

ll posx[] = {1,-1, 0, 0};
ll posy[] = {0, 0, 1,-1};

int main()
{
    FastRead

#ifdef Mfc_Tanzim
    freopen("input.txt","r", stdin);
    // freopen("output.txt","w", stdout);
#endif /// Mfc_Tanzim

    ll t = 1, n, k, l, r, d;
    //cin >> t;

    while(t--){
        cin >> l >> r >> d;
        ll ans = 0, k = d;
        while(1){
            if(d>=l && d<=r){
                ans++;
            }
            d=d+k;
            if(d>r){
                break;
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    ll s;
    cin >> s;
    ll n=s;
    ll sum=0;
    while(n)
    {
        ll a=n%10;
        sum+=a;
        n/=10;
    }
    if(s%sum==0)
        cout << "Yes\n";
    else
        cout << "No\n";
}


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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	forn(i,0,5){
		int x; cin >> x;
		if(!x){
			cout << i+1 << '\n';
			break;
		}
	}
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 3596
#include <stdio.h>

int main()
{
	int d[3], j, i, tenp;
	
	scanf("%d %d %d", &d[0], &d[1], &d[2]);
	
	for (j = 0; j < 3; j++)
	{
		for (i = j + 1; i<3; i++)
		{
			if (d[j]>d[i])
			{
				tenp = d[j];
				d[j] = d[i];
				d[i] = tenp;
			}
		}
	}

	
	printf("%d %d %d\n", d[0], d[1], d[2]);
	


	return 0;
}

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

int main() {
 int n;
 cin >> n;
 
 vector<int> a(n);
 rep(i,n) {
  cin >>a.at(i);
  }
  
  vector<int> b(n);
  rep(i,n) {
  cin>>b.at(i);
  }
  
  vector<int> c(n);
  c.at(0) = 0;
 for(int i = 1;i<n;i++) {
  cin>>c.at(i);
  }
   
   int ans = 0;
   

     for(int i =0; i<n-1;i++) {
    if(a.at(i)+1 == a.at(i+1)) {
     ans+=c.at(a.at(i));}
     }
     
   for(int i = 0; i<n;i++) {
    ans+=b.at(i);
    }
    
    cout << ans;
    


}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>


#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;
class UnionFind
{
public:
	UnionFind(int min, int max)
		: elems_(max - min + 1)
		, min_(min)
		, rank_(max - min + 1)
	{
		for (int i = min; i <= max; i++) {
			Elem& elem = this->elems_[i - min];
			elem.i = i;
			elem.num = 1;
		}
	}

	int find(int i) {
		int idx = i - this->min_;
		if (this->elems_[idx].i == i) return i;

		int root = this->find(this->elems_[idx].i);
		this->elems_[idx].i = root; // 簡略化
		return root;
	}

	int size(int i) {
		int root = this->find(i);
		int idx = root - this->min_;
		return this->elems_[idx].num;
	}

	int rank() {
		return rank_;
	}

	void merge(int i, int j) {
		int i_root = this->find(i);
		int j_root = this->find(j);
		if (i_root == j_root) return;

		int i_idx = i_root - this->min_;
		int j_idx = j_root - this->min_;

		int i_size = this->elems_[i_idx].num;
		int j_size = this->elems_[j_idx].num;

		if (i_size < j_size) {
			this->elems_[i_idx].i = j_root;
			this->elems_[j_idx].num += this->elems_[i_idx].num;
		}
		else {
			this->elems_[j_idx].i = i_root;
			this->elems_[i_idx].num += this->elems_[j_idx].num;

		}
		this->rank_--;
	}

private:
	struct Elem {
		int i;
		int num; // root 以外は無効
	};

	vector<Elem> elems_;
	int          min_;
	int          rank_;
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, m, k; cin >> n >> m >> k;

	UnionFind uf(1, n);
	vector<unordered_set<int>> nb(n + 1);
	vector<unordered_set<int>> nf(n + 1);

	FOR_LT(i, 0, m) {
		int a, b; cin >> a >> b;
		uf.merge(a, b);
		nf[a].insert(b);
		nf[b].insert(a);
	}
	FOR_LT(i, 0, k) {
		int a, b; cin >> a >> b;
		nb[a].insert(b);
		nb[b].insert(a);
	}

	FOR_LE(i, 1, n) {
		int ns = uf.size(i) - nf[i].size() - 1;
		for (auto b : nb[i]) {
			if (uf.find(i) == uf.find(b)) ns--;
		}
		cout << ns << " ";
	}
	cout << endl;
	cout << endl;

	return 0;
}

Measured memory_bytes: 33152
n=int(input())
f=[list(map(int,input().split())) for i in range(n)]
p=[list(map(int,input().split())) for i in range(n)]

ans=-10**18
for i in range(1<<10):
  if i==0:continue
  tp=0
  for j in range(n):
    tcnt=0
    for k in range(10):
      if i&(1<<k):tcnt+=f[j][k]
    tp+=p[j][tcnt]
  ans=max(ans,tp)
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <bitset>
#include <cmath>

using namespace std;

int main()
{

    bitset<18> subset, T;
    
    int n, k;
    cin >> n >> k;

    int upper = pow(2, n);
    for (int i = 0; i < upper; i++)
    {
        subset = i;
        if (subset.count() == k)
        {
            cout << i << ":";            
            for (int j = 0; j < n; j++)
            {
                if (subset[j])
                {
                    cout << ' ' <<  j;
                }
            }
            cout << endl;            
        }

    }
}


Measured memory_bytes: 3284
def inp():exec('global inppp\ninpmoto,inppp=input().split(),[]\nfor i in inpmoto:\n try:inppp.append(int(i))if float(i).is_integer()else inppp.append(float(i));\n except:\n  try:inppp.append(str(i))\n  except:print("error in inp")');return inppp[0]if len(inppp)==1else list(inppp)
n = inp()
if str(n)[-1] == "2" or str(n)[-1] == "4" or str(n)[-1] == "5" or str(n)[-1] == "7" or str(n)[-1] == "9":
    print("hon")
elif str(n)[-1] == "0" or str(n)[-1] == "1" or str(n)[-1] == "6" or str(n)[-1] == "8":
    print("pon")
else:
    print("bon")

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;


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

	if(n==1){
		cout<<"Yes"<<endl;
		return 0;
	}

	bool flag=true;
	for (int i = n-1; i > 0; i--){
		if(h[i]>=h[i-1])continue;
		h[i-1]--;
		if(h[i]<h[i-1]){
			flag=false;
		}
	}

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

	return 0;
}
	

Measured memory_bytes: 640
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long num = 0;
        int cnt = 1;
        long[] array26 = new long[10000000];
        while (num < N){
            num = num + (long) Math.pow(26, cnt);
            array26[cnt] = num;
            cnt++;
        }

        long digit_num = 0;
        digit_num = N - array26[cnt - 2] - 1;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < cnt - 1; i++){
            sb.append(String.valueOf((char) (digit_num % 26 + 97)));
            digit_num = digit_num / 26;
        }
        StringBuffer reverseString = new StringBuffer(sb.toString());
        System.out.println(reverseString.reverse().toString());
    }
}

Measured memory_bytes: 115928
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N;
    int A[114514];
    cin >> N;
    REP(i,N){cin >> A[i];}
    if(N==1){
        cout << 1 << endl;
        return 0;
    }
    int Ans=1,mode=0;
    ZREP(i,N){
        if(A[i-1]<A[i]){
            if(mode==-1){
                Ans++;mode=0;
            }else{
                mode=1;
            }
        }else if(A[i-1]>A[i]){
            if(mode==1){
                Ans++;mode=0;
            }else{
                mode=-1;
            }
        }
    }
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
using namespace std;

int cnt;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;
#define inf 1000000001
void merge(int a[], int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int l[n1 + 1], r[n2 + 1];
    rep(i, n1) l[i] = a[left + i];
    rep(i, n2) r[i] = a[mid + i];
    l[n1] =  inf;
    r[n2] = inf;
    int i = 0, j = 0;
    for(int k = left; k < right; k++){
        cnt++;
        if(l[i] <= r[j]){
            a[k] = l[i];
            i++;
        }else{
            a[k] = r[j];
            j++;
        }
    }
}

void mergesort(int a[], int left, int right){
    if(left + 1 < right){
        int mid = (left + right) / 2;
        mergesort(a, left, mid);
        mergesort(a, mid, right);
        merge(a, left, mid, right);
    }
}

int main(){
    int a[5000000], n;
    cnt = 0;
    cin >> n;
    rep(i, n) cin >> a[i];
    mergesort(a, 0, n);
    rep(i, n){
        if(i) cout << " ";
        cout << a[i];
    }
    cout << endl << cnt << endl;
}


Measured memory_bytes: 6928
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>
#include <cstdio>

using namespace std;

class Stand {
public:
	int r;
	int num;
};

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	vector<Stand> stand;
	stand.emplace_back();
	stand.back().r = s[0] == '0' ? 0 : 1;
	stand.back().num = 1;
	for (int i = 1; i < n; i++) {
		if (s[i - 1] == s[i]) {
			stand.back().num++;
		}
		else {
			stand.emplace_back();
			stand.back().r = s[i] == '0' ? 0 : 1;
			stand.back().num = stand[stand.size() - 2].num + 1;
		}
	}
	int tmp0 = 0;
	for (int i = 0; i < stand.size(); i++) {
		if (stand[i].r == 0)tmp0++;
	}
	if (tmp0 <= k) {
		cout << n << endl;
		return 0;
	}

	int max = 0;
	int k_ = k * 2 + 1;


	if (s[0] == '0') {
		max = stand[k * 2 - 1].num;
		for (int i = 1; i + k_ - 1 < stand.size(); i += 2) {
			int min = 0;
			if (i - 1 >= 0)min = stand[i - 1].num;
			max = std::max(max, stand[i + k_ - 1].num - min);
		}
	}
	else {
		for (int i = 0; i + k_ - 1 < stand.size(); i += 2) {
			int min = 0;
			if (i - 1 >= 0)min = stand[i - 1].num;
			max = std::max(max, stand[i + k_ - 1].num - min);
		}
	}
	if (s[n - 1] == '0') {
		int min = 0;
		if (stand.size() - 1 - k * 2 >= 0)min = stand[stand.size() - k * 2 - 1].num;
		max = std::max(max, n - min);
	}
	cout << max << endl;

	return 0;
}

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

/*
##Knigh's moves without attack
ll sq = n*n;
ll a = sq*(sq-1)/2; //all moves
ll b = 4*(n-1)*(n-2); //moves with attack
z = a - b; //moves without

##2^k
for(int i = 0; i < n; ++i)
ans = 2*ans%((int)1e9+7);

## 'x' from (a) and 'y' from (b) 
(a+b)%(x+y)==0  2*a>=b && 2*b>=a gap checker 




*/

const int MOD = 1e9+7;
const int MX = 1e6+5;
int arr[MX];
//int dp[MX];



int main() {
      ios::sync_with_stdio(0);
      cin.tie(0);
      int n, x;
      cin >> n >> x;

      for(int i = 0; i < n; ++i)
        cin >> arr[i];
      vector<int> dp(n,1e9);
      dp[0] = 0;

      for(int i = 0; i < n; ++i)
        for(int j = i+1; j <= i+x; ++j)
          dp[j] = min(dp[j], dp[i] + abs(arr[i]-arr[j]));

        cout<<dp[n-1];
      
    return 0;
}




Measured memory_bytes: 4008
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<list>
#include<string>
#define ll long long 
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
#define E exp(1)
#define mod 1e9+7
int main()
{
	string s;
	cin>>s;
	if(s=="SUN")
	cout<<7<<endl;
	else if(s=="MON")
	cout<<6<<endl;
	else if(s=="TUE")
	cout<<5<<endl;
	else if(s=="WED")
	cout<<4<<endl;
	else if(s=="THU")
	cout<<3<<endl;
	else if(s=="FRI")
	cout<<2<<endl;
	else if(s=="SAT")
	cout<<1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<ll>>;
using P = pair<int,int>;
#define MOD 1000000007
#define INF 1000000
#define PI 3.14159265358979323846

ll nC2[200020];

ll init()
{
  nC2[0]=0;
  nC2[1]=0;
  for (ll i=2;i<=200010;i++)
  {
    nC2[i]=i*(i-1)/2; 
  }
}

int main()
{
  ll N;cin>>N;
  vector<ll> A(N+1);
  vector<ll> ball(N+1);
  for (ll i=1;i<=N;i++)
  {
    cin>>A[i];
    ball[A[i]]++;
  }
  
  init();
  
  vector<ll> cnt(N+1,0);
  
  ll count=0;
  for (ll i=1;i<=N;i++)
  {
    count += nC2[ball[i]];
  }
  
  for (ll i=1;i<=N;i++)
  {
      cout<< count-(ball[A[i]]-1)<<endl;
  }
}

Measured memory_bytes: 8832
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b && a!=c) printf("%d\n",c);
    else if(a==c && a!=b) printf("%d\n",b);
    else if(b==c && b!=a) printf("%d\n",a);
    return 0;
}


Measured memory_bytes: 128
def check(n, y):
    for i in range(y // 10000 + 1):
        for j in range(n - i + 1):
            k  = n - i - j
            if 10000 * i + 5000 * j + 1000 * k == y:
                return [i, j, k]

    return [-1, -1, -1]

n, y = map(int, input().split())
ans = check(n, y)
print(ans[0], ans[1], ans[2])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int N,M,ans;
int G[10][10];
bool used[10];

void dfs(int v,int c){
    if(c==N){
        ans++;
        return;
    }
    used[v]=1;
    REP(i,N) if(!used[i] and G[v][i]) dfs(i,c+1);
    used[v]=0;
}

signed main()
{
    cin>>N>>M;
    REP(i,M){
        int a,b; cin>>a>>b;
        a--; b--;
        G[a][b]=G[b][a]=1;
    }
    dfs(0,1);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
    string s = scan;
    string ans;
    foreach(c; s){ if(c == '?') ans ~= 'D'; else ans ~= c; }
    ans.print;
}



Measured memory_bytes: 3704
import sys

def main():
        run()

def run():
        data = input()
        splited = [int(x) for x in data.split(" ")]

        sum_cost = 0
        prev_cost = 0
        while(splited):
                cost = max(splited)
                splited.remove(cost)
                if prev_cost != 0:
                        sum_cost += abs(prev_cost - cost)
                prev_cost = cost
        print(sum_cost)

if __name__ == "__main__":
        main()

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

struct node {
	struct node *right;
	struct node *left;
	struct node *parent;
	int key;
};

typedef struct node * Node;
#define NIL NULL

Node root;

Node treeSearch(Node root, int k) {
	if (root->key = k) return root;
	if (root->key < k) {
		if (root->left != NIL) return treeSearch(root->left, k);
		else return NIL;
	} else {
		if (root->right != NIL) return treeSearch(root->right, k);
		else return NIL;
	}
}

void insert(int k) {
	Node y = NIL;
	Node x = root;
	Node z;

	z = malloc(sizeof(struct node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	
	if (y == NIL) {
		root = z;
	} else if (z->key < y->key) {
		y->left = z;
	} else {
		y->right = z;
	}
}

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

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

void treeDelete(Node z) {
	Node y;
	Node x;
	return;
}

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

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

Measured memory_bytes: 24036
#include<iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int prev = -1;
    int curr , cnt = 0 , sum = 0;
    for(int i=0;i<n;++i)
    {
        cin>>curr;
        if(curr == prev)
            ++cnt;
        else
        {
            sum += cnt/2;
            cnt = 1;
            prev = curr;
        }
    }
    sum += cnt/2;
    cout<<sum<<"\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int S = sc.nextInt();
      int W = sc.nextInt();
      String result = "";
      
      // 判定
      if(S <= W){
        result = "unsafe";
      }else{
        result = "safe";
      }
      
      
      // 出力
      System.out.println(result);
    }
}

Measured memory_bytes: 35800
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct city {
	int P;
	int Y;
	int cityNo;
	int downAutheNo;
};

int ascY(const void *a, const void *b) {
	struct city *A = (struct city *)a;
	struct city *B = (struct city *)b;
	return A->Y - B->Y;
}

int ascCityNo(const void *a, const void *b) {
	struct city *A = (struct city *)a;
	struct city *B = (struct city *)b;
	return A->cityNo - B->cityNo;
}

int main() {
	int N, M, i, Pcount[100001];
	struct city ans[100000];
	memset(Pcount, 0, sizeof(Pcount));

	scanf("%d %d", &N, &M);
	for (i = 0; i < M; i++) {
		scanf("%d %d", &ans[i].P, &ans[i].Y);
		ans[i].cityNo = i + 1;
	}

	qsort(ans, M, sizeof(struct city), ascY);

	for (i = 0; i < M; i++) {
		Pcount[ans[i].P]++;
		ans[i].downAutheNo = Pcount[ans[i].P];
	}

	qsort(ans, M, sizeof(struct city), ascCityNo);

	for (i = 0; i < M; i++) {
		printf("%06d%06d\n", ans[i].P, ans[i].downAutheNo);
	}

	return 0;
}

Measured memory_bytes: 4972
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/


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

	ll n, m;
	cin >> n >> m;

	// 最大の最大公約数 → ans * a ですべて構成される
	// すべてがansで割れる
	// ansでmを割って、その上その値がn以上ならおけ

	for (int ans = m / n; ans > 0; ans--) {
		if (m % ans == 0) {
			if ((m / ans) >= n) {
				cout << ans << endl;
				return 0;
			}
		}
	}

	// mの約数をすべて表示
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

const ll INF = 1LL << 60;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    int rest = N - N / 2 - N / 2 + 1;
    vector<vector<ll>> dp(N, vector<ll>(rest + 1, -INF));
    rep(i, 0, rest + 1) {
        dp[i][rest - i] = A[i];
    }
    rep(i, 0, N) rep(j, 0, rest + 1) {
        rep(k, 0, j + 1) {
            if (i + k + 2 >= N) {
                break;
            }
            chmax(dp[i + k + 2][j - k], dp[i][j] + A[i + k + 2]);
        }
    }
    ll ans = -INF;
    rep(i, 0, rest + 1) {
        chmax(ans, dp[N - 1 - i][i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15876