akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define MAX 200
#define INF (1<<26)
#define min(x,y) ((x)<(y)?(x):(y))
int n,m,s,g1,g2,a,b,c;
int t[MAX][MAX];
void init(){
    for(int i=0;i<MAX;i++){
        for(int j=0;j<MAX;j++){
            t[i][j]=(i==j?0:INF);
        }
    }
}
int main(void){
    while(1){
        scanf("%d%d%d%d%d",&n,&m,&s,&g1,&g2);
        if(n==0) break;
        s--,g1--,g2--;
        init();
        for(int i=0;i<m;i++){
            scanf("%d%d%d",&a,&b,&c);
            a--,b--;
            t[a][b]=c;
        }
        for(int k=0;k<n;k++){
            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    t[i][j]=min(t[i][j],t[i][k]+t[k][j]);
                }
            }
        }
        int ans=INF;
        for(int i=0;i<n;i++)
            ans=min(ans,t[s][i]+t[i][g1]+t[i][g2]);
        printf("%d\n",ans);
    }
}



Measured memory_bytes: 2064
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  console.log(' ' + buildMaxHeap(lines.shift().split(' ').map(i=>Number(i))).join(' '));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest = i;
    left = 2 * i + 1;
    right = 2 * i + 2;
    if (left < n && (arr[left]) > (arr[largest])) largest = left;
    if (right < n && (arr[right]) > (arr[largest])) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
  return arr;
}



Measured memory_bytes: 110752
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#define ll long long
using namespace std;
ll b[1000000];
int main()
{
    int n;
    scanf("%d",&n);
    ll a[100005],i;
    
    for(i=0; i<n; i++)
        scanf("%lld",&a[i]),b[i]=0;
    if(a[0]!=0)
            printf("0\n");
    else
    {
        ll ans=1;
        for(i=0;i<n;i++)
            b[a[i]]++;
        for(i=1;i<n;i++)
        {
            ans*=b[a[i]-1];
            ans%=998244353;
        }

        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 1792
from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

m,d = mi()

ans=0

for i in range(1,m+1):
    for j in range(1,d+1):
        if j<22:
            continue

        d1 = j%10
        d10 = j//10
        if d1>=2 and d10>=2 and d1*d10 == i:
            ans += 1
print(ans)


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

using namespace std;

const long long MOD = 1000000007;
using ll = long long;

// intだとオーバーフローする
int main() {
    ll N, K; cin >> N >> K;

    // tの候補
    vector<ll> A;
    ll sqrtN = (ll)sqrt(N) + 1;
    for (ll i = 0; i < sqrtN; i++) {
            A.push_back(i);
    }
    for (ll i = sqrtN - 1; i > 0; i--) {
            A.push_back(ceil(N/i));
    }
    // for (auto e : A) {
    //     cout << e << ",";
    // }
    // cout << "\n";
    vector<ll> dp1(A.size(), 1);
    dp1[0] = 0;

    for (ll i = 1; i <= K; i++) {
        vector<ll> dp2(dp1.size());
        for (ll j = 1; j < ll(A.size()); j++) {
            dp2[j] = (dp2[j-1] + dp1[dp1.size()-j]*(A[j]-A[j-1])) % MOD;
        }
        copy(dp2.begin(), dp2.end(), dp1.begin());
    }

    ll ans = dp1[dp1.size()-1];
    cout << ans << "\n";

}

Measured memory_bytes: 1912
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<iomanip>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    double ans = 0;
    REP(i, n) {
        double ai;
        cin >> ai;
        ans += 1 / ai;
    }
    ans = 1 / ans;
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
int n;
int h[100000];
int c[100000];
int ans;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", h + i);
	}
	for (int i = n - 2; i >= 0; i--) {
		if (h[i] >= h[i + 1])c[i] = c[i + 1] + 1;
	}
	for (int i = 0; i < n; i++) {
		if (c[i] > ans)ans = c[i];
	}
	printf("%d\n", ans);
}

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


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

    for (int i = a; a < b+1 ; a++)
    {
        if (a % k == 0)
        {
            cout << "OK" << endl;
            return (0);
                    }
    }
    cout << "NG" << endl;

}

Measured memory_bytes: 3648
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;


struct UnionFind {
	VI par;
	UnionFind(int N) :par(N) {
		REP(i, N)par[i] = i;
	}
	int root(int x) {
		if (par[x] == x)return x;
		return par[x] = root(par[x]);
	}
	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;
		par[rx] = ry;
	}
	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

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

	int N, M; cin >> N >> M;
	VI A(N), B(N), C(M), D(M);
	REP(i, N)cin >> A[i] >> B[i];
	REP(i, M)cin >> C[i] >> D[i];
	REP(i, N) {
		int ans, cnt = LLINF;
		REP(j, M) {
			if (abs(A[i] - C[j]) + abs(B[i] - D[j]) < cnt) {
				cnt = abs(A[i] - C[j]) + abs(B[i] - D[j]);
				ans = j;
			}
		}
		cout << ans + 1 << endl;
	}
	return 0;
}



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

main() {
  int N, K; cin >> N >> K;
  vector<int> l(N); for (int i = 0; i < N; i++) cin >> l[i];
  sort(l.begin(), l.end(), greater<int>());
  int ans = 0;
  for (int i = 0; i < K; i++) ans += l[i];
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
using namespace std;

int main(){
  ll N;
  cin>>N;
  ll A[N+1];
  REP(i,N+1) A[i]=0;
  
  for(int i=2; i<=N; ++i){
    ll a;
    cin>>a;
    A[a]++;
  }
  
  for(int i=1; i<=N; ++i) cout<<A[i]<<endl;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	int N;
	cin >> N;
	vecl(A)
	fx(N) {
		vecpl(A)
	}

	sorts(A)
	ll ans1 = 0, ans2=0;
	int left = 1, right = N - 1;
	vecl(B)
		B.insert(B.begin(), A.at(0));
	bool flag = true;
	while(true){
		if (flag) {
			B.insert(B.begin(), A.at(right));
			right--;
			if (right < left) { break; }
			B.insert(B.begin()+B.size(), A.at(right));
			right--;
		}
		else {
			B.insert(B.begin(), A.at(left));
			left++;
			if (right < left) { break; }
			B.insert(B.begin() + B.size(), A.at(left));
			left++;
		}
		flag = !flag;
	}
	fx(N-1) {
		ans1 +=abs( B.at(x) - B.at(x + 1) );
	}
	flag = true;
	left = 0;
	right = N - 2;
	B.clear();
	B.insert(B.begin(), A.at(N-1));
	while (true) {
		if (!flag) {
			B.insert(B.begin(), A.at(right));
			right--;
			if (right < left) { break; }
			B.insert(B.begin() + B.size(), A.at(right));
			right--;
		}
		else {
			B.insert(B.begin(), A.at(left));
			left++;
			if (right < left) { break; }
			B.insert(B.begin() + B.size(), A.at(left));
			left++;
		}
		flag = !flag;
	}
	fx(N - 1) {
		ans2 += abs(B.at(x) - B.at(x + 1));
	}
	//ans2 += abs(A.at(left) - A.at(right));
	ce(max(ans1,ans2))
    return 0;
}



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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(i, v) for(auto i =  v.begin(); i !=  v.end(); ++i)
#define RFOR(i, v) for(auto i = v.rbegin(); i != v.rend(); ++i)

template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T> ostream & operator<<(ostream & os, const vector<T> & v) {
	os << "[";
	FOR(it, v) {
		if(it != v.begin()) { os << ", "; }
		os << *it;
	}
	os << "]";
	return os;
}
template<typename F, typename S> ostream & operator<<(ostream & os, const pair<F, S> & p) {
	os << "<" << p.FI << ", " << p.SE << ">";
	return os;
}

// ---- ----

LL x;

int main() {
	cin >> x;
	
	cout << (x / 11) * 2 + (x % 11 != 0) + (6 < x % 11) << endl;
	
	return 0;
}


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

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

  long long ans = 1;
  vector<long long> as(n);
  for (int i = 0; i < n; i++)
  {
    cin >> as[i];
  }
  sort(as.begin(),as.end());

  if(as[0]==0){
    cout << 0 << endl;
    return 0;
  }

  for (int i = 0; i < n; i++)
  {
    if(ans>1000000000000000000/as[i]){
      cout << -1 << endl;
      return 0;
    }
    ans*=as[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3972
#include<stdio.h>

int main() 
{
	int weight[4];
	for (int i = 0; i < 4; i++)
	{
		scanf("%d", &weight[i]);
	}
	if ((weight[0] + weight[1]) == (weight[2] + weight[3]))
	{
		printf("Balanced");
	}
	else if((weight[0] + weight[1]) > (weight[2] + weight[3]))
	{
		printf("Left");
	}
	else
	{
		printf("Right");
	}
	return 0;
}


Measured memory_bytes: 128
#B
mod = 998244353
N = int(input())
D = list(map(int,input().split()))
MD = max(D)
C = [0]*(MD+1)
for d in D:
    C[d]+=1
if D[0] != 0 or C[0] != 1:
    print(0)
else:
    ans = 1
    for i in range(MD):
        ans *= pow(C[i],C[i+1],mod)
    print(ans%mod)
    


Measured memory_bytes: 14396
import java.util.Scanner;

public class Main {

	// A, B, C からなる長さ N の文字列 S と、1 以上 N 以下の整数 K が与えられます。
	// 文字列 S の K 文字目を小文字に書き換え、新しくできた S を出力してください。

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

		int N = in.nextInt();
		int K = in.nextInt();
		String S = in.next();

		if ( K == 1 ) {
			String target = S.substring(0, 1);
			String back = S.substring(K);

			String result = target.toLowerCase() + back;
			System.out.println(result);
			return;
		}

		String front = S.substring(0, K - 1);
		String target = S.substring(K - 1, K);
		String back = S.substring(K);

		String result = front + target.toLowerCase() + back;

		System.out.println(result);
	}
}


Measured memory_bytes: 20560
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime> 

using namespace std;

int main(void){
	int a;
	int maxa=0;
	vector<int> ans;
	map<int,int> f;
	for(a=0;a<=100;a++){
		f.insert( map<int,int>::value_type(a,0));
	}
	while(~scanf("%d",&a)){
		f[a]++;
	}
	for(a=0;a<=100;a++){
		maxa=max(maxa,f[a]);
	}
	for(a=0;a<=100;a++){
		if(maxa==f[a])ans.push_back(a);
	}
	sort(ans.begin(), ans.end());

	for(a=0;a<ans.size();a++){
		cout << ans[a] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
// dile a la jardinera que traigo flores
// corner cases // int vs ll // cin vs scanf
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define N 100050
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int INF = 1e9+10;

int n,W,w[128],v[128],dp[128][N];

int main(){

	fastio;
	cin >> n >> W;
	FER(i,0,n) cin >> w[i] >> v[i];
	FER(i,0,128) FER(j,0,N) dp[i][j] = INF;
	dp[0][0] = 0;
	
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < N; ++j){
			dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
			if(dp[i][j] + w[i] <= W)
				dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]],dp[i][j] + w[i]);
		}
	}

	int ans;
	for(ans = N-1; dp[n][ans] == INF; --ans);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 50304
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n;
    cin>>n;
    vi a(n);
    LL c[202020]={};
    FOR(i,0,n){
        cin>>a[i];
        c[a[i]]++;
    }
    LL ans=0;
    FOR(i,0,202020){
        if(c[i]>=2){
            ans+=c[i]*(c[i]-1)/2;
        }
    }
    FOR(i,0,n){
        if(c[a[i]]>=2){
            cout<<ans-c[a[i]]*(c[a[i]]-1)/2+(c[a[i]]-2)*(c[a[i]]-1)/2<<endl;
        }else{
            cout<<ans<<endl;
        }
    }


}


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

int main() {
  int n;
  cin >> n;
  
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    
    if (a == b) cnt++;
    else cnt = 0;
    
    if (cnt == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

int main() {
int64_t n,a,b;
  cin>>n;
  vector<int64_t> p;
   vector<int64_t> m; 
  for(int64_t i=0;i<n;i++){
  cin>>a>>b;
    p.push_back(a+b);
    m.push_back(a-b);
  }
  sort(p.begin(), p.end());
  sort(m.begin(),m.end());
  cout<<max((p.at(n-1)-p.at(0)),(m.at(n-1)-m.at(0)))<<endl;
}

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

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(s...)  fprintf(stderr, s)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
const string X = "CODEFESTIVAL2016";
string S;

int main() {
    cin >> S;
    int ans =0; 
    REP (i, 16) ans += (S[i] != X[i]);
    printf("%d\n", ans);


    return 0;
}



Measured memory_bytes: 256
let modulo = 1000000007
let (+@) a b = (a + b) mod modulo
let ( *@) a b = (a * b) mod modulo
let rec mod_pow a n =
  if n = 0 then 1
  else if n mod 2 = 1 then a *@ mod_pow a (n-1)
  else let h = mod_pow a (n/2) in h *@ h
let () =
  Scanf.scanf "%d %d %d" @@ fun h w k ->
  let dp = Array.init (h+1) (fun _ -> Array.make w 0) in
  dp.(0).(0) <- 1;
  for i = 1 to h do
    for b = 1 to mod_pow 2 (w-1) do
      let exc = Array.init (w-1) (fun j -> b land (1 lsl j) > 0) in
      let valid = fst @@
        Array.fold_left (fun (a,p) b ->
          a && (not (p && b)), b) (true, false) exc
      in
      if valid then begin
        for j = 0 to w-1 do
          if (j = 0 || not exc.(j-1)) && (j = w-1 || not exc.(j)) then
            dp.(i).(j) <- dp.(i).(j) +@ dp.(i-1).(j);
        done;
        Array.iteri (fun j b ->
          if b then begin
            dp.(i).(j)   <- dp.(i).(j) +@ dp.(i-1).(j+1);
            dp.(i).(j+1) <- dp.(i).(j+1) +@ dp.(i-1).(j);
          end) exc
      end
    done;
  done;
  Printf.printf "%d\n" dp.(h).(k-1)


Measured memory_bytes: 2560
n, m = map(int, input().split())
alis = list(map(int, input().split()))
my_dict = dict()

tmp = 0

for item in alis:
    tmp += item
    tmp %= m
    if tmp in my_dict:
        my_dict[tmp] += 1
    else:
        my_dict[tmp] = 1

ret = 0

for item in my_dict:
    if item == 0:
        val = my_dict[item]
        ret += val * (val - 1) // 2 + val
    else:
        val = my_dict[item]
        ret += val * (val - 1) // 2

print(ret)


Measured memory_bytes: 14224
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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 A,B;

int main(){
    cin>>A>>B;
    out(max(A+B,max(A-B,A*B)));
    
    
}


Measured memory_bytes: 256
/*
ID: Aman Raj
LANG: C++
TASK: prefix
*/
//#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long int ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
//#define mod 13
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
   ll power(ll a,ll b)//a raised to power b
   {  if(b==0)return 1;if(b==1)return a;
       ll c=power(a,b/2);
       c*=c;c%=mod;if(b%2==1)c*=a;c%=mod;
        return c;
   }
   ll mi(ll a)
   {
       return power(a,mod-2);
   }

   int main()
{     vector<ll>  v(2);
      for(ll i=0;i<2;i++)cin>>v[i];
        sort(all(v));
         if((v[0]+v[1])%2==0) cout<<(v[0]+v[1])/2;
         else cout<<"IMPOSSIBLE";

    return 0;
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007
#define N 100005



int main() {

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

    ll t=1;
    //cin>>t;

    while(t--) {

        ll x;
        cin>>x;

        for(int i=-120;i<=120;i++) {
            for(int j=-120;j<=120;j++) {
                ll k1 = pow(i , 5);
                ll k2 = pow(j , 5);

                if(k1 - k2 == x) {
                    cout<<i<<" "<<j<<"\n";
                    return 0;
                }
            }

       }
    }



}


Measured memory_bytes: 4032
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
  int64_t number = 3;
  int64_t prev0 = 2;
  int64_t prev1 = 1;
  int n;
  cin >> n; 
  if (n==1){
    cout << 1 << endl;
  }
  else if (n==2){
    cout << 3 << endl;
  }
  else{
    for (int i =2; i<=n; i++){
      number = prev0 + prev1;
      prev0 = prev1;
      prev1 = number;
    }
    cout << number << endl;
  }
  
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    char s[222];
    cin >> s;
    int n = strlen(s);
    for (int i=n-2; 0<i; i-=2){
        if(strncmp(s, s+i/2, i/2) == 0){
            out(i);
            return 0;
        }
    }
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, W;
    cin >> n >> W;
    vi v(n), w(n);
    rep(i, n) {
        cin >> v[i] >> w[i];
    }

    vi dp(W+1);
    rep(i, n) {
        for(int j = W-w[i]; j >= 0; --j) {
            dp[j+w[i]] = max(dp[j+w[i]], dp[j] + v[i]);
        }
    }

    rep(i, W) {
        dp[i+1] = max(dp[i+1], dp[i]);
    }

    cout << dp[W] << endl;
}


Measured memory_bytes: 3228
n,m = (int(i) for i in input().split())
x = [0 for i in range(n)]
for _ in range(m):
	a,b = (int(i)-1 for i in input().split())
	x[a],x[b] = 1-x[a],1-x[b]
if sum(x): print("NO")
else: print("YES")

Measured memory_bytes: 4008
#include <iostream>

using namespace std;

typedef long long ll;
#define x first
#define y second
#define mp make_pair

int n, m;

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
cout << (n * (n - 1)) / 2 + (m * (m - 1)) / 2 << endl;

return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, r;
	cin>>n>>r;
	if(n>=10){
		cout<<r<<endl;
	}else{
		cout<<r+100*(10-n)<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

import javax.print.attribute.standard.DialogTypeSelection;

class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int count = 0;
        for(int i = 1; i <= n; i++){
            if(((int)(Math.log10(i)) + 1) % 2 == 1) count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C, D = MAP()

while 1:
    C -= B
    # print(C)
    if C <= 0:
        print("Yes")
        exit()
    A -= D
    # print(A)
    if A <= 0:
        print("No")
        exit()


Measured memory_bytes: 10052
#include<bits/stdc++.h>
#define  forn(i, n)  for(int i=0; i < (int)n; i++)
#define  vi          vector<int>
// #define  pb          push_back
// #define  ap          append
// #define  mii         map<int, int> 
using namespace std ;
// vector<string> splitstring(string str, string delimiter) {
//     vector<string> v;
//     string token;
//     istringstream parse(str);
//     while(getline(parse, token, delimiter)) {
//     v.push_back(token);
//     }
//     return v;
// }
// int gcd (int a, int b) {
//     if (b == 0) return a;
//     else return gcd (b, a % b);
// }
// int lcm(int a, int b){
//   return a / gcd(a,b) * b;
// }
int a[200010];
int ans[200010];   
void solve() {
   int n ;
   cin >> n ;
   for(int i=2; i<=n; i++) cin >> a[i] ;
   for(int j=2; j<=n; j++) ans[a[j]]++ ;
   for(int i=1; i<=n; i++) cout << ans[i] << "\n";  
}
int main() {
  int t=1;
  //cin >> t ;
  while(t--) solve() ;
  return 0 ;
}


Measured memory_bytes: 5192
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  int n,a=0,b=0,c=0,d=0,e=0;
  cin >> n;
  bool flag = false;
  
  for(int i=31;i>0;i--){
    for(int j=n;j>0;j--){
      if(j==i*i){
        a=j;
        flag = true;
        break;
      }
    }
    if(flag){
        flag = false;
        break;
    }
  }
  
  for(int i=10;i>0;i--){
    for(int j=n;j>0;j--){
      if(j==i*i*i){
        b=j;
        flag = true;
        break;
      }
    }
    if(flag){
        flag = false;
        break;
    }
  }
  for(int i=3;i>0;i--){
    for(int j=n;j>0;j--){
      if(j==(i*i*i*i*i)){
        c=j;
        flag = true;
        break;
      }
    }
    if(flag){
        flag = false;
        break;
      }
  }
  for(int i=2;i>0;i--){
    for(int j=n;j>0;j--){
      if(j==(i*i*i*i*i*i*i)){
        d=j;
        flag = true;
        break;
      }
    }
    if(flag){
        flag = false;
        break;
      }
  }
  for(int i=2;i>0;i--){
    for(int j=n;j>0;j--){
      if(j==(i*i*i*i*i*i*i*i*i)){
        e=j;
        flag = true;
        break;
      }
    }
    if(flag){
        flag = false;
        break;
      }
  }
  cout << max(max(a,b),max(max(c,d),e)) << endl;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n;cin>>n;
    vl a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    ll res = a[0];
    ll mul = a[n-1];
    ll idx = 0;
    rep(i,n-1){
        ll ans  = min(mul-a[i],a[i]);
        if(res < ans){
            res = ans;
            idx = i;
        }
    }
    cout << mul << " " << a[idx] << endl;
}


Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N;
    cin >> N;

    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    vector<int> odd;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] % 2 == 0) ans += A[i];
        else odd.push_back(A[i]);
    }

    sort(odd.begin(), odd.end());
    if (odd.size() % 2 == 1) {
        for (int i = 1; i < odd.size(); i++) ans += odd[i];
    } else {
        ans += accumulate(odd.begin(), odd.end(), 0);
    }

    cout << ans / 2 << endl;

}












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

using namespace std;

int par[100010];
int root[100010];
   
void init( int n ){
  for(int i=0;i<n;i++){
    par[i] = i ;
    root[i] = 0;
  }
}

int find(int x){
  if(par[x] == x){
    return x ;
  }
else{
  return par[x] = find(par[x]);
}
}

void unite(int x , int y ){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  
  if(root[x] < root[y]){
    par[x] = y;
  }
  else{
    par[y] = x ;
    if(root[x] == root[y]) root[x]++;
  }
}

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


int main(){
  
  init(100010);
  
  int n , m;
  
  int a[100010],b[100010],c[100010];
  
  cin >> n >> m;
  
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i] >> c[i];
    
    a[i]--;
    b[i]--;
    c[i]--;
  }
  
  for(int i=0;i<m;i++){
    unite(a[i] , b[i]);
  }
  
    set<int> se;
    
    for (int i = 0; i < n; ++i){
      se.insert(find(i));
    
  }
  
cout << (int)se.size() << endl;
}

  
  


Measured memory_bytes: 6784
N, W = map(int, input().split())
vw = [list(map(int, input().split())) for _ in range(N)]
dp = [[0]*(W+1) for _ in range(N+1)] #i番目までみたときの重さjでの価値の最大値
for i in range(N):
  v, w = vw[i]
  for j in range(W+1):
    if w <= j:
      dp[i+1][j] = max(dp[i][j], dp[i][j-w]+v)
    else:
      dp[i+1][j] = dp[i][j]
print(dp[N][W])


Measured memory_bytes: 25520
#!python3

# input
N = int(input())
A = list(map(int, input().split()))
# N = 2000
# A = [i for i in range(1, N + 1)]


def main():
    P = [(A[i], i + 1) for i in range(N)]
    P.sort(reverse=True)

    dp = [[0] * (N + 1) for _ in range(N + 1)]
    for n, p in zip(range(1, N + 1), P):
        x, y = p
        for i in range(n):
            j = n - 1 - i
            left = dp[i][j] + x * abs(y - (i + 1))
            dp[i + 1][j] = max(dp[i + 1][j], left)
            right = dp[i][j] + x * abs(y - (N - j))
            dp[i][j + 1] = max(dp[i][j + 1], right)

    ans = max([dp[i][N - i] for i in range(N)])
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    int h, w;
    cin >> h >> w;
    string map[h]; rep(i, h) cin >> map[i];
    Graph G(h*w);
    vector<int> dist(h*w, -1);
    queue<int> que;
    int white = 0;
    rep(i, h){
        rep(j, w){
            if(map[i][j] == '.'){
                white++;
                if(i != 0){
                    if(map[i-1][j]){
                        G[i*w+j].emplace_back((i-1)*w+j);
                        G[(i-1)*w+j].emplace_back(i*w+j);
                    }
                }
                if(j != 0){
                    if(map[i][j-1]){
                        G[i*w+j].emplace_back(i*w+j-1);
                        G[i*w+j-1].emplace_back(i*w+j);
                    }
                }
            }
        }
    }
    dist[0] = 0;
    que.push(0);
    
    while(!que.empty()){
        int v = que.front();
        que.pop();
        
        for(int nv: G[v]){
            if(dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
    int cost = dist.back();
    if(cost == -1){
        cout << -1 << endl;
    }else{
        cout << white - cost - 1 << endl;
    }
}




Measured memory_bytes: 384
a=int(input())
b=int(input())
c=int(input())
x=int(input())
count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x == i*500 + j*100 + k*50:
                count += 1
print(count)

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

//read_kaisetsu
int MOD = 1000000007;

int main() {
    int n;cin>>n;
    int a[1001];
    rep(i,1001)a[i]=1;  
    for(int i=2;i<=n;++i){
            int k=i;
            int j=2;
            while(k>1){
            while(k%j==0){
                ++a[j];
                k/=j;
            }
            ++j;
        }
    }
    ll ans = 1;
    rep(i,1001)if(a[i]!=0)ans=(ans*a[i])%MOD;
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3628
let bas = Scanf.scanf "%d %d" @@ fun _ m -> Array.init m @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> b, a
let _ = Array.(sort compare bas; fold_left (fun (c, k) (b, a) -> if a <= k then c, k else c + 1, b - 1) (0, 0) bas) |> fst |> Printf.printf "%d\n"

Measured memory_bytes: 6784
s=input()
N=len(s)
rl=[]
tmp=""
t=0
ans=[-1,-1]

for i in range(N):
    if tmp=="":
        tmp=s[i]
        t +=1
    else:
        if s[i]==tmp:
            t +=1
            ans = [i-t+2,i+1]
        else:
            rl.append([tmp,t,i])
            tmp=s[i]
            t=1
else:
    rl.append([tmp,t,N])
    
#print(rl)
if ans!=[-1,-1]:
    print(*ans)
else:
    leng=len(rl)
    if leng>=3:
        for j in range(2,leng):
            if rl[j][0]==rl[j-2][0]:
                ans=[rl[j][2]-2,rl[j][2]]
                break
    print(*ans)

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

int main() {
  ll n, k; cin >> n >> k;
  if (n % k == 0) cout << 0 << endl;
  else if (n < k) cout << min(n, k - n) << endl;
  else cout << min(abs(n - (n / k) * k), abs(n - ((n + k - 1) / k) * k)) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    A--;
    ll ans = B + B / (C * D / GCD(C, D)) - (B / C + B / D) - (A + A / (C * D / GCD(C, D)) - (A / C + A / D));
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
N, M, X = map(int, input().split())

algo = [X] * M
b = [None] * N

for i in range(N):
    c, *l = map(int, input().split())
    b[i] = (c, l)


res = float("inf")

mask = 0
while (mask < (1<<N)):
    cost = 0
    l = [0] * M

    for i in range(N):
        if (mask & (1 << i)):
            cost += b[i][0]
            l = [b[i][1][j] + l[j] for j in range(M)]

    if all(map(lambda x: x>= X, l)):
        res = min(res, cost)

    mask += 1

if res != float("inf"):
    print(res)
else:
    print(-1)

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

const int INF = 1001001001;

int main() {
  int n, tmp = 0, ans = 0;
  cin >>n;
  int p[n];
  int sum = 0;
  rep(i,n) {
  cin >>p[i];
  sum += p[i];
  tmp = max(tmp, p[i]);
  }
  sum -= tmp/2;
  cout<<sum<<endl;

  return 0;
}

Measured memory_bytes: 256
/*       _________
        /|______/ \
        ||  _|_|\  |
        || |_|   | /
        ||    _ / |
        ||  _| \\  \    
        ||_|_|\ || |
        |/_|/ | /|_/
              /__/      Written by: Rishabh Roshan
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int            	long long
#define tree         	ped
#define integer        	int32_t
#define mod         	1000000007
#define vint        	vector<integer>
#define pint        	pair<integer, integer>
#define umint        	unordered_map<integer, integer>
#define mint        	map<integer, integer>
#define in(x)        	int x; cin>>x
#define setbits(x)    	__builtin_popcountll(x)
#define zerobits(x)    	__builtin_ctzll(x)
#define w(x)        	int x; cin>>x; while(x--)
#define sp(x, y)    	fixed<<setprecision(y)<<x
#define poll(x)        	x.front(); x.pop()
#define f(x)        	for(int i=0; i<x; i++)
#define endl         	'\n'
#define inf         	1e9 
#define order_set     	tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

// #include "functions.h"

void om_shree_ganeshaya_namah(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main(){
    
    om_shree_ganeshaya_namah();

    in(n);
    vector<vint> dp(n, vint(3));
    f(n) for(int j=0; j<3; j++) cin>>dp[i][j];

    for(int i=1; i<n; i++){
    	for(int j=0; j<3; j++){
    		switch(j){
    			case 0:
    				dp[i][j] = max((dp[i][j]+dp[i-1][1]), (dp[i][j]+dp[i-1][2]));
    			break;
    			case 1:
    				dp[i][j] = max((dp[i][j]+dp[i-1][0]), (dp[i][j]+dp[i-1][2]));
    			break;
    			case 2:
    				dp[i][j] = max((dp[i][j]+dp[i-1][1]), (dp[i][j]+dp[i-1][0]));
    			break;
    		}
    	}
    }
    int ans = max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    cout<<ans<<endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> mochi(N);
  for (int i = 0; i < N; i++) cin >> mochi[i];
  
  set<int> kagami;

  for (int i = 0; i < N; i++) {
    kagami.insert(mochi[i]);
  }
  cout <<  kagami.size() << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
 
using namespace std;
 
const int N = 3;
const int INF = 15000001;
 
class S{
public:
  int t[N], cost;
  S(int a = 0, int b = 0, int c = 0, int cost = 0) : cost(cost){
    t[0] = a;
    t[1] = b;
    t[2] = c;
  }
};
 
int n, m;
 
int calc(S s, int pres, int pret){
  while(1){
    if(s.cost > m) return INF;
    if(s.t[0] == (1 << n) - 1 || s.t[2] == (1 << n) - 1) return s.cost;
    int tmp[N];
    fill(tmp, tmp+N, 0);
    for(int j=0;j<N;j++){
      for(int i=n-1;i>=0;i--){
        if(s.t[j] & 1 << i){
          tmp[j] = i+1;
          break;
        }
      }
    }
    for(int i=0;i<N;i++){
      if(tmp[i]){
        for(int j=0;j<N;j++){
          if(abs(i-j) != 1) continue;
          if(i == pret && j == pres) continue;
          if(tmp[i] > tmp[j]){
            s.t[i] -= 1 << (tmp[i] - 1);
            s.t[j] += 1 << (tmp[i] - 1);
            s.cost++;
            pres = i;
            pret = j;
            goto CONT;
          }
        }
      }
    }
    CONT:;
  }
  return INF;
}
 
int solve(S s){
  if(s.t[0] == (1 << n) - 1 || s.t[2] == (1 << n) - 1) return s.cost;
  int res = INF;
  int tmp[N];
  fill(tmp, tmp+N, -1);
  for(int j=0;j<N;j++){
    for(int i=n-1;i>=0;i--){
      if(s.t[j] & 1 << i){
        tmp[j] = i+1;
        break;
      }
    }
  }
  for(int i=0;i<N;i++){
    if(tmp[i]){
      for(int j=0;j<N;j++){
        if(abs(i-j) != 1) continue;
        if(tmp[i] > tmp[j]){
          S t = s;
          t.t[i] &= (~(1 << (tmp[i]-1)));
          t.t[j] |= (1 << (tmp[i]-1));
          t.cost++;
          res = min(res, calc(t, i, j));
        }
      }
    }
  }
  if(res == INF) return -1;
  return res;
}
 

main(){
  while(cin >> n >> m && (n|m)){
    int data[N];
    for(int i=0;i<N;i++){
      int size;
      cin >> size;
      data[i] = 0;
      for(int j=0;j<size;j++){
        int in;
        cin >> in;
        data[i] |= 1 << (in-1);
      }
    }
    cout << solve(S(data[0], data[1], data[2], 0)) << endl;
  }
}

Measured memory_bytes: 868