akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main(){
  int n,flag,cnt;
  char c,in;
  string str,str1;
  vector<string> V,out;
  vector<pair<string,int> > C;
  while(1){
    cin >> n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin >> c;
      getline(cin,str);
      str=c+str;
      for(int j=0;j<str.size();j++){
	if(str[j]!=' ') str1+=str[j];
	else{
	  V.push_back(str1);
	  str1.clear();
	}
      }
      V.push_back(str1);
      str1.clear();
    }
    cin >> in;
    sort(V.begin(),V.end());
    for(int i=0;i<V.size();i++){
      flag=0;
      for(int j=0;j<C.size();j++){
	if(C[j].first==V[i]){
	  C[j].second++;
	  flag=1;
	}
      }
      if(flag==0){
	C.push_back(make_pair(V[i],1));
      }
    }
    for(int i=0;i<C.size();i++){
      for(int j=1;j<C.size();j++){
	if(C[j].second>C[j-1].second) swap(C[j],C[j-1]);
      }
    }
    flag=0;
    cnt=0;
    for(int i=0;i<C.size();i++){
      if(in==C[i].first[0]&&cnt!=5){
	cnt++;
	flag=1;
	out.push_back(C[i].first);
      }
    }
    for(int i=0;i<out.size();i++){
      cout << out[i];
      if(i!=out.size()-1) cout << ' ';
    }
    if(flag==1) cout << endl;
    if(flag==0) cout << "NA" << endl;
    V.clear();
    C.clear();
    out.clear();
  }
  return 0;
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string ta, tb;
	cin >> ta >> tb;
	string a, b;
	a += ' '; b += ' ';
	a += ta;  b += tb;
	int sizea = a.size(), sizeb = b.size();
	int dp[sizea + 5][sizeb + 5];
	memset(dp, 0, sizeof(dp));
//	printf("  ");
//	for(int i=1; i<sizeb; i++)
//		printf("%c ",b[i]);
//	printf("\n");
	for(int i=1; i<sizea; i++)
	{
//		printf("%c ",a[i]);
		for(int j=1; j<sizeb; j++)
		{
			dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			if(a[i] == b[j])
			{
				dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
			}
//			printf("%d ",dp[i][j]);
		}
//		printf("\n");
	}
	char ans[99999];
	int m = 0;
	int posx = sizea - 1, posy = sizeb - 1;
	while(posx >= 0 && posy >= 0)
	{
		if(dp[posx - 1][posy] == dp[posx][posy])
		{
			posx--;
		}
		else if(dp[posx][posy - 1] == dp[posx][posy])
		{
			posy--;
		}
		else
		{
			ans[m++] = b[posy];
			posx--;
			posy--;
		}
	}
	for(int i=m-1; i>=0; i--)
		printf("%c",ans[i]);
	return 0;
}

Measured memory_bytes: 35584
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; } return x; }
long lcm(long x, long y) { return (x / gcd(x, y) * y); }

//using pll = pair<long, long>;
//using W_graph = vector<vector<pll>>;

int main() {

	double A, B, X; cin >> A >> B >> X; 
    double L , res;
    if (2 * X <= A * A * B){
	L = (double)2 * X / (A * B); 
	res = atan(B / L);
	res /= 3.14159265359;
	res *= 180.00000000;
    }else{
    X = A * A * B - X;
    L = (double)2 * X / (A * A);
    res = atan(L / A);
	res /= 3.14159265359;
	res *= 180.00000000;   
    }
	cout << setprecision(20) << res << endl;
}

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

signed main(){
  
  int n, h, w;
  cin>>n>>h>>w;
  
  int ans = 0;
  
  for(int i=0;i<n/2;i++){
    
    int a, b;
    cin>>a>>b;
    
    int R = max( w * 2 - b, a + w );
    int L = min( w * 2 - ( b + w ), a );
    
    ans += h * ( w * 2 - ( R - L ) );
    
  }  
  
  cout<<ans<<endl;
  
  return 0;
}



Measured memory_bytes: 3116
#include<cstdio>
#define ri register int
#define rc register char
#define ll long long int
#define rl register long long int
#define in inline
#define gc getchar
in int read()
{
	ri x=0,p=1;
	rc ch=gc();
	while(ch<'0' || ch>'9')
	{
		if(ch=='-')
		{
			p=-1;
		}
		ch=gc();
	}
	while(ch>='0' && ch<='9')
	{
		x=x*10+ch-'0',ch=gc();
	}
	return x*p;
}
int L;
long double x;
int main()
{
	L=read(),x=(long double)(L)/3,printf("%.12Lf\n",x*x*x);
	return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().split())
s = input()
rest = k
i = 0
while i < n:
    if s[i] == '1':
        i += 1
    else:
        if rest == 0:
            break
        rest -= 1
        while i < n and s[i] == '0':
            i += 1
ans = i
j = 0
while i < n:
    while i < n and s[i] == '0':
        i += 1
    while i < n and s[i] == '1':
        i += 1
    while j < n and s[j] == '1':
        j += 1
    while j < n and s[j] == '0':
        j += 1
    ans = max(ans, i - j)
print(ans)


Measured memory_bytes: 3316
#include<iostream>
#include<cmath>
#include<cstdlib>
#define ll long long
using namespace std;

int main(){
  int n,a[100002];
  ll max_ans = 0ll,ans = 0ll;

  cin >> n;
  for(int i = 0; i < n+2; i++){
    if(i == 0 or i == n+1) a[i] = 0;
    else cin >> a[i];
    max_ans += abs(a[i] - a[i-1]);
  }

  for(int i = 1; i < n+1; i++){
    if(a[i-1] <= a[i] and a[i] <= a[i+1]){
      cout << max_ans << endl;
    }
    else if(a[i-1] >= a[i] and a[i] >= a[i+1]){
      cout << max_ans << endl;
    }
    else{
      ans = max_ans - (abs(a[i+1] - a[i]) + abs(a[i] - a[i-1]) - abs(a[i+1] - a[i-1]));
      cout << ans << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 2296
#include <bits/stdc++.h>
using namespace std;
char sir[110],l,i,c;
int main()
{
    cin>>sir;
    l=strlen(sir);
    for(i=0;i<l;i++)
    {
        if(sir[i]=='C')
            c=1;
        if(sir[i]=='F' && c==1)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    n, w_max = map(int, input().split())
    items = [tuple(map(int, input().split())) for _ in range(n)]
    inf = float('inf')
    dp = [[inf] * 100001 for _ in range(n + 1)]
    dp[0][0] = 0
    for i1 in range(1, n + 1):
        w, v = items[i1 - 1][0], items[i1 - 1][1]
        for col in range(1, 100001):
            if v >= col:
                tmp1 = w
            else:
                tmp1 = dp[i1 - 1][col - v] + w
            dp[i1][col] = min(dp[i1 - 1][col], tmp1)
    for i2 in range(100000, 0, -1):
        if dp[-1][i2] <= w_max:
            print(i2)
            sys.exit()

if __name__ == '__main__':
    main()


Measured memory_bytes: 309880
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include <map>
#include <set>

using namespace std;

#define REP(i,x) for(int i=0; i<(int)(x); i++)       // 0 <= i < x
#define REPS(i,x) for(int i=1; i<=(int)(x); i++)     // 0 < i <= x
#define RREP(i,x) for(int i=((int)(x)-1); i>=0; i--) // x > i >= 0
#define RREPS(i,x) for(int i=((int)(x)); i>0; i--)   // x >= i > 0
#define INF 100000000

typedef long long ll;
typedef pair<int, int> P;

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int main(void){
    int N;
    cin >> N;
    int F[N][10], P[N][11];
    REP(i, N){
        REP(j, 10){
            cin >> F[i][j];
        }
    }
    REP(i, N){
        REP(j, 11){
            cin >> P[i][j];
        }
    }
    
	int res = -(1 << 30);
    int c;
    int profit = 0;
    for(int i = 1; i < (1 << 10); i++){
        profit = 0;
        REP(j, N){ //shop j
            c = 0;
            REP(k, 10){ //time k
                c += F[j][k] & (i >> k);
            }
            profit += P[j][c];
        }

        res = max(res, profit);
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int main()
{
	int n,r;
	cin>>n>>r;
	if(n<10) cout<<r+100*(10-n)<<endl; 
	else cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)((n>>m)&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n,ans;
int main(){
	scanf("%lld",&n);
	puts(n==3||n==5||n==7?"YES":"NO");
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

typedef long long int ll;

int MAX(int a, int b){return a>b?a:b;}
int MIN(int a, int b){return a>b?b:a;}
int compare(const void* a, const void* b){return *(int*)a - *(int*)b;}
ll llMAX(ll a, ll b){return a>b?a:b;}
ll llMIN(ll a, ll b){return a>b?b:a;}
ll digits(ll a){ll tmp=a; ll cnt=0; while(tmp>0){tmp/=10; cnt+=1;} return cnt;}

int main(void){
    int n;
    scanf("%d", &n);

    int a[n+2];
    a[0] = 0;
    a[n+1] = 0;
    for(int i=1; i<n+1; i++){scanf("%d", &a[i]);}

    //d[i]: iからi+1までの距離
    ll d[n+1];
    ll sum = 0;
    for(int i=0; i<n+1; i++){
        d[i] = abs(a[i+1]-a[i]);
        sum += d[i];
    }

    for(int i=1; i<n+1; i++){
       ll delete = d[i] + d[i-1];
       printf("%lld\n", sum - delete + abs(a[i-1]-a[i+1]));
    }

    return 0;
}

Measured memory_bytes: 2304
using System;
class Program
{    
    static void Main(string[] args)
     {
        string[] input = Console.ReadLine().Split(' ');
        int b = int.Parse(input[0]);
        int c = int.Parse(input[1]);
        Console.WriteLine((b * c) % 2 == 0 ? "Even" : "Odd");
     }
 }

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

int main()
{
    int x;
    cin >> x;
    //ベキ乗数を記録する配列
    vector<bool> expo(x + 1);//添字＝＝ベキ乗数となるように調整

    expo.at(1) = 1;
    for (int b = 2; b <= x;b++){//底２から探していく
        int v = b * b;//ｖの初期化
        while(v<=x){//xよりもベキ乗数が小さい間
            expo.at(v) = 1;//計算によって出てきた値を記録
            v *= b;//どんどんかけていく
        }
    }
    for (int i = x; i >= 1;i--){//大きな数字からベキ乗数を探す
    if(expo.at(i)){
        cout << i << endl;
        return 0;
    }
    }

}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long k = sc.nextLong();
        if (k <= a) {
            System.out.println(k);
        } else if (k <= a + b) {
            System.out.println(a);
        } else {
            System.out.println(a - (k - a - b));
        }
		    
    }
}

Measured memory_bytes: 35740
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> void Min(T &m, const T q) { if (m > q) m = q; }

int N;
lint D;
vector<lint> A;
int main()
{
    cin >> N >> D;
    A.resize(N);
    for (auto &v : A) cin >> v;
    lint res = accumulate(A.begin(), A.end(), 0LL);
    REP(i, N - 1) Min(A[i + 1], A[i] + D);
    IREP(i, N - 1) Min(A[i], A[i + 1] + D);
    cout << res + accumulate(A.begin(), A.end(), 0LL) - A[0] - A[N - 1] + (N - 1) * D << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
using namespace std;
typedef pair<int,int> P;
const int INF = ~(1<<31) / 2;


int n,m;
string name[100];
int cost[100];
map<string, int> nametoi;
vector<vector<int> > g;

int dfs(int v){
    //printf("%d %d\n",v,cost[v]);
    if(g[v].size()!=0){
        int wrought_c = 0;
        for(int i=0;i<g[v].size();i++){
            wrought_c += dfs(g[v][i]);
        }
        cost[v] = min(cost[v],wrought_c);
    }
    return cost[v];
}

int main(){
    while(1){
        scanf("%d", &n);
        if(n==0)break;
        g.clear();
        g.resize(n);
        for(int i=0;i<n;i++){
            cin >> name[i] >> cost[i];
            nametoi[name[i]] = i;
        }

        scanf("%d",&m);
        for(int i=0;i<m;i++){
            string target;
            int e_num;
            cin >> target >> e_num;

            int target_i = nametoi[target];
            for(int j=0;j<e_num;j++){
                string e;
                cin >> e;
                g[target_i].push_back(nametoi[e]);
            }
        }
        string str;
        cin >> str;
        cout << dfs(nametoi[str]) << endl;
    }
    return 0;
}

Measured memory_bytes: 1304
#include <cstdio>
#include <stack>
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main(){
    int n,b;
    map<string,int> mm[5];
    string a;
    
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        cin >> a >> b;
        
        if(mm[a.size()-1].find(a)==mm[a.size()-1].end()){
            mm[a.size()-1][a]=b;
        }else{
            mm[a.size()-1][a]+=b;
        }
    }
    
    for(int i=0;i<5;i++)
        for(map<string,int>::iterator it=mm[i].begin();it!=mm[i].end();it++){
        cout << it->first << " " << it->second << endl;
        }
    
    return 0;
}
    

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
//cout << fixed << setprecision(8) << a << endl;
//cout << "Case " << ca << ": " << ans << endl;
#define Fast_Input ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define MX 100005
#define infinity 20000000
#define pb push_back
#define ll long long int
int main()
{
    ll k,n,first,i;
    cin >> k >> n;
    vector < ll >v;
    for(i=1;i<=n;i++)
    {
        ll x;
        cin >> x;
        v.push_back(x);
    }

    ll maxi=-1;
    for(i=0;i<n;i++)
    {
        ll x;
        x=v[i]-v[i-1];
        if(x>maxi)
            maxi=x;
    }

    first=abs(0-v[0]);
    first+=abs(k-v[n-1]);

    //cout << first << endl;
    if(first>maxi)
        maxi=first;

    cout << k-maxi << endl;
    return 0;
}


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

int main(){
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());

    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), N = ip[0], i = ip[1];
	writeln(N - i + 1);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
import math

def countDividers(n):
    divisors = []
    for i in range(1, int(math.sqrt(n))+1):
        if n % i == 0:
            divisors.append(i)
            divisors.append(int(n/i))
    return len(divisors)


if __name__ == '__main__':
    n = int(input())
    count = 0
    for i in range(1,n+1):
        if i %2 ==1 and countDividers(i) == 8:
            count += 1
           
    print(count)


Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;


#define INX(x) (cin >> x)
#define OUTX(x) (cout << x << endl)

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>


int main()
{
    ll N, M;
    cin >> N >> M;

    //vvll g(N+1); //graph of friend network; g[0] is not used
    vector<set<ll>> g(N+1);
    for (ll i = 1; i <= M; i++)
    {
        ll tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        //g[tmp1].ADD(tmp2);
        //g[tmp2].ADD(tmp1);
        g[tmp1].emplace(tmp2);
        g[tmp2].emplace(tmp1);
    }
    
    ll result = 1;
    vector<bool> checked(N+1, false);
    for (ll i = 1; i <= N; i++)
    {
        if(checked[i])
        {
            continue;
        }

        checked[i] = true;
        queue<ll> q;
        for(auto x : g[i])
        {
            if(checked[x])
            {
                continue;
            }

            checked[x] = true;
            q.push(x);
        }

        ll groupsize = 1;
        while(q.size() != 0)
        {
            ll target = q.front();
            checked[target] = true;
            groupsize++;
            for(auto y : g[target])
            {
                if(checked[y])
                {
                    continue;
                }

                checked[y] = true;
                q.push(y);
            }
            q.pop();
        }

        if(groupsize > result)
        {
            result = groupsize;
        }
    }
    cout << result << endl;
    



    return 0;
}


Measured memory_bytes: 31908
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define INF (ll)1e19
#define N 2000006

using namespace std;

int n, m;
char a[105][105];
int dx[8] = {0, 0, 1, -1, -1, -1, 1, 1};
int dy[8] = {1, -1, 0, 0, -1, 1, -1 ,1};
int main() {
    //freopen("txt.in", "r", stdin);
    //freopen("txt.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
        cin >> a[i][j];
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
        if (a[i][j] != '#') {
        int c = 0;
        for (int k = 0; k < 8; k++)
            if (a[i + dx[k]][j + dy[k]] == '#') c++;
        a[i][j] = char(c + 48);
        }
        if (j < m) cout << a[i][j];
        else cout << a[i][j] << endl;
    }

	return 0;
}


Measured memory_bytes: 256
<?php
/*
    Problem URL : http://abc053.contest.atcoder.jp/tasks/abc052_b

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

fscanf(STDIN, "%d", $N);
fscanf(STDIN, "%s", $S);

$ans = 0;
$cur = 0;

for ($i = 0; $i < $N; $i++) {
    switch($S[$i]) {
        case "I":
            $cur++;
            $ans = max($ans, $cur);
            break;

        case "D":
            $cur--;
            break;

    }
}

echo $ans . PHP_EOL;


Measured memory_bytes: 4604
#include<stdio.h>
 
int main(void){

	double x[2][3];
	double su1=0,su2=0;
	int i,j,k;
	char str[100];
    
	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		sscanf(str,"%lf %lf %lf %lf %lf %lf",&x[0][0],&x[0][1],&x[0][2],&x[1][0],&x[1][1],&x[1][2]);

/*????§????????????????*/
    for(k=0;k<=0;k++){
        for(j=k+1;j<=1;j++){
            su1=x[k][k];
            su2=x[j][k];
            for(i=0;i<=2;i++){
                x[j][i]=x[j][i]-x[k][i]*su2/su1;
            }
        }
    }
    
/*?????????????????????*/
    for(k=0;k<=0;k++){
        for(j=k+1;j<=1;j++){
            su1=x[1-k][1-k];
            su2=x[1-j][1-k];
            for(i=0;i<=2;i++){
                x[1-j][i]=x[1-j][i]-x[1-k][i]*su2/su1;
            }
        }
    }
 
 
    su1=0;
        for(j=0;j<=1;j++){
        su1=x[j][j];
            for(i=0;i<=2;i++){
                    x[j][i]=x[j][i]/su1;
            }
        }
 
/*?????¢??????*/
 
    printf("%3.3f %3.3f\n",x[0][2],x[1][2]);
    }
    return 0;
}

Measured memory_bytes: 656
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

/*==================================================*/

/*==================================================*/

int H,W;
string a;

int alp[26];

int main() {
    cin>>H>>W;
    REP(i,0,H){
        cin>>a;
        REP(j,0,a.size()){
            alp[a[j]-'a']++;
        }
    }

    for(int i = 0; i < H/2; i++){
        for(int j = 0; j < W/2; j++){
            sort(alp,alp+26);

            if(alp[25] >= 4){
                alp[25] -= 4;
            }else{
                cout<<"No"<<endl;
                return 0;
            }
        }
    }

    bool flag = true;

    if(H % 2 == 1){
        //test
        // cout<<"H % 2 == 1"<<endl;
        REP(j,0,W/2){
            sort(alp,alp+26);

            if(W % 2 == 1 && j == W / 2){
                // if(alp[25] >= 1){
                //     flag = false;
                //     alp[25]--;
                //     continue;
                // }else{
                //     cout<<"No"<<endl;
                //     return 0;
                // }
            }else{
                if(alp[25] >= 2){
                    alp[25] -= 2;
                    continue;
                }else{
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }
    if(W % 2 == 1){
        //test
        //cout<<"W % 2 == 1"<<endl;
        REP(i,0,H/2){
            sort(alp,alp+26);

            //test
            // REP(k,0,26){
            //     cout<<alp[k]<<", ";
            // }
            // cout<<endl;

            if(H % 2 == 1 && i == H / 2){
                // if(alp[25] >= 1 || !flag){
                //     if(flag) alp[25]--;
                //     continue;
                // }else{
                //     cout<<"No"<<endl;
                //     return 0;
                // }
            }else{
                if(alp[25] >= 2){
                    alp[25] -= 2;
                    continue;
                }else{
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }

    if(H % 2 == 1 && W % 2 == 1){
        sort(alp,alp+26);
        if(alp[25] != 1){
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll s;
  cin >> s;
  cout << s%9 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
using P = pair<int,int>; using vp = vector<P>;
//constexpr int MOD = /**/ 1000000007; //*/ 998244353;
constexpr int MOD = 104857601;
////////////////

void solve(){
  vector<string> n = {
    "SUN","MON","TUE","WED","THU","FRI","SAT"
  };
  ins(S);
  out( 7 - int( find( all(n) , S ) - n.begin()));
}

/*
void solve(){
  ini(N,M);
  vl a(N); in(a);
  map<ll,int> m;
  m[0]++;
  ll cur = 0;
  each(x,  a){
    cur = (cur + x + M - 1) % M;
    m[cur]++;
  }
  ll ans = 0;
  each(x,m)trc(x);
  each(x , m){
    ans += 1LL * x.se * (x.se - 1) / 2;
  }
  out(ans);

  
}
*/

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from collections import *
import math
from bisect import *
import functools
INF = float('inf')
mod = 10**9+7

a, b = map(int, input().split())
if b == 1:
    print(0)
    exit()
n, c = a, 1
while n < b:
    n += a-1
    c += 1
print(c)


Measured memory_bytes: 3828
n=int(input())
lists=list(map(int,input().split()))
listsa=[0]
s=0
for i in range(n):
    s+=lists[i]
 
    listsa.append(s)

uselists=sorted(listsa)

import collections
ans=collections.Counter(uselists)
a=0
for i in ans.values():
    a+=(i-1)*(i)//2
print(a)


Measured memory_bytes: 42996
#include<bits/stdc++.h>
using namespace std;
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
char S[200002];
char T[200002];
int N;
int cnv[26];
int rev[26];
int main(){
  int i, j;
  N = rd(S);
  rd(T);
  for(i=0;i<26;i++){
    cnv[i] = rev[i] = -1;
  }
  for(i=0;i<N;i++){
    S[i] -= 'a';
  }
  for(i=0;i<N;i++){
    T[i] -= 'a';
  }
  for(i=0;i<N;i++){
    if(cnv[S[i]]==-1 && rev[T[i]]==-1){
      cnv[S[i]] = T[i];
      rev[T[i]] = S[i];
    }
    if(cnv[S[i]] != T[i] || rev[T[i]] != S[i]){
      wt_L("No");
      wt_L('\n');
      return 0;
    }
  }
  wt_L("Yes");
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// char S[200002], T[200002];
// 
// int N;
// int cnv[26], rev[26];
// {
//   int i, j;
// 
//   rd(S@N, T);
//   rep(i,26) cnv[i] = rev[i] = -1;
//   rep(i,N) S[i] -= 'a';
//   rep(i,N) T[i] -= 'a';
// 
//   rep(i,N){
//     if(cnv[S[i]]==-1 && rev[T[i]]==-1){
//       cnv[S[i]] = T[i];
//       rev[T[i]] = S[i];
//     }
// 
//     if(cnv[S[i]] != T[i] || rev[T[i]] != S[i]){
//       wt("No");
//       return 0;
//     }
//   }
// 
//   wt("Yes");
// }


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

int n, a[100000];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);

	int height = 0, width = 0;
	for (int i = n-1; i > 0; i--) {
		if (a[i] == a[i - 1]) {
			if (height == 0)height = a[i];
			else if(width == 0)width = a[i];
			i--;
		}
	}

	long long menseki = height;
	menseki *= width;
	cout << menseki << endl;
}

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

#define BROKE 1

int main() {

  int64_t n,m;
  cin>>n>>m;
  
  
  //n段目に来るルートは１段前から来るか、2段前から来るか
  //ただし、1段目か2段目が壊れていたら来れない
  //格段のルート数の足し算が移動方法になる

  //壊れた床の場所を格納
  vector<int64_t> broken(n+1);
  for(int i=0;i<m;i++){
    int wk=0;
    cin>>wk;
    broken.at(wk)=BROKE;
  }

  //移動方法を調べる
  vector<int64_t> route(n+1);
  route.at(0)=1;
  for(int i=1;i<=n;i++){
    int route1,route2;
    if(broken.at(i-1)==BROKE)
      route1 = 0;
    else
      route1 = route.at(i-1);
    
    if(i<2 || broken.at(i-2)==BROKE)
      route2 = 0;
    else
      route2 = route.at(i-2);
    
    if(broken.at(i)==BROKE)
      route.at(i)=0;
    else
      route.at(i) += (route1+route2)%1000000007;
  }

  cout<<route.at(n)<<endl;

  return 0;
}


Measured memory_bytes: 4856
#include<stdio.h>

#define N 100
#define MAX 2000
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2


int A[N][N], n;

void dijkstra();

int main(){
  int i, j, s, x, y, c, k;
  scanf("%d", &n);
  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j ++){
      A[i][j] = INFTY;
    }
  }
  for( i = 0 ; i < n ; i++ ){
    scanf("%d%d", &x, &k);
    for( j = 0 ; j < k ; j ++){
      scanf("%d%d", &y, &c);
      A[x][y] = c;
    }
  }

  dijkstra();

  return 0;
  
}


void dijkstra(){
  
  int i, x, y, min;
  int sum = 0;
  int d[N], color[N];

  for( i = 0 ; i < n ; i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }
  d[0] = 0;
  color[0] = GRAY;
  while(1){
    min = INFTY;
    x = -1;
    for( i = 0; i < n ; i++){
      if(min > d[i] && color[i] != BLACK){
        x = i;
        min = d[i];
      }
    }
    if( x == -1 ) break;
    color[x] = BLACK;
    for( y = 0 ; y < n ; y++){
      if( color[y] != BLACK && A[x][y] != INFTY ){
        if( d[y] > d[x] + A[x][y] ){
          d[y] = d[x] + A[x][y];
          color[y] = GRAY;
        }
      }
    }
  }
  for( i = 0 ; i < n ; i++ ){
    printf("%d %d\n", i, (d[i] == INFTY ? -1 : d[i]));
  }
}



Measured memory_bytes: 2060
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string a, b ; cin >> a >> b ;
  sort(all(a));
  sort(rall(b));

  if(a < b ) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np
N,M=map(int,input().split())
flag=[False]*(N+1)
ac=0
wa=[0]*(N+1)
for _ in range(M):
    p,s=input().split()
    p=int(p)
    if flag[p]==False:
        if s=='AC':
            flag[p]=True
        else:
            wa[p]+=1
print(sum(np.array(flag)),sum(np.array(wa)*np.array(flag)))

Measured memory_bytes: 28780
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n, m; readV(n, m);

  auto r = 1;
  foreach (f; 1..m.nsqrt+1) {
    if (m%f != 0) continue;
    if (m/f >= n) r = max(r, f);
    if (f >= n) r = max(r, m/f);
  }

  writeln(r);
}

pure T nsqrt(T)(T n)
{
  import std.algorithm, std.conv, std.range, core.bitop;
  if (n <= 1) return n;
  T m = T(1) << (n.bsr/2+1);
  return iota(1, m).map!"a * a".assumeSorted!"a <= b".lowerBound(n).length.to!T;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 5005, M = 202, LG = 14;
int n, m, B[M][N], Log[N];
long long Mx, A[N], dp[N][N];
pair < int , int > MX[LG][N];
inline int RMQ(int l, int r)
{
    int &lg = Log[r - l];
    return (max(MX[lg][l], MX[lg][r - (1 << lg)]).second);
}
void Solve(int l, int r)
{
    if (r < l) return ;
    int i = RMQ(l, r + 1);
    dp[l][i] += MX[0][i].first;
    dp[i + 1][i] -= MX[0][i].first;
    dp[l][r + 1] -= MX[0][i].first;
    dp[i + 1][r + 1] += MX[0][i].first;
    Solve(l, i - 1); Solve(i + 1, r);
}
int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 2; i <= n; i++)
        scanf("%d", &A[i]), A[i] += A[i - 1];
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            scanf("%d", &B[j][i]);
    for (int i = 2; i < N; i++)
        Log[i] = Log[i >> 1] + 1;
    for (int j = 1; j <= m; j++)
    {
        for (int i = 1; i <= n; i++)
            MX[0][i] = {B[j][i], i};
        for (int h = 1; h < LG; h++)
            for (int i = 1; i + (1 << h) <= n + 1; i++)
                MX[h][i] = max(MX[h - 1][i], MX[h - 1][i + (1 << h - 1)]);
        Solve(1, n);
    }
    for (int i = 1; i < N; i++)
        for (int j = 1; j < N; j++)
            dp[i][j] += dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
    for (int i = 1; i <= n; i++)
        for (int j = i; j <= n; j++)
            Mx = max(Mx, dp[i][j] - A[j] + A[i]);
    return !printf("%lld", Mx);
}

Measured memory_bytes: 200320
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  vll a(n); REP(i, n) cin >> a.at(i);
  vll b(n); REP(i, n) cin >> b.at(i);
  sort(b.begin(), b.end());
  ll k = 1;
  ll ans = 0;
  REP(i, 29) {
    vll ar(n), br(n);
    ll div = (1 << i);
    REP(j, n) {
      ar.at(j) = a.at(j) % (div << 1);
      br.at(j) = b.at(j) % (div << 1);
    }
    sort(br.begin(), br.end());
    ll ians = 0;
    REP(j, n) {
      ians += lower_bound(br.begin(), br.end(), 2*div-ar.at(j)) - lower_bound(br.begin(), br.end(), div-ar.at(j)) +
        lower_bound(br.begin(), br.end(), 4*div-ar.at(j)) - lower_bound(br.begin(), br.end(), 3*div-ar.at(j));
    }
    ans += ((ians%2) << i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6548
import collections
n = int(input())
v = list(map(int,input().split()))
v_odd = []
v_even = []
for i,v in enumerate(v):
    if i % 2:
        v_even.append(v)
    else:
        v_odd.append(v)
odd_n = len(v_odd)
even_n = len(v_even)
v_odd = collections.Counter(v_odd)
v_odd = sorted(v_odd.items(), key=lambda x:x[1],reverse=True)
v_even = collections.Counter(v_even)
v_even = sorted(v_even.items(), key=lambda x:x[1],reverse=True)

if v_odd[0] == v_even[0] and 2 <= len(v_odd) and 2 <= len(v_even):
    if v_odd[1][1] < v_even[1][1]:
        v_even.pop(0)
    elif v_odd[1][1] > v_even[1][1]:
        v_odd.pop(0)

num = v_odd[0][0]

ans = odd_n-v_odd[0][1]
st = 0
for i,v in v_even:
    if num == i:
        continue
    else:
        st = v
        break
print(ans+(even_n-st))

Measured memory_bytes: 24704
using System.Text;
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var Q = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        Array.Sort(a);
        var amax = a[n - 1];
        var b = new int[amax + 1];
        setB(a, b);
        var sb = new StringBuilder();
        for (int i = 0; i < Q; i++)
        {
            var q = int.Parse(Console.ReadLine().Trim());
            getAns(b, q , sb);
        }
        Console.Write(sb);
    }
    public static void getAns(int[] b, int q , StringBuilder sb)
    {
        var ans = 0;
        var na = b[b.Length - 1];
        while (true)
        {
            na = b[na];
            var w = na % q;
            if (w == q - 1) { sb.Append(string.Format("{0}\n", q - 1)); return; }
            ans = Max(ans, w);
            if (w == 0) na -= 1;
            else na -= w;
            if (na <= 0) break;
        }
        sb.Append(string.Format("{0}\n", ans));
    }
    public static void setB(int[] a, int[] b)
    {
        var aL = a.Length;
        var bL = b.Length;
        for (int i = 0; i < aL; i++)
            b[a[i]] = a[i];
        for (int i = a[0] + 1; i < bL; i++)
            if (b[i] == 0) b[i] = b[i - 1];
    }
}




Measured memory_bytes: 46076
import sys
(N, M) = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(M)]

answer_arry = ['x'] * N

dict = {}
for i in range(M):
    if S[i][0] in dict and S[i][1] != dict[S[i][0]]:
          print(-1)
          sys.exit()
    if N != 1 and S[i][0] == 1 and S[i][1] == 0:
          print(-1)
          sys.exit()
    dict[S[i][0]] = S[i][1]
    answer_arry[S[i][0] - 1] = S[i][1]

answer_str = ""
for i in range(N):
    if answer_arry[i] == 'x':
        if i == 0 and N != 1:
            answer_str += '1'
        else:
            answer_str += '0'
    else:
        answer_str += str(answer_arry[i])
print(int(answer_str))

Measured memory_bytes: 3064
import java.util.*;
import java.lang.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		int input1;
		int input2;

		Scanner sc = new Scanner(System.in);
		// String inputline = sc.next();
		// String[] inputArray = inputline.split("\\s");
		// input1 = Integer.parseInt(inputArray[0]);
		// input2 = Integer.parseInt(inputArray[1]);

		input1 = sc.nextInt();
		input2 = sc.nextInt();
		
		int swap;
		if (input1 > input2) {
			
			swap = input2;
			input2 = input1;
			input1 = swap;
		}
		
		// ユークリッドの互除法を用いた最大公約数を
		swap = 0;
		while ((swap = input1 % input2) != 0) {
			input1 = input2;
			input2 = swap;
		}
		
		System.out.println(input2);
	}
}


Measured memory_bytes: 26244
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Mar  1 19:29:34 2019

@author: nakamuratakayuki
"""
A,B = tuple(map(int, input().split()))

if 1 <= abs(A-B):
    print(max(A,B)*2-1)
else:
    print(max(A,B)*2)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define MAX 2*1000
using namespace std;

int N,L[MAX];
int ans = 0;

int main(){
	cin >> N;
	for(int i=0;i<N;i++) cin >> L[i];
	for(int i=0;i<N;i++){
		for(int j = 0;j < i;j++){
			if(L[j] > L[i]) swap(L[i],L[j]);
		}
	}
	
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			for(int k=j+1;k<N;k++){
				if(L[i] + L[j] > L[k]) ans++;
			}
		}
	}
	cout << ans << endl;	
}


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

int sumOfEachDigits(int num) {
  int sum = 0;
  while (num != 0)
  {
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

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

  bool f = 0;
  if (N % sumOfEachDigits(N) == 0) f = 1;

  cout << (f ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int waru(int n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n=n/10;
        //sum++;
    }
    return sum;
}
   


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

    int n,a,b;
    cin>>n;
    int min =waru(n-1)+waru(1);

    rep(i,n)FOR(j,i+1,n){
        if(i+j==n && min>waru(i)+waru(j)){
            min =waru(i)+waru(j);
            //cout<<i<<" "<<j<<endl;

        }
    }
cout<<min<<endl;
}



Measured memory_bytes: 3640
#include <utility>
#include <vector>
#include <iostream>
#include <cstdlib>
#include<bits/stdc++.h>
#include <limits>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
using namespace std;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ul N;
    cin >> N;
    ul min = LLONG_MAX;
    for(ul i = 1; i*i <= N; i++){
        if(N % i == 0){
            ul j = N / i;
            int place = log10(j)+1;
            if(place < min){
                min = place;
            }
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define int ll
#define ld double
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect

void solve25(string s, int p) {
    int ans2 = 0, ans5 = 0;
    loop(i, s.size()) {
        if ((s[i] - '0') % 2 == 0)
            ans2 += i + 1;
        if ((s[i] - '0') % 5 == 0)
            ans5 += i + 1;
    }
    cout << (p == 2 ? ans2 : ans5);
}

void solve() {
    int n, p;
    cin >> n >> p;
    string s; cin >> s;
    if (p == 2 || p == 5) {
        solve25(s, p);
        return;
    }
    int deg[n + 1] = {1}, ps[n + 1];
    loop1(i, n)
        deg[i] = deg[i - 1] * 10 % p;
    ps[n] = 0;
    for (int i = n - 1; i >= 0; --i)
        ps[i] = (deg[n - i - 1] * (s[i] - '0') + ps[i + 1]) % p;
    int calc[p] = {0};
    loop(i, n + 1)
        ++calc[ps[i]];
    int ans = 0;
    loop(i, p)
        ans += calc[i] * (calc[i] - 1) / 2;
    cout << ans;
}
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <vector>

int main()
{
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  std::vector<std::vector<std::pair<int, bool>>> xy(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
    xy[i].resize(a[i]);
    for (int j = 0; j < a[i]; ++j) {
      int x;
      bool y;
      std::cin >> x >> y;
      xy[i][j] = std::make_pair(x - 1, y);
    }
  }

  auto isOK = [&](std::vector<bool> &bit) -> bool {
    for (int i = 0; i < n; ++i) {
      if (!bit[i])
        continue;
      for (int j = 0; j < a[i]; ++j) {
        if (bit[xy[i][j].first] != xy[i][j].second)
          return false;
      }
    }
    return true;
  };

  int res = 0;
  for (int k = 0; k < (1 << n); ++k) {
    std::vector<bool> bit(n, false);
    for (int i = 0; i < n; ++i)
      if (k & (1 << i))
        bit[i] = true;

    if (isOK(bit)) {
      int num = 0;
      for (auto v : bit)
        if (v)
          ++num;
      if (res < num)
        res = num;
    }
  }

  std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

int b[4010][4010];

int sumt(int x1,int y1,int x2,int y2){
  return b[x2][y2]-b[x1][y2]-b[x2][y1]+b[x1][y1];
}
// Driver program
void Main() {

  int N,K;
  cin>>N>>K;

  int K2=2*K;
  //int b[2*K2+1][2*K2+1]={};

  rep(i,N){
    int x,y; char c;
    cin>>x>>y>>c;
    if(c=='B'){
      int nx=x%K2+1;
      int ny=y%K2+1;
      ++b[nx][ny];
      ++b[nx][ny+K2];
      ++b[nx+K2][ny];
      ++b[nx+K2][ny+K2];
    }
    else{
      int nx=(x+K)%K2+1;
      int ny=y%K2+1;
      ++b[nx][ny];
      ++b[nx][ny+K2];
      ++b[nx+K2][ny];
      ++b[nx+K2][ny+K2];
    }
  }

  reps(i,1,K2*2+1){
    reps(j,1,K2*2+1){
      b[i][j]+=b[i][j-1]+b[i-1][j]-b[i-1][j-1];
    }
  }

  ll ans=0;
  rep(i,K2){
    rep(j,K2){
      ll buff=0;
      buff+=sumt(i,j,i+K,j+K);
      buff+=sumt(i+K,j+K,i+K2,j+K2);
      maxi(ans,buff);
    }
  }

  cout<< ans<<"\n";
}


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


Measured memory_bytes: 62976
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using Pii = pair<int, int>;
using Vi = vector<int>;
using St = string;
using Ch = char;

const double pi = 3.1415926535;

void Main()
{
	int a, b, c;
	cin >> a >> b >> c;
	for (int i = 1; i <= b; i++) {
		if (i*a % b == c) {
			cout << "YES" << endl;
			return;
		}
	}
	cout << "NO" << 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: 3620