akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll dp[301010];
pair < vector<ll>, pair<vector<ll>, vector<ll> > >calc(string s)
{
	reverse(s.begin(), s.end());
	s.push_back('1');
	reverse(s.begin(), s.end());
	fill(dp, dp + s.size() + 5, 0);
	dp[0] = 1;
	vector<ll>r1, r2, r3;
	ll now = 0;
	for (int i = 0; i < s.size() / 2; i++)
	{
		int c = 0, d = 0;
		if (s[i * 2] != '1'&&s[i * 2 + 1] != '1')dp[i + 1] += dp[i], c++;
		if (s[i * 2] != '1'&&s[i * 2 + 1] != '0')dp[i + 1] += dp[i], c++, d++;
		if (s[i * 2] != '0'&&s[i * 2 + 1] != '1')dp[i + 1] += dp[i], c++;
		if (s[i * 2] != '0'&&s[i * 2 + 1] != '0')c++, d++;
		dp[i + 1] %= mod;
		ll t = now*d%mod;
		now = now*c%mod;
		if (s[i * 2] != '0'&&s[i * 2 + 1] != '0')
		{
			r1.push_back(dp[i]);
			now = (now + dp[i]) % mod;
			t = (t + dp[i]) % mod;
		}
		else r1.push_back(0);
		r2.push_back(now);
		r3.push_back(t);
		//printf("%lld %lld %lld\n", r1[i], r2[i], dp[i]);
	}
	return make_pair(r1, make_pair(r2, r3));
}
int main()
{
	string s;
	cin >> s;
	pair < vector<ll>, pair<vector<ll>, vector<ll> > >z1 = calc(s);
	reverse(s.begin(), s.end());
	pair < vector<ll>, pair<vector<ll>, vector<ll> > >z2 = calc(s);
	ll r = 0;
	for (int i = 0; i < s.size() / 2 + 1; i++)
	{
		r += z1.first[i] * z2.second.second[s.size() / 2 - i];
		r %= mod;
	}
	printf("%lld\n", r);
}

Measured memory_bytes: 17248
import sys
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
if(n==2):
  mi=abs(a[0]-a[1])
else:
  mi=10**15
  s1=a[0]
  for i in range(1,len(a)-1):
    s1+=a[i]
    s2=s-s1
    #print(s1,s2)
    mi=min([mi,abs(s1-s2)])
print(mi)


Measured memory_bytes: 24812
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int sum = 0;
  for(int i = a; i <= b; i++) {
    if(i % c == 0) sum++;
  }
  cout << sum << "\n";
}

Measured memory_bytes: 3584
s = input()
ans = 0
counter = 0
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or s[i] == 'C':
        counter += 1
    else: 
        ans = max(ans,counter)
        counter = 0
ans = max(ans,counter)
print(ans)

Measured memory_bytes: 61192
from collections import Counter

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

cnt_dict = Counter(A)
cnt_common = cnt_dict.most_common()

if len(cnt_common) <= K:
  ans = 0
else:
  n_asis = 0
  for i in range(K):
    n_asis += cnt_common[i][1]
  ans = N - n_asis

print(ans)

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

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

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

        if x == y:
            return

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

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

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

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

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

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

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

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

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
L = [[] for _ in range(m)]
for i in range(n):
  k, *l = map(int, input().split())
  for j in l:
    L[j-1].append(i)

uf = UnionFind(n)
for i in L:
  for j in range(len(i)-1):
    uf.union(i[j], i[j+1])
if uf.group_count() == 1:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 15908
import org.w3c.dom.ls.LSOutput;
import java.util.*;
public class Main {
    static boolean visited[] = new boolean[1002];
    static boolean counted[] = new boolean[1002];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a[]= new int[3];
        for (int i=0;i<3;i++){
            a[i]=sc.nextInt();
        }
        int n = sc.nextInt();
        while (a[1]<=a[0]){
            a[1]<<=1;
            n--;
        }
        while (a[2]<=a[1]){
            a[2]<<=1;
            n--;
        }
        System.out.println(n>=0?"Yes":"No");
    }
}






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

const int INF = INT_MAX;

template<typename T>
struct SegmentTree {
	SegmentTree(int n_){
		for (n = 1; n < n_; n <<= 1);
		val.assign(n * 2 - 1, INF);
	}
	void update(int k, T x){
		k += n - 1;
		val[k] = x;
		while (k){
			k = (k - 1) / 2;
			val[k] = std::min(val[k * 2 + 1], val[k * 2 + 2]);
		}
	}
	T min(int l, int r, int k, int a, int b){
		if (r <= a || b <= l) return INF;
		if (l <= a && b <= r) return val[k];
		int m = (a + b) / 2;
		T vl = min(l, r, k * 2 + 1, a, m);
		T vr = min(l, r, k * 2 + 2, m, b);
		return std::min(vl, vr);
	}
	T min(int l, int r){
		return min(l, r, 0, 0, n);
	}
private:
	int n;
	vector<T> val;
};

int n, q;
int c, x, y;

int main()
{
	cin >> n >> q;
	SegmentTree<int> rmq(n);
	for (int i = 0; i < q; i++){
		cin >> c >> x >> y;
		if (c == 0) rmq.update(x, y);
		else cout << rmq.min(x, y + 1) << endl;
	}
}

Measured memory_bytes: 2060
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

const int MOD = 1000000007;
const int A = 1;
const int C = 2;
const int G = 3;
const int T = 4;
int N;
int dp[110][5][5][5];

bool ok(int a, int b, int c, int d) {
    // AGC
    if (a == A && b == G && c == C) return false;
    if (b == A && c == G && d == C) return false;

    // ACG
    if (a == A && b == C && c == G) return false;
    if (b == A && c == C && d == G) return false;

    // GAC
    if (a == G && b == A && c == C) return false;
    if (b == G && c == A && d == C) return false;

    // A*GC
    if (a == A && c == G && d == C) return false;

    // AG*C
    if (a == A && b == G && d == C) return false;

    return true;
}

void _main() {
    cin >> N;
    FOR (i, 1, 5) FOR (j, 1, 5) FOR (k, 1, 5) {
        if (ok(i, j, k, 0)) {
            dp[3][i][j][k] = 1;
        }
    }
    FOR (i, 3, N) FOR (j, 1, 5) FOR (k, 1, 5) FOR (l, 1, 5) {
        FOR (m, 1, 5) {
            if (ok(j, k, l, m)) {
                (dp[i + 1][k][l][m] += dp[i][j][k][l]) %= MOD;
            }
        }
    }
    int ans = 0;
    FOR (i, 1, 5) FOR (j, 1, 5) FOR (k, 1, 5) {
        (ans += dp[N][i][j][k]) %= MOD;
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 384
import sys

n = list(map(int, input().split()))
k = n[0]
x = n[1]

start = min([(x - k + 1), -100])

if k is 1:
  print(x)
  quit()


i = 0
while True:
  if x - k + 1 + i == x:
    break
  print(x - k + 1 + i, end = " ")
  i += 1

j = 0
while True:
  print(x+j, end = " ")
  j += 1
  if x+j == x + k - 1:
    print(x + k - 1)
    quit()



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N,K;
    cin >> N >> K;
    ll ans;
    if (K % 2 == 1){
        ll count = 0;
        for (ll i = 1; i <= N; i++){
            if (i % K == 0){
                count++;
            }
        }
        ans = count * count * count;
    }
    else if (K % 2 == 0){
        ll count_1 = 0;
        ll count_2 = 0;
        for (ll i = 1; i <= N; i++){
            if (i % K == 0){
                count_1++;
            }
            else if (i % K == (K / 2)){
                count_2++;
            }
        }
        ans = count_1 * count_1 * count_1 + count_2 * count_2 * count_2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e5+10;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
int main() 
{
	int k , a, b;
	cin>>k>>a>>b;
	int f=0;
	for(int i=a;i<=b;i++)
		if(i%k==0) f=1;
	if(f)
		cout<<"OK";
	else
		cout<<"NG";
	
}

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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

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

int main() {
  cout << setprecision(15);
  string S;
  cin >> S;
  u32 flag = 0;
  if (S[0] == 'A' && S[1] == 'A' && S[2] == 'A') {
    cout << "No" << endl;
    return 0;
  }
  if (S[0] == 'B' && S[1] == 'B' && S[2] == 'B') {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
import sys

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


def main():
    S = input().split('T')
    x, y = map(int, input().split())

    X = []
    Y = []
    flag = 0
    for s in S:
        if flag == 0:
            X.append(len(s))
        else:
            Y.append(len(s))
        flag ^= 1

    A = set()
    A.add(X[0])
    for i in X[1:]:
        tmp = set()
        for a in A:
            tmp.add(a + i)
            tmp.add(a - i)
        A = tmp

    B = set()
    B.add(0)
    for j in Y:
        tmp = set()
        for b in B:
            tmp.add(b + j)
            tmp.add(b - j)
        B = tmp

    if x in A and y in B:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9824
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    long long a, l = 1, m, n, p, q;
    bool bad = false;
    cin >> n >> m;
    for (int i = 0; i < n; i++){
        cin >> a;
        a >>= 1;
        p = (-a) & a;
        if (i){
            if (p != q){
                bad = true;
                break;
            }
        }
        else q = p;
        l = (l * a) / __gcd(l, a);
        if (l > m){
            bad = true;
            break;
        }
    }
    if (bad) cout << 0 << '\n';
    else{
        cout << ((m / l) + 1)/2 << '\n';
    }
}


Measured memory_bytes: 384
/*
AUTHOR: Aman Raj
LANG: C++
*/

using namespace std;

typedef   long long  int ll;
#include <bits/stdc++.h>


//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
#define fast  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define all(a) a.begin(),a.end()
//#define mod 998244353


#define mod   1000000007

#define inf 1e18
//#define mod 3
#define flush fflush(stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<ll, ll, hash< ll > > ht;

// find_by_order()  // order_of_key
typedef tree<
    ll,
    null_type,
    less<ll>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;






ll power1(ll a, ll b)//a raised to power b
   {  if(b<=0) return 1; if(b==1) return a;
       ll c=power1(a,b/2);
        c*=c;c%=mod;if(b%2==1) c*=a;c%=mod;
        return c;
   }
   ll mi(ll a,ll m)
   { ll c= power1(a,m-2);

     return c;
   }



 struct less_then_greater {
    template<typename T, typename U>
    bool operator()(T const& lhs, U const& rhs) const {
        if (lhs.first < rhs.first) return true;
        if (rhs.first < lhs.first) return false;
        return lhs.second > rhs.second;
    }
};

 /*std::priority_queue<std::pair<int, int>,
                    std::vector<std::pair<int, int>>,
                    less_then_greater
                    > pq;*/

vector<vector<pair<ll,ll>> > v;
vector<ll> vans;
ll k;
void dfs(ll a,ll p,ll col)
{    //set<ll> scolor;scolor.insert(p);
    ll color=1;
    for(auto x:v[a])
    {
        if(x.first!=p)
        {  /* if(scolor.find(color)==scolor.end()){k=max(k,color);vans[x.second]=color;scolor.insert(color);color++;  }
            else
            {
                color++;assert(scolor.find(color)==scolor.end());
                k=max(k,color);vans[x.second]=color;scolor.insert(color);color++;
            }*/
            if(col==color)color++;
            k=max(k,color);
            vans[x.second]=color;
            dfs(x.first,a,color);
            color++;
        }
    }
}
  int main()
{  fast;
    ll n;cin>>n;
      v.resize(n+1);

     for(ll i=0;i<n-1;i++)
     {
         ll a,b;cin>>a>>b;v[a].push_back({b,i+1});v[b].push_back({a,i+1});

     }
     vans.resize(n+1,-1);
      k=0;
      dfs(1,1,0);
     cout<<k<<endl;
     for(ll i=1;i<n;i++)cout<<vans[i]<<endl;

   return 0;
}


Measured memory_bytes: 12640
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    int R=sc.nextInt();
    
    if(N<=10) System.out.println(R+100*(10-N));
    else System.out.println(R);
  }
}

Measured memory_bytes: 22484
#include<iostream>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long int ll;
ll func(ll num1, ll num2){
  if (num1 > num2)swap(num1, num2);
  if(num2 % num1 == 0)return num1;
  return func(num1, num2 % num1);
}
int main(){
  int n;cin>>n;
  ll ans=1;
  for(int i=0;i<n;i++){
    ll x;cin>>x;
    ans = (x / func(ans, x))*ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,ap=0;
    cin>>n;
    int a[n],b,i=0;
    while(n--)
    {
        cin>>b;
        if((b&1)==0)
            a[i++]=b;

    }
    for(int j=0;j<i;j++)
    {
        if(((a[j]%3)==0) || ((a[j]%5)==0))
           {
            ap++;
            }
        else
            {ap=0;}
    }
    if(ap==i)
        cout<<"APPROVED";
    else
        cout<<"DENIED";


}


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

int main(){
  
  int N, K;
  cin>>N>>K;
  vector<int> h(N), cst(N, 2000000000);
  for(int i=0; i<N; i++) cin>>h[i];
  
  cst[0]=0;
  for(int i=0; i<N; i++){
    for(int j=0; j<min(K, N-i-1); j++){
      cst[i+j+1]=min(cst[i+j+1], cst[i]+abs(h[i+j+1]-h[i]));
    }
  }
  
  cout<<cst[N-1]<<endl;
  return 0;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.14159265358979323

int main() 
{
    FAST;
    string s,p;
    cin>>s>>p;
    ll n=s.length(),m=p.length();
    if(n==m-1)
    {
    	bool b=1;
    	for(int i=0;i<n;i++)
    		if(s[i]!=p[i])
    			b=0;
    	if(b)
    		cout<<"Yes";
    	else
    		cout<<"No";
    }
    else
    	cout<<"No";
    //cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL MOD = 998244353;
// Fermat's little theorem を 適用し, 大きな冪乗の計算を行う.
// a の p乗 を 計算.
// @param a: べき乗したい正整数.
// @param b: 指数.
// @return:  べき乗した計算結果(mod版).
LL mPow(LL a, LL p){
    LL res = 1;
    while(p){
        if(p & 1) res = res * a % MOD;
        a = a * a % MOD;
        p >>= 1;
    }
    return res;
}
int X[111111];

int main(){
    
    // 1. 入力情報.
    int N, d0, d;
    scanf("%d %d", &N, &d0);
    X[d0]++;
    for(int i = 1; i < N; i++){
        scanf("%d", &d);
        X[d]++;
    }
    
    // 2. 条件を満たさない場合は終了.
    if(d0 != 0){
        printf("%d\n", 0);
        return 0;
    }
    
    // 3. 条件を満たす木を数える.
    // 連続する距離の小さい順に, d1, d2, d3, ... 個あったとして,
    // (d1 の d2)乗 × (d2 の d3)乗 × (d3 の d4)乗 × ... を 計算してみる.
    // 途中, 距離が歯抜けになったら, 条件を満たしていないと見て終了.
    LL ans = 1, bef = 1;
    int e = N - 1;
    for(int i = 1; i < 111111; i++){
        if(X[i - 1] > 0 && X[i] > 0){
            ans *= mPow(bef, (LL)X[i]);
            ans %= MOD;
            bef = (LL)X[i];
            e -= X[i];
        }else{
            break;
        }
    }
    
    // 4. 出力.
    if(e == 0) printf("%lld\n", ans);
    else       printf("%d\n", 0);
    return 0;
    
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
inline void read(long long &x)
{
    int i=1;
    x=0;
    char a=getchar();
    while(a<'0'||a>'9')
    {
        if(a=='-') i=-1;
        a=getchar();
    }
    while(a>='0'&&a<='9')
    {
        x=x*10+a-48;
        a=getchar();
    }
    x*=i;
}
inline void write(long long x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9) write(x/10);
    putchar(x%10+48);
}
long long t[100100];
int main()
{
	long long qw,z=0,x=0,times,a,b,f=0;
    read(qw);
	for(int i=1;i<=qw;i++)
	{
    	read(t[i]);
    	read(a);       
    	read(b);
    	times=t[i]-t[i-1];
    	int sum=a-z+b-x;
    	if(sum>times)
    	f=1;
    	else if((times-sum)%2!=0)
    	f=1;
    	else
    	{
    		z=a;
    		x=b;
    	}
    	if(f==1) break;
    }
    if(f==0) printf("Yes");
    else printf("No");
    return 0; 
}

Measured memory_bytes: 896
import heapq


def dijkstra_heap(s):
    d = [float("inf")] * n
    prev = [float("inf")] * n
    d[s] = 0
    edgelist = [[d[s], s]]
    heapq.heapify(edgelist)

    while edgelist:
        dis, v = heapq.heappop(edgelist)
        if d[v] < dis:
            continue

        for e in edge[v]:
            if d[e] > dis + 1:
                d[e] = dis + 1
                heapq.heappush(edgelist, [dis + 1, e])
                prev[e] = v
    return d, prev


n, w = map(int, input().split())

edge = [[] for i in range(n)]
for i in range(w):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    edge[x].append(y)
    edge[y].append(x)
d, prev = dijkstra_heap(0)

if float('inf') in prev[1:]:
    print('No')
else:
    print('Yes')
    for i in prev[1:]:
        print(i + 1)


Measured memory_bytes: 39992
#!/usr/bin/env PyPy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

def main():
    N,C=MI()
    T=10**5
    
    tc=[[0]*(T+1) for _ in range(C)]
    
    
    for i in range(N):
        s,t,c=MI()
        tc[c-1][s-1]+=1
        tc[c-1][t]-=1
        
    for c in range(C):
        for i in range(T):
            tc[c][i+1] +=tc[c][i]
            
    ans=0
    
    for i in range(T+1):
        temp=0
        for c in range(C):
            if tc[c][i]>0:
                temp+=1
        ans=max(ans,temp)
        
    print(ans)        
                    
        



main()


Measured memory_bytes: 71000
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;


struct Edge {
    ll from;
    ll to;
    ll cost;
    Edge(ll f, ll t, ll c) {
        from = f;
        to = t;
        cost = c;
    }
};


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

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

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

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

    bool unite(int x, int y) {
        int rx = root(x);
        int ry = root(y); 
        if (rx == ry) return false;
        if (size[rx] < size[ry]) swap(x, y);
        size[rx] += size[ry];
        par[ry] = rx; 
        return true;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

ll kruskal(vector<Edge> &edges, int V) {
    sort(edges.begin(), edges.end(), [](const Edge &a, const Edge &b) {
        return a.cost < b.cost;
    });
    UnionFind unionFind(V);
    ll res = 0;
    for (Edge& e: edges) {
        if (unionFind.unite(e.to, e.from)) {
            res += e.cost;
        }
    }
    return res;
}


void Main()
{
    ll n;
    cin >> n;

    vector<ll> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    vector<Edge> edges;

    typedef pair<ll, ll> P;

    vector<P> xp(x.size());
    rep(i, x.size()) xp[i] = P(x[i], i);
    sort(all(xp));    
    rep(i, xp.size() - 1) {
        edges.push_back(Edge(
            xp[i].second,
            xp[i+1].second,
            abs(xp[i].first - xp[i+1].first)
        ));
    }

    typedef pair<ll, ll> P;
    vector<P> yp(y.size());
    rep(i, y.size()) yp[i] = P(y[i], i);
    sort(all(yp));    
    rep(i, yp.size() - 1) {
        edges.push_back(Edge(
            yp[i].second,
            yp[i+1].second,
            abs(yp[i].first - yp[i+1].first)
        ));
    }

    ll res = kruskal(edges, n);
    put(res);
}
signed main(){ Main();return 0;}

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


using namespace std;


#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search  >
#define lower(arr,n,fixed) lower_bound(arr,arr+n,fixed)-arr  //Lower value search  >=
#define FOR(i,a,n) for(int i=a; i<(int)n; i++)
#define FORI(i,a,n) for(int i=a; i>=(int)n; i--)
#define pii pair<int,int>
#define vpii vector<pii>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0)
#define endl "\n"
#define all(a) a.begin(), a.end()
#define MEMSET(p,i) memset(p,i,sizeof(p))





int main(void)
{
	fastIO();

	int a, b;
	cin >> a >> b;

	int ans = a-1;
	if(b >= a)
		ans++;
	cout << ans << endl;
	

	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)


def unite(par, i, j):
    j = get_par(par, j)
    par[j] = get_par(par, i)

def get_par(par, p):
    while par[p] != p:
        p = par[p]
    return par[p]

def resolve():
    n,m = map(int, input().split())
    bridges = [list(map(lambda x: int(x)-1, input().split())) for i in range(m)]

    graph = {}
    # if a not in graph:
    #     graph[a] = {}
    # if b not in graph:
    #     graph[b] = {}
    # graph[a][b] = graph[b][a] = 1
    tmp = n * (n-1) // 2
    ans = [tmp]
    append=ans.append
    cnt = [1 for _ in range(n)]
    par = [i for i in range(n)]

    for i in range(m)[::-1]:
        a,b = bridges[i]
        aa = get_par(par, a)
        bb = get_par(par, b)
        if aa == bb:
            append(tmp)
            continue
        # unite
        tmp -= cnt[aa] * cnt[bb]
        append(tmp)
        if cnt[aa] > cnt[bb]:
            par[bb] = aa
            cnt[aa] += cnt[bb]
        else:
            par[aa] = bb
            cnt[bb] += cnt[aa]

    [print(i) for i in ans[:-1][::-1]]


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 36800
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i ++){
        cin >> a.at(i);
    }

    sort(a.begin(),a.end(),greater<int>());

    int alice = 0,bob = 0;

    for(int i = 0;i < n;i ++){
        if(i % 2 == 0) alice += a.at(i);
        else bob += a.at(i);
    }

    cout << alice - bob << endl;
}


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

struct sp {
    int idx;
    string s;
    int p;

    bool operator <(const sp& a) {
    if (s == a.s) {
        return p > a.p;
    } else {
        return s < a.s;
    }
}
    
};


int main(void)
{
    int n;
    cin >> n;
    vector<sp> v;
    for(int i = 0;i < n; i++) {
        string s;
        int p;
        cin >> s >> p;
        v.emplace_back(sp{i+1,s,p});
    }
    sort(v.begin(),v.end());

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#define INF 1000000007
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> P;


int main() {

	int a, b,c;
	cin >> a >> b >> c;
	if (a + b < c||a>c) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}

	return 0;
}




Measured memory_bytes: 764
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;


//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;


/*
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
*/
/*
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
*/

const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/

int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
       vll v(3);
       cin>>v[0]>>v[1]>>v[2];
       sort(all(v));
       cout<<(v[0]*v[1])/2<<endl;

   }
}












Measured memory_bytes: 3644
#include<stdio.h>

int main(void){

int a=0;

int W,H,x,y,r=0;

scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

if(x-r>=0&&x+r<=W){

if(y-r>=0&&y+r<=H){

a=1;

}

}

else{

a=0;

}

if(a==1){

printf("Yes\n");

}

else if(a==0){

printf("No\n");

}

return 0;

}

Measured memory_bytes: 584
import math

h, w, a, b = map(int, input().split())

#divmod
mod = pow(10,9)+7
def divmod(num, mod=10**9+7):
    return pow(num, mod-2, mod)

#combination
def comb(a,b):
	p=fact[a-b]*fact[b]%mod
	return fact[a]*divmod(p)%mod

fact = [1]
for i in range(1,h+w):
    fact.append(i*fact[i-1]%mod)
#print(fact)

ans = 0
for j in range(h-a):
    tmp = comb(b-1+j,j)*comb(w+h-b-2-j,w-b-1)%mod
    ans += tmp
    ans = ans%mod
#    ans = ans + fact[b-1+j]*fact[w+h-b-2-j]/fact[b-1]/fact[j]/fact[w-b-1]/fact[h-1-j]
print(int(ans))

'''
単純なh*wのマス目だった場合
#h-row / w-col
con = [[0]*w]*h
for i in range(h):
    con[i][0] = 1
for j in range(w):
    con[0][j] = 1

for k in range(1,h):
    for l in range(1,w):
        con[k][l] = con[k-1][l] + con[k][l-1]

print(con[h-1][w-1])
'''

'''
全量を計算するやり方
H*Wがデカすぎると時間というよりもメモリエラー
print('initialize')
con = [[0 for i in range(w)] for j in range(h)]
#リスト内包表記で作らないとバグる
#ダメな例 -> con = [[0]*w]*h
#https://qiita.com/utgwkk/items/5ad2527f19150ae33322
print('initialize finished')


for i in range(h-a):
    con[i][0] = 1
#print(con[0])
for j in range(w):
    #wは先に初期化やっちゃう
    con[0][j] = 1
#print(con)

for k in range(1,h-a):
#    print(k)
    for l in range(1,b+1):
        con[k][l] = con[k-1][l] + con[k][l-1]
#print(con[h-a-1][b-1])
#print(con[h-a][b-1])
#print(con[h-a-1][b])

for m in range(1,h):
#    print('---{} row---'.format(m))
#    print(con[m])
    for n in range(b,w):
#        print('m,n:('+str(m)+','+str(n)+')')
        con[m][n] = con[m-1][n] + con[m][n-1]
#    print(con[m])

print(con[h-1][w-1])
'''



Measured memory_bytes: 11052
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <string.h>
#include <vector>

using namespace std;
int main() {
    int A,B;
    cin >> A>>B;
    cout << (B%A == 0 ? A+B : B-A) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main(){
    int m, n;
    vector<string> s, t;
    cin >> n;
    string M, N;
    REP(i, n){
        cin >> N;
        s.push_back(N);
    }
    cin >> m;
    REP(i, m){
        cin >> M;
        t.push_back(M);
    }
    int max_ = 0;
    REP(i, n){
        int tmp = count(s.begin(), s.end(), s[i]) - count(t.begin(), t.end(), s[i]);
        max_ = max(max_, tmp);
    }
    print(max_);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define ALL(a) (a).begin(),(a).end()
#define EACH(e,v) for(auto& e:v)
#define SORT(v) sort(ALL(v))
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = 1000'000'007;
 
signed main(){
    int n;
    string s,t;
    cin>>n>>s>>t;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define nl '\n'
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int M = 1e9+7;
const int N = 2*1e5;

string s = "";

int main(){
    AC
    ll n;
    cin>>n;
    while(n>0){
        int m = n%26;
        if(m==0){
            s = 'z'+s;
            if((n-26)%26==0)
                n-=26;
        }
        else
            s = (char)('a'+(m-1)) + s;
        n/=26;
    }
    cout<<s<<endl;
}

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

ll x,y,tmp;

inline ll gcd(ll x,ll y)
{
	if(y==0)return x;
	return gcd(y,x%y);
}

int main()
{

	cin >>x>>y;

	ll g = gcd(x,y);

	for(ll i=2; i<= g / i; i++)
		if(g%i==0)
			{
				tmp++;
				while(g%i == 0) g /= i;
			}

	if(g>1)tmp++;
	cout<<tmp+1<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
string S;
  cin>>S;
  int N=S.size();
  vector<int>A(N-2);
  for(int i=0;i<N-2;i++){
  string s="";
    for(int j=0;j<3;j++){
    s+=S.at(i+j);
    }
    A.at(i)=stoi(s);
    
  
  }int Min=1000;
  for(int i=0;i<N-2;i++)
    if(abs(A.at(i)-753)<=Min)
       Min=abs(A.at(i)-753);
       cout<<Min<<endl;
   return 0;
}

Measured memory_bytes: 256
# import numpy
import sys

sys.setrecursionlimit(10**6)

digtmp = [[0, 1], [1, 1], [1, 0], [1, -1], [0, -1], [-1, -1], [-1, 0], [-1, 1]]

def dfs(i, j):
    global dfsflag
    if Mapdata[i][j] == 1 and Mapcheck[i][j] == 0:
        Mapcheck[i][j] = 1
        dfsflag = 1
        for tmp in digtmp:
            digh = i + tmp[0]
            digw = j + tmp[1]
            if 0 <= digh < h and 0 <= digw < w:
                dfs(digh, digw)
    else:
        Mapcheck[i][j] = 1

while True:
    w, h = map(int, input().split())
    if w == 0 and h == 0:
        break
    Mapdata = []
    for _ in range(h):
        tmp = list(map(int, input().split()))
        Mapdata.append(tmp)
    Mapcheck = [[0] * w for _ in range(h)]
    count = 0
    for i in range(h):
        for j in range(w):
            dfsflag = 0
            dfs(i, j)
            if dfsflag == 1:
                count += 1
    print(count)



Measured memory_bytes: 7964
import pprint
[r,c]=[int(item)for item in input().split()]

table = []

for i in range(r):
    row = [int(item)for item in input().split()]
    row.append(sum(row))
    table.append(row)

lastrow=[0 for _ in range(c+1)]
for row in table:
    for i,cell in enumerate(row):
        lastrow[i]+=cell

table.append(lastrow)

for row in table:
    print(*row)




Measured memory_bytes: 7228
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <list>
#include <bitset>
#include <fstream>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = (LL(n) - 1); i >= (a); --i)
#define EPS 1e-11
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT fixed << setprecision(16)
const double PI = 3.1415926535897932;

template <class T, class U>
istream& operator >> (istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
//sum, 累積和
// 負のときの割り算に注意
#if 1
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<class T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Suffix_Array.h"
#include "Matrix.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator >> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

int main() {
	string s;
	int k;
	cin >> s >> k;
	for (int i = 0; i < s.size(); i += k) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	int r, g ,b ;
	cin >> r>> g >>b ;
	int num = 100* r + 10 *g + b ;
	if(num %4){
		puts("NO");
	} else {
		puts("YES");
	}
}


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

int compare(const void *a, const void *b) {
	int ia = *(int *) a;
	int ib = *(int *) b;

	return ia - ib;
}

int main() {
	static int aa[3];
	int i;

	for (i = 0; i < 3; i++)
		scanf("%d", &aa[i]);
	qsort(aa, 3, sizeof *aa, compare);
	printf(aa[0] == 5 && aa[1] == 5 && aa[2] == 7 ? "YES\n" : "NO\n");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const long double PI = 3.14159265358979323846;  /* pi */

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

    int a, b;
    cin >> a >> b;
    cout << a * b;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <complex>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << "\n"
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[3000][3000];
char field[200][200];

ll max_p[1000010],min_p[1000010];

void func(){
  max_p[0] = min_p[0] = 0;
  rep(i,1,1000010){
    min_p[i] = max_p[i] = i;
    rep(j,1,1000010){
      // 正四面体
      ll test = j * (j + 1) * (j + 2) / 6;
      // インデックス
      if(i - test < 0)break;
      min_p[i] = min(min_p[i] ,min_p[i - test] + 1);
      if(test % 2)max_p[i] = min(max_p[i],max_p[i - test] + 1);
    }
  }
}

int main(){
  func();
  while(cin >> n,n){
    cout << min_p[n] << " " << max_p[n] << endl;
  }
  return 0;
}


Measured memory_bytes: 18628
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;

// B - Cut and Count
int main(){
    map<char, bool> bucket;
    int N;
    string S;

    cin >> N >> S;
    int ans = 0;
    for(int i=0;i<N;++i){
        int tmp_ans = 0;
        bucket.erase(bucket.begin(), bucket.end());
        // left side
        for(int j=0;j<i;++j){
            bucket.insert(make_pair(S[j], true));
        }
        // compare to right side
        for(int k=i;k<N;++k){
            if(bucket.find(S[k]) != bucket.end() && bucket[S[k]]){
                tmp_ans++;
                bucket[S[k]] = false;
            }
        }
        if(tmp_ans>ans){
            ans = tmp_ans;
        }
    }
        cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int aStart = sc.nextInt();
		int aEnd = sc.nextInt();
		int bStart = sc.nextInt();
		int bEnd = sc.nextInt();
		sc.close();

		int start = aStart > bStart ? aStart : bStart;
		int end = aEnd > bEnd ? bEnd : aEnd;

		int answer = end - start;

		if (aEnd < bStart || bEnd < aStart) {
			System.out.println("0");
		} else {
			System.out.println(answer);
		}

	}

}

Measured memory_bytes: 21844
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    double d;
    double t;
    double s;
    cin >> d >> t >> s;
    double res = d / s;
    if(res <= t)
    {
        cout << "Yes";
    }
    else if(res > t)
    {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0; i<n; i++)
    cin>>a[i];
  int b=1000;
  int c=0;
  for(int i=0; i<n; i++){
    b=min(b,a[i]);
    c=max(c,a[i]);
  }
  cout<<c-b<<endl;
}
    

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

void solve(){
    int n,w;
    cin>>n>>w;
    vector<ll>w1(n),v(n);
    for(int i=0;i<n;i++){
        cin>>w1[i]>>v[i];
    }
    vector<vector<ll>>dp(n+1,vector<ll>(w+1,0));
    for(int i=0;i<=n;i++){
        for(int j=0;j<=w;j++){
            if(i==0 or j==0)
                dp[i][j]=0;
            else if(w1[i-1]<=j){
                dp[i][j]=max(v[i-1]+dp[i-1][j-w1[i-1]],dp[i-1][j]);
            }
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    // for(int i=0;i<=n;i++){
    //     for(int j=0;j<=w;j++){
    //         cout<<dp[i][j]<<' '; 
    //     }
    //     cout<<endl;
    // }
    // cout<<endl;
    cout<<dp[n][w];
}

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

Measured memory_bytes: 80256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,k=map(int,readline().split())
    h=[0]*n
    for i in range(n):
        h[i]=int(readline())
    h.sort()

    ans=float("inf")
    for i in range(k-1,n):
        s=h[i]-h[i-k+1]
        ans=min(s,ans)

    print(ans)
    
if __name__=="__main__":
    main()

Measured memory_bytes: 7468
N, M = map(int, input().split())
X = [0] * (10 ** 5)

for i in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    X[a] += 1
    X[b] += 1

if all(map(lambda x: x % 2 == 0, X)):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
using ll=unsigned long long;
static const ll INF=10000000000000000000000;
ll N,X;
ll sum[200005];
ll x[200005];
ll a[200005];
int main(){
  cin>>N>>X;
  for(ll i=0;i<N;i++)
    cin>>x[i];
  for(ll i=1;i<=N;i++)
    sum[i]=sum[i-1]+x[i-1];
  a[0]=5;a[1]=5;
  for(ll i=2;i<=200004;i++)
    a[i]=a[i-1]+2;
  ll ans=INF;ll zero=0;
  for(ll i=1;i<=N;i++){
  ll t=i*X;
    for(ll j=0;j*i<=N;j++){
      if((j+1)*i<=N)
    t+=a[j]*(sum[N-i*j]-sum[N-(j+1)*i]);
      else
        t+=a[j]*(sum[N-i*j]-sum[0]);
    }if(t<ans)ans=t;
  }ans+=N*X;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 8280
#include<bits/stdc++.h>
using namespace std;
int A[100002];
int main(){
	int a,i;
	cin>>a;
	for(i=1;i<=a;i++)cin>>A[i];
	sort(A+1,A+a+1),cout<<A[a/2+1]-A[a/2];
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;


int main()
{
    int n,k;cin >> n >> k;
    vector<int> p(n);rep(i,n)cin >> p[i];
    sort(p.begin(),p.end());
    int sum = 0;
    rep(i,k)
    {
        sum += p[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define INF 10000000000000001
#define DIM 200001
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define T true
#define F false
#define endl "\n"
typedef char ch;
typedef bool boll;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef set < string > sst;
typedef set < long long > sl;
typedef queue < long long > que;
typedef vector < long long > vec;
typedef map < long long, long long > mll;
typedef pair < long long, long long > pll;
typedef vector < pair < long long, long long > > vpl;
typedef pair < long long, unsigned long long > pul;
ll  a[5][5],b[11],c[5][5],n,z,x,s;
int main()
{
    cin>>n;
    cout<<(n/2)+(n%2)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
   ll X; cin >> X;
   ll ansa, ansb;
   rep(i, 2000){
       rep(j, 2000){
           ll A = 1, B = 1;
           rep(ii, 5){
               A*=(i-1000);
           }
           rep(jj, 5){
               B*=(j-1000);
           }
           if(A-B==X){
               ansa=i-1000; ansb=j-1000; break;
           }
       }
   }
   cout << ansa << " " << ansb << endl;
}
    

Measured memory_bytes: 3620