akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#define ii pair<int, int>
#define p1 first
#define p2 second
#define pb push_back
using namespace std;

const int N = 1e5+5;
int n, x[N];
map<int,int> Cnt;

int main()
{
    //freopen("a.inp","r",stdin);

    scanf("%d",&n);
    for(int i=1; i<=n; ++i) {
        scanf("%d",x+i);
        Cnt[x[i]] += 1;
    }
    if (Cnt[0] == n) { puts("Yes"); return 0; }
    if (x[1] == 0) for(int i=2; i<=n; ++i) if (x[i]) {swap(x[1], x[i]); break; }

    for(int i=2; i<=n; ++i) {
        int OK = 0, a, b, c;
        a = x[1]; b = x[i]; c = a ^ b;
        if (Cnt[c] == 0) continue;
        if (a == b)
            OK = (Cnt[a] == Cnt[c]*2 || Cnt[a] == Cnt[c]*2+1) && Cnt[a] + Cnt[c] == n;
        else
        if (a == c)
            OK = (Cnt[a] == Cnt[b]*2 || Cnt[a]+1 == Cnt[b]*2) && Cnt[a] + Cnt[b] == n;
        else
            OK = Cnt[a] == Cnt[b] && Cnt[a] == Cnt[c] && Cnt[a] + Cnt[b] + Cnt[c] == n;
        if (OK) {puts("Yes"); return 0;};
    }
    puts("No");
}


Measured memory_bytes: 7808
N = gets.to_i
ary = []
sum, longest, time = 0, 0, 0
flag = 1

N.times do |i|
    a, b = gets.chomp.split(" ").map(&:to_i)
    ary << [a, b]
    sum += a
    longst = b if b > longest
end

if longest > sum 
    puts "No"
else
    ary.sort_by! {|a| a[1]}
    ary.each do |a|
        time += a[0]
        flag = -1 if time > a[1]
    end
    if flag == 1
        puts "Yes"
    else
        puts"No"
    end    
end


Measured memory_bytes: 22520
import std.stdio, std.array, std.conv, std.typecons, std.algorithm;

immutable INF = 1<<30;

long impl(long n, long v, const ref long[] ws, const ref long[] vs, ref long[][] dp) {
    if(dp[n][v] == INF) {
        const auto yes = {
            const auto prev_v = v-vs[n-1];
            return prev_v >= 0 ? impl(n-1, prev_v, ws, vs, dp) + ws[n-1] : INF;
        }();
        const auto no = impl(n-1, v, ws, vs, dp);
        dp[n][v] = min(yes, no, dp[n][v]);
    }
    return dp[n][v];
}

long solve(long n, long w, const ref long[] ws, const ref long[] vs) {
    const long avg = (vs.sum + vs.count - 1) / vs.count;
    auto vmax = avg*n;

    auto dp = new long[][](n+1, vmax+1);
    foreach(ref v ; dp[]) { v[] = INF;} // clear all
    foreach(ref v ; dp[0]) { v = INF-1;} // set dp[0][x]
    dp[0][0] = 0;

    for(long i = vmax; i >= 0; i--) {
        auto ret_w = impl(n, i, ws, vs, dp);
        if (ret_w <= w) return i;
    }

    return -1; // unreachable
}

void main() {
    immutable i1 = readln.split.to!(long[]);
    immutable n = i1[0], w = i1[1];
    auto ws = new long[n];
    auto vs = new long[n];

    for(auto i = 0; i < n; i++) {
        auto input = readln.split.to!(long[]);
        ws[i] = input[0];
        vs[i] = input[1];
    }

    writeln(solve(n, w, ws, vs));
}


Measured memory_bytes: 80764
n = int(input())
a = list(map(int, input().split()))
res = 0
for i in range(n-2):
  if (a[i] > a[i+1] and a[i+1] > a[i+2]) or (a[i] < a[i+1] and a[i+1] < a[i+2]):
    res += 1
print(res)

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

int dp[150][11][80];
const int INF = 1<<30;

int main(){
    int n, m;
    while(cin >> n >> m, n+m){
        memset(dp, 0, sizeof(dp));
        vector<pair<int,int>> v[n];
        for(int i = 0; i < n; i++){
            int k;  cin >> k;
            while(k-- > 0){
                int x, d; cin >> x >> d;
                v[i].push_back({x, d});
                for(int j = 0; j <= m; j++){
                    dp[i][k][j] = INF;
                }
            }
        }
        
        for(int j = 0; j < v[0].size(); j++){
            dp[0][j][m] = 0;
        }
        for(int j = 0; j < v[1].size(); j++){
            if(m)   dp[1][j][m-1] = 0;
        }
        
        int ans = INF;
        for(int i = 0; i < n-1; i++){
            for(int from = 0; from < v[i].size(); from++){
                for(int mm = m; mm >= 0; mm--){
                    if(dp[i][from][mm] == INF)   continue;
                    for(int to = 0; to < v[i+1].size(); to++){
                        int cost = abs(v[i][from].first-v[i+1][to].first)*(v[i][from].second+v[i+1][to].second);
                        dp[i+1][to][mm] = min(dp[i+1][to][mm], dp[i][from][mm]+cost);
                        if(i+1 == n-1)  ans = min(ans, dp[i+1][to][mm]);
                    }
                    if(mm == 0)  continue;
                    if(i == n-2){
                        ans = min(ans, dp[i][from][mm]);
                        continue;
                    }
                    for(int to = 0; to < v[i+2].size(); to++){
                        int cost = abs(v[i][from].first-v[i+2][to].first)*(v[i][from].second+v[i+2][to].second);
                        dp[i+2][to][mm-1] = min(dp[i+2][to][mm-1], dp[i][from][mm]+cost);
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
n = int(input())
flag = [-1]*3
ans = 0
for i in range(n):
    a,b = map(int,input().split())
    flag[0] = flag[1]
    flag[1] = flag[2]
    if a == b:
        flag[2] = 1
    else:
        flag[2] = 0
    if flag[0] == 1:
        if flag[1] == 1:
            if flag[2] == 1:
                ans = 1

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

Measured memory_bytes: 62440
def solved():
    n = int(input())
    colors = input()
    red = colors.count('R')
    white = n - red

    wrong_red = 0
    for i in range(red):
        if colors[i] != 'R':
            wrong_red += 1
    wrong_white = 0
    for i in range(white):
        if colors[red + i] != 'W':
            wrong_white += 1
    assert wrong_white == wrong_red
    print(wrong_red)


if __name__ == '__main__':
    solved()

Measured memory_bytes: 9404
//
//  sublime text 3,
//  emre yazicioglu
//

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;
typedef vector <ll> vll;
typedef vector <pll> vpll;
#define pb push_back
#define fi first
#define se second
#define INF (ll) (1e18 + 7)
#define MOD (ll) (1e9 + 7)

const int N = 2e6 + 7;
ll mn = INF, mx = -INF;
ll n, m, k, s, q, t;
ll a, b, c, d, e;
ll ans, cur, sum, cnt;
ll ar[N], p[N], dp[N];
string str; bool h[N];
pll pp[N]; vll v;
string day[]{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

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

  // freopen("../in.txt","r",stdin);
  // freopen("../out.txt","w",stdout);

  cin >> str;
  for(int i = 0; i < 7; i++)
    if(str == day[i])
      a = i;
  cout << (7 - a);
}

Measured memory_bytes: 2304
A, B, C, D, E, F = map(int, input().split())

weight = 100 * A
suger = 0
den = 0
for a in range(0, F + 1, 100 * A):
    for b in range(0, F - a + 1, 100 * B):
        w = a + b
        if w == 0:
            continue
        S = E * w // 100
        for c in range(0, S + 1, C):
            for d in range(0, S - c + 1, D):
                s = c + d
                if w > 0 and w + s <= F and w * E >= s * 100:
                    tden = s / w
                    if den < tden:
                        weight = s + w
                        suger = s
                        den = tden

print(weight, suger)


Measured memory_bytes: 41948
#include <iostream>
#include <string>
using namespace std;
//線形探索
int main() {
	int a, b, c, x,ct=0;
	cin >> a >> b >> c >> x;
	for (int i= 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				int total = 500 * i + 100 * j + 50 * k;
				if (total== x)
					ct++;
			}
		}

	}
	cout << ct;

	return 0;
}

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

public class Main {
	public static int solution (int x) {
		return x * x * x;
	}

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        System.out.println(solution(x));
	}
}


Measured memory_bytes: 26348
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int X = sc.nextInt();
		if (X >= A && A + B >= X && B >= X - A) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 23764
#include <iostream>

using namespace std;

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(A==B && B==C) cout << "No" << endl;
  else if (A==B || B==C || C==A) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF = 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();
LL ave(LL, LL);

int main() {
	int x, a, b; cin >> x >> a >> b;
	if (abs(a - x) < abs(b - x))cout << "A";
	else cout << "B";
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}
LL ave(LL a, LL b) {
	return (a + b) / 2;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-07-17 12:17:41 +0900
# LastModified: 2020-07-17 12:18:40 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    a = int(input())
    b = int(input())
    if a>b:
        print("GREATER")
    elif a==b:
        print("EQUAL")
    else:
        print("LESS")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9160
# -*- coding: utf-8 -*-
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = set(table)
    return table


def common_divisor(x, y):
    xd = divisor(x)
    yd = divisor(y)
    return xd & yd


a, b = map(int, input().split())
cd = sorted(list(common_divisor(a, b)))

cnt = 1
div = {1}
for i in cd[1:]:
    i_d = divisor(i)
    if len(div & i_d) == 1:
        cnt += 1
    div |= i_d

print(cnt)


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

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W; cin >> H >> W;
	vector<vector<int>>dp(H, vector<int>(W));
	vector<vector<int>>G(dp);
	rep(i, 0, H)rep(j, 0, W)cin >> G[i][j];
	int ans(0);
	rep(i, 0, H)rep(j, 0, W) {
		dp[i][j] = (G[i][j] + 1) % 2;
		chmax(ans, dp[i][j]);
	}
	rep(i, 1, H)rep(j, 1, W) {
		if (G[i][j])dp[i][j] = 0;
		else dp[i][j] = min(dp[i - 1][j], min(dp[i][j - 1], dp[i - 1][j - 1])) + 1;
		chmax(ans, dp[i][j]);
	}
	cout << ans*ans << endl;
	return 0;
}

Measured memory_bytes: 18320
fun main(args: Array<String>) {
    val MOD = 1000000007L
    var S = Array<Long>(100002) { 0 }
    val L = "0" + readLine()!!
    val N = L.length
    var ret = 0L; var v = 1L; var a = 1L
    S[0] = 1
  	for (i in 0 until N) {
        S[i + 1] = S[i]
        if (L[i] == '1') S[i + 1] = S[i + 1] * 2 % MOD
    }
    for (i in N - 1 downTo 1) {
        if (L[i] == '1') {
            v = v * 2 % MOD
            ret += a * S[i] % MOD
        }
        a = a * 3 % MOD
    }
    ret += v; ret = ret % MOD
    println(ret)
}


Measured memory_bytes: 39416
s=list(input())
s.sort()
t=list(input())
t.sort(reverse=True)
for i in range(min(len(s),len(t))):
  if s[i]<t[i]:
    print("Yes")
    exit()
  elif s[i]>t[i]:
    print("No")
    exit()
if len(s)<len(t):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;
const double PI=3.14159265358979323846;

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

    
    vector<vector<int>> A(N,vector<int> (2));
    int B[N][2];
    rep(i,0,N) {
        cin >> A[i][0];
        A[i][1] = i;
        B[i][0] = A[i][0];
    }
    
    sort(A.begin(),A.end());

    rep(i,0,N) {
        if (i<=N/2-1) {
            B[A[i][1]][1] = A[N/2][0];
        }
        else {
            B[A[i][1]][1] = A[N/2-1][0];
        }

    }
    rep(i,0,N) {
        cout << B[i][1] << endl;
    }

}





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

int main() {
 string s,t;
 cin >> s >> t;
 int ans = 0;
 for(int i = 0;i < 3;i++){
  if(s.at(i) == t.at(i)){
   ans++;
  }
 }
 cout << ans << endl;
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  VECINT CS(9);
  REP(i,9) cin>>CS[i];
  int max_a1 = min(CS[0],CS[1]);
  max_a1 = min(max_a1,CS[2]);
  REP(a1,max_a1+1) {
    int b1 = CS[0]-a1;
    int b2 = CS[1]-a1;
    int b3 = CS[2]-a1;
    int a2 = CS[3]-b1;
    int a3 = CS[6]-b1;
    if (CS[4]==a2+b2 && CS[5]==a2+b3 && CS[7]==a3+b2 && CS[8]==a3+b3) {
      OUT("Yes");
      return 0;
    }
  }
  OUT("No");

  return 0;
}


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

long long n,i,j,x,y,ans,S,SS,B;
long long l[100005],nextt[100005],last[100005],tot;
long long a[1005];
long long list1[1005],list2[1005];
char ch;

void insert(int x,int y)
{
	tot++;
	l[tot]=y;
	nextt[tot]=last[x];
	last[x]=tot;
}

int main()
{
//	freopen("read.in","r",stdin);
	scanf("%lld",&n);
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=n;j++)
		{
			ch=getchar();
			while ((ch!='0')&&(ch!='1')) ch=getchar();
			if (ch=='1')
			insert(i,j);
		}
	}
	for (B=1;B<=n;B++)
	{
		memset(a,0,sizeof(a));
		memset(list1,0,sizeof(list1));
		memset(list2,0,sizeof(list2));
		list1[0]=1;list1[1]=B;a[B]=1;
		S=SS=0;
		while (list1[0]>0)
		{
			S++;
			for (i=1;i<=list1[0];i++)
			{
				x=list1[i];
				for (j=last[x];j>=1;j=nextt[j])
				{
					if (a[l[j]]!=0)
					{
						if (abs(a[l[j]]-a[x])!=1) SS=-1;
					}
					else
					{
						list2[++list2[0]]=l[j];
						a[l[j]]=a[x]+1;
					}
				}
			}
			for (i=1;i<=list2[0];i++)
			list1[i]=list2[i];
			list1[0]=list2[0];
			list2[0]=0;
		}
		if (SS!=-1) ans=max(ans,S);
	}
	if (ans==0) printf("-1");
	else printf("%lld",ans);
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int K, A, B;
  cin>>K>>A>>B;

  Int ans = 0;
  for(Int i=A;i<=B;i++){
    if(i % K == 0) ans = 1;
  }

  cout<<(ans? "OK":"NG")<<endl;



  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t
int main(){
    intf a,b,c,d;
    cin >>a >>b >>c >>d;
    while(1){
        c-=b;
        if(c<=0){
            cout << "Yes" <<endl;
            return 0;
        }
        a-=d;
        if(a<=0){
            cout << "No" <<endl;
            return 0;
        }
    }

}

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
typedef struct
{
  char mark;
  int c;
} CARD;


void swap(CARD *,CARD *);

int n;
int main(){
  int i,j,minj,k,flag=0;
  CARD trp1[36],trp2[36];
  char c[36][4];
  char memory[4][10];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    c[i][3]=0;
    scanf("%s",c[i]);
    if(c[i][3]!=0)exit(1);
    trp1[i].mark=trp2[i].mark=c[i][0];
    trp1[i].c=trp2[i].c=atoi(&c[i][1]);
}
  for(i=0;i<4;i++){
    for(j=0;j<10;j++){
      memory[i][j]='a';
    }
  }
  for(j=1;j<=9;j++){
    k=0;
   for(i=0;i<n;i++){   
     if(trp1[i].c==j)  {memory[k][j]=trp1[i].mark;k++;}
      
  }
  }

      
for(i=0;i<=n-1;i++){
  for(j=n-1;j>=i+1;j--){
    if(trp1[j].c<trp1[j-1].c) swap(&trp1[j],&trp1[j-1]);  
  }
 }
 for(i=0;i<=n-1;i++){
    if(i==n-1) printf("%c%d\n",trp1[i].mark,trp1[i].c);
    else  printf("%c%d ",trp1[i].mark,trp1[i].c);
 }
 for(i=1;i<=9;i++){
   k=0;
   for(j=0;j<n;j++){
   if(trp1[j].c==i){
     if(trp1[j].mark==memory[k][i])k++;
     else { flag=1; break;}
   }
   }
 }
 if(flag==0)printf("Stable\n");
 else printf("Not stable\n");

 flag=0;
for(i=0;i<=n-1;i++){
  minj=i;
  for(j=i;j<=n-1;j++){
    if(trp2[j].c<trp2[minj].c) minj=j;
  }
  swap(&trp2[i],&trp2[minj]);
 }

 for(i=0;i<n;i++){
    if(i==n-1) printf("%c%d\n",trp2[i].mark,trp2[i].c);
    else printf("%c%d ",trp2[i].mark,trp2[i].c);
  }
   for(i=1;i<=9;i++){
   k=0;
   for(j=0;j<n;j++){
   if(trp2[j].c==i){
     if(trp2[j].mark==memory[k][i])k++;
     else { flag=1; break;}
   }
   }
 }
   if(flag==0)printf("Stable\n");
   else printf("Not stable\n");
return 0;
}
void swap(CARD *c1,CARD *c2){
  CARD temp;
   temp =*c1;
    *c1=*c2;
    *c2=temp;
}

  



Measured memory_bytes: 2108
#include<iostream>
#include<cstring>
#include<queue>
#include<vector>
#include<utility>

typedef long long ll;

using namespace std;

int main() {
    int N;
    bool flg = true;
    cin >> N;
    
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(i*j == N){
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=1;i<=n;i++)

//負の辺がない場合
typedef pair<ll,int> P;
const int MAX = 100100;
const ll INF = 1e15;
struct edge{
    int to,cost;
};
int v;
vector<vector<edge>> G(MAX);
ll d[MAX];

void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P>> pq;
    rep(i,v) d[i] = INF;
    d[s]=0;
    pq.push({0,s});
    while(!pq.empty()){
        P p = pq.top(); pq.pop();
        int v = p.second;
        if(d[v]<p.first) continue;
        for(edge u:G[v]){
            if(d[u.to]>d[v]+u.cost){
                d[u.to]=(ll)d[v]+u.cost;
                pq.push({d[u.to],u.to});
            }
        }
    }
}

int main(){
    cin >> v;
    int n; cin >> n;
    rep(i,n){
        int l,r,c; cin >> l >> r >> c;
        l--; r--;
        G[l].push_back({r,c});
    }
    rep(i,v) if(i+1<n) G[i+1].push_back({i,0});
    dijkstra(0);
    if(d[v-1]<INF) cout << d[v-1];
    else cout << -1;
}


Measured memory_bytes: 8056
fun main(args: Array<String>) {
        val nk = readLine()!!.split(" ").map { it.toInt() }
        val h = readLine()!!.split(" ").map { it.toInt() }.sortedDescending()

        var count = nk[1]
        var result: Long = 0
        if (h.count() <= count) {
            result = 0
        } else {
            h.forEach { 
                if (count > 0) {
                    count -= 1
                } else {
                    result += it
                }
            }
        }
        print(result.toString())
}

Measured memory_bytes: 83744
#include <iostream>
#include <string>
using namespace std;
int main(){
    int i,j;
    int N,T,c,t,a=1001;
    cin >> N >> T;
    int cc[N],tt[N];
    for(i =0; i<N; i++){
        cin >> c >> t;
        cc[i] = c;
        tt[i] = t;
    }
    for(i =0; i<N; i++){
        if(tt[i]<= T){
            if(cc[i]<a){
                a = cc[i];
            }
        }
    }
    if(a!=1001){
        cout << a;
    }
    else{
        cout <<"TLE";
    }
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    int n, k; cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; ++i) cin >> h[i];

    vector<int> dp(n);
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);

    for(int i = 2; i < n; ++i) {
        int next = dp[i-1] + abs(h[i]-h[i-1]);
        for(int j = 2; i-j >= 0 && j <= k; ++j) {
            int cand = dp[i-j] + abs(h[i]-h[i-j]);
            next = min(next, cand);
        }
        dp[i] = next;
    }

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


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

void solve(std::string s){
  int a,z;
  REP(i, s.size()) {
    if(s[i] == 'A') {
      a = i;
      break;
    }
  }

  RREP(i, s.size()) {
    if(s[i] == 'Z') {
      z = i;
      break;
    }
  }

  cout << ((z - a) + 1) << 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(){
    std::string s;
  std::cin >> s;
    solve(s);
    return 0;
}


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

int main(){
  int a[3];
  
  for(int i=0;i < 3;i++){
    cin >> a[i];
  }
  sort(a,a+3);
  reverse(a,a+3);
  
  cout << a[0]*10+a[1]+a[2] << endl;
}

Measured memory_bytes: 256
n, d, a = [int(i) for i in input().split()]

xh = []
for i in range(n):
    xh.append([int(i) for i in input().split()])

# 座標でソート
xh.sort()
x = [xh[i][0] for i in range(n)]
h = [xh[i][1] for i in range(n)]

# i番目のモンスターに、i-k番目で使った爆弾が届いた場合の最小のi-k
# bisectより尺取り法のほうが圧倒的に速いだろjk
bomb_syakutori = [0 for i in range(n)]
l = 0
r = 0
flag = 0
while r <= n - 1:
    if x[r] <= x[l] + 2*d:
        bomb_syakutori[r] = l
        r += 1
    else:
        l += 1


bomb_ruisekiwa = [0 for i in range(n)]
# 左から貪欲に爆弾を使用
for i in range(n):
    bomb = 0
    if i == 0:
        bomb = (h[i]) // a + ((h[i]) % a != 0)
        bomb_ruisekiwa[i] = bomb
    else:
        if bomb_syakutori[i] == i:
            damage = 0
        elif bomb_syakutori[i]-1 < 0:
            damage = (bomb_ruisekiwa[i-1]) * a
        else:
            damage = (bomb_ruisekiwa[i-1] - bomb_ruisekiwa[bomb_syakutori[i]-1]) * a
        if h[i] - damage > 0:
            bomb = (h[i] - damage) // a + ((h[i] - damage) % a != 0)
        bomb_ruisekiwa[i] = bomb + bomb_ruisekiwa[i-1]

print(bomb_ruisekiwa[-1])

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

int main(){

    int N;
    
    int count = 0;

    cin >> N;

    rep(i,N){
        int cur;
        cin >> cur;
        if(cur != i+1){
            count++;
        }
    }

    if(count>2){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }


    return 0;
}

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

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


int main() {
	
	int N, X; cin >> N >> X;
	vector<int> x(N),y(N);              //y[i]を|X-x[i]|とする
	for (int i = 0;i < N;i++) {
		cin >> x[i];
		y[i] = abs(X-x[i]);

	}
	int ans = y[0];
	for (int i = 0;i < N - 1;i++) {
		ans = gcd(ans, y[i + 1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int main(){

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

	int mini = BIG_NUM,maxi = -BIG_NUM;
	int tmp;

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

		scanf("%d",&tmp);

		mini = min(mini,tmp);
		maxi = max(maxi,tmp);
	}

	printf("%d\n",maxi-mini);

	return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
#include <set>
using namespace std;


vector<vector<int>> g;
vector<pair<int, int>> edges;
map<pair<int, int>, int> c;
vector<int> vis;

int MX = 0;
int CNT = 0;

void find_root(int v)
{
	vis[v] = 1;
	CNT++;
	int m = (int)g[v].size();
	for (int i = 0; i < m; i++)
	{
		int nx = g[v][i];
		if (!vis[nx])
		{
			find_root(nx);
		}
	}
}

void color(int v, int p = -1, int pc = 0)
{
	vis[v] = 1;

	int m = (int)g[v].size();

	if (p != -1)
	{
		c[make_pair(p, v)] = c[make_pair(v, p)] = pc;
		MX = max(pc, MX);
	}
	
	int col = 1;
	for (int i = 0; i < m; i++)
	{
		int nx = g[v][i];

		if (!vis[nx])
		{
			if (col == pc)
			{
				col++;
			}
			color(nx, v, col++);
		}
	}

	
}

void solve()
{
	int n;
	cin >> n;

	g.resize(n);
	vis.assign(n, 0);

	for (int i = 0; i < n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		u--, v--;
		g[u].push_back(v);
		g[v].push_back(u);
		edges.push_back(make_pair(u, v));
	}


	int root = 0;
	for (int i = 0; i < n; i++)
	{
		if (!vis[i])
		{
			find_root(i);
		}
		
		if (CNT == n)
		{
			root = i;
			break;
		}
	}

	vis.assign(n, 0);

	color(root);

	cout << MX << "\n";
	for (int i = 0; i < n - 1; i++)
	{
		cout << c[edges[i]] << "\n";
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("file.in", "r", stdin);//freopen("file.out", "w", stdout);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 19708
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define REP(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define TF(flag) (flag)?1:0
#define fi first
#define se second
#define debug if(DEBUG)
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using pi = pair<ll,ll>;
 
template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}
 
template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  return os;
}
 
template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}
 
bool DEBUG=true;

// Code from here ! ==================================================================

vec<ll> dijkstra(mat<pi> G,int K){
  vec<ll> res(G.size(),LLONG_MAX);
  rpq<pi> que;
  res[K]=0;
  que.emplace(res[K],K);
  while(!que.empty()){
    ll cost,now; tie(cost,now)=que.top(); que.pop();
    if(res[now]<cost) continue;
    for(auto &e:G[now]){
      ll ncost=cost+e.second;
      if(res[e.first]<=ncost) continue;
      res[e.first]=ncost;
      que.emplace(res[e.first],e.first);
    }
  }
  return res;
}

int main(void){
  int N; cin>>N;
  mat<pi> G(N);
  rep(i,N-1){
    int a,b,c; cin>>a>>b>>c;
    --a,--b;
    G[a].emplace_back(b,c);
    G[b].emplace_back(a,c);
  }
  int Q,K; cin>>Q>>K;
  vec<ll> dist=dijkstra(G,K-1);
  vec<ll> ans(Q);
  rep(i,Q){
    int x,y; cin>>x>>y;
    ans[i]=dist[x-1]+dist[y-1];
  }
  for(auto &e:ans) cout<<e<<endl;
}
















Measured memory_bytes: 18160
//https://atcoder.jp/contests/abc136/tasks/abc136_d
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
#if LOCAL&01
    std::ifstream in("./input.txt"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    string S; cin>>S;
    vector<ll> ans(S.size());
    ll a=0;
    ll b=0;
    for(ll i=0;i<S.size()-1;++i){
        swap(a,b);
        if(S[i]=='R'&&S[i+1]=='L'){
            ans[i]=1+a;
            ans[i+1]=1+b;
            a=0;
            b=0;
        } else if(S[i]=='R'){
            ++a;
        }
    }    
    //反対から
    a=0,b=0;
    for(ll i=S.size()-1;i>=1;--i){
        swap(a,b);
        if(S[i-1]=='R'&&S[i]=='L'){
            ans[i-1]+=b;
            ans[i]+=a;
            a=0;
            b=0;
        } else if(S[i]=='L'){
            ++a;
        }
    }    
    REP(i,ans.size()){
        if(i==0){
            cout<<ans[i];
        } else {
            cout<<" "<<ans[i];
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
 
using namespace std;

int main()
{
	int n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	if(s[k-1] == 'A') s[k-1] = 'a';
	if(s[k-1] == 'B') s[k-1] = 'b';
	if(s[k-1] == 'C') s[k-1] = 'c';
	cout<<s<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define s(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
int main(){
  int n,m;
  cin >> n>>m;
  vector<vl>a(m);
  rep(i,m){
    int k;
    cin >>k;
    rep(j,k){
      int s;
      cin >>s;s--;
      a[i].push_back(s);
    } 
  }
  vl p(m);
  rep(i,m) cin>>p[i];
  int ans =0;
  for(int bit =0;bit<(1<<n);bit++){
    bool  f = true;
    rep(i,m){
      int count =0;
      for(auto v:a[i]){
        if(bit&(1<<v))count++;
      }
      if(count%2!=p[i])f=false;
    }
    if(f)ans++;

  }
  cout<<ans<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int d;
vector<int> c(26);
vector<vector<int>> s(400, vector<int>(26));

int get_score(vector<int> t){
    int ans = 0;
    vector<int> last(26, 0);
    rep(i, d){
        ans += s[i][t[i]];
        rep(j, 26){
            if(t[i] == j)last[j] = i+1;
            ans -= c[j] * ((i+1)-last[j]);
        }
    }
    return ans;
}

int main() {
    cin >> d;
    rep(i, 26)cin >> c[i];
    rep(i, d)rep(j, 26)cin >> s[i][j];
    //-----code------// 
    vector<int> t(d, 0);
    int m;
    cin >> m;
    rep(i, 100000){
        int D = rand() % d, q = rand() % 26;
        int old = t[D], olds = get_score(t);
        t[D] = q;
        if(get_score(t) < olds)t[D] = old;
    }
    rep(i, d)cout << t[i]+1 << endl;
}


Measured memory_bytes: 3628
'use strict'

function Main(input) {
  const N = Number(input.split("\n")[0])
  const list = input.split("\n").slice(1)

  const sorted = list.map(x => x.split("").sort().join("")).sort()

  let count = 0
  let ans = 0
  for(let i=1; i<N; i++) {
    if(sorted[i-1] === sorted[i]) {
      count++
    } else {
      ans += ((1+count)*count/2)
      count = 0
    }
  }
  ans += ((1+count)*count/2)

  console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim())

Measured memory_bytes: 56024
/*
 * Codeforces Contest
 * Au: Lost_Deviation
 */
#ifndef open_dbg_func
#define err(args...)
#endif
#include <bits/stdc++.h>
using namespace std;
#define ll long long
static auto XxXOxO = []() {
    std::ios::sync_with_stdio(false); // turn off sync
    cin.tie(nullptr);                 // untie in/out streams
    return 0;
}();
struct T {
    int x, y;
};
int cmp(const T &a, const T &b) {
    if (a.x != b.x)
        return (a.x < b.x);
    else
        return (a.y < b.y);
}
int a[32] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
             1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(void) {
    int k;
    cin >> k;
    cout << a[k - 1];
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
const int INF = 1e9;
const ll MOD = 1000000007;
const ll LINF = 1e18;
using namespace std;



int main() {
    ll n,m, count=0;
    cin>>n>>m;
    
    vector<ll> h(n);
    rep(i,n) cin>>h[i];
    
    vector<ll> a(m);
    vector<ll> b(m);
    
    vector<bool> c(n,true);
    
    rep(i,m){
        cin>>a[i]>>b[i];
    }
    
    rep(i,m){
        if(h[a[i]-1]>h[b[i]-1]) c[b[i]-1] = false;
        
        if(h[a[i]-1]<h[b[i]-1]) c[a[i]-1] = false;
        
        if(h[a[i]-1]==h[b[i]-1]){
            c[a[i]-1] = false;
            c[b[i]-1] = false;
        }
    }
    
    rep(i,n) {
        if(c[i]==true) count++;
    }
    
    cout<<count<<endl;
    
    return 0;
}



Measured memory_bytes: 5592
//
//  main.cpp
//  test
//
//  Created by 田宇航 on 2019/8/4.
//  Copyright © 2019 田宇航. All rights reserved.
//
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<stack>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define MAXN 100000+50
#define MAXM 30000
#define ll long long
#define rep(i,n,m) for(int i=n;i<=m;++i)
#define mod 1000000000 + 7
#define mian main
#define mem(a, b) memset(a, b, sizeof a)
#ifndef ONLINE_JUDGE
#define dbg(x) cout << #x << "=" << x << endl;
#else
#define dbg(x)
#endif
inline int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
    {
        x = 10 * x + ch - '0';
        ch = getchar();
    }
    return x * f;
}
int s[] = { 0,9,0,900,0,90000,0,9000000};
int main()
{
    int T=1;
    while(T--){
    int n = read();
    int num = n / 10;
    int sum = 0;
    if (num == 0) sum = n;
    else {
        //100 200 300
        num = n;
        int num_d = 0;
        while (num) { num /= 10; num_d++; }
        for (int i = 1; i < num_d; ++i) sum += s[i];
        int st = 1;
        rep(i, 1, num_d - 1) st *= 10;
        if (num_d & 1)
        {
            sum += (n - st + 1);
        }
    }
    cout << sum << endl;
    }
}
// 100-999 99999-10000 90000


Measured memory_bytes: 256
N = int(input())
cards = list(map(int, input().split()))
cards.sort(reverse = True)
score_A = 0
score_B = 0
for i in range(len(cards)):
  if i%2 == 0:
    score_A += cards[i]
  else :
    score_B += cards[i]
print(score_A - score_B)

Measured memory_bytes: 9116
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    rep(i, 10) {
        rep(j, 10) {
            rep(k, 10) {
                string num = to_string(i*100+j*10+k);
                if (i == 0) {
                    if (j == 0) { 
                        num = "00" + num;
                    }
                    else {
                        num = "0" + num;
                    }
                }
                int now = 0;
                rep(l, n) {
                    if (now == 3) break;
                    if (s[l] == num[now]) now++;
                }
                if (now == 3) ans++;
            }
        }
    }
    cout << ans << endl;
}

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

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        public static List<long> GeneratePrime(long max)
        {
            long prime;
            double sqrtMax = Math.Sqrt(max);
            var primeList = new List<long>();

            List<long> searchList = new List<long>();
            for (long i = 2; i <= max - 1; i++)
            {
                searchList.Add(i);
            }

            do
            {
                prime = searchList.First();
                primeList.Add(prime);
                searchList.RemoveAll(n => n % prime == 0);
            } while (prime < sqrtMax);

            primeList.AddRange(searchList);

            return primeList;
        }

        void Omame()
        {
            cin = new Scanner();
            long a = cin.nextLong();
            long b = cin.nextLong();
            StringBuilder aaa = new StringBuilder();
            StringBuilder bbb = new StringBuilder();

            for (int i = 0; i < a; i++)
            {
                aaa.Append(b);
            }

            for (int i = 0; i < b; i++)
            {
                bbb.Append(a);
            }

            List<string> list = new List<string>();
            list.Add(aaa.ToString());
            list.Add(bbb.ToString());

            list.Sort();

            Console.WriteLine(list[0]);


        }
    }
}


Measured memory_bytes: 13408
import sys
input=lambda: sys.stdin.readline().rstrip()
k=int(input())
S=input()
mod=10**9+7
n=len(S)
n_max=2*(10**6+1)
F,FI=[0]*(n_max+1),[0]*(n_max+1)
F[0],FI[0]=1,1
for i in range(n_max):
  F[i+1]=(F[i]*(i+1))%mod
FI[n_max-1]=pow(F[n_max-1],mod-2,mod)
for i in reversed(range(n_max-1)):
  FI[i]=(FI[i+1]*(i+1))%mod
def comb(x,y):
  return (F[x]*FI[x-y]*FI[y])%mod

P1,P2=[1],[1]
for _ in range(10**6):
  P1.append((P1[-1]*26)%mod)
  P2.append((P2[-1]*25)%mod)

ans=0
for i in range(n,n+k+1):
  ans+=comb(i-1,n-1)*P2[i-n]*P1[n+k-i]
  ans%=mod
print(ans)


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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 998244353

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define prll(v) for (auto i: v) cout << i << " ";

bool isPrime(ll a) {
    if (a == 1)
        return true;
    if (a%2 == 0 && a > 2)
        return false;
    for (ll i = 3; i*i <= a; i += 2)
        if (a%i == 0)
            return false;
    return true;
}

int main() {
    fast
    ll a, b;
    cin >> a >> b;
    ll g = __gcd(a, b);
    ll x = 0;
    for (ll i = 1; i*i <= g; i++) {
        if (g%i == 0) {
            x += isPrime(i);
            if (i*i != g)
                x += isPrime(g/i);
        }
    }
    cout << x << endl;
}


Measured memory_bytes: 256
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(1,n):
    if a[i-1]+a[i]>x:
        ans+=a[i]+a[i-1]-x
        if x<a[i-1]:
            a[i]=0
        else:
            a[i]=x-a[i-1]
print(ans)

Measured memory_bytes: 14068
import java.util.*;

public class Main {
	public static void main(String[] args){
	     Scanner sc = new Scanner(System.in);
	     int n = sc.nextInt();
	     
	     int n3 = n%10;
	     int n2 = n/10%10;
	     int n1 = n/100;

	     switch(n1){
	     	case 1:
	     	n1 = 9;
	     	break;
	     	case 9:
	     	n1 = 1;
	     	break;
	     }

	     switch(n2){
	     	case 1:
	     	n2 = 9;
	     	break;
	     	case 9:
	     	n2 = 1;
	     	break;
	     }

	     switch(n3){
	     	case 1:
	     	n3 = 9;
	     	break;
	     	case 9:
	     	n3 = 1;
	     	break;
	     }

	     System.out.println(100*n1 + 10*n2 + n3);
	}
}

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

#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int k;
    int x;
    cin >> k >> x;
    if (500 * k >= x)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  ll x;
  cin >> x;

  for (ll t = 0;; ++t) {
    if (t*(t+1)/2 >= x) {
      cout << t << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
set<string> set_substring;
string str,minstr;
char sz[5001];
set<string>::iterator it;
void PSS(string s,int k)
{
	int i,j;
	for(i=1;i<=k;i++)
	{
		for(j=0;j<k-i+1;j++)
			set_substring.insert(s.substr(j,i));
	}
}
int main()
{
	int k;
	int i;
	scanf("%s",sz);
	scanf("%d",&k);
	str=sz;
	minstr=str;
	if(str.length()>=k)
	{	
		for(i=1;i<=str.length()-k;i++)
		{
			if(minstr>str.substr(i-1,i+k-1))
			{
				minstr=str.substr(i-1,i+k-1);
				PSS(minstr,k);
			}
		}
		PSS(str.substr(str.length()-k),k);
	}
	else
	{
		PSS(str,str.length());
	}
	it=set_substring.begin();
	for(i=0;i<k-1;i++)
		it++;
	printf("%s",(*it).c_str());
	return 0;
}

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

using namespace std;

vector<vector<pair<int, int>>> graph;
vector<int> res;
void dfs (int r, int rc, int n) {
  int c = rc == 0 ? 1 : 0;
  for (auto t : graph[n]) {
	if (t.second == r)
	  continue;
	res[t.first] = c;
	dfs(n, c, t.second);
	c = c + 1 == rc ? rc+1 : c+1;
  }
}

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

  int N; cin>>N;
  graph.resize(N);
  for (int i = 0; i < N-1; i++) {
    int a,b; cin>>a>>b;
    a--; b--;
    graph[a].push_back({i, b});
    graph[b].push_back({i, a});
  }
  int max_col = 0;
  for (int i = 0; i < N; i++) {
    int ncol = graph[i].size();
    if (ncol > max_col) {
      max_col = ncol;
    }
  }

  res.resize(N-1);
  dfs(-1, -1, 0);

  cout << max_col << endl;
  for (auto c : res)
    cout << c+1 << endl;

  return 0;
}


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

int main() {
  int s,s1,s2,s3;
  cin >> s;
  s1 = s/100;
  s2 = (s-s1*100)/10;
  s3 = s-s1*100-s2*10;
  cout << s1+s2+s3 << endl;
}

Measured memory_bytes: 256