akhauriyash/Code-Regression huggingface dataset:
def main():
    from itertools import product

    D, G = map(int, input().split())

    prob = []
    for j in range(1, D + 1):
        p, c = map(int, input().split())
        prob.append((j * 100, p, c))  # score,amount,bonus

    ans = -1
    for prd in product([0, 1], repeat=D):
        cnt = 0
        g = 0
        for j, (score, amount, bonus) in zip(prd, prob):
            if j:
                cnt += amount
                g += score * amount + bonus

        if g < G:
            for j, (score, amount, bonus) in reversed(tuple(zip(prd, prob))):
                if (not j) and (score * amount >= G - g):
                    use = (G - g + score - 1) // score
                    cnt += use
                    g += score * use
                    break

        if (g < G) or (~ans and ans <= cnt): continue
        ans = cnt

    print(ans)


if __name__ == '__main__':
    main()


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

using ll = unsigned long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int t;
  cin >> t;
  
  while (t--) {
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    
    map<ll, ll> mp; // number, minimum cost from N
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq; // cost, number
    mp[n] = 0;
    mp[0] = 1e18;
    pq.push(make_pair(0, n));
    
    while (!pq.empty()) {
      auto [cost, num] = pq.top();
      pq.pop();
      if (mp[num] < cost || num == 0) continue;
      // if (cost >= mp[0]) break;
      
      if (mp[0] > cost + d * num) mp[0] = cost + d * num;
      
      for (auto i : {-1, 0, 1}) {
        if ((num + i) % 2 != 0) continue;
        ll num2 = num + i, cost2 = cost + d * abs(i);
        if (mp.find(num2 / 2) == mp.end()) {
          mp[num2 / 2] = cost2 + a;
          pq.push(make_pair(cost2 + a, num2 / 2));
        }
        else if (mp[num2 / 2] > cost2 + a) {
          mp[num2 / 2] = cost2 + a;
          pq.push(make_pair(cost2 + a, num2 / 2));
        }
      }
      
      for (auto i : {-2, -1, 0, 1, 2}) {
        if ((num + i) % 3 != 0) continue;
        ll num2 = num + i, cost2 = cost + d * abs(i);
        if (mp.find(num2 / 3) == mp.end()) {
          mp[num2 / 3] = cost2 + b;
          pq.push(make_pair(cost2 + b, num2 / 3));
        }
        else if (mp[num2 / 3] > cost2 + b) {
          mp[num2 / 3] = cost2 + b;
          pq.push(make_pair(cost2 + b, num2 / 3));
        }
      }
      
      for (auto i : {-4, -3, -2, -1, 0, 1, 2, 3, 4}) {
        if ((num + i) % 5 != 0) continue;
        ll num2 = num + i, cost2 = cost + d * abs(i);
        if (mp.find(num2 / 5) == mp.end()) {
          mp[num2 / 5] = cost2 + c;
          pq.push(make_pair(cost2 + c, num2 / 5));
        }
        else if (mp[num2 / 5] > cost2 + c) {
          mp[num2 / 5] = cost2 + c;
          pq.push(make_pair(cost2 + c, num2 / 5));
        }
      }
    }
    
    cout << mp[0] << '\n';
  }
}

Measured memory_bytes: 5476
import java.util.*;
import java.io.*;
public class Main{
	
  public static void main(String[] args){
  	HashMap<String,Integer> map = new HashMap<String,Integer>();
    Scanner scan = new Scanner(System.in);
    int count = scan.nextInt();
    for(int i = 0 ; i <=count ; i++){
      String key = scan.nextLine();
    	int c = map.getOrDefault(key,0);
      	map.put(key,c+1);
    }
    System.out.println("AC x " + map.getOrDefault("AC",0));
    System.out.println("WA x "+map.getOrDefault("WA",0));
    System.out.println("TLE x " + map.getOrDefault("TLE",0));
    System.out.println("RE x " + map.getOrDefault("RE",0));
                    
  
  }



}

Measured memory_bytes: 59468
#include <stdio.h>

void maxHeapify(int *, int);
void buildMaxHeap(int *);

int h;

int main(){
  int i,H[500001];

  scanf("%d",&h);

  for(i=1;i<=h;i++){
    scanf("%d",&H[i]);
  }

  buildMaxHeap(H);

  /* output */
  for(i=1;i<=h;i++){
    printf(" %d",H[i]);
  }
  printf("\n");

  return 0;
}

void maxHeapify(int *A, int i){
  int l,r,largest,B;
  l = 2*i;
  r = 2*i+1;
  // 左の子、自分、右の子で値が最大のノードを選ぶ
  if(l <= h && A[l]>A[i]) largest=l;
  else largest = i;
  if(r <= h && A[r]>A[largest]) largest = r;
  if(largest!=i){
    B=A[i];
    A[i]=A[largest];
    A[largest]=B;

    maxHeapify(A, largest); // 再帰的に呼び出し
  }
}

void buildMaxHeap(int *A){
  int i;
  for (i = h/2 ; i >= 1 ; i--) maxHeapify(A, i);
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define nl cout<<"\n"
#define pb push_back
#define se second
#define fi first
#define pi =3.14159265358979323846264338327950L;
typedef long long int ll;
int mod=1e9+7;
ll n,a,b,c,d;
ll mx1;
map<ll,ll> mp;
 
 
ll solve(ll x){
	ll ans=LONG_MAX;
	if(x<ans/d){
		ans=x*d;
	}
	if(mp[x]>0) return mp[x];
	if(x==0){
		return 0;
	}
	if(x==1){
		return d;
	}
	if(x%3==0){
		ans=min(ans,b+solve(x/3));
	}
	else{
		ans=min(ans,d*(3-x%3)+b+solve((x+3-x%3)/3));
		ans=min(ans,d*(x%3)+b+solve((x-x%3)/3));
	}
	if(x%5==0){
		ans=min(ans,c+solve(x/5));
	}
	else{
		ans=min(ans,d*(5-x%5)+c+solve((x+5-x%5)/5));
		ans=min(ans,d*(x%5)+c+solve((x-x%5)/5));
	}
	if(x%2==0){
		ans=min(ans, a+solve(x/2));
	}
	else{
		ans=min(ans,d+a+solve((x+1)/2));
		ans=min(ans,d+a+solve((x-1)/2));
	}
	mp[x]=ans;
	return ans;
}
 
int main(){
	//~ ios_base :: sync_with_stdio(0);
	//~ cin.tie(0);
	//~ cout.tie(0);
	//~ freopen("input.txt", "r", stdin); 
    //~ freopen("output.txt", "w", stdout); 
	int t;
	cin>>t;
	while(t--){
		mp.clear();
		cin>>n>>a>>b>>c>>d;
		cout<<solve(n)<<endl;
	}
    return 0;
}


Measured memory_bytes: 4448
#include "bits/stdc++.h"
using namespace std;
string s;
int main(void) {
	while (cin >> s) {
		for (int i = 0; i < s.length(); ++i) {

			if (s[i] == '@') {
				for (int j = 0; j < s[i + 1] - '0'; ++j) {
					cout << s[i + 2];
				}
				i = i + 2;
			}else{
				cout << s[i];
			}
		}cout<<endl;
	}
}

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

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


Measured memory_bytes: 3100
# vim: fileencoding=utf-8


def main():
    d = {}
    n = int(input())
    for i in range(n):
        s = input()
        v = d.get(s, 0)
        d[s] = v + 1

    m = int(input())
    for i in range(m):
        s = input()
        v = d.get(s, 0)
        d[s] = v - 1
    ans = 0
    for i in d.values():
        if i > ans:
            ans = i
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61952
import collections

n = int(input())
s = input()
cnt = 0
dictionary = {}

for i in range(n)[::-1]:
  if s[i] in dictionary.keys():
    dictionary[s[i]] += 1
  else:
    dictionary[s[i]] = 1
  ch = s[i:]
  tmp_cnt = 1
  for k,v in dictionary.items():
    if k != s[i]:
      tmp_cnt *= (v+1)
  cnt += tmp_cnt % (10**9+7)
print(cnt % (10**9+7))

Measured memory_bytes: 3816
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
#include <algorithm>
#include<set>
#include<map>
#include <limits>
#include<iomanip>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_2 100000
#define d9_7 1000000007
int main(void){
  string n,k;
  cin>>n>>k;
  int cnt=0;
  rep(i,3){
    if(n[i]==k[i])cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    
    long long int n, i, dap=0, x, y;
    cin>>n;
    
    for(i=2;i<=1000000;i++)
    {
        long long int k=0;
        while(n%i==0)
        {
            k++;
            n/=i;
        }
        x=0;
        y=0;
        while(y<=k)
        {
            x++;
            y+=x;
        }
        x--;
        dap+=x;
    }
    if(n>1)
    dap++;
    cout<<dap;
}

Measured memory_bytes: 3636
from collections import Counter
n=int(input())
lst=list(map(int,input().split()))
c=Counter(lst)
c=c.most_common()
ans=0
for i in range(len(c)):
    if c[i][0]<c[i][1]:
        ans+=(c[i][1]-c[i][0])
    elif c[i][0]>c[i][1]:
        ans+=(c[i][1])
print(ans)

Measured memory_bytes: 107456
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
template<class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
  return os << "{" << p.first << ", " << p.second << "}";
}
template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
  os << "{";
  rep(i, v.size()) { if(i) os << ", "; os << v[i]; }
  return os << "}";
}
// template<class t> ostream& operator<<(ostream& os, const set<t>& se) {
//   os << "{";
//   auto itr = se.begin();
//   rep(i, se.size()) { if(i) os << ", "; os << *itr; itr++; }
//   return os << "}";
// }
// template<class t, class u>
// ostream& operator<<(ostream& os, const map<t, u>& mp) {
//   os << "{";
//   auto itr = mp.begin();
//   rep(i, mp.size()) { if(i) os << ", "; os << *itr; itr++; }
//   return os << "}";
// }
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  for(char s: S) cout << char('A'+(int(s-'A')+N)%26);
  cout << endl;
  return 0;
}



Measured memory_bytes: 256
from collections import defaultdict


def solve(n, p):
    if n == 1:
        return p
    i = 2
    ps = defaultdict(lambda: 0)
    while i * i <= p:
        while p % i == 0:
            p //= i
            ps[i] += 1
        i += 1
    ans = 1
    for p, c in ps.items():
        ans *= p ** (c // n)
    return ans


n, p = map(int, input().split())
print(solve(n, p))


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

int main()
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    string res = "Yes";

    if (N % 2 != 0) {
        res = "No";
    }
    else {
        for (int i = 0; i < N / 2; i++) {
            if (S[i] != S[N / 2 + i]) res = "No";
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll s,i,j;
	cin>>s;
	if(s==1){
		cout<<"0 0 0 1 1 0";return 0;
	}
	ll hi=min(s,(long long)1e9),lo=1,mid;
	while(hi-lo>1){
		mid=(hi+lo)/2;
		ll y=(s+mid-1)/mid;
		if(y>1e9)
			lo=mid;
		else
			hi=mid;
	}
	ll x2,y2;
	if((s+mid-1)/mid<1e9)
		x2=mid,y2=(s+mid-1)/mid;
	else
		x2=hi,y2=(s+hi-1)/hi;
	//ll x2=mid,y2=(s+mid-1)/mid;
	ll req=x2*y2-s;
	if(req==0){
		cout<<"0 0 0 "<<y2<<" "<<x2<<" 0";return 0;
	}
	for(i=1;i*i<=req;i++){
		if(req%i==0&&(req/i)<1e9){
			cout<<"0 0 "<<x2<<" "<<i<<" "<<(req/i)<<" "<<y2;return 0;
		}
	}
	return 0;
}

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

string k;
int d;
int dp[10010][110][5];
int rj[10010][110];
const int MOD = 1e9 + 7;
int sol = 0;

int rek(int x, int y, int z) {
	if (x == k.size()) {
		if (y == 0) return 1;
		return 0;
	}

	int &ret = dp[x][y][z];
	if (ret != -1) return ret;
	ret = 0;

	if (z == 0) {
		for (int i = 0; i <= 9; i ++) {
			ret += rek(x+1, (y+i)%d, 0);
			ret %= MOD;
		}
	}
	else {
		for (int i = 0; i < (k[x] - '0'); i ++) {
			ret += rek(x+1, (y+i)%d, 0);
			ret %= MOD;
		}

		ret += rek(x+1, (y+(k[x] - '0'))%d, 1);
		ret %= MOD;
	}

	return ret;
}

int dr(int x, int y) {
	if (x == k.size()-1) {
		if (y == 0) return 1;
		return 0;
	}

	int &ret = rj[x][y];
	if (ret != -1) return ret;
	ret = 0;
	if (y == 0) ret ++;

	for (int i = 0; i <= 9; i ++) {
		ret += dr(x+1, (y+i)%d);
		ret %= MOD;
	}

	return ret;
}

int main () {

	cin >> k;
	cin >> d;
	memset(dp, -1, sizeof dp);
	for (int i = 1; i < k[0] - '0'; i ++) {
		sol += rek(1, i%d, 0);
		sol %= MOD;
	}

	sol += rek(1, (k[0] - '0')%d, 1);
	sol %= MOD;

	if (k.size() > 1) {
		memset(rj, -1, sizeof rj);
		for (int i = 1; i < 10; i ++) {
			sol += dr(1, i%d);
			sol %= MOD;
		}
	}

	cout << sol;

	return 0;
}

Measured memory_bytes: 26880
#include <bits/stdc++.h>
#define rep(i, l, r) for (__typeof(l) i = (l); i <= (r); ++i)
#define per(i, r, l) for (__typeof(r) i = (r); i >= (l); --i)
using namespace std;
typedef long long ll;
const int mod = 998244353;
int read() {
	int f = 1, x = 0; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return f * x;
}
int qpow(int a, int b) { int res = 1; while (b) { if (b & 1) res = (ll)res * a % mod; a = (ll)a * a % mod; b >>= 1; } return res; }

int x, y, z; 
int main() {
	x = read(), y = read(), z = read();
	swap(x, y), swap(x, z);
	cout << x << " " << y << " " << z << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

ll sum(int bit,string s){
  ll res = 0;
  string temp[10];
  int j = 0;
  for(int i;i<=s.length();++i){
    temp[j] += s[i];
    if (bit & (1 << i) || i == s.length()){
      res+=stoll(temp[j]);
      j++;
    }
    
  }
  return res;
}

int main(){
  string s;
  cin >> s;
  ll ans = 0;;
  for (int bit = 0; bit < (1<<s.length()-1); ++bit) {
    ans+=sum(bit,s);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/*----------------
     Smit Patel
     DA-IICT
----------------*/
#include<iostream>
#include<bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ins insert
#define fori(i,a,n) for(int i=a; i<n; i++)
#define ford(i,a,n) for(int i=a; i>n; i--)
#define clr(a,b) memset(a,b,sizeof(a))
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define bp __builtin_popcount
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1e18+5
#define N 200005
#define LN 20

typedef long double ld;
typedef long long ll;
typedef map<ll,ll> mll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef set<ll> sll;

ll choose(ll n,ll k);
bool isprime(ll n);
ll power(ll x,ll y,ll p);
ll power(ll x,ll y);
ll gcd(ll a,ll b);

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll n,m;
  string s,t;
  cin>>s>>t;
  n=s.length(),m=t.length();
  ll dp[n+1][m+1]={};
  fori(i,0,n)
  {
    fori(j,0,m)
    {
      if(s[i]==t[j])
      {
        dp[i+1][j+1]=dp[i][j]+1;
      }
      else
      {
        dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
      }
    }
  }
  string ans="";
  ll i=n,j=m;
  while(i>0 && j>0 && dp[i][j]!=0)
  {
    ll x=dp[i][j];
    while(dp[i][j]==x)
    {
      i--;
    }
    i++;
    while(dp[i][j]==x)
    {
      j--;
    }
    i--;
    ans+=s[i];
  }
  reverse(all(ans));
  cout<<ans<<endl;
  return 0;
}

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

ll choose(ll n,ll k)
{
  if(k==0)
    return 1;
  return (n* choose(n-1,k-1))/k;
}

bool isprime(ll n)
{
  for(ll i=2;i*i<=n;i++)
  {
    if(n%i==0)
      return false;
  }
  return true;
}

ll power(ll x,ll y,ll p)
{
  ll res=1;
  x=x%p;
  while(y>0)
  {
    if(y&1)
      res=(res*x)%p;
    y=y>>1;
    x=(x*x)%p;
  }
  return res;
}

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0)
  {
    if(y&1)
      res=res*x;
    y=y>>1;
    x=x*x;
  }
  return res;
}


Measured memory_bytes: 70784
#from collections import deque,defaultdict
from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

s = ins()
print(s[:3])


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    vector<ll> X, Y, X1, X2, Y1, Y2;
    rep(i, N) {
        ll x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        X.push_back(x1);
        X1.push_back(x1);
        X.push_back(x2);
        X2.push_back(x2);
        Y.push_back(y1);
        Y1.push_back(y1);
        Y.push_back(y2);
        Y2.push_back(y2);
    }
    sort(X.begin(), X.end());
    X.erase(unique(X.begin(), X.end()), X.end());
    rep(i, N) {
        X1[i] = lower_bound(X.begin(), X.end(), X1[i]) - X.begin();
        X2[i] = lower_bound(X.begin(), X.end(), X2[i]) - X.begin();
    }

    sort(Y.begin(), Y.end());
    Y.erase(unique(Y.begin(), Y.end()), Y.end());

    rep(i, N) {
        Y1[i] = lower_bound(Y.begin(), Y.end(), Y1[i]) - Y.begin();
        Y2[i] = lower_bound(Y.begin(), Y.end(), Y2[i]) - Y.begin();
    }
    vector<vector<ll>> grid(X.size() + 5, vector<ll>(Y.size() + 5, 0));
    rep(i, N) {
        ll x1 = X1[i];
        ll x2 = X2[i];
        ll y1 = Y1[i];
        ll y2 = Y2[i];
        grid[x1][y1] += 1;
        grid[x2][y1] -= 1;
        grid[x1][y2] -= 1;
        grid[x2][y2] += 1;
    }
    rep(i, X.size() + 3) {
        rep(j, Y.size() + 3) {
            grid[i + 1][j] += grid[i][j];
        }
    }
    rep(i, X.size() + 3) {
        rep(j, Y.size() + 3) {
            grid[i][j + 1] += grid[i][j];
        }
    }

    ll ans = 0;
    rep(i, X.size()) {
        rep(j, Y.size()) {
            if (grid[i][j] >= 1) {
                ans += (X[i + 1] - X[i]) * (Y[j + 1] - Y[j]);
            }
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}



Measured memory_bytes: 128556
import java.util.Scanner;

//20180508
//02

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

		int a = scanner.nextInt();
		int b = scanner.nextInt();

		int d = a / b;
		int r = a % b;
		double f = (double)a / b;

		System.out.println(d + " " + r + " " + String.format("%.8f", f));

    	scanner.close();
    }
}



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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {
    string S;
    cin >> S;

    // 後ろから解くかわりにすべての文字列を「左右反転」する
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    // 端から切っていく
    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false; // 4 個の文字列たちどれかで divide できるか
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) { // d で divide できるか
                can2 = true;
                i += d.size(); // divide できたら i を進める
            }
        }
        if (!can2) { // divide できなかったら
            can = false;
            break;
        }
    }

    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3776
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val S = ns()
    val T = ns()
    var cnt = 0
    for (i in 0 until S.length) {
      if (S[i] != T[i]) cnt++
    }
    out.println(cnt)
  }













































  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }
  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}

Measured memory_bytes: 39036
'use strict';
(function(input){
  
  const compare=Symbol();
  
  Array.prototype[compare]=function(){
    const S=this[0];
    const T=this[1];
    return S.
    reduce(
      (a,c,i)=>a&&(c===T[i]),
      true
    );
  }
  
  const result=input.
  split(/\s+/).
  map(str=>str.split(''))[compare]();
  
  console.log(result?'Yes':'No');
  
})(require('fs').readFileSync('/dev/stdin','utf-8'));



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

using namespace std;

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

void Main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	for(int i = a; i <= b; i++){
		if(c % i == 0){
			ans++;
		}
	}
	cout << ans << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}



Measured memory_bytes: 3164
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using StructLayoutAttribute = System.Runtime.InteropServices.StructLayoutAttribute;
using FieldOffsetAttribute = System.Runtime.InteropServices.FieldOffsetAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        //絶対値のmaxの奴を2回足すと
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

        int max = -1;
        int maxInd = -1;
        for (int i = 0; i < a.Length; i++)
        {
            if (max < Abs(a[i]))
            {
                max = Abs(a[i]);
                maxInd = i;
            }
        }

        List<Tuple<int, int>> ops = new List<Tuple<int, int>>();
        int currentInd = a[maxInd] > 0 ? 0 : n - 1;
        int next = a[maxInd] > 0 ? 1 : -1;
        ops.Add(new Tuple<int, int>(maxInd, currentInd));
        ops.Add(new Tuple<int, int>(maxInd, currentInd));
        currentInd += next;
        while (0 <= currentInd && currentInd < n)
        {
            ops.Add(new Tuple<int, int>(currentInd - next, currentInd));
            ops.Add(new Tuple<int, int>(currentInd - next, currentInd));
            currentInd += next;
        }
        Console.WriteLine(ops.Count);
        Console.WriteLine(string.Join("\n", ops.Select(x => $"{x.Item1 + 1} {x.Item2 + 1}")));
    }
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>
#include <iostream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int main(){
    char c;
    cin >> c;
    if(c == 'A')
        cout << 'T' << endl;
    else if(c == 'T')
        cout << 'A' << endl;
    else if(c == 'G')
        cout << 'C' << endl;
    else
        cout << 'G' << endl;
    
    return 0;
    
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		long ans = 0;
		
		if(h == 1 && w == 1) {
			ans = 1;
			System.out.println(ans);
		}
		else if(h != 1 && w != 1) {
			ans =(long) (w - 2) * (h - 2);
			System.out.println(ans);
		}
		else {
			if(h == 1) {
				ans = w -2;
				System.out.println(ans);
			}
			if(w == 1) {
				ans = h -2;
				System.out.println(ans);
			}
		}
	}

}


Measured memory_bytes: 21844
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-03-17 13:22:57
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

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

LL modpower(LL n, LL m, LL mod) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod) {
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> l(q), r(q);
    for (int i = 0; i < q; i++)
        cin >> l[i] >> r[i];
    
    vector<int> cnt(n+1, 0);
    for (int i = 0; i < n-1; i++) {
        if (s[i] == 'A' && s[i+1] == 'C') {
            cnt[i+2] = cnt[i+1] + 1;
        } else {
            cnt[i+2] = cnt[i+1];
        }
    }

    vector<int> ans(q);
    for (int i = 0; i < q; i++) {
        ans[i] = cnt[r[i]] - cnt[l[i]];
    }

    for (int i = 0; i < q; i++)
        cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 2688
let N=stdin.ReadLine() |> int
let A=stdin.ReadLine().Split() |> Array.map int
let B=stdin.ReadLine().Split() |> Array.map int
let C=stdin.ReadLine().Split() |> Array.map int
let rec f i e p=
    if i=N then p
    else
        let E=A.[i]-1
        if E=(e+1) then
            let P=p+B.[E]+C.[e]
            f (i+1) E P
        else
            let P=p+B.[E]
            f (i+1) E P
f 0 -2 0 |> stdout.WriteLine

Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define p_ pair<int,int>
#define mp_ make_pair
#define ll long long
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int main()
{
    fastio();
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
int main(void){
    int row,col,i,j;   
    scanf("%d %d", &row, &col);
    int count_row[row],count_col[col];//行と列での＃の出現の判定に使う
    char box[row][col];//マス目を読み込む
    for(i=0;i<row;i++){
        for(j=0;j<col;j++){
            scanf(" %c",&box[i][j]);
            count_row[i]=0;//値の初期化
            count_col[j]=0;
        }
    }
    for(i=0;i<row;i++){
        for(j=0;j<col;j++){
            if(box[i][j]=='#'){
                count_row[i]=1;//行または列に＃が存在すれば1となる
                count_col[j]=1;
            }
        }
    }
    for(i=0;i<row;i++){
        if(count_row[i]==1){//行中に＃があるか判定
            for(j=0;j<col;j++){
                 if(count_col[j]){//列中に＃があるか判定
                      printf("%c",box[i][j]);//消えない部分をプリントする
                 }
            }
            printf("\n");//1行ごとに改行
        }
    }
    return 0;
}


Measured memory_bytes: 128
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "abc162_d.cpp"

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  vl cumR(n + 1, 0), cumG(n + 1, 0), cumB(n + 1, 0);
  REP(i, n) {
    cumR[i + 1] = cumR[i];
    cumG[i + 1] = cumG[i];
    cumB[i + 1] = cumB[i];
    if (s[i] == 'R') {
      cumR[i + 1]++;
    }
    if (s[i] == 'G') {
      cumG[i + 1]++;
    }
    if (s[i] == 'B') {
      cumB[i + 1]++;
    }
  }

  ll ans = 0;

  REP(i, n) {
    FOR(j, i + 1, n) {
      if (s[i] == s[j])
        continue;
      if ((s[i] == 'R' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'R')) {
        ans += cumB[n] - cumB[j + 1];
        if (j + (j - i) < n && s[j + (j - i)] == 'B')
          ans--;
      }
      if ((s[i] == 'R' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'R')) {
        ans += cumG[n] - cumG[j + 1];
        if (j + (j - i) < n && s[j + (j - i)] == 'G')
          ans--;
      }
      if ((s[i] == 'B' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'B')) {
        ans += cumR[n] - cumR[j + 1];
        if (j + (j - i) < n && s[j + (j - i)] == 'R')
          ans--;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3712
//I read the news today, oh boy
//About a lucky man who made the grade
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ll((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define roF(i,a,b) for(ll i = ll(a); i >= ll(b); i--)
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const ll N=1e6;

ll v[N];

int main(){
	fastio;
	int n; cin>>n;
	map<ll,ll> S[2];
	For(i,0,n){
		cin>>v[i];
		S[i&1][v[i]]++;
	}
	int ans = 0;
	if(S[0].size()==1 && S[1].size()==1 && (*S[0].begin()!=*S[1].begin())) ans = 0;
	else{
		if(S[0].size()==1 && S[1].size()==1){
			ans = n/2;
		}else if(S[0].size()==1){
			ll may=0;
			for(auto x: S[1]){
				if(x.ff!=(*S[0].begin()).ff) may = max(x.ss,may);
			}
			ans = n/2-may;
		}else if(S[1].size()==1){
			ll may=0;
			for(auto x: S[0]){
				if(x.ff!=(*S[1].begin()).ff) may = max(x.ss,may);
			}
			ans = n/2-may;
		}else{
			ii best1 = mp(0,0), best2 = mp(0,0);
			for(auto x: S[0]) if(x.ss>best1.ss) best1=x;
			for(auto x: S[1]) if(x.ss>best2.ss) best2=x;
			if(best1.ff!=best2.ff) ans = n - (best1.ss+best2.ss);
			else{
				ii secondbest1 = mp(0,0), secondbest2 = mp(0,0);
				for(auto x: S[0]) if(x.ff!=best1.ff && x.ss>secondbest1.ss)
					secondbest1 = x;
				for(auto x: S[1]) if(x.ff!=best2.ff && x.ss>secondbest2.ss)
					secondbest2 = x;
				ans = n - max(best1.ss+secondbest2.ss,best2.ss+secondbest1.ss);
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 10632
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)

int main() {
    int n,ans=0;
    cin>>n;
    vector<int>p(n);
    rep(i,n)cin>>p[i];
    sort(p.begin(),p.end());
    ans=p[n/2]-p[n/2-1];
    
    cout<<ans;
	return 0;
}


Measured memory_bytes: 640
N=int(input())-1
L=[]
S=[]
A=[chr(i) for i in range(97,123)]
X=""
while N>=0:
  if N==0:
    L.append(N%26)
    N=N//26
    break
  elif N!=0:
    L.append(N%26)
    N=N//26-1
S=list(reversed(L))
for i in range(len(S)):
  X+=A[S[i]]
print(str(X))

  

Measured memory_bytes: 8996
#include <iostream>
#include <limits>
#include <algorithm>
using namespace std;

int main() {
	for (;;) {
		int h, w;
		cin >> h >> w;
		if (h == 0 && w == 0) {
			break;
		}
		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				if (x == 0 || y == 0 || x == w - 1 || y == h - 1) {
					cout << "#";
				} else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3112
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);

    int n;
    std::vector<int> number;
    int result = INT32_MAX;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int m1;
        cin >> m1;
        number.push_back(m1);
    }

    for (int target = -100; target <= 100; target++) {
        int answer = 0;
        for (auto a : number) {
            // cout << a << " " << target << endl;
            answer += (a - target) * (a - target);
        }
        if (result > answer) {
            result = answer;
        }
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define SIZE 1005
 
using namespace std;
typedef long long ll;
int N;
int X[SIZE];

int main(){

cin>>N;

for(int j=2; j<=N; j++){
    int k=j;
for(int i=2; i<=j; i++){
    if(k%i==0){
        int cnt=0;
        while(k%i==0){
            k/=i;
            cnt++;
        }
        X[i]+=cnt;
    }
 }
}

ll ans=1LL;
for(int i=2; i<=N; i++){
    if(X[i]>0){
        ans=ans*(X[i]+1LL)%MOD;
    }
}

cout<<ans<<endl;

return 0;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F         first
#define S          second
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define hell        1000000007
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 1e9
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e9+1;


using namespace std;
void solve();

void fastIO() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);


void solve(){

  int n;
  cin>>n;
  int a[n];
  forn(i,0,n)
  cin>>a[i];
  sort(a,a+n);

  int ans=0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      int x=lower_bound(a,a+n,a[i]+a[j])-a;
      ans+=x-j-1;
    }
  }
  cout<<ans;
}


///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

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


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1)%hell)*k%hell)%hell;
  else
  return ((pw(k,x/2)%hell)*(pw(k,x/2)%hell))%hell;
}

/*void sieve(){

  for(int i=2;i<=1000000;i++){
    if(prime[i]==true){
      for(int j=i*i;j<=1000000;j+=i)
      prime[j]=false;
    }
  }

}*/


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

const int MAX_N = 100010;
int N, M, s, t;
int d1[MAX_N], d2[MAX_N];
vector<int> G[MAX_N];
int cnt1[MAX_N], cnt2[MAX_N];

void bfs(int v, int *d) {
  queue<int> que;
  que.emplace(v);
  memset(d, -1, sizeof(int) * N);
  d[v] = 0;
  while (!que.empty()) {
    int curr = que.front(); que.pop();
    for (int next : G[curr]) {
      if (d[next] < 0) {
        d[next] = d[curr] + 1;
        que.emplace(next);
      }
    }
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M >> s >> t;
  s--, t--;
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    G[x].emplace_back(y);
    G[y].emplace_back(x);
  }
  bfs(s, d1);
  bfs(t, d2);
  for (int i = 0; i < N; i++) {
    if (d1[i] >= 0) cnt1[d1[i]]++;
    if (d2[i] >= 0) cnt2[d2[i]]++;
  }
  ll ans = 0;
  for (int i = 0; i < d1[t] - 1; i++) {
    ans += (ll)cnt1[i] * cnt2[d1[t] - 2 - i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 10260
#include <cstdio>
#include <iostream>

using namespace std;

const int maxn = 2005;

int n, m, Q;
int dian[maxn][maxn];
int bianz[maxn][maxn];
int bians[maxn][maxn];
char ss[maxn];

inline int getbians(int lx, int ly, int rx, int ry)
{
	return bians[rx][ry] + bians[lx - 1][ly - 1] - bians[rx][ly - 1] - bians[lx - 1][ry];
}

inline int getbianz(int lx, int ly, int rx, int ry)
{
//	cout << "getbianz " << bianz[rx][ry] << ' ' << bianz[lx - 1][ly - 1] << ' ' << bianz[rx][ly - 1] << ' ' << bianz[lx - 1][ry] << endl;
	return bianz[rx][ry] + bianz[lx - 1][ly - 1] - bianz[rx][ly - 1] - bianz[lx - 1][ry];
}

inline int getbian(int lx, int ly, int rx, int ry)
{
//	cout << "getbian " << getbians(lx + 1, ly, rx, ry) << ' ' << getbianz(lx, ly + 1, rx, ry) << endl;
	return getbians(lx + 1, ly, rx, ry) + getbianz(lx, ly + 1, rx, ry);
}

inline int getdian(int lx, int ly, int rx, int ry)
{
	return dian[rx][ry] + dian[lx - 1][ly - 1] - dian[rx][ly - 1] - dian[lx - 1][ry];
}

int main()
{
	scanf("%d%d%d", &n, &m, &Q);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%s", ss + 1);
		for (int j = 1; j <= m; ++j)
		{
			dian[i][j] = (ss[j] == '1');
			bianz[i][j] = dian[i][j] && dian[i][j - 1];
			bians[i][j] = dian[i][j] && dian[i - 1][j];
		}
	}
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			dian[i][j] += dian[i][j - 1];
			bians[i][j] += bians[i][j - 1];
			bianz[i][j] += bianz[i][j - 1];
		}
	}
	for (int j = 1; j <= m; ++j)
	{
		for (int i = 1; i <= n; ++i)
		{
			dian[i][j] += dian[i - 1][j];
			bians[i][j] += bians[i - 1][j];
			bianz[i][j] += bianz[i - 1][j];
		}
	}
//	cout << "bians " << endl;
//	for (int i = 1; i <= n; ++i)
//	{
//		for (int j = 1; j <= m; ++j)
//			cout << bians[i][j] << ' ';
//		cout << endl;
//	}
//	cout << "bianz " << endl;
//	for (int i = 1; i <= n; ++i)
//	{
//		for (int j = 1; j <= m; ++j)
//			cout << bianz[i][j] << ' ';
//		cout << endl;
//	}
	while (Q--)
	{
		int lx, ly, rx, ry;
		scanf("%d%d%d%d", &lx, &ly, &rx, &ry);
		printf("%d\n", getdian(lx, ly, rx, ry) - getbian(lx, ly, rx, ry));
//		std::cout << getdian(lx, ly, rx, ry) << ' ' << getbian(lx, ly, rx, ry) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 48896
n, m = map(int, input().split())
*a, = [input() for _ in range(n)]
*b, = [input() for _ in range(m)]
for h in range(n-m+1):
    for k in range(n-m+1):
        if [a[i][k:k+m] for i in range(h, h+m)] == b:
            print("Yes")
            break
    else:
        continue
    break
else:
    print("No")


Measured memory_bytes: 3060
#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 vii vector<vi>

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

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int r;
	cin>>r;
	cout<<r*r*3<<endl;


	return 0;
}


Measured memory_bytes: 256
/*
*	User: Isanchez_Aguilar
*	Problem: AtCoder ABC134B - Golden Apple
*/
#include <bits/stdc++.h>

using namespace std;
using Long = long long;

const Long INF = 1e9+1;

Long dp[100][100001];


int main(void)
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	Long n, w;
	cin >> n >> w;

	vector< pair<Long, Long> > products(n);

	for (auto& p : products)
		cin >> p.first >> p.second;


	memset(dp, INF, sizeof dp);

	dp[0][0] = 0;

	dp[0][products[0].second] = products[0].first;

	for (int i = 1; i < n; ++i)
	{
		pair<Long, Long> p = products[i];
		
		for (int j = 0; j <= 100000; ++j)
		{
			dp[i][j] = dp[i - 1][j];

			if (j - p.second >= 0 and dp[i - 1][j - p.second] != INF)
				dp[i][j] = min(dp[i][j], dp[i - 1][j - p.second] + p.first);   
		}
	}

	Long ans = 0;

	for (int i = 100000; i >= 0; --i)
	{
		if (dp[n - 1][i] <= w)
		{
			ans = i;
			break;
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 78336
n=int(input())
if n<=111:
    print(111)
elif n<=222:
    print(222)
elif n<=333:
    print(333)
elif n<=444:
    print(444)
elif n<=555:
    print(555)
elif n<=666:
    print(666)
elif n<=777:
    print(777)
elif n<=888:
    print(888)
else:
    print(999)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------

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

  ll n,k; cin >> n >> k;
  ll tmp = n % k;
  if(tmp==0){
    cout << 0 << endl;
    return 0;
  }

  cout << min(tmp,k-tmp) << endl;

  return 0;
}


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

#define all(x) x.begin(),x.end()
#define LB(V,x) lower_bound(all(V),x)-V.begin()

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using pi = pair<int32, int32>;
using pll = pair<int64, int64>;
using vi = vector<int32>;
using vll = vector<int64>;
using ll = int64;

void Main(){
    int A, B;
    cin >> A >> B;
    if(B%A==0) cout << A+B << endl;
    else cout << B-A << endl;
}

int main(){cin.tie(0);ios::sync_with_stdio(false);Main();return 0;}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String...args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		for(int i = 0; i < N; i++) {
			float[] x = new float[3];
			x[0] = sc.nextFloat();
			x[1] = sc.nextFloat();
			x[2] = sc.nextFloat();
			Arrays.sort(x);
			float a,b,c,d,e,f = 0;
			// 3:4:5
			a = x[0]/3.0f;
			b = x[1]/4.0f;
			c = x[2]/5.0f;
			// 5:12:13
			d = x[0]/5.0f;
			e = x[1]/12.0f;
			f = x[2]/13.0f;
			if(a == b && b == c) {
				System.out.println("YES");
			}
			else if(d == e && e == f) {
				System.out.println("YES");
			}
			// Not a right angled triangle.
			else {
				System.out.println("NO");
			}
		}
	}
}

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

int n,m,c;
int ans;
int b[150];
int a;

inline int read(){
	long long s=0,w=1;
	char ch = getchar();
	while(ch < '0' || ch > '9'){
		if(ch == '-')w = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9'){
		s = s*10+ch-'0';
		ch = getchar();
	}
	return w*s;
}

int main(){
	n = read(),m = read(),c = read();
	for(int i = 1;i <= m;++i){
		b[i] = read();
	}
	while(n--){
		int sum = 0;
		for(int i = 1;i <= m;++i){
			a = read();
			sum += a*b[i];
		}
		if(sum+c > 0)++ans;
	}
	cout << ans;
	return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  int x;
  x = a * b;
  if(x % 2 == 0){
   	cout << "Even" << endl; 
  } else {
  	cout << "Odd" << endl;
  }
  return 0;
}

Measured memory_bytes: 256