akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
 
int main(){
 
    long laggage_num, napzak_weight,laggage_weight,laggage_value;
    long i,j,value;

    scanf("%ld %ld" , &laggage_num, &napzak_weight);
 
    long dP1[napzak_weight + 1], dP2[napzak_weight + 1];

    for (i = 0 ; i <= napzak_weight ; i++){
        dP1[i] = 0;
        dP2[i] = 0;   
    }

    for(i = 1 ; i <= laggage_num ; i++){
        scanf("%ld %ld" , &laggage_weight, &laggage_value);

        if(i % 2 == 1){

            for(j = 0 ; j <= napzak_weight; j++){

                if(j < laggage_weight){
                    dP1[j] = dP2[j];
                }else{
                    value = dP2[j - laggage_weight] + laggage_value;

                    if(dP2[j] < value){
                        dP1[j] = value;
                    }else{
                        dP1[j] = dP2[j];
                    }

                }

                //printf("%ld\n", dP1[j]);
                
            }
            
        }else{

            for(j = 0 ; j <= napzak_weight; j++){

                if(j < laggage_weight){
                    dP2[j] = dP1[j];
                }else{
                   value = dP1[j - laggage_weight] + laggage_value;

                    if(dP1[j] < value){
                        dP2[j] = value;
                    }else{
                        dP2[j] = dP1[j];
                    }
                }
                
                //printf("%ld\n", dP2[j]);
            }

        }


    } 

    
    if(laggage_num % 2 == 1){
        printf("%ld", dP1[napzak_weight]);
    }else{
        printf("%ld", dP2[napzak_weight]);
    }

}

Measured memory_bytes: 1664
import java.util.*;


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

        String ans;
        if ((a*b)%2 == 0){
            ans = "Even";
        }else {
            ans = "Odd";
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        String str = new Scanner(System.in).nextLine();
        String[] strs = str.split(" ");
        int a = Integer.parseInt(strs[0]);
        int b = Integer.parseInt(strs[1]);
        if(a<b){
            System.out.println("a < b");
        }else if(a>b){
            System.out.println("a > b");
        }else{
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26092
#include <iostream>
using namespace std;
 
int main() {
    int N;
    int counter = 0;

    cin >> N;

    int a[N];

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

    for (int i = 0; i < N; i += 2) {
        if (a[i] % 2 == 1) {
            counter++;
        }
    }

    cout << counter << endl;
}

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

int main() {
    ll x,y;
    std::cin >> x>>y;
    
    if(abs(x-y)<=1){
        std::cout << "Brown" << std::endl;
    }else{
        std::cout << "Alice" << std::endl;
    }
}



Measured memory_bytes: 256
def dfs(graph, start):
    visited = set()
    stack = [start]

    while stack:
        v = stack.pop()
        if v not in visited:
            stack.extend(graph[v])
            visited.add(v)
            yield v


def read_graph(nodes, edges):
    graph = [[] for _ in range(nodes)]
    for _ in range(edges):
        a, b = (int(x) - 1 for x in input().split())
        graph[a].append(b)
        graph[b].append(a)

    return graph


def count_candidates(n, counts, groups, block, friend):
    for i in range(n):
        count = counts[groups[i]]
        for v in block[i]:
            if groups[i] == groups[v]:
                count -= 1

        count -= len(friend[i])
        count -= 1
        yield count


def main():
    n, m, k = map(int, input().split())
    friend = read_graph(n, m)
    block = read_graph(n, k)

    groups = [-1 for _ in range(n)]
    counts = []
    i = 0
    group_id = 0
    while i < n:
        if groups[i] != -1:
            i += 1
            continue

        for j, v in enumerate(dfs(friend, i)):
            groups[v] = group_id

        counts.append(j + 1)
        group_id += 1

    print(" ".join(str(i) for i in count_candidates(n, counts, groups, block, friend)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 47360
#include<iostream>
#include<stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  //整数の時はint
  int n,m,a;
  //文字の時はstring
  // int a;

  int sum=0;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>a;
    sum+=a;
  }
  if(sum<=n)
    cout<<n-sum<<endl;
  else
    cout<<"-1"<<endl;
  return 0;
}

Measured memory_bytes: 3600
//ALL GLORY TO JESUS CHRIST 
#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;

#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n-1); i>=0; --i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )

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

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
}
//modular inverse
//inv(a,m) - inverse of a mod m
template <class T>
inline T inv(T a, T m){
 return 1<a ? m - inv(m%a, a)*m/a : 1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef LOCAL
    clock_t tStart = clock();
#endif
    int a, b; cin >> a >> b;
    if(a/10 == 0 && b/10 == 0)
        cout << a*b << "\n";
    else
        cout << -1 << "\n";
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * (clock() - tStart)/ CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll A, B;
  cin >> A >> B;
  cout << A * B << endl;

  return 0;
}


Measured memory_bytes: 3636
#!/usr/bin/ruby
class Fixnum
	def pow_binary_mod(y)
		x = self
		z = 1
		while y != 0
			while y % 2 == 0
				x = x * x % $N
				#y = y / 2
				y = y >> 1
			end
			y = y - 1
			z = z * x % $N
		end
		z
	end
	def /(n)
		m=(n%$N+$N)%$N
		raise if m==0
		self*m.pow_binary_mod($N-2)%$N
	end
end
loop{
	n,exp=gets.chomp.gsub(' ','').split(':')
	$N=n.to_i
	break if $N==0
	begin
		puts "#{exp} = #{(eval(exp)%$N+$N)%$N} (mod #{$N})"
	rescue
		puts :NG
	end
}

Measured memory_bytes: 15896
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
typedef long long ll;
using namespace std; 
using P = pair<int,int>;
const ll mod = 1e9+7;
const int INF = 1001001001;

const int MAX_W = 500;
const int MAX_H = 500;


int main(){
  string s;
  cin >> s;
  int total=1;
  for(int i=1;i<4;i++){
    if(s[i-1]==s[i]){
      total++;
      if(total==3){
	cout << "Yes" << endl;
	return 0;
      }
    }else{
      total = 1;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = []

for i in range(m):
    p, y = map(int, input().split())
    a.append([p, y, i, 0])

a.sort(key=lambda x: x[1])
a.sort(key=lambda x: x[0])

# print(a)

count_l1 = a[0][0]
index = 0
for i in range(m):
    if i == 0:
        a[0][3] = 1
        index = 1
    else:
        if count_l1 == a[i][0]:
            index += 1
            a[i][3] = index
        else:
            index = 1
            count_l1 = a[i][0]
            a[i][3] = index
    # print(a[i])

a.sort(key=lambda x: x[2])

for i in range(m):
    print('{:06}{:06}'.format(a[i][0], a[i][3]))


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

int preX[1020][55];
int dp[1020];

int main() {
	int q;
	cin >> q;
	for(int t = 0; t < q; t++) {
		string X, Y;
		for(int i = 0; i < 1020; i++) {
			for(int j = 0; j < 55; j++) {
				preX[i][j] = 0;
			}
			dp[i] = 0;
		}
		cin >> X >> Y;
		for(int i = 0; i < X.size(); i++) {
			for(int j = 0; j < 55; j++) {
				preX[i+1][j] = preX[i][j];
			}
			if(i > 0) {
				if('a' <= X[i-1] && X[i-1] <= 'z')
					preX[i+1][X[i-1]-'a'] = i;
				else
					preX[i+1][X[i-1]-'A'] = i;
			}
		}
		for(int i = 0; i < Y.size(); i++) {
			for(int j = (int)X.size()-1; j >= 0; j--) {
				if(Y[i] == X[j])
					for(int k = 0; k < 55; k++)
						dp[j+1] = max(dp[j+1], dp[preX[j+1][k]] + 1);
			}
		}
		int res = 0;
		for(int i = 0; i < 1020; i++)
			res = max(res, dp[i]);
		cout << res << endl;
	}
}

Measured memory_bytes: 1432
import java.io.*;
 
class Main {
	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try{
			String line = reader.readLine();
			int n = Integer.parseInt(line);
			line = reader.readLine();
			char[] s =line.toCharArray();
			String ans = "Yes";
 
			if(n%2 != 0){
				ans = "No";
			}else{
				if(!(line.substring(0, n/2).equals(line.substring(n/2, n)))){
					ans = "No";
				}
			}
			System.out.println(ans);
		} catch(IOException e) {
			System.out.println(e);
		} catch(NumberFormatException e) {
			System.out.println(e);
		}
	}
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

#ifdef DEBUG
#define debug(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
#else
#define debug(fmt, ...)
#endif

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }



ll solve(int N, vi& a,vi& b) {
    vector<pair<ll,int>> c(N);
    rep(i,N) c[i] = make_pair((ll)a[i] + b[i], i);
    sort(ALL(c)); reverse(ALL(c));
    ll tak=0, aok=0;
    rep(i,N){
        if(i%2==0){
            tak += a[c[i].second];
        } else {
            aok += b[c[i].second];
        }
    }
    return tak - aok;
}

int main() {
    int N; scanf("%d",&N);
    vi a(N), b(N);
    rep(i,N){
        scanf("%d%d",&a[i],&b[i]);
    }
    cout << solve(N,a,b) << endl;
    return 0;
}


Measured memory_bytes: 2560
//****************************//
/**********  main *************/
//****************************//
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i, n) for(i = 0; i < n; i++)
#define FOR(i, a, b) for(i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())

double pi = 3.141592653589793;

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

int main() {

    std::cin.tie(0);

    int n;
    int i,res;
    int ac=0,wa=0,tle=0,re=0;
    cin >> n;

    // string s[n];
    string s;
    // for(i=0;i<n;i++){
    //     cin >> s[i];
    // }

    for(i=0;i<n;i++){

        cin >> s;
        // if(s[i]=="ac")ac++;
        // if(s[i]=="wa")wa++;
        // if(s[i]=="tle")tle++;
        // if(s[i]=="re")re++;

        if(s=="AC")ac++;
        if(s=="WA")wa++;
        if(s=="TLE")tle++;
        if(s=="RE")re++;
    }


    cout << "AC x " << ac << endl;
    cout << "WA x " << wa  << endl;
    cout << "TLE x " << tle  << endl;
    cout << "RE x " << re  << endl;

    return 0;
    
}


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

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}

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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int n,k,p[5005];
long long d[5005],c[5005];

void nhap()
{
    scanf("%d %d",&n,&k);
    for (int i=1;i<=n;++i)
    {
        scanf("%d",&p[i]);
    }
    for (int i=1;i<=n;++i)
    {
        scanf("%lld",&c[i]);
    }
}

void process()
{
    long long kq=-1e18;
    for (int i=1;i<=n;++i)
    {
        int vt=i,dem=1;
        while (vt!=i || dem==1)
        {
            d[dem]=d[dem-1]+c[p[vt]];
            vt=p[vt];
            dem++;
        }
        for (int i=1;i<=min(k,dem-1);++i)
        {
            long long ma=max(d[i],d[i]+d[dem-1]*((k-i)/(dem-1)));
            kq=max(kq,ma);
        }
    }
    cout<<kq;
}

int main()
{
    nhap();
    process();
    return 0;
}


Measured memory_bytes: 3844
#include <iostream>

using namespace std;

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

int main()
{
  int N, Q;
  while( cin >> N >> Q, (N|Q) ) {

    int list[N][100];
    rep(i, N) rep(j, 100) list[i][j] = 0;
    rep(i, N) {
      int M;
      cin >> M;

      rep(j, M) {
        int d;
        cin >> d;
        ++list[i][d];
      }
    }

    int ax = 0;
    int ans = 0;
    rep(i, 100) {
      int cnt = 0;
      rep(j, N) {
        cnt += list[j][i];
      }
      if(cnt >= Q && ax < cnt) {
        ax = cnt;
        ans = i;
      }
    }

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

Measured memory_bytes: 1176
// Problem : A - Don't be late
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define int long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define mod 998244353
#define bug cout<<"HY"<<endl
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define numize(A) A.numize(unique(A.begin(), A.end()) - A.begin())
typedef pair<int,int> P;
int power(int a,int b)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return (power((a*a)%mod,b/2))%mod;
    return (a*(power((a*a)%mod,b/2))%mod)%mod;
}
int modInv(int n)
{
    return power(n, MOD-2);
}
int nCr(int n, int r, int p=MOD)
{
   if (r==0)
      return 1;
    int Fact[n+1];
    Fact[0] = 1;
    for (int i=1 ; i<=n; i++)
    {
        Fact[i] = (Fact[i-1]*i)%p;
    }
    return (((Fact[n]* modInv(Fact[r])) % MOD) *(modInv(Fact[n-r]) % MOD)) % MOD;
}
double PI=3.14159265359;
void solve()
{
	int d,t,s;
	cin>>d>>t>>s;
	if(d<=t*s)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}
int32_t main()
{
    boost;
    int  t=1;
    // cin>>t;
    while(t--)
    {
    	solve();
    }
}


Measured memory_bytes: 3612
//状态:
//题号:
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <iomanip>
#include <cassert>
#include <complex>
#include <functional>
#include <list>
#include <cmath>
using namespace std;
int main(){
	string s;
	int w;
	cin>>s>>w;
	for(int i=0;i<s.size();i+=w){
		putchar(s[i]);
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 10000
#define Q 500

main(){  
  int n,q,i,j,count=0;
  int S[N],T[Q];
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  
  scanf("%d",&q);
  
  for(j=0;j<q;j++){
    scanf("%d",&T[j]);
  }
  
    for(j = 0 ; j < q ; j++){
      for(i = 0 ; i < n ; i++){
      if(T[j]==S[i]){
	count++;
	break;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}
       

Measured memory_bytes: 640
N = input()
ans = str()
for i in range(len(N)):
    if N[i] == "0":
        ans += "0"
    elif N[i] == "1":
        ans += "1"
    else:
        if len(ans) == 0:
            continue
        else:
            ans = ans[:-1]

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#define N 100
using namespace std;

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

	int A[N][N], B[N], C[N];

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

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


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

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

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

	return 0;
}


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

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

int main() {
  ll n, sum = 0;
  set<ll> a;
  cin >> n;

  for (int i = 1; i <= n; ++i) {
    sum += i;
    a.insert(i);
    if (sum >= n) {
      a.erase(sum - n);
      break;
    }
  }

  for(ll aa:a) cout << aa << endl;
  return 0;
}


Measured memory_bytes: 512
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    h1, m1, h2, m2, k = map(int, input().split())
    ans = (h2 * 60 + m2) - (h1 * 60 + m1) - k
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 61688
n=int(input())
arr=list(map(int,input().split()))
ans=int(1)
temp=int(0)
for i in range(n):
  if(ans>(10**18)):
    ans=-1
  if(ans!=-1):
  	ans*=arr[i]
  if(arr[i]==0):
    temp=int(1)
if(ans>(10**18)):
  ans=-1
if(temp==1):
  ans=0
print(int(ans))

Measured memory_bytes: 84764
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

ll num[26];
ll mod = 1000000000LL+7LL;
int main() {
  int n;
  cin>>n;
  string s;
  cin>>s;
  for(auto c:s)num[c-'a']++;

  ll ans = 1;
  rep(i,26){
    ans *= num[i]+1;
    ans%=mod;
  }
  print((ans+mod-1)%mod);
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)


int main() {

ll A,B,N; cin >> A >> B >> N ;

ll x = min(B-1,N);
ll ans=(A*x/B)-(x/B*A);

cout << ans << endl;

return 0;
}

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

using namespace std;

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

int const INF = 1e9;
struct edge { int to, cap, cost, rev;};

int const V = 366;
typedef pair<int,int> Pii;

vector<edge> G[V];
int h[V], dist[V];
int prevv[V], preve[V];

inline void add_edge(int from, int to, int cap, int cost){
  G[from].push_back((edge){to, cap, -cost, (int)G[to].size()});
  G[to].push_back((edge){from, 0, cost, (int)G[from].size() - 1});
}

int min_cost_flow(int s, int t, int f){
  
  int res = 0;
  memset(h, 0, sizeof h);
  
  while(f > 0){
    priority_queue<Pii, vector<Pii>, greater<Pii> > pq;
    fill(dist, dist + V, INF);
    dist[s] = 0;
    pq.push(Pii(0, s));
    while(!pq.empty()){
      Pii p = pq.top(); pq.pop();
      int v = p.second;
      
      if(dist[v] < p.first) { continue; }
      
      rep(i, G[v].size()){
	edge &e = G[v][i];
	if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
	  dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
	  prevv[e.to] = v;
	  preve[e.to] = i;
	  pq.push(Pii(dist[e.to], e.to));
	}
      }
    }
    
    if(dist[t] == INF) return -1;
    
    rep(v, V) h[v] += dist[v];
    
    int d = f;
    for(int v=t; v!=s; v=prevv[v]) {
      d = min(d, G[prevv[v]][preve[v]].cap);
    }
    
    f -= d;
    res += d*h[t];
    
    for(int v=t; v!=s; v=prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  
  return res;
}


int main() {
  
  while(1) {
    
    int N; cin >> N; if(N == 0) break;
    rep(i, V) G[i].clear();
    rep(i, V-1) add_edge(i, i+1,2,0);
    rep(i, N) {
      int a, b, c; cin >> a >> b >> c;
      add_edge(a-1, b, 1, c);
    }
    
    cout << -min_cost_flow(0, 365, 2) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1360
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	set<int> se;
	for (int i = 0; i < n; i++) {
		int d;
		cin >> d;
		se.insert(d);
	}

	cout << se.size() << endl;
	return 0;
}


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



int main ()
{
long long int a,b,e,d,c;

cin >>a;
cin >>b;
 c =abs( (a+b)/2);
 d =abs( a-c);
 e =abs( b-c);


if (d==e)
{
    cout << c;
}

else
{
    cout << "IMPOSSIBLE";
}


}













Measured memory_bytes: 256
s=gets.chomp.to_s
a=["SUN","MON","TUE","WED","THU","FRI","SAT","SUN","MON","TUE","WED","THU","FRI","SAT"]
ans=0
i=a.index(s)
(i+1..13).each do |x|
    if a[x]=="SUN"
        ans=x-i
        break
    end
end
p ans

Measured memory_bytes: 1788
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
		// 整数の入力
        
        int[] num = new int[5];
        
        int ans = 0;

        for(int i = 0;i < 5;i++){
            num[i] = sc.nextInt();
        }
		for(int i = 0;i < 5;i++){
            if(num[i] == 0) ans = i+1;
        }
		// 出力
		System.out.println(ans);

    }
}

Measured memory_bytes: 35796
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

void init_io() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(30);
}

// #define DEBUGGING
#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#endif

int main() {
    init_io();
    ll N;
    cin >> N;
    V<ll> A(N);
    for(ll &e : A) cin >> e;
    
    ll ok = 5e18, ng = -1;
    auto ceil = [](ll n, ll k) { return n / k + !!(n % k); };
    
    while(ok - ng > 1) {
        ll mid = (ok + ng) / 2;
        V<ll> cpy = A;
        ll times;
        bool suc = false;
        for(times = max<ll>(0, mid - 2 * N); times <= mid; times++) {
            ll cnt = 0;
            for(ll e : cpy) {
                e += times;
                e -= (N - 1);
                chmax(e, (ll)0);
                cnt += ceil(e, N + 1);
            }
            if(cnt <= times) {
                suc = true;
                break;
            }
        }
        if(suc) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    return 0;
}


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

class UF{
  vi p,r;
public:
  UF(int n):p(n,-1),r(n,0){ }

  int find(int x){ return (p[x]<0)?x:(p[x] = find(p[x])); }

  void unite(int x,int y){
    x = find(x); y = find(y);
    if(x==y)return;

    if(r[x] < r[y])p[x] = y;
    else p[y] = x;
    if(r[x] == r[y])r[x]++;
  }

  bool same(int x,int y){return find(x)==find(y);}
};

int main(){
  int n,w,h,x,y;
  cin >> n >> w >> h;
  UF uf(h+w+n);
  int nearWall = 0;
  rep(i,n){
    cin >> x >> y;
    uf.unite(n+x-1,i);
    uf.unite(n+w+y-1,i);
    if(x==1 || y==1 || x==w || y==h)nearWall = 1;
  }
  
  set<int> group;
  rep(i,n)group.insert(uf.find(i));
  int k = group.size();
  if(k==1){
    cout << n-1 << endl;
  }else{
    cout << n-k + 2*k-1 - nearWall << endl;
  }
}

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

int main()
{
  int N, Y;
  cin >> N >> Y;
  int res10000 = -1, res5000 = -1, res1000 = -1;
  for(int a = 0; a <= N; ++a){
    for(int b = 0;b + a <= N; ++b){
      int c = N - a - b;
      int total= 10000*a + 5000*b + 1000*c;
      if(total == Y){
        res10000 = a;
        res5000 = b;
        res1000 = c;
      }
    }
  }

  cout << res10000 << " " << res5000 << " "  << res1000 <<endl;
}

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

int main()
{
    int n,a[100]={0};
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> a[i];
        int num=0,sum=0;
    for(int i=0;i<n;i++)
    {
        cin >> num;
        if(a[i]>num)
            sum+=a[i]-num;
    }
    cout <<sum <<endl;
    return 0;
}


Measured memory_bytes: 256
/*
	* ernestvw
	* C++
	* April 2020
	* ABC164/B
*/

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

#define int long long

#define x first
#define y second
#define pb push_back
#define pii pair<int, int>
#define veci vector<int>
#define vecs vector<string>
#define amax(x, v) x = max(x, (v))
#define amin(x, v) x = min(x, (v))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define nl '\n'

using ll = long long;
using ld = long double;
template <class T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

const int oo = 1e9; // INT_MAX
const int OO = 1e18; // LLONG_MAX
const double eps = 1e-9;

#define TEST_CASES 0

void solve(int test_case);

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

	int T = 1;
	if(TEST_CASES) cin >> T;
	for(int t = 1; t <= T; t++)
		solve(t);

	return 0;
}

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

void solve(int test_case) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while(a > 0 and b > 0) {
		c -= b;
		if(c <= 0) {
			cout << "Yes" << endl;
			return;
		}
		a -= d;
		if(a <= 0) {
			cout << "No" << endl;
		}
	}
}



















































Measured memory_bytes: 3656
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int A, P;
	cin >> A >> P;
	int num = A * 3 + P;
	int ans = num / 2;
	cout << ans;
}

Measured memory_bytes: 256
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i

cnt = 0

for i in 0..A do
  for j in 0..B do
    for k in 0..C do
      sum = (500*i)+(100*j)+(50*k)
      cnt += 1 if sum == X
    end
  end
end

puts cnt

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
    ll a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    ll ans=(ll)1e12;
    for(ll i=0;i<=max(x,y);i++){
        ll sum=2*i*c;
        ll xres=max(0ll,x-i);
        ll yres=max(0ll,y-i);
        sum+=xres*a+yres*b;
        ans=min(ans,sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
from collections import Counter
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, M, K = map(int, readline().split())


def graph_input(N, M):
    G = [[] for _ in range(N+1)]
    for _ in range(M):
        a, b = map(int, readline().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)
    return G


friend = graph_input(N, M)
block = graph_input(N, K)
seen = [0] * N


def dfs(x, group):
    # DFS で頂点 x がどの group に属するかを記録していく
    # 後に、各 group に対して、seen[x] = group となるがいくつあるか数えれば連結成分数もわかる
    seen[x] = group
    for y in friend[x]:
        if seen[y]:
            continue
        else:
            seen[y] = group
            dfs(y, group)


group = 1
for x in range(N):
    if seen[x] == 0:
        dfs(x, group)
        group += 1


counter = Counter(seen)  # リストの値の出現回数を Counter で数えることで各連結成分数を得ている

res = []
for x in range(N):
    # x 自身を連結成分数から除く-1 さらに friend[x] を除く
    cand_n = counter[seen[x]] - len(friend[x]) - 1
    # block[x]と xの連結成分の共通部分の抜くのが難しい
    for a in block[x]:
        if seen[a] == seen[x]:
            cand_n -= 1
    res.append(cand_n)

print(" ".join(map(str, res)))


if __name__ == '__main__':
    print()


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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};
using namespace std;

void solve(){
   int A[3];
    cin>>A[0]>>A[1]>>A[2];
   sort(A,A+3);
   cout<<(A[2]-A[0]);    
}

int main(){
    std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll k;
    cin>>k;
    string s;
    cin>>s;
    rep(i,s.size()){
        if(i<k){
            cout<<s[i];
        }else{
            cout<<"...";
            break;
        }
    }
    cout<<endl;
}


Measured memory_bytes: 3672
from sys import stdin
input = stdin.readline
from time import time
from random import randint
from copy import deepcopy

start_time = time()

def calcScore(t, s, c):
    scores = [0]*26
    lasts = [0]*26
    for i in range(1, len(t)):
        scores[t[i]] += s[i][t[i]]
        dif = i - lasts[t[i]]
        scores[t[i]] -= c[t[i]] * dif * (dif-1) // 2
        lasts[t[i]] = i
    for i in range(26):
        dif = len(t) - lasts[i]
        scores[i] -= c[i] * dif * (dif-1) // 2
    return scores

def greedy(c, s):
    day_lim = len(s)
    socres = [0]*26
    t = [0]*day_lim
    lasts = [0]*26
    for i in range(1, day_lim):
        pls = [v for v in socres]
        mns = [v for v in socres]
        for j in range(26):
            pls[j] += s[i][j]
            mns[j] -= c[j] * (i - lasts[j])
        sum_mns = sum(mns)
        pt = sum_mns - mns[0] + pls[0]
        idx = 0
        for j in range(1, 26):
            tmp = sum_mns - mns[j] + pls[j]
            if pt < tmp:
                pt = tmp
                idx = j
        t[i] = idx
        lasts[idx] = i
        for j in range(26):
            if j == idx:
                socres[j] = pls[j]
            else:
                socres[j] = mns[j]
    return socres, t

D = int(input())
c = list(map(int, input().split()))
s = [[0]*26 for _ in range(D+1)]
for i in range(1, D+1):
    s[i] = list(map(int, input().split()))

scores, t = greedy(c, s)
sum_score = sum(scores)

while time() - start_time < 1.75:
    tmp_t = deepcopy(t)
    for _ in range(30):
        tmp_t[randint(1, D)] = randint(0, 25)
    tmp_scores = calcScore(tmp_t, s, c)
    sum_tmp_score = sum(tmp_scores)
    if sum_score < sum_tmp_score:
        sum_score = sum_tmp_score
        t = tmp_t
        scores = tmp_scores

for v in t[1:]:
    print(v+1)


Measured memory_bytes: 86556
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcountll(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define BACK(x) prev((x).end())
#define HASK(x, y) ((x).find(y) != (x).end())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;
 
const int maxN = 1 << 19;

int T[maxN];

void solve()
{
	int n,m ;
	scanf ("%d%d", &n, &m);
	FOR(i, 0, n)
		scanf ("%d", T+i);
	sort(T, T+n);
	long long res = 0;
	FOR(i, 0, max(0, n-m))
		res += T[i];
	printf("%lld\n", res);
}
 
int main()
{
	int t = 1;
	//scanf ("%d", &t);
	FOR(tid, 1, t+1)
	{
		//printf("Case #%d: ", tid);
		solve();
	}
	return 0;
}





Measured memory_bytes: 4600
#include <iostream>
    
int main() {
    int x = 0;
    std::cin >> x;
    int h = x / 3600;
    int m = (x - h * 3600) / 60;
    int s = (x - h * 3600 - m * 60);
    
    std::cout << h << ":" << m << ":" << s << std::endl;
    return 0;
}

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

int main() {
  int r, c;
  cin >> r >> c;
  vector< vector<int> > sheet(r + 1, vector<int>(c + 1));
  for(int i = 0; i < r; i++) {
    for(int j = 0; j < c; j++) {
        cin >> sheet.at(i).at(j);
        sheet.at(i).at(c) += sheet.at(i).at(j);
    }
  }

  for(int i = 0; i <= c; i++) {
    int sum_r = 0;
    for(int j = 0; j < r; j++) {
      sheet.at(r).at(i) += sheet.at(j).at(i);
    }
  }

  for(int i = 0; i <= r; i++) {
    for(int j = 0; j <= c; j++) {
      if(j < c) cout << sheet.at(i).at(j) << " ";
      else cout << sheet.at(i).at(j) << endl;
    }
  }
}


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

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

using namespace std;

int main(){
  int Q;
  cin >> Q;
  rep(_,Q){
    int c,a,n,answer=0;
    cin >> c >> a >> n;
    while( c && a && n ) { --c, --a, --n; ++answer; }
    while( c >= 2 && a ) { c -= 2, --a;   ++answer; }
    while( c >= 3 )      { c -= 3;        ++answer; }
    cout << answer << endl;
  }
  return 0;
}

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

using namespace std;

const int INF = 1e9 + 10;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    vector<int> a(n);

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

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

    int ans = INF;
    
    for (int i = 0; i < n - 1; i++) {
      ans = min(ans, abs(a[i] - a[i + 1]));
    }

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

Measured memory_bytes: 3176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		String s = scan.next();
		int n = s.length();
		String palindrome = s.substring(0, (n-1) / 2);
		if (s.substring((n + 3)/2 - 1).equals(palindrome)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 998244353
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool prime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

struct CustomCompare
{
    bool operator()(const int& lhs, const int& rhs)
    {
        return lhs < rhs;
    }
};

bool comp(pair<ll, pi>a,pair<ll,pi>b)
{
    if(a.se.fi==b.se.fi)return a.se.se>b.se.se;
    return a.se.fi>b.se.fi;
}

ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}


int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll x; cin>>x;
ll n; cin>>n;
map<ll,ll>mp;
rep(i,0,n)
{
    ll y; cin>>y;
    mp[y]++;
}
ll ans =0;
for(ll i=0;i<=102;i++)
{
    if(mp.count(x-i)==0)
    {
        ans = x-i;
        break;
    }
    if(mp.count(x+i)==0)
    {
        ans = x+i;
        break;
    }
}
cout<<ans<<endl;
return 0;
}
/*
50 25
39 99 70 24 49 13 86 43 88 74 45 92 72 71 90 32 19 76 84 46 63 15 87 1 39 58 17 65 99 43 83 29 64 67 100 14 17 100 81 26 45 40 95 94 86 2 89 57 52 91 45
1221 360 459 651 958 584 345 181 536 116 1310 403 669 1044 1281 711 222 280 1255 257 811 409 698 74 838
*/


Measured memory_bytes: 3660
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	int n;
	cin >> n;
	if (n <= 999)cout << "ABC" << endl;
	else cout << "ABD"<< endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <cstring>
#include <bitset>
#include <functional>
#include <tuple>
#include <complex>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;


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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    
    int n;
    cin >> n;
    string s;
    cin >> s;

    ll res = 0;

    for (int mask = 0; mask < (1 << n); ++mask) {
        string u, v;

        for (int i = 0; i < n; ++i) {
            if (!(mask & (1 << i))) {
                u += s[i];
            } else {
                v += s[i];
            }
        }
        reverse(all(v));
        reverse(all(u));

        vector<ll> dp1(n + 1), dp2(n + 1);
        dp1[0] = 1;

        for (int i = n; i < 2 * n; ++i) {
            dp2.assign(n, 0);

            for (int j = 0; j <= i - n; ++j) {
                if (j < sz(u) && u[j] == s[i]) {
                    dp2[j + 1] += dp1[j];
                }

                if (i - n - j < sz(v) && v[i - n - j] == s[i]) {
                    dp2[j] += dp1[j];
                }
            }

            dp1.swap(dp2);
        }

        res += dp1[sz(u)];
    }

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;

public class Main {
	final Scanner sc=new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		new AOJ1245();
	}
	
	class AOJ1245{
		final int OFFSET=200, MAX=OFFSET*2, INF=Integer.MAX_VALUE/4;
		final int[] vx={0,1,1,0,-1,-1,0},	vy2={1,0,-1,-1,-1,0,0},
											vy1={1,1,0,-1,0,1,0};
		AOJ1245(){
			int sx=sc.nextInt()+OFFSET, sy=sc.nextInt()+OFFSET,
				gx=sc.nextInt()+OFFSET, gy=sc.nextInt()+OFFSET,
				N=sc.nextInt();
			int[] x=new int[N],y=new int[N];
			for(int i=0; i<N; i++){
				x[i]=sc.nextInt()+OFFSET;
				y[i]=sc.nextInt()+OFFSET;
			}
			int LX=sc.nextInt(),LY=sc.nextInt();
			boolean[][] b=new boolean[MAX][MAX];
			for(int i=0; i<N; i++)	b[x[i]][y[i]]=true;
			
			PriorityQueue<State1> open=new PriorityQueue<State1>();
			open.add(new State1(sx,sy,0,0));
			int[][][] close=new int[MAX][MAX][6];
			for(int i=0; i<MAX; i++)for(int j=0; j<MAX; j++)for(int k=0; k<6; k++)close[i][j][k]=INF;
			close[sx][sy][0]=0;
			
			int ans=INF;
			while(!open.isEmpty()){
				State1 now=open.poll();
				//System.out.println(now);
				if(now.x==gx && now.y==gy){
					ans=now.cost;
					break;
				}
				int d=(abs(now.x-OFFSET)*abs(now.y-OFFSET)*now.step)%6;
				for(int i=0; i<7; i++){
					int xx=now.x+vx[i], yy=now.y+(now.x%2==0? vy2[i]: vy1[i]);
					if(abs(xx-OFFSET)>LX || abs(yy-OFFSET)>LY)	continue;
					if(b[xx][yy])	continue;
					int next=now.cost+(d==i? 0: 1);
					if(close[xx][yy][(now.step+1)%6]<=next)	continue;
					open.add(new State1(xx,yy,(now.step+1)%6,next));
					close[xx][yy][(now.step+1)%6]=next;
				}
			}
			System.out.println(ans>=INF? -1: ans);
		}
		class State1 implements Comparable<State1>{
			int x,y,step,cost;
			State1(int x,int y,int step,int cost){
				this.x=x;	this.y=y;	this.step=step;	this.cost=cost;
			}
			@Override public int compareTo(State1 o){
				return (this.cost!=o.cost? this.cost-o.cost: this.step-o.step);
			}
			@Override public String toString(){
				return x+","+y+" "+cost+" "+step+"steps";
			}
		}
	}
}

Measured memory_bytes: 20000
<?php

fscanf(STDIN, "%d %d", $n, $m);
$X = array_map('intval', explode(' ', trim(fgets(STDIN))));

if ($n >= $m) {
    echo 0;
    return;
}

sort($X);

$div = [];
for ($i = 0; $i < $m - 1; ++$i) {
    $div[] = $X[$i + 1] - $X[$i];
}
rsort($div);

$sum = 0;
for ($i = $n - 1; $i < $m; ++$i) {
    $sum += $div[$i];
}
echo $sum;


Measured memory_bytes: 18932