akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

#define MAX 25
#define NIL (-1)

using namespace std;

typedef struct Node {
    int parent;
    int left;
    int right;
} Node;

Node T[MAX];
int H[MAX];
int D[MAX];

int setHeight(int *H,int u) {
    int h1 = 0;
    int h2 = 0;
    if ( T[u].right != NIL ) h1 = setHeight(H, T[u].right) + 1;
    if ( T[u].left != NIL ) h2 = setHeight(H, T[u].left) + 1;

    return H[u] = ((h1 > h2) ? h1 : h2);
}

void setDepth (int u, int d) {
    if ( u == NIL ) return;
    D[u] = d;
    setDepth(T[u].left, d+1);
    setDepth(T[u].right, d+1);
}

int getSibling(int u) {
    if ( T[u].parent == NIL ) return NIL;
    else if ( T[T[u].parent].left != u && T[T[u].parent].left != NIL )
        return T[T[u].parent].left;
    else if ( T[T[u].parent].right != u && T[T[u].parent].right != NIL )
        return T[T[u].parent].right;
    else return NIL;
}

void print( int u ) {
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "sibling = " << getSibling(u) << ", ";
    int deg = 0;
    if ( T[u].left != NIL ) deg++;
    if ( T[u].right != NIL ) deg++;
    cout << "degree = " << deg << ", ";
    cout << "depth = " << D[u] << ", ";
    cout << "height = " << H[u] << ", ";

    if ( T[u].parent == NIL ) cout << "root" << endl;
    else if ( T[u].left == NIL && T[u].right == NIL ) cout << "leaf" << endl;
    else cout << "internal node" << endl;
}

int main() {
    int n;
    int id, l,r;
    int root = 0;

    cin >> n;
    for ( int i = 0; i < n; ++i ) {
        T[i].parent = NIL;
    }

    for ( int i = 0; i < n; ++i ) {
        cin >> id;
        cin >> l;
        cin >> r;
        T[id].left = l;
        T[id].right = r;
        if ( l != NIL ) T[l].parent = id;
        if ( r != NIL ) T[r].parent = id;
    }

    for ( int i = 0; i < n; ++i ) {
        if ( T[i].parent == NIL ) root = i;
    }

    setDepth(root,0);
    setHeight(H,root);

    for ( int i = 0; i < n; ++i ) print(i);

    return 0;
}


Measured memory_bytes: 3100
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        IntStream.rangeClosed(1, n).forEach(i -> {
            if (i % 3 == 0) {
                System.out.print(" " + i);
                return;
            }
            if (i % 10 == 3) {
                System.out.print(" " + i);
                return;
            }
            int devided = i / 10;
            while (true) {
                if (devided <= 0) {
                    break;
                }
                if (devided % 10 == 3) {
                    System.out.print(" " + i);
                    return;
                }
                devided = devided / 10;
            }
        });
        System.out.println();
    }
}





Measured memory_bytes: 35340
#include <iostream>
using namespace std;
typedef long long ll;
const int N=2010,mod=1000000007;
int a[N*N],b[N*N],f[N][N];
int add(int a,int b){
    a+=b;
    return a>=mod?a-mod:a;
}
int mul(int a,int b){
    return 1LL*a*b%mod;
}
int pow(int a,int b)
{
    ll res=1%mod;
    for(;b;b>>=1){
        if(b&1) res=(ll)(res*a)%mod;
        a=(ll)a*a%mod;
    }
    return res;
}

int function(int n,int m)
{
    return mul(a[n+m-1],mul(b[m-1],b[n]));
}
void init(int n)
{
	a[0]=1;
	for(int i=1;i<=n;i++)
		a[i]=mul(a[i-1],i);
	b[n]=pow(a[n],mod-2);
	for(int i=n;i;--i)
		b[i-1]=mul(b[i],i);
}
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	if(k==1) return 0&puts("1");
	init(n*k);
	f[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=i;j>=0;--j)
			f[i][j]=add(f[i][j+1],j==0?0:mul(f[i-1][j-1],mul(n-i+1,function(k-2,(i-1)*k-(j-1)+1))));
	printf("%d\n",f[n][0]);
	return 0;
}

Measured memory_bytes: 46592
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
long long dp[110][110000];
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;}
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  c *= 2;
  long long ans = INF;
  rep(i, 110000){
    chmin(ans, (long long)(i*c + a*max(0, x-i) + b*max(0, y-i)));
  }
  cout << ans << endl;
}


Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;
int main() {
	int N;
	cin>>N;
  	if(N%4==0||N%7==0) { cout<<"Yes"<<endl; return 0; }
	for(int i=4; i<N; i+=4) {
		for(int j=i; j<=N; j+=7) {
			if(j==N) { cout<<"Yes"<<endl; return 0; }
		}
	}
	cout<<"No"<<endl;
	return 0;
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve(){
    pair <int,int>p[5];
    int c=0,k;
    rep(i,0,5) cin>>p[i].y, p[i].x=(10-p[i].y%10)%10;
   sort(p,p+5);
   rep(i,0,4) c+=p[i].x+p[i].y;
   c+=p[4].y;
   cout<<c;

}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
from bisect import bisect_left

def main():
	N = int(input())
	
	for i in range(N, 1000):
		tmp = i % 10
		ans = ""
		tugi = 0
		isOK = True
		for j in range(len(str(i))):
			if j == 0:
				tugi = i
			tmp2 = tugi % 10
			tugi = tugi // 10
			ans += str(tmp)
			if tmp != tmp2:
				isOK = False
				break
		if isOK == True:
			print(ans)
			sys.exit()
		
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;
    int cnt[26] = {};
    rep(i, N) {
        cnt[S[i] - 'a']++;
    }
    int ans = 1;
    rep(i, 26) ans = (ans * (cnt[i] + 1)) % mod;
    cout << ((ans - 1) + mod) % mod << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n,m;
int a[9],b[9];
bool visited[9] = {false};
bool graph[9][9];

void input(){
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        graph[a-1][b-1] = true;
        graph[b-1][a-1] = true;
    }
}
// 引数に現在の頂点を取る
int dfs(int cur){
    bool allvisited = true;
    for(int i=0;i<n;i++){
        if(visited[i]==false) allvisited = false;
    }
    if(allvisited) return 1;
    int ret = 0;
    for(int i=0;i<n;i++){
        if(graph[cur][i]==false) continue;
        if(visited[i]) continue;

        visited[i] = true;
        ret += dfs(i);
        visited[i] = false;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    visited[0] = true;
    cout << dfs(0) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#define LL long long

const int maxn = 2e5 + 5;
int n, ans = 0;
LL d, x[maxn], y[maxn];

int main()
{
    scanf("%d", &n);
    scanf("%lld", &d);
    for(int i = 1; i <= n; ++i)
    {
        scanf("%lld%lld", &x[i], &y[i]);
        if(x[i] * x[i] + y[i] * y[i] <= d * d) ++ans;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 4856
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(int)(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) ((flag)?1:0)
#define YN(flag) cout<<(flag?"YES":"NO")<<endl;
#define Yn(flag) cout<<(flag?"Yes":"No")<<endl;
#define yn(flag) cout<<(flag?"yes":"no")<<endl;
#define Cout(v) cout<<(v)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

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

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ===================

// Template End =========================

int main(void){
  int a,b; cin>>a>>b; Cout(a>12?b:(a>=6?b/2:0));
}












Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	if(n==0||n==m) {cout<<1;return 0;}
	for(int i=m/n+1;i>=0;i--)
	if(m%i==0) {cout<<i;return 0;}
}

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

int main(){
    int A,B;
    cin >> A >> B;
    int flag = 0;
    for(int i =0;i<=1000000000;i++){
        if(abs(A-i)==abs(B-i)){
            flag = i;
        }
    }
    if(flag !=0){
        cout << flag;
    }else {
        cout << "IMPOSSIBLE";
    }

}

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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 2e5 + 10;
const int oo = 1e18;

int n, ans = 0;
int h[N];

void solve(int lef, int rig)    {
    if(lef > rig) return;
    int minn = oo, pos = -1;
    FOR(i, lef, rig) if(h[i] < minn)
        minn = h[i], pos = i;
    ans += minn;
    FOR(i, lef, rig) h[i] -= minn;
    solve(lef, pos - 1); solve(pos + 1, rig);
}
signed main()  {
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);
    ios_base::sync_with_stdio(false); cout.tie(0);

    cin >> n;
    FOR(i, 1, n) cin >> h[i];

    solve(1, n);

    return cout << ans, 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    a = sorted(LI())
    i = 0
    if a[0] >= 0:
        i = 0
    elif a[-1] <= 0:
        i = n - 2
    else:
        i = bisect.bisect_right(a,0) - 1

    r = []
    j = i + 1
    # print(a,i,j)
    for k in range(i-1,-1,-1):
        r.append('{} {}'.format(a[j], a[k]))
        a[j] -= a[k]
    for k in range(j+1,n):
        r.append('{} {}'.format(a[i], a[k]))
        a[i] -= a[k]
    r.append('{} {}'.format(a[j],a[i]))

    return '{}\n{}'.format(a[j]-a[i], JA(r, '\n'))


print(main())



Measured memory_bytes: 20960
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
int n,a[maxn];

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++){
        if(a[i]-1>=a[i-1]){
            a[i]--;
            continue;
        }
        if(a[i]<a[i-1]){
            return !printf("No\n");
        }
    }
    printf("Yes\n");
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

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

  if((b-b%a)/a <= c)cout << (b-b%a)/a<< endl;
  else cout << c << endl;
}


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


int MOD=1000000007;


int main() {
	string S;
	cin >> S;
	sort(S.begin(),S.end());
	if(S[0]==S[1] && S[3]==S[2] && S[0]!=S[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = sc.nextInt();
    int c = a * a * b;
    double d = (double)x/(a*a);
    double f = 0.0;
    double t = 0.0;
    double ans = 0.0;
    if(d*2 > b){
      f = (b-d)*2;
      t = Math.atan(f/a);
      ans = t*(180/Math.PI);
    }else{
      double S = (double)x/a;
      f = S*2/b;
      t = Math.atan(f/b);
      ans =90 - (t*180/Math.PI);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>                                
using namespace std;
#define pb push_back
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
const int mill = 1e9;
const ll mln = 1e6;
const int INF = 2e9;
const ll mod = 1e9 + 7;
const ll mod2 = 3e9 - 71;
const ll longINF = 3e18;
const ld pi = acos(-1);
const ld eps = 1e-8;
const int M = 1 << 21;
const ll smod = 998244353;

int a, b;
char c[105][105];
                                                                                                                                                                            
int main() 
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);                                                                                         
	cout.tie(0);
	srand(time(0));   
	#ifdef LOCAL
         	freopen("input.txt", "r", stdin);
        	freopen("output.txt", "w", stdout);
        #endif
        cin >> a >> b;
        cout << "100 100\n";
        int ci = 0, cj = 0;
        for (int i = 0; i < a - 1; i++) {
                c[ci][cj] = '.';
                c[ci][cj + 1] = '#';
                cj += 2;
                if (cj >= 100) {
                	cj = 0;
                	ci += 2;
                	for (int j = 0; j < 100; j++)
                		c[ci - 1][j] = '#';
                }
        }
        /*cout << "Temp table:\n";
        for (int i = 0; i < 100; i++) {
        	for (int j = 0; j < 100; j++)
        		cout << c[i][j];
        	cout << '\n';
        }
        cout << "\n\nOut table:\n\n";*/
        for (int j = cj; j < 100; j++)
        	c[ci][j] = '#';
        for (int j = 0; j < 100; j++)
        	c[ci + 1][j] = '#';
        for (int i = ci + 2; i < 100; i++)
        	for (int j = 0; j < 100; j++)
        		c[i][j] = '.';
        ci = 99;                             
        cj = 99;
        for (int i = 0; i < b - 1; i++) {
        	c[ci][cj] = '#';
        	cj -= 2;
        	if (cj < 0) {
        		cj = 99;
        		ci -= 2;
        	}
        }
        for (int i = 0; i < 100; i++) {
        	for (int j = 0; j < 100; j++)
        		cout << c[i][j];
        	cout << '\n';
        }
        return 0;
}

Measured memory_bytes: 256
def z_algorithm(s):
    """文字列sが与えられたとき、各iについて「SとS[i:|S|-1]の最長共通接頭辞の長さ」
    を記録した配列 A を O(|S|) で構築するアルゴリズムです。"""

    a = [0] * len(s)
    i = 1
    j = 0
    a[0] = len(s)
    while i < len(s):
        while i + j < len(s) and s[j] == s[i+j]:
            j += 1
        a[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i + k < len(s) and k + a[k] < j:
            a[i+k] = a[k]
            k += 1
        i += k
        j -= k
    return a


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

p = [0] * n
q = [0] * n
for i in range(n):
    p[i] = a[i] ^ a[(i + 1) % n]
    q[i] = b[i] ^ b[(i + 1) % n]

test = q + p + p
res = z_algorithm(test)
ans = []
for i in range(n, 2*n):
    if res[i] >= n:
        ans.append((i - n, a[(i - n) % n] ^ b[0]))
ans = sorted(ans)

for i in ans:
    print(*i)

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

long long func(long long b, long long n) {
	if (b < 2) return -1;
	if (b > n) return n;
	else return func(b, n / b) + (n % b);
}
 
int main() {
long long n, s;
cin >> n >> s;
if (n == s) {
cout << n + 1 << "\n";
}
else {
bool is = true;
    for (long long i = 2; i * i <= n; i++) {
        if (func(i, n) == s) {
            cout << i << "\n";
            is = false;
            break;
        }
    }
    if (is) {
        long long result = -1;
        for (long long i = 1; i * i <= n; i++) {
            long long key = (n - s) / i + 1;
            if (func(key, n) == s) result = key;
        }
        cout << result << "\n";
    }
}
return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h> 
    //#define M_PI 3.14159265358979323846



using namespace std;

#define rep(i,a,b) for(int i=a;i<b;++i)
#define repb(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define vc vector<char>
#define vld vector<ld>
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
#define vvld vector<vector<ld> >
#define vpii vector<pii>
#define vpll vector<pll>
#define ld long double
#define ll long long
#define sz(a) (ll)a.size()
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define ssortB(arr)   stable_sort(arr.begin(),arr.end(),greater<pair<int,int> >());
#define pii pair<int,int>
#define pll pair<long long,long long>
#define ff first
#define ss second
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define endl "\n" 
#define PI acos(-1.0)
#define GCD(a,b) __gcd(a,b)
#define popcount(x) __builtin_popcountll(x)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fix(f,n) fixed<<setprecision(n)<<f<<endl
#define checkin(ds, a) (ds.find(a)!=ds.end()?1:0)
#define mem(arr)  memset(arr,0,sizeof(arr))
const int M=(int)1e9+7;
ll power(ll x,ll y)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % M; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % M;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % M;  
    }  
    return res;  
}  
int main(){
    ll n;cin>>n;
   
    if(n==1)cout<<0<<endl;
    else{
    ll x=power(9,n);
    ll y;
    y=(power(8,n))%M;
    x=(x*2)%M;
    
    
    ll z=power(10,n);
    z=(z+y)%M;
    z=(z-x+M)%M;
     cout<<z<<endl;}
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;

int cnt(int H, int W, int x, int y, int a){
    int S = y * W + a * x;
    int b = gcd(x, y) + gcd(W - x, y + a) + gcd(W, a);
    return (S + 2 - b) / 2;
}

signed main(){

    int W, H, K; cin >> W >> H >> K;
    int ans = 0;
    REP(_, 2){
        FOR(a, 1, H - 1){
            int M = min(W - 1, 2 * (K + W) / a);
            FOR(x, 1, M + 1){
                int ymin = min((2 * K - a * x) / W, H - 1 - a);
                if(ymin >= 1) ans += ymin * 2;
                REP(k, 2) if(ymin + 1 + k <= H - 1 - a && ymin + 1 + k >= 1 && cnt(H, W, x, ymin + 1 + k, a) <= K) ans += 2;
            }
        }

        FOR(x, 1, W){
            int ymin = min(2 * K / W, H - 1);
            if(ymin >= 1) ans += ymin;
            REP(k, 2) if(ymin + 1 + k <= H - 1 && ymin + 1 + k >= 1 && cnt(H, W, x, ymin + 1 + k, 0) <= K) ans += 1;
        }

        swap(W, H);
    }
    ans *= 2;
    Out(ans);

    return 0;
}


Measured memory_bytes: 3648
def ifkai(s, st, en)
  for i in 0..((en-st-1)/2)
    return 0 if s[st+i] != s[en-i]
  end
  return 1
end

s = gets.chomp.split("")
ln = s.length
if ifkai(s,0,ln-1)*ifkai(s,0,(ln-1)/2-1)*ifkai(s,(ln+3)/2-1,ln-1) == 1
  puts "Yes"
else
  puts "No"
end

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

int main() {
  int n;
  cin >> n;
  if(n /100 == n % 10) cout << "Yes" << endl;
  else cout << "No" <<endl;
}


Measured memory_bytes: 3628
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

totalMonster = 0
kurikoshi = 0
for i in range(N + 1):
    if i == N:
        if kurikoshi >= A[i]:
            totalMonster = totalMonster + A[i]
        else:
            totalMonster = totalMonster + kurikoshi
        break

    if kurikoshi >= A[i]:
        totalMonster = totalMonster + A[i]
        kurikoshi = B[i]
    elif kurikoshi + B[i] >= A[i]:
        totalMonster = totalMonster + A[i]
        kurikoshi = kurikoshi + B[i] - A[i]
    else:
        totalMonster = totalMonster+ kurikoshi + B[i]
        kurikoshi = 0

print(totalMonster)

Measured memory_bytes: 18624
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 105;
const int INF = 0x3f3f3f3f;
typedef long long ll;
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
const int MOD = 1e9+7;


int h[N];
int Has[N]; int tot;
ll dp[N][N];

ll Pow(ll x, ll y) {
	if(y <= 0) return 1;
	ll result = 1;
	while(y) {
		if(y & 1)
			result = result * x % MOD;
		y >>= 1;
		x = x*x % MOD;
	}
	return result;
}

int main() {
	int n;
	while(~scanf("%d", &n)) {
		tot = 0;
		memset(dp, 0, sizeof(dp));
		h[0] = 0;
		dp[0][0] = 1;

		for(int i = 1; i <= n; ++i) {
			scanf("%d", &h[i]);
			Has[++tot] = h[i];
		}
		sort(Has + 1, Has + tot + 1);
		tot = unique(Has+1, Has + tot + 1) - Has - 1;
		
		for(int i = 1; i <= n; ++i) {
			h[i] = lower_bound(Has + 1, Has + tot + 1, h[i]) - Has;
		}
		
		
		for(int i = 1; i <= n; ++i) {
			dp[i][0] = dp[i-1][0] * 2 % MOD;
			for(int j = h[i] + 1; j <= h[i-1]; ++j) dp[i][0] = (dp[i][0] + dp[i-1][j] * 2 % MOD) % MOD;

			ll tmpPow = Pow(2, Has[h[i]] - Has[h[i-1]]);
			for(int j = 1; j <= min(h[i-1], h[i]) ; ++j) {
				dp[i][j] = dp[i-1][j] * tmpPow % MOD;
			}

			for(int j = h[i-1] + 1; j <= h[i]; ++j) {
				dp[i][j] = (dp[i][j] + j==1? ( dp[i-1][0] * ( Pow(2, Has[j]) - 2) % MOD * Pow(2, Has[h[i]] - Has[j]) % MOD ) :
											 ( dp[i-1][0] * 2 * (Pow(2, Has[j]-Has[j-1]) - 1) % MOD * Pow(2, Has[h[i]]-Has[j]) % MOD ) 
											 ) %MOD;
			}
		}


		ll result = 0;
		for(int i = 0; i <= tot; ++i) {
			result = (result + dp[n][i]) % MOD;
		}
		printf("%lld\n", result);
	}
	return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		char[][] field = new char[n][];
		for (int i = 0; i < n; i++) {
		    field[i] = sc.next().toCharArray();
		}
		int count = 0;
		for (int i = 0; i < n; i++) {
		    char[] arr = sc.next().toCharArray();
		    for (int j = 0; j < m; j++) {
		        if (arr[j] != field[i][j]) {
		            count++;
		        }
		    }
		}
		System.out.println(count);
	}
}



Measured memory_bytes: 76192
#include <iostream>
#include <vector>
using namespace std;
main(){for(;;){int n,m,i=0,j,o=0,v,cnt=0,it;cin>>n>>m;vector<int> hmap(1),wmap(1),map;if(!n)return 0;for(;i<n;i++){cin>>v;o+=v;hmap.push_back(o);}o=0;for(i=0;i<m;i++){cin>>v;o+=v;wmap.push_back(o);}map.resize(max(hmap[n],wmap[m])+5);for(i=0;i<n;i++){for(j=i+1;j<n+1;j++){map[hmap[j]-hmap[i]]++;}}for(i=0;i<m;i++){for(j=i+1;j<m+1;j++){it=wmap[j]-wmap[i];if(map[it]>0)cnt+=map[it];}}cout<<cnt<<endl;}return 0;}

Measured memory_bytes: 3356
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *
 */

/**
 * @author cthanh
 *
 */
public class Main {

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\?????????
		    String str = br.readLine();
		    double r =  Double.parseDouble(str);
		    double men = (double) r *r *Math.PI;
		    double syu = (double) r*2* Math.PI;
		   // System.out.println(Math.PI);
		    System.out.printf( "%.6f %.6f",men , syu );


	}

}

Measured memory_bytes: 24484
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MOD 1000000007
#define pb push_back
#define mp make_pair

void solve()
{
	int n, num, k;
	cin >> n >> k;
	vector<int> v;
	for (int i = 0; i < n; ++i)
	{
		cin >> num;
		v.pb(num);
	}

	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	for (int i = 0; i < n ; i++)
	{
		for (int j = 1; j <= k; j++)
		{
			if (i + j < n)
				dp[i + j] = min(dp[i + j], dp[i] + abs(v[i] - v[i + j]));
		}
	}
	cout << dp[n - 1] << "\n";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	//cin >> t;
	t = 1;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 4264
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

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


int main() {
    int a,b; cin >> a >> b;
    cout << a + b/2 << endl;
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef long long LL;
const int MAxn = 2e5 + 5;
const int MA_N = 5e3 + 5;
 
int main(){
	int a, b, c, d;
	while(cin >> a >> b >> c >> d){
	int m = max(a, c);
	int n = min(b, d);
	int ans = n - m;
	if(ans < 0) printf("0\n");
	else cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		long a = S.length() - 1;
		long sum = 0;
		
		for(int i = S.length() - 1; i >= 0; i--) {
			if(S.charAt(i) == 'B') {
				sum += a - (long)i;
				a--;
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 26068
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if((A==B && B!= C) || (B==C && C!=A) || (C==A && A!=B)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
ans = [0]*(len(s)+1)

for i in range(len(s)):
    if s[i] =='<':
        ans[i+1] = ans[i]+1
        
for i in range(len(s)-1,-1,-1):
    if s[i]=='>':
        ans[i]= max(ans[i],ans[i+1]+1)
print(sum(ans))



Measured memory_bytes: 46320
/*************************************************************************
    > File Name: c.cpp
    > Author: HandsomeHow
    > Mail: handsomehowyxh@gmail.com 
    > Created Time: 2017/8/21 21:54:22
 ************************************************************************/

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

#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define cl(a) memset((a),0,sizeof(a))
#ifdef HandsomeHow
#define dbg(x) cerr << #x << " = " << x << endl
#else
#define dbg(x)
#endif
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
const int inf=0x3f3f3f3f;
const double eps=1e-8;
const int mod=1000000007;
const double pi=acos(-1.0);
inline void gn(long long&x){
    int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
    while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
ll gcd(ll a,ll b){return a? gcd(b%a,a):b;}
ll powmod(ll a,ll x,ll mod){ll t=1ll;while(x){if(x&1)t=t*a%mod;a=a*a%mod;x>>=1;}return t;}
// (づ°ω°)づe★------------------------------------------------
map<int,int>cnt;
vector<int>vv;
int main(){
#ifdef HandsomeHow
    //freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
#endif
    int n;gn(n);
    rep(i,1,n){
        int x;gn(x);cnt[x]++;
    }
    for(auto it:cnt){
        int now = it.second;
        while(now >= 2){
            now -= 2;
            vv.pb(it.first);
        }
    }
    reverse(vv.begin(),vv.end());
    vv.pb(0);
    vv.pb(0);
    cout<<1ll*vv[0]*vv[1]<<endl;
    return 0;
}



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

using namespace std;
#define mx 100000

int main(){

int n,m;
   cin>>n>>m;
   char ar[n+2][m+2];

   for(int i=1;i<=n;i++){
      scanf("%s",ar[i]+1);
   }


   int row[n+2][m+2];
   int col[n+2][m+2];

   memset(row,0,sizeof row);
   memset(col,0,sizeof col);


   for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){

       if(ar[i][j] == '.'){

       col[i][j] = col[i][j-1]+1;
       row[i][j] = row[i-1][j] +1;}


    }
   }


   for(int i=1;i<=n;i++){

    // for(int j=1;j<=m;j++)cout<<row[i][j];
    // cout<<endl;
   }
   int ans=0;
   for(int i=1;i<=n;i++){


     for(int j=1;j<=m;j++){

     if(ar[i][j]=='#')continue;

        int  lo = 1,hi = i;
        int res=0;
        while(lo<=hi){

          int mid= (lo+hi)/2;
          if(row[i][j]-row[mid-1][j] == i-mid+1){
            hi = mid-1;
            res=max(res,i-mid);
          }
          else lo=mid+1;
        }
        lo = i,hi = n;
        int res1=0;
        while(lo<=hi){

          int mid= (lo+hi)/2;
          if(row[mid][j]-row[i-1][j] == mid-i+1){
            lo=mid+1;
            res1=max(res1,mid-i);
          }
          else hi=mid-1;
        }
        lo = 1,hi = j;
         int res2=0;
        while(lo<=hi){

          int mid= (lo+hi)/2;
          if(col[i][j]-col[i][mid-1] == j-mid+1){
            hi = mid-1;
            res2=max(res2,j-mid);
          }
          else lo=mid+1;
        }
        lo = j,hi = m;
       int  res3=0;
        while(lo<=hi){

          int mid= (lo+hi)/2;
          if(col[i][mid]-col[i][j-1] == mid-j+1){
           lo=mid+1;
            res3=max(res3,mid-j);
          }
          else hi=mid-1;
        }
       // if(i==2&&j==2)cout<<res<<res1<<res2<<res3<<endl;
        ans =max(ans,1+res+res1+res2+res3);


     }
   }

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


Measured memory_bytes: 35456
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    int Q = scn.nextInt();
    scn.nextLine();
    String S = scn.nextLine();

    int[] L = new int[N];
    L[0] = 0;
    for (int i = 1; i < N; i++) {

      if (S.substring(i - 1, i + 1).equals("AC")) {
        L[i] = L[i - 1] + 1;
      } else {
        L[i] = L[i - 1];
      }
    }

    for (int i = 0; i < Q; i++) {
      int l = scn.nextInt() - 1;
      int r = scn.nextInt() - 1;
      System.out.println(L[r] - L[l]);
    }

  }
}

Measured memory_bytes: 67472
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public struct Pair<T> { public T x, y; public Pair(T x, T y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        int K = NextInt();
        int A = (N - 1) * (N - 2) / 2;
        if (K > A) { Console.WriteLine(-1); return; }

        Console.WriteLine((N - 1) + A - K);
        for (int i = 2; i <= N; i++) Console.WriteLine(1 + " " + i);
        int a = 2;
        int b = a + 1;
        for (int i = 0; i < A - K; i++)
        {
            Console.WriteLine(a + " " + b);
            if (b == N) { a += 1;b = a + 1; }
            else b++;
            
        }

    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


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

using ll =long long;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b == 0){
       return(b);
   }else{
       return(gcd(b, a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a * b / gcd(a, b);
}

//文字列→数列
//string S;int A=atoi(S.c_str());
//数列→文字列
//int A;string S=to_string(A);
//数字判定　isdigit(a)
//pair宣言　pair<int,int> p(5,7);
//

int main(){
cout<<fixed<<setprecision(10);
  
  ll N;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  sort(vec.begin(),vec.end());
  int A=0;
  bool K=false;
  for(int i=0;i<N;i++){
    if(A==vec[i]){K=true;break;}
    A=vec[i];
  }
  if(K==true){
    cout<<"NO"<<endl;}
  else{cout<<"YES"<<endl;
      }
      

}


Measured memory_bytes: 1024
using System;
namespace AtConderCSharp
{
    class Program
    {
        public static void Main()
        {
            var x = Console.ReadLine().Split(' ');

            int h = int.Parse(x[0]);//敵体力
            int n = int.Parse(x[1]);//個数
            //int[] f = new int[1000];
            int sum = 0;
            var xx = Console.ReadLine().Split(' ');
            for (int i = 0;i<n;i++)
            {
                int v = int.Parse(xx[i]);
                sum += v;

            }
          

            if(h-sum <= 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            
        }
    }
}

Measured memory_bytes: 18016
import string

# -*- coding: utf-8 -*-
s = raw_input()
k = int(raw_input())

a_ls = list(string.ascii_lowercase)
a_len = len(a_ls)

end = ''

for c in s:
    idx = a_ls.index(c)
    for_overflow = a_len - idx
    if c is not 'a' and k - for_overflow >= 0:
        end += 'a'
        k -= for_overflow
    else:
        end += c

if k > 0:
    end = end[:len(end)-1] + a_ls[(a_ls.index(end[-1]) + k) % a_len]

# output
print end


Measured memory_bytes: 3072
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string,fractions
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
mod = 10**9+7
ans = 0 ;count = 0 ;pro = 1

def lcm(m,n):
    return (m*n)//fractions.gcd(m,n)
n=int(input())
T=[int(input()) for i in range(n)]
g=1
for ti in T:
    pro=lcm(pro,ti)
print(pro)



Measured memory_bytes: 64748
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int[][] c = new int[3][3];
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				c[i][j] = sc.nextInt();
			}
		}

		int sum = c[0][0] + c[1][1] + c[2][2];
		for (int i = 0; i < 3; i++) {
			int tmp = 0;
			int tmp2 = 0;
			for (int j = 0; j < 3; j++) {
				tmp += c[j][(i + j) % 3];
				tmp2 += c[j][(i - j + 3) % 3];
			}

			if (tmp != sum) {
				pr.println("No");
				return;
			}
			if (tmp2 != sum) {
				pr.println("No");
				return;
			}
		}

		pr.println("Yes");
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
using namespace std;
long long n,a,ans,p;
int main(void){
    scanf("%lld",&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&a);
        p+=a;
        if(a==0||i==n-1){
            ans+=p/2;
            p=0;
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 764
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))

L.sort()
result = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        result += bisect_left(L, L[i] + L[j]) - j - 1
print(result)


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

int main()
{
  int64_t N, K, cnt = 0, kcnt = 0;
  cin >> N >> K;
  vector<bool> R(N, 0);
  char c;
  for (int i = 0; i < N; i++)
  {
    cin >> c;
    if (c == 'R')
      R.at(i) = 1;
  }
  for (int i = 0; i < N - 1; i++)
  {
    if (R.at(i) == R.at(i + 1))
    {
      cnt++;
      continue;
    }
    if (kcnt >= K)
      continue;
    if (i + 1 == N - 1) // ***RL or ***LR
    {
      R.at(i + 1) = !R.at(i + 1);
      cnt++;
      kcnt++;
      break;
    }
    int64_t l = i + 1;
    if (R.at(i)) // *RL*
    {
      for (int j = i + 1; j < N - 1; j++)
      {
        if (!R.at(j) && R.at(j + 1)) // LRを探す
        {
          int64_t r = j;
          reverse(R.begin() + l, R.begin() + r + 1);
          for (int k = l; k <= r; k++)
            R.at(k) = !R.at(k);
          kcnt++;
          cnt++;
          break;
        }
        if (j == N - 2 && !R.at(j) && !R.at(j + 1))
        {
          int64_t r = j + 1;
          reverse(R.begin() + l, R.begin() + r + 1);
          for (int k = l; k <= r; k++)
            R.at(k) = !R.at(k);
          kcnt++;
          cnt++;
          break;
        }
      }
    }
    else // *LR*
    {
      for (int j = i + 1; j < N - 1; j++)
      {
        if (R.at(j) && !R.at(j + 1)) // RLを探す
        {
          int64_t r = j;
          reverse(R.begin() + l, R.begin() + r + 1);
          for (int k = l; k <= r; k++)
            R.at(k) = !R.at(k);
          kcnt++;
          cnt++;
          break;
        }
        if (j == N - 2 && R.at(j) && R.at(j + 1))
        {
          int64_t r = j + 1;
          reverse(R.begin() + l, R.begin() + r + 1);
          for (int k = l; k <= r; k++)
            R.at(k) = !R.at(k);
          kcnt++;
          cnt++;
          break;
        }
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func init() {
	Max := 1001001
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0, Max), Max)
	sc.Split(bufio.ScanWords)
}

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

//var done []bool = make([]bool, 10)
//var memo []int = make([]int, 10)

//func fib(n int) int {
//	fmt.Println(n)
//	if n == 0 {
//		return 0
//	}
//	if n == 1 {
//		return 1
//	}
//	if done[n] {
//		fmt.Println("done" + fmt.Sprint(n))
//		return memo[n]
//	}
//	done[n] = true
//	memo[n] = fib(n-1) + fib(n-2)
//	return memo[n]
//}

var m map[string]int = make(map[string]int)
var mInt map[int]int = make(map[int]int)

//var dp []int = make([]int, n)

//func fib(n int) int {
//	dp[0] = 0
//	dp[1] = 1
//	for i := 2; i <= n; i++ {
//		dp[i] = dp[i-1] + dp[i-2]
//	}
//	return dp[n]
//}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	s := next()
	var result int = 1
	for i := 1; i < n; i++ {
		if s[i] != s[i-1] {
			result++
		}
	}

	fmt.Println(result)
}


Measured memory_bytes: 896
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


def solve():
    N, K = Scanner.map_int()

    MOD = int(1e09) + 7
    MAX = 200010
    fac = [0] * MAX
    finv = [0] * MAX
    inv = [0] * MAX
    fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    def cmb(n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

    ans = 0
    for m in range(0, min(K, N - 1) + 1):
        a = cmb(N, m)
        b = cmb(N - 1, m)
        ans += a * b
        ans %= MOD
    print(ans)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 34288
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
	string S, T, U; cin >> S >> T;
	int A, B; cin >> A >> B;
	cin >> U;
	if (S == U) {
		cout << A-1 << " " << B << endl;

	}
	else {
		cout << A << " " << B-1 << endl;
	}
	
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define N 200010
ll a[N],b[N],n,ans;
void calc(){
    for(int i=0;i<n;i++){
	int j=(i+1)%n,k=(i+2)%n;
	ll p=b[i]+b[k];
	ll cnt=(b[j]-a[j])/p;
	ans+=cnt;
	b[j]-=cnt*p;
	//cout<<p<<" "<<cnt<<" "<<(b[j]-a[j])<<":";
    }
    //for(int i=0;i<n;i++)cout<<b[i]<<" ";cout<<endl;
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>b[i];
  ans=0;
  for(int i=0;i<100;i++)calc();
  bool ok=1;
  for(int i=0;i<n;i++)ok&=(a[i]==b[i]);
  if(ok)cout<<ans<<endl;
  else cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
int A[100000],n;

int binarySearch(int key){
  int left=0;
  int right=n;
  int mid;
  while(left<right){
    mid=(left+right)/2;
    if(A[mid]==key){
      return 1;
    }
    if(key>A[mid]){
      left=mid+1;
    }
    else if(key<A[mid]){
      right=mid;
    }
  }
  return 0;
}
int main(){
  int i, q, key, sum=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(binarySearch(key)){
      sum++;
    }
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 988