akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 0003：Is it a Right Triangle?
 * 
 * @author Lyu
 * @version 2015/07/12
 */
public class Main {

    /** 区切り文字：スペース */
    private static final String DELIMITER_SPACE = " ";

    /**
     * データセットで与えられた数を3辺とする三角形が直角三角形かを判断する。
     * 
     * @param args
     * @throws IOException
     * @throws NumberFormatException
     */
    public static void main(String[] args) throws NumberFormatException, IOException {

        List<int[]> dataSets = new ArrayList<int[]>();
        int countOfDataSet = getInput(dataSets);

        for (int i = 0; i < countOfDataSet; ++i) {
            System.out.println(getResult(dataSets.get(i)));
        }
    }

    private static String getResult(int[] dataSets) {
        Arrays.sort(dataSets);

        if (isRightTriangle(dataSets)) {
            return "YES";
        } else {
            return "NO";
        }
    }

    private static boolean isRightTriangle(int[] lengths) {
        if (lengths[2] * lengths[2] == lengths[0] * lengths[0] + lengths[1] * lengths[1]) {
            return true;
        }
        return false;
    }

    private static int getInput(List<int[]> target) throws NumberFormatException, IOException {
        // 入力読取り
        InputStreamReader streamReader = new InputStreamReader(System.in);
        BufferedReader bufferedReader = new BufferedReader(streamReader);

        String line = null;
        boolean isFirst = true;
        int numberOfDataSet = 0;

        try {
            while ((line = bufferedReader.readLine()) != null) {
                if (isFirst) {
                    numberOfDataSet = Integer.parseInt(line);
                    isFirst = false;
                } else {
                    String[] strLengths = line.split(DELIMITER_SPACE);
                    int[] intLengths = new int[3];
                    intLengths[0] = Integer.parseInt(strLengths[0]);
                    intLengths[1] = Integer.parseInt(strLengths[1]);
                    intLengths[2] = Integer.parseInt(strLengths[2]);
                    target.add(intLengths);
                }
            }
            return numberOfDataSet;
        } finally {
            bufferedReader.close();
            streamReader.close();
        }
    }
    
}

Measured memory_bytes: 20216
#include <bits/stdc++.h>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define NMAX 100013
using namespace std;
int N, M, R, C, x, y, start, j;
multiset <int> target;
multiset <int> curr;
int main() {
    cin >> N;
    int M  = (1 << N);
    vector <int> A(M);
    for (int i = 0; i < M; ++i)
        cin >> x, target.insert(-1 * x);
    curr.insert(*(target.begin()));
    target.erase(target.begin());
    while (!target.empty()) {
        multiset <int> toadd;
        for (auto x : curr) {
            auto pos = target.upper_bound(x);
            if (pos == target.end()) {
                cout << "No\n";
                return 0;
            }
            toadd.insert(*pos);
            target.erase(pos);
        }
        for (auto x : toadd)
            curr.insert(x);
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 19712
#include<bits/stdc++.h>
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   long long x;
   cin >> x;
   long long ans = 0;
   ans += (x/500)*1000;
   long long y = x%500;
   ans += (y/5)*5;
   cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
const int MAXN=3010;
char a[MAXN],b[MAXN];
int f[MAXN][MAXN],g[MAXN][MAXN];
//(g=0:in LCS sequence),(g=1:from[i-1,j]),(g=-1:from[i,j-1])

void dfs(int i,int j){
	if(i==0||j==0)
		return;
	if(g[i][j]==0){
		dfs(i-1,j-1);
		putchar(a[i]);
	}
	else if(g[i][j]==1)
		dfs(i-1,j);
	else
		dfs(i,j-1);
}

int main(){
	scanf("%s%s",a+1,b+1);
	int n=strlen(a+1),m=strlen(b+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			if(a[i]==b[j]){
				f[i][j]=f[i-1][j-1]+1;
				g[i][j]=0;
			}
			else if(f[i-1][j]>=f[i][j-1]){
				f[i][j]=f[i-1][j];
				g[i][j]=1;
			}
			else{
				f[i][j]=f[i][j-1];
				g[i][j]=-1;
			}
		}
	dfs(n,m);puts("");
	return 0;
}

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

int main(){
    int n;
    cin >>n;
    int x;
   x = n%10;
    if(x==2 || x==4 || x==5 || x==7 || x==9)
    	cout << "hon" << endl;
    else if(x==0 || x==1 || x==6 || x==8)
    	cout << "pon" << endl;
    else
    	cout << "bon" << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
const int maxn = 10000005;
const int mod = 998244353;
const int mx = 2e9;
vector<int>g[100005];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int m;
    cin >> m;
    f (m) {
        int x, y;
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    int v[n + 5] = {};
    int ans[n + 5] = {};
    queue<int>q;
    q.push(1);
    v[1] = 1;
    while (q.size()) {
        auto now = q.front();
        q.pop();
        for (auto i : g[now]) {
            if (!v[i]) {
                v[i] = 1;
                ans[i] = now;
                q.push(i);
            }
        }
    }
    for (int i = 1 ; i <= n ; i++) {
        if (! v[i]) {
            cout << "No\n";
            exit(0);
        }
    }
    cout << "Yes\n";
    for (int i = 2 ; i <= n ; i++) {
        cout << ans[i] << '\n';
    }
}

Measured memory_bytes: 10928
import java.io.PrintWriter

object Loop {
  @inline def rep(n: Int, f: => Unit): Unit = { var c = 0; while (c < n) { f; c += 1 } }
  @inline def rep(n: Int, f: Int => Unit): Unit = { var c = 0; while (c < n) { f(c); c += 1 } }

  @inline def breakAble(n: Int, m: Int, f: Int => Boolean): Unit = if (f(n) && n < m) breakAble(n + 1, m, f)
  @inline def !(n: Int): Int = (1 + n) * n / 2
}
object Mod {
  def create(n: Int, mod: Int) = Mod(n, mod)
}
case class Mod(n: Int, mod: Int) {
  val factorial: Array[Int] = Array.fill[Int](n + 1)(1)
  val inverse: Array[Int] = Array.fill[Int](n + 1)(1)
  val inverseFactorial: Array[Int] = Array.fill[Int](n + 1)(1)
  Loop.rep(n - 1, i => {
    val k = i + 2
    factorial(k) = modMultiplyExact(factorial(k - 1), k, mod)
    inverse(k) = modMultiplyExact(inverse(mod % k), mod - (mod / k): Int, mod)
    inverseFactorial(k) = modMultiplyExact(inverseFactorial(k - 1), inverse(k), mod)
  })
  def getFactorial(n: Int): Int = factorial(n)
  def getInverse(n: Int): Int = inverse(n)
  def getInverseFactorial(n: Int): Int = inverseFactorial(n)
  def C(n: Int, k: Int): Int = {
    if (n <= 0 || k < 0 || k > n) 0 else if (k == 0 || k == n) 1 else {
      modMultiplyExact(
        getFactorial(n),
        getInverseFactorial(n - k),
        getInverseFactorial(k),
        mod
      )
    }
  }
  def modMultiplyExact(a: Int, b: Int, m: Int): Int =
    ((a.toLong * b.toLong) % m).toInt
  def modMultiplyExact(a: Int, b: Int, c: Int, m: Int): Int =
    modMultiplyExact(a, modMultiplyExact(b, c, m), m)
}
object Scanner {
  private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0
  @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
  @inline private def hasNextByte(): Boolean =
    if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }
  @inline private def hasNext(): Boolean = {
    while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
    hasNextByte()
  }
  @inline private def readByte(): Byte =
    if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }
  def next(): String = {
    if(!hasNext()) ???
    val sb = new StringBuilder; var b = readByte()
    while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
    sb.toString
  }
  def nextInt(): Int = {
    val n = nextLong()
    if (n < Int.MinValue || Int.MaxValue < n) ???
    n.toInt
  }
  def nextLong(): Long = {
    if(!hasNext()) ???
    var minus = false; var b = readByte()
    if (b == '-') { minus = true; b = readByte() }
    def go (b: Byte, n: Long = 0): Long =
      if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }
      else if (minus) { -n } else { n }
    go(b)
  }
  def nextDouble(): Double = next.toDouble

  def print(f:PrintWriter => Unit): Unit = {
    val pw: PrintWriter = new java.io.PrintWriter(System.out)
    //pw.println("")
    f(pw)
    pw.flush()
  }
}
////////////////////////////////////////
//
////////////////////////////////////////
object Main extends App {

  val a, b, c = Scanner.nextInt()
  val sum = a + b + c
  if (sum >= 22) print("bust") else print("win")

}

Measured memory_bytes: 25496
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int main() {
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  for(int i = 1; i <= 1000; i++) {
    if((i*a)%b == c) {
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");
}


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

int main()
{
	string s;
	string::iterator it;
	int n=0, mx=0;

	getline(cin, s);

	for(it=s.begin();it!=s.end();it++){
		if(*it=='A' || *it=='C' || *it=='T' || *it=='G')n++;
		else{
			mx = max(mx, n);
			n=0;
		}
	}
	mx = max(mx,n);
	cout << mx << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	string s; cin>>s;
	rep(i,0,s.size()) cout<<"x";
	cout<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(N: int):
    if "7" in str(N):
        yes()
    else:
        no()
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9212
#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 a,b;
	cin >> a >> b;
	int cnt = 0;
	for(int i = a;i <= b;i++){
        int k = i;
		int hi = k%10;
		k /= 10;
		int hu = k%10;
		k /= 10;
        k /= 10;
		int yo = k%10;
		k /= 10;
		int go = k%10;
		if(hi == go && hu == yo) cnt++;
	}
	cout << cnt << endl;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

void read() {
	string s;
	cin >> s;
	if (s != "ABC")
		cout << "ABC";
	else 
		cout << "ARC";
}

void run() {

}

void write() {

}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <stdlib.h>

using namespace std;

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

    vector<vector<int>> p(N);
    int a, b, c;
    for (int i = 0; i < N; ++i)
    {
        cin >> a >> b >> c;
        p[i] = { a, b, c };
    }

    vector<vector<int>> dp(N + 1, vector<int>(3, 0));

    for (int i = 1; i < N + 1; ++i) {
        for (size_t prev = 0; prev < 3; ++prev) {
            dp[i][prev] = max({ dp[i][prev], dp[i - 1][(prev + 1) % 3] + p[i - 1][(prev + 1) % 3], dp[i - 1][(prev + 2) % 3] + p[i - 1][(prev + 2) % 3] });
        }
    }
    int mx;
    mx = max({ dp[N][0], dp[N][1], dp[N][2] });
    cout << mx << "\n";
}

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

    solve();
}


Measured memory_bytes: 14288
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

int N,A[105];
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cin>>N;
	rep(i,N)cin>>A[i];
	sort(A,A+N);
	int ans=0;
	rep(i,N){
		for(int j=i+1;j<N;j++){
			if(A[i]==A[j])continue;
			for(int k=j+1;k<N;k++){
				if(A[j]==A[k]||A[i]==A[k])continue;
				if(A[k]<A[i]+A[j])ans++;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;
int memo[201][201];

int rec(int a,int b) {
    if (memo[a][b] == -1) {
        if (a % b == 0)
            memo[a][b] = b;
        else
            memo[a][b] = rec(b, a % b);
    }
    return memo[a][b];
}

int gcd(int a, int b) {
    if (a < b)
        return rec(b, a);
    return rec(a, b);
}

int main(void) {
    int N;
    int ans = 0;

	cin >> N;

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            memo[i][j] = -1;
        }
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            for (int k = 1; k <= N; k++) {
                ans += gcd(gcd(i, j), k);
            }
        }
    }
	cout << ans << endl;
	return 0;
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1000000007LL
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(i=a;i<=b;i++)

#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

ll mypow(ll a, ll b) { if(b == 0) return 1; ll temp=mypow(a,b/2); temp=(temp*temp)%INF; if(b%2 == 1) temp=(a*temp)%INF; return temp; }
int mygcd(int a, int b) { if(b==0) return a; return mygcd(b,a%b); }
int cntBits(ll a) { int ret=0; while(a>0) { ret++; a/=2; } return ret; }

int n, arr[200], dp[100010][2];

int func(int k, int turn)
{
	if(k==0) return 0;
	if(k<0) return 1;
	if(dp[k][turn]!=-1) return dp[k][turn];
	dp[k][turn]=0;
	for(int i=0;i<n;i++)
	{
		if(func(k-arr[i], 1-turn)==0)
		{
			dp[k][turn]=1;
			break;
		}
	}
	return dp[k][turn];
}

int main()
{
	ios::sync_with_stdio(0);
	int tt=1,tcase; 
	//cin >> tt;
	rep(tcase,1,tt)
	{
		int k; cin >> n >> k;
		for(int i=0;i<n;i++) cin >> arr[i];
		for(int i=0;i<=k;i++) dp[i][0]=dp[i][1]=-1;
		if(func(k,0)) cout << "First\n";
		else cout << "Second\n";
	}
	return 0;
}


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

using namespace std;

const int N = 1e5 + 10;

int n;
int a[N];
int cnt[N];

void run() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  for (int i = 1; i <= n; ++i) cnt[a[i]]++;
  int ans = 1;
  for (int i = 1; i < N - 1; ++i) {
    ans = max(ans, cnt[i - 1] + cnt[i] + cnt[i + 1]);
  }
  printf("%d\n", ans);
}

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


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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 int main() {
   int N, Y, x = -1, y = -1, z = -1;
   cin >> N >> Y;
   bool done = false;

   rep(i, min(N + 1, Y / 10000 + 1)) {
     rep(j, min(N + 1, Y / 5000 + 1)) {
       if (Y - 10000 * i -  5000 * j >= 0 && (Y - 10000 * i -  5000 * j) % 1000 == 0 && N - i - j == (Y - 10000 * i -  5000 * j) / 1000){
         x = i;
         y = j;
         z = N - i - j;
         done = true;
         break;
       }
     }
     if (done) break;
   }

   cout << x << " " << y << " " << z << endl;
 }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
set<int> st;
int n,x,ans;
int m[1005];
int tmpmin=1e9;
int main(int argc,char const* argv[])
{
  int a,b,c,k,x,y;
  cin >> a >> b >> c;
  cin >> k;
  int tmp=max(a,b);
  tmp=max(tmp,c);
  if(tmp==a) x=b,y=c;
  else if(tmp==b) x=a,y=c;
  else if(tmp==c) x=a,y=b;
  for(int i=0;i<k;i++)
    {
      tmp*=2;
    }
  cout << tmp+x+y << endl;
  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 INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  string S;
  cin >> S;

  int cnt =0;
  REP(i,S.size()-1){
    if(S.at(i)!=S.at(i+1)){
      cnt++;
    }
  }

  cout << cnt << endl;
}

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

int main()
{
    int ans = 0;

    int X, D;
    cin >> X >> D;
    for (int i = 0; i < X; i++)
    {
        ll x, y;
        cin >> x >> y;
        double d = sqrt(x * x + y * y);
        if (d <= D)
        {
            ans++;
        }
    }

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

Measured memory_bytes: 3676
#include <cstdio>
using namespace std;

typedef long long ll;
typedef struct stick{
 ll lren, rren, sl, sr, weight; 
} STICK;

ll n, tmp, top;
ll depth[101];
STICK st[101];

void init(ll k){
 for(ll i = 0; i <= k; i++){
  depth[i] = 0;
  st[i].weight = 0;
 }
}

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

ll lcm(ll a, ll b){
 return a * b / gcd(a, b);
}

ll solve(ll k){
 if(st[k].weight > 0) return st[k].weight;
 if(st[k].sl == 0 && st[k].sr == 0){
  return st[k].weight = st[k].lren + st[k].rren;
 }else if(st[k].sl == 0){
  return st[k].weight = solve(st[k].sr) * (st[k].lren + st[k].rren) / gcd(solve(st[k].sr), st[k].lren);
 }else if(st[k]. sr == 0){
  return st[k].weight = solve(st[k].sl) * (st[k].lren + st[k].rren) / gcd(solve(st[k].sl), st[k].rren);
 }else {
  tmp = lcm(solve(st[k].sl) * st[k].lren, solve(st[k].sr) * st[k].rren);
  return st[k].weight = tmp / st[k].lren + tmp / st[k].rren;
 }
}

int main(){
 while(scanf("%d", &n)){
  if(n == 0) break;
  init(n);
  for(ll i = 1; i <= n; i++){
   scanf("%d %d %d %d", &st[i].lren, &st[i].rren, &st[i].sl, &st[i].sr);
   tmp = gcd(st[i].lren, st[i].rren);
   st[i].lren /= tmp;
   st[i].rren /= tmp;
  }
  for(ll i = 1; i <= n; i++){
   depth[st[i].sl]++;
   depth[st[i].sr]++;
  }
  for(ll i = 1; i<= n; i++){
   if(depth[i] == 0){
    top = i;
    break;
   }
  }
  printf("%d\n", solve(top));
 }
 return 0;
}

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

int main(){
	int xi,yi,xf,yf;
	cin >> xi >> yi >> xf >> yf;
	
	for(int i = 0;i<(yf-yi);i++)
		cout<<"U";
	for(int i = 0;i<(xf-xi);i++)
		cout<<"R";
	for(int i = 0;i<(yf-yi);i++)
		cout<<"D";
	for(int i = 0;i<(xf-xi);i++)
		cout<<"L";
	cout<<"L";
	for(int i = 0;i<(yf-yi+1);i++)
		cout<<"U";
	for(int i = 0;i<(xf-xi+1);i++)
		cout<<"R";
	cout<<"D";
	cout<<"R";
	for(int i = 0;i<(yf-yi+1);i++)
		cout<<"D";
	for(int i = 0;i<(xf-xi+1);i++)
		cout<<"L";
	cout<<"U";
	

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using ld = long double;
constexpr ld eps = 1e-4;

ld calc(const vector<pair<ld,ld>> &vv, const vector<ld> &coeff, const int i, const ld x) {
  ld sum = 0;
  REP(j,i) {
    ld mul = 1;
    REP(k,j) {
      mul *= x - vv[k].first;
    }
    sum += mul * coeff[j];
  }
  return sum;
}

ld mul(const vector<pair<ld,ld>> &vv, const int i, const ld x) {
  ld mul = 1;
  REP(j,i) {
    mul *= x - vv[j].first;
  }
  return mul;
}

ld val(const vector<pair<ld,ld>> &vv, const ld x) {
  int n = vv.size();
  vector<ld> coeff;
  coeff.push_back(vv[0].second);
  FOR(i,1,n) {
    ld sum = calc(vv, coeff, i, vv[i].first);
    coeff.push_back((vv[i].second - sum) / mul(vv, i, vv[i].first));
  }
  return calc(vv, coeff, n, x);
}

int main() {
  while (true) {
    int d;
    cin>>d;
    if (!d) break;
    vector<pair<ld,ld>> vv;
    REP(i,d+3) {
      ld v;
      cin>>v;
      vv.emplace_back((ld)i, v);
    }
    set<int> s;
    REP(i,d+3) s.insert(i);
    REP(i,d+3)REP(j,i) {
      vector<pair<ld,ld>> tmp;
      REP(k,d+3) {
        if (k==i || k==j) continue;
        tmp.push_back(vv[k]);
      }
      ld diffi = val(tmp, vv[i].first) - vv[i].second;
      ld diffj = val(tmp, vv[j].first) - vv[j].second;
      if (abs(diffi) < eps || abs(diffj) < eps) {
        REP(k,d+3) {
          if (k==i || k==j) continue;
          s.erase(k);
        }
      }
    }
    assert(s.size() == 1);
    cout << *begin(s) << endl;
  }
  return 0;
}

Measured memory_bytes: 3280
import sys
from heapq import heappush, heappop

def main():
    _,M,*A = map(int, open(0).read().split())

    A = [-x for x in A] # reverse max to min
    A.sort()

    for _ in range(M):
        a = int(heappop(A) / 2)
        heappush(A, a)
    print(-sum(A))

if __name__=='__main__':
    main()

Measured memory_bytes: 71228
/* # */

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <functional>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;
#define		it(x)  x.begin() 
#define		all(x)  x.begin(), x.end()
#define		pb(x)   push_back(x)
constexpr int           inf = 0x3f3f3f3f;
constexpr long long 	INF = 9123456789123456789;
constexpr long long     MOD = 1000000007LL;
/*************************************************/

void sol() {
    ll n, ans(0);
    cin >> n;
    for (ll i = 1; i <= n; i++) {
        ll cnt = (n / i);

        if (cnt % 2 == 0) 
        {
            ans += (i + cnt * i) * (cnt / 2);
        }
        else
        {
            ans += ((cnt + 1) * i / 2) * cnt;
        }
    }
    
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie(nullptr);
    int T(1);
    while (T--)
        sol();


    return 0;
}

Measured memory_bytes: 3584
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 998244353; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	A, B, C, D = getlist()
	DP = [[0] * (D + 1) for i in range(C + 1)]
	DP[A][B] = 1
	for i in range(B + 1, D + 1):
		DP[A][i] = (DP[A][i - 1] * A) % con

	for i in range(A + 1, C + 1):
		DP[i][B] = (DP[i - 1][B] * B) % con

	#DP
	for i in range(A + 1, C + 1):
		for j in range(B + 1, D + 1):
			DP[i][j] = (DP[i][j - 1] * i + DP[i - 1][j] * j - DP[i - 1][j - 1] * (i - 1) * (j - 1)) % con

	ans = DP[C][D]
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 131304
import copy

s = input()
t = input()

sn = len(s)
tn = len(t)
a = [[] for i in range(26)]
for i in range(sn):
    num = ord(s[i]) - 97
    a[num].append(i)

table = [[0]*sn for i in range(26)]
for i in range(26):
    if a[i]:
        table[i][:] = [copy.deepcopy(a[i][0])]*sn
    f = 0
    for j in a[i]:
        table[i][f:j] = [copy.deepcopy(j)]*(j-f)
        f = copy.deepcopy(j)

flg = True
cnt = 0 # 今何週したか
x = -1 # 今何文字目か
for i in range(tn):
    num = ord(t[i]) - 97
    # sの中に対象の文字が存在しない
    if not a[num]:
        flg = False
        break
    # sの中に対象の文字が存在
    xx = copy.deepcopy(x)
    x = table[num][x]
    if xx >= x:
        cnt += 1
print(cnt*sn + x+1) if flg else print(-1)

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

int main()
{

        ll X, Y; cin >> X >> Y;
        ll max = X * 4;
        ll min = X * 2;
        if (Y > max || Y < min) {
                cout << "No" << endl;
                exit(0);
        }
        if (Y % 2 && Y % X) {
                cout << "No" << endl;
                exit(0);
        }
        else if (Y % 2) {
                cout << "No" << endl;
                exit(0);
        }
        cout << "Yes" << endl;



}


Measured memory_bytes: 3632
#include <stdio.h>
int main()
{
    int i,a,b,c;
    char op;
    for(i=0;;i++)
    {
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?')
            break;
        else{
                if(op=='+')
                c=a+b;
                else if(op=='-')
                c=a-b;
                else if(op=='*')
                c=a*b;
                else if(op=='/')
                c=a/b;


        }
        printf("%d\n",c);
    }



    return 0;
}



Measured memory_bytes: 2128
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
  		int x = sc.nextInt();    	
  
      	if(x == 1) x = 0;
      	else x = 1;
           
      	System.out.println(x);
        
	}
}


Measured memory_bytes: 35712
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		n: usize,
		mut a: [isize; n],
	}

	a.insert(0, 0);
	a.push(0);

	let mut p = a[0];
	let mut sum = 0isize;
	for i in 1..=n+1 {
		sum += (p-a[i]).abs();
		p = a[i];
	}
	for i in 1..n+1 {
		println!("{}", sum - (a[i-1]-a[i]).abs() - (a[i]-a[i+1]).abs() + (a[i-1]-a[i+1]).abs() );
	}
}



Measured memory_bytes: 3420
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
int n,k=0,s[10011]={};
while(1){
memset(s,0,sizeof(s));
cin >> n;
if(n==0){
break;
}
for(int i=0;i<n;i++){
cin >> k;
s[k]++;
k=0;
}
for(int a=0;a<10;a++){
if(s[a]!=0){
for(int i=0;i<s[a];i++){
cout << "*";
}
}else{
cout << "-";
}
cout << "\n";
}
}
return(0);
}


Measured memory_bytes: 3048
s=input()
t=input()
ds={}
dt={}
for i in range(len(s)):
  ts=s[i]
  tt=t[i]
  if ts not in ds:
    ds[ts]=tt
    rs=tt
  else:
    rs=ds[ts]
  if tt not in dt:
    dt[tt]=ts
    rt=ts
  else:
    rt=dt[tt]
  if rs==tt and rt==ts:
    continue
  else:
    print('No')
    break
else:
  print('Yes')

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,k;
  cin >> n >> k;
  ll m = (n-1)*(n-2)/2-k;
  if(m < 0){
    cout << -1;
    return 0;
  }
  cout << n-1+m << '\n';
  for(int i = 1; i < n; ++i) cout << i << ' ' << n << '\n';
  for(int i = 1; i < n; ++i){
    for(int j = i+1; j < n; ++j){
      if(m == 0) return 0;
      cout << i << ' ' << j << '\n';
      --m;
    }
  }
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
city=[]
table={}
table2={}
for i in range(m):
    city.append(list(map(int,input().split())))
    word=str(city[i][0])+str(city[i][1])
    table[i]=word
city.sort()
temp=city[0][0]
count=1
for i in range(m):
    if temp!=city[i][0]:
        temp=city[i][0]
        count=1
    top=str(0)*(6-len(str(city[i][0])))+str(city[i][0])
    bottom=str(0)*(6-len(str(count)))+str(count)
    word=str(city[i][0])+str(city[i][1])
    table2[word]=top+bottom
    count+=1
for i in range(m):
    print(table2[table[i]])



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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
typedef long long ll;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    int N; cin >> N;
    vector<int> a(N+1), b(N);
    rep(i, N+1) cin >> a[i];
    rep(i, N) cin >> b[i];
    ll cnt = 0;
    rep(i, N) {
        cnt += min(a[i], b[i]);
        tie(a[i], b[i]) = make_tuple(a[i] - min(a[i], b[i]), b[i] - min(a[i], b[i]));
        cnt += min(a[i+1], b[i]);
        a[i+1] -= min(a[i+1], b[i]);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    a, b = map(int, readline().split())
    if a>b:
        print(a-1)
    else:
        print(a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9148
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int kotae = 0;
	int mae = getint();
	int i = 1;
	for (; i < N; i++) {
		int tugi = getint();
		if (mae == i) {
			kotae++;
			mae = getint();
			i++;
		}
		else mae = tugi;
	}
	if (i == N && mae == N) kotae++;

	printf("%d", kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s;
  for(char i = 'a'; i <= 'z'; i++){
    if(!count(s.begin(), s.end(), i)){
      cout << i << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 512
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n, ma, mb;
	cin >> n >> ma >> mb;
	Vec a(n), b(n), c(n);
	rep(i, n) cin >> a[i] >> b[i] >> c[i];

	Vec2<ll> dp(500, Vec(500, LINF));
	dp[0][0] = 0;
	rep(k, n) repr(i, 500) repr(j, 500) if(i >= a[k] && j >= b[k]) chmin(dp[i][j], dp[i-a[k]][j-b[k]]+c[k]);

	ll ans = LINF, cnt = 1;
	while(true){
		chmin(ans, dp[ma*cnt][mb*cnt]);
		cnt++;
		if(ma*cnt >= 500 || mb*cnt >= 500) break;
	}
	if(ans != LINF) co(ans);
	else co(-1);

	return 0;
}


Measured memory_bytes: 2176
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)

	n := readInt()
	a := make(map[int]int, n)

	ans := true
	for i := 0; i < n; i++ {
		input := readInt()
		if a[input] > 0 {
			ans = false
		}
		a[input]++
	}
	if ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


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

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

	vector<int> v;
	int num;
	for (int i = 0; i < N; i++) {
		cin >> num;
		v.push_back(num);
	}

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

	int total = 0;

	for (int i = 0; i < K; i++) {
		total += v.back();
		v.erase(v.end() - 1);
	}

	cout << total << endl;

	return 0;

}

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

using namespace std;
typedef long long ll;

struct edge {
    int to;
    ll cost;
};

struct status {
    ll cost;
    int v;

    bool operator<(const status &another) const { return cost < another.cost; };

    bool operator>(const status &another) const { return cost > another.cost; };
};

const ll INF = 1145141919810364364;

ll dijkstra(int n, vector<vector<edge>> &graph) {
    priority_queue<status, vector<status>, greater<>> que;
    vector<ll> dis(n, INF);
    dis[0] = 0;
    que.push({0, 0});

    while (!que.empty()) {
        status now = que.top();
        que.pop();

        if (dis[now.v] < now.cost)continue;

        for (auto next:graph[now.v]) {
            if (dis[next.to] > dis[now.v] + next.cost) {
                dis[next.to] = dis[now.v] + next.cost;
                que.push({dis[next.to], next.to});
            }
        }
    }

    return dis[n - 1];
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<edge>> graph(n);
    for (int i = 1; i < n; i++)graph[i].push_back({i - 1, 0});

    for (int i = 0; i < m; i++) {
        int l, r, c;
        cin >> l >> r >> c;
        graph[l - 1].push_back({r - 1, c});
    }

    ll ret = dijkstra(n, graph);
    cout << (ret == INF ? -1 : ret) << endl;
    return 0;
}

Measured memory_bytes: 10104
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    ll n;
    cin >> n;
    ll a[n];
    map<ll,ll> mp;
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
        mp[a[i]]++;
    }
    ll sum = 0;
    auto itr = mp.begin();
    while(itr != mp.end())
    {
        sum += itr -> second * ((itr -> second) - 1) / 2;
        itr++;
    }
    for(int i = 0;i < n;i++)
    {
        ll key = a[i];
        ll a = mp[key] * (mp[key] - 1) / 2;
        ll b = (mp[key] - 1) * (mp[key] - 2) / 2;
        cout << sum - a + b << "\n";
    }

    return 0;
}

Measured memory_bytes: 11008
//21171_somesh || asomesh999

#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define io ios::sync_with_stdio(false);cin.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
long int mod=1000000007;

int main()
{
	io
	#ifdef CODE
		clock_t startTime = clock();
		freopen("input.txt","r",stdin);
	#endif

	string s;
	cin >> s;
	set<char> st;
	fr(i,0, 3) {
		st.insert(s[i]);
	}
	if (st.size() == 2) {
		cout << "Yes";
	} else {
		cout << "No";
	}

	#ifdef CODE
		cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
	#endif
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int arr[100005];
int dp[3005][3005];
int anss  = 0 ;
char rep[100005];
int c=0;
string str1,str2;
int lcs(int first,int last)
    {
        if(first<=0|last<=0)
            {
                return 0;
            }
        if(dp[first][last]!=-1)
            return dp[first][last];
        if(str1[first]==str2[last]&&(first!=str1.size()&&last!=str2.size()))
        {
            dp[first][last]=1+lcs(first-1,last-1);
            //anss = max(anss,dp[first][last]);
 
        }
        else
            {
            dp[first][last] = max(dp[first][last],max(lcs(first-1,last),lcs(first,last-1)));
            }
        return dp[first][last];
 
    }
void printstring()
    {
        int i = str1.size();
        int j = str2.size();
        //int idx = anss;
        int idx=lcs(str1.size()-1,str2.size()-1);
        char str[idx+1];
        str[idx+1]='\0';
        while(i>0&&j>0)
        {
            if(str1[i]==str2[j])
            {
                str[idx]= str1[i];
                idx--;
                i--;
                j--;
            }
            else if(dp[i-1][j]>dp[i][j-1])
            {
                i--;
            }
            else
                j--;
        }
        cout<<str<<endl;
    }
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    for(int i=0;i<3006;i++)
        for(int j=0;j<3006;j++)
            dp[i][j]=-1;
    cin>>str1>>str2;
    str1="X"+str1;
    str2="Y"+str2;
    string ans="";
    int n = min(str2.size(),str1.size());
    int n1 = max(str2.size(),str1.size());
    //lcs(str1.size()-1,str2.size()-1);
    printstring();
 
}
 

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

int main() {
	string O, E;
	cin >> O >> E;
	for(int i=0; i<E.size(); i++)
	   cout << O[i] << E[i];
	if(O.size() != E.size())
	   cout << O.back() << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

void sort(int *a);

int main(void)
{
	int n,k;
	int i,j;
	char tmp[11];
	int cnt[26] = {0};
	int result= 0;
	
	scanf("%d %d\n", &n, &k);
	
	for(i = 0; i < n; i++){
		scanf("%s", tmp);
		cnt[tmp[0]-'A']++;
	}
	
	while(1){
		sort(cnt);
		for(i = 0; i < k;i++){
			cnt[i]--;
			if(cnt[i] < 0){
				printf("%d\n", result);
				return 0;
			}
		}
		result++;
	}
	
}

void sort(int *a){
	int i,j;
	int tmp;
	int max,num;
	
	for(i = 0; i < 26; i++){
			max= 0;
			num = i;
		for(j = i; j < 26; j++){
			if(a[j]>max){
				num = j;
				max = a[j];
			}
		}
		tmp = a[num];
		a[num] = a[i];
		a[i] = tmp;
	}
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int tbl1[1000000],tbl2[1000000];
int main(){
  int n = 1000000;
  int c = 0;
  for(int i=1;i<n;++i) tbl1[i]=tbl2[i]=i;
  for(int i=2;;++i){
    int t = i*(i+1)*(i+2)/6;
    if(t>=n) break;
    for(int j=0;j+t<n;++j){
      if(t%2) tbl2[j+t]=min(tbl2[j+t],tbl2[j]+1);
      tbl1[j+t]=min(tbl1[j+t],tbl1[j]+1);
    }
  }
  while(cin>>n,n)
    cout << tbl1[n] << " " << tbl2[n] << endl;
  return 0;
}

Measured memory_bytes: 8972
#include <stdio.h>
#include <stdlib.h>
int cmpint(const void *x, const void *y) { return *(int *)y - *(int *)x; }
int main() {
	int n, k, l[50], sum = 0;
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &l[i]);
	}
	qsort(l, n, sizeof(int), cmpint);
	for (int i = 0; i < k; i++) {
		sum += l[i];
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int sum = 0;
        int p_max = 0;
        for(int i = 1; 1<=i && i<=N; i++) {
            int pi = sc.nextInt();
            sum += pi;
            if(p_max < pi) {
                p_max = pi;
            }
        }
        System.out.println(sum - p_max/2);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
using namespace std;
const int MOD = 1000000007; 
typedef long long ll;
typedef string str;
 
int main(){
  int n,m;
  scanf("%d%d",&n,&m);
  printf("%d",(n - 1) * (m - 1));
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define Rep(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define Repr(i, b, e) for(int (i) = (b) - 1; (i) >= (e); --(i))
#define Print(x) cout << (x) << endl 
#define Min2(a, b) ((a) < (b)) ? (a) : (b)
#define Max2(a, b) ((a) > (b)) ? (a) : (b)

typedef long long ll;

using namespace std;

int main(){
    int A, B, ans = 0;
    cin >> A >> B;
    Rep(i, 0, 2){
        if(A < B){
            ans += B;
            B--;
        }else{
            ans += A;
            A--;
        }
    }
    Print(ans);
    return 0;
}

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

typedef long long ll;

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

// chmax, chmin
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 (a > b) { a = b; return 1; } return 0; }

int main() {
    int N, Y;
    cin >> N >> Y;
    
    int num = Y / 1000;
    
    int a,b,c;
    bool exist = false;
    for ( int ten = 0; ten <= num; ++ten){
        int rest = num - 10 * ten;
        int restnum = rest / 5;
        for ( int five = 0; five <= restnum; ++five){
            int rest2 = rest - 5 * five;
            int all = ten + five + rest2;
            if ( all == N ) {
                a = ten; b = five; c = rest2;
                exist = true;
                goto OUT;
            }
        }
    }
    OUT:
    
    if ( exist ){
        cout << a << " " << b << " " << c << endl;
    } else {
        cout << "-1 -1 -1 " << endl;
    }
    
    
    
    
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
typedef long long ll;
 
int main() {
  ll a,b;cin>>a>>b;
  cout<<(a==b ? a*2:2*max(a,b)-1);
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp(a,b) make_pair(a,b)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

int main(){
	ll N; cin>>N;
	ll d4=0,d2=0;
	rep(i,N){
		ll a; cin>>a;
		if(a%4==0) d4++;
		else if(a%2==0) d2++;
	}
	if(2*d4+1>=N) cout<<"Yes";
	else if(2*d4+d2>=N) cout<<"Yes";
	else cout<<"No";    
}

Measured memory_bytes: 256
import math

def is_prime(x):
    if x < 2: return False  # 2未満に素数はない
    if x == 2 or x == 3 or x == 5: return True  # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False  # 2,3,5の倍数は合成数
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False
        prime += step
        step = 6 - step
    return True

def main():
    X = int(input())
    while 1:
        if is_prime(X):
            print(X)
            break
        X += 1


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
#define clr(a) memset(a,0,sizeof(a))
#define umap unordered_map
#define uset unordered_set
#define fr first
#define sc second
#define pb push_back
#define M int(1e9+7)


using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;


int main(){
	fast_io; cout_precision;
	int n;	cin >> n;
	double arr[n];	for(int i=0; i<n; i++)	cin >> arr[i];
	double ans=0;
	for(int i=0; i<n; i++){
		ans+=(1/arr[i]);
	}
	ans=1/ans;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256