akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int dataset = scanner.nextInt();
		for(int i=0; i<dataset; i++){
			double xa = scanner.nextDouble();
			double ya = scanner.nextDouble();
			double ra = scanner.nextDouble();
			double xb = scanner.nextDouble();
			double yb = scanner.nextDouble();
			double rb = scanner.nextDouble();
			
			double dist = Math.sqrt(Math.pow(xa-xb, 2) + Math.pow(ya-yb, 2));
			double bigr = (ra >= rb) ? ra : rb;
			double smallr = (ra >= rb) ? rb : ra;
			
			if( dist > (ra + rb) ){
				System.out.println("0");
			}else{
				if(dist < (bigr - smallr)){
					if(ra>rb){
						System.out.println("2");
					}else{
						System.out.println("-2");
					}
				}else{
					System.out.println("1");
				}
			}
			

		}
		
	}
}

Measured memory_bytes: 20520
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int k = saori.saori_hayami();
		final String[] ans = Integer.toString(n, k).split("");
		System.out.println(ans.length);
		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 20180
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
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,k;
    cin >> n >> k;
    ll ans = 0;
    ll s = n/k;
    ans+=pow(s,3);
    if(k%2==1){
        cout << ans << endl;
        return 0;
    }
    if(n-s*k>=k/2){
        ans+=pow(s+1,3);
    }
    else{
        ans+=pow(s,3);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,m,ans,a[N],b[N];
char s[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	int a=read(),b=read(),c=read();
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c;
	return 0;
}

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

int main() {
	int n, sum = 0;
	cin >> n;
	int t = n;
	while (t != 0) {
		sum += t % 10;
		t /= 10;
	}
	if (n%sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int L=max(A,C);
  int R=min(B,D);
  if(L<=R)cout<<R-L<<endl;
  else cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <queue>
#include <vector>
#include <set>


using namespace std;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

template<class T> inline bool chmin(T& a, T b) {
  //aの方が大きければ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;
}
bool compare_a_big(pair<int,int> l,pair<int,int> r){
  //firstが大きい方からソート、firstが同じならbが小さい方から
  if(l.first != r.first){
    return l.first>r.first;
  }
  else{
    return l.second < r.second;
  }
}
bool compare_a_b_big(pair<int,int> l,pair<int,int> r){
  //firstが大きい方からソート、firstが同じならbが大きい方から
  if(l.first != r.first){
    return l.first>r.first;
  }
  else{
    return l.second > r.second;
  }
}
bool compare_b_small(pair<int,int> l,pair<int,int> r){
  //secondが小さい方からソート、firstが同じならfirstが小さい方から
  if(l.second != r.second){
    return l.second<r.second;
  }
  else{
    return l.first < r.first;
  }
}
const int INF = 1e9;
const int M = 1000000007;


typedef long long int ll;
vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算、a,b<=300000でないと使えない
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}



int main(){
  int h,m;
  cin>> h>>m;

  cout << (h/m)+((h%m)!=0) << endl;




}


Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
int main() {
	int n = 0, ans = 0,max = 0;
	char str[100] = {};
	std::cin >> n;
	for (int i = 0; i < n; i++) { std::cin >> str[i]; }
	for (int i = 0; i < n; i++) {
		if (str[i] == 'I') { ans++; }
		else if (str[i] == 'D') { ans--; }
		max = std::max(max, ans);
	}
	std::cout << max << std::endl;
}

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

int main() {
    int a,b;
    cin>>a>>b;
    if(a>=b){
        for(int i=0;i<a;i++){
            cout<<b;
        }
        cout<<endl;
    }else {
        for (int i = 0; i < b; i++) {
            cout << a ;
        }
        cout<<endl;
    }

}


Measured memory_bytes: 256
import scala.io.StdIn.readInt

object Main {
  def round(n:Double) = {
    val m = n % 1000
    if(m>0) n-m+1000 else n
  }

  def getDebt(n:Int,m:Double):Int = if(n==0) m.toInt else getDebt(n-1,round(m*1.05))

  def main(args:Array[String]) = println(getDebt(readInt,100000))
}

Measured memory_bytes: 43228
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

int T,minimum,sleep[30],N,last_day,last_time,dp[101][30],pre_day,sche[101];

int main(){

	int tmp_day,tmp_time;

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

		for(int i = 0; i < T; i++)scanf("%d",&sleep[i]);

		scanf("%d",&N);

		for(int i = 0; i <= 100; i++)sche[i] = 0;

		for(int i = 1; i <= N; i++){
			scanf("%d %d",&tmp_day,&tmp_time);
			if(sche[tmp_day] != 0){
				sche[tmp_day] = min(sche[tmp_day],tmp_time);
			}else{
				sche[tmp_day] = tmp_time;
			}
		}

		for(int i = 0; i <= 100; i++){
			for(int k = 0; k < T; k++)dp[i][k] = BIG_NUM;
		}

		dp[1][0] = 0;

		for(int day = 2; day <= 100; day++){
			for(int cicle = 0; cicle < T; cicle++){
				if(dp[day-1][cicle] == BIG_NUM)continue;

				if(sche[day] >= sleep[(cicle+1)%T] || sche[day] == 0){
					dp[day][(cicle+1)%T] = min(dp[day][(cicle+1)%T],dp[day-1][cicle]);
					dp[day][0] = min(dp[day][0],dp[day-1][cicle]+1);
				}else{
					dp[day][0] = min(dp[day][0],dp[day-1][cicle]+1);
				}
			}
		}

		minimum = 200;
		for(int i = 0; i < T; i++){
			minimum = min(minimum,dp[100][i]);
		}

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

	return 0;
}

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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int n, T;
pair<int, int> shop[200005];

const int INF = 1010101010;
int dp[200005][32]; // consider shops 1..i, chose j, minimum time?

bool comparator(pair<int, int> s, pair<int, int> t){
	return 1LL * s.first * (1 + t.second) > 1LL * t.first * (1 + s.second);
}

int main(){
	scanf("%d %d", &n, &T);
	for(int i = 1; i <= n; i++){
		scanf("%d %d", &shop[i].first, &shop[i].second);
	}
	sort(shop + 1, shop + n + 1, comparator);
	
	dp[0][0] = 0;
	for(int i = 1; i <= 30; i++){
		dp[0][i] = INF;
	}
	
	int final = n + 1;
	
	for(int i = 1; i <= n; i++){
		if(shop[i].first == 0){
			final = i;
			break;
		}
		for(int j = 0; j <= 30; j++){
			dp[i][j] = INF;
		}
		for(int j = 0; j <= 30; j++){
			// shop or not shop, simple choice
			// shop
			long long next_time = 1LL * (dp[i - 1][j] + 1) * (shop[i].first + 1) + shop[i].second;
			if(next_time <= T){
				dp[i][j + 1] = next_time;
			}
			// not shop
			dp[i][j] = min(dp[i][j], dp[i - 1][j]);
		}
	}
	
	// consider doing some final shopping, in ascending order of time, of course
	sort(shop + final, shop + n + 1);
	int ans = 0;
	for(int j = 0; j <= 30; j++){
		int cur_time = dp[final - 1][j];
		int cur_ans = j;
		int index = final;
		if(cur_time > T){
			continue;
		}
		while(index <= n && cur_time + 1 + shop[index].second <= T){
			cur_ans++;
			cur_time += 1 + shop[index].second;
			index++;
		}
		ans = max(ans, cur_ans);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 26752
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

int main(){
    int N, X;
    cin >> N >> X;
    vector<int> M(N);
    for(int i = 0; i < N; i++) cin >> M[i];
    sort(all(M));
    int sum = 0;
    for(int i = 0; i < N; i++) sum += M[i];
    int ans = N + (X - sum) / M[0];
    cout << ans << endl;
}


Measured memory_bytes: 3632
n = int(input())
A = [int(i) for i in input().split()]

count = 0
for i in range(0, len(A)-1):
    for j in range(len(A)-1, i, -1):
        if A[j-1]>A[j]:
            A[j-1], A[j] = A[j], A[j-1]
            count += 1

print(*A)
print(count)



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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
string S, T,U;
	int A, B;
	cin >> S >> T >> A >> B >> U;
	if (S==U) {
		doublece(A-1,B)
	}
	else {
		doublece(A , B-1)
	}

    return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string.h>
#include <string>
#include <complex>
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i = 0; i < n; ++i)
#define Rep(i,n) for(int i = 1; i <= n; ++i)
#define lowbit(x) ((x)&(-x))
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#define eps 1e-8
#define sqr(x) ((x)*(x))
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef complex<double>cp;
template<class T>inline void rread(T&num){
    num=0;T f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
    num*=f;
}
const ll inf = 1e18;
const int maxn = 2e5+10, mod = 1e9 + 7;
const int mod1 = 1e8+7,mod2 = 41;
const double pi = acos(-1);
ll gcd (ll a, ll b)
{return ( a ? gcd(b%a, a) : b );}
void exgcd(ll a,ll b,ll &d,ll& x,ll& y)
{
    if(!b){d=a;x=1;y=0;}
    else {exgcd(b,a%b,d,y,x);y-=x*(a/b);}
}
cp power(cp a, int n)
{cp p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
unsigned long long power(unsigned long long a, unsigned long long n)
{unsigned long long p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n)
{ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod)
{ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
//head
int n,m;
int a[32000];
int main()
{
    int kase=1;
    //freopen("data2.out","r",stdin);
    //freopen("ans2.out","w",stdout);


   while(cin>>n>>m)
   {
       m/=1000;
       int f = 0;
       for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++)
       {
           int s = i*10+j*5;
           if(n-i-j>=0&&n-i-j==m-s)
           {
               f =1;
               cout<<i<<" "<<j<<" "<<n-i-j<<endl;
               break;
           }
       }
       if(f==1)
        break;
       }
       if(f==0)
        cout<<-1<<" "<<-1<<" "<<-1<<endl;

   }

    return 0;
}


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

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

  vector<int> c(27);
  long long csum = 0;
  for (int i = 1; i <= 26; i++) {
    cin >> c.at(i);
    csum += c.at(i);
  }

  vector<vector<int>> s(d+1, vector<int>(27));
  for (int i = 1; i <= d; i++) {
    for (int j = 1; j <= 26; j++) {
      cin >> s.at(i).at(j);
    }
  }

  vector<int> last(27, 0);
  long long curc = 0;
  long long satisfy = 0;
  for (int i = 1; i <= d; i++) {
    int t;
    cin >> t;
    curc += csum - (c.at(t) * (i - last.at(t)));
    last.at(t) = i;
    satisfy += s.at(i).at(t) - curc;
    cout << satisfy << endl;
  }

  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, a[26], t[26];
    cin >> n;
    for (int i = 0; i < 26; i++) t[i] = 0;
    string s[n];
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
        for (int j = 0; j < 26; j++) a[j] = 0;
        for (int j = 0; j < s[i].length(); j++)
            a[int(s[i][j]) - 97]++;
        for (int j = 0; j < 26; j++)
        {
            if (i == 0) t[j] = a[j];
            else t[j] = min(t[j], a[j]);
        }
    }
    for (int i = 0; i < 26; i++)
    {
        if (t[i] > 0)
            for (int j = 0; j < t[i]; j++) cout << char(i + 97);
    }
}

Measured memory_bytes: 3628
from sys import exit
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()
ul = 1
dl = H
rl = W
ll = 1
for s, t in zip(S[1::][::-1], T[:-1:][::-1]):
    if s == 'U':
        ul += 1
    elif s == 'D':
        dl -= 1
    elif s == 'L':
        ll += 1
    else:
        rl -= 1
    if ul > dl or ll > rl or ul == H + 1 or dl == 0 or ll == W + 1 or rl == 0:
        print('NO')
        exit()
    if t == 'U':
        dl = min(H, dl+1)
    elif t == 'D':
        ul = max(1, ul-1)
    elif t == 'L':
        rl = min(W, rl+1)
    else:
        ll = max(1, ll-1)
s = S[0]
if s == 'U':
    ul += 1
elif s == 'D':
    dl -= 1
elif s == 'L':
    ll += 1
else:
    rl -= 1

if ul <= sr <= dl and ll <= sc <= rl:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 51212
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 
#define sqrt(d) pow((long double) (d), 0.50)

const ll INF = 2e9;
const ll large_P = 1e9 + 7;


int main(){
  int X, A, B;
  cin >> X >> A >> B;
  X -= A;
  X %= B;
  cout << X;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int A[2000000];
int B[2000000];
int C[10001];

void CountingSort(int n,int k)
{
	for (int i = 0; i < 10001; i++)
	{
		C[i] = 0;
	}

	for (int i = 0; i < n; i++)
	{
		C[A[i]]++;
	}

	for (int i = 1; i < k; i++)
	{
		C[i] += C[i - 1];
	}

	for (int i = n - 1; i >= 0; i--)
	{
		B[C[A[i]] - 1] = A[i];
		C[A[i]]--;
	}
}

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

	for (int i = 0; i < N; i++)
	{
		scanf("%d", &A[i]);
	}

	CountingSort(N, 10000);

	printf("%d", B[0]);
	for (int i = 1; i < N; i++)
	{
		printf(" %d", B[i]);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 18852
import java.util.Scanner;

//提出時にclass Main に書き換え
public class Main {
	public static void main(String[] args)  {
		// 標準入力を受け取る
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine(); // String Sを受け取る
		sc.close(); // 標準入力を終了

		// 操作で追加できる文字列
		String[] t = {"dream", "dreamer", "erase", "eraser"};
		String[] rt = new String[4];

		// Sを反転
		String rs = new StringBuffer(S).reverse().toString();

		// tを反転
		for(int i = 0; i < t.length; i++) {
			rt[i] = new StringBuffer(t[i]).reverse().toString();
		}


		boolean can = true; // 可能フラグ
	    boolean dis = false; // 発見フラグ

		while(rs.length() > 0 && can) {
			for(int i = 0; i < rt.length; i++) {
				// rsがrt中の文字列で始まるか調査
				if(rs.startsWith(rt[i])) {
					// 見つかった分の文字列を切り取る
					rs = rs.substring(rt[i].length());
					dis = true;
					break; // for処理中断
				}
			}
			// 発見フラグがtrueで無ければ、可能フラグをfalseに
			if(!dis) {
				can = false;
			} else {
				dis = false;
			}
		}

		// 可能フラグがtrueならYESを出力
		if(can) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

}

Measured memory_bytes: 57004
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define V vector
#define pb push_back
#define mkp make_pair
#define pi pair<int,int>//struct pi {int fi,se;};
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define ln length()
#define sz size()
const int N=100005;
///////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

int32_t main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    // int t;cin>>t;while(t--)
    {
        int i,j,k,n,m,a,b,c,ans=0,cnt=0,sum=0;
        cin>>a>>b>>c>>k;
        if(b <= a){
            while(b <= a){
                b *= 2;
                k--;
            }
        }
        if(c <= b){
            while(c <= b){
                c *= 2;
                k--;
            }
        }
        if(k >= 0){
            cout << "Yes"<<endl;
        }else{
            cout << "No"<<endl;
        }
    }
}

Measured memory_bytes: 3636
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    sosu=[false for i in 1:10^5]
    sosu[2]=true
    for i in 3:10^5
        res=true
        for j in 2:sqrt(i)+1
            if i%j==0
                res=false
                break
            end
        end
        sosu[i]=res
    end
    cnt=[0 for i in 1:10^5]
    for i in 3:10^5
        cnt[i]=cnt[i-1]
        if i%2==1 && sosu[i] && sosu[div(i+1,2)]
            cnt[i]+=1
        end
    end
    q=parseInt(readline())
    for i in 1:q
        l,r=parseMap(split(readline()))
        println(cnt[r]-cnt[max(1,l-1)])
    end
end
main()

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

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define FILE "parade"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const ull ULLINF = numeric_limits<ull>::max();
const double PI = acos(-1.0);

int main()
{
//    freopen(FILE".in", "r", stdin);
//    freopen(FILE".out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    set<int> d;
    for(int i = 0; i < k; i++)
    {
        int a;
        cin >> a;
        d.insert(a);
    }
    for(int i = n; ; i++)
    {
        int f = i;
        bool good = 1;
        while(f)
        {
            if(d.find(f % 10) != d.end())
            {
                good = 0;
                break;
            }
            f /= 10;
        }
        if(good)
        {
            cout << i;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
//ALDS1_11_C
#include <iostream>
#include <vector>
#define  N     1000
using namespace std;

void BFS(vector<vector<int> > A, vector<int> &d, vector<int> &visit, int v){
	if(v == 0){
		d[0] = 0;
		visit[0] = 1;
	}

	for(int i=0;i<A[v].size();i++){
		if((A[v][i] == 1) && (d[i] > d[v]+1)){
			d[i] = d[v]+1;
			visit[i] = 1;
			BFS(A, d, visit, i);
		}
	}	
}

int main(){
	int n, u, k;
	vector<vector<int> > A;
	vector<int> d, visit;

	cin>>n;
	A.resize(n);
	for(int i=0;i<n;i++){
		A[i].resize(n);
		d.push_back(N);
		visit.push_back(0);
	}

	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			A[i][j] = 0;

	for(int i=0;i<n;i++){
		cin>>u>>k;
		int v;
		
		for(int j=0;j<k;j++){
			cin>>v;
			A[u-1][v-1] = 1;
		}
	}

	BFS(A, d, visit, 0);
	for(int i=0;i<n;i++)
		if(visit[i] == 0)
			d[i] = -1;

	for(int i=0;i<n;i++)
		cout<<i+1<<" "<<d[i]<<endl;

	return 0;
}

Measured memory_bytes: 5512
/*

*/
#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int k;cin>>k;
  string s;cin>>s;
  if(s.size()<=k){
    cout<<s<<endl;
  }else{
    cout<<s.substr(0,k)<<"..."<<endl;
  }
}


Measured memory_bytes: 3616
# -*- coding: utf-8 -*-
N = int(input())

A = list(map(int, input().split()))

i=0
gcd=2
while(True):
    flag=False
    for Ai in A:
        if Ai % gcd != 0:
            flag=True
            break
    if flag:
        break
    else:
        gcd *= 2
        i+=1

print(i)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;

int main(int argc, const char * argv[]) {

    int k;
    string s;
    
    cin >> k;
    cin >> s;
    
    if(s.length() <= k)
    {
        cout << s << endl;
    } else {
        for(int i=0; i<k; i++)
        {
            cout << s[i];
        }
        cout << "..." << endl;
    }

    return 0;
    
    
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))

// #undef LOCAL
#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef pair<int, int> P;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

struct T
{
  int a;
  int b;
  T(int _a, int _b)
    : a(_a)
    , b(_b)
  {}
  // default compare function for sort
  bool operator<(const T& a) const
  {
    // compare val
    return b < a.b;
  }
  friend ostream& operator<<(ostream& os, const T& a)
  {
    os << a.a << ':' << a.b;
    return os;
  }
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  int N, K;
  cin >> N >> K;
  vector<ll> comb(N + 1);
  for (ll i = 2; i <= N; i++) {
    comb[i] = (i - 1) * (i - 2) / 2;
  }
  dumpv(comb);
  if (comb[N] < K) {
    cout << -1 << endl;
    return 0;
  }
  int n1 = N;
  int n2 = comb[N] - K;
  dump(n1, n2);
  cout << n1 - 1 + n2 << endl;
  for (int i = 2; i <= n1; i++) {
    cout << "1 " << i << endl;
  }
  if (n2 == 0) {
    return 0;
  }
  for (int i = 2; i < N; i++) {
    for (int j = i + 1; j <= N; j++) {
      cout << i << " " << j << endl;
      n2--;
      if (n2 == 0)
        return 0;
    }
  }
  return 0;
}

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

using namespace std;
#define ll long long 
#define INF  (-1000000005)

int n;
int f[105][12];
ll p[105][13];
int c[105];

int main(void){
	cin >> n;
	for(int i=1;i<=n;i++) for(int j=0;j<10;j++) cin >> f[i][j];

	for(int i=1;i<=n;i++) for(int k=0;k<=10;k++)cin >> p[i][k];


	ll ans = INF;
	for(int k=1;k<1024;k++){

		//calc all c
		for(int i=1;i<=n;i++) {
			c[i] = 0;
			for(int j = 0; j < 10; j++)
			{
				int tmp = (k >> j) % 2;
				if (tmp == 1 && f[i][j] == 1)
				{
					c[i]++;
				}
			}
		}
		

		//calc cost
		ll cost = 0;
		for(int i=1;i<=n;i++){
			//cout << c[i]<<" ";
			//if(c[i]>10) return 0;
			cost+=p[i][c[i]];
			
		}

		//update
		if(ans<cost) ans=cost;
	}

	cout << ans;

	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0 ; i < n ;i++){
        cin >> h[i];
    }
    int tmp = h[0];
    bool flag = true;
    for(int i = 1 ; i < n ;i++){
        if(tmp < h[i]){
            tmp = h[i]-1;
            h[i]--;
        }

        if(h[i-1] > h[i]){
            flag = false;
            break;
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt(), nabeatsu;

        for (int i=3; i<=n; i++) {
            nabeatsu = i;
            if (nabeatsu % 3 == 0) {
                System.out.print(" " + i);
                continue;
            }
            while (nabeatsu != 0) {
                if (nabeatsu % 10 == 3) {
                    System.out.print(" " + i);
                    break;
                }
                nabeatsu /= 10;
            }
        }
        System.out.println();
    }
}

Measured memory_bytes: 28784
#include<bits/stdc++.h>
using namespace std;
inline int read(){
    register int x=0;
    register char ch=getchar();
    while(ch<'0'||ch>'9')   ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x;
}
const int N=2e5+5;
int n,m,now,a[N],b[N],v[N],fa[N],id[N],vi[N],nex[N],head[N];
void addedges(int x,int y){
    nex[++now]=head[x];
    head[x]=now,v[now]=y;
}
vector<int>d[N];
long long f[N],s[N];
bool com(int x,int y){
    return a[x]<a[y];
}
int find(int x){
    return fa[x]?fa[x]=find(fa[x]):x;
}
void dfs(int x){
    int si=d[x].size();
    for(int i=0;i<si;i++){
        int v=d[x][i];
        dfs(v),s[x]+=s[v];
    }
    s[x]+=b[x],f[x]=s[x]+a[x];
    for(int i=0;i<si;i++){
        int v=d[x][i];
        f[x]=min(f[x],s[x]-s[v]+max(f[v],1LL*a[x]));
    }
}
int main(){
    //freopen("1.out","w",stdout);
    //freopen("1.in","r",stdin);
    n=read(),m=read();
    for(int i=1;i<=n;i++)   a[i]=read(),b[i]=read(),a[i]=max(a[i]-b[i],0);
    for(int i=1;i<=m;i++){
        int x=read(),y=read();
        addedges(x,y),addedges(y,x);
    }
    for(int i=1;i<=n;i++)   id[i]=i;
    sort(id+1,id+n+1,com);
    for(int i=1;i<=n;i++){
        int x=id[i];    vi[x]=1;
        for(int j=head[x];j;j=nex[j])
            if(vi[v[j]]){
                int y=find(v[j]);
                if(y==x)    continue;
                d[x].push_back(y),fa[y]=x;
            }
    }
    dfs(id[n]);
    printf("%lld\n",f[id[n]]);
    return 0;
}

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

bool* to_binary(int, int);

int main(){
    int n, m;
    cin >> n >> m;
    int *k = new int[m];
    int **s = new int*[m];
    for(int i = 0; i < m; i++){
        cin >> k[i];
        s[i] = new int[k[i]];
        for(int j = 0; j < k[i]; j++) cin >> s[i][j];
    }
    int *p = new int[m];
    for(int i = 0; i < m; i++) cin >> p[i];
    int combination_sum = 0;
    for(int i = 0; i < pow(2, n); i++){ // スイッチ
        bool is_ok = true;
        bool *binary = to_binary(i, n);
        
        for(int j = 0; j < m; j++){ // 電球
            int sum = 0;
            for(int l = 0; l < k[j]; l++) sum += (int)binary[s[j][l] - 1];
            if(sum % 2 != p[j]){
                is_ok = false;
                break;
            }
        }
        combination_sum += (int)is_ok;
    }
    cout << combination_sum << endl;
    
    return 0;
}

bool* to_binary(int num, int digit){
    bool *result = new bool[digit];
    for(int i = 0; i < digit; i++){
        result[i] = (bool)(num % 2);
        num /= 2;
    }
    return result;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long double A, V, B, W, T;
  cin >> A >> V >> B >> W >> T;
  if (V <= W) {
    puts("NO");
    return 0;
  }
  long double get = (abs(B-A)/(V-W));
  if (get < 0) {
    puts("NO");
  } else {
    puts(get <= T ? "YES" : "NO");
  }
  return 0;
}

Measured memory_bytes: 3780
#include <fstream>
#include <iostream>

// BE CAREFUL WITH HASH TABLE & UNORDERED MAP
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define MOD 998244353
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= (a); i--)
#define RF0(i,b) RFO(i,0,b)
#define ll long long
#define pii pair<int,int>
#define add(a,b,m) ((int) (((ll) (a) + (b))%(m)))
#define mul(a,b,m) ((int) (((ll) (a) * (b))%(m)))
#define PB emplace_back

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

int N, P;
ll ans = 0;
string S;
int ct [10001] = {0};

// Helper Functions

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> P >> S;
    if (P == 2 || P == 5) {
        ll cur = 0;
        RF0(i,N) {
            cur += ((S[i]-'0')%P == 0);
            ans += cur;
        }
        cout << ans << '\n';
        return 0;
    }
    ct[0]++;
    int md = 0;
    int pw = 1;
    RF0(i,N) {
        md = add(md, mul(S[i]-'0',pw,P),P);
        ans += ct[md];
        ct[md]++;
        pw = mul(pw, 10,P);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define COUT(x) cout << (x) << endl
#define VIEW(x) do{cout << "--" << #x << "--" << endl; view(x);}while(0)
template<typename T> void view(T e){COUT(e);}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#define _GLIBCXX_DEBUG

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

  if (a <= x && x - a <= b)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n;
ll x[101];
int main() {
    cin>>n;
    REP(i, 0, n) cin>>x[i];

    ll ans=inf;
    REP(i, 1, 101){
        ll hp=0;
        REP(j, 0, n){
            hp+=(x[j]-i)*(x[j]-i);
        }
        ans=min(ans, hp);
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;
#define MOD1 1000000007
#define MOD2 1000000009
#define fr(a,b) for(ll i=a;i<b;i++)
#define end "\n"


int32_t main(){
#ifdef _MSC_VER
    _CRT_SECURE_NO_WARNINGS
#endif
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
#pragma warning(suppress: 4101) srand(time(nullptr));
    cout << setprecision(20) << fixed;
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll st=min(k,x/d);
    k-=st;
    x-=st*d;
    if(k%2==0)
        cout<<x<<endl;
    else
        cout<<d-x<<endl;
    return 0;
}

Measured memory_bytes: 3620
import sys

def trick_or_treat(in_):
    n, k = map(int, in_.readline().split())
    
    snacks = set()
    for _ in range(k):
        d = int(in_.readline())
        snacks.update(map(int, in_.readline().split()))

    snaks = frozenset(range(1, n + 1))
    no_snacks = snaks - snacks
    return len(no_snacks)


def main():
    answer = trick_or_treat(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9252
import numpy as np

n,m=map(int,input().split())
a=[]
k=[]
for _ in range(n):
    b=list(map(int,input().split()))
    k.append(b[0])
    a.append(b[1:])
#print(k)
#print(a[1][0])

c=np.zeros(m)
for i in range(n):
    for j in range(k[i]):
        d=a[i][j]
#        print(d)
        c[d-1]+=1

ans=0
for i in range(m):
    if c[i]==n:
        ans+=1
print(ans)


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

using namespace std;
typedef long long ll;
#define DBG(v) cerr << #v << " = " << (v) << endl;

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

    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    for (int &x:a)
        cin >> x;
    for (int &x:b)
        cin >> x;

    const int mod = (int) 1e9 + 7;
    vector<vector<ll>> dp(n + 1, vector<ll>(m + 1));
    for (int i = n; i >= 0; --i)
        for (int j = m; j >= 0; --j) {
            ll &res = dp[i][j] = 0;
            if (i == n || j == m)
                res = 1;
            else {
                if (a[i] == b[j])
                    res += dp[i + 1][j + 1];
                res += dp[i + 1][j] + dp[i][j + 1] - dp[i + 1][j + 1];
                res %= mod;
            }
        }
    cout << (dp[0][0]%mod+mod)%mod;

    return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  int64_t color = (int64_t)k;
  if(n != 1) {
    for(int i = 1; i < n; i++) color *= (k - 1);
  }
  cout << color;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll N,W;
ll w[110],v[110];
vector<ll> v1[4];
ll num[4]={};
int main(){
	cin>>N>>W;
	REP(i,N){
		cin>>w[i]>>v[i];
		v1[w[i]-w[0]].push_back(v[i]);
		num[w[i]-w[0]]++;
	}
	REP(i,4)sort(v1[i].begin(),v1[i].end(),greater<ll>());
	ll dp[num[0]+1][num[1]+1][num[2]+1][num[3]+1];
	REP(i,num[0]+1)
		REP(j,num[1]+1)
			REP(k,num[2]+1)
				REP(l,num[3]+1)
				dp[i][j][k][l]=0;
	FOR(i,1,num[0]+1){
		dp[i][0][0][0]=dp[i-1][0][0][0]+v1[0][i-1];
	}
	REP(i,num[0]+1){
		FOR(j,1,num[1]+1){
			dp[i][j][0][0]=dp[i][j-1][0][0]+v1[1][j-1];
		}
	}
	REP(i,num[0]+1){
		REP(j,num[1]+1){
			FOR(k,1,num[2]+1){
				dp[i][j][k][0]=dp[i][j][k-1][0]+v1[2][k-1];
			}
		}
	}
	REP(i,num[0]+1){
		REP(j,num[1]+1){
			REP(k,num[2]+1){
				FOR(l,1,num[3]+1){
					dp[i][j][k][l]=dp[i][j][k][l-1]+v1[3][l-1];
				}
			}
		}
	}
	ll ans=0;
	REP(i,num[0]+1){
		REP(j,num[1]+1){
			REP(k,num[2]+1){
				REP(l,num[3]+1){
					if(i*w[0]+j*(w[0]+1)+k*(w[0]+2)+l*(w[0]+3)>W)continue;
					ans=max(ans,dp[i][j][k][l]);
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}
	

Measured memory_bytes: 3840
import java.util.*;
import static java.lang.System.*;
import java.io.*;
import java.math.*;

public class Main {
	static long INF = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		long n = sc.nextLong();
		long m = sc.nextLong();
		long ans = 0;
		if ( Math.abs(n - m) < 2) {
			ans = 1;
			for(long i = n; i > 1; i--) 
				ans = (ans * i) % INF;
			for(long i = m; i > 1; i--)
				ans = (ans * i) % INF;
			if(n == m)
				ans = (ans * 2) % INF;
		}
		out.println(ans % INF);
		
		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}

Measured memory_bytes: 23252
#include <iostream>
#include <cstring>
#include <cstdio>
#include <set>
using namespace std;
int n;
set <int> st;
int main(){
#ifdef __APPLE__
	freopen("main.in","r",stdin);
#endif
	scanf(" %d",&n);
	for(int i = 1; i <= n; i++){
		int a; scanf(" %d",&a);
		if(!st.count(a)) st.insert(a);
		else {
			auto it = st.find(a);
			st.erase(it);
		}
	}
	printf("%d\n",st.size());
	return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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

#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
//#define vvector(name,typ,m,n)vector<vector<typ> > name(m,vector<typ> (n))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
ll ceil(ll a,ll b){
    return ((a+b-1)/b);
}
const int INF = 2000000000;
const ll INF64 = 9223372036854775807ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//mapは、if関数などで覗いただけで構成されるので注意しよう！
//std::vector<vector<int>> g;


//std::vector<std::set<int>> g;
int main(){
    int n;
    std::cin >> n;
    VEC(int,a,n);
    int c=0,cc=0,ccc=0;
    rep(i,n){
        if(a[i]%4==0)c++;
        else if(a[i]%2==0)cc++;
        else ccc++;
    }
    if(cc)ccc++;
    if(c+1>=ccc)std::cout << Yes << std::endl;
    else std::cout << No << std::endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int K, N, ans = 0;

		N = Integer.parseInt(sc.next());
		K = Integer.parseInt(sc.next());

		int[] l = new int[N];

		for(int i = 0; i < N; i++){
			l[i] = Integer.parseInt(sc.next());
		}

		for(int i = 0; i < N; i++){
			for(int j = N-1; j > i; j--){
				if(l[j] > l[j-1]){
					int temp = l[j];
					l[j] = l[j-1];
					l[j-1] = temp;
				}
			}
		}

		for(int i = 0; i < K; i++){
			ans += l[i];
		}

		System.out.println(ans);

	}

}

Measured memory_bytes: 21972
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する

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

    ll N;
    cin >> N;

    if(N < 3){
        cout << 1 << endl;
        return 0;
    }
    int k;
    for(k = 1;((1LL << k) - 2) < N; k++){

    }
    cout << k - 1 << endl;

    return 0;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
ll m,n,yy[100005],sum; 

int main()
{
    std::ios::sync_with_stdio(0); std::cin.tie(0);
    cin>>m;
    for(int i=1;i<=m;++i)
    {
    	cin>>yy[i];
    	if(i%2) sum+=yy[i],n-=2*yy[i];
    	else sum-=yy[i],n+=2*yy[i];
	}
	cout<<sum<<" ";
	n+=2*yy[1];
	for(int i=1;i<m;++i)
	{
		sum=sum+n;
		cout<<sum<<" ";
		n=n+2*yy[i]-2*yy[i+1];
		n=-n;
	}
 	return 0;
}

Measured memory_bytes: 4404
//#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
/*#define fast ios_base::sync_with_stdio(0); cin.tie(0)*/
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
const double pi = acos(-1);
typedef long long ll;
int main()
{
	//fast;
	
	ll n,ans;
	cin>>n;
	cout<<n/3;
}

Measured memory_bytes: 3640