akhauriyash/Code-Regression huggingface dataset:
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
typedef unsigned long ul;
typedef unsigned int ui;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int N,i,cnt[9],cnt2;
vector<int> a;

inline void solve(){
  IN(N);
  a.resize(N);
  REP(i,N){
    IN(a[i]);
    if(a[i]<400)cnt[0]++;
    else if(a[i]<800)cnt[1]++;
    else if(a[i]<1200)cnt[2]++;
    else if(a[i]<1600)cnt[3]++;
    else if(a[i]<2000)cnt[4]++;
    else if(a[i]<2400)cnt[5]++;
    else if(a[i]<2800)cnt[6]++;
    else if(a[i]<3200)cnt[7]++;
    else cnt[8]++;
  }
  REP(i,8)if(cnt[i])cnt2++;
  if(cnt2)cout<<cnt2;
  else cout<<1;
  if(!cnt[8])cout<<" "<<cnt2<<endl;
  // else cout<<" "<<min(9,cnt2+cnt[8])<<endl;
  else cout<<" "<<cnt2+cnt[8]<<endl;
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define ALL( a )        (a).begin(), (a).end()             

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

	int cnt = 0;
	while( t >= a ) {
		t -= a;
		cnt++;
	}

	cout << cnt * b << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <cmath>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)
int n;
vector<long long int> v;
long long int solve(int first_pon){
    long long int pon = first_pon, sum = 0, result = 0;
    REP(i,n){
        sum += v[i];
        if(pon>0&&sum>=0){
            result += sum + 1;
            sum = -1;

        }else if(pon<0&&sum<=0){
            result += (-sum) + 1;
            sum = 1;

        }
        if(sum>0){
            pon = 1;
        }else{
            pon = -1;
        }
    }
    return result;
}

int main(){

    
    cin >> n ;
    v = vector<long long int>(n);
    REP(i,n){
        cin >> v[i];
    }
    cout << min(solve(1), solve(-1)) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define mod 1000000007

int n;
vector<int> cnt;
vector<int> sumcnt;

int solve(int k) {
	int l = 0, r = n / k + 1;
	while (r - l > 1) {
		int m = (l + r) / 2;
		int overmind = lower_bound(cnt.begin(), cnt.end(), m) - cnt.begin();
		int overmnum = n - overmind;
		if (overmnum >= k) {
			l = m;
			continue;
		}
		int restind = overmind - (k - overmnum);
		int rest = sumcnt[overmind] - sumcnt[restind];
		int need = m * (k - overmnum) - rest;
		if (sumcnt[restind] >= need) {
			l = m;
		} else {
			r = m;
		}
	}
	return l;
}

int main() {
	cin >> n;
	cnt = vector<int>(n, 0);
	sumcnt = vector<int>(n + 1, 0);
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		a--;
		cnt[a]++;
	}
	sort(cnt.begin(), cnt.end());
	for (int i = 1; i <= n; i++) {
		sumcnt[i] = sumcnt[i - 1] + cnt[i - 1];
	}
	for (int k = 1; k <= n; k++) {
		cout << solve(k) << endl;
	}
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  T="abcdefghijklmnopqrstuvwxyz";
  S="";
  rep(i,0,1){
    if(N==1)Out(T[i]);
    else rep(j,0,i+2){
      if(N==2)Out(S+T[i]+T[j]);
      else rep(k,0,j+2){
        if(N==3)Out(S+T[i]+T[j]+T[k]);
        else rep(l4,0,max(max(i,j),k)+2){
          if(N==4)Out(S+T[i]+T[j]+T[k]+T[l4]);
          else rep(l5,0,max(max(i,j),max(k,l4))+2){
            if(N==5)Out(S+T[i]+T[j]+T[k]+T[l4]+T[l5]);
            else rep(l6,0,max(l5,max(max(i,j),max(k,l4)))+2){
              if(N==6)Out(S+T[i]+T[j]+T[k]+T[l4]+T[l5]+T[l6]);
              else rep(l7,0,max(max(l5,l6),max(max(i,j),max(k,l4)))+2){
                if(N==7)Out(S+T[i]+T[j]+T[k]+T[l4]+T[l5]+T[l6]+T[l7]);
                else rep(l8,0,max(max(l5,max(l6,l7)),max(max(i,j),max(k,l4)))+2){
                  if(N==8)Out(S+T[i]+T[j]+T[k]+T[l4]+T[l5]+T[l6]+T[l7]+T[l8]);
                  else rep(l9,0,max(max(max(l5,l8),max(l6,l7)),max(max(i,j),max(k,l4)))+2){
                    if(N==9)Out(S+T[i]+T[j]+T[k]+T[l4]+T[l5]+T[l6]+T[l7]+T[l8]+T[l9]);
                    else rep(l0,0,max(max(l9,max(max(l5,l8),max(l6,l7))),max(max(i,j),max(k,l4)))+2){
                      Out(S+T[i]+T[j]+T[k]+T[l4]+T[l5]+T[l6]+T[l7]+T[l8]+T[l9]+T[l0]);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,ans= "";
  while(cin>>s){
    auto it = string::npos;
    if((it = s.find("apple")) != string::npos){
      s.replace(it,5,"peach");
    }
    else if((it = s.find("peach")) != string::npos){
      s.replace(it,5,"apple");
    }
    ans += s + " ";
  }
  ans.resize(ans.size()-1);
  cout << ans << endl;
  return 0;
}

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

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

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

using namespace std;

int main(){

    int n;
    cin >> n;
    vector<pair<pair<string, int>, int>> arr(n);
    for(int i = 0; i < n; i++){
        cin >> arr[i].first.first >> arr[i].first.second;
        arr[i].first.second *= -1;
        arr[i].second = i+1;
    }

    sort(arr.begin(), arr.end());
    for(int i = 0; i < n; i++)
        cout << arr[i].second << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;

int main() {
	int a, b, c, n, t[3], s,ss;
	cin >> n;
	for (n; n > 0; n--) {
		cin >> a >> b >> c;
		 t[0]=a;
		if (t[0] < b) {
			t[1] = t[0];
			t[0] = b;
		}
		else t[1] = b;
		if (t[0] <c) {
			t[2] = t[1];
			t[1] = t[0];
			t[0] = c;
		}else if(t[1] <c) {
			t[2] = t[1];
			t[1] = c;
		}
		else t[2] = c;
		s = t[1] * t[1] + t[2] * t[2];
		ss = t[0] * t[0];
			if (s == ss) {
			cout << "YES"<<endl;
		}else cout << "NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3104
A, B, C, X, Y = gets.strip.split.map(&:to_i)

maximum_price = 
  if X < Y
    C*2*Y
  else
    C*2*X
  end

reduced_price =
  if X < Y
    maximum_price-(C*2*(Y-X))+(B*(Y-X))
  else
    maximum_price-(C*2*(X-Y))+(A*(X-Y))
  end

result = 
  if reduced_price < maximum_price
    reduced_price
  else
    maximum_price
  end

single_price = A*X+B*Y

result = single_price if single_price < result

#  puts(maximum_price)
#  puts(reduced_price)
  puts(result)


Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pp pair<ll,ll>
#define vi vector<pair<pp,pp> >
#define pq_min priority_queue<ll,vector<ll>,greater<ll> >
#define pq_max priority_queue<ll>
#define forx(i,a,b) for(ll i=0;i<a;i++)
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define ld long double
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef pair<pp,pp> ppll;
const ll mod=1e9 + 7;
const ll N = 1e5 + 5;
ll FactNumInv[N+1];
ll NaturalNumInv[N+1];
ll fact[N+1];

void InvofNumber(ll p)
{
   NaturalNumInv[0]=1;
   NaturalNumInv[1]=1;
   
   for(ll i=2;i<=N;i++)
   {
   	  NaturalNumInv[i] = (NaturalNumInv[p%i] * (p - p/i) )%p;
   }
} 

void InvofFactorial(ll p)
{
	FactNumInv[0]=1;
	FactNumInv[1]=1;
	for(ll i=2;i<=N;i++)
	{
		FactNumInv[i] = (NaturalNumInv[i] * FactNumInv[i-1])%p;
	}
}

void factorial(ll p)
{
	fact[0]=1;
	for(ll i=1;i<=N;i++)
	{
		fact[i] = (fact[i-1] * i)%p;
	}
}

ll nCrModp(ll n,ll r,ll p)
{
    if ( r == 0 || n == 0) return 1;
    if ( r == 1 ) return n;
	ll ans = ((fact[n] * FactNumInv[r])%p * FactNumInv[n-r])%p;
	return ans;
}



int main()
{
	fast;
    ll n,m;
    cin>>n>>m;
    ll a[n];
    InvofNumber(mod);
    InvofFactorial(mod);
    factorial(mod);
    for(ll i=0;i<n;i++)
    {
    	cin>>a[i];
	}
	sort(a,a+n);
	ll sum=0;
	ll h=n-2;
	ll ans=0,ans2=0;
	ll s=h;
	for(ll i=m-2;i<=h;i++)
	{
		sum = (sum + nCrModp(i,m-2,mod) )%mod;
	}
	ll g=sum;
	for(ll i=n-1;i>=m-1;i--)
	{
		ans = (ans%mod + ((a[i] * sum + mod )%mod) )%mod;
	//	ll d = ;
		sum = (sum -(nCrModp(s,m-2,mod)%mod) + 2*mod)%mod;
		s--;
	}
	//cout<<ans<<" ";
	sum=g%mod;
	s=h;
	for(ll i=0;i<=n-m;i++)
	{
		ans2 = (ans2%mod + (( ((a[i]*sum)%mod) + mod)%mod))%mod;
		sum = (sum - nCrModp(s,m-2,mod) + 2*mod)%mod;
		s--;
	}
	cout<<(ans - ans2 + 2*mod)%mod;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+7;

ll n,x;
ll a[N],b[N];
ll gcd(ll a,ll b){
  if(b%a == 0) return a;
  else gcd(b%a,a);
}

int main(){

  //sortして隣の差の最大公約数を求める
  cin >> n >> x;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  a[n] = x;
  sort(a,a+n+1);

  if(n == 1){
    cout << a[1] - a[0] << endl;
    return 0;
  }

  ll ans = 1e9;
  for(int i = 0; i < n-1; i++){
    ll res = gcd(a[i+1]-a[i],a[i+2]-a[i+1]);
    ans = min(ans,res);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
	T f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = N << 2;

int n, a[N], cnt, b[N];
int ton[N];
map <int, bool> p;

int main()
{
	//File("");
	n = gi <int> ();
	for (int i = 1; i <= n; i+=1)
	{
		a[i] = gi <int> ();
		if (!p[a[i]]) p[a[i]] = true, b[++cnt] = a[i];
	}
	sort(a + 1, a + 1 + n);
	sort(b + 1, b + 1 + cnt);
	int now = n;
	for (int i = 1; i <= n; i+=1) ++ton[a[i]];
	vector <int> v;
	for (int i = 1; i <= cnt; i+=1) if (ton[b[i]] >= 2) v.push_back(b[i]);
	for (int i = 1; i <= n; i+=1)
	{
		if (ton[b[i]] <= 1) continue;
		int x = ton[b[i]] % 2;
		if (x == 1) now -= ton[b[i]] - 1;
		else
		{
			auto y = lower_bound(v.begin(), v.end(), b[i] + 1);
			if (y != v.end())
			{
				int yy = *y;
				--ton[yy];
				now -= ton[b[i]];
				if (ton[yy] <= 1) v.erase(y);
			}
			else now -= ton[b[i]];
		}
	}
	printf("%d\n", now);
	return 0;
}


Measured memory_bytes: 9552
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int a, b;

    cin >> a >> b;

    if (a < b) {
        cout << 0 << endl;
    }
    else {
        cout << a-b << endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
long gcd(long a,long b){
    if(a<b){
        long t=a;
        a=b;
        b=t;
    }
    while(b!=0){
        long t=a;
        a=b;
        b=t%b;
    }
    return a;
}
int main(){
    int a,b;
    while(~scanf("%d%d",&a,&b)){
        long g=gcd(a,b);
        long l=a/g*b;
        printf("%ld %ld\n",g,l);
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
using namespace std;
long long ax[100005];
long long a,b,n;

long long gaoshi (long long L,long long R){
    long long mid = (L+R)/2,i,j,k=0;
    if(L==R)return L;
    for(i=0;i<n;i++){
        j = ax[i] - b*mid;
        if(j>0){
          k += j/(a-b);
          if(j%(a-b)!=0)k++;
        }
    }
    if(k>mid) return gaoshi(mid+1,R);
    return gaoshi(L,mid);
}

int main()
{
    long long i,res;
    scanf("%lld%lld%lld",&n,&a,&b);
    for(i=0;i<n;i++){
        scanf("%lld",&ax[i]);
    }
    res = gaoshi(1,(long long)1e9);
    printf("%lld",res);
    return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

const uint64_t MOD = 1000000000 + 7;

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

	int64_t bx = b / x;
	int64_t ax = ((a - 1) / x);
	if (a == 0 && ax == 0)
	{
		ax = -1;
	}
	cout << bx- ax << endl;
}

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

//template
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define repr(i,n) for(ll i=n;i>0;i--)
#define all(v) v.begin(),v.end()
#define in cin>>
#define out cout<<
#define en <<endl
const ll INF = 10000000000000;

int main()
{
	char x;
	in x;
	out (char)(x+1) en;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, '%d %d %d %d', $A, $B, $C, $D);

$takahashi = false;
while ($A > 0 && $C > 0) {
    $takahashi = !$takahashi;
    if ($takahashi) {
        $C -= $B;
    } else {
        $A -= $D;
    }
}

if ($takahashi) {
    echo 'Yes';
} else {
    echo 'No';
}

echo PHP_EOL;


Measured memory_bytes: 16156
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define F first
#define S second
#define fast_io ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int N=4e2+10,LN=30;
const int MOD=1000000007 /*998244353*/;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using pll=pair<ll,ll>;
using pii=pair<int,int>;
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update>
ll pow(ll x, ll y, ll mod){
    if(y==0) return 1;
    if(y==1) return x%mod;
    ll a=y/2,b=1;
    if(y%2) b=x;
    return pow(x*x%mod,a,mod)*b%mod;
}
ll n,c,dp[N][N],s[N][N],a[N],b[N],p[N][N];
int main() {
    fast_io;
    cin >> n >> c;
    for(ll i=1; i<=400; i++) p[i][0]=1;
    for(ll i=1; i<=400; i++){
        for(ll j=1; j<=400; j++) p[i][j]=p[i][j-1]*i%MOD;
    }
    for(ll i=0; i<n; i++) cin >> a[i];
    for(ll i=0; i<n; i++) cin >> b[i];
    for(ll i=0; i<n; i++){
        for(ll j=0; j<=c; j++){
            for(ll k=a[i]; k<=b[i]; k++) s[i][j]+=p[k][j],s[i][j]%=MOD;
        }
    }
    for(ll j=0; j<=c; j++) dp[0][j]=s[0][j];
    for(ll i=1; i<n; i++){
        for(ll j=0; j<=c; j++){
            for(ll k=0; k<=j; k++){
                dp[i][j]+=dp[i-1][j-k]*s[i][k]%MOD;
                dp[i][j]%=MOD;
            }
        }
    }
    cout << dp[n-1][c];
    return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;
struct A {
    int l, r, x;
    bool operator<(const A& a) const {
        return x < a.x;
    }
}a[N];
int ans[N];
int main() {
    int n, q;
    cin >> n >> q;
    for(int i = 0; i < n; i++) {
        cin >> a[i].l >> a[i].r >> a[i].x;
    }
    sort(a, a + n);
    typedef pair<int, int> pa;   
    set<pa> st;
    for(int i = 0, t; i < q; i++) {
        cin >> t;
        st.insert(pa(t, i));
        ans[i] = -1;
    }
    for(int i = 0; i < n; i++) {
        int l = max(0, a[i].l - a[i].x), r = a[i].r - a[i].x; // [l, r)
        auto it = st.lower_bound(pa(l, 0));
        while(it != st.end()) {
            auto nxt = next(it);
            if(it->first >= r) {
                break;
            }
            ans[it->second] = a[i].x;
            st.erase(it);
            it = nxt;
        }
    }
    for(int i = 0; i < q; i++) {
        cout << ans[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 14976
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()

int main(){
	int N,K;cin>>N>>K;
	if(K>1){
	    cout<<N-K<<endl;
	}else{
		cout<<0<<endl;
	}
}


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

using namespace std;

int main(void) {
	string s,p;
	getline(cin,s);
	getline(cin,p);
	bool find = false;
	int slen = s.length();
	int plen = p.length();
	for (int i = 0; !find && i < slen; ++i) {
		bool seq = true;
		for (int j = 0; seq && j < plen; ++j) {
			if (s[(i+j)%slen] != p[j]) {
				seq = false;
			}
		}
		if (seq) {
			find = true;
		}
	}
	if (find) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
#include <math.h>
#define lli long long int
#include <limits.h>
#include <math.h>

using namespace std;

/*lli gcd(lli a,lli b)
{
	if(a==0)return b;
	return gcd(b%a,a);
}*/

int main()
{
    /*ios_base::sync_with_stdio(false);
    cin.tie(NULL);*/
    lli a,b,n,ans;
    cin>>a>>b>>n;
    if(n>=b)
    {
        cout<<a*(b-1)/b<<endl;
    }
    else
        cout<<a*n/b<<endl;
    return 0;
}


Measured memory_bytes: 3632
import heapq
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

low = 0
high = 10**9

if k == 0:
    print(max(a))
    exit()

    
while low+1 < high:
    tmp = 0
    mid = (low + high) //2
    
    for i in range(n):
        tmp += ((a[i]+mid-1) // mid)-1
        
    if tmp <= k:
        high = mid
    else:
        low = mid
        
print(high)


Measured memory_bytes: 93656
# -*- coding: utf-8 -*-
# 入力
n, m = map(int, input().split())
a = [int(n) for n in input().split()]

# 出力
a = sorted(a, reverse=True)
sum = sum(a)

for i in range(m):
  if a[i] < (sum / (4 * m)): 
    print("No")
    exit()

print("Yes")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;



int main() {

	int n;
	cin >> n;
	vector<int> t(n+1);
	vector<int> x(n+1);
	vector<int> y(n+1);

	for (int i = 1; i <=n;i++) {
		cin >> t[i] >> x[i] >> y[i];
	}

	bool canTravel = true;
	for (int i = 1; i <= n;i++) {
		int dis = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
		if (t[i] - t[i - 1] < dis) {
			canTravel = false;
			break;
		}
		if ((t[i] - t[i - 1] )% 2 != dis % 2) {
			canTravel = false;
			break;
		}
	}

	cout << (canTravel ? "Yes" : "No") << endl;

}

Measured memory_bytes: 1408
def dfs(v, visited):
    """
    :param v: X側の未マッチングの頂点の1つ
    :param visited: 空のsetを渡す（外部からの呼び出し時）
    :return: 増大路が見つかればTrue
    """
    for u in edges[v]:
        if u in visited:
            continue
        visited.add(u)
        if matched[u] == -1 or dfs(matched[u], visited):
            matched[u] = v
            return True
    return False


n = int(input())
r_ls = []
b_ls = []

for i in range(n):
    a, b = map(int, input().split())
    r_ls.append((a, b))

for i in range(n):
    c, d = map(int, input().split())
    b_ls.append((c, d))

edges = [set() for _ in range(n)]
matched = [-1] * n

for i in range(len(r_ls)):
    for j in range(len(b_ls)):
        if r_ls[i][0] < b_ls[j][0] and r_ls[i][1] < b_ls[j][1]:
            edges[i].add(j)

print(sum(dfs(s, set()) for s in range(n)))


Measured memory_bytes: 3188
#include<stdio.h>
#include<ctype.h>

int main()
{
    char ch[1200];
    int count=0;
    while(1){
        scanf("%c",&ch[count]);
        if(ch[count]=='\n')
            break;
            if('a'<=ch[count]&&ch[count]<='z'){
                ch[count]-=32;
            }else if('A'<=ch[count]&&ch[count]<='Z'){
                ch[count]+=32;
            }
        printf("%c",ch[count]);
        count+=1;
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2624
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#include <boost/multiprecision/cpp_int.hpp> 
using boost::multiprecision::cpp_int; 
#define FIO           	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


void solve()
{
	int n; cin >> n;
	cpp_int a[n];cpp_int res = 1;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a, a+n);
	for(int i = 0; i < n; i++)
	{
		
		res = res*a[i];
		if(res > 1000000000000000000)
		{
			cout << -1 << endl;
			return;
		}
	}
	cout << res << endl;
 
}
 
int32_t main()
{
	FIO
    
    {
    	solve();
    }
    return 0;
}

Measured memory_bytes: 6852
#include <iostream>
#define ll long long int
using namespace std;

ll calc(int i, int j, int k, int **cc, int c, int** D){
	ll result = 0;
	for(int x = 0; x < 3; x++){
			for(int y = 0; y < c; y++){
					if(x == 0){
							result += cc[x][y] * D[y][i];
					}else if(x == 1){
							result += cc[x][y] * D[y][j];
					}else{
							result += cc[x][y] * D[y][k];
					}
			}
	}
	return result;
}

int main(int argc, char const* argv[])
{
	
	int n, c;
	cin >> n >> c;
	int **D = new int*[c];
	int* cc[3];
	for(int i = 0; i < 3; i++){
			cc[i] = new int[c];
	}
	for(int i = 0; i < c; i++){
			D[i] = new int[c];
			for(int j = 0; j < 3; j++){
					cc[j][i] = 0;
			}
			for(int j = 0; j < c; j++){
					cin >> D[i][j];
			}
	}
	for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
					int a;
					cin >> a;
					if((i + j + 2) % 3 == 0){
							cc[0][a - 1] += 1;
					}else if((i + j + 2) % 3 == 1){
							cc[1][a - 1] += 1;
					}else{
							cc[2][a - 1] += 1;
					}
			}
	}
	ll least = 100000000001;
	for(int i = 0; i < c; i++){
			for(int j = 0; j < c; j++){
					if(i == j)continue;
					for(int k = 0; k < c; k++){
							if(i == k || j == k)continue;
							ll result = calc(i, j, k, cc, c, D);
							if(result < least)least = result;
					}
			}
	}
	cout << least << endl;
	return 0;
}


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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
constexpr int mod = 1e9 + 7;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
  friend ostream &operator<<(ostream &os, const mint &a) { return (os << a.x); }
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {

  int n;
  cin >> n;
  vector<int> x(n);
  int mod2 = 0;
  int mod4 = 0;
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
    if (x[i] % 2 == 0) {
      ++mod2;
      if (x[i] % 4 == 0) { ++mod4; }
    }
  }
  mod2 -= mod4;

  if (mod4 >= n / 2 || mod2 >= n || (mod4 * 2 + (n % 2) + mod2) >= n) {
    cout << "Yes";
  } else
    cout << "No";
  cout << endl;
}


Measured memory_bytes: 640
def gcd(a,b):
  ret = d[a][b]
  if ret != 0:
    return ret
  while b:
    a,b = b,a%b
  d[a][b] = a
  d[b][a] = a
  
  return a

def gcd2(A):    
  ret = gcd(gcd(A[0],A[1]),A[2])    
  return ret

n = int(input())

d = [[0]*(n+1) for _ in range(n+1)]

ans = 0
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      ans += gcd(gcd(i,j),k)

print(ans)

Measured memory_bytes: 69616
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,k,i,j,h[200000],cnt;
	long long sum;
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	sort(h,h+n);
	cnt=k;
	sum=0;
	for(i=n-1;i>=0;i--){
		if(cnt<=0){
			sum+=h[i];
		}
		else{
			cnt--;
		}
	}
	printf("%lld\n",sum);
	return 0;
}
	

Measured memory_bytes: 896
import numpy as np
n=int(input())
s=list(input())
dp=np.ones(1,dtype=np.int64)
mod=10**9+7
for c in s:
    d=np.zeros(len(dp)+1,dtype=np.int64)
    if c=='<':
        d[1:]=dp.cumsum(dtype=np.int64)%mod
    else:
        d[:-1]=np.cumsum(dp[::-1],dtype=np.int64)[::-1]%mod
    dp=d
print(sum(dp)%mod)

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

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

    if (c >= a && c <= b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] iArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long N = iArray[0];
            long D = iArray[1];
            long[,] point = new long[N, D];
            int cnt = 0;
            for (int p = 0; p < N; p++)
            {
                long[] tmpArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
                for(int t = 0; t < D; t++)
                {
                    point[p, t] = tmpArray[t];
                }
            }
            
            for (int i = 0;i < N; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    long sum = 0;
                    for (int z = 0; z < D; z++)
                    {
                         sum += (long)Math.Pow(point[i, z] - point[j, z], 2);
                    }
                  	long b = (long)Math.Sqrt(sum);
                    if (sum == b * b)
                    {
                        cnt++;
                    }
                }
            }
            Console.WriteLine(cnt);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


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

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 1001;
  for(int i = 0; i <= (int(s.size() - t.size())); ++i) {
    int temp = 0;
    for(int j = i, p = 0; j < i + (int)t.size(); ++j, ++p) temp += s[j] != t[p];
    //cout << temp << endl;
    ans = min(ans, temp);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <fstream>
#include <string> 
#include <cstring>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
//#include <boost/multiprecision/cpp_int.hpp>

#define BIT(a) (1 << (a))
#define EPS (1e-10)

using namespace std;
//using namespace boost::multiprecision;

const long long MOD = 1000000007;
const int COUNTER_CLOCKWISE = 1;
const int CLOCKWISE = -1;
const int ONLINE_BACK = 2;
const int ONLINE_FRONT = -2;
const int ON_SEGMENT = 0;

class Point{
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}
    
    Point operator+(Point p){return Point(x + p.x, y + p.y);}
    Point operator-(Point p){return Point(x - p.x, y - p.y);}
    Point operator*(double a){return Point(a * x, a * y);}
    Point operator/(double a){return Point(x / a, y / a);}

    bool operator < (const Point &p) const {
        return y != p.y ? y < p.y : x < p.x;
    }

    double norm(){return x * x + y * y;}
};
typedef Point Vector;
typedef vector<Vector> Polygon;

double cross(Vector a, Vector b){
    return a.x*b.y - a.y*b.x;
}

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

int ccw(Point p0, Point p1, Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (cross(a, b) > EPS)return COUNTER_CLOCKWISE;
    if (cross(a, b) > -EPS)return CLOCKWISE;
    if (dot(a, b) < -EPS)return ONLINE_BACK;
    if (a.norm() < b.norm())return ONLINE_FRONT;

    return ON_SEGMENT;
}

Polygon andrewScan(Polygon s){
    Polygon u, l;
    if (s.size() < 3) return s;
    sort(s.begin(), s.end());
    u.push_back(s[0]);
    u.push_back(s[1]);
    l.push_back(s[s.size()-1]);
    l.push_back(s[s.size()-2]);
    
    for (size_t i = 2; i < s.size(); i++){
        for (size_t n = u.size(); n >= 2 && ccw(u[n-2], u[n-1], s[i]) == COUNTER_CLOCKWISE; n--){
            u.pop_back();
        }
        u.push_back(s[i]);
    }

    for (int i = (int)s.size() - 3; i >= 0; i--){
        for (size_t n = l.size(); n >= 2 && ccw(l[n-2], l[n-1], s[i]) == COUNTER_CLOCKWISE; n--){
            l.pop_back();
        }
        l.push_back(s[i]);
    }

    reverse(l.begin(), l.end());
    for (size_t i = u.size() - 2; i >= 1; i--) l.push_back(u[i]);

    return l;
}

long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}


int main(void){
    int mountain[15];
    for (int i = 0; i < 10; i++){
        cin >> mountain[i];
    }
    sort(mountain, mountain+10);
    for (int i = 9; i > 9 - 3; i--){
        cout << mountain[i] << endl;
    }
    return 0;
}   



Measured memory_bytes: 3152
#include <iostream>
#include <vector>

using namespace std;

long long int N, cnt[6] = {}, ans = 0;
char S[20] = {};
vector<bool>flag;

void solve(long long int cur, long long int num,vector<bool>flagS) {
	if (num < 3) {
		if (3 - num < 6 - cur)solve(cur + 1, num, flagS);
		flagS[cur] = true;
		solve(cur + 1, num + 1, flagS);
	}
	else {
		long long int box = 1;
		for (int i = 1; i <= 5; i++) {
			if (flagS[i])box *= cnt[i];
		}
		ans += box;
	}
}

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> S;
		if (S[0] == 'M')cnt[1]++;
		if (S[0] == 'A')cnt[2]++;
		if (S[0] == 'R')cnt[3]++;
		if (S[0] == 'C')cnt[4]++;
		if (S[0] == 'H')cnt[5]++;
	}
	for (int i = 1; i <= 6; i++)flag.push_back(false);
	solve(1, 0, flag);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    for(int i=0;i<=2000;i++){
        int x=i*0.08;
        int y=i*0.1;
        if(x==a&&y==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
const long long MOD =1000000000+7;
int main(){
	int n;
	cin >>n;
	int ans=INF;
	vector<vector<int>>dp(2,vector<int>(6000000,INF));
	for(int i=0;i<n+3;i++){
		dp[0][i]=i;
		ans=dp[0][n];
	}
	int plse=6;
	int kindcount=0;
	while(plse <=n+1){
		kindcount = (kindcount + 1) % 2;
		for(int i=0;i<=n+1;i++){
			if(i >=plse){
				chmin(dp[kindcount][i],dp[kindcount==1?0:1][i-plse]+1);
				chmin(dp[kindcount][i], dp[kindcount][i - plse] + 1);
			
			}else{
				chmin(dp[kindcount][i], dp[kindcount == 1 ? 0 : 1][i]);
			}
		//	cout <</* i << " -" <<*/ dp[kindcount][i] << " ";
			ans=ans< dp[kindcount][n]?ans:dp[kindcount][n];
		}
		plse*=6;
		//cout<<endl;
	}
	plse=9;
	while (plse <= n+1)
	{
		kindcount = (kindcount + 1) % 2;
		for (int i = 0; i <= n + 1; i++)
		{
			if (i >= plse)
			{
				chmin(dp[kindcount][i], dp[kindcount == 1 ? 0 : 1][i - plse] + 1);
				chmin(dp[kindcount][i], dp[kindcount][i - plse] + 1);
			}
			else
			{
				chmin(dp[kindcount][i], dp[kindcount == 1 ? 0 : 1][i]);
			}
			//cout <</* i << " -" <<*/ dp[kindcount][i] << " ";
			ans = ans < dp[kindcount][n] ? ans : dp[kindcount][n];
		}
		plse *= 9;
		//cout<<endl;
	}
	//for(int i=0;i<=n;i++){
	//	cout <<dp[kindcount][i]<<endl;
	//}
	cout <<min(ans,dp[kindcount][n])<<endl;
}


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

int main () {
  int a, b, c, t;
  cin >> a >> b >> c;
    
    if ( a > b ) { t = a; a = b; b = t; }
    if ( b > c ) { t = b; b = c; c = t; }
    if ( a > b ) { t = a; a = b; b = t; }
    
    cout << a << " " << b << " " << c << endl;
    
    return 0;
}    

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

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define d7 1000000007
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++)
        {if (j == 0 || j == i) C[i][j] = 1;
            else C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}
    return C[n][k];
 }

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

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}

ll kk=1;
void dfsi(vector<bool> &vis, vector<ll> adj1[], ll n, ll start, vector<ll> &pre, vector<ll> &pos){
    vis[start]=true;
    pre[start]=kk;kk++;
    for(ll i: adj1[start]){
        if(!vis[i]){
            vis[i]=true;
            dfsi(vis,adj1,n,i,pre,pos);
        }
    }
    pos[start]=kk;kk++;
}

void bfsi(vector<ll> &dis, vector<ll> adj[], ll s, vector<ll> &parent){
    dis[s]=-1;
    queue<ll> q;
    q.push(s);
    while(!q.empty()){
        ll z=q.front();
        q.pop();
        for(ll v:adj[z]){
            if(dis[v]==0){
            q.push(v);
            dis[v]=-dis[z];
                parent[v]=z;}
        }
    }
}

void make_set(ll v, vector<ll> &parent, vector<ll> &krank) {
    parent[v] = v;
    krank[v] = 0;
}

ll find_set(ll v,vector<ll> &parent, vector<ll> &krank) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v], parent, krank);
}

void union_sets(ll a, ll b,vector<ll> &parent, vector<ll> &krank) {
    a = find_set(a,parent,krank);
    b = find_set(b,parent,krank);
    if (a != b) {
        if (krank[a] < krank[b])
            swap(a, b);
        parent[b] = a;
        if (krank[a] == krank[b])
            krank[a]++;
    }
}

void dijkstra(ll s, vector<ll> &dist, vector<ll> &parent, ll n, vector<pair<ll,ll>> adj[]){
    dist[s]=0;
    vector<bool> u(n,false);
    fori(n){
        ll v=-1;
        forj(n){
            if(!u[j] &&(v==-1||(dist[j]<dist[v]))) v=j;
        }
        if(dist[v]==d7) break;
        u[v]=true;
        for(auto j:adj[v]){
            ll a,b;
            a=j.first;
            b=j.second;
            if(dist[v]+b<dist[a]){
                dist[a]=dist[v]+b;
                parent[a]=v;
            }
        }
    }
}


int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
// code now
   
    ll n,k;
    cin>>n>>k;
    if(n%k==0){cout<<n/k;}
    else{cout<<n/k+1;}
    
//code ends
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

S = input().strip()
N = len(S) + 1
incre = [0] * N
decre = [0] * N
sum_a = 0

t = 0
for i, s in enumerate(S):
    if s == '<':
        t += 1
        incre[i + 1] = t
    else:
        t = 0

t = 0
for i, s in enumerate(S[::-1]):
    if s == '>':
        t += 1
        decre[-(i + 2)] = t
    else:
        t = 0

for i, (inc, dec) in enumerate(zip(incre, decre)):
    if inc < dec:
        incre[i] = dec

print(sum(incre))

Measured memory_bytes: 27692
#include<iostream>
#include<bits/stdc++.h>
#include<vector>
#include<numeric>
using namespace std;
#define ll long long
int main(){
    ll x,y,r,g,c,i,result=0,j;
    vector <ll> red;
    vector <ll> green;
    vector <ll> colorless;
    vector <ll> temp;
    cin>>x>>y>>r>>g>>c;
    for(i=0;i<r;i++){
    cin>>j;red.push_back(j);}
    sort(red.rbegin(),red.rend());
    for(i=0;i<g;i++){
    cin>>j;green.push_back(j);}
    sort(green.rbegin(),green.rend());
    for(i=0;i<c;i++){
    cin>>j;colorless.push_back(j);}
    sort(colorless.rbegin(),colorless.rend());
    for(i=0;i<x;i++)temp.push_back(red[i]);
    for(i=0;i<y;i++)temp.push_back(green[i]);
    for(i=0;i<c;i++)temp.push_back(colorless[i]);
    sort(temp.rbegin(),temp.rend());
 for(i=0;i<x+y;i++)result+=temp[i];
   cout<<result;
   return 0;
}


Measured memory_bytes: 8816
#include<stdio.h>
#include<iostream>
using namespace std;
#define MAX 105

int N; /* size of matrix */
long long M[ MAX ][ MAX ]; /* input matrix */
long long T[ MAX + 1 ]; /* 1 array matrix for DP */
long long S[ MAX + 1 ]; /* cost table for DP */
long long max_value;

void read(){
  cin >> N;

  for ( int i = 1; i <= N; i++ ){
    for ( int j = 1; j <= N; j++ ){
      cin >> M[i][j];
    }
  }
}

/* find maximum sum by DP */
void find_max(){
  S[0] = 0;
  long long current_max = -1000000000;

  for ( int i = 1; i <= N; i++ ){
    if ( S[i-1] >= 0 ){
      S[i] = S[i-1] + T[i];
    } else {
      S[i] = T[i];
    }
    current_max = max( current_max, S[i] );
  }

  max_value = max( max_value, current_max );
}

void work(){
  long long A[MAX][MAX];
  for ( int j = 1; j <= N; j++) A[0][j] = 0;
  for ( int j = 1; j <= N; j++ ){
    for ( int i = 1; i <= N; i++ ){
      A[i][j] = A[i-1][j] + M[i][j];
    }
  }

  max_value = -1000000000;

  for ( int i = 1; i <= N; i++ ){
    for ( int k = i; k <= N; k++ ){
      for ( int j = 1; j <= N; j++ ){
	T[j] = A[k][j] - A[i-1][j];
      }
      find_max();
    }
  }
  cout << max_value << endl;
}

main(){
  read();
  work();
}

// @end_of_source_code

Measured memory_bytes: 1336
n,m=map(int,input().split())
a=[]
b=[]
for i in range(m):
	numa,numb=map(int,input().split())
	a.append(numa)
	b.append(numb)
bb=[]
aa=[]
for j in range(len(a)):
    if 1==a[j]:
        bb.append(b[j])
for k in range(len(b)):
    if n==b[k]:
        aa.append(a[k])
list=set(aa) & set(bb)
print("IMPOSSIBLE" if len(list)==0 else "POSSIBLE")

Measured memory_bytes: 28080
import sys
input = sys.stdin.readline

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

E=[[] for i in range(n+1)]

for i in range(m):
    x,y,s=map(int,input().split())
    E[x].append((y,s))
    E[y].append((x,s))

Q=[1]
USE=[-1]*(n+1)
USE[1]=0
FROM=[-1]*(n+1)

flag=1
while Q and flag==1:
    x=Q.pop()
    #print(x,USE)
    for to,c in E[x]:
        if USE[to]==USE[x]:
            flag=0
            flagpoint=to
            break
        if USE[to]==-1:
            Q.append(to)
            USE[to]=1-USE[x]
            FROM[to]=x

#print(flag,USE)
if flag==0:
    Q=[flagpoint]
    FROM=[-1]*(n+1)
    FROM[flagpoint]=-5
    USE=[-1]*(n+1)
    USE[flagpoint]=0
    flag=1
    while Q and flag==1:
        x=Q.pop()

        for to,c in E[x]:
            if USE[to]==USE[x]:
                flag=0
                break

            if FROM[to]==-1:
                Q.append(to)
                FROM[to]=x
                USE[to]=1-USE[x]

    S1=[to,x]
    while S1[-1]!=flagpoint:
        S1.append((FROM[S1[-1]]))

    S2=[to]
    while S2[-1]!=flagpoint:
        S2.append((FROM[S2[-1]]))

    while S1[-1]==S2[-1]:
        x=S1.pop()
        S2.pop()

    #print(S1,S2)

    ROOP=S1+S2[1:]+[x]
    #print(ROOP)

    score=0
    ind=0

    NOW=ROOP[-1]
    for ind in range(len(ROOP)):
        for to,c in E[ROOP[ind-1]]:
            if to==ROOP[ind]:
                score+=c*(-1)**(ind%2)
                break
        #print(score)
    #print(score)

    if score%2!=0 or score<=0:
        print(0)
        sys.exit()

    ANS=[-1]*(n+1)
        
    ANS[ROOP[-1]]=score//2

    Q=[ROOP[-1]]
    USE=[0]*(n+1)

    while Q:
        x=Q.pop()
        for to,c in E[x]:
            if USE[to]==0:
                USE[to]=1
                ANS[to]=c-ANS[x]
                Q.append(to)

    for i in range(1,n+1):
        if ANS[i]<=0:
            print(0)
            sys.exit()

    flag=1
    for i in range(n+1):
        for to,c in E[i]:
            if ANS[to]+ANS[i]!=c:
                flag=0
                print(0)
                sys.exit()

    print(1)
    sys.exit()

Q=[1]
score=[-1<<31]*(n+1)
score[1]=0
while Q:
    x=Q.pop()
    for to,c in E[x]:
        if score[to]==-1<<31:
            score[to]=c-score[x]
            Q.append(to)
        else:
            if score[to]!=c-score[x]:
                print(0)
                sys.exit()

MIN0=0
MIN1=1<<31

for i in range(1,n+1):
    if USE[i]==0:
        MIN0=min(MIN0,score[i])
    else:
        MIN1=min(MIN1,score[i])

#print(MIN0,MIN1)
print(max(0,max(0,MIN1)+MIN0-1))

Measured memory_bytes: 44244
N=int(input())

S_list = []
S_count = []
max = 1
temp_list = []
#for i in range(N):
#    s = input()
#    temp_list.append(s)
S_dict = {}
for i in range(N):
    s = input()
    if s in S_dict.keys():
        S_dict[s] += 1
        if max < S_dict[s]:
            max = S_dict[s]
    else:
        S_dict[s] = 1
    
     
#print(S_list)
#print(S_count)
#print(max)
S_max = []
for j in S_dict:
    if S_dict[j] == max:
        S_max.append(j)

S_max.sort()
for k in range(len(S_max)):
    print(S_max[k])

Measured memory_bytes: 32096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int A[100001],B[100001];
int main()
{
	int n,i,j,k=0,count1=INT_MIN,count2=INT_MIN,x,y;
	cin>>n;
	int a[n];
	for ( i=0;i<n;i++)
	{
		cin>>a[i];
		if (i%2==0)
		{
			A[a[i]]++;
			if (A[a[i]]>count1)
			{
				count1=A[a[i]];
				x=a[i];
			}
		}
		else
		{
			B[a[i]]++;
			if (B[a[i]]>count2)
			{
				count2=B[a[i]];
				y=a[i];
			}
		}
	}
	for (i=1;i<n;i++)
	if (a[i]!=a[i-1])
	k=1;
	if (k==1&&x!=y)
	cout<<n-count1-count2;
	else if (k==1&&x==y)
	{
		sort(A,A+100001,greater<int>());
		sort(B,B+100001,greater<int>());
		cout<<min(n-count1-B[1],n-count2-A[1]);
	}
	else
	cout<<n/2;
	
}

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

int main() {
  string a, b; cin >> a >> b;
  bool ans = true;
  for (int i = 0; i < 3; i++) {
  	if (a.at(i) != b.at(2 - i)) {
    	ans = false;
  	}
  }
  if (ans) {
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}

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

int main(){

int H,W;
while(1){
    cin>>H>>W;
    if(H==0 && W==0){
        break;
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if((i+j)%2==0){
                cout<<"#";
            }else{
                cout<<".";
            }
        }
        cout<<endl;
    }
    cout<<endl;
}

    return 0;
}


Measured memory_bytes: 3076