akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define MOD 1000000007

int a[100], dp[101][100001] = {}, prefixSum[101][100001];

void add(int &a, int b) {
    a = (a + b) % MOD;
}

void sub(int &a, int b) {
    a = (a - b + MOD) % MOD;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    dp[0][0] = 1;
    for (int j=0; j<=k; j++)
        prefixSum[0][j] = 1;
    for (int i=1; i<=n; i++)
        for (int j=0; j<=k; j++) {
            add(dp[i][j], prefixSum[i-1][j]);
            if (j > a[i-1])
                sub(dp[i][j], prefixSum[i-1][j-a[i-1]-1]);
            prefixSum[i][j] = ((j > 0 ? prefixSum[i][j-1] : 0) + dp[i][j]) % MOD;
        }

    cout << dp[n][k] << "\n";

    return 0;
}


Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    string s;
    cin>>s;
    if(t%2!=0)
    {
        cout<<"No"<<endl;
    }
    else
    {
        int j=t/2;
       //  cout<<j<<endl;
        for(int i=0; i<t/2; i++)
        {
            if(s[i]!=s[j])
            {
                cout<<"No"<<endl;
                return 0;
            }
            j++;
        }
        cout<<"Yes"<<endl;
    }



}



Measured memory_bytes: 256
N = int(input())
GA, SA, BA = map(int, input().split())
GB, SB, BB = map(int, input().split())

def napsac(x, g1, s1, b1, g2, s2, b2):
    dp = [0 for _ in range(x+1)]
    dp[0] = 0

    def case(i, m1, m2):
        return 0 if i - m1 < 0 else dp[i-m1] + m2

    for i in range(1,x+1):
        dp[i] = max(i, case(i, g1, g2), case(i, s1, s2), case(i, b1, b2))

    return dp[-1]

print(napsac(napsac(N, GA, SA, BA, GB, SB, BB), GB, SB, BB, GA, SA, BA))


Measured memory_bytes: 424496
#include <iostream>

using namespace std;

int main() {
  int m, f, r;

  for(int i=0; i < 50; i++) {
    cin >> m >> f >> r;
    if( m==-1 && f==-1 && r==-1 ) break;
    if( m==-1 || f==-1) cout << "F" << endl;
    else if( m + f >= 80 ) cout << "A" << endl;
    else if( m + f >= 65 && m + f < 80 ) cout << "B" << endl;
    else if( m + f >= 50 && m + f < 65 ) cout << "C" << endl;
    else if( m + f >= 30 && m + f < 50 ) {
      if( r >= 50 ) {
        cout << "C" << endl;
      } else cout << "D" << endl;
    }
    else cout << "F" << endl;
  }
  return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  REP(i, 7){
    int a, b; cin >>a >>b;
    cout <<a-b <<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;

int main(void){
	int n;
	int l;
	cin>>n>>l;
	int sum=0;
	for(int i=0;i<n;i++){
		sum+=(l+i);
	}
	int ans=1e6,tmp=0;
	int c=0;
	for(int i=0;i<n;i++){
		tmp = sum-(l+i);
		//ans = min(ans,abs(sum-tmp));
		if(ans>abs(sum-tmp)){
			ans = abs(sum-tmp);
			c=i;
		}
	}
	ans=0;
	for(int i=0;i<n;i++){
		if(i==c)continue;
		ans+=(l+i);
	}
	cout<<ans<<endl;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  string s;
  cin >> s;
  int c=0;
  string t="keyence";
  bool ok=true;
  for(int i=0;i<7;i++){
    if(s.substr(0,i)==t.substr(0,i)&&s.substr(s.length()-(7-i),7-i)==t.substr(i,7-i)){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


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

class UF {
  vector<int> v;
public:
  UF(int n) : v(n) {
    for (int i = 0; i < n; ++i) {
      v[i] = i;
    }
  }
  
  int root(int i) {
    if (v[i] == i) return i;
    return v[i] = root(v[i]);
  }
  
  bool same(int i, int j) {
    return root(i) == root(j);
  }
  
  void unite(int i, int j) {
    int ri = root(i);
    int rj = root(j);
    if (ri == rj) return;
    v[ri] = rj;
  }
};

int n, q;
long m;
int a[100000], b[100000], c[100000];

bool sub() {
  bool has_mult = false;
  for (int k = 0; k < q; ++k) {
    if (c[k] == 1) {
      has_mult = true;
    }
  }
  
  UF uniq(n);
  UF mult(n);
  for (int k = 0; k < q; ++k) {
    if (c[k] == 0) {
      uniq.unite(a[k], b[k]);
    } else {
      mult.unite(a[k], b[k]);
    }
  }
  
  for (int k = 0; k < q; ++k) {
    if (c[k] == 1) {
      if (uniq.same(a[k], b[k])) return false;
    }
  }
  
  set<int> rs;
  for (int i = 0; i < n; ++i) {
    rs.insert(uniq.root(i));
  }
  
  if (has_mult && rs.size() < 3) return false;
  
  set<int> qs;
  for (int k = 0; k < q; ++k) {
    if (c[k] == 1) {
      qs.insert(uniq.root(a[k]));
      qs.insert(uniq.root(b[k]));
    }
  }
  
  long mn = has_mult ? n : n - 1;
  long mx = n - rs.size() + (long)rs.size() * (rs.size() - 1) / 2;
  return m >= mn && m <= mx;
}

int main() {
  cin >> n >> m >> q;
  for (int k = 0; k < q; ++k) {
    cin >> a[k] >> b[k] >> c[k];
  }
  
  bool res = sub();
  cout << (res ? "Yes" : "No") << endl;
}


Measured memory_bytes: 11520
package main

import (
	"fmt"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

func main() {

	var a, b, x uint64

	fmt.Scan(&a, &b, &x)

	var y uint64
	if a == 0 {
		y = b/x + 1
	} else {
		y = b/x - (a-1)/x
	}

	out(y)
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int INFLL = 1e18;
const int MOD = 1e9 + 7;

// fi:to, se:cost
vector<P> G[100001];
vector<int> ans;

void dfs( int v, int p, int c ){
    ans[v] = c;
    for( auto e : G[v] ){
        if( e.first == p ) continue;
        if( e.second & 1 ) dfs( e.first, v, c ^ 1 );
        else dfs( e.first, v, c );
    }
}

signed main(){
    int N; cin >> N;
    REP( i, N - 1 ){
        int from, to, cost;
        cin >> from >> to >> cost;
        from--, to--;
        G[from].emplace_back( to, cost );
        G[to].emplace_back( from, cost );
    }

    ans.assign( N, 0 );
    dfs( 0, -1, 0 );

    REP( i, N ){
        cout << ans[i] << endl;
    }

}


Measured memory_bytes: 11008
from sys import stdin

N = int(stdin.readline().rstrip())
tupleList=[]
for i in range (N):
  city,score = stdin.readline().rstrip().split()
  tupleList.append((city,int(score)*-1))
tupleListSort=sorted(tupleList)

for i in range (N):
  print(tupleList.index(tupleListSort[i])+1)

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for ((i) = 0; (i) < (n); (i)++)
#define rep2(i, s, e) for ((i) = (s); (i) < (e); (i)++)
#define repd(i, n) for ((i) = (n)-1; (i) >= 0; (i)--)
#define rep2d(i, s, e) for ((i) = (e)-1; (i) >= (s); (i)--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b)
{
    return b ? gcd(b, a % b) : a;
}
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

void func(std::string S, std::string T)
{
    int i, flg = 1;
    rep(i, S.length())
    {
        if (S[i] != T[i])
            flg = 0;
    }
    if (flg && T.length() - S.length() == 1)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

int main()
{
    // cout << fixed << setprecision(5);

    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    func(S, T);
    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    if (a - b == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,p;cin>>n>>p;
  if(n==1){
    cout<<p<<endl;
    return 0;
  }
  ll ans=1;
  for(ll i=2;;i++){
    if(pow(i,n)>p)break;
    ll num=pow(i,n);
    if(p%num==0)ans=i;
  }
  cout<<ans<<endl;
}

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

int main(){
    int maxl = 0,sum = 0;
    int N;cin >> N;
    rep(i,N){
        int l;cin >> l;
        sum += l;
        maxl = max(maxl,l);
    }
    if(maxl < sum-maxl)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

using namespace std;

int main(){
  int n,i,j,m;
	string a,b;
	cin>>a>>b;
	n = a.length();
	m = b.length();
	vector<vector<int>>dp(n,vector<int>(m,0));
	dp[0][0] = a[0]==b[0]?1:0;
	for(i=1;i<n;i++){
		if(a[i] == b[0])
		  dp[i][0] = 1;
		else dp[i][0] = max(0,dp[i-1][0]);
	}
	for(i=1;i<m;i++){
		if(a[0] == b[i])
		  dp[0][i] = 1;
		else dp[0][i] = max(0,dp[0][i-1]);
	}
	for(i=1;i<n;i++){
		for(j=1;j<m;j++){
		  if(a[i] == b[j])
			dp[i][j] = 1+dp[i-1][j-1];
		  else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
		}
	}
	i = n-1;
	j = m-1;
	string ans = "";
	while(i>=0 && j>=0){
		if(i>0 && j>0){
			if(a[i] == b[j]){
			  ans+=a[i];
			  i--;
			  j--;
			  continue ;
			}
			if(dp[i-1][j]>=dp[i][j-1]){
			  i--;
			  continue ;
			}
			if(dp[i-1][j]<dp[i][j-1]){
			  j--;
			  continue ;
			}
		}
		else {
			if(i==0 && j>0){
				if(a[i]==b[j]){
					ans+=a[i];
					break;
				}
				j--;
			}
			else if(i>0 && j==0){
				if(a[i]==b[j]){
					ans+=a[i];
					break;
				}
				i--;
			}
			else if(i==0 && j==0){
				if(a[i]==b[j]){
					ans+=a[i];
				}
				break;
			}
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<"\n";
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  ll x;
  cin >> x;
  while (1)
  {
    bool prime = true;
    for (int i = 2; i <= x - 1; i++)
    {
      if (x % i == 0)
      {
        prime = false;
        break;
      }
    }
    if (prime)
    {
      cout << x << endl;
      return 0;
    }
    x++;
  }
  return 0;
}


Measured memory_bytes: 256
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/
 
#include <bits/stdc++.h>
using namespace std;
 
 
#define ll                          long long
#define ld                          long double
 
#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second
 
#define vpi                         vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
#define  MN                           INT_MIN
#define  MX                           INT_MAX
 
bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}

int32_t main()
{
	int n;
	cin >> n;
	int a[n];
	for(int i = 0;i<n;i++)
		cin >> a[i];
	int ans = 0;
	for(int i = 0;i<n-2;i++)
	{
		for(int j = i+1;j<n-1;j++)
		{
			for(int k = j+1;k<n;k++)
			{
				if(a[i] != a[j] && a[j] != a[k] && a[i] != a[k])
				{
					if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i])ans++;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  string res="No";
  for(int i=0;i<26;i++){
    for(int j=0; j<15; j++){
      if(4*i +7*j ==N){
        res ="Yes";
      }
    }
  }
  cout<< res<<endl;
}

Measured memory_bytes: 256
w,h,n=map(int,input().split())
X=set(range(1,w+1))
Y=set(range(1,h+1))
for i in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    X=X&set(range(x+1,w+1))
  if a==2:
    X=X&set(range(1,x+1))
  if a==3:
    Y=Y&set(range(y+1,h+1))
  if a==4:
    Y=Y&set(range(1,y+1))
print(len(X)*len(Y))

Measured memory_bytes: 3064
fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val (d,x) = readLine()!!.split(" ").map { it.toInt() }
    val eat = (1..n).map { readLine()!!.toInt() }
    val totalEat = eat.map { (d-1)/it + 1 }.sum()
    println(totalEat + x)
}


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

const int maxn = (int)(1e5) + 5;
int a[maxn];

int main() {
    ios::sync_with_stdio(false);
    int n; cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort(a + 1, a + n + 1);
    int M = (n + 1) >> 1;
    long long ret = a[M] - a[M + 1];
    if (n & 1) ret = max(a[M] + a[M - 1], 3 * a[M] - a[M + 1]);
    for (int i = 1; i <= M; ++i) ret -= a[i] * 2;
    for (int i = M + 1; i <= n; ++i) ret += a[i] * 2;
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
 
int N,n;
 
int main(){
  int i=0,n,j,max = 0,min = 10000000;
  cin >> n >> j;
  while(i < j ){
    int li,ri;
    cin >> li >> ri;
    if(max<li)max=li;
    if(min>ri)min=ri;
    i++;
  }
  if(min < max){
    cout << 0 << endl;
  }else{
    cout << min - max + 1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

const int MAX_N = 100010;

class node {
  public:
    int p = -1, l, r;
};
node nod[MAX_N];

vector<int> depth(MAX_N);
vector<int> heigh(MAX_N);

void setDepth(int i, int d) {
    depth[i] = d++;
    if(nod[i].l != -1) setDepth(nod[i].l, d);
    if(nod[i].r != -1) setDepth(nod[i].r, d);
}
int setHeight(int i) {
    int h1 = 0, h2 = 0;
    if(nod[i].l != -1) h1 = setHeight(nod[i].l) + 1;
    if(nod[i].r != -1) h2 = setHeight(nod[i].r) + 1;
    return heigh[i] = max(h1, h2);
}

int getSibling(int i) {
    if(nod[i].p == -1)
        return -1;
    else
        return (nod[nod[i].p].l != i ? nod[nod[i].p].l : nod[nod[i].p].r);
}

int getDegree(int i) { return (nod[i].l != -1) + (nod[i].r != -1); }

string isNodeType(int i) {
    if(nod[i].p == -1) return "root";
    if(nod[i].l == -1 && nod[i].r == -1) return "leaf";
    return "internal node";
}

void traverse(int now, int order) {
    if(order == 0) cout << " " << now; // preorder
    if(nod[now].l != -1) traverse(nod[now].l, order);
    if(order == 1) cout << " " << now; // inorder
    if(nod[now].r != -1) traverse(nod[now].r, order);
    if(order == 2) cout << " " << now; // postorder
}

int main() {
    int n, id, l, r, root;
    cin >> n;
    rep(i, n) {
        cin >> id >> l >> r;
        nod[id].l = l;
        nod[id].r = r;
        if(l != -1) nod[l].p = id;
        if(r != -1) nod[r].p = id;
    }
    rep(i, n) {
        if(nod[i].p < 0) {
            root = i;
            break;
        }
    }

    cout << "Preorder" << endl;
    traverse(root, 0);
    cout << endl << "Inorder" << endl;
    traverse(root, 1);
    cout << endl << "Postorder" << endl;
    traverse(root, 2);
    cout << endl;
}



Measured memory_bytes: 4560
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, a, b;
    cin >> n >> a >> b;
    int cnt[3] = {};
    rep(i, n)
    {
        int p;
        cin >> p;
        if (p <= a)
            cnt[0]++;
        else if (b < p)
            cnt[2]++;
        else
            cnt[1]++;
    }
    cout << min(min(cnt[0], cnt[1]), cnt[2]) << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <set>
#include <ctime>
#include <map>
#include <cstring>
#include <iterator>
#include <queue>
#include <assert.h>
#include <bitset>
#include <complex>
#include <unordered_map>

//#pragma comment(linker, "/STACK:512000000")

using namespace std;

#define pb emplace_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define forab(i, a, b) for (int i = (a); i < (b); ++i)

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

const int infi = 1e9 + 7;
const ll infl = (ll)1e18 + (ll)7;

int ar[100500];

int32_t main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
   // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    //freopen("customs.in", "r", stdin); freopen("customs.out", "w", stdout);
    int n, k;
    cin >> n >> k;
    forn(i, n)
        cin >> ar[i];
    sort(ar, ar + n);
    int ans = infi;
    for (int i = 0, j = k - 1; j < n; ++j, ++i)
        ans = min(ans, ar[j] - ar[i]);
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int h, w;
char a[8][8];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> h >> w;
    rep(i, 0, h) rep(j, 0, w) cin >> a[i][j];
    int x = 0, y = 0;
    a[0][0] = '.';
    rep(i, 0, h+w) {
        a[x][y] = '.';
        if (a[x+1][y] == '#') {
            a[x+1][y] = '.';
            x++;
        }
        else if (a[x][y+1] == '#') {
            a[x][y+1] = '#';
            y++;
        }
    }
    rep(i, 0, h) rep(j, 0, w) 
        if (a[i][j] != '.') {
            cout << "Impossible" << endl;
            return 0;
        }
    cout << "Possible" << endl;
    return 0;
}


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

using namespace std;

#define ll long long
#define int long long

const ll mod = (ll)1e9 + 7;

ll modpow(ll a, ll b) {
	if (b == 0) return 1;
	ll t = modpow(a, b / 2);
	if (b & 1)
		return t * t % mod * a % mod;
	return t * t % mod;
}

signed main() {
	int n; cin >> n;
	vector<ll> a(max((ll)5, n + 1));
	vector<ll> b(max((ll)5, n + 1));
	a[0] = a[1] = 1;
	a[2] = 3;
	b[0] = b[1] = 1;
	b[2] = 5; b[3] = 31;
	for (int i = 0; i < n - 2; ++i) {
		ll tmp_b = (3 * i + 7) * b[i + 2] % mod;
		tmp_b -= (i + 2) * (3 * i + 2) % mod * b[i + 1] % mod;
		tmp_b = (tmp_b + mod) % mod;
		tmp_b += (i + 2) * (i + 1) % mod * i % mod * b[i] % mod;
		tmp_b %= mod;
		b[i + 3] = tmp_b;
	}
	for (int i = 3; i <= n; ++i) {
		ll tmp_a = (2 * i - 1) * a[i - 1] % mod;
		tmp_a -= (i - 1) * (i - 2) % mod * a[i - 2] % mod;
		tmp_a = (tmp_a + mod) % mod;
		a[i] = tmp_a;
	}

	//for (int i = 0; i < 10; ++i) {
	//	cout << a[i] << " " << b[i] << endl;
	//}

	ll fra = 1;
	for (int i = 1; i <= n; ++i)
		fra = (fra * i) % mod;

	ll bns = (fra * b[n] % mod - modpow(a[n], 2) + mod) % mod;
	ll bnb = modpow(fra, 2);
	ll ans = bns * modpow(bnb, mod - 2) % mod;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4296
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <string>
using namespace std;



int main()
{
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 1; i <= a[n - 1]; i++) {
		int idx =lower_bound(a.begin(), a.end(), i) - a.begin();
		int k_upper = n - idx;
		int k_lower = idx;
		if (k_upper == k_lower)
			ans++;
	}
	cout << ans;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int K, X;

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

  bool space = false;
  for (int i = -1000000; i <= 1000000; i++) {
    if (i > X - K && i < X + K) {
      if (space) {
        cout << " ";
        cout << i;
      } else {
        cout << i;
        space = true;
      }
    }
  }
  cout << endl;

  return 0;
}

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

struct Dice {
    int a, b, c, d, e, f;
    Dice(int a, int b, int c, int d, int e, int f) {
        setFaces(a, b, c, d, e, f);
    }
    void setFaces(int a, int b, int c, int d, int e, int f) {
        this->a = a;
        this->b = b;
        this->c = c;
        this->d = d;
        this->e = e;
        this->f = f;
    }
    void rotate(char dir) {
        switch (dir) {
            case 'N':
                setFaces(b, f, c, d, a, e);
                break;                
            case 'E':
                setFaces(d, b, a, f, e, c);
                break;                
            case 'S':
                setFaces(e, a, c, d, f, b);
                break;                
            case 'W':
                setFaces(c, b, f, a, e, d);
                break;
            case 'L':
                setFaces(a, d, b, e, c, f);
                break;
            case 'R':
                setFaces(a, c, e, b, d, f);
                break;
        }
    }
    void roll(string s) {
        for (int i=0; i<s.size(); i++)
            rotate(s[i]);
    }
    bool equal(Dice dice) {
        if (dice.a == a && dice.b == b && dice.c == c 
            && dice.d == d && dice.e == e && dice.f == f)
            return true;
        else
            return false;
    }
    bool equivalent(Dice dice) {
        string s = "EEEENEEEENEEEENEEEENLEEEELLEEEE";
        for (int i=0; i<s.size(); i++) {
            dice.rotate(s[i]);
            if (equal(dice))
                return true;
        }
        return false;
    }
};

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    Dice dice1(a, b, c, d, e, f);
    cin >> a >> b >> c >> d >> e >> f;
    Dice dice2(a, b, c, d, e, f);
    if (dice1.equivalent(dice2))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}



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

int main(){
    ll h,w,n,ans,a;
    cin >> h >> w >> n;
    a = max(h,w);
    ans = n/a;
    if(n%a != 0){
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int l,r,d;
	cin>>l>>r>>d;
	int count = 0 ;
	for (int i = l; i <= r; i++){
			if(i % d == 0){
				count++;
			}
	}	
	cout<<count<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PP;	//point, team, time

void solve()
{
	int N, R, L;
	cin >> N >> R >> L;
	priority_queue< pair<int, int> > PQue;
	for (int i = 0; i < N; ++i)
	{
		PQue.push(make_pair(0, -i));
	}
	int prev = 0;
	vector<int> score(N);
	vector<int> time(N);
	for (int i = 0; i < R; ++i)
	{
		int d, t, x;
		cin >> d >> t >> x;
		--d;
		while (score[-PQue.top().second] != PQue.top().first)
		{
			int id = -PQue.top().second;
			PQue.pop();
			PQue.push(make_pair(score[id], -id));
		}
		time[-PQue.top().second] += t - prev;
		score[d] += x;
		PQue.push(make_pair(score[d], -d));
		prev = t;
	}
	while (score[-PQue.top().second] != PQue.top().first)
	{
		int id = -PQue.top().second;
		PQue.pop();
		PQue.push(make_pair(score[id], -id));
	}
	time[-PQue.top().second] += L - prev;
	cout << 1 + (max_element(time.begin(), time.end()) - time.begin()) << endl;
}

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

Measured memory_bytes: 11904
A, B, K = map(int, input().split())

C = A + K - 1
D = B - K + 1

if C >= D:
    for i in range(A, B + 1):
        print(i)
else:
    for i in range(0, K):
        print(i + A)
    for i in range(K - 1, -1, -1):
        print(B - i)

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);

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

  vector<long long> left(n + 1);
  {
    multiset<int> q;
    long long sum = 0;
    for (int i = 0; i < n; i++) {
      sum += a[i];
      q.insert(a[i]);
    }
    for (int i = 0; i <= n; i++) {
      left[i] = sum;
      auto it = q.begin();
      if (*it < a[n + i]) {
        sum -= *it;
        q.erase(it);
        sum += a[n + i];
        q.insert(a[n + i]);
      }
    }
  }

  vector<long long> right(n + 1);
  {
    multiset<int> q;
    long long sum = 0;
    for (int i = 0; i < n; i++) {
      sum += a[3 * n - 1 - i];
      q.insert(a[3 * n - 1 - i]);
    }
    for (int i = 0; i <= n; i++) {
      right[i] = sum;
      auto it = prev(q.end());
      if (*it > a[2 * n - 1 - i]) {
        sum -= *it;
        q.erase(it);
        sum += a[2 * n - 1 - i];
        q.insert(a[2 * n - 1 - i]);
      }
    }
  }

  long long ans = -5e16;
  for (int i = 0; i <= n; i++) {
    ans = max(ans, left[i] - right[n - i]);
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 10656
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
using namespace std;
void CutandCount() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	bool c[26];
	bool d[26];
	int m = 0;
	for (size_t i = 1; i < S.size() - 1; i++)
	{
		for (size_t j = 0; j < 26; j++) {
			c[j] = false;
			d[j] = false;
		}
		string s1 = S.substr(0, i);
		for (size_t j = 0; j < s1.size(); j++)
		{
			c[s1[j] - 'a'] = true;
		}
		string s2 = S.substr(i);
		for (size_t j = 0; j < s2.size(); j++)
		{
			d[s2[j] - 'a'] = true;
		}
		int count = 0;
		for (size_t j = 0; j < 26; j++)
		{
			count += c[j] && d[j];
		}
		m = max(m, count);
	}
	cout << m;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

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


int main(){
	int N;
	cin>>N;
	ll t[N];
	rep(i,N){
		cin>>t[i];
	}
	rep(i,N-1){
		t[i+1]=lcm(t[i],t[i+1]);
	}
	cout<<t[N-1]<<endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  int ans = 0;
  int cur = 0;
  rep(i, n-1) {
    if (h[i+1] <= h[i]) cur++;
    else cur = 0;
    if (cur > ans) ans = cur;    
  }
  cout << ans << '\n';
 
  return 0;
}

Measured memory_bytes: 3704
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

vector< vector<double >> dist; // Tree which contains the distance of i-j.

// ll counter = 0; // For Debug

// dfs returns the distance
vector<double> dfs(set<int>& rest, int prev) {
  // if (rest.size() == 0) { ++counter; } // FOr Debug
  vector<double> res;
  for (auto v : rest) {
    set<int> ns = rest; // copy
    ns.erase(v);
    double d = dist[prev][v];

    if (ns.size() == 0) {
      res.emplace_back(d);
    } else {
      vector<double> after = dfs(ns, v); // after contains the distance of after this.
      for (auto a_d : after) {
        res.emplace_back(a_d + d);
      }
    }
  }
  return res;
}

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  vector<double> x(n);
  vector<double> y(n);
  rep(i, n) {
    cin >> x[i];
    cin >> y[i];
  }
  // printvec(x);
  // printvec(y);

  dist.assign(n, vector<double>(n)); // Tree which contains the distance of i-j.
  rep(i, n) {
    for (int j = i + 1; j < n; ++j) {
      double d = sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
      dist[i][j] = d;
      dist[j][i] = d;
      // cout << "i: " << i << endl;
      // cout << "j: " << j << endl;
      // cout << "d: " << d << endl;
    }
  }
  // rep(i, n) {
  //   printvec(dist[i]);
  // }

  // Now, we have distance matrix

  // First, calculate the summention of all.
  set<int> s;
  rep(i, n) {
    s.insert(i);
  }
  // Now, start set has all case.
  double ans = 0;
  rep(i, n) {
    set<int> ns = s; // copy
    ns.erase(i);
    vector<double> res = dfs(ns, i);
    for (auto d : res) {
      ans += d;
    }
  }

  ll divisor = 1;
  rep(i, n) {
    divisor *= i + 1;
  }
  // cout << "divisor: " << divisor << endl;
  // cout << "coutner: " << counter << endl;

  cout << (ans / (double)divisor) << endl;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextInt();
  int K = nextInt();

  vector<int> count(N+1);
  REP(i, K) {
    int B = nextInt();
    REP(j, B) {
      count[ nextInt() ]++;
    }
  }
  int ans = 0;
  for (int i = 1; i <= N; i++) if (count[i] == 0) ans++;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
int n,k;
string s;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k>>s;
	for (int i=0;i<s.size();++i)
	{
		if (i==k-1) s[i]=(char)(s[i]+32);
	}
	cout<<s;
	return 0;
}

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

int main() {
    ll x;
    cin>>x;
    for (ll a = -200; a<=200; a++) {
        for (ll b = -200; b <=200; b++) {
            if (a*a*a*a*a - b*b*b*b*b == x) {
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3616
a, b, h, m = gets.chomp.split(' ').map(&:to_i)
 
hd = 30.0 * h + 0.5 * m
md = 6.0 * m

d = hd > md ? hd - md : md - hd
d = 360 - d if d > 180

p Math.sqrt((a ** 2) + (b ** 2) - ((2 * a * b) * Math.cos(d * Math::PI / 180)))


Measured memory_bytes: 14696
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;


int main() {
    int n; cin >> n;
    if (n==3 || n==5 || n==7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


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

int main(void) {
  int A,B;
  cin >> A >> B;
  int ans = -1;
  for(int i = 1; i < 1500; i++){
   int tmpA,tmpB;
    tmpA = i*0.08;
    tmpB = i*0.1;
    if((A==tmpA)&&(B==tmpB)){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#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;
void Main()
{
    ll n, Z, W;
    cin >> n >> Z >> W;

    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    
    if (n >= 2) {
        put(max(abs(W - a[n-1]), abs(a[n-1] - a[n-2])));
    }
    else {
        put(abs(W - a[n-1]));
    }
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3608
#pragma GCC optimize (2)
#include<cstdio>
#include<cstring>
#define int long long
#define rep(i, a, b) for (register int i=(a); i<=(b); ++i)
#define per(i, a, b) for (register int i=(a); i>=(b); --i)
using namespace std;
typedef long long ll;
inline void chkmax(int &x, int y){x<y?(x=y):0;}
inline void chkmin(int &x, int y){x>y?(x=y):0;}
const int N=5005;
int dp[N][N], a[N];

inline int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}

signed main()
{
	int n=read(), A=read(), B=read(), ans=1ll<<60;
	rep(i, 1, n) a[i]=read();
	memset(dp, 0x3f, sizeof(dp)); dp[0][0]=0;
	rep(i, 1, n) rep(j, 0, n)
		if (a[i]>j) 
			chkmin(dp[i][j], dp[i-1][j]+A), 
			chkmin(dp[i][a[i]], dp[i-1][j]);
		else
			chkmin(dp[i][j], dp[i-1][j]+B);
	rep(i, 0, n) chkmin(ans, dp[n][i]);
	printf("%lld\n", ans);
	return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, x);
  int dan;
  if (x < 600)
    dan = 8;
  else if (x < 800)
    dan = 7;
  else if (x < 1000)
    dan = 6;
  else if (x < 1200)
    dan = 5;
  else if (x < 1400)
    dan = 4;
  else if (x < 1600)
    dan = 3;
  else if (x < 1800)
    dan = 2;
  else if (x < 2000)
    dan = 1;
  out(dan);
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

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

  int div_num = 0;
  for (int i = 0; i < N; ++i)
  {
    int a;
    cin >> a;

    //奇数になるまで割り続ける
    while (a % 2 == 0)
    {
      a = a / 2;
      ++div_num;
    }
  }
  cout << div_num << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#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
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {

	ll A,an=0;
	cin >> A;
	rep(i, 4) {
		if (A % 10 == 2) {
			an++;
		}
		A /= 10;
	}
	
	cout <<an<< endl;


}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
metro = {i:0 for i in range(N)}

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

for i in range(N):
  print(metro[i])

Measured memory_bytes: 3060
#include <iostream>
 #include <vector>
 #include <map>
 #include <string>
 #include <algorithm>
 using namespace std;

 typedef long long ll;

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

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

    ll x = (ll)(a-1 - (a-1)/c - (a-1)/d + (a-1)/((c / gcd(c, d) * d)));
    ll y = (ll)(b - b/c - b/d + b/((c / gcd(c, d) * d)));

    cout << y - x << endl;
     return 0;
 }

Measured memory_bytes: 256
n, l = map(int, input().split())
li = [l + i for i in range(n)]
if 0 <= l:
    print(sum(li[1:]))

else:
    if 0 <= n + l - 1:
        print(sum(li))
    else:
        print(sum(li) + abs(n + l - 1))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define PI acos(-1)
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define sp fixed<<setprecision
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int MOD = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        string s;
        cin>>s;
        if(s[s.length() - 1] == 's')s += "es";
        else s += "s";
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 3660
import sys

def gcd(a, b):
    """Euclidean Algorithm"""
    while b != 0:
        a, b = b, a % b
    return a


def lcm(a, b):
    return (a * b) // gcd(a, b)


def main():
    input = sys.stdin.readline
    A, B, C, D = map(int, input().split())
    E = lcm(C, D)

    total = B - A + 1
    multi_c = max(0, B // C) - max(0, A // C)
    if A % C == 0:
        multi_c += 1
    multi_d = max(0, B // D) - max(0, A // D)
    if A % D == 0:
        multi_d += 1
    multi_e = max(0, B // E) - max(0, A // E)
    if A % E == 0:
        multi_e += 1
    return total - (multi_c + multi_d - multi_e)


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3064
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
const int N=1919810;
struct edge{
	int to,nxt,cap;
}e[N];
int n,m,sx,sy,tx,ty,id[105][105][2],nod,head[N],cnt=1,ans,dep[N];
int R[105],C[105],T,iter[N];
char mp[105][105];
void addedge(int u,int v,int cap=1){
	e[++cnt]=(edge){v,head[u],cap},head[u]=cnt;
	e[++cnt]=(edge){u,head[v],0},head[v]=cnt;
}
queue<int>q;
void BFS(){
	dep[0]=1;
	for(q.push(0);!q.empty();){
		int u=q.front();q.pop();
		for(int i=head[u];i;i=e[i].nxt)
		if(e[i].cap&&!dep[e[i].to]){
			dep[e[i].to]=dep[u]+1;
			q.push(e[i].to);
		}
	}
}
int dfs(int u,int f){
	if(u==T||!f)return f;
	for(int&i=iter[u];i;i=e[i].nxt)
	if(e[i].cap&&dep[e[i].to]>dep[u]){
		int d=dfs(e[i].to,min(f,e[i].cap));
		if(d){
			e[i].cap-=d,e[i^1].cap+=d;
			return d;
		}
	}
	return 0;
}
void dinic(){
	for(;;){
		for(int i=0;i<=T;++i)dep[i]=0;
		BFS();
		if(!dep[T])break;
		for(int i=0;i<=T;++i)iter[i]=head[i];
		while(int f=dfs(0,0x3fffffff))ans+=f;
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i){
		scanf("%s",mp[i]+1);
		for(int j=1;j<=m;++j)
		if(mp[i][j]=='S')sx=i,sy=j;else
		if(mp[i][j]=='T')tx=i,ty=j;else
		if(mp[i][j]=='o'){
			id[i][j][0]=++nod,id[i][j][1]=++nod;
			addedge(nod-1,nod);
		}
	}
	if(sx==tx||sy==ty)return puts("-1"),0;
	for(int i=1;i<=n;++i)R[i]=++nod;
	for(int i=1;i<=m;++i)C[i]=++nod;
	T=++nod;
	for(int i=1;i<=n;++i)
	for(int j=1;j<=m;++j)if(mp[i][j]=='o'){
		addedge(id[i][j][1],R[i],0x3fffffff);
		addedge(id[i][j][1],C[j],0x3fffffff);
		addedge(R[i],id[i][j][0],0x3fffffff);
		addedge(C[j],id[i][j][0],0x3fffffff);
	}
	addedge(0,R[sx],0x3fffffff),addedge(0,C[sy],0x3fffffff);
	addedge(R[tx],T,0x3fffffff),addedge(C[ty],T,0x3fffffff);
	dinic();
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <algorithm>

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

int main()
{
    int x,y,z;
    cin >> x >> y >> z;

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


    
    
    return 0;
}

Measured memory_bytes: 256
#a, b, c, d = (int(i) for i in input().split())  
N = int(input())
W = [int(i) for i in input().split()] 

#P, Q, R = (int(i) for i in input().split())

for i, w in enumerate(W):
    if i == 0:
        min_diff = abs(sum(W[:0]) - sum(W[0:]))
        pass
    if min_diff > abs(sum(W[:i]) - sum(W[i:])):
        min_diff =  abs(sum(W[:i]) - sum(W[i:]))
        pass
    pass
    
print(min_diff)

Measured memory_bytes: 3064