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

#define ll long long
#define pb push_back
#define MP make_pair
#define PLL pair<ll,ll>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

int main()
{
  ll t;
  t=1;
  while(t--)
  {
     ll n;
     cin >> n;
     ll a[n],i,j,k,count=0;

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

     sort(a,a+n);

     for(i=0;i<n;i++)
     {
       for(j=i+1;j<n;j++)
       {
         if(a[i]==a[j])
         continue;
         for(k=j+1;k<n;k++)
         {
           if(a[j]==a[k])
           continue;

           if(a[i]+a[j] > a[k] )
           count++;
         }
       }
     }
     cout << count << '\n';
  }
}


Measured memory_bytes: 3636
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

std::string s;
long cnt, ans;

int main(){
    std::cin >> s;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'S'){
            cnt++;
        }else{
            if(cnt > 0){
                cnt--;
            }else{
                ans++;
            }
        }
    }
    printf("%ld\n", ans*2);
}


Measured memory_bytes: 640
N,A,B = map(int,input().split())
H=[int(input()) for i in range(N)]
C = A-B
def tao(k):
    num=0
    for h in H:
        t = h -B*k
        if t >0:
            num += t//C
            if t %C !=0:
                num +=1
    if num <= k:
        return True
    else:
        return False

mi =0
ma=10**9+1
while ma-mi>1:
    mid = (ma +mi)//2
    if tao(mid):
        ma=mid
    else:
        mi=mid
print(ma)

Measured memory_bytes: 7072
import java.util.Scanner;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int [] mo = new int [5];
		int min=2001;
		int sum=0;
		Scanner sc = new Scanner(System.in);
		for(int i = 0; i < mo.length; i++){
			mo[i]=sc.nextInt();
		}
		for(int m = 0; m < 3; m++){
			for(int n = 3; n < 5; n++){
				sum = (mo[m]+mo[n])-50;
				if(min>sum){
					min = sum;
				}
			}
		}
		System.out.println(min);
		// TODO Auto-generated method stub

	}

}

Measured memory_bytes: 17356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//---------------------------------------------------------------------------------------------------
ll MOD = 1e9+7;
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
 
void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long C(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//---------------------------------------------------------------------------------------------------

ll add(ll &a, ll b)
{
    a = (a+b)%MOD;
}
ll mul(ll &a, ll b)
{
    a = a * b % MOD;
}

int main()
{
    init();
    ll n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    for(ll d = 1; d <= m-1; d++)
    {
        ll tmp = 1;
        mul(tmp, m-d);
        mul(tmp, n);
        mul(tmp, n);
        mul(tmp, d);
        add(ans, tmp);
    }
    for(ll d = 1; d <= n-1; d++)
    {
        ll tmp = 1;
        mul(tmp, n-d);
        mul(tmp, m);
        mul(tmp, m);
        mul(tmp, d);
        add(ans, tmp);
    }
    mul(ans, C(n*m-2, k-2));
    cout << (ans+MOD)%MOD << endl;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int x, y; x = tx - sx; y = ty - sy;
    for (int i = 0; i < y; i++) {
        printf("U");
    }
    for (int i = 0; i < x; i++) {
        printf("R");
    }
    for (int i = 0; i < y; i++) {
        printf("D");
    }
    for (int i = 0; i < x+1; i++) {
        printf("L");
    }
    for (int i = 0; i < y+1; i++) {
        printf("U");
    }
    for (int i = 0; i < x+1; i++) {
        printf("R");
    }
    printf("D");
    printf("R");
    for (int i = 0; i < y+1; i++) {
        printf("D");
    }
    for (int i = 0; i < x+1; i++) {
        printf("L");
    }
    printf("U\n");

}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
inline long long func(long long x)
{
	return x * x * x * x * x;
}
signed main()
{
	long long x;
	scanf("%lld", &x);
	for(long long i = -500; i <= 500; ++i)
	{
		for(long long j = -500; j <= 500; ++j)
		{
			if(func(i) - func(j) == x)
			{
				printf("%lld %lld\n", i, j);
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3828
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>

#define long long ll

using namespace std;
char op[2] = {'+', '-'};
int sign[2] = {1, -1};
int comb[3];
int input;
int N[4];

int main()
{
    cin >> input;

    for (int i=0; i<4; i++) {
        int rank = static_cast<int>(pow(10, 3-i));
        N[i] = input / rank;
        input -= N[i] * rank;
    }
    
    for (comb[0] = 0; comb[0] < 2; comb[0]++) {
        for (comb[1] = 0; comb[1] < 2; comb[1]++) {
            for (comb[2] = 0; comb[2] < 2; comb[2]++) {

                int sum = N[0];

                for (int i=0; i<3; i++) {
                    sum += N[i+1] * sign[comb[i]];
                }

                if (sum == 7) {
                    cout << N[0];
                    for (int i=0; i<3; i++) {
                        cout << op[comb[i]] << N[i+1];
                    }
                    cout << "=7" << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

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

using P=std::pair<int,int>;
constexpr int MAX_N=3000;

int n;

std::set<P> set;

int X[MAX_N],Y[MAX_N];

void swap(int& x,int& y){
	int tmp=x;
	x=y;
	y=-tmp;
}

int main(){
	while(std::cin>>n){
		if(n==0)
			break;
		for(int i=0;i<n;++i){
			std::cin>>X[i]>>Y[i];
			set.emplace(X[i],Y[i]);
		}
		int max=0;
		for(int i=0;i<n;++i){
			for(int j=0;j<n;++j){
				int vX=X[j]-X[i];
				int vY=Y[j]-Y[i];
				swap(vX,vY);
				int x=X[j]+vX;
				int y=Y[j]+vY;
				if(x>=0&&y>=0&&set.count(P(x,y))){
					swap(vX,vY);
					if(x+vX>=0&&y+vY>=0&&set.count(P(x+vX,y+vY))){
						max=std::max(max,vX*vX+vY*vY);
					}
				}
			}
		}
		std::cout<<max<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 3764
#include<stdio.h>
#include<math.h>

int isprime(int);

#define N 10000

int main(){

  int A[N],i,n,count = 0;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
    if(isprime(A[i]) == 1) count++;
  }

  printf("%d\n",count);

  return 0;
}

int isprime(x){

  int i = 3;

  if(x == 2){
    return 1;
  }

  else if(x < 2 || x % 2 == 0){
    return 0;
  }

  while(i <= sqrt(x)){
    if(x % i == 0){
      return 0;
    }
    i += 2;
  }

  return 1;
}

Measured memory_bytes: 628
X, K, D = map(int, input().split())
a, b = abs(X)//D, abs(X)%D
if K <= a:
  if X >= 0:
    ans = X - K*D
  else:
    ans = X + K*D
else:
  K = (K - a) % 2
  if X >= 0:
    ans = X - a*D
  else:
    ans = X + a*D
  if K == 1:
    if abs(X+D) < abs(X-D):
      ans += D
    else:
      ans -= D
print(abs(ans))

Measured memory_bytes: 9192
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    int l[n];
    long long ans = 1LL << 60;

    REP(i, n)
    {
        cin >> l[i];
    }
    for (int x = 0; x < (1 << n * 2); x++)
    {
        long long tmpans = 0;
        // 1011
        // 10 11
        // A,B,Cの竹、最後のはつかっていない竹
        // 各竹の利用を2ビットで表現する
        int lines[4] = {0, 0, 0, 0};
        int mp[4] = {0, 0, 0, 0};
        REP(i, n)
        {
            int tmp = (x >> i * 2) & 3;
            if (lines[tmp] != 0)
                mp[tmp] += 10;
            lines[tmp] += l[i];
        }
        // a,b,cそれぞれについて少なくとも１本竹をつかっているか
        if (lines[0] == 0 or lines[1] == 0 or lines[2] == 0)
            continue;
        REP(i, 3)
        {
            tmpans += mp[i] + abs(lines[i] - a[i]);
        }
        ans = min(ans, tmpans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 200020
#define M 64
using namespace std;

int f[M][N];

int main(void)
{
    int n;
    long long k;
    int i, j, o;

    scanf("%d %lld", &n, &k);
    for(i = 1; i <= n; i ++)
        scanf("%d", &f[0][i]);
    for(i = 1; i < M; i ++)
        for(j = 1; j <= n; j ++)
            f[i][j] = f[i - 1][f[i - 1][j]];

    for(i = M - 1, o = 1; i > -1; i --)
        if(k >> i & 1)
            o = f[i][o];
    printf("%d\n", o);

    return 0;
}


Measured memory_bytes: 53828
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;

int main()
{
	ll n;
	string rr = "";
	cin >> n;
	while (n>0) {
		int xx = n % 26;
		n /= 26;
		if (xx == 0) {
			rr += "z";
			n--;
		}
		else {
			rr += (char)('a' + (xx - 1));
		}
	}
	reverse(rr.begin(), rr.end());
	cout << rr;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+7;
char s[maxn];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	for(int i=1;i<=n;i++)
	{
		if(i<n&&s[i]==s[i+1])
		{
			printf("%d %d\n",i,i+1);
			return 0;
		}
		if(i<n-1&&s[i]==s[i+2])
		{
			printf("%d %d\n",i,i+2);
			return 0;
		}
	}
	printf("-1 -1\n");
}


Measured memory_bytes: 384
#include <stdio.h>
#define N 100

int main(){
  int i, j, mini, length, x, A[N], swap_count=0;
  //There is x in this program for storing the value of the element of A.

  scanf("%d",&length);
  for(i = 0; i < length; i++) scanf("%d",&A[i]);

  for(i = 0; i < length; i++){
    mini = i;
    for(j = i; j < length; j++){
      if( A[j] < A[mini] ) mini = j;
    }
    if( i != mini ){
      x = A[i];
      A[i] = A[mini];
      A[mini] = x;
      swap_count++;
    }
  }
  
  for(i = 0; i < length; i++){
    if( i == length-1 ) printf("%d\n",A[i]);
    else printf("%d ",A[i]);
  }
  printf("%d\n",swap_count);
  
  return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<int> a(n);
    vector<int> order(n);
    for(int i=0; i<n; i++){ 
        cin >> a[i];
        order[a[i]-1]=i+1;
    } 

    // for(int i=0; i<n; i++) {
    //     for(int j=0; j<n; j++) {
    //         if(i==a[j]-1){
    //             order[i]=j+1;
    //             // dbg(i);
    //             // dbg(order[i]);
    //             // dbg(j+1);
    //             break;
    //         }
    //     }
    // }
    for(int i=0; i<n; i++) {
        cout<<order[i]<<endl;
    }
    
    return  0;
}


Measured memory_bytes: 1664
Module Module1

    Sub main()
        Dim result As String = ""
        Dim total As Long = 0

        Dim user1 As List(Of String) = New List(Of String)(Split(Console.ReadLine(), " "))
        Dim honsu = user1(0)
        Dim mamoHP = user1(1)

        Dim katanaNormal As New List(Of Long), katanaThrow As New List(Of Long)

        For i = 0 To honsu - 1

            Dim user2 As List(Of String) = New List(Of String)(Split(Console.ReadLine(), " "))
            katanaNormal.Add(user2(0))
            katanaThrow.Add(user2(1))
        Next

        ' 投げ強い順にソート
        katanaThrow.Sort()
        katanaThrow.Reverse()

        ' 殴り強い刀を選出
        katanaNormal.Sort()
        katanaNormal.Reverse()
        Dim maxPowerAttack = katanaNormal(0)

        ' 投げ合計の取得
        Dim throws As New List(Of Long)
        throws = New List(Of Long)(Array.FindAll(katanaThrow.ToArray, Function(num As Long) num >= maxPowerAttack))
        total = throws.Sum

        Dim attackCount As Long = 0

        ' 投げで倒しきれたか判定
        If total > mamoHP Then

            ' 投げ回数を計測
            For Each myThrow In katanaThrow
                mamoHP -= myThrow
                attackCount += 1
                If mamoHP <= 0 Then Exit For
            Next
            result = attackCount
        Else
            ' 魔物減算
            mamoHP = mamoHP - total
            attackCount = Math.Ceiling(mamoHP / maxPowerAttack)
            result = throws.Count + attackCount
        End If
        Console.WriteLine(result)
    End Sub
end module

Measured memory_bytes: 53252
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    map<string,ll> mp;
    rep(i,n){
        string s;cin>>s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    ll res=0;
    for(auto& p:mp){
        ll now=p.second;
        now=now*(now-1)/2;
        res+=now;
    }
    cout<<res<<endl;
}

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

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()

using namespace std;
using namespace __gnu_pbds;

typedef tree< int, null_type, less< int >, rb_tree_tag, tree_order_statistics_node_update> ost;
// name.find_by_order(x) or name.order_of_key(x)
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<vector<int>> vvi;

void yes() {printf("YES\n");}
void no() {printf("NO\n");}

int dx4[] = {-1, 1, 0, 0};
int dy4[] = {0, 0, -1, 1};
int dx8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};

const int maxn = 2e5 + 5, maxv = 2e6 + 5;
const int MOD = 998244353;

int mult(ll a, ll b) {return (a * b) % MOD;}
int pot(int n, int k) {
	int ret = 1, pot = n;
	for(;k > 0;k >>= 1, pot = mult(pot, pot)) 
		ret = mult(ret, (k & 1) ? pot : 1);
	return ret;
}
int divide(int a, int b) {return mult(a, pot(b, MOD - 2));}
int add(int a, int b) {a += b;if(a >= MOD) a -= MOD;return a;}
int sub(int a, int b) {a -= b;if(a < 0) a += MOD;return a;}

vector<int> fact;
void calc_fact(int n) {
	fact = vector<int>(n + 1, 1);
	for(int i = 1;i <= n;i++) fact[i] = mult(fact[i - 1], i);
}
int choose(int n, int k) {return divide(fact[n], mult(fact[n - k], fact[k]));}

bool prime(ll a) {
	if (a == 1) return 0;
	for(ll i = 2;i * i <= a;i++) 
		if (a % i == 0) return 0;
	return 1;
}

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

ll phi(ll x) {
	double ret = x;
	for(ll i = 2;i * i <= x;i++) {
		if (x % i) continue;
		ret *= (1.0 - 1.0 / (double)i);
		while (x % i == 0) x /= i;
	}
	if (x > 1) ret *= (1.0 - 1.0 / (double)x );
	return (ll)ret;
}

int n, k, POT = 1;
ii P[11];
int seg[maxn * 4];

void update(int x, int v) {
	x += POT;
	for(;x;x >>= 1) seg[x] = add(seg[x], v);
}

int query(int node, int lo, int hi, int a, int b) {
	if(lo > hi) return 0;
	if(hi < a || lo > b) return 0;
	if(a <= lo && hi <= b) return seg[node];
	int mid = (lo + hi) / 2;
	return add(query(node * 2, lo, mid, a, b), query(node * 2 + 1, mid + 1, hi, a, b));
}

int main() {
	scanf("%d %d", &n, &k);
	for(int i = 0;i < k;i++) scanf("%d %d", &P[i].x, &P[i].y);
	while(POT < n) POT <<= 1;
	update(0, 1);
	for(int i = 1;i < n;i++) {
		int ans = 0;
		for(int j = 0;j < k;j++) {
			int a = i - P[j].y;
			int b = i - P[j].x;
			a = max(a, 0);
			if(b < 0) continue;
			int x = query(1, 0, POT - 1, a, b);
			ans = add(ans, x);
		}
		update(i, ans);
	}
	printf("%d\n", query(1, 0, POT - 1, n - 1, n - 1));
	return 0;
}


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

ll dp[110][6][6][6];

bool ng(int a,int b,int c){
  return a==1&&b==2&&c==3;
}

bool check(int a,int b,int c,int d){
  return ng(a,b,c)||ng(b,a,c)||ng(a,c,d)||ng(a,c,b)||ng(a,b,d);
}

ll f(int idx,int a,int b,int c){
  if(~dp[idx][a][b][c])return dp[idx][a][b][c];
  if(!idx)return 1;
  ll res=0;
  for(int i=0;i<4;i++)if(!check(i,a,b,c))res+=f(idx-1,i,a,b);
  return dp[idx][a][b][c]=res%MOD;
}

int main(){
  memset(dp,-1,sizeof(dp));
  int n;cin>>n;
  cout<<f(n,5,5,5)<<endl;
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int L, R, d;
    cin >>  L >> R  >> d;
    int ans = 0;
    for (int i=L; i<=R; i++){
        if (i%d==0)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define int long long
#define ri register int
#define N 5005
using namespace std;
struct node {
	int h,p;
} a[N]= {0};
int n,ans,f[N]= {0};
template <typename T> inline void read(T &x) {
    T c=getchar(),f=0;
    for (; c<48||57<c; c=getchar()) if (c=='-') f=1;
    for (x=0; 48<=c&&c<=57; c=getchar()) x=(x<<3)+(x<<1)+(c^48);
    if (f) x=-x;
}
template <typename T> inline void print(T x) {
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
inline int cmp(node a,node b) {
	return (a.h+a.p)<(b.h+b.p);
}
signed main() {
	read(n);
	for (ri i=1; i<=n; i++) read(a[i].h),read(a[i].p);
	for (ri i=1; i<=n; i++) f[i]=1e18;
	sort(a+1,a+1+n,cmp),f[0]=0;
	for (ri i=1; i<=n; i++)
		for (ri j=i; j; j--)
			if (f[j-1]<=a[i].h) f[j]=min(f[j],f[j-1]+a[i].p);
	for (ri i=0; i<=n; i++)
		if (f[i]<1e18) ans=i;
	print(ans);
    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

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

string red(string s) {
	stack<char> st;
	for(auto i: s)
		if(i=='(')
			st.push('(');
		else if(i==')' && (st.size()==0 || st.top()==')'))
			st.push(')');
		else
			st.pop();
	string ans="";
	while(st.size())
		ans+=st.top(),st.pop();
	reverse(all(ans));
	return ans;
}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
	
	ll x, y=100LL,ans=0;
	cin>>x;
	while(y<x){
		y+=y/100;
		ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 3636
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


N = ni()
A_array = na()

A = 0

for a in A_array:
    A = A ^ a

ans_array = [A ^ a for a in A_array]

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


Measured memory_bytes: 116188
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>

struct HexCoordinate {
	int x, y;
	std::vector<HexCoordinate> neighbors() const {
		if (y % 2 == 0) {
			return { {x - 1, y}, {x + 1, y}, {x, y - 1}, {x + 1, y - 1}, {x, y + 1}, {x + 1, y + 1} };
		}
		else {
			return { {x - 1, y}, {x + 1, y}, {x - 1, y - 1}, {x, y - 1}, {x - 1, y + 1}, {x, y + 1} };
		}
	}
};
int main() {
	while (true) {
		int m, n; std::cin >> m >> n; if (n == 0 && m == 0) break;
		int s; std::cin >> s;
		std::vector<std::vector<int>> min_distance(n, std::vector<int>(m, INT_MAX));
		for (auto i = 0; i < s; ++i) {
			int x, y; std::cin >> x >> y;
			std::queue<HexCoordinate> queue; queue.push(HexCoordinate{ x, y });
			min_distance[y - 1][x - 1] = 0;
			while (!queue.empty()) {
				const auto top = queue.front(); queue.pop();
				for (const auto next : top.neighbors()) if (1 <= next.x && next.x <= m && 1 <= next.y && next.y <= n) {
					if (min_distance[next.y - 1][next.x - 1] > min_distance[top.y - 1][top.x - 1] + 1) {
						min_distance[next.y - 1][next.x - 1] = min_distance[top.y - 1][top.x - 1] + 1;
						queue.push(next);
					}
				}
			}
		}
		int t; std::cin >> t;
		int max_count = 0;
		for (auto i = 0; i < t; ++i) {
			int x, y; std::cin >> x >> y;
			auto min = min_distance;
			int count = 1;
			std::queue<HexCoordinate> queue; queue.push(HexCoordinate{ x, y });
			min[y - 1][x - 1] = 0;
			while (!queue.empty()) {
				const auto top = queue.front(); queue.pop();
				for (const auto next : top.neighbors()) if (1 <= next.x && next.x <= m && 1 <= next.y && next.y <= n) {
					if (min[next.y - 1][next.x - 1] > min[top.y - 1][top.x - 1] + 1) {
						min[next.y - 1][next.x - 1] = min[top.y - 1][top.x - 1] + 1;
						queue.push(next);
						++count;
					}
				}
			}
			max_count = std::max(max_count, count);
		}
		std::cout << max_count << '\n';
	}
}



Measured memory_bytes: 3036
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 ans = 0;
	string ss;
	cin >> ss;
	for(int64 ii = 0;ii < ss.length();ii++)
	{
		if(ss[ii] != ss[ss.length() - ii - 1])
		{
			ans++;
		}
	}
	cout << ans / 2 << endl;
	return 0;
}

Measured memory_bytes: 3624
n = int(input())
l = list(map(int, input().split()))

count = 0

for i in range(n):
    min_index = i
    for j in range(i, n):
        if l[min_index] > l[j]:
            min_index = j
    if min_index != i:
        l[i], l[min_index] = l[min_index], l[i]
        count += 1

print(' '.join(map(str, l)))
print(count)



Measured memory_bytes: 5596
#include<stdio.h>

int n, A[50];

int solve (int i, int m) {
  if ( m == 0 ) return 1;
  if ( i >= n ) return 0;
  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

int main() {
  int q, M, i;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &M);
    if ( solve(0, M) ) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}


Measured memory_bytes: 2676
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size() - 1;
  for (int bit = 0; bit < (1<<n); bit++) {
    string ans;
    ans += s.at(0);
    int sum = s.at(0) - '0';
    for (int j = 2; j >= 0; j--) {
      if (bit & (1 << j)) {
        sum -= s.at(4 - j - 1) - '0';
        ans += "-";
        ans += s.at(4 - j - 1);
      } else {
        sum += s.at(4 - j - 1) - '0';
        ans += "+";
        ans += s.at(4 - j - 1);
      }
    }
    if (sum == 7) {
      cout << ans << "=7" << endl;
      break;
    } else {
      ans.clear();
    }
  }
}


Measured memory_bytes: 256
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA
*/
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
using namespace std::tr1;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld\n",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli,lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};
lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    lli a,b;
    cin>>a>>b;
    if((a*b)%2)
    {
        cout<<"Odd";
    }
    else
    {
        cout<<"Even";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,j,k) for(int (i)=(j);(i)<(k);++(i))

int main(){
    int N,ans=0;
    cin>>N;++N;
    vector<int> A(N,0),B(N,0);
    rep(i,1,N){cin>>A[i];A[i]+=A[i-1];}
    rep(i,1,N){cin>>B[i];B[i]+=B[i-1];}
    rep(i,1,N)ans=max(ans,A[i]+B[N-1]-B[i-1]);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import heapq

N,u,v = map(int,input().split())
u -= 1
v -= 1

du = [float('inf')]*N
dv = [float('inf')]*N
G = [[]]*N

def calcDist(s, dist):
    q = []
    heapq.heappush(q,[0, s])
    dist[s] = int(0)
    
    while q!=[]:
        p = heapq.heappop(q)
        pv = p[1]
        if dist[pv] < p[0] :
            continue
        for eto in G[pv]:
            if dist[eto] > dist[pv] + 1:
                 dist[eto] = int(dist[pv] + 1)
                 heapq.heappush(q, [dist[eto], eto])


for i in range(N-1):
    e1,e2 = map(int, input().split())
    e1 -= 1
    e2 -= 1
    if G[e1] == []:
        G[e1] = [e2]
    else:
        G[e1].append(e2)
    if G[e2] == []:
        G[e2] = [e1]
    else:
        G[e2].append(e1)

if v in G[u]:
    ans = 0
else:    

    calcDist(v,dv)
    calcDist(u,du)
    maxD = 0
    for idu,idv in zip(du,dv):
        if idu < idv:
            maxD = max(maxD, idv)       
    ans = maxD-1
    
print(ans)

Measured memory_bytes: 29520
import sys
input = lambda : sys.stdin.readline().rstrip()

import heapq
h = []
heapq.heapify(h)

n, m, s = list(map(int, input().split()))
a, b = [[None] * m for _ in range(2)]
c, d = [[None] * n for _ in range(2)]

ns = {u: set() for u in range(n)}
uv2e = {}
for i in range(m):
    u,v,a[i],b[i] = list(map(int, input().split()))
    ns[u-1].add(v-1)
    ns[v-1].add(u-1)
    uv2e[u-1,v-1] = i
    uv2e[v-1,u-1] = i
for i in range(n):
    c[i], d[i] = list(map(int, input().split()))

maxs = max(a)*(n-1)
s = min(s, maxs)
state = (0, 0, s) # (距離, ノード, 銀貨枚数)
ans = [[None] * (maxs+1) for _ in range(n)]
heapq.heappush(h, state)
count = 0
while h:
    count += 1
    dd, u, ss = heapq.heappop(h)
#     print(dd, u, ss)
    if ans[u][ss] is not None and ans[u][ss] <= dd:
        continue
    ans[u][ss] = dd
    
    # グラフの隣接点
    for v in ns[u]:
        e= uv2e[u,v]
        if ss<a[e] or ans[v][ss-a[e]] is not None:
            continue
        heapq.heappush(h, (dd + b[e], v, ss-a[e]))
    # 両替
    if ss+c[u] <= maxs:
        heapq.heappush(h, (dd + d[u], u, ss+c[u]))
    elif ss < maxs:
        heapq.heappush(h, (dd + d[u], u, maxs))

for item in ans[1:]:
    print(min(item))


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

int main(){
	int k; cin >>k;
	int odd = 0, even =0;
	for(int i = 1; i <= k; i++){
		if( i % 2 == 0 )
			even++;
		else
			odd++;
	}
	cout << even * odd << endl;
	return 0;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> input = Arrays.asList(br.readLine().split(" "));
            List<Integer> numbers = new ArrayList<>();

            for (String s : input) {
                numbers.add(Integer.parseInt(s));
            }

            int staminaOfMonster = numbers.get(0);
            int aggressivityOfServal = numbers.get(1);
            int result = 0;

            do {
                result += 1;
                staminaOfMonster -= aggressivityOfServal;
            } while (staminaOfMonster >= aggressivityOfServal || staminaOfMonster > 0);

            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h,a; cin>>h>>a;
  cout<<(h+a-1)/a<<endl;
}
 

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int a[100002];
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 0, j; i < n; ++i)
	{
		scanf("%d", &j);
		++a[j];
		++a[j + 1];
		++a[j + 2];
	}
	printf("%d\n", *max_element(a, a + 100002));
}

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

int main() {
    string a, b;
    cin >> a >> b;
    long long N = stoll(a + b);
    for (int i = 1; i * i <= N; i++) {
        if (i * i == N) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Dice dice = new Dice();
		int s1 = sc.nextInt();
		int s2 = sc.nextInt();
		int s3 = sc.nextInt();
		int s4 = sc.nextInt();
		int s5 = sc.nextInt();
		int s6 = sc.nextInt();
		dice.setSurf(s1, s2, s3, s4, s5, s6);
		int q = sc.nextInt();
		int ue[] = new int[q];
		int mae[] = new int[q];
		for (int i = 0; i < q; i++) {
			ue[i] = sc.nextInt();
			mae[i] = sc.nextInt();
		}
		for (int i = 0; i < q; i++) {
			while (true) {
				if (ue[i] == dice.getSurf1() && mae[i] == dice.getSurf2()) {
					System.out.println(dice.getSurf3());
					break;
				} else if (ue[i] == dice.getSurf1()) {
					dice.rollR();
				} else if (mae[i] == dice.getSurf2()) {
					dice.rollE();
				} else {
					dice.rollN();
				}
			}
		}
	}
}

class Dice {
	private int surf1;
	private int surf2;
	private int surf3;
	private int surf4;
	private int surf5;
	private int surf6;
	private int upper;
	private int rightside;

	public int getSurf1() {
		return surf1;
	}

	public int getSurf2() {
		return surf2;
	}

	public int getSurf3() {
		return surf3;
	}

	public int getSurf4() {
		return surf4;
	}

	public int getSurf5() {
		return surf5;
	}

	public int getSurf6() {
		return surf6;
	}

	public void setSurf(int surf1, int surf2, int surf3, int surf4, int surf5, int surf6) {
		this.surf1 = surf1;
		this.surf2 = surf2;
		this.surf3 = surf3;
		this.surf4 = surf4;
		this.surf5 = surf5;
		this.surf6 = surf6;
	}

	public void rollN() {
		this.upper = this.surf2;
		this.surf2 = this.surf6;
		this.surf6 = this.surf5;
		this.surf5 = this.surf1;
		this.surf1 = this.upper;
	}

	public void rollS() {
		this.upper = this.surf5;
		this.surf5 = this.surf6;
		this.surf6 = this.surf2;
		this.surf2 = this.surf1;
		this.surf1 = this.upper;
	}

	public void rollE() {
		this.upper = this.surf4;
		this.surf4 = this.surf6;
		this.surf6 = this.surf3;
		this.surf3 = this.surf1;
		this.surf1 = this.upper;
	}

	public void rollW() {
		this.upper = this.surf3;
		this.surf3 = this.surf6;
		this.surf6 = this.surf4;
		this.surf4 = this.surf1;
		this.surf1 = this.upper;
	}

	public void rollR() {
		this.rightside = this.surf5;
		this.surf5 = this.surf4;
		this.surf4 = this.surf2;
		this.surf2 = this.surf3;
		this.surf3 = this.rightside;
	}
}


Measured memory_bytes: 26276
def main():
    import sys

    sys.setrecursionlimit(10 ** 7)

    N, M = map(int, input().split())

    g = tuple(set() for _ in range(N))
    for _ in range(M):
        a, b = (int(x) - 1 for x in input().split())
        g[a].add(b)
        g[b].add(a)

    def dfs(v=0, visited=1 << 0):
        if visited == (1 << N) - 1:
            return 1

        ret = 0
        for u in g[v]:
            if (visited >> u) & 1:
                continue
            ret += dfs(u, visited | (1 << u))
        return ret

    ans = dfs()
    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 3064
/*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n;i>0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    string s,t;
    cin>>s>>t;
    rep(i,s.size()-1)cout<<s[i]<<t[i];
    cout<<s[s.size()-1];
    if(s.size()==t.size()) cout<<t[t.size()-1];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
s = deque(input())
Q = int(input())
c = 0
for _ in range(Q):
  q = input()
  if (q[0] == "1"):
    c += 1
  else:
    if (q[2] == "1"):
      if (c % 2 == 0):
        s.appendleft(q[4])
      else:
        s.append(q[4])
    else:
      if (c % 2 == 0):
        s.append(q[4])
      else:
        s.appendleft(q[4])
if (c % 2 == 0):
  print("".join(list(s)))
else:
  print("".join(list(s))[::-1])

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

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


int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<int>> t(h, vector<int>(w));

    int current = 0, ans = 0;

    rep(i, h) {
        string tmp;
        cin >> tmp;
        rep(j, w) {
            t[i][j] = (tmp[j] == '.') ? 0 : 1;
            if (t[i][j] == 1) current++;
        }
    }

    // if (current == k) ans++;

    int n = h + w;

    for (int bit = 0; bit < (1 << n); bit++) {
        vector<int> b(n, 0);
        current = 0;
        rep(i, n) {
            if (bit & (1 << i)) {
                b[i] = 1;
            }
        }
        rep(x, h) {
            rep(y, w) {
                if (b[x] == 1 || b[y + h] == 1) {
                    continue;
                }
                if (t[x][y] == 1) current++;
                // cout << "x = " << x << " y = " << y << endl;
            }
        }

        if (current == k) {
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}
/*
vector<pair<int, int>> b;

rep(i, h) {
    rep(j, w) {
        b.push_back(make_pair(i, j));
    }
}

vector<int> c;

rep(i,h){
    c.push_back(i);
}
// 行のみ
rep(i, h) {
    current = 0;
    rep(j, h) {
        rep(l, w) {
            if(c[i] == j) continue;

            if (t[j][l] == 1) {
                current++;
            }
        }
    }
    if (current == k) {
        ans++;
    }
}


vector<int> d;

rep(i,h){
    d.push_back(i);
}

// 列のみ
rep(i,w) {
    current = 0;
    rep(j, h) {
        rep(l, w) {
            cout << i << " ij " << j << endl;
            if (d[i] == l) continue;

            if (t[j][l] == 1) {
                current++;
            }
        }
    }
    if (current == k) {
        ans++;
    }

    cout << current << endl;
}

// i行目j列目を変更
rep(i, h * w) {
    current = 0;
    rep(x, h) {
        rep(y, w) {
            if (x == b[i].first || y == b[i].second) {
                continue;
            }
            if (t[x][y] == 1) {
                current++;
            }
        }
    }
    cout << b[i].first + 1 << " " << b[i].second + 1 << endl;
    cout << current << endl;
    if (current == k) {
        ans++;
    }

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

Measured memory_bytes: 3628
#include <iostream>
#include <unordered_map>
using namespace std;
 
int main() {
  int N, M, tmp, mod;
  long long res, value;
  unordered_map<int,int> MOD;
  MOD[0] = 1;
  
  cin >> N >> M;
  mod = 0;
  for(int i=0; i<N; i++) {
    cin >> tmp;
    mod += tmp;
    mod %= M;
    auto itr = MOD.find(mod); 
    if( itr != MOD.end() ) {
      MOD[mod] += 1;
    } else {
      MOD[mod] = 1;
    }
  }
  
  res = 0;
  for (auto itr = MOD.begin(); itr != MOD.end(); ++itr){
    value = itr->second;
    res += value*(value-1)/2;
  }
  
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define int long long

#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##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=998244353;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	int k;
	cin>>k;
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cout<<a[k-1]<<endl;
}

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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	string s;
	cin >> s;
	string ans = s[0] + to_string(s.length()-2) + s[s.length()-1];
	P(ans);
}

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


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



int main() {
  ll S,W;
  cin>>S>>W;
  if(W>=S)
  {
    cout<<"unsafe"<<endl;
  }
  else
  {
    cout<<"safe"<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int n; ll c;
	ll X, V;
	cin >> n >> c;
	int i;
	ll x[100000], v[100000];
	ll score1[100000], score2[100000],score3[100000],score4[100000];
	for (i = 0; i < n; i++) {
		cin >> X >> V;
		x[i] = X; v[i] = V;
	}
	score1[0] = v[0] - x[0];
	score2[0] = v[n - 1] - (c - x[n - 1]);
	score3[0] = v[0] - 2*x[0];
	score4[0] = v[n - 1] - 2*(c - x[n - 1]);
	ll sushi1[100000], sushi2[100000], sushi3[100000], sushi4[100000];
	sushi1[0] = max((ll)0, score1[0]);
	sushi2[0] = max((ll)0, score2[0]);
	sushi3[0] = max((ll)0, score3[0]);
	sushi4[0] = max((ll)0, score4[0]);
	for (i = 1; i < n; i++) {
		score1[i] = score1[i-1]+v[i] - (x[i]-x[i-1]);
		score2[i] = score2[i-1]+v[n - 1 - i] - (x[n-i]-x[n - 1 - i]);
		score3[i] = score3[i - 1] + v[i] - 2*(x[i] - x[i - 1]);
		score4[i] = score4[i-1] + v[n - 1 - i] - 2*(x[n - i] - x[n - 1 - i]);
		sushi1[i] = max(sushi1[i - 1], score1[i]);
		sushi2[i] = max(sushi2[i - 1], score2[i]);
		sushi3[i] = max(sushi3[i - 1], score3[i]);
		sushi4[i] = max(sushi4[i - 1], score4[i]);
	}
	ll out = 0;
	for (i = 0; i < n-1; i++) {
		out = max(out, sushi1[i] + sushi4[n - 2 - i]);
		out = max(out, sushi2[i] + sushi3[n - 2 - i]);
	}
	out = max(out, sushi1[n - 1]);
	out = max(out, sushi2[n - 1]);
	cout << out << endl;
	return 0;
}


Measured memory_bytes: 8064
def main():
    N,M = map(int,input().split())
    if abs(N-M) > 1:
        return 0
    N_mlt = 1
    M_mlt = 1
    for i in range(1,N+1,1):
        N_mlt *= i
        N_mlt = N_mlt%1000000007
        #print(i,N_mlt)
    for i in range(1,M+1,1):
        M_mlt *= i
        M_mlt = M_mlt%1000000007
        #print(i,M_mlt)
    #print(N_mlt,M_mlt)
    ans = (N_mlt*M_mlt)%1000000007
    if abs(N-M)==0:
        ans = (ans*2)%1000000007
        return  ans
    else:
        return ans

print(main())


Measured memory_bytes: 9200
def getinputdata():

    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

a = int(arr_data[0][0])
b = int(arr_data[0][1])

arr=[]
mysum=0
for i in range(1,1000):
    
    mysum+=i
    arr.append(mysum)

for i in range(1,999):
    
    if arr[i]-arr[i-1]==b-a:
        
        print(arr[i]-b)
        break
        

Measured memory_bytes: 3064