akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n;cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];

    rep(i,n){
        sort(s[i].begin(), s[i].end());
    }
    sort(s.begin(), s.end());
    ll ans = 0;
    ll tmp = 1;
    rep(i,n-1){
        if(s[i]==s[i+1]){
            ++tmp;
        }else{
            ans += (tmp - 1) * tmp / 2;
            tmp = 1;
        }
        cerr << tmp << endl;
    }
    ans += (tmp - 1) * tmp / 2;
    cout << ans << endl;
}

Measured memory_bytes: 7296
N,A,B,C=map(int,input().split(' '))
S = [input() for i in range(N)]
ans = []
if A+B+C==0:
    print('No')
else:
    d = {"A":A,"B":B,"C":C}
    for n,i in enumerate(S):
        l,r=list(i)
        L,R=d[l],d[r]
        if L==R==0:
            print('No')
            exit()
        elif L==0:
            ans.append(l)
            d[l] +=1
            d[r] -=1
        elif R==0:
            d[l] -=1
            d[r] +=1
            ans.append(r)
        elif L==R==1 and n != N-1 and i != S[n+1]:
            if l in S[n+1]:
                d[l] +=1
                d[r] -=1
                ans.append(l)
            else:
                d[l] -=1
                d[r] +=1
                ans.append(r)
        else:
            if L>=R:
                d[l] -=1
                d[r] +=1
                ans.append(r)
            else:
                d[l] +=1
                d[r] -=1
                ans.append(l)
    print('Yes')
    for i in ans:
        print(i)

Measured memory_bytes: 16992
#include <stdio.h>
#define N 20
int main(void)
{
  char a[N]={0},b[N]={0},c[N]={0};
  int i,flag=1,flag2=1;
  scanf("%s%s%s",a,b,c);
  for(i=0;;i++)
  {
    if(a[i]==0)
    {
      if(a[i-1]!=b[0])
      {
        flag=0;
      }
      break;
    }
  }
  for(i=0;;i++)
  {
    if(b[i]==0)
    {
      if(b[i-1]!=c[0])
      {
        flag2=0;
      }
      break;
    }
  }
  if(flag==1 && flag2==1)
  {
    printf("YES\n");
  }
  else
  {
    printf("NO\n");
  }
  return 0;
}


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

int main(){
    double A,B,T,ans;
    cin >> A >> B >> T;
    ans = 0;
    
    while(T + 0.5 >= A){
        ans += B;
        T -= A;
    }
    cout << ans << "\n";
    return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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 main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    vector<ll> a(n),b(n),c(n);
    vector<set<ll>> nbs(n,set<ll>());
    rep(i,n-1){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
        nbs[a[i]].insert(b[i]);
        nbs[b[i]].insert(a[i]);
    }
    ll vals[n]={};
    ll res=0;
    rep(i,n){
        cin>>c[i];
    }
    sort(begin(c),end(c),greater<ll>());
    repr(i,1,n){
        res += c[i];
    }
    cout << res << endl; 
    queue<ll> que;
    que.push(0);
    bool chk[n]={};
    ll cnt=0;
    while(!que.empty()){
        ll tmp = que.front();
        que.pop();
        vals[tmp]=c[cnt];
        chk[tmp]=true;
        for(auto x:nbs[tmp]){
            if(!chk[x]){
                que.push(x);
            }
        }
        cnt++;
    }
    rep(i,n){
        cout << vals[i] << endl;
    }
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  if (s.size() > n) {
    for (int i = 0; i < n; i++) {
      cout << s[i];
    }
    cout << "...\n";
  } else {
    cout << s << '\n';
  }
  return 0;
}

Measured memory_bytes: 3620
from heapq import heappush, heappop
from collections import defaultdict as dd
N, M = map(int, input().split())
arrs = dd(list)
for _ in range(N):
  a, b = map(int, input().split())
  arrs[a].append(-b)
q = []
ans = 0
for a in range(1, M+1):
  for b in arrs[a]:
    heappush(q, b)
  if len(q):
    ans -= heappop(q)
print(ans)

Measured memory_bytes: 27652
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string s = Console.ReadLine();
		if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) Console.WriteLine("Bad");
    else Console.WriteLine("Good");
	}
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    long long k;
    cin>>k;
    long long K=-k;
    long long a[n],f[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        K+=a[i];
    }
    for(int i=0;i<n;i++)cin>>f[i];
    if(K<=0){
        cout<<"0"<<endl;
        return 0;
    }
    sort(a,a+n);
    sort(f,f+n,greater<long long>());
    long long l=0,r=1000000000000000000;
    while(r-l>1){
        long long mid=(l+r)/2;
        long long x=0;
        for(int i=0;i<n;i++)if(a[i]>mid/f[i])x+=a[i]-mid/f[i];
        if(x>k)l=mid;
        else r=mid;
    }
    cout<<r<<endl;
    return 0;
}

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

	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		int x=input.nextInt();
		int flag=0;
		while(x!=0)
		{
			int rem=x%10;
			if(rem==7)
			{
				flag=1;
				break;
			}
			x=x/10;
				
		}
		if(flag==1)
			System.out.println("Yes");
		else
			System.out.println("No");
		input.close();
	}
	

}


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

using namespace std;
const long long MOD = 1000000007;

int A[100005];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		A[i] = 0;
	}
	int h = -1;
	for (int i = 0; i < n; ++i) {
		int aux;
		scanf("%d", &aux);
		A[aux] += 1;
		if (aux > h) h = aux;
	}
	if (A[0] >= 1 && A[1] >= 1) {
		printf("0\n");
	} else {
		int j;
		if (h % 2 == 0) j = 0;
		else j = 1;
		long long sum = 1;
		for ( j; j <= h; j += 2) {
			if (A[j] != 2) {
				if ((j == 0) && (h % 2 == 0)){
					sum = (sum * 1) % MOD;
				} else {
					sum = 0;
					break;
				}
			} else {
				sum = (sum * 2) % MOD;
			}
		}
		printf("%lld\n", sum);
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define endl "\n"

using namespace std;

void dout() {
    cerr << endl;
}

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}


typedef pair <int, int> pii;
int n;
db res;

void cleanup() {
    return;
}

void solve() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        res += (db)1 / x;
    }
    res = (db)1 / res;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
    int tc = 1;
//    cin >> tc;
    while (tc--) {
        solve();
        cleanup();
    }
}


Measured memory_bytes: 256
//
//  main.cpp
//  A
//
//  Created by Hashizo on 2019/09/28.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {

	double a;
	ll n;
	cin >> n;

	ll siin;
	if ((n % 2) == 0){
		siin = (n / 2);
	}
	else {
		siin = (n / 2) + 1;
	}
	a = (double)((double)siin / (double)n);

	
	printf("%f\n", a);
    return 0;
}


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

#define pi acos(-1.0)

int main(){
    double x;
    cin >> x;
    double ans=pi*x*x;
    double ans2= 2*pi*x;
    printf("%.6lf %.6lf\n",ans,ans2);

    return 0;
}



Measured memory_bytes: 3300
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String line = sc.nextLine();
      String str[] = line.split(" ");
      String a = str[0].substring(0,1);
      String b = str[1].substring(0,1);
      String c = str[2].substring(0,1);
      System.out.println(a+b+c);
	}
}


Measured memory_bytes: 21844
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1LL<<60
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

struct edge{
  ll from, to, cost;
};

edge e[2000];
ll d[2000];

bool check(int n, int m){
  REP(i, 1000) d[i] = 0;
  bool k[n] = { };
  REP(i, n){
    REP(j, m){
      edge ec = e[j];
      if(d[ec.to] > d[ec.from] + ec.cost){
        d[ec.to] = d[ec.from] + ec.cost;
        if(i == n-1) k[ec.to] = true;
      }
    }
  }
  return k[n-1];
}

void dis(int n, int m){
  REP(i, 1000) d[i] = INF;
  d[0] = 0;
  REP(i, n){
    REP(j, m){
      edge ec = e[j];
      if(d[ec.from] != INF && d[ec.to] > d[ec.from] + ec.cost){
        d[ec.to] = d[ec.from] + ec.cost;
      }
    }
  }
}

int main(){
  int n, m;
  cin >> n >> m;
  REP(i, m){
    ll a, b, c;
    cin >> a >> b >> c;
    e[i] = {a-1, b-1, (-1)*c};
  }
  if(check(n,m)) cout << "inf" << endl;
  else{
    dis(n, m);
    cout << (-1)*d[n-1] << endl;
  }
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
const int INF=1e9;
int D,N;
int a[105],e[105],r[105];
int dp[105][105];
int ans=INF;
template<typename A,size_t N,typename T>
void Fill(A (&array)[N],const T &val)
{
  std::fill( (T*)array,(T*)(array+N),val );
}

int main()
{
  while(cin >> D >> N && D)
    {
      ans=INF;
      Fill(dp,INF);
      dp[D][0]=0;
      for (int i = 0; i < N; ++i)
	{
	  cin >> a[i] >> e[i] >> r[i];
	}
      for (int i = D; i >=0; i--)
	{
	  for (int j = 0; j <= 100; ++j)
	    {
	      for (int k = 0; k < N; ++k)
		{
		  if(r[k]<=j)
		    {
		      int nexthp=max(i-a[k],0);
		      int nextexp=min(100,j+e[k]);
		      dp[nexthp][nextexp]=min(dp[nexthp][nextexp],dp[i][j]+1);
		    }
		}
	    }
	}
      for (int i = 0; i <= 100; ++i)
	{
	  ans=min(ans,dp[0][i]);
	}
      if(ans==INF)
	{
	  cout << "NA" << endl;
	}
      else
	{
	  cout << ans << endl;
	}
    }
  return 0;
}



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

int main(){
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e;
    cin >> k;
    if(e - a <= k){
        cout << "Yay!" << endl;
    }
    else{
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int n, m, now;
int ans[55];

int main(){
 	scanf("%d %d",&n,&m);
 	for(int i = 1; i <= 2*m ; i++){
		scanf("%d",&now);
		ans[now]++;
	}

	for(int i = 1 ; i <= n ; i++){
		printf("%d",ans[i]);
		if(i != n)printf("\n");
	}
}


Measured memory_bytes: 128
str = raw_input()
q = int(raw_input())

for i in range(q):
	do_list = raw_input().split()
	a = int(do_list[1])
	b = int(do_list[2])
	if do_list[0] == "print":
		print(str[a:(b+1)])
	elif do_list[0] == "reverse":
		part = str[a:(b+1)]
		rev = ""
		for j in range(len(part)):
			rev += part[-j-1]
		if a == 0:
			str = rev + str[(b+1):]
		elif b == len(str)-1:
			str = str[:a] + rev
		else:
			str = str[:a] + rev + str[(b+1):]
	else:
		p = do_list[3]
		if a == 0:
			str = p + str[(b+1):]
		elif b == len(str)-1:
			str = str[:a] + p
		else:
			str = str[:a] + p + str[(b+1):]

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

char s[200001];
int main() {
	memset(s, '\0', 200001);
	scanf("%s", s);
	int flag = 0;
	int start, end;
	for(int i = 0; i < 200000; i++) {
		if(s[i] == '\0') {
			break;
		}
		if(flag) {
			if(s[i] == 'Z') {
				end = i;
			}
		}
		else {
			if(s[i] == 'A') {
				start = i;
				flag = 1;
			}
		}
	}
	// printf("%d %d\n", start, end);
	printf("%d\n", end- start + 1);
	return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

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

static const double eps = 10e-9;

int main(){
	int n;

	while(~scanf("%d",&n)){
		if(n==0) break;

		vector<int> input;
		for(int i=1;i<=n-1;i++){
			input.push_back((i*i)%n);
		}

		int* table = new int[(n-1)/2+1]();

		sort(input.begin(),input.end());

		vector<int>::iterator end_it = unique(input.begin(),input.end());
		input.erase(end_it,input.end());

		for(int i=0;i<input.size();i++){
			for(int j=0;j<input.size();j++){
				if(i==j) continue;
				int calc = input[i]-input[j] ;
				if(calc < 0) calc+=n;
				if(calc > (n-1)/2) calc = n - calc;

				table[calc]++;
			}
		}

		for(int i=1;i<(n-1)/2+1;i++){
			printf("%d\n",table[i]);
		}

		delete[] table;
	}
}

Measured memory_bytes: 3196
def f(a,x,y):
    a[y][x]='0'
    for dx,dy in [[-3,0],[-2,0],[-1,0],[1,0],[2,0],[3,0],[0,-3],[0,-2],[0,-1],[0,1],[0,2],[0,3]]:
        if 0<=x+dx<8 and 0<=y+dy<8 and a[y+dy][x+dx]=='1':f(a,x+dx,y+dy)
    return a

for i in range(int(input())):
    print('Data %d:'%(i+1));input()
    [print(*x,sep='')for x in f([list(input()) for _ in [0]*8],int(input())-1,int(input())-1)]

Measured memory_bytes: 7660
import java.util.Scanner;
class Main{
  public static void main(String args[]){
    Scanner scan=new Scanner(System.in);
    String str=scan.next();
    int y=Integer.parseInt(str.substring(0,4));
    int m=Integer.parseInt(str.substring(5,7));
    int d=Integer.parseInt(str.substring(8,10));
    if((y>2019)||((y==2019)&&(m>=5))){
      System.out.println("TBD");
    }else{
      System.out.println("Heisei");
    }
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    string s, t;
    cin >> s >> t;
    ll count = 0;
    ll len = 0;
    bool ok = false;
    ll c = 0;
    if(s.length()>=t.length()){
        for(ll i = 0; i <= s.length()-t.length(); i++){
            //cout << i << endl;
            for(ll j = 0; j < t.length(); j++){
                if(s[i+j]!=t[j] && s[i+j]!='?') break;
                if(j==t.length()-1) {
                    ok = true;
                    c = i;
                }
            }
        }
    }
    string ans;
    if(ok==true){
        for(ll i = 0; i < c; i++) {
            if(s[i]!='?')ans += s[i];
            else ans+= 'a';

        }
        ans += t;
        for(ll i = c+t.length(); i < s.length(); i++){
            if(s[i]!='?')ans += s[i];
            else ans+= 'a';
        }
        cout << ans << endl;
    }
    else if(ok==false)
        cout << "UNRESTORABLE" << endl;
    return 0;
}


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

int main()
{
	int a,b;
	cin>>a>>b;
	int h=a+b;
	if(a%3==0) cout<<"Possible";
	else if(b%3==0) cout<<"Possible";
	else if(h%3==0) cout<<"Possible";
	else cout<<"Impossible";
	return 0;
 } //偷个懒
 

Measured memory_bytes: 256
# coding: utf-8


def solve(*args: str) -> str:
    n, k = map(int, args[0].split())
    P = list(map(int, args[1].split()))

    S = [0]*(n+1)
    for i, p in enumerate(P):
        S[i+1] += S[i] + P[i]

    ret = 0
    for i in range(k, n+1):
        ret = max(ret, (S[i]-S[i-k]+k)/2)

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 25548
#include <bits/stdc++.h>
using namespace std;
const int N = 110 , mz = 1e9+7;
char s[N];

int main(){
    scanf("%s",s);putchar(s[0]);
    scanf("%s",s);putchar(s[1]);
    scanf("%s",s);putchar(s[2]);
    puts("");
    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

struct UnionFind {
  vector<ll> data;

  UnionFind(ll n){
    data.resize(n+1);
    fill(data.begin(), data.end(), -1);
  }

  ll root(ll x){
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }

  void unite(ll x, ll y){
    ll rx=root(x);
    ll ry=root(y);

    if(rx!=ry){
      if(data[ry] < data[rx])swap(rx, ry);

      data[rx]+=data[ry];
      data[ry]=rx;
    }
  }

  bool same(ll x, ll y){
    return root(x)==root(y);
  }

  ll size(ll x){
    return -data[root(x)];
  }
};

int main(){
  ll n,m,k;cin>>n>>m>>k;
  vector<pll>ab(m);
  rep(i, m)cin>>ab[i].first>>ab[i].second;
  vector<pll>cd(k);
  rep(i, k)cin>>cd[i].first>>cd[i].second;

  UnionFind f_uf(n), b_uf(n);
  map<ll, ll> friends_count, block_count;

  for(auto p:ab){
    f_uf.unite(p.first, p.second);
    friends_count[p.first]++;
    friends_count[p.second]++;
  }

  for(auto p: cd)if(f_uf.same(p.first, p.second)){
    b_uf.unite(p.first, p.second);
    block_count[p.first]++;
    block_count[p.second]++;
  }

  rep1(i, n){
    cout<<f_uf.size(i) - friends_count[i] - block_count[i] - 1<<' ';
//    cout<<f_uf.size(i) - friends_count[i] - b_uf.size(i)<<' ';
//    cout<<f_uf.size(i) <<' '<< friends_count[i] <<' '<< b_uf.size(i)<<'|'<<block_count[i]<<endl;
  }

//rep1(i, n)cout<<f_uf.data[i]<<' ';cout<<endl;
//rep1(i, n)cout<<b_uf.data[i]<<' ';cout<<endl;

  return 0;
}



Measured memory_bytes: 18176
H,W=map(int,input().split())
c=[list(map(int,input().split())) for i in range(10)]
Gd=[]
for i in range(H):
  Gd=Gd+list(map(int,input().split()))
dp = [[[10000]*10 for i in range(10)] for t in range(10)]
dp[0] = c[:]
for t in range(1,10):
  for i in range(10):
    for j in range(10):
      for k in range(10):
        dp[t][i][j]=min(dp[t][i][j],dp[t-1][i][k]+c[k][j])
ret = 0
for i in Gd:
  if i>=0:
    ret+=dp[-1][i][1]
print(ret)

Measured memory_bytes: 3980
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  double
#define pii pair<int,int>
#define pip pair<int,pii>
#define ppi pair<pii,int> 
#define ppp pair<pii,pii>
#define pb push_back
#define N 200003
#define inf (ll)1e9+11
#define warmup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7;

signed main()
{
    warmup
    
    ld a,b;
    cin>>a>>b;
    int i=a/0.08;
    for(;i<=N;i++)
    {
        if((int)(i*0.08)==a and (int)(i*0.1)==b)
            return cout<<i, 0;
        else if((int)(i*0.1)>b)
            return cout<<-1, 0;
    }   
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 3e6 + 17;

struct pt
{
	int x, y;
	pt() { }
};

struct fenwick
{
	int n;
	unordered_map<int, int> F;

	fenwick()
	{
		n = inf;
		F.rehash(3000000);
		F.max_load_factor(0.25);
	}

	void upd(int i, int x)
	{
		for (; i < n; i |= i + 1)
			F[i] = max(F[i], x);
	}

	int get(int i)
	{
		int res = 0;

		for (; i >= 0; i &= i + 1, --i)
			res = max(res, F[i]);

		return res;
	}
};

int n;
pt s, f;
pt p[maxn];

bool read()
{
	if (scanf("%d %d %d %d %d", &s.x, &s.y, &f.x, &f.y, &n) != 5)
		return false;

	forn (i, n)
		scanf("%d %d", &p[i].x, &p[i].y);

	return true;
}

bool cmp(pt a, pt b) { return make_pair(a.x, a.y) < make_pair(b.x, b.y); }

void solve()
{
	if (s.x > f.x)
		swap(s, f);

	if (s.y > f.y)
	{
		f.y = 2 * s.y - f.y;

		forn (i, n)
			p[i].y = 2 * s.y - p[i].y;
	}

	vector<pt> pp;

	forn (i, n)
		if (s.x <= p[i].x && p[i].x <= f.x && s.y <= p[i].y && p[i].y <= f.y)
			pp.push_back(p[i]);

	sort(pp.begin(), pp.end(), cmp);
	fenwick dp;

	forn (i, size(pp))
		dp.upd(pp[i].y, dp.get(pp[i].y) + 1);

	int lis = dp.get(inf);
	long double ans = 0;

	if (lis != min(f.y - s.y, f.x - s.x) + 1)
		ans = 100.0 * (f.y - s.y + f.x - s.x) - 20.0 * lis + 5 * M_PI * lis;
	else
		ans = 100.0 * (f.y - s.y + f.x - s.x) - 20.0 * lis + 5 * M_PI * (lis - 1) + 10 * M_PI;

	printf("%.15f\n", (double) ans);
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


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

int main() {
  int ans = 0;
  string s;
  cin >> s;
  if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R') ans++;
  for(int i = 1; i < 3; i++) {
    if(s[i] == 'S') {
      continue;
    }
    else {
      if(s[i-1] == 'R') {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
import copy
h,w,k=map(int,input().split())
c=[None]*h
for i in range(h):
  c[i]=list(input())
ans=0
for i1 in range(2**h):
  for i2 in range(2**w):
    tmp=copy.deepcopy(c)
    b=0
    for j1 in range(h):
      for j2 in range(w):
      	if not ((i1 >> j1) & 1) and not ((i2 >> j2) & 1):
          if c[j1][j2]=='#':
            b+=1
    if b==k:
      ans+=1
print(ans)

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

int main() {
    int a, b, m; cin >> a >> b >> m;
    vector<int> a_s(a);
    vector<int> b_s(b);
    vector<int> x(m), y(m), c(m);
    rep(i, a) cin >> a_s[i];
    rep(i, b) cin >> b_s[i];
    rep(i, m) cin >> x[i] >> y[i] >> c[i];
    int ans =  *min_element(a_s.begin(), a_s.end()) + *min_element(b_s.begin(), b_s.end());

    rep(i, m) {
        ans = min(ans, a_s[x[i]-1]+b_s[y[i]-1] - c[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define MOD 10000

char A[510], B[510];
int M;
int memo[510][10][3][3][500];

int f(char *x, int i, int d, int c, int u, int r) {
  if (memo[i][c][d][u][r] >= 0) return memo[i][c][d][u][r];
  if (i == strlen(x)) {
    int ret = 0;
    if (u != 2) ret = r == 0;
    return memo[i][c][d][u][r] = ret;
  }
  int ret = r == 0;
  for (int k=0; k<10; k++) {
    int nu = u;
    if (c == k) continue;
    if (d == 0 && c < k) continue;
    if (d == 1 && c > k) continue;
    int nd;
    if (d == 2) nd = c > k;
    else        nd = 1-d;
    if (u == 1 && k > (int)(x[i] - '0')) nu = 2;
    if (u == 1 && k < (int)(x[i] - '0')) nu = 0;
    ret += f(x, i+1, nd, k, nu, (k + r*10) % M);
    ret %= MOD;
  }
  return memo[i][c][d][u][r] = ret;
}

int f(char *x) {
  int ret = 0;
  for (int i=0; i<510; i++) {
    for (int j=0; j<10; j++) {
      for (int d=0; d<3; d++) {
        for (int k=0; k<3; k++) {
          for (int l=0; l<500; l++) {
            memo[i][j][d][k][l] = -1;
          }
        }
      }
    }
  }
  for (int i=1; i<10; i++) {
    char c = (int)(x[0] - '0');
    ret += f(x, 1, 2, i, i > c ? 2 : (i == c ? 1 : 0), i % M);
    ret %= MOD;
  }
  return ret;
}

void decrement(char *x) {
  int L = strlen(x);
  int h = L - 1;
  while (x[h] == '0') {
    x[h] = '9';
    h -= 1;
  }
  x[h] = (char)(x[h] - 1);
  if (L > 1 && h == 0) {
    for (int i=0; i<L-1; i++) x[i] = x[i+1];
    x[L-1] = '\0';
  }
}

int main() {
  cin >> A >> B >> M;
  decrement(A);
  cout << (f(B) - f(A) + MOD) % MOD << "\n";
  return 0;
}

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


int main() {
  long n;
  cin >> n;
  vector<long>a(n);
  rep(i,n){
    cin>>a.at(i);
    a.at(i)-=i+1;
  }
  sort(a.begin(),a.end());
  long now=0;
  rep2(i,1,n){
    a.at(i)-=a.at(0);
    now+=a.at(i);
  }
  a.at(0)=0;
  rep2(i,1,n){
    if(a.at(i)-a.at(i-1)!=0){
      if(i<n-i){
        now-=(a.at(i)-a.at(i-1))*(n-2*i);
      }
      else{
        break;
      }
    }
  }
  cout<<now<<endl;
}

Measured memory_bytes: 1792
s = input()

cnt_0 = 0
cnt_1 = 0
for i in range(0, len(s), 2):
  if s[i] == '0':
    cnt_0 += 1
  else:
    cnt_1 += 1

if cnt_0 > cnt_1:
  first = '0'
  second = '1'
elif cnt_0 == cnt_1:
  if s[len(s)-1] == '1':
    first = '0'
    second = '1'
  else:
    first = '1'
    second = '0'
else:
  first = '1'
  second = '0'

cnt = 0
for i in range(0, len(s)):
  if not i%2:
    if s[i] != first:
      cnt += 1
  else:
    if s[i] != second:
      cnt += 1
print(cnt)

Measured memory_bytes: 3188
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=1000000+19;
const int oo=(1<<30)-1;

char A[N],B[N];
int f0[N],pos[N],ans[N];
int n,m,t,res,wei;

int main(){
	n=IN();
	scanf("%s%s",A+1,B+1);
	For(i,1,n+1) if (A[i]!=B[i]) wei=1;
	if (!wei){
		puts("0");
		return 0;
	}
	m=n;
	for (int i=n;i;i--){
		int tmp=i;
		while (i>1&&B[i]==B[i-1]) i--;
		while (m>=1&&(m>i||A[m]!=B[i])) m--;
		if (m==0){
			puts("-1");
			return 0;
		}
		t++;
		f0[t]=m;
		pos[t]=tmp;
	}
	reverse(f0+1,f0+t+1);
	reverse(pos+1,pos+t+1);
	f0[t+1]=oo;
	for (int i=t;i;i--){
		for (ans[i]=ans[i+1];f0[i+ans[i]]-ans[i]<pos[i];ans[i]++);
	}
	printf("%d\n",ans[1]);
}

Measured memory_bytes: 13952
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n = I()
ans = 1
for i in range(n):
    ans *= (i+1)
    ans %= mod
print(ans%mod)


Measured memory_bytes: 10432
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int a, b;
cin >> a >> b;
if ( a * b == 15 ) {
cout << "*" << endl; 
}
else if  ( a + b == 15 ) {
 cout << " +" << endl;
}
else {
cout << "x" << endl;
}
}


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	long long n;
	cin >> n;
	vector<long long> a(n + 1);
	long long ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; i * j <= n; j++){
			a[i * j]++;
		}
		ans += i * a[i];
	}	
	cout << ans << '\n';
}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc=new Scanner(System.in);
		
		String s=sc.next();
		String t=sc.next();
		
		//char n=t.charAt(0);
		//t.substring(t.length() - 切り出したい文字列の長さ);
				
		if(t.indexOf(s)==0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}		
	sc.close();
	}

}


Measured memory_bytes: 26896
#include <iostream>
using namespace std;
 
int main()
{
    int a, b;
    char op;

    do {
        cin >> a >> op >> b;
        if (op == '+')
            cout << a + b << endl;
        else if (op == '-')
            cout << a - b << endl;
        else if (op == '*')
            cout << a * b << endl;
        else if (op == '/')
            cout << a / b << endl;
    } while (op != '?');
    
    return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

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

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

template<typename T>
struct SegmentTree {
	
	SegmentTree(int _n) : n(_n) { 
		t.resize(n * 4);
		lazy.resize(n * 4);
	}
	
	SegmentTree(vector<T>& a) {
		n = (int)a.size();
		t.resize(4 * n);
		lazy.resize(4 * n);
		build(a, 1, 1, n);
	}
	
	int n;
	vector<T> t, lazy;
	
	void build(vector<T>& a, int v, int tl, int tr) {
	    if (tl == tr) {
	        t[v] = a[tl - 1];
	    } else {
	        int tm = (tl + tr) / 2;
	        build(a, v*2, tl, tm);
	        build(a, v*2+1, tm+1, tr);
	        t[v] = min(t[v*2], t[v*2+1]);
	    }
	}
	
	void _push(int v) {
	    t[v*2] += lazy[v];
	    lazy[v*2] += lazy[v];
	    t[v*2+1] += lazy[v];
	    lazy[v*2+1] += lazy[v];
	    lazy[v] = 0;
	}
	
	void update(int l, int r, T addend) {
		_update(1, 1, n, l, r, addend);
	}
	
	void _update(int v, int tl, int tr, int l, int r, T addend) {
	    if (l > r) 
	        return;
	    if (l == tl && tr == r) {
	        t[v] += addend;
	        lazy[v] += addend;
	    } else {
	        _push(v);
	        int tm = (tl + tr) / 2;
	        _update(v*2, tl, tm, l, min(r, tm), addend);
	        _update(v*2+1, tm+1, tr, max(l, tm+1), r, addend);
	        t[v] = min(t[v*2], t[v*2+1]);
	    }
	}
	
	T query(int l, int r) {
		return _query(1, 1, n, l, r);
	}
	
	T _query(int v, int tl, int tr, int l, int r) {
	    if (l > r)
	        return std::numeric_limits<T>::max();
	    if (l <= tl && tr <= r)
	        return t[v];
	    _push(v);
	    int tm = (tl + tr) / 2;
	    return min(_query(v*2, tl, tm, l, min(r, tm)), 
	               _query(v*2+1, tm+1, tr, max(l, tm+1), r));
	}
};
int main() {
	ios_base::sync_with_stdio(0);
	int n, q;
	cin >> n >> q;
	SegmentTree<int> tree(n);
	REP(i, q) {
		int type, s, t, x;
		cin >> type;
		if (type == 0) {
			cin >> s >> t >> x;
			s++; t++;
			tree.update(s, t, x);
		} else {
			cin >> s >> t;
			s++; t++;
			cout << tree.query(s, t) << "\n";
		}
	}
	return 0;
}
 



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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n, d;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &d);

  printf("%d", (n - 1 + 2 * d + 1) / (2 * d + 1));

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
typedef pair<int,pint> ppi;
const int inf   = 510101010;
const ll longinf=1LL<<60;

int main(){
  int n;
  cin>>n;
  int a[n][n],dist[n][n];
  rep(i,n)rep(j,n){
    if(i==j) a[i][j]=dist[i][j]=0;
    else a[i][j]=dist[i][j]=inf;
    }
  int m;cin>>m;
  rep(i,m){
    int l,r,d;
    cin>>l>>r>>d;
    l--;r--;
    a[l][r]=a[r][l]=dist[l][r]=dist[r][l]=d;
    }
  rep(i,n)rep(j,n)rep(k,n){
    dist[j][k]=min(dist[j][k],dist[i][j]+dist[i][k]);
    }
  int cnt=0;
  rep(i,n)rep(j,n){
    if(a[i][j]<inf&&a[i][j]>dist[i][j])
      cnt++;
    }
  cout<<cnt/2<<endl;
  return 0;
  }

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };


int func(int k);

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

	int N = 100005;

	int a[100005];
	a[0] = c_YET;
	a[1] = s;
	for (int i = 2; i < N; i++)a[i] = func(a[i - 1]);

	for (int i = 1; i < N; i++)
		if (a[i] == a[i + 3]) {
			printf("%d", i + 3);
			break;
		}


}

int func(int k) {
	if (k % 2 == 0)return k / 2;
	else return 3 * k + 1;
}



/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
・文字列の＜＜スペル＞＞は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

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

int main(void){
    long long int a, b, c, k;
    cin >> a >> b >> c >> k;
    long long answer = 0;
    k++;
    //cout << k % 2 << endl;
    if (k % 2 == 0)
    {
        answer = b - a;
    }
    else
    {
        answer = a - b;
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

class BIT:

    def __init__(self, n):
        # 0-indexed
        nv = 1
        while nv < n:
            nv *= 2
        self.size = nv
        self.tree = [0] * nv

    def sum(self, i):
        """ [0, i]を合計する """
        s = 0
        i += 1
        while i > 0:
            s += self.tree[i-1]
            i -= i & -i
        return s

    def add(self, i, x):
        """ 値の追加：添字i, 値x """
        i += 1
        while i <= self.size:
            self.tree[i-1] += x
            i += i & -i

    def get(self, l, r=None):
        """ 区間和の取得 [l, r) """
        # 引数が1つなら一点の値を取得
        if r is None: r = l + 1
        res = 0
        if r: res += self.sum(r-1)
        if l: res -= self.sum(l-1)
        return res
    
    def bisearch_left(self, l, r, x):
        """ 区間l,rで左からx番目の値がある位置 """
        l_val = self.sum(l)
        ok = r
        ng = l
        while ng+1 < ok:
            mid = (ok+ng) // 2
            if self.sum(mid) - l_val >= x:
                ok = mid
            else:
                ng = mid
        return ok

    def bisearch_right(self, l, r, x):
        """ 区間l,rで右からx番目の値がある位置 """
        r_val = self.sum(r)
        ok = r
        ng = l
        while ng+1 < ok:
            mid = (ok+ng) // 2
            if r_val - self.sum(mid) < x:
                ok = mid
            else:
                ng = mid
        return ok

N = INT()
A = LIST()
# aの昇順に処理できるようにindexで並べておく
idxs = [0] * (N+1)
for i, a in enumerate(A):
    idxs[a] = i + 1

bit = BIT(N+2)
# 先頭と末尾に番兵を仕込む
bit.add(0, 1)
bit.add(N+1, 1)
ans = [0] * (N+1)
for a in range(1, N+1):
    # a(1~N)が格納されているindex
    idx = idxs[a]
    # 自分より小さいindexで最初に自分より小さい値がある直前の場所
    l = bit.bisearch_right(-1, idx, 1) + 1
    # 自分より大きいindexで最初に自分より小さい値がある直前の場所
    r = bit.bisearch_left(idx, N+1, 1) - 1
    # aを使う回数 * a = 左端として使える範囲 * 右端として使える範囲 * a
    ans[a] = (idx-l+1) * (r-idx+1) * a
    # aを出現済とする
    bit.add(idx, 1)
# 全てのaについての合計
print(sum(ans))


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

int main() 
{
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (s==u)
        cout << a-1 << " " << b;
    else 
        cout << a << " " << b-1;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

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

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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

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

long long lcm(long long a, long long b){
  return a / gcd(a, b) * b;
}

int main(){
  int N; cin >> N;
  ll ans = 1;
  rep(i, N){
    ll t; cin >> t;
    ans = lcm(ans, t);
  }
  cout << ans << endl;
}


Measured memory_bytes: 764
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;

int i,n,k,a[N];

bool check(int mid)
{
	int req=0;
	for(i=1;i<=n;i++)
	{
		if(a[i]<=mid)
			continue;
		req+=(a[i]-1)/mid;
	}
	return req<=k;
}

void solve()
{
    cin>>n>>k;
    for(i=1;i<=n;i++)
    {
    	cin>>a[i];
    }
    int lo=1,hi=1e9;
    while(lo<hi)
    {
    	int mid=(lo+hi)>>1;
    	if(check(mid))
    		hi=mid;
    	else
    		lo=mid+1;
    }
    cout<<lo;
}

signed main()
{
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 5076
def make_divisor(n):
  divisors=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      divisors.append([n//i,i])
  return divisors

n = int(input())
lis = make_divisor(n)
for j in lis:
  if j[0]<10 and j[1]<10:
    print('Yes')
    exit(0)
print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=1e9+7;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    ll n,m;
    cin >> n >> m;
    if (n>m) swap(n,m);
    ll ans=1;
    repr(i,1,n+1) ans=(ans*i)%MOD;
    ans=(ans*ans)%MOD;
    if (m==n) ans=(ans*2)%MOD;
    else if (m-n==1) ans=(ans*m)%MOD;
    else ans=0;
    cout << ans << endl;

    return 0; 
}


Measured memory_bytes: 3640
package main

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

func main() {
	io, flush := NewIO()
	defer flush()

	n, m := io.ScanInt(), io.ScanInt()
	observatories := io.ScanInts(n)
	highestObservatoryMap := map[int]int{}
	for i := 0; i < m; i++ {
		a, b := io.ScanInt(), io.ScanInt()
		if observatories[b-1] > highestObservatoryMap[a] {
			highestObservatoryMap[a] = observatories[b-1]
		}
		if observatories[a-1] > highestObservatoryMap[b] {
			highestObservatoryMap[b] = observatories[a-1]
		}
	}

	var goodObservatoryNum int
	for i, o := range observatories {
		if o > highestObservatoryMap[i+1] {
			goodObservatoryNum++
		}
	}
	fmt.Println(goodObservatoryNum)
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


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

int main(){
    int N;
    cin >> N;
    double num_odd=0;
    for(int i=1;i<=N;i++){
        if(i%2){
            num_odd++;
        }
    }


    cout << num_odd/N << endl;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

class topological_sort {
private:
	int V;
	vector<vector<int>> edges;
	vector<int> in;
public:
	topological_sort(int n) :V(n), edges(n), in(n) {}
	topological_sort(vector<vector<int>> &edges) :V(edges.size()), in(edges.size()) { this->edges = edges; }

	void add_edge(int from, int to) { edges[from].emplace_back(to); }

	int build() {

		for (int i = 0; i < V; i++) for (const auto &e : edges[i]) in[e]++;
		vector<int> used(V), res;
		res.reserve(V);

		queue<int> que;
		for (int i = 0; i < V; i++) {
			if (in[i] == 0 && !used[i]) {
				used[i] = 1;
				que.emplace(i);
			}
		}

		while (!que.empty()) {
			int now = que.front();
			DMP(now, in);
			que.pop();
			res.emplace_back(now);
			for (const auto &e : edges[now]) {
				in[e]--;
				if (in[e] == 0) {
					if (used[e]) return -1; // unable to sort
					used[e] = used[now] + 1;
					que.emplace(e);
				}
			}
		}

		if (res.size() != V) return -1;
		else return *max_element(used.begin(), used.end());
	}

};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	auto id = [&](int l, int r) { return min(l, r)*N + max(l, r); };

	auto rid = [&](int id) {
		int row = id / N, col = id % N;
		if (row >= col) return make_pair(-1, -1);
		else return make_pair(row, col);
	};

	topological_sort ts(N * N);
	for (int i = 0; i < N; i++) {
		vector<int> A(N - 1);
		for (int j = 0; j < N - 1; j++) cin >> A[j];
		for (int j = 0; j < N - 2; j++) ts.add_edge(id(i, A[j] - 1), id(i, A[j + 1] - 1));
	}

	cout << ts.build() << "\n";

	return 0;
}


Measured memory_bytes: 53032