akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N,L = inputIL()
A = inputIL()



for index in range(N):
  if index == 0:
    if A[0]+A[1] >= L:
      print("Possible")
      for i in range(N-1)[::-1]:
        print(i+1)
      exit()

  elif index == N-1:
    if A[N-1]+A[N-2] >= L:
      print("Possible")
      for i in range(N-1):
        print(i+1)
      exit()      

  else:
    if A[index]+A[index-1] >= L:
      print("Possible")
      for i in range(index,N-1)[::-1]:
        print(i+1)
      for i in range(index):
        print(i+1)
      exit()
    elif A[index]+A[index+1] >= L:
      print("Possible")
      for i in range(index):
        print(i+1)
      for i in range(index,N-1)[::-1]:
        print(i+1)
      exit()

print("Impossible")



Measured memory_bytes: 85356
#include<map>
#include<cstdio>
using namespace std;
int main(){for(int T,n,k,c,d,C;scanf("%d",&T),T;puts("")){
	map<pair<int,int>,int>m;
	for(;T--&&scanf("%s%d",&C,&n);){
		if(C=='D'){
			for(auto it=m.begin();it!=m.end();)if(it->second==n)m.erase(it++);else ++it;
		}else if(C=='R'){
			auto it=m.lower_bound({n,2000000000});
			printf("%d\n",it==m.begin()||n<(--it)->first.first||it->first.second<n?-1:it->second);
		}else if(C=='W'){
			c=!scanf("%d",&k);
			for(auto it=m.begin();k&&it!=m.end();++it){
				d=it->first.first-c;
				if(d>k)d=k;
				if(d)m.insert({{c,c+d-1},n});
				k-=d;
				c=it->first.second+1;
			}
			if(k)m.insert({{c,c+k-1},n});
		}
	}
}}

Measured memory_bytes: 1236
s = gets.chomp

chunks = [[],[]]
i = 0
last = ''
len = 0
s.each_char do |c|
  if c == last
    chunks[i].push(len)
    i = i == 0 ? 1 : 0
    len = 1
  else
    len += 1
  end

  last = c
end
chunks[i].push(len)
chunks[1].push(0)

def my_sum(a)
    ret = 0
    a.each do |i|
        ret += i
    end
    ret
end

a0 = my_sum(chunks[0])
a1 = my_sum(chunks[1])
ans = a0 > a1 ? a1 : a0
print ans

Measured memory_bytes: 2824
#include <bits/stdc++.h>
using namespace std;
int n;
int a[100009];
int dp[100009];
int main(){
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=n-1;i>=0;i--){
        int x=abs(a[i]-a[i+1])+dp[i+1];
        int y=abs(a[i]-a[i+2])+dp[i+2];
        if(i==n-2) y=x;
        dp[i]=min(y,x);
    }
    cout<<dp[0]-a[n-1]<<endl;
}


Measured memory_bytes: 1024
#include <iostream>

using  namespace std;

int main() {
        int n;
        cin >> n;
        string s;
        cin >> s;

        int ans = 0;
        for(int i = 0; i < n; i++) {
                if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
                        ans++;
                }
        }

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



Measured memory_bytes: 764
/*
 *
 *    I am o0o0oo00.
 *
 */
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll          long long
#define p7          1000000007
#define p9          998244353
#define pb          push_back
#define ff          first
#define ss          second
#define vll         vector<ll>
#define pll         pair<ll,ll>
#define vpll        vector<pll>
#define mll         map<ll,ll>
#define test        ll T;cin>>T;while(T--)
#define ad(a,n)     vll a;a.resize(n);for(ll i=0;i<n;i++)cin>>a[i];
#define as(a,n)     for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<endl;
#define all(x)      x.begin(),x.end()

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll powm(ll x, ll y, ll m = p7) {
    x = x % m; ll res = 1; while (y)
    {if (y & 1)res = res * x; res %= m; y = y >> 1; x = x * x; x %= m;} return res;
}
ll modi(ll a, ll m = p7) {return powm(a, m - 2, m);}
void yesno(bool f) {f ? cout << "YES" << endl : cout << "NO" << endl;}


void ss99()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}


int32_t main()
{
//    ss99();
//    test
    {
        ll n, k; cin >> n >> k;
        ll h[n + 1], dp[n + 1] = {0};
        for (ll i = 1; i <= n; i++)
            cin >> h[i];
        dp[n] = 0;
        for (ll i = n - 1; i >= 1; i--)
        {
            ll val = dp[i + 1] + abs(h[i] - h[i + 1]);
            for (ll j = i + 1; j <= min(n, i + k); j++)
            {
                val = min(val, dp[j] + abs(h[i] - h[j]));
            }
            dp[i] = val;
        }
        cout << dp[1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<map>
#include<math.h>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int maxn=2e6+50;
ll  a1[maxn],b1[maxn];
ll quickpow(ll a ,ll b){
   ll ans=1;
   while(b>0){
         if(b&1) ans=ans*a%mod;
         a=a*a%mod;
         b>>=1;
   }
   return ans;
}
ll ni(ll x){
    return quickpow(x,mod-2);
}
void init (){
     a1[0]=1;
     for(int i=1;i<=maxn;i++){
        a1[i]=(a1[i-1]*i)%mod;
     }
     b1[maxn]=ni(a1[maxn]);
     for(int i=maxn-1;i>=0;i--){
         b1[i]=b1[i+1]*(i+1)%mod;
     }
}
ll c(ll n,ll m){
    return (a1[n]*b1[m]%mod)*b1[n-m]%mod;
}
int main (){
    ll n,ans=0;
    init();
    string s;
    cin>>n>>s;
    ll len=s.size();
    for(int i=len;i<=n+len;i++){
        ans=(ans+c(n+len,i)*quickpow(25,n+len-i)%mod)%mod;
    }
    printf ("%lld\n",ans%mod);





}









Measured memory_bytes: 35716
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string.h>
#define INF 1111111
using namespace std;
int d[111][111];
int d2[111][111];
int V;
int main(void){
  int i,j,k;
  int N,M;
  int a,b,c;
  int res=0;

  cin>>N>>M;
  V=N;
  for(i=0;i<=V;i++){
    for(j=0;j<=V;j++){
      d[i][j]=d2[i][j]=INF;
    }
  }

  for(i=0;i<M;i++){
    cin>>a>>b>>c;
    d[a][b]=d[b][a]=d2[a][b]=d2[b][a]=c;
  }

  for(k=1;k<=V;k++)
    for(i=1;i<=V;i++)
      for(j=1;j<=V;j++) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);

  for(i=1;i<=V;i++){
    for(j=1;j<=V;j++){
      if(d[i][j]!=d2[i][j]&&d2[i][j]!=INF) res++;
    }
  }

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define ff first
#define ss second
typedef pair<int,int> pii;

bool ok(int mnlen , int k , int n , int a[]){
 int cnt = 0 ;
 for(int i = 0 ; i < n ; i++)
  if(a[i] > mnlen){
   if(a[i] % mnlen == 0){
    cnt += (a[i] / mnlen) - 1 ;
   }
   else 
    cnt += (a[i] / mnlen) ;
  }

 return cnt <= k ;
}

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

 sort(a , a+ n) ;

 int lo = 0 , hi = 1e9 + 7 ;

 while(hi - lo > 1){
  int mid = lo + (hi - lo)/2 ;

  if(ok(mid , k , n , a))hi = mid ;
  else lo = mid ;
 }

 cout << hi ;


 return 0;
}        

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

#define MAX 10000

struct Node {
	int p, l, r;
};

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

int setDepth(int id, int d) {
	if(id == -1)   return 0;
	D[id] = d;
	setDepth(T[id].l, d + 1);
	setDepth(T[id].r, d + 1);
}

int setHeight(int id) {
	int h1 = 0;
	int h2 = 0;
	if(T[id].l != -1)
		h1 = setHeight(T[id].l) + 1;
	if(T[id].r != -1)
		h2 = setHeight(T[id].r) + 1;
	
	H[id] = ((h1 > h2) ? h1 : h2);
	return H[id];
}

int getSibling(int id) {
	if(T[id].p == -1)
		return -1;
	if(T[T[id].p].l != id && T[T[id].p].l != -1)
		return T[T[id].p].l;
	if(T[T[id].p].r != id && T[T[id].p].r != -1)
		return T[T[id].p].r;
	return -1;
}

void show(int id) {
	cout << "node " << id << ": ";
	cout << "parent = " << T[id].p << ", ";
	cout << "sibling = " << getSibling(id) << ", ";
	int degree = 0;
	if(T[id].l != -1)   ++degree;
	if(T[id].r != -1)   ++degree;
	cout << "degree = " << degree << ", ";
	cout << "depth = " << D[id] << ", ";
	cout << "height = " << H[id] << ", ";
	if(T[id].p == -1)   cout << "root" << endl;
	else if(T[id].l == -1 && T[id].r == -1)   cout << "leaf" << endl;
	else   cout << "internal node" << endl;
}

int main(void) {
	int id, l, r;
	int n;
	int root = 0;
	
	cin >> n;
	for(int i = 0; i < n; ++i)   T[i].p = -1;
	
	for(int i = 0; i < n; ++i) {
		cin >> id >> l >> r;
		T[id].l = l;
		T[id].r = r;
		if(l != -1)   T[l].p = id;
		if(r != -1)   T[r].p = id;
	}
	
	while(T[root].p != -1)   ++root;
	
	setDepth(root, 0);
	setHeight(root);
	
	for(int i = 0; i < n; ++i)   show(i);
	
	return 0;
}


Measured memory_bytes: 3112
#include<algorithm>
#include<iostream>
#include<cmath>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

int main()
{
  int w,n,Nari=1;
  while(cin >> n >> w,n|w)
    {
      int total[n],input[n],mincost[n];
	rep(i,n)
	  {
	    cin >> input[i];
	    total[i] = input[i] + (i?total[i-1]:0);
	    mincost[i] = abs(total[i]-w);
 	  }

	//rep(i,n)cout << "mincost["<<i<<"] = " << mincost[i] << endl;
	//rep(i,n)cout << "total["<<i<<"] = " << total[i] << endl;

	rep(i,n)
	  rep(j,i)
	    mincost[i] = min(mincost[i],mincost[j]+abs((total[i]-total[j])-w));


	int ans = max(0,total[n-1]-w);

	rep(i,n)
	  ans = min(ans,mincost[i]+max(0,(total[n-1]-total[i]-w)));

	  cout << "Case " << Nari++ << ": " << ans << endl;
    }
  return 0;
}

Measured memory_bytes: 1172
#include<iostream>
using namespace std;
int main(){
	while(1){
		int m,f,r;
		cin>>m>>f>>r;
		if(m==-1&&f==-1&&r==-1)break;
		if(m==-1||f==-1)cout<<'F'<<endl;
		else if(m+f>=80)cout<<'A'<<endl;
		else if(m+f>=65)cout<<'B'<<endl;
		else if(m+f>=50)cout<<'C'<<endl;
		else if(m+f>=30){
			if(r>=50)cout<<'C'<<endl;
			else cout<<'D'<<endl;
		}
		else cout<<'F'<<endl;
	}
}

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

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

    int res = 100000;

    for(int i = 0; i < N; ++i) {
        int sum_f = 0;
        int sum_s = 0;
        for(int k = 0; k < i; ++k) {
            sum_f += W[k];
        }

        for(int k = i; k < N; ++k) {
            sum_s += W[k];
        }

        int sum = abs(sum_f - sum_s);
        if(res > sum) {
            res = sum;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <random>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define pi 3.141592653589793
#define prique priority_queue
constexpr auto mod=1000000007;
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int n){
    int cnt=0;
    for(int i=1;i<=sqrt(n);i++){
        if(n%1==0)cnt++;
    }
    if(cnt!=1) return false;
    else return n!=1;
}
struct UnionFind{
    vector<int> r;
    UnionFind(int N){
        r=vector<int>(N,-1);
    }
    int root(int x){
        if(r[x]<0) return x;
        return r[x]=root(r[x]);
    }
    bool unite(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(r[x]>r[y]) swap(x,y);
        r[x]+=r[y];
        r[y]=x;
        return true;
    }
    int size(int x){
        return -r[root(x)];
    }
};
vector<int> v;
int n,m,cnt=0,ans=0,aa[220000];
pair<int,int> pp[220000];
string s,ss[220000];
queue<int> que;
signed main(){
    cin>>n;
    cout<<1-n;
}

Measured memory_bytes: 10460
s = int(input())
m = 0
h = 0

if s >= 60:
    m = int(s / 60)
    s = s % 60

if m >= 60:
    h = int(m / 60)
    m = m % 60

print(h,end = ":")
print(m,end = ":")
print(s)


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int n, i;
	cin >> n >> i;
	cout << n + 1 - i << "\n";
}

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


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

using namespace std;

typedef long long int ll;

int main()
{
    ll n;

    cin >> n;

    ll ans = 0;

    for (ll i = 2; i*i <= n; i++)
    {
        ll e = 0;

        while (n % i == 0)
        {
            n = n / i;
            e++;
        }

        for (ll j = 1; j <= 100; j++)
        {
            if (e < j)
                break;
            e = e - j;
            ans++;
        }
    }

    if (n > 1)
        ans++;

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include <climits>
#include<vector>
#include<numeric>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, q;
	cin >> n >> q;
	queue<string> qu_name;
	map<string,int> mp_time;
	int res = 0;
	REP(i, n) {
		string name;
		cin >> name;
		qu_name.push(name);
		int time;
		cin >> time;
		mp_time[name] = time;
	}
	while (!qu_name.empty()) {
		string name = qu_name.front();
		if (mp_time[name] <= q) {
			res += mp_time[name];
			cout << name << " " << res << "\n";
			qu_name.pop();
		}
		else {
			res += q;
			mp_time[name] -= q;
			qu_name.pop();
			qu_name.push(name);
		}
	}

	return 0;
}


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

using namespace std;

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

int main(){
  int k;
  long long ans=0;
  cin >> k;
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int l=1;l<=k;l++){
        ans += gcd(i, gcd(j, l));
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3636
package main

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

/*-----------Main-----------*/

func main() {
	k := readI()
	a, b := readI(), readI()

	for i := a; i <= b; i++ {
		if i%k == 0 {
			fmt.Println("OK")
			return
		}
	}
	fmt.Println("NG")
}

/*-----------Utilities-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}

func max(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] > m {
			m = a[i]
		}
	}
	return m
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

func sortI(a []int) []int {
	sort.Ints(a)
	return a
}

func reverse(a []int) []int {
	l := len(a)
	r := make([]int, l)
	for i := 0; i < l; i++ {
		r[i] = a[l-i-1]
	}
	return r
}

func countI(a []int, b int) int {
	l := len(a)
	var c int
	for i := 0; i < l; i++ {
		if a[i] == b {
			c++
		}
	}
	return c
}


Measured memory_bytes: 1780
import numpy as np
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = list(map(int, input().split()) for _ in range(M))
A = list(map(list, set(map(tuple, A))))
#print(A)
#1本の道を辿っていける展望台の標高の最大値を求める
h = np.ones((N))

ans = 0
tmp = 0
for i in range(len(A)):
    if H[A[i][0]-1] > H[A[i][1]-1]:
        h[A[i][1]-1] = 0
    elif H[A[i][0]-1] < H[A[i][1]-1]:
        h[A[i][0]-1] = 0
    elif H[A[i][0]-1] == H[A[i][1]-1]:
        h[A[i][0]-1] = 0
        h[A[i][1]-1] = 0
#print(h)       
for i in range(N):
    if h[i]==1:
        ans+=1
print(ans)

Measured memory_bytes: 81388
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();

        for (int i = 0; i < S.length; i++) {
            if (i % 2 == 0) {
                System.out.print(S[i]);
            }
        }

    }

}


Measured memory_bytes: 28796
import java.io.*;
class Main
{
public static void main(String args[])throws IOException
{
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
while(true)
{
String str=input.readLine();
String str_ary[]=str.split(" ");
if(str_ary[0].equals("0") && str_ary[1].equals("0") && str_ary[2].equals("0") && str_ary[3].equals("0") &&str_ary[4].equals("0")&& str_ary[5].equals("0"))break;
int x[]=new int[6];
for(int i=0;i<6;i++)
{
x[i]=Integer.parseInt(str_ary[i]);
}
int score=15*(x[0]+x[1])+15*(x[0]*5+x[1]*3)+7*x[2]+2*x[3]+100-3*(x[5]-x[4]-(x[0]*5+x[1]*3))-2*(x[0]*5+x[1]*3);
System.out.println(score);
}
}
}

Measured memory_bytes: 18156
n=gets.chomp.to_i
A=gets.chomp.split.map(&:to_i)
y=A.inject(:+)
x=0
ans=10**12
A.pop
A.each do |e|
   x+=e
   y-=e
   z=(y-x).abs
   ans=z if ans > z
end
puts ans.abs

Measured memory_bytes: 16516
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
  	int A, B, C;
  	cin >> A >> B >> C;
  	int arr[] = {A, B, C};
  	sort(arr, arr + 3);
  	if (arr[0] == 5 && arr[1] == 5 && arr[2] == 7) cout << "YES";
  	else cout << "NO";
 	return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
struct loc{
	double x;
	double y;
}; 
struct loc p1,p2;
void koch(int i,struct loc p1a,struct loc p2a){
	if(i==0)
	return;//递归结束条件 
	
	struct loc s,u,t;
	s.x=(p2a.x+2*p1a.x)/3;
	s.y=(p2a.y+2*p1a.y)/3;
	t.x=(2*p2a.x+p1a.x)/3;
	t.y=(2*p2a.y+p1a.y)/3;
	u.x=(t.x-s.x)*0.5-(t.y-s.y)*(sqrt(3)/2)+s.x;
	u.y=(t.x-s.x)*(sqrt(3)/2)+(t.y-s.y)*0.5+s.y;//计算坐标 
	
	koch(i-1,p1a,s);
	printf("%.8lf %.8lf\n",s.x,s.y);
	koch(i-1,s,u);
	printf("%.8lf %.8lf\n",u.x,u.y);
	koch(i-1,u,t);
	printf("%.8lf %.8lf\n",t.x,t.y);
	koch(i-1,t,p2a);//递归 
}
int main(){
	p1.x=0.00000000;
    p1.y=0.00000000;
    p2.x=100.00000000;
    p2.y=0.00000000;
	int n;
	scanf("%d",&n);
	printf("%.8lf %.8lf\n",p1.x,p1.y);
	koch(n,p1,p2);
	printf("%.8lf %.8lf\n",p2.x,p2.y);
	return 0;
} 


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

using namespace std;

int main() {
    int n, k, q;
    cin >> n >> k >> q;

    vector<int> res(n, k - q);
    for (int i = 0; i < q; ++i) {
        int a;
        cin >> a;
        res[a - 1]++;
    }

    for (auto &x:res) {
        cout << (x > 0 ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  transform(s1.begin(), s1.end(), s1.begin(), ::toupper);
  transform(s2.begin(), s2.end(), s2.begin(), ::toupper);
  transform(s3.begin(), s3.end(), s3.begin(), ::toupper);
  cout << s1[0] << s2[0] << s3[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18;
void print() { cout << endl; }
template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);}
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<head;print0(tail...);}
// clang-format on

template <class T>
class ssegment_tree {
   public:
    ll size;
    vector<T> data;
    T default_value;

    ssegment_tree(ll n, T default_value_) {
        default_value = default_value_;

        ll siz = 1;
        while (siz < n) {
            siz = siz * 2;
        }
        data.resize(siz * 2, default_value);
        size = siz;
    }

    ~ssegment_tree() {}

    T compare(T& a, T& b) {
        //  ここをカスタム ex) min
        //return min(a, b);
        //return min(a, b);
        return max(a, b);
    }

    void update(ll k, T value) {
        // 葉の節点
        k += size - 1;
        data[k] = value;

        while (k > 0) {
            // 順に親に向かっていく
            k = (k - 1) / 2;
            data[k] = compare(data[k * 2 + 1], data[k * 2 + 2]);
        }
    }

    // [a, b) で compare 最強のもの
    T query_open(ll a, ll b, ll k, ll l, ll r) {
        if (r <= a || b <= l) {  // 共通要素がない
            return default_value;
        }
        if (a <= l && r <= b) {  // 完全に含んでいる
            return data[k];
        }

        // 2つの子の compare で勝つほう
        T vl = query_open(a, b, k * 2 + 1, l, (l + r) / 2);
        T vr = query_open(a, b, k * 2 + 2, (l + r) / 2, r);
        return compare(vl, vr);
    }

    // [a, b] で compare 最強のもの
    T query(ll a, ll b) {
        return query_open(a, b + 1, 0, 0, size);
    }
};
using ssegmenttree = ssegment_tree<ll>;

struct aval {
    ll index;
    ll val;
};
int main() {
    ll N, K;
    cin >> N >> K;
    vector<aval> va(N);
    vector<aval> ia(N);
    for (ll i = 0; i < N; i++) {
        ll v;
        cin >> v;
        va[i] = {i, v};
        ia[i] = {i, v};
    }

    sort(va.begin(), va.end(), [](aval p, aval q) {
        return p.val < q.val;
    });

    vector<ll> ssti(N, 0);
    for (ll i = 0; i < N; i++) {
        ssti[va[i].index] = i;
    }
    auto sst = ssegmenttree(N, 0);
    vector<ll> vva(N);
    for (ll i = 0; i < N; i++) {
        vva[i] = va[i].val;
    }
    vector<ll> dp(N, 0);
    dp[N - 1] = 1;
    sst.update(ssti[N - 1], 1);
    ll maxval = 0;
    for (ll i = N - 2; i >= 0; i--) {
        ll v = ia[i].val;
        ll left = lower_bound(vva.begin(), vva.end(), v - K) - vva.begin();
        ll right = upper_bound(vva.begin(), vva.end(), v + K) - vva.begin() - 1;
        dp[i] = 1 + sst.query(left, right);
        maxval = max(dp[i], maxval);
        sst.update(ssti[i], dp[i]);
    }
    print(maxval);
}


Measured memory_bytes: 27832
#include <iostream>
#include<algorithm>
using namespace std;
bool complare(int c,int d)
{
    return c>d;
}
int main()
{
    long int s[200000],b=0;
    int a;
    int i;
    cin>>a;
    for(int i=0;i<a;i++)
    {
        cin>>s[i];
    }
    sort(s,(s+a),complare);
    b+=s[0];
    for (i = 1; i < (a/2); ++i) {
        b+=(2*s[i]);
    }
    if(a%2!=0)
    {
        b+=s[a/2];
    }
    cout<<b;
    return 0;
}

Measured memory_bytes: 5156
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)
 
#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(20)
 
const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;
 
// typedef long long ll;
#define int long long
#define double long double
 
template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
 
typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N; string S; cin >> N >> S;
  REP(i, S.size()){
    int idx = S[i]-'A';
    idx += N; idx %= 26;
    S[i] = 'A' + idx;
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c, d = LI()
    a += b
    c += d
    ans = ["Left", "Right"]
    if a == c:
        print("Balanced")
        return
    print(ans[a < c])
    return

#B
def B():
    n, a, b = LI()
    ans = 0
    for i in range(1, n + 1):
        if a <= sum(list(map(int, list(str(i))))) <= b:
           ans += i
    print(ans) 
    
    return

#C
def C():
    x, y = LI()
    ans = 0
    while x <= y:
        ans += 1
        x *= 2
    print(ans)
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 40944
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int[] n = SpRead(' ').Select(a => int.Parse(a)).ToArray();
        
        if (n[0] <= n[2] && (n[0] + n[1]) >= n[2]) Console.WriteLine("YES");
        else Console.WriteLine("NO");
    }

}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int Cin()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }

}


Measured memory_bytes: 13268
#include <cmath>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    ll N, K;
    double sum;
    double sumMax;

    cin >> N >> K;

    double P[N];
    double p;
    for(ll i = 0; i < K; i++){
        cin >> p;
        P[i] = (p + 1.0) / 2.0;
        sum += P[i];
        sumMax += P[i];
    }
    for(ll i = 0; i < N - K; i++){
        cin >> p;
        P[i + K] = (p + 1.0) / 2.0;
        sum -= P[i];
        sum += P[i + K];
        if(sumMax < sum){
            sumMax = sum;
        }
    }

    cout << fixed << setprecision(12) << sumMax << endl;

    return 0;
}


Measured memory_bytes: 1792
X, K, D = map(int, input().split())
X = abs(X)
"""#
Y = X (mod D)
|Y - X|/ D = K (mod 2)
x = p * D + r (p, r == Z, 0 <= r < D)
#"""
#XからYへ移動を繰り返した後
# 余った回数（偶数回）だけ-Dした座標との間を行き来すればよい

m = abs (int(X / D))
if K < m:   #途中でK回使い切った場合
    print(X - D * K)
else:
    K = K - m
    A = X - D * m
    if K % 2 == 0:
        print(A)
    else:
        print(abs(A - D))


Measured memory_bytes: 9196
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;

    cout << (n + 1) / 2 << endl;

    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

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

    ll R, C, K;
    cin >> R >> C >> K;

    vvl X(R, vl(C, 0));
    REP(i, K){
        ll r, c, v;
        cin >> r >> c >> v;
        r--, c--;
        X[r][c] = v;
    }

    vector<vvl> dp(4, vvl(R, vl(C, 0)));

    vl dx = {1, 0};
    vl dy = {0, 1};

    if(X[0][0]>0) dp[1][0][0] = X[0][0];

    REP(i, R){
        REP(j, C){
            REP(t, 4){
                    REP(d, 2){
                        ll nx = i+dx[d];
                        ll ny = j+dy[d];
                        if(nx<R and ny<C){
                            if(X[nx][ny]>0){
                                if(d==0){
                                    chmax(dp[1][nx][ny], dp[t][i][j]+X[nx][ny]);
                                }else{
                                    if(t<3) chmax(dp[t+1][nx][ny], dp[t][i][j]+X[nx][ny]);
                                }
                            }
                            if(d==0){
                                chmax(dp[0][nx][ny], dp[t][i][j]);
                            }else{
                                chmax(dp[t][nx][ny], dp[t][i][j]);
                            }
                        }
                    }
                }
            }
        }

    ll ma = 0;
    REP(i, 4) chmax(ma, dp[i][R-1][C-1]);
    cout << ma << endl;

    return 0;
}

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

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

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


int main()
{
    ll N;
    INX(N);

    ll tmp = N % 1000;
    if(tmp == 0)
    {
        OUTX(0);
    }
    else
    {
        OUTX(1000 - tmp);
    }
    

    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	ll N,D;
	scanf("%lld %lld",&N,&D);

	if(D == 1){
		printf("%lld\n",(N*(N-1))/2);
	}else if(D == N-1){
		printf("%lld\n",D);
	}else{
		printf("%lld\n",(N-1)+((N-D)*(N-D-1))/2+(N-D-1));
	}

	return 0;
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
map<string,int> m;
string s;
int main()
{
	cin>>s;
	m["MON"]=6;
	m["TUE"]=5;
	m["WED"]=4;
	m["THU"]=3;
	m["FRI"]=2;
	m["SAT"]=1;
	m["SUN"]=7;
	cout<<m[s];
	return 0;
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define first fst
#define second scd

#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long


signed main(){
  int cnt[5]={0};//m,a,r,c,h
  int n;
  string s;
  cin>>n;
  rep(i,n){
    cin>>s;
    if(s[0]=='M') cnt[0]++;
    if(s[0]=='A') cnt[1]++;
    if(s[0]=='R') cnt[2]++;
    if(s[0]=='C') cnt[3]++;
    if(s[0]=='H') cnt[4]++;
  }
  int ans=0;
  rep(i,5){
    repi(j,i+1,5){
      repi(k,j+1,5){
	ans+=cnt[i]*cnt[j]*cnt[k];
      }
    }
  }
  cout<<ans<<endl;
  
    
  return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v.at(i);
  map<int, int> odd;
  map<int, int> even;
  for (int i = 0; i < n; i++){
    if(i % 2) odd[v.at(i)]++;
    else even[v.at(i)]++;
  }
  
  int odd_first = 0;
  int odd_second = 0;
  int odd_memo = 0;
  for (auto c : odd){
    int memo = c.first;
    int count = c.second;
    if (count > odd_first){
      odd_second = odd_first;
      odd_first = count;
      odd_memo = memo;
    }
    else if (count > odd_second){
      odd_second = count;
    }
  }
  
  int even_first = 0;
  int even_second = 0;
  int even_memo = 0;
  for (auto c : even){
    int memo = c.first;
    int count = c.second;
    if (count > even_first){
      even_second = even_first;
      even_first = count;
      even_memo = memo;
    }
    else if (count > even_second){
      even_second = count;
    }
  }
  
  if (odd_memo != even_memo){
    cout << n - odd_first - even_first << endl;
  }
  else{
    cout << n - max(odd_first, even_first) - max(odd_second, even_second) << endl;
  }
  
}


Measured memory_bytes: 8248
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x, sm = 0, diff = 0;
  for(int i=0;i<5;i++){
    cin >> x;
    sm += ((x/10)+(x%10 == 0? 0 : 1))*10;
    diff = max(diff, (10-(x%10))%10 );
  }
  cout << sm - diff << endl;
}

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

int n;
char x[200005];
int dp[200005];
long long sump, summ;
int popcnt;

long long fastexp(int base, int index, int mod) {
	if (index == 0) return 1 % mod;
	if (index == 1) return base % mod;
	long long temp = fastexp(base, index / 2, mod) % mod;
	temp *= temp;
	temp %= mod;
	if (index % 2 == 1) temp *= base;
	temp %= mod;
	return temp;
}

int main() {
	scanf("%d", &n);
	scanf(" %s", x);
	for (int i = 0; i < n; i++) if (x[i] == '1') popcnt++;
	for (int i = 0; i < n; i++) {
		if (x[i] == '1') {
            sump += fastexp(2, n - i - 1, popcnt + 1);
            sump %= popcnt + 1;
            if (popcnt > 1) {
                summ += fastexp(2, n - i - 1, popcnt - 1);
                summ %= popcnt - 1;
            }
		}
	}
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i % __builtin_popcount(i)] + 1;
	}
	for (int i = 0; i < n; i++) {
		long long cursum;
		if (x[i] == '0') {
			cursum = sump + fastexp(2, n - i - 1, popcnt + 1);
			cursum %= popcnt + 1;
		}
		else if (popcnt > 1) {
			cursum = summ - fastexp(2, n - i - 1, popcnt - 1);
			cursum %= popcnt - 1;
			cursum = (cursum + popcnt - 1) % (popcnt - 1);
		} else {
            printf("0\n");
            continue;
		}
		printf("%d\n", dp[cursum] + 1);
	}
	return 0;
}


Measured memory_bytes: 4680
N = int(input())
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
C = [int(_) for _ in input().split()]

res = sum(B)

for i in range(N-1):
    if A[i+1] -A[i] == 1:
        res += C[A[i]-1]

print(res)

Measured memory_bytes: 3064
from itertools import accumulate
from math import sqrt
from bisect import bisect_left

N = int(input())
n = list(accumulate(range(int(sqrt(2 * N)) + 2)))

r = bisect_left(n, N)

if n[r] == N:
    print('\n'.join(map(str, range(1, r + 1))))
    exit()

d = n[r] - N
for i in range(1, r + 1):
    if i != d:
        print(i)

Measured memory_bytes: 3620
from collections import deque
N=int(input())
A=[]
for i in range(N):
    s=int(input())
    A.append(s)
A.sort()
H=deque()
H.append(A[0])
s=1
t=N-1
i=0
while t-s!=-1:
    x=A[s]
    y=A[t]
    a=abs(H[0]-x)
    b=abs(H[-1]-x)
    c=abs(H[0]-y)
    d=abs(H[-1]-y)
    e=max(a,b,c,d)
    if a==e:
        H.appendleft(x)
        s+=1
    elif b==e:
        H.append(x)
        s+=1
    elif c==e:
        H.appendleft(y)
        t-=1
    else:
        H.append(y)
        t-=1
ans=0
for i in range(N-1):
    ans+=abs(H[i+1]-H[i])
print(ans)

Measured memory_bytes: 59224
#include <bits/stdc++.h>
#define forn(i, n) for (long long i = 0; i < (long long)(n); ++i)
#define for1(i, n) for (long long i = 1; i <= (long long)(n); ++i)
#define fore(i, l, r) for (long long i = (long long)(l); i <= (long long)(r); ++i)
#define fordn(i, n) for (long long i = (long long)(n) - 1; i >= 0; --i)
#define ford1(i, n) for (long long i = (long long)(n); i >= 1; --i)
#define all(x) (x).begin(), (x).end()
#define PI 3.141592653589793
using namespace std;
using ll = long long;
using ld = long double;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll x, a, b;
    cin >> x >> a >> b;
    int s = b - a;
    if(s <= 0) cout << "delicious" << endl;
    else if(s <= x) cout << "safe" << endl;
    else cout << "dangerous" << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int p[200000],q[200000];
int main(void)
{
	int n,m,a,b,i;
	scanf("%d%d",&n,&m);
	FOR(i,0,m){
		scanf("%d%d",&a,&b);
		if(a>b) swap(int,a,b);
		if(a==1) p[b-1]=1;
		if(b==n) q[a-1]=1;
	}
	FOR(i,1,n-1){
		if(p[i]&&q[i]){
			puts("POSSIBLE");
			return 0;
		}
	}
	puts("IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
int main(){
    int a,b,c,d,count;
    count = 0;
    scanf("%d%d%d", &a,&b,&c);
    for(int i = a; i <= b; i++){
        d = c % i;
        if (d == 0){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2100
N = int(input())
Ts = list(map(int, input().split()))
M = int(input())

for _ in range(M):
  P, X = list(map(int, input().split()))
  sum = 0
  for i in range(len(Ts)):
    if i + 1 == P:
      sum += X
    else:
      sum += Ts[i]
  
  print(sum)

Measured memory_bytes: 3060
# frozen_string_literal: true

n = gets.to_i
d = n.times.map { gets.split.map(&:to_i) }

(2..(n - 1)).each do |i|
  if d[i][0] == d[i][1] && d[i - 1][0] == d[i - 1][1] && d[i - 2][0] == d[i - 2][1]
    puts 'Yes'
    exit
  end
end
puts 'No'


Measured memory_bytes: 14348
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map(String::toLong)
    println(Math.min(calcCount(aList,true),calcCount(aList,false)))
}

fun calcCount(aList: List<Long>, f:Boolean): Long {
    var flag = f
    var sum = 0L
    var count = 0L

    for (i in 0 until aList.size) {
        sum += aList[i]
        when {
            sum == 0L -> {
                count++
                sum = if (flag) 1 else -1
            }
            flag == sum > 0 -> {
                //do nothing
            }
            flag == sum < 0 -> {
                count += Math.abs(sum) + 1
                sum = if (flag) 1 else -1
            }
        }
        flag = !flag
    }
    return count
}


Measured memory_bytes: 53628
import sys


def alg_combination_mod(n, r, mod):
    r = min(n - r, r)
    if r == 0:
        return 1
    else:
        denominator = 1
        for i in range(n, n - r, -1):
            denominator = (denominator * i) % mod
        molecule = 1
        for i in range(1, r + 1):
            molecule = (molecule * i) % mod
        return denominator * pow(molecule, mod - 2, mod) % mod


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, a, b = list(map(int, input().rstrip('\n').split()))
    all_cnt = pow(2, n, mod)
    a_cnt = alg_combination_mod(n, a, mod)
    b_cnt = alg_combination_mod(n, b, mod)
    print((all_cnt - a_cnt - b_cnt - 1) % mod)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 39280
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N;long D,A;cin>>N>>D>>A;
	pair<long,long> X[N];
	rep(i,0,N) cin>>X[i].first>>X[i].second;
	sort(X,X+N);
	long t[N];long res=0;
	long ans=0;
	int j=0;
	rep(i,0,N){
		while(X[j].first+2*D<X[i].first){
			res-=t[j];
			j++;
		}
        X[i].second-=res*A;
		t[i]=max((X[i].second+A-1)/A,(long)0);
		res+=t[i]; ans+=t[i];
		X[i].second-=A*t[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4992
n=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
  num=str(input())
  if num=="AC":
    ac+=1
  elif num=="WA":
    wa+=1
  elif num=="TLE":
    tle+=1
  else:
    re+=1
    
print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))


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

using namespace std;

double A, B, H, M;
double ax, ay, bx, by, ans;
double pi = 3.141592653589793238;

int main() {
    cin >> A >> B >> H >> M;

    ax = A*cos(2 * pi * (H + M / 60) / 12);
    bx = B*cos(2 * pi * M / 60);
    ay = A*sin(2 * pi * (H + M / 60) / 12);
    by = B*sin(2 * pi * M / 60);

    ans = sqrt(pow(ax - bx, 2) + pow(ay - by, 2));
    cout << fixed << setprecision(15) << ans;
}

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

const int N_MAX = 100000;
const int Q_MAX = 50000;

int main() {
  int n, q;
  int s[N_MAX], t[Q_MAX];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &s[i]);
  scanf("%d", &q);
  for (int i = 0; i < q; i++) scanf("%d", &t[i]);

  int ans = 0;
  int left, right, mid;
  for (int i = 0; i < q; i++) {
    left = 0;
    right = n;
    while (left < right) {
      mid = (left + right) / 2;
      if (s[mid] == t[i]) {
        ans++;
        break;
      } else if (s[mid] > t[i]) {
        right = mid;
      } else {
        left = mid + 1;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}

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


int main()
{
	string s;
	map <string, int> m;
	map <string, int> m2;
	int maxlen = -1;

	pair<string, int> max_pair;
	pair<string, int> max2_pair;
	while (cin >> s){
		if (m.count(s) == 0){
			m.insert(pair<string, int>(s, 0));
			m2.insert(pair<string, int>(s, (int)s.length()));
		}
		else{
			m[s]++;
		}
	}

	for (auto pm = m.begin(); pm != m.end(); pm++){
		if (pm->second > max_pair.second){
			max_pair = *pm;
		}
	}
	for (auto pm = m2.begin(); pm != m2.end(); pm++){
		if (pm->second > max2_pair.second){
			max2_pair = *pm;
		}
	}
	cout << max_pair.first << " "<<max2_pair.first<<endl;
	return 0;
}

Measured memory_bytes: 1196