akhauriyash/Code-Regression huggingface dataset:
import sys
from typing import List


COMP_NUM = 0


def merge(elements: List[int], left: int, mid: int, right: int) -> None:
    global COMP_NUM
    n1 = mid - left
    n2 = right - mid
    left_array = [0] * (n1 + 1)
    right_array = [0] * (n2 + 1)
    left_array[0:n1] = elements[left:left + n1]
    left_array[n1] = sys.maxsize
    right_array[0:n2] = elements[mid:mid + n2]
    right_array[n2] = sys.maxsize

    i = 0
    j = 0
    for k in range(left, right):
        COMP_NUM += 1
        if left_array[i] <= right_array[j]:
            elements[k] = left_array[i]
            i += 1
        else:
            elements[k] = right_array[j]
            j += 1


def merge_sort(elements: List[int], left: int, right: int) -> None:
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(elements, left, mid)
        merge_sort(elements, mid, right)
        merge(elements, left, mid, right)


if __name__ == "__main__":
    n = int(input())
    elements = list(map(lambda x: int(x), input().split()))
    merge_sort(elements, 0, len(elements))
    print(" ".join([str(elem) for elem in elements]))
    print(f"{COMP_NUM}")



Measured memory_bytes: 76140
//#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <algorithm>
#include <vector>
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 IO(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);
const int inf = 0x3f3f3f3f;
const int maxn=55;
//int road[maxn][maxn];
int n,m;
int fa[maxn];
int vis[maxn];
struct Edge{int u,v;}e[2500];
void init()
{
    for(int i=1;i<=n;i++) {fa[i]=i;}
    memset(vis,0,sizeof(vis));
}
int F(int x){return x==fa[x]?x:F(fa[x]);}
int main()
{
  cin>>n>>m;
  int cnt=0;
  for(int i=1;i<=m;i++) scanf("%d%d",&e[i].u,&e[i].v);
  for(int k=1;k<=m;k++)
  {
    init();
    int num=0;
    // de(k);
    for(int i=1;i<=m;i++)
    {
     if(i==k) continue;
     int u=e[i].u,v=e[i].v;
     if(F(u)==F(v)) continue;
     fa[F(u)]=F(v);
    }
    for(int i=1;i<=n;i++) vis[F(i)]=1;
    for(int i=1;i<=n;i++){if(vis[i]) num++; }
    if(num==1) cnt++;
    }
    cout<<m-cnt;
  return 0;
}


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

using namespace std;

using ll = long long;

bool Dfs(const int cur, auto &visited, const auto &adj) {
    visited[cur] = 1;
    for (auto v : adj[cur]) {
        if (visited[v] == 1) return true;
        else if (!visited[v] && Dfs(v, visited, adj)) return true;
    }
    visited[cur] = 2;
    return false;
}

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

    int n, m;
    string s;
    cin >> n >> m >> s;

    vector<vector<int>> adj(2 * n);
    for (int i = 0, u, v; i < m; ++i) {
        cin >> u >> v; --u; --v;
        if (s[u] == s[v]) {
            adj[u].push_back(v + n);
            adj[v].push_back(u + n);
        }
        else {
            adj[u + n].push_back(v);
            adj[v + n].push_back(u);
        }
    }

    vector<char> visited(2 * n, 0);
    bool is_cycle = false;
    for (int v = 0; v < n; ++v) {
        if (!visited[v]) {
            if (Dfs(v, visited, adj)) {
                is_cycle = true;
                break;
            }
        }
    }

    if (is_cycle) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 23376
#include<stdio.h>

int a[26];

int main(){
	char S[200001],T[200001];
	scanf("%s%s",S,T);
	
	int c=0;
	int s[200001],t[200001];
	for(int i=0;i<26;i++)a[i]=0;
	for(int i=0;S[i]!='\0';i++){
		if(a[S[i]-'a']==0){
			c++;
			a[S[i]-'a']=c;
		}
		s[i]=a[S[i]-'a'];
	}
	c=0;
	for(int i=0;i<26;i++)a[i]=0;
	for(int i=0;T[i]!='\0';i++){
		if(a[T[i]-'a']==0){
			c++;
			a[T[i]-'a']=c;
		}
		t[i]=a[T[i]-'a'];
	}
	for(int i=0;S[i]!='\0';i++){
		if(s[i]!=t[i]){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 2176
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

const int MSQ = sqrt(N) + 5;

std::vector<int> wa;
bool  y[1000005];
void sieve(){
	for(int i=2;i<=1000000;i++){
		if(y[i])continue;
		wa.pb(i);
		for(int j=i;j<=1000000;j+=i){
			y[j]=1;
		}
	}
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	
	int n;

	scanf("%d",&n);
	int ans = 0;
	set<int>s;
	for(int i=0,x;i<n;i++){
		scanf("%d",&x);
		s.insert(x);
		if(*s.begin()==x)ans++;
	}
	printf("%d\n",ans );
}		



Measured memory_bytes: 9600
using System;

namespace AOJ.Volume1
{
    public class Alphametic
    {
        public static int Main()
        {
            while (true)
            {
                var input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }

                var sp = input.Split(new char[] { '+', '=' });
                string left = sp[0];
                string right = sp[1];
                string ans = sp[2];

                // ????????§???????????§?????????????????????????????????????????????
                int counter = Math.Max(left.Length, right.Length);
                left = left.PadLeft(counter, '0');
                right = right.PadLeft(counter, '0');
                char[] left_arr = new char[counter];
                for (int i = 0; i < counter; i++) { left_arr[i] = i < left.Length ? left[i] : '0'; }
                Array.Reverse(left_arr);

                char[] right_arr = new char[counter];
                for (int i = 0; i < counter; i++) { right_arr[i] = i < right.Length ? right[i] : '0'; }
                Array.Reverse(right_arr);

                bool success = false;
                for (int i = 0; i <= 9; i++)
                {
                    char[] ans_arr = new char[counter + 1];
                    bool kuri = false;
                    for (int j = 0; j < counter; j++)
                    {
                        int a = left_arr[j] == 'X' ? i : int.Parse(left_arr[j].ToString());
                        int b = right_arr[j] == 'X' ? i : int.Parse(right_arr[j].ToString());
                        int an = a + b + (kuri ? 1 : 0);
                        // ?¬????????¨???????????????°?????????????????§??????
                        kuri = an >= 10 ? true : false;
                        ans_arr[j] = char.Parse((an % 10).ToString());
                    }
                    if (kuri) { ans_arr[counter] = '1'; }
                    else { ans_arr[counter] = '0'; }

                    // ??????????????§??????
                    Array.Reverse(ans_arr);
                    string ans_chk = "";
                    string ans_tmp = ans.Replace("X", i.ToString());
                    for (int j = 0; j <= counter; j++)
                    {
                        if (j == 0 && ans_arr[j] == '0') { continue; }
                        ans_chk += ans_arr[j];
                    }
                    if(ans_tmp == ans_chk)
                    {
                        success = true;
                        Console.WriteLine(i);
                        break;
                    }
                }

                if (!success) { Console.WriteLine("NA"); }
            }

            return 0;
        }
    }
}

Measured memory_bytes: 9248
import java.util.Scanner;

class Main{
  static void output(int[] a){
    int i;
    for(i = 0; i < a.length - 1; i++)
      System.out.print(a[i] + " ");
    System.out.println(a[i]);
  }

  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int a[] = new int[n];
    for(int i = 0; i < n; i++)
      a[i] = stdIn.nextInt();

    for(int i = 0; i < n; i++){
      int w = a[i];
      int j = i;
      while(j > 0 && a[j - 1] > w){
        a[j] = a[j - 1];
        j--;
      }
      a[j] = w;
      output(a);
    }

  }
}

Measured memory_bytes: 31060
// Don't Lose Hope, Nor Be Sad -- Quran

#include <bits/stdc++.h>
using namespace std;

int main(){
    int group1[7] = {1,3,5,7,8,10,12};
    int group2[4] = {4,6,9,11};
    int a,b;
    cin >> a >> b;
    if(a == 2 && b == 2) cout << "Yes\n",exit(0);
    if(a == 2 && b != 2) cout << "No\n",exit(0); 
    else{
        bool found = false;
        if(a == 4 || a == 6 ||a == 9 ||a == 11)
        {
            for(int i=0; i<4; i++){
                if(b == group2[i]) found = true;
            }
            if(found)cout << "Yes\n";
            else cout << "No\n";
        }
        else{
            for(int i=0; i<7; i++){
                if(b == group1[i]) found = true;
            }
            if(found)cout << "Yes\n";
            else cout << "No\n";
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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

int main() {
	int r;cin >> r;
    cout << r*r << endl;
    return 0;



}


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

void reverse(const char *str1,char *str2);
int check(const char* str1,char* str2);
void str_cpy(const char* str1,char* str2,int start,int end);

int main(void)
{
    int flag=1;
    char s[100]={},s1[50]={},s2[50]={},rstr[100]={};
    scanf("%s",s);
    str_cpy(s,s1,0,(strlen(s)-1)/2);
    str_cpy(s,s2,((strlen(s)+3)/2)-1,strlen(s));

    if(check(s,rstr)!=0) flag=0;
    if(check(s1,rstr)!=0) flag=0;
    if(check(s2,rstr)!=0) flag=0;
    if(flag==1) printf("Yes");
    else printf("No");
    return 0;
}

void reverse(const char* str1,char* str2){
    strcpy(str2,str1);
    for(int i=0;i<strlen(str1);i++) str2[i]=str1[strlen(str1)-i-1];
    str2[strlen(str1)]='\0';
}

int check(const char* str1,char* str2){
    reverse(str1,str2);
    return strcmp(str1,str2);
}

void str_cpy(const char* str1,char* str2,int start,int end){
    for(int i=start;i<end;i++) str2[i-start]=str1[i];
}


Measured memory_bytes: 1736
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

#define fr(i,n)	for(int i=0;i<n;i++)
#define frr(i,n)	for(int i=1;i<=n;i++)

#define ms(x,i)	memset(x,i,sizeof(x))
#define dbg(x) cout << #x << " = " << x << endl
#define all(x) x.begin(),x.end()

#define gnl cout << endl
#define olar cout << "olar" << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


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

const int INF = 0x3f3f3f3f;


int main(){
    fastio;
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<int> A;
    vector<int> B;
    vector<int> C;
    for(int i = 0; i<a; i++){
        int x;
        cin >> x;
        A.push_back(x);
    }
    for(int i = 0; i<b; i++){
        int x;
        cin >> x;
        B.push_back(x);
    }
    sort(all(A), greater<int>());
    sort(all(B), greater<int>());
    for(int i = 0; i<x; i++){
        C.push_back(A[i]);
    }
    for(int i = 0; i<y; i++){
        C.push_back(B[i]);
    }
    for(int i = 0; i<c; i++){
        int x;
        cin >> x;
        C.push_back(x);
    }
    ll ans = 0;
    sort(all(C), greater<int>());
    for(int i = 0; i<x+y; i++){
        ans += C[i];
    }
    cout << ans << endl;

}

Measured memory_bytes: 3188
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math") 
///#pragma GCC target("avx2")
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <functional>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <climits>
#include <numeric>

using namespace std;
#define open_streams ifstream fin("olympiad.in");ofstream fout("olympiad.out")
#define close_streams fin.close();fout.close()
#define speed cout.tie(0);cin.tie(0);ios_base::sync_with_stdio(0)
#define ll long long
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define UNIQ(a) a.resize(unique(all(a)) - a.begin())
#define eps 1e-6
//const double PI = M_PI;
const int INF = INT_MAX;
const ll limit = 1LL * 1e12;
const int MOD = 1e9 + 711;
const int MOD2 = 1e9 + 933;
//---------------------------------------------------------------------------
const int mod = 1e9 + 7;
const int maxn = 1e6 + 100;



signed main() {
	speed;
	string s, t, a;
	cin >> s >> t;
	int n, m;
	cin >> n >> m;
	cin >> a;
	if (a == s) {
		cout << --n << ' ' << m;
	}
	else {
		cout << n << ' ' << --m;
	}
	
	return 0;
}

Measured memory_bytes: 256
def main():
    a, b, c, d = map(int, input().split())
    flag = False
    while True:
        c -= b
        if c <= 0:
            flag = True
            break
        a -= d
        if a <= 0:
            break
    if flag:print("Yes")
    else:print("No")

if __name__ == "__main__":
    main()

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

#define ll  long long

#define AREA_W  3
#define AREA_H  3

void solve(const ll H, const ll W, const std::vector<std::pair<ll, ll>>& I)
{
    std::vector<std::pair<ll, ll>> P;
    for (auto itr = I.begin(); itr != I.end(); ++itr)
    {
        for (int w = 0; w < AREA_W; w++)
        {
            for (int h = 0; h < AREA_H; h++)
            {
                if (1 <= itr->second - w && itr->second - w <= W - (AREA_W - 1) && 1 <= itr->first - h && itr->first - h <= H - (AREA_H - 1))
                {
                    P.push_back(std::make_pair(itr->second - w, itr->first - h));
                }
            }
        }
    }
    std::sort(P.begin(), P.end());

    int c = 1;
    std::vector<ll> A(10, 0);
    A[0] = (H - (AREA_H - 1)) * (W - (AREA_W - 1));
    for (int i = 0; i < P.size(); i++)
    {
        if (P[i].first == P[i + 1].first && P[i].second == P[i + 1].second)
        {
            c++;
        }
        else
        {
            A[0]--;
            A[c]++;
            c = 1;
        }
    }

    for (auto itr = A.begin(); itr != A.end(); ++itr)
    {
        std::cout << *itr << std::endl;
    }
}

int main(void)
{
    int H, W, N;
    std::cin >> H >> W >> N;

    std::vector<std::pair<ll, ll>> I(N);
    for (ll i = 0; i < N; i++)
    {
        std::cin >> I[i].first >> I[i].second;
    }
    solve(H, W, I);

    return 0;
}

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

#define scd second
#define fst first
#define pb push_back
#define mkp make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;
typedef list<int> lint;
typedef list<ll> llong;
typedef list<pii> lpii;
typedef list<pll> lpll;
typedef list<lint> llint;
typedef list<llong> lllong;

ll const LINF=numeric_limits<long long int>::max();
int const INF=numeric_limits<int>::max();

ll gcd(ll a, ll b){
	return b ? gcd(b,a%b) : a;
}

ll pow_mod(ll a, ll e, ll m){
	ll res=1;
	while(e){
		if(e&1) res=res*a%m;
		a=a*a%m;
		e>>=1;
	}
	return res;
}

ll inv_mod(ll b, ll m){
	b%=m;
	ll x=0, y=1, r, q, a=m;
	while(b){
		q=a/b;
		r=a%b;
		a=b;
		b=r;
		r=x;
		x=y;
		y=r-q*y;
	}
	x+=m;
	return x%m;
}

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

	int n;
	cin>>n;
	vint perm(n), tmp;
	vpii xy(n);
	for(int i=0; i<n; i++){
		perm[i]=i;
		cin>>xy[i].fst>>xy[i].scd;
	}

	tmp=perm;
	double s=0;
	for(int j=1; j<n; j++){
		int i=tmp[j], k=tmp[j-1];
		int x=xy[i].fst-xy[k].fst;
		int y=xy[i].scd-xy[k].scd;
		s+=sqrt(x*x+y*y);
	}

	while(true){
		next_permutation(all(tmp));
		if(tmp==perm) break;
		for(int j=1; j<n; j++){
			int i=tmp[j], k=tmp[j-1];
			int x=xy[i].fst-xy[k].fst;
			int y=xy[i].scd-xy[k].scd;
			s+=sqrt(x*x+y*y);
		}
	}

	int m=1;
	for(int i=2; i<=n; i++) m*=i;

	cout<<fixed<<setprecision(8)<<s/m<<endl;
}

Measured memory_bytes: 256
//競技プログラミング　テンプレ
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cstdlib> //abs() これは整数のみ

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)

const int max_v = 300;
const int INF = 1000000;



int main() {
	int n, ans=0;
	string s;
	cin >> s;
	//vector <int> A(n);
	//string str;

	s[3] = '8';
 	
	//sort(A.begin(), A.end());

	cout << s << endl;
	return 0;
}


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

int d;
vector<int> c;
vector< vector<int> > s;

int satisfaction(const vector<int>& t) {
  vector<int> last(26, -1);
  int ans = 0;
  for (int i = 0; i < (int) t.size(); i++) {
    ans += s[i][t[i]];
    last[t[i]] = i;
    for (int j = 0; j < 26; j++) {
      ans -= c[j] * (i - last[j]);
    }
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  srand(time(nullptr));
  cin >> d;
  c.resize(26);
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
  }
  s.assign(d, vector<int>(26));
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
  vector<int> t;
  for (int i = 0; i < d; i++) {
    vector<int> tmp = t;
    vector<int> best = {-1};
    for (int j = 0; j < 26; j++) {
      tmp.push_back(j);
      if (best[0] == -1 || satisfaction(tmp) > satisfaction(best)) {
        best = tmp;
      }
      tmp.pop_back();
    }
    swap(t, best);
  }
  for (int i = 0; i < 10000; i++) {
    int pos = rand() % d, x = rand() % 26;
    vector<int> tmp = t;
    tmp[pos] = x;
    if (satisfaction(tmp) > satisfaction(t)) {
      swap(t, tmp);
    } 
  }
  for (auto& x : t) {
    cout << x + 1 << '\n';
  }
  return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#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 n, m;
    cin >> n >> m;
    map<int, int> hi;
    for(int i = 1; i <= n; i++) {
        cin >> hi[i];
    }

    vector<bool> hh(n, true);
    rep(j, m) {
        int a, b;
        cin >> a >> b;
        if(hi[a] >= hi[b]) {
            hh[b - 1] = false;
        }
        if(hi[a] <= hi[b]) {
            hh[a - 1] = false;
        }
    }
    int count = 0;
    rep(i, n) {
        if(hh[i]) {
            count++;
        }
    }

    cout << count << endl;
}


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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

int main() {
    int N; int K;
    cin >> N >> K;
    set<int> ds;
    for (int i = 0; i < K; ++i) {
        int d;
        cin >> d;
        ds.insert(d);
    }

    for (int n = N;; ++n) {
        string n_str = to_string(n);
        bool found = false;
        for (const auto d : n_str) {
            if (ds.count(d - '0')) {
                found = true;
            }
        }
        if (found) { continue; }
        cout << n << endl;
        break;
    }
}

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

int main() {
    int k; cin >> k;
    if(k % 2 == 0){
        cout << (k/2)*(k/2) << endl;
    }
    else{
        cout << ((k+1)/2) * ((k+1)/2 - 1) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n,k,s;cin >> n >> k >> s;
    if(s!=1e9){
        rep(i,k)cout << s << ' ';
        rep2(i,k,n)cout << s+1 << " \n"[i+1==n];
    }
    else{
        rep(i,k)cout << s << ' ';
        rep2(i,k,n)cout << 1 << " \n"[i+1==n];
    }
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cstring>
#define LL long long
const int MAXN = 2e6 + 5;
const int Mod = 1e9 + 7; 
int n, m;
char str[MAXN];
LL fact[MAXN], inv[MAXN]; 

LL qpow(LL a, int b) {
	LL res = 1;
	for (; b; b >>= 1, a = a * a % Mod)
		if (b & 1) res = a * res % Mod;
	return res;
}

LL C(int n, int m) {
	return fact[n] * inv[n - m] % Mod * inv[m] % Mod;
} 

int main() {
	LL ans = 0;
	scanf("%d%s", &n, str + 1);
	m = strlen(str + 1);
	
	fact[0] = 1;
	for (int i = 1; i <= n + m; i++) fact[i] = fact[i - 1] * i % Mod;
	inv[n + m] = qpow(fact[n + m], Mod - 2);
	for (int i = n + m - 1; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % Mod;
	
	for (int i = 0; i <= n; i++) 
		ans  = (ans + qpow(26, i) * C(n + m - i - 1, m - 1) % Mod * qpow(25, n - i) % Mod) % Mod;
	printf("%lld\n", ans);
}

Measured memory_bytes: 35396
#include<iostream>
#include<cstdio>

using namespace std;

int coins[]={0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289};

int main()
{
	int m;

	while (scanf("%d", &m))
	{
		if (m==0)
		break;

		long long int T[18][m+1];

		for (int i=0; i<18; i++)
		{
			for (int j=0; j<=m; j++)
			{
				if (i==0)
				T[i][j]=0;
				else if (j==0)
				T[i][j]=1;
				else if (j>=coins[i])
				T[i][j]=T[i-1][j]+T[i][j-coins[i]];
				else
				T[i][j]=T[i-1][j];
			}
		}

		printf("%d\n",T[17][m]);
	}

	return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	i64 n, m; cin >> n >> m;
	
	i64 ret = 1;
	const int MOD = 1e9 + 7;
	if(n % 2 == m % 2) ret *= 2;
	
	for(i64 i = 1; i <= n; i++) (ret *= i) %= MOD;
	for(i64 i = 1; i <= m; i++) (ret *= i) %= MOD;
	
	if(std::abs(n - m) > 1) ret = 0;
	
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 1e5 + 5;
int  ans[N];
int main() {
	IO
	int n, k;
	cin >> n >> k;
	int h[n];
	for (int i = 0; i < n; i++){
		cin >> h[i];
	}
	ans[1] = abs(h[0] - h[1]);
	for (int i = 2; i < n; i++){
		ans[i] = abs(h[i] - h[i - 1]) + ans[i - 1];
		for (int j = 2; j <= k && i - j >= 0; j++){
			ans[i] = min(ans[i] , abs(h[i - j] - h[i]) + ans[i - j]);
		}
	}
	cout << ans[n - 1];
	return 0;
}


Measured memory_bytes: 1024
//1�ȏ�N�ȉ��̐����̂����A10�i�@�ł̊e�s�̘a��A�ȏ�B�ȉ��ł������̂̑��a�����߂Ă�������

#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main() {
	int A, B, sum = 0, tmp = 0, ans = 0;
	int N;
	cin >> N >> A >> B;

	for (int j = 1; j <= N; j++) {
		for (int i = 1; i <= j / 10 + 1; i++) {
			if (i == 1) sum += (j - tmp) % 10;
			else        sum += (j - tmp) % (int)pow(10, i) / (int)pow(10, i - 1);
			tmp += (j - tmp) % (int)pow(10, i);
		}
		if (sum >= A && sum <= B) ans += j;
		sum = tmp = 0;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    s = S()
    N = len(s)

    for i in range(N//2//2):
        # print('s', i)
        if s[i] != s[N-i-1]:
            print('No')
            return

    for i in range(N//2):
        # print('b', i)
        if s[i] != s[N-i-1]:
            print('No')
            return

    sl = s[(N+3)//2-1:N]
    # print(sl)
    for i in range(len(sl)//2):
        # print('c', i, sl[i], sl[len(sl)-i-1])
        if sl[i] != sl[len(sl)-i-1]:
            print('No')
            return

    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
H = gets.to_i
A = gets.split.map(&:to_i)

ret = 0

target = 1
i = 0
while i < A.length
  if A[i] == target
    target += 1
  else
    ret += 1
  end
  i += 1
end

if target == 1
  ret = -1
end

p ret


Measured memory_bytes: 15364
#include<bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define mod 1000000007
#define M 1000000
using namespace std;

int isprime(ll n){
    if(n==1) return 0;
    if(n==2 || n==3) return 1;
    for(int i=2;i*i<=n;i++){
        if(n%i==0) return 0;
    }
    return 1;
}

void answer(){
    ll n,ans=0,m,p=0,x;
    cin>>n>>m;
    ll a[m];
    for(int i=0;i<m;i++) cin>>a[i];
    sort(a,a+m);
    for(int i=0;i<m;i++){
        ans+=a[i];
    }
    if(ans>=n) cout<<"Yes";
    else cout<<"No";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int q;
    //cin>>q; while(q--)
        answer();
    return 0;
}

Measured memory_bytes: 1024
struct Read<R: std::io::BufRead> {
    stdin: R,
    v: Vec<String>,
    i: usize,
}
impl<R:std::io::BufRead> Read<R> {
    pub fn new(stdin: R) -> Self {
        Read{
            stdin: stdin,
            v: Vec::new(),
            i: 0,
        }
    }
    pub fn read_line(&mut self) {
        self.i = 0; self.v.clear();
        let mut buf = String::new();
        self.stdin.read_line(&mut buf).unwrap();
        let buf = buf.trim().to_owned();
        let mut ws = buf.split_whitespace();
        loop {
            let x = ws.next();
            if x.is_none() {break;}
            let x = x.unwrap().to_owned();
            self.v.push(x);
        }
    }
    pub fn read_t<T: std::str::FromStr>(&mut self) -> T {
        if self.i == self.v.len() {self.read_line();}
        let elem = &self.v[self.i];
        self.i += 1;
        elem.parse().unwrap_or_else(|_| panic!())
    }
    
    #[allow(dead_code)]
    pub fn read_i32(&mut self) -> i32 {
        if self.i == self.v.len() {self.read_line();}
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }
    #[allow(dead_code)]
    pub fn read_usize(&mut self) -> usize {
        if self.i == self.v.len() {self.read_line();}
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }
    #[allow(dead_code)]
    pub fn read_u64(&mut self) -> u64 {
        if self.i == self.v.len() {self.read_line();}
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }
    #[allow(dead_code)]
    pub fn read_string(&mut self) -> String {
        if self.i == self.v.len() {self.read_line();}
        let elem = &self.v[self.i];
        self.i += 1;
        elem.to_owned()
    }
}
fn main() {
    use std::io;
    let stdin = io::stdin();
    let stdin = io::BufReader::new(stdin.lock());
    let read = Read::new(stdin);
    solve(read);
}

fn solve<R: std::io::BufRead>(mut r: Read<R>) {
    let mut a:Vec<Vec<i32>> = Vec::new();
    for i in 0..3 {
        a.push(Vec::new());
        for j in 0..3 {
            a[i].push(r.read_i32());
        }
    }
    let mut n = r.read_i32();
    let mut b:Vec<i32> = Vec::new();
    for i in 0..n {
        b.push(r.read_i32());
    }

    for i in 0..n as usize{
        for j in 0..3 {
            for k in 0..3 {
                if b[i] == a[j][k] {
                    a[j][k] = -1;
                }
            }
        }
    }
    let mut ans = 0;
    for i in 0..3 as usize {
        if a[i][0] == a[i][1] && a[i][1] == a[i][2] {
            ans+=1;
        }
    }
    for i in 0..3 as usize {
        if a[0][i] == a[1][i] && a[1][i] == a[2][i] {
            ans+=1;
        }
    }
    if a[0][0] == a[1][1] && a[1][1] == a[2][2] {
        ans+=1;
    }
    if a[0][2] == a[1][1] && a[1][1] == a[2][0] {
        ans+=1;
    }

    println!("{}", if ans > 0 {
        "Yes"
    }else{
        "No"
    });
}

Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;

#define mp make_pair
#define pb push_back
#define PI 3.1415926535897932384626433832795

#define fill(x, v)  fillchar(x, v, sizeof(x))
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector< pii >   vpii;

#define MAXN 100500
#define MOD (int)(1e9 + 7)

int f[MAXN][2];
vi  g[MAXN];
int n, x, y;


void rec(int v, int from) {
    f[v][0] = 1;
    f[v][1] = 1;
    for(int w : g[v]) {
        if (w == from) continue;
        rec(w, v);
        f[v][0] = ((ll)f[v][0] * f[w][1]) % MOD;
        f[v][1] = ((ll)f[v][1] * (f[w][1] + f[w][0])) % MOD;
        //printf("v=%i  w=%i   0=%i  1=%i\n", v, w, f[v][0], f[v][1]);
        
    }
}

int main() {
    scanf("%i", &n);
    for(int i = 1; i < n; ++i) {
        scanf("%i%i", &x, &y);
        g[x].pb(y);
        g[y].pb(x);
    }


    rec(1, 0);

    f[1][0] = (f[1][0] + f[1][1]) % MOD;
    printf("%i\n", f[1][0]);

    



    return 0;
}

Measured memory_bytes: 13440
N,M,K = list(map(int, input().split()))

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
uf = UnionFind(N)      
V = [[] for _ in range(N)]

for _ in range(M):
  a,b = map(int, input().split())
  a,b = a-1, b-1
  V[a].append(b)
  V[b].append(a)
  uf.union(a,b)
  
for _ in range(K):
  a,b = map(int, input().split())
  a,b = a-1, b-1
  if uf.same(a,b):
    V[a].append(b)
    V[b].append(a)

ans = [-1] * N
for i in range(N):
  ans[i] = uf.size(i) - len(V[i]) - 1
  
print(" ".join(list(map(str, ans))))



Measured memory_bytes: 45836
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::HashSet;
use std::cmp;
use std::f64::consts;

fn main() {
    let input: String = read();
    let vec: Vec<char> = input.chars().collect();
    let mut vec_i: Vec<i32> = Vec::new();

    for &c in vec.iter() {
        let i: i32 = c.to_digit(10).unwrap() as i32;
        vec_i.push(i);
    }

    for i in 0..i32::pow(2, vec.len() as u32 -1) {
        let mut s = vec[0].to_string();
        let mut sum = vec_i[0];
        for j in 0..vec.len()-1 {
            if (1 & i >> j) == 1 {
                sum += vec_i[j+1];
                s = format!("{}+{}", s, vec[j+1]);
            } else {
                sum -= vec_i[j+1];
                s = format!("{}-{}", s, vec[j+1]);
            }
        }

        if sum == 7 {
            s = format!("{}=7", s);
            println!("{}", s);
            break;
        }
    }
}

fn calc_distance(x: i32, y: i32, target_x: i32, target_y: i32) -> i32 {
    let diff_x = (target_x - x).abs();
    let diff_y = (target_y - y).abs();

    return diff_x + diff_y;
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// 最大公約数
fn gcd(a: i32, b: i32) -> i32 {
    match b {
        0 => a,
        _ => gcd(b, a % b)
    }
}

// 最小公倍数
fn lcm(a: i32, b: i32) -> i32 {
    a * b / gcd(a, b)
}

// 階乗
fn kaijou(n: i32)->i32 {
    if n == 1 {
        return n;
    }
    return n * kaijou(n-1);
}

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

void solve(long long N, std::vector<std::string> S)
{
    map<string, int> mp;
    for (auto x : S)
    {
        mp[x] = 0;
    }

    int mx = 0;
    for (auto x : S)
    {
        mp[x]++;
        mx = max(mx, mp[x]);
    }

    for (auto x : mp)
    {
        if (x.second == mx)
        {
            cout << x.first << endl;
        }
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<std::string> S(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 26752
#include <iostream>
using namespace std;
bool check(int i)
{
	int ret = 0;
	for(int p = 1;p <= i; ++p)
	{
		if(i % p == 0)
		{
			ret++;
		}
	}
	return ret == 8;
}
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int sum = 0;
	for(int i = 1;i <= n; i += 2)
	{
		sum += check(i);
	}
	cout<<sum<<endl;
	return 0;
}

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

int main(){
    int N;
    string S, T;
    cin >> N >> S >> T;

    string ans = "";

    for(int i = 0; i < N; i++){
        ans += S.at(i);
        ans += T.at(i);
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
	int A,B;
	int tc=0;
	while(cin>>A>>B,A||B){
		if(tc!=0) puts("");
		bool flag=false;
		for(int i=A;i<=B;i++){
			if(i%4==0 && (i%100!=0 || i%400==0)){
				printf("%d\n",i);
				flag=true;
			}
		}
		if(flag==false) puts("NA");
		tc++;
	}
	return 0;
}

Measured memory_bytes: 1148
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	string s, t,an="No";
	cin >> s >> t;
	int x = stoi(s + t);
	for (int i = 1; i <= 1000; i++) {
		if (i * i == x) {
			an= "Yes";
			break;
		}
	}
	cout << an << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

int N, x, a[100100];
ll tot;

int main () {
        scanf("%d %d", &N, &x);
        fo(i, 0, N) scanf("%d", &a[i]);
        fo(i, 1, N) {
                if (a[i]+a[i-1]>x) {
                        int e = min(a[i], a[i]+a[i-1]-x);
                        a[i] -= e, tot += e;
                }
                if (a[i]+a[i-1]>x) {
                        assert(!a[i]);
                        int e = a[i]+a[i-1]-x;
                        a[i-1] -= e, tot += e;
                }
                assert(a[i]+a[i-1]<=x);
        }
        printf("%lld\n", tot);
        return 0;
}


Measured memory_bytes: 768
n = int(input())
if n >= 400 and n <= 599:
  print(8)
if n >= 600 and n <= 799:
  print(7)
if n >= 800 and n <= 999:
  print(6)
if n >= 1000 and n <= 1199:
  print(5)
if n >= 1200 and n <= 1399:
  print(4)
if n >= 1400 and n <= 1599:
  print(3)
if n >= 1600 and n <= 1799:
  print(2)
if n >= 1800 and n <= 1999:
  print(1)

Measured memory_bytes: 9224
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vector<pii> A(N);
    REP(i, N) {
        cin >> A[i].first;
        A[i].second = i;
    }
    sort(ALL(A));
    
    int ans = 0;
    REP(i, N) {
        if (A[i].second % 2 != i % 2) {
            ans++;
        }
    }
    cout << ans / 2 << endl;
    return (0^_^0);
}



Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
using namespace std;
int main (){
  int d,e;
  while(cin >> d >> e,d){
    double min=200;
    for(int x=0;x<=d;x++){
      if(abs(sqrt(x*x+(d-x)*(d-x))-e)<min)min=abs(sqrt(x*x+(d-x)*(d-x))-e);
    }
    cout << setprecision(10) << min << endl;
  }
}

Measured memory_bytes: 3256
#include <iostream>
#include <string.h>
using namespace std;

int main() {
	string sa,sb,sc;
	cin >> sa >> sb >> sc;
	char turn = 'a' ;
	int turna = 0;
	int turnb = 0;
	int turnc = 0;
	
	for(int i=0;i<=300;i++){
		if(turn == 'a'){
			turn = sa[turna];
			if(sa[turna]==0){
				cout << 'A' << endl;
				break;
			}
			turna ++;
		}
		else if(turn == 'b'){
			turn = sb[turnb];
			if(sb[turnb]==0){
				cout << 'B' << endl;
				break;
			}
			turnb ++;
		}
		else if(turn == 'c'){
			turn = sc[turnc];
			if(sc[turnc]==0){
				cout << 'C' << endl;
				break;
			}
			turnc ++;
		}
	}
		
	return 0;
	
	
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  
  int a[105][105],b[105][105];
  int ac,bc,n,m,l,i,j,k;
  long long c[105][105];

  for(i=0;i<105;i++){
    for(j=0;j<105;j++){
      c[i][j]=0;
    }
  }

  scanf("%d%d%d",&n,&m,&l);
  
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&a[i][j]);
    }
  }
  for(i=0;i<m;i++){
    for(j=0;j<l;j++){
      scanf("%d",&b[i][j]);
    }
  }
  
  for(i=0;i<=n+1;i++){
    for(j=0;j<=l+1;j++){
      for(k=0;k<=m+1;k++){
	
	c[i][j]+=a[i][k]*b[k][j];
      }
    }
  }
  
  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      printf("%lld",c[i][j]);
      if(j<l-1){
	printf(" ");
      }
    }
    puts("");
  }
  
  return 0;
}

Measured memory_bytes: 788
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
#define ALL(x) (x).begin,(x).end()
int main(){
  string s,t;
  cin>>s>>t;
  lint leng=s.size();
  lint i;
  vint cnts(26,0);
  vint cntt(26,0);
  cnts[0]=count(s.begin(),s.end(),'a');
  cnts[1]=count(s.begin(),s.end(),'b');
  cnts[2]=count(s.begin(),s.end(),'c');
  cnts[3]=count(s.begin(),s.end(),'d');
  cnts[4]=count(s.begin(),s.end(),'e');
  cnts[5]=count(s.begin(),s.end(),'f');
  cnts[6]=count(s.begin(),s.end(),'g');
  cnts[7]=count(s.begin(),s.end(),'h');
  cnts[8]=count(s.begin(),s.end(),'i');
  cnts[9]=count(s.begin(),s.end(),'j');
  cnts[10]=count(s.begin(),s.end(),'k');
  cnts[11]=count(s.begin(),s.end(),'l');
  cnts[12]=count(s.begin(),s.end(),'m');
  cnts[13]=count(s.begin(),s.end(),'n');
  cnts[14]=count(s.begin(),s.end(),'o');
  cnts[15]=count(s.begin(),s.end(),'p');
  cnts[16]=count(s.begin(),s.end(),'q');
  cnts[17]=count(s.begin(),s.end(),'r');
  cnts[18]=count(s.begin(),s.end(),'s');
  cnts[19]=count(s.begin(),s.end(),'t');
  cnts[20]=count(s.begin(),s.end(),'u');
  cnts[21]=count(s.begin(),s.end(),'v');
  cnts[22]=count(s.begin(),s.end(),'w');
  cnts[23]=count(s.begin(),s.end(),'x');
  cnts[24]=count(s.begin(),s.end(),'y');
  cnts[25]=count(s.begin(),s.end(),'z');
  
  cntt[0]=count(t.begin(),t.end(),'a');
  cntt[1]=count(t.begin(),t.end(),'b');
  cntt[2]=count(t.begin(),t.end(),'c');
  cntt[3]=count(t.begin(),t.end(),'d');
  cntt[4]=count(t.begin(),t.end(),'e');
  cntt[5]=count(t.begin(),t.end(),'f');
  cntt[6]=count(t.begin(),t.end(),'g');
  cntt[7]=count(t.begin(),t.end(),'h');
  cntt[8]=count(t.begin(),t.end(),'i');
  cntt[9]=count(t.begin(),t.end(),'j');
  cntt[10]=count(t.begin(),t.end(),'k');
  cntt[11]=count(t.begin(),t.end(),'l');
  cntt[12]=count(t.begin(),t.end(),'m');
  cntt[13]=count(t.begin(),t.end(),'n');
  cntt[14]=count(t.begin(),t.end(),'o');
  cntt[15]=count(t.begin(),t.end(),'p');
  cntt[16]=count(t.begin(),t.end(),'q');
  cntt[17]=count(t.begin(),t.end(),'r');
  cntt[18]=count(t.begin(),t.end(),'s');
  cntt[19]=count(t.begin(),t.end(),'t');
  cntt[20]=count(t.begin(),t.end(),'u');
  cntt[21]=count(t.begin(),t.end(),'v');
  cntt[22]=count(t.begin(),t.end(),'w');
  cntt[23]=count(t.begin(),t.end(),'x');
  cntt[24]=count(t.begin(),t.end(),'y');
  cntt[25]=count(t.begin(),t.end(),'z');
  sort(cnts.begin(),cnts.end());
  sort(cntt.begin(),cntt.end());
  bool flag=true;
  for(i=0;i<=25;i++){
    if(cnts[i]!=cntt[i]){
      flag=false;break;
    }
  }
  cout<<(flag?"Yes":"No")<<endl;
}

Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;

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

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int H, N, i, x ,sum = 0;

    scanf("%d %d", &H, &N);

    for (i = 0 ; i < N ; i++)
    {
        scanf("%d", &x);
        sum += x;
    }

    if(sum >= H)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}



Measured memory_bytes: 1604
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    write(c > a + b && 4 * a * b < (c - a - b) * (c - a - b) ? "Yes" : "No");
}

Measured memory_bytes: 256
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(M):
    x, y, c = map(int, input().split())
    if i == 0:
        ans = a[x - 1] + b[y - 1] - c
        continue
    ans = min(ans, a[x - 1] + b[y - 1] - c)

a.sort()
b.sort()
ans = min(ans,a[0] + b[0])
print(ans)

Measured memory_bytes: 25456
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			Map<String, Integer> map = new HashMap<String, Integer>();
			while (n-- > 0) {
				String str = scanner.next();
				int cost = scanner.nextInt();
				map.put(str, cost);
			}
			int s = scanner.nextInt();
			while (s-- > 0) {
				String str = scanner.next();
				int m = scanner.nextInt();
				int sum = 0;
				while (m-- > 0) {
					String line = scanner.next();
					if (map.containsKey(line))
						sum += map.get(line);
				}
				map.put(str, Math.min(map.get(str), sum));
			}
			System.out.println(map.get(scanner.next()));

		}
	}
}

Measured memory_bytes: 24860
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;
using ll = long long;

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

  string ans = "";
  if(a < b){
    for(int i = 0; i < b; ++i){
      ans += to_string(a);
    }
  }else{
    for(int i = 0; i < a; ++i){
      ans += to_string(b);
    }
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256