akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll N = 500030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    998244353;


int main()
{  fast
ll n;
cin>>n;
while(n)
{
	int x=n%10;
	if(x==7)
	{
		cout<<"Yes";
		return 0;
}
n/=10;
}
cout<<"No";
	

}


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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

signed main()
{
   cin.tie(nullptr);
   ios_base::sync_with_stdio(false);

   string s;
   cin>>s;
   int n;
   cin>>n;
   int cnt=0;

   rep(i,0,s.size()){
      if(s[i] == '1') ++cnt;
      else break;
   }

   if(n <= cnt){
      cout<<1<<'\n';
   }else if(cnt == 0){
      cout<<s[0]<<'\n';
   }else{
      cout<<s[cnt]<<'\n';
   }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		Scanner scn = new Scanner(System.in);
		int k = scn.nextInt();
		long ans = 0;
		for (int i = 1; i <= k; i++)
			for (int j = 1; j <= k; j++)
				for (int p = 1; p <= k; p++)
					ans += gcd(gcd(i, j), p);
		System.out.println(ans);
	}
 
	public static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}
 
	static class Scanner {
 
		StringTokenizer st;
		BufferedReader br;
 
		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 32712
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, k;
    cin >> n >> k;
    const ll m = n*(n+1)/2;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    vl rui(n+1);
    rep(i, n) {
        rui[i+1] = rui[i] + a[i];
    }

    vl v;
    rep(i, n) {
        exrep(j, i+1, n) {
            v.pb(rui[j] - rui[i]);
        }
    }

    ll ans = 0;
    vector<bool> dame(m);
    for(ll d = 60; d >= 0; d--) {
        ll cnt = 0;
        rep(i, m) {
            if(dame[i]) {
                continue;
            }
            if(v[i] & (1LL<<d)) {
                cnt++;
            }
        }
        if(cnt >= k) {
            ans += (1LL<<d);
            rep(i, m) {
                if(!(v[i] & (1LL<<d))) {
                    dame[i] = true;
                }
            }
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 6388
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp62 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());

            int[] H = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            //n項目から右に連続で下降する個数をV[n]とする
            int[] V = new int[N];
            V[N - 1] = 0;

            for (int i = N - 1; i > 0; i--) {
                if (H[i - 1] >= H[i]) {
                    V[i - 1] = V[i] + 1;
                } else {
                    V[i - 1] = 0;
                }
            }

            Console.WriteLine(V.Max());
        }
    }
}


Measured memory_bytes: 32732
#include <iostream>
using namespace std;
int main() {
    int n, x;
    cin >> n >> x;
    int cur = 0;
    int d = 0;
    for(int i = 0; i < n; i++) {
        int l;
        cin >> l;
        if(d > x)
            break;
        d += l;
        cur++;
    }
    if(d <= x)
        cur++;
    cout << cur << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<=b){
		if(b<=c){printf("%d %d %d\n",a,b,c);}
		else if(a<=c){printf("%d %d %d\n",a,c,b);}
		else{printf("%d %d %d\n",c,a,b);}
	}
	else{
		if(a<=c){printf("%d %d %d\n",b,a,c);}
		else if(b<=c){printf("%d %d %d\n",b,c,a);}
		else{printf("%d %d %d\n",c,b,a);}
	}
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> p;
typedef long long ll;
typedef pair<ll,ll> pll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;
const ll MOD=1e9+7;

int main(){
    int h,w;cin>>h>>w;
    vector<string> A(h);
    for(int i=0;i<h;++i) cin>>A[i];
    vector<vector<int> > d(h,vector<int>(w,INF));
    queue<pii> que;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            if(A[i][j]=='#'){
                d[i][j]=0;
                que.push(pii(i,j));
            }
        }
    }
    int ans=0;
    while(!que.empty()){
        pii p=que.front();que.pop();
        int y=p.first,x=p.second;
        for(int i=0;i<4;++i){
            int ny=y+dy[i];
            int nx=x+dx[i];
            if(ny<0||ny>=h||nx<0||nx>=w) continue;
            if(d[ny][nx]!=INF) continue;
            d[ny][nx]=d[y][x]+1;
            que.push(pii(ny,nx));
            ans=max(ans,d[ny][nx]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 17124
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, t;
int a[100010];

int solve() {
    int mini[n+1];
    mini[0] = inf;
    for (int i = 0; i < n; i++) {
        mini[i+1] = min(mini[i], a[i]);
    }

    int md = 0;
    for (int i = 0; i < n; i++) {
        md = max(md, a[i] - mini[i]);
    }

    int res = 0;
    int prev = -inf, previ = 0, c0 = 0, c1 = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] - mini[i] == md) {
            if (prev != a[i]) {
                res += min(c0, c1);
                c0 = 1;
                c1 = 0;
                prev = a[i];
            } else {
                c0++;
            }
            for (int j = previ; j < i; j++) {
                if (a[j] == mini[i])
                    c1++;
            }
            previ = i;
        }
    }
    res += min(c0, c1);
    return res;
}

void input() {
    cin >> n >> t;
    for (int i = 0; i < n; i++) cin >> a[i];
}

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

    input();
    cout << solve() << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;

int main(){
    int N,M;
    ll ans = 0;
    cin >> N >> M;
    vector<pair<ll,ll>> vec(N);
    for(int i=0;i<N;i++){
        cin >> vec[i].first >> vec[i].second;
    }
    sort(vec.begin(),vec.end());

    int Sum = 0;
    for(int i=0;i<N;i++){
        if(vec[i].second <= (M - Sum)){
            ans = ans + vec[i].first * vec[i].second;
            Sum = Sum + vec[i].second;
        }else{
            ans = ans + vec[i].first * (M - Sum);
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
/**
 * author: BueVonHun 🐼🎋
 * More Info: https://github.com/Bue-von-hon
**/

#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <cstring>
#include <cmath>

typedef long long ll;
using namespace std;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl '\n'
#define mp make_pair
#define pii pair<int,int>
#define piii pair<int,pii>
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

template <class T> T _min(T a,T b){return (a<b ? a : b);}
template <class T> T _max(T a,T b){return (a>b ? a : b);}
template<class T> void read(T& x) {cin >> x;}

int test_case;
int main(void) {
    fast_cin();

    int n,x,t;
    cin >> n >> x >> t;
    int time = t;
    int sol = x;
    while (true) {
        if (sol>=n) {cout << time << endl; break;}
        time+=t;
        sol+=x;
    }

    return 0;
}


Measured memory_bytes: 3648
N,M = map(int, input().split())
LR = list()
al = 0
ar = 0
for i in range(M):
    LR.append( list(map(int,input().split())) )
    L = LR[i][0]
    R = LR[i][1]
    if i == 0:
        al = L
        ar = R
    if al < L:
        al = L
    if ar > R:
        ar = R
    if ar < L or al > R:
        print(0)
        exit()
print(ar-al+1)

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

int main(){
  int A,B;
  cin>>A>>B;
  if(A==1){
    A=14;
  }
  if(B==1){
    B=14;
  }
  if(A==B){
    cout <<"Draw"<<endl;
  } else if(A >B){
    cout <<"Alice"<<endl;
  }else{
    cout<<"Bob"<<endl;
  }
  return 0;
}

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

int main() {
    int M,N;
    cin >> N >> M;
    int cnt_N, cnt_M;

    if(N == 0 || N == 1){
        cnt_N = 0;
    }else{
        cnt_N = N * (N - 1) / 2;
    }

    if(M == 0 || M == 1){
        cnt_M = 0;
    }else{
        cnt_M = M * (M - 1) / 2;
    }

    cout << cnt_N + cnt_M << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC79 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

#全点対最短路問題(ワーシャルフロイド法)
h,w = map(int,input().split())
d = [list(map(int,input().split())) for _ in range(10)]
for k in range(10):
    for i in range(10):
        for j in range(10):
            d[i][j] = min(d[i][j],d[i][k] + d[k][j])
m = [list(map(int,input().split())) for _ in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if m[i][j] == -1:
            continue
        if m[i][j] == 1:
            continue
        else:
            ans += d[m[i][j]][1]
print(ans)


Measured memory_bytes: 40540
PROGRAM-ID.                      ABC_053_B.
ENVIRONMENT                      DIVISION.
INPUT-OUTPUT                     SECTION.
FILE-CONTROL.
    SELECT SYSIN ASSIGN TO KEYBOARD ORGANIZATION LINE SEQUENTIAL.

DATA                             DIVISION.
FILE                             SECTION.
    FD  SYSIN.
        01 INDATA PIC X(200000).

WORKING-STORAGE                  SECTION.
    01 INP1.
        03 INP PIC X(1) OCCURS 200000.

    01 len     PIC 9(6).

    01 i       PIC 9(6) BINARY.
    01 j       PIC 9(6) BINARY.

    01 ZS      PIC Z(7).
    01 DUMMY   PIC X(1).

    01 ans     PIC X(6).

PROCEDURE                        DIVISION.
    OPEN INPUT SYSIN.

    READ SYSIN INTO INP1.

    CLOSE SYSIN.

    COMPUTE len = FUNCTION STORED-CHAR-LENGTH(INP1).

    PERFORM VARYING i FROM 1 BY 1 UNTIL len < i
        IF INP(i) = 'A' THEN
            EXIT PERFORM
        END-IF
    END-PERFORM.

    PERFORM VARYING j FROM len BY -1 UNTIL j < 1
        IF INP(j) = 'Z' THEN
            EXIT PERFORM
        END-IF
    END-PERFORM.

    SUBTRACT i FROM j.
    ADD 1 TO j.

    MOVE j TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 768
n,m=(int(x) for x in input().split())
z=0
dic={}
for i in range(m):
	s,c=(int(x) for x in input().split())
	if s in dic:
		if dic[s]!=c:
			z=-1
	else:
		dic[s]=c
if z==-1:
	print(-1)
else:
	if 1 in dic and n>1 and dic[1]==0:
			print(-1)
	else:
		if n==1:
			if 1 not in dic:
				print(0)
			else:
				print(dic[1])
		elif n==2:
			if 1 not in dic:
				dic[1]=1
			if 2 not in dic:
				dic[2]=0
			print(10*dic[1]+dic[2])
		elif n==3:
			if 1 not in dic:
				dic[1]=1
			if 2 not in dic:
				dic[2]=0
			if 3 not in dic:
				dic[3]=0
			print(100*dic[1]+10*dic[2]+dic[3])
				

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++){
        if ((i % 2 == 0 && (s[i] == 'L')) || (i % 2 == 1 && s[i] == 'R')){
            printf("No");
            return 0;
        }
    }
    printf("Yes");


}


Measured memory_bytes: 256
import java.util.*;

class Main{
    static{
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int ans = 0;
        ans = a;
        if(b < a){
            ans--;
        }
        System.out.println(ans);
    }
    public static void main(String[] args){

    }
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const ll MOD=998244353,INF=1ll<<60;
int dx[]={0,0,1,-1};
int dy[]={-1,1,0,0};
typedef pair<int,pint>P2;
typedef vector<vint>vvint;

int a,b,c,d,e,f,g,h;
int ans=0;

signed main() {
    IOS();
    cin>>a>>b>>c>>d>>e>>f>>g;
    if((a&&d%2&&e%2)||(a%2&&d&&e%2)||(a%2&&d%2&&e)){
        ans+=3;
        a--;
        d--;
        e--;
    }
    ans+=b+(a/2)*2+(d/2)*2+(e/2)*2;
    cout<<ans+(a%2&&d%2&&e%2)*3<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#define maxn 100000
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
int n;
struct edge {
	int from;
	int to;
	int len;
	int next;
} E[maxn*2+5];
int esz=1;
int head[maxn+5];
void add_edge(int u,int v,int w) {
	esz++;
	E[esz].from=u;
	E[esz].to=v;
	E[esz].len=w;
	E[esz].next=head[u];
	head[u]=esz;
}

ll ans=0; 
int root;
int sz[maxn+5],f[maxn+5];
void dfs1(int x,int fa){
	sz[x]=1;
	for(int i=head[x];i;i=E[i].next){
		int y=E[i].to;
		if(y!=fa){
			dfs1(y,x);
			sz[x]+=sz[y];
			f[x]=max(f[x],sz[y]);
		}
	}
	f[x]=max(f[x],n-sz[x]);
	if(f[x]<f[root]) root=x;
}
void dfs2(int x,int fa,ll len){
	for(int i=head[x];i;i=E[i].next){
		int y=E[i].to;
		if(y!=fa){
			dfs2(y,x,E[i].len);
		}
	}
	ans+=min(sz[x],n-sz[x])*len*2; 
}
int main(){
	int u,v,w;
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d %d %d",&u,&v,&w);
		add_edge(u,v,w);
		add_edge(v,u,w);
	}
	f[0]=INF;
	dfs1(1,0);
	dfs2(1,0,0);
	int minl=INF;
	for(int i=head[root];i;i=E[i].next){
		int y=E[i].to;
		minl=min(minl,E[i].len);
		if(f[root]==f[y]){//两个重心 
			printf("%lld\n",ans-E[i].len);
			return 0;
		}
	}
	printf("%lld\n",ans-minl);
}

Measured memory_bytes: 8576
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define MP make_pair
#define PB push_back

//Union-Find木(ランク有り)
struct UnionFind{
private:
	vector<int> parent;
	vector<int> rank;
public:
	void init(int N){ //初期化する O(N)
		parent.clear();
		rank.clear();
		for(int i=0; i<N; i++) parent.push_back(i);
		for(int i=0; i<N; i++) rank.push_back(0);
	}
	int root(int a){ //親を返す O(log N)
		if(parent[a] == a) return a;
		return parent[a] = root(parent[a]);
	}
	void unite(int a, int b){ //木を併合する O(log N)
		int rootA = root(a);
		int rootB = root(b);
		if(rootA == rootB) return;
		if(rank[rootA] < rank[rootB]) parent[rootA] = rootB;
		else{
			parent[rootB] = rootA;
			if(rank[rootA] == rank[rootB]) rank[rootA]++;
		}
	}
	bool same(int a, int b){ //属する木が同じかを返す O(log N)
		return root(a) == root(b);
	}
};


int main(){
	
	int N,M;
	cin >> N >> M;
	UnionFind uf;
	uf.init(N);
	for(int i=0; i<M; i++){
		int X,Y,Z;
		cin >> X >> Y >> Z;
		uf.unite(X-1, Y-1);
	}
	int ans = 0;
	for(int i=0; i<N; i++){
		if(uf.root(i) == i) ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
using namespace std;
const int N=1e5+3, INF=1e9;
string s;
bool check(string p)
{
    bool ret = true;
    int i = 0, j = p.length()-1;
    while(j>=i)
    {
        if(p[i]!=p[j]) ret = false;
        i++;
        j--;
    }
    return ret;
}
signed main()
{
    cin >> s;
    int n = s.length();
    bool ans = true;
    if(!check(s)) ans=false;
    string t = "";
    for(int i = 0; i < (n-1)/2; i++)
    {
        t+=s[i];
    }
    if(!check(t)) ans = false;
    t = "";
    for(int i = (n+3)/2 - 1; i < n; i++)
    {
        t+=s[i];
    }
    if(!check(t)) ans = false;
    if(ans)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var a = cin.ReadIntArray(N);

            var min = a.Min();
            var max = a.Max();

            WriteLine(max - min);

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13524
A,B,C,X,Y=map(int,input().split())

if A+B<=2*C:
  print(A*X+B*Y)
else:
  if X<Y:
    print(min(2*X*C+B*(Y-X),2*Y*C))
  else:
    print(min(2*Y*C+A*(X-Y),2*X*C))

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

int comp(const void *a, const void *b)
{
  return *(int*)a - *(int*)b;
}

int main()
{
  int i,j,k,n;
  int L[2000];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&L[i]);
  int ans=0;
  qsort(L,n,sizeof(int),comp);
//  for(i=0;i<n;i++) printf("%d ",L[i]);
  for(i=0;i<n-2;i++)
    for(j=i+1;j<n-1;j++)
      for(k=j+1;k<n;k++){
        if(L[k]<L[i]+L[j])
          ans++;
        else
          break;
      }
  printf("%d\n",ans);
  return 0;
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl



signed main() {

	int A, P;
	cin >> A >> P;

	cout << (3 * A+P) / 2 << endl;


	return 0;
}


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

#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define Puts(x) puts(x? "Yes":"No")
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(int n, int m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(int n, int m) {return (n / gcd(n, m) * m);}
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};

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

  int h, w, d;
  cin >> h >> w >> d;
  vt<int> x(h * w + 1), y(h * w + 1);
  rep(i, 0, h) {
    rep(j, 0, w) {
      int a;
      cin >> a;
      x[a] = j;
      y[a] = i;
    }
  }

  vt<int> cost(h * w + 1, 0);
  rep(i, d + 1, h * w + 1) {
    cost[i] = cost[i - d] + abs(x[i] - x[i - d]) + abs(y[i] - y[i - d]);
  }

  int q;
  cin >> q;
  rep(i, 0, q) {
    int l, r;
    cin >> l >> r;
    cout << cost[r] - cost[l] << endl;
  }
} 


Measured memory_bytes: 2176
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007LL;

int main(void) {
    ll b = 0LL;
    multiset<ll> a1, a2;
    int Q;
    cin >> Q;
    ll ans = 0LL;
    for (int i=0;i<Q;i++) {
        int k;
        cin >> k;
        if (k == 1) {
            ll one, two;
            cin >> one >> two;
            if (a1.empty()) {
                a1.insert(one);
                a2.insert(one);
            } else {
                ll l = *(a1.rbegin()), r = *(a2.begin());
                if (one < l) {
                    a2.insert(l);
                    a1.erase(--(a1.end()));
                    a1.insert(one);
                    a1.insert(one);
                    ans = ans + l - one;
                } else if (one > r) {
                    a1.insert(r);
                    a2.erase(a2.begin());
                    a2.insert(one);
                    a2.insert(one);
                    ans = ans - r + one;
                } else {
                    a1.insert(one);
                    a2.insert(one);
                }
            }
            b += two;
        } else {
            cout << *(a1.rbegin()) << " " << ans + b << endl;
        }
    }
 
    return 0;
}


Measured memory_bytes: 18944
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
static int imin = std::numeric_limits<int>::min();
static int imax = std::numeric_limits<int>::max();

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  for(int i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  return os;
}

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  int N;
  int sum = 0;
  std::cin >> N;
  for(int i = 0; i<N; ++i){
    int x;
    std::cin >> x;
    int count = 0;
    while(x % 2 == 0){
      count++;
      x /= 2;
    }
    sum = count + sum;
    // std::cout << " count=" << count << "\n";
  }
  std::cout << sum << std::endl;

}
#endif


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  cin >> ans;
  if (ans % 2 == 0)
    pr(ans);
  else
    pr(ans * 2);

  return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int K, N;
    cin >> K >> N;
    vector<ll> A;
    rep(i, N) {
        ll a;
        cin >> a;
        A.pb(a);
    }

    ll maxLen = 0;
    rep(i, N - 1) {
        ll maxTmp = A[i+1] - A[i];
        maxLen = max(maxLen, maxTmp); 
    }

    ll lastLen = (K - A[N-1]) + A[0];
    maxLen = max(maxLen, lastLen); // 最大距離を一つスキップできる

    cout << (K - maxLen) << endl;
}


Measured memory_bytes: 2420
#include<iostream>
#include<algorithm>
using namespace std;
int last(int t)
{
	if(t%10==0)return 0;
	else return (10-t%10);
}
bool cmp(int x,int y)
{
	return last(x) < last(y);
}
int main() {
 	int a[5];
 	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
 	
 	sort(a,a+5,cmp);
 	cout<<
 	(a[0]+last(a[0]))+
	(a[1]+last(a[1]))+
	(a[2]+last(a[2]))+
	(a[3]+last(a[3]))+
	(a[4])
 	<<endl;
 	
 	
}


Measured memory_bytes: 256
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e2 + 10;
const ll inf = 1e18;

vector<int> v;
set<vector<int>> mp;
ll a[N] = {0};
bool dv[N][N];

void solve(int i, int m);

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

	int m = 1;
	while (4 * m <= n) {
		++m;
	}

	for (int i = n; i >= m; --i) {
		if (a[i] < 0) {
			ll t = 0;
			for (int j = i; j <= n; j += i) {
				t += a[j];
			}

			if (t < 0) {
				for (int j = i; j <= n; j += i) {
					a[j] = 0;
				}
			}
		}
	}

	for (int i = 0; i < N; ++i) {
		for (int j = 1; j < N; ++j) {
			dv[i][j] = (i % j == 0);
		}
	}

	solve(1, m);
	ll ans = -inf;
	for (auto &w : mp) {
		bool dest[N] = {0};
		for (auto &i : w) {
			for (int j = i; j <= n; j += i) {
				dest[j] = true;
			}
		}

		for (int i = n; i >= m; --i) {
			if (!dest[i] and a[i] < 0) {
				ll t = 0;
				for (int j = i; j <= n; j += i) {
					if (!dest[j]) {
						t += a[j];
					}
				}

				if (t < 0) {
					for (int j = i; j <= n; j += i) {
						dest[j] = true;
					}
				}
			}
		}

		ll temp = 0;
		for (int i = 1; i <= n; ++i) {
			if (!dest[i]) {
				temp += a[i];
			}
		}

		ans = max(ans, temp);
	}

	cout << ans << endl;
}

void solve(int i, int m) {
	if (i >= m) {
		mp.insert(v);
		return;
	}

	solve(i + 1, m);
	for (auto &j : v) {
		if (dv[i][j]) {
			return;
		}
	}

	v.pb(i);
	solve(i + 1, m);
	v.pop_back();
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#ifdef LOCAL
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string(string(s)); }
string to_string(bool b) { return to_string(int(b)); }
string to_string(char b) { return "'" + string(1, b) + "'"; }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) {
	string res = "{";
	for (const auto& x : v) res += (res == "{" ? "" : ", ") + to_string(x);
	return res + "}";
}
void debug() { cerr << endl; }
template <typename Head, typename... Tail>
void debug(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug(T...);
}
#define db(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define db(...) 42
#endif
typedef long long ll;
typedef long double ld;
int main() {
	int q;
	scanf("%d", &q);
	while (q--) {
		int n, m, a, b;
		scanf("%d%d%d%d", &n, &m, &a, &b);
		printf("%lld\n", floor_sum(n, m, a, b));
	}
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
using  ll = long long;

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

	vector<vector<vector<ll>>> dp(N+1, vector<vector<ll>>(2, vector<ll>(3, -1LL<<60)));

	// dp[i][j][k]: i番目, i要素目を取らないならj = 1, k: これまで連続で選ばなかった箇所の個数
	dp[0][1][0] = 0;
	for(int i=0;i<N;i++) {
		// 取らない
		for(int k=0;k<2;k++)
			dp[i+1][1][k+1] = max(dp[i+1][1][k+1], dp[i][1][k]);
		for(int k=0;k<3;k++)
			dp[i+1][1][k] = max(dp[i+1][1][k], dp[i][0][k]);

		// 取る
		for(int k=0;k<3;k++)
			dp[i+1][0][k] = max(dp[i+1][0][k], dp[i][1][k] + A[i]);
	}
	if(N % 2 == 0) cout << max(dp[N][0][1], dp[N][1][0]) << endl;
	else cout << max(dp[N][0][2], dp[N][1][1]) << endl;
}

Measured memory_bytes: 34412
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ll long long
#define cl(x) memset(x,0,sizeof(x))
const int N=1e5+10;
const int mod=1e7+9;
const int maxn=0x3f3f3f3f;
const int minn=0xc0c0c0c0;
const int inf=99999999;
using namespace std;
int dp[N],v[N],w[N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n,m,i,j;
	cin>>n>>m;
	for(i=1;i<=m;i++)
		cin>>v[i]>>w[i];
	memset(dp,maxn,sizeof(dp));
	dp[0]=0;
	for(i=1;i<=m;i++)
		for(j=1;j<=2e4;j++)
			if(j-v[i]>=0)
				dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
	int ans=maxn;
	for(i=n;i<=2e4;i++)
		ans=min(ans,dp[i]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
N=int(input())

A=list(map(int,input().split()))
#print(A)

dic={}
for i in range(len(A)):
    if i-A[i] in dic:
        dic[i-A[i]]+=1
    else:
        dic[i-A[i]]=1

ans=0
for i in range(len(A)):
    temp=i+A[i]
    if temp in dic:
        ans+=dic[temp]
        #print(A[i],ans)
    if i-A[i]==i+A[i]:
        ans-=1
print(ans)

Measured memory_bytes: 40532
#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<math.h>
using namespace std;
int main(){
    double  x,h,s;
    while(1){
        cin>>x>>h;
        if(x==0 && h==0){
            break;
        }
        double takasa;
        takasa=(x/2)*(x/2)+h*h;
        takasa=sqrt(takasa);
        s=(x*x)+(x*takasa/2)*4;
        printf("%.6lf",s);
        cout<<endl;
    }
    return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    int dd = n / (d * 2 + 1);
    int rr = n % (d * 2 + 1);

    if (0 < rr) dd += 1;

    cout << dd << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>
#include <cstring>
#include <stack>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/*********** TEMPLATE ENDS HERE *************/

#define int long long

main()
{
	IOS
	
	string s;
	cin >> s;
	
	s = '1' + s;
	
	int n = s.size() - 1;
	int last = 1;
	int nr = 0;
	
	for(int i = 1; i <= n; i++)
		if(s[i] == 'W')
		{
			nr += i - last;
			last++;
		}
	
	cout << nr;
}

Measured memory_bytes: 788
#include<stdio.h>
int main(void)
{
    int a,b;
	scanf("%d %d",&a,&b);
	if(a<b) {
	    printf("a < b\n");
	}
	else if(a>b)    {
        printf("a > b\n");
	}
	else {
	    printf("a == b\n");
	}
	return 0;
}


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

int P(int x){
    int a,b,c,px;
    a=x/1000;
    b=a%10;
    a/=10;
    c=a%10;
    px=(x/100)*100+10*b+c;
    return px;
}

int main() {
  int A,B;
  cin>>A>>B;
  int sum=B/100-A/100;
  if(A<=P(A))sum++;
  if(B<P(B))sum--;
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define PI acos(-1.0)
const long long MAX=200005;
typedef long long ll;
const int INF=0x3f3f3f3f;
//int d[8][2]={-1,0,0,-1,0,1,1,0,1,1,-1,-1,-1,1,1,-1};
struct node
{
    int x,y,k;
}a[100005];
double b[50]={0};
int nmp(node i,node j)
{
    return i.x<j.x;
}
int main()
{
    int n,c,sum=0;
    scanf("%d%d",&n,&c);
    for(int i=0;i<n;i++)
        scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].k);
    sort(a,a+n,nmp);
    b[a[0].k]=a[0].y;
    for(int i=1;i<n;i++)
    {
        int g=0;
        if(a[i].x>=b[a[i].k]&&b[a[i].k]!=0)
        {
            b[a[i].k]=a[i].y;
            continue;
        }
        else
        {
            for(int j=1;j<=c;j++)
            {
                if(a[i].x>=b[j]+0.5&&b[j]!=0)
                {
                    b[a[i].k]=a[i].y;
                    b[j]=0;
                    g=1;
                    break;
                }
            }
            if(g==0)
                b[a[i].k]=a[i].y;
        }
    }
    for(int i=1;i<=c;i++)
        if(b[i]>0) sum++;
    printf("%d\n",sum);
    return 0;
}


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


#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define lmax1 9223372036854775807
#define max1 2147483647
#define lmin1 -9223372036854775808
#define pi 3.141592653589793116
#define mod 1e9+7

int main() {
    off;
        int n,m;
    long long sum=0,x,y;
    cin>>n>>m;
    vector <pair <long long int ,long long int > > v;
    for(int i=0;i<n;i++)
    {   //int x,y;
        cin>>x>>y;
        v.push_back({x,y});
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++)
    {   x=v[i].first,y=v[i].second;
        if(m>y)
        {   sum+=(x*y);
            m-=y;
        }
        else
        {   sum+=(x*m);
            m=0;
            break;
        }
    }
    cout<<sum<<'\n';
      return 0;
    }



Measured memory_bytes: 2420
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int h = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());

            double rect_l = m * 360.0 / 60.0; //長針
            double rect_s = h * 30.0 + m * 0.5; //短針
            double diff = rect_s - rect_l;
            if (diff > 180) diff = 360 - diff;
            double ans = Math.sqrt((a * a) + (b * b) - 2 * a * b * Math.cos(Math.toRadians(diff)));
            // 出力
            out.printf("%.13f\n", ans);

        }

    }
}



Measured memory_bytes: 36040
from math import gcd
from collections import defaultdict

N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]
MOD = 10**9 + 7

d = defaultdict(int)
cnt_00 = 0
cnt_0b = 0
cnt_a0 = 0
for a,b in AB:
    if a == b == 0:
        cnt_00 += 1
    elif a == 0:
        cnt_a0 += 1
    elif b == 0:
        cnt_0b += 1
    else:
        num_gcd = gcd(a,b)
        grad = 1 if a * b > 0 else -1
        a //= num_gcd
        b //= num_gcd
        d[(grad, abs(a), abs(b))] += 1



ans = 1
for k in d.keys():
    if d[k] == 0:
        continue
    
    grad, a, b = k[0], k[1], k[2]
    if (-grad, b, a) in d:
        
        # 傾き a/bのものを一つ以上選ぶ場合（-b/aは選ばない） + -b/aから一つ以上選ぶ場合（a/bは選ばない） + どちらからも選ばない場合
        ans *= (pow(2, d[(grad, a, b)], MOD)-1) + (pow(2, d[(-grad, b, a)], MOD)-1) + 1
        ans %= MOD
        d[(grad, a, b)] = 0
        d[(-grad, b, a)] = 0
    else:
        # a/bから0個以上選ぶ場合
        ans *= pow(2, d[(grad, a, b)], MOD)
        ans %= MOD
        d[(grad, a, b)] = 0

# a,bの一方のみ0の場合 + どちらからも選ばない場合
ans *= (pow(2, cnt_a0, MOD)-1) + (pow(2, cnt_0b, MOD)-1) + 1
ans %= MOD

# 0,0のみを１つだけ入れる場合
ans += cnt_00
# なにも選ばない場合を除く
ans -= 1

ans %= MOD

print(ans)

Measured memory_bytes: 160972
import bisect
n = int(input())
l = list(map(int, input().split()))
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        a = l[i]+l[j]
        index = bisect.bisect_left(l, a)
        count += index - j -1
print(count)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int mxd;
int vv = 0;
int dfs(int a, int p, int d, vector<vector<int> > &ed) {
	if (mxd < d) {
		mxd = d;
		vv = a;
	}
	for (int i = 0; i < ed[a].size(); i++) {
		if (ed[a][i] != p) {
			dfs(ed[a][i], a, d + 1, ed);
		}
	}
}
vector<int> path;
int dfs2(int a, int p, int b, vector<vector<int> > &ed) {
	path.push_back(a);
	if (path.back() == b)return 0;
	for (int i = 0; i < ed[a].size(); i++) {
		if (path.back() == b)return 0;
		if (ed[a][i] != p) {
			dfs2(ed[a][i], a, b, ed);
		}
	}
	if (path.back() == b)return 0;
	path.pop_back();
}
vector<int> num;
int N;
int dfs3(int a, int p, int d, vector<vector<int> > &ed) {
	if (p == -1) {
		num[d] = max(num[d], (int)ed[a].size());
	}
	else {
		num[d] = max(num[d], (int)ed[a].size() - 1);
	}
	/*if (d != 0) {
		num[d] = max(num[d], (int)ed[a].size());
	}
	if (d == 1) {
		num[0]++;
	}*/
	for (int i = 0; i < ed[a].size(); i++) {
		if (ed[a][i] != p) {
			dfs3(ed[a][i], a, d + 1, ed);
		}
	}
}
int solve(int a, int b, vector<vector<int> > &ed) {
	num.clear();
	
	num.resize(N + 1, 0);
	//cerr << "solve" << endl;
	//cerr << a << " " << b << endl;
	if (b != -1) {
		//cerr << "Ok" << endl;
		dfs3(a, b, 0, ed);
		dfs3(b, a, 0, ed);
	}
	else {
		dfs3(a, -1, 0, ed);
	}
	
	/*for (int i = 0; i < num.size(); i++) {
		if (num[i] == 0)break;
		cerr << num[i] << " ";
	}
	cerr << endl;*/

	int res;
	if (b == -1) {
		res = 1;
	}
	else {
		res = 2;
	}
	for (int i = 0; i < num.size(); i++) {
		if (num[i] == 0)break;
		res *= num[i];
	}
	return res;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	vector<int> A(N);
	vector<vector<int> > ed(N);
	int res1;
	int res2;
	int a, b;
	for (int i = 0; i < N - 1; i++) {
		cin >> a >> b;
		a--;
		b--;
		ed[a].push_back(b);
		ed[b].push_back(a);
	}
	mxd = -1;
	dfs(0, -1, 0, ed);
	a = vv;
	mxd = -1;
	dfs(a, -1, 0, ed);
	res1 = (mxd + 2) / 2;
	//cerr << "mxd=" << mxd + 1 << endl;
	b = vv;
	dfs2(a, -1, b, ed);
	if (path.size() % 2 == 0) {
		res2 = solve(path[path.size() / 2], path[(path.size() / 2) - 1], ed);
	}
	else {
		//cerr << path[path.size() / 2] << endl;
		res2 = solve(path[path.size() / 2], -1, ed);
		//cerr << res2 << endl;
		for (int i = 0; i < ed[path[path.size() / 2]].size(); i++) {
			res2 = min(res2, solve(path[path.size() / 2], ed[path[path.size() / 2]][i], ed));
		}
	}
	cout << res1 << " " << res2 << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String X =sc.next();
        String Y =sc.next();
        int numX;
        int numY;
        
        if(X.equals("A")){
            numX=1;
        }else if(X.equals("B")){
            numX=2;
        }else if(X.equals("C")){
            numX=3;
        }else if(X.equals("D")){
            numX=4;
        }else if(X.equals("E")){
            numX=5;
        }else if(X.equals("F")){
            numX=6;
        }else{
            numX=0;
        }
        
        if(Y.equals("A")){
            numY=1;
        }else if(Y.equals("B")){
            numY=2;
        }else if(Y.equals("C")){
            numY=3;
        }else if(Y.equals("D")){
            numY=4;
        }else if(Y.equals("E")){
            numY=5;
        }else if(Y.equals("F")){
            numY=6;
        }else{
            numY=0;
            
        }
        
        if(numX<numY){
            System.out.println("<");
        }else if(numX>numY){
            System.out.println(">");
        }else{
            System.out.println("=");
        }
        
        
   }
}


Measured memory_bytes: 35508
#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast")
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
inline int read() {
    int s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch>'9') { if (ch == '-')w = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
    return s * w;
}
#define f(i, l, r) for (int i = l; i <= r; ++i)
#define rf(i, r, l) for (int i = r; i >= l; --i)
#define all(x) (x).begin(), (x).end()
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))
#define mod1(x) ((x >= mod) && (x -= mod))
#define mod2(x) ((x < 0) && (x += mod))

const int inf = 2e9 + 7;
//const ll INF = INT64_MAX;
double eps = 1e-6;
const int mod = 1e9+7;
const int N = 2e5 + 10;
const double pi = acos(-1.0);
ll power(ll a, ll b) { ll res = 1; while (b) { if (b & 1)res = res * a % mod; a = a * a % mod; b >>= 1; }return res; }
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
void add(ll& a, ll b) { a += b; mod1(a); mod2(a); }
/*int len, C[N], clen;
int id(int v) { return lower_bound(C + 1, C + len, v) - C; }
void initC() { sort(C + 1, C + clen); len = unique(C + 1, C + 1 + clen) - C - 1; }*/

vector<int> g[N];
int vis[N];
int sum;
void dfs(int u) {
    sum++; vis[u] = 1;
    for (auto v : g[u])if (!vis[v]) {
        dfs(v);
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef local
    freopen("in.txt", "r", stdin);
    int start = clock();
#endif
    int n, m; cin >> n >> m;
    f(i, 1, m) {
        int u, v; cin >> u >> v; g[u].push_back(v); g[v].push_back(u);
    }
    int res = 0;
    f(i, 1, n)if (!vis[i]) {
        sum = 0;
        dfs(i); res = max(sum, res);
    }
    cout << res;

#ifdef local
    int end = clock();
    //cout << '\n' << end - start << "ms";
#endif* /
}

Measured memory_bytes: 21620
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int x;
    cin >> x;
    for(int i = 1; i <= 360; i++){
        if(x * i % 360 == 0){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
 
 
int main(int argc, char** argv){
	int x,hap{0};
	cin >> x;
	hap += ((x/500)*1000);
	x = x%500;
	hap += (x/5)*5;
	cout << hap;
	return 0;
}

Measured memory_bytes: 256