akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
int main(){
    string n;
    cin >> n;
   // int s = n.size();
    //char nn = n.push_back();
    if(n.back() == '3'){
        cout << "bon" << endl;
    }else  if(n.back() == '0' || n.back() == '1' || n.back()== '6' || n.back() == '8'){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3628
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
typedef long long ll;
using namespace std;
int r, g, b;
void Haiku() {
	string s;
	cin >> s;
	s[5] = ' ';
	s[13] = ' ';
	cout << s << endl;

}

int main() {
	Haiku();
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long ul;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef set<int> si;
typedef multiset<int> mi;
 
const ll INF = 1e18;
const int MOD = 1e9+7;
 
int main() {
	
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	//ofstream cout ("fileName.txt");
	//ifstream cin ("fileName.txt");

	char c;
	cin>>c;
	
	if(c-'a'>=0 && c-'a'<26) cout<<"a\n";
	else cout<<"A\n";
 	
	return 0;
}


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


Measured memory_bytes: 2616
import java.util.*;
import java.io.*;
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        int k=sc.nextInt()-1;
        int a[]=new int[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        int ans=1<<29;
        for(int i=0; i+k<n; i++) {
            if(a[i+k]<=0){
                ans=min(ans,-a[i]);
            }
            else if(0<=a[i]){
                ans=min(ans,a[i+k]);
            }
            else {
                ans=min(ans,a[i+k]-a[i]+min(-a[i],a[i+k]));
            }
        }

        out.println(ans);
        out.flush();
    }


    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

class P implements Comparable<P>{
    int id, d;
    P(int  id, int d) {
        this.id=id;
        this.d=d;
    }
    public int compareTo(P p){
        return d-p.d; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 36912
// Example program
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < b; i++)
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const int INF = ~(1<<31);


struct node {
	node* left = NULL;
	node* right = NULL;
	int sum, mx, mn, atr, atl;
	node(node* l, node* r, int v, int al, int ar) {
		left = l; right = r;
		sum = v; mx = v; mn = v;
		atl = al; atr = ar;
	}
	void change(int at, int to) { // changes index of at into value of to
		if(at > atr || at < atl) return;
		if(at == atr && at == atl) {
			sum = to; mx = to; mn = to;
			return;
		}
		left->change(at,to);
		right->change(at,to);
		update();
	}
	void add(int at, int by) { // adds by to the index of at
		if(at > atr || at < atl) return;
		if(at == atr && at == atl) {
			sum+=by;mx+=by;mn+=by;
			return;
		}
		left->add(at,by);
		right->add(at,by);
		update();
	}
	void update() { // Changes everything when done
		sum = left->sum+right->sum;
		mn = min(left->mn, right->mn);
		mx = max(left->mx, right->mx);
	}
	int qsum(int l, int r) { // gets the some from range l to r
		if(l > atr || r < atl) return 0;
		if(l <= atl && atr <= r) return sum;
		return left->qsum(l,r)+right->qsum(l,r);
	}
	int qmn(int l, int r) { // gets the min value from l to r
		if(l > atr || r < atl) return INF;
		if(l <= atl && atr <= r) return mn;
		return min(left->qmn(l,r),right->qmn(l,r));
	}
	int qmx(int l, int r) { // gets the max value from l to r
		if(l > atr || r < atl) return 0;
		if(l <= atl && atr <= r) return mx;
		return max(left->qmx(l,r), right->qmx(l,r));
	}
};
node* build(int l, int r) {
	if(l > r) return NULL;
	if(l == r) return new node(NULL,NULL,0,l,r);
	int m = (l+r)/2;
	node* left = build(l,m);
	node* right = build(m+1,r);
	node* cur = new node(left,right,0,l,r);
	return cur;
}


bool isprime(int n) {
    if(n == 1) return 0;
    if(n == 2) return 1;
    for(int i = 2; i*i <= n; i++) if(n % i == 0) return 0;
    return 1;
}

int main() {
    int q;
    cin >> q;
    node* root = build(0,200000);
    rep(i,1,200000) {
        if(i%2 == 0) continue;
        if(isprime(i) && isprime((i+1)/2)) {
            root->add(i,1);    
        }    
    }
    rep(i,0,q) {
        int l,r;
        cin >> l >> r;
        cout << root->qsum(l,r) << endl;
    }
}


Measured memory_bytes: 21248
#include <iostream>
#include <complex>
#include <algorithm>
#include <cstdio>

using namespace std;

const double INF = 100000000.0;

typedef complex<double> Point;
typedef pair<Point, Point> Line;

using namespace std;

double calcDist(Point a, Point b){
  return abs(a-b);
}

main(){
  int n;
  int tc = 1;
  while(cin >> n && n){
    Line data[14];
    for(int i=0;i<n;++i){
      cin >> data[i].first.real() >> data[i].first.imag()
          >> data[i].second.real() >> data[i].second.imag();
    }
    double dp[1<<14][14][2];
    fill(dp[0][0], dp[1<<14][0], INF);
    for(int i=0;i<n;++i) dp[1<<i][i][0] = dp[1<<i][i][1] = calcDist(data[i].first, data[i].second);
    for(int i=0;i<(1<<n);++i){
      for(int j=0;j<n;++j){
        for(int k=0;k<n;++k){
          dp[i|(1<<k)][k][0] = 
            min(dp[i|(1<<k)][k][0], 
                dp[i][j][0] + calcDist(data[j].first, data[k].second) + calcDist(data[k].first, data[k].second));
          dp[i|(1<<k)][k][0] = 
            min(dp[i|(1<<k)][k][0], 
                dp[i][j][1] + calcDist(data[j].second, data[k].second) + calcDist(data[k].first, data[k].second));
          dp[i|(1<<k)][k][1] = 
            min(dp[i|(1<<k)][k][1], 
                dp[i][j][0] + calcDist(data[j].first, data[k].first) + calcDist(data[k].first, data[k].second));
          dp[i|(1<<k)][k][1] = 
            min(dp[i|(1<<k)][k][1], 
                dp[i][j][1] + calcDist(data[j].second, data[k].first) + calcDist(data[k].first, data[k].second));
        }
      }
    }
    double ans = INF;
    for(int i=0;i<n;++i){
      ans = min(ans, min(dp[(1<<n)-1][i][0], dp[(1<<n)-1][i][1]));
    }
    printf("Case %d: %.5f\n", tc++, ans);
  }
  return 0;
}

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    string s;
    cin >> s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7'){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

int main(){

  ll x;
  ll sat = 0;
  cin >> x;
  
  sat = (x/500)*1000 + ( (x-(x/500)*500)/5 )*5;
  
  cout << sat << endl;
  
  
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt");
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        int n = int.Parse(input.ReadLine());
        double[] ary = ToIntArray(input.ReadLine(), n);
        var list = new List<double>(ary);

        list.Sort();

        for(int i=0; i<n-1; i++) {
            list[i + 1] = (list[i] + list[i + 1]) / 2.0;
        }
        return list.Last();
    }
    static double[] ToIntArray(string strs, int n) {
        var ret = new double[n];
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++) ret[i] = double.Parse(spl[i]);
        return ret;
    }
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> card(N);
  for (int i=0; i<N; i++) {
    cin >> card.at(i);
  }
  
  int A=0;
  int B=0;
  sort(card.begin(), card.end());
  for (int i=0; i<N; i+=2) {
    A += card.at(N-i-1);
  }
  for (int i=1; i<N; i+=2) {
    B += card.at(N-i-1);
  }
  cout << A-B << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,c,sum=1;
  cin>>a>>b>>c;
  if(a!=b && b!=c) sum++;
  if(a!=c) sum++;
  cout<<sum<<'\n';
  return 0;
}


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

namespace ABC132
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var d = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var r = d.OrderBy(x => x).ToArray();

            Console.WriteLine(r[n / 2] - r[n / 2 - 1]);
            
        }
    }
}


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

int main()
{
    string S;
    cin >> S;
    S = '`' + S + '{'; // `, { は文字コードでぞれぞれ a, z の前後の文字
    sort(S.begin(), S.end());
    int l = S.length();
    int ans = l;
    REP(i, l - 1){
        if (S[i+1] - S[i] > 1){
            ans = i;
            break;
        }
    }
    if (ans == l) cout << "None" << endl;
    else cout << char (S[ans] + 1) << endl;
    return 0;
}

Measured memory_bytes: 512
n = int(input())

a = []
deps = []
for i in range(n):
    dep = []
    a.append(int(input()))
    for j in range(a[i]):
        x,y = map(int,input().split())
        dep.append((x, y))
    deps.append(dep)


ans = 0
for i in range(2 ** n):
    bag = 0
    ok = 0
    for j in range(n):
        if (i >> j) & 1:
            bag += 1
            for x,y in deps[j]:
                if (i >> x-1) & 1:
                    if y != 1:
                        ok = -1
                else:
                    if y == 1:
                        ok = -1
    if ok == 0:
        ans = max(ans,bag)

print(ans)
                        




Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n],i;
        for(i=0;i<n;i++)
        {
            cin>>a[i];
        }
        ll sum=0;
        ll maxi=a[0];
        for(i=1;i<n;i++)
        {
            sum+=max(0LL,maxi-a[i]);
            maxi=max(maxi,a[i]);
        }
        cout<<sum;
    }
}

Measured memory_bytes: 5192
t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())

d1=t1*a1+t2*a2
d2=t1*b1+t2*b2

import sys
if d1>d2:
    dif=d1-d2
    gap=(b1-a1)*t1
elif d1<d2:
    dif=d2-d1
    gap=(a1-b1)*t1
else:
    print('infinity')
    sys.exit()

if (b1-a1)*(b2-a2)>0 or (b1-a1)*(d2-d1)>0:
    print(0)
    sys.exit()
if gap%dif!=0:
    print(gap//dif*2+1)
else:
    print(gap//dif*2)

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string s;
  cin>>s;
  int K;
  cin>>K;
  map<string,int>m;
  for(int i=0;i<s.size();i++){
    for(int j=0;j<=K&&i+j<=s.size();j++){
      if(j==0)continue;
      m[s.substr(i,j)]++;
    }
  }
  auto it=m.begin();
  advance(it,K-1);
  cout<<it->first<<endl;
  return 0;
}


Measured memory_bytes: 1920
import numpy as np

NM=np.array(input().split(" "),dtype=np.int32)
N=NM[0]
M=NM[1]

A=np.array(input().split(" "),dtype=np.int32)

total=sum(A)

th=total*(1/(4*M))

count=0

for a in A:
    if(a>=th):
        count+=1

if(count>=M):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 21512
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while (true) {
      int n = sc.nextInt();
      if (n == 0) {
        break;
      }
      boolean[] isPrime = new boolean[n+1];
      for (int i = 2; i <= n; i++) {
        isPrime[i] = true;
      }
      for (int i = 2; i*i <= n; i++) {
        if(isPrime[i]) {
          for (int j = 2*i; j <= n; j += i) {
            isPrime[j] = false;
          }
        }
      }
      int counter = 0;
      for (int i = 1; i <= n/2; i++) {
        if(isPrime[i] && isPrime[n-i]) {
          counter++;
        }
      }
      System.out.println(counter);
    }
  }
}

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

int main() 
{
    int n , m ;
    cin >> n >> m ;
    int res = 0 ;
    res = m*1900 + ( n-m ) * 100 ;
    res *= pow(2,m) ; 
    cout << res << endl ; 
   return 0  ; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS() ios::sync_with_stdio(0);cin.tie(0);
#define mp(a,b) make_pair(a,b)
signed main()
{
	string s;
	while(cin>>s)
	{
		string s2;
		for(char c:s)
		{
			if(c=='?') s2+='D';
			else s2+=c; 
		}
		cout<<s2<<"\n";
	}
}

Measured memory_bytes: 3828
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
//1 2 3 4 100 1
/*
N枚Y円
10000,5000,1000のさん通り考えられる
そもそも1000が足りているのか
val = val - num*1000
valを10000と50000,1000で作った時にNになるのか
%10000を5000で作るばあいと1000で作る場合に場合分け
全部1000で作る
1000を減らしていく
5000や10000を加えていく


*/


int main(void){
    int N,Y;
    scanf("%d %d",&N,&Y);
    int t_n = (Y%5000)/1000,num = N-t_n;
    int num1,num2,num3,total,flag = 1;
    if(num<0){
        printf("-1 -1 -1\n");
    }else{
        for(num1=0;num1<=num;num1 += 5){//1000の位が5or0を作りまくる
            for(num2=0;num2<=num-num1;num2++){
                num3 = num-num1-num2;
                total = 1000*(num1+t_n) + 5000*(num2) + 10000*(num3);
                if(total == Y){
                    printf("%d %d %d\n",num3,num2,num1+t_n);
                    flag = 0;
                    break;
                }
            }
            if(!flag){
                break;
            }

        }
        if(flag){
            printf("-1 -1 -1\n");
        }
    }


    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int W,H,x,y;
  cin>>W>>H>>x>>y;
  
  double ans=W*H/2;
  
  if(x+x==W&&y+y==H){
    printf("%lf %d",double(W)*double(H)/2,1);
  }
  else{
    printf("%lf %d",double(W)*double(H)/2,0);
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int  ll;
#define nl cout<<"\n";
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() {
    
    fastio;
    int n;cin>>n;
    ll tot  = 0;
    for(int i=0;i<=n;i++){
        if(i%3==0 || i%5==0){continue;}
        else{tot = tot+i;}
    }
    cout<<tot;    
}


Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int DP[] = new int[51];
		int pri[] = {0, 0, 380, 550, 0, 850};
		int num[] = {0, 0, 5, 4, 0, 3};
		double per[] = {0, 0, 0.8, 0.85, 0, 0.88};
		
		for(int i = 0; i <= 50; i++){
			DP[i] = Integer.MAX_VALUE;
		}
		
		DP[0] = 0;
		
		for(int space: new int[]{2,3,5}){
			for(int i = 50; i >= 0; i--){
				if(DP[i] != Integer.MAX_VALUE){
					int count = 0;
					for(int j = i; j <= 50; j += space, count++){
						if(count == 0){
							continue;
						}
						
						int next = DP[i] + (int)((count / num[space]) * num[space] * pri[space] * per[space]) + (count % num[space]) * pri[space];
						if(next < DP[j]){
							DP[j] = next;
						}
					}
				}
			}
		}
		
		while(true){
			int n = sc.nextInt();
			if(n == 0){break;}
			
			System.out.println(DP[n/100]);
			
		}
		
	}
}

Measured memory_bytes: 11000
N=int(input())
path=[list(map(int,input().split())) for _ in range(N-1)]

def next_station(Time,s):
    Time+=path[s][0]
    ns=s+1
    if ns==N-1:
        print(Time)
    elif Time<=path[ns][1]:
        Time=path[ns][1]
        next_station(Time,ns)
    else:
        if Time%path[ns][2]==0:
            next_station(Time,ns)
        else:
            Time+=(path[ns][2]-Time%path[ns][2])
            next_station(Time,ns)

for i in range(N-1):
    next_station(path[i][1],i)
print(0)

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

int main()
{
    // ll T;
    // cin >> T;

    // while(T--){
        ll n;
        cin >> n;
        ll arr;
        ll ans = 1;
        ll a, b;
        for(ll i=0; i<n; i++){
            cin >> arr;

            if(arr == 0) ans = 0;
            if(ans <= 0) continue;

            a = log10(ans);
            b = log10(arr);

            // cout << a << " " << b << endl;
            // cout << ans << endl;
            if(a+b > 18){
                ans = -1;
            }
            else if(a+b <= 17){
                ans *= arr;
                if(ans > INF || ans < 0) ans = -1;
            }
          	else{
              	a = ans; b = arr;
              	while(ans != -1 && a >= 10){
                  	if(a%10 > 0) ans = -1;
                  	a /= 10;
                }
              	if(a > 1) ans = -1;
              	while(ans != -1 && b >= 10){
                	if(b%10 > 0) ans = -1;
                  	b /= 10;
                }
              	if(b > 1) ans = -1;

                if(ans != -1) ans *= arr;
            }
        }

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

Measured memory_bytes: 3968
// problem: "https://atcoder.jp/contests/abc144/tasks/abc144_b"

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n;

    cin>>n;

    int i,j;

    for(i=1;i!=10;i++)
        for(j=1;j!=10;j++)
            if(i*j == n)
            {
                cout<<"Yes";
                exit(0);
            }

    cout<<"No";
    
    return 0;
}


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

#include<cstring>

#include<algorithm>

using namespace std;

int main(){

	priority_queue<int>q;    //优先队列自动从大到小排序

	int m,n,t;

	cin >>n>>m;

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

		cin>>t;

		q.push(t);    //每输入一个数都入队

	}

	long long sum=0;

	while(m){

		t=q.top()/2;

		q.pop();

		q.push(t);

		m--;

	}

	while(!q.empty()){

		sum+=q.top();

		q.pop();

	}

	cout<<sum;    //输出都处理完的总和

	return 0;

}


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

int main()
{
    long long n;
    cin>> n;
    vector<long long> v(n);
    map<long long ,long long> m;
    long long maxx=0;
    for(int i=0;i<n;i++)
    {
        cin>> v[i];
        m[v[i]]++;
        // maxx=max(maxx,m[v[i]]);

    }

    map<int,int> p;
    long long sum=0;
    for(auto i:m)
    {
        long long a=i.second;
        if(a>=2)
        sum+=a*(a-1)/2;
        
        
    }

    for(int i=0;i<n;i++)
    {
        
        long long res=0;
        if(m[v[i]]>=3)
            res=(m[v[i]]-1)*(m[v[i]]-2)/2;
          long long  ans=0;
        if(m[v[i]]>=2)
        ans=(m[v[i]]*(m[v[i]]-1)/2);
        cout<<sum-ans+res<<endl;
    }

    return 0;



}

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

using namespace std;

int main(){
	int n , x;
	cin >> n >> x ;
	int arr[n];
	for(int i = 0 ;  i < n ; i++)
		cin >> arr[i];
	vector<int> d(n+1,0);
	d[0] = 0 ;
	for(int i = 0 ; i < n ; i+=1)
		d[i+1] = arr[i]+d[i];



	int ans = lower_bound(d.begin(),d.end(),x)-d.begin();
	if(d[ans] == x)
		ans++;
	cout << ans << endl;

}

Measured memory_bytes: 3596
import java.io.*;
// import java.math.*;
// import java.util.*;
// import java.util.Map.*;
// import java.util.stream.*;

public class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));
        String[] arr = reader.readLine().split (" ");
        int A, B;
        A = Integer.parseInt (arr[0]);
        B = Integer.parseInt (arr[1]);
        System.out.println (A <= 9 && B <= 9 ? A * B : -1);
        return;
    }
}

Measured memory_bytes: 32732
var chunk = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = chunk.split('\n');


var calc = {'+': function (a, b) {return a + b; }, '-': function (a, b) {return a - b; }, '*': function (a, b) {return a * b; }, '/': function (a, b) {return Math.floor(a / b); }};


for (var i = 0; i < lines.length; i ++) {
    var arr = lines[i].split(' ');
    var a = Number(arr[0]);
    var op = arr[1];
    var b = Number(arr[2]);
    if (op === '?') {
        break;
    }
    console.log(calc[op](a, b));
}

Measured memory_bytes: 15708
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long ll;
const int MAXN = 200005;

int n, a[MAXN]; ll ans;

int main(){
	scanf( "%d", &n );
	for( int i = 1; i <= n; ++i )
		scanf( "%d", &a[i] );
	if( a[1] != 0 )
		return puts( "-1" ), 0;
	for( int i = 2; i <= n; ++i ){
		if( a[i] > a[i-1] + 1 )
			return puts( "-1" ), 0;
		if( a[i] == a[i-1] + 1 ) ++ans;
		else ans += a[i];
	}
	printf( "%lld\n", ans );
	return 0;
}

Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main(){
  char b;
  cin >> b;
  if (b == 'A') cout << 'T' << endl;
  else if (b == 'T') cout << 'A' << endl;
  else if (b == 'C') cout << 'G' << endl;
  else if (b == 'G') cout << 'C' << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
#include <deque>
#include <math.h>
#include <tgmath.h>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ull a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

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

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

//fast power
ll calc(ll a, ll b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        ll d = calc(a, b / 2);
        return (d * d) % MOD;
    }
    else return (a * calc(a, b - 1)) % MOD;
}

//fast combination
ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}

ll comb2(ll a) {
    ll b = a / 2;
    if (a % 2) {
        b = (a - 1) / 2;
        return (b * a);
    }
    return (b * (a - 1)); 
}

int kyotsu(string ss, int st, int ed, string ss2) {
    int ans = 0;
    for ( int i = st; i < ed; ++i ) {
        if (i - st >= ss2.size()) return ans;
        if (ss[i] == ss2[i - st] || ss[i] == '?') {
            ans++;
        } else {
            return -1;
        }
    }
    return ans;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    vector<ll> aa(n);
    m = 0;
    rep (i, 0, n) {
        cin >> aa[i];
        if (aa[i] > m) m = aa[i];
    }
    vector<ll> bb(m + 1, 0);
    vector<ll> cc(m + 1, -1);
    rep (i, 0, n) {
        bb[aa[i]]++;
    }
    d = 0;
    rep (i, 0, m + 1) {
        d += comb2(bb[i]);
    }

    rep (i, 0, n) {
        cout << d - (bb[aa[i]] - 1) << endl;
    }

    return 0;
}


Measured memory_bytes: 7168
using System.Linq;
using System;
class Program
{
    static long InputNumber() { return long.Parse(Console.ReadLine()); }
    static string InputString() { return Console.ReadLine(); }
    static long[] InputNumbers() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
    static string[] InputStrings() { return Console.ReadLine().Split(' '); }

    static void Main()
    {
        var NAB = InputNumbers();
        var N = NAB[0];
        var A = NAB[1];
        var B = NAB[2];

        if (A > B || N == 1 && A != B)
        {
            Console.WriteLine(0);
        }
        else
        {
            var min = A * (N - 1) + B;
            var max = A + B * (N - 1);
            Console.WriteLine((B - A) * (N - 2) + 1);
        }
    }
}

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

public class Main{
	final int INF = 1<<24;

	private void doit(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n-- > 0){
			String human = sc.next();
			StringBuilder after = new StringBuilder( sc.next());
			int len = after.length();
			for(int i = human.length() - 1; i >= 0; i--){
				char nowhuman = human.charAt(i);
				char temp;
				switch(nowhuman){
				case 'J':
					//right
					temp = after.charAt(len-1);
					for(int j = len-1; j > 0; j--){
						after.setCharAt(j, after.charAt(j- 1));
					}
					after.setCharAt(0, temp);
					break;
				case 'C':
					//left
					temp = after.charAt(0);
					for(int j = 0; j < len-1; j++){
						after.setCharAt(j, after.charAt(j+ 1));
					}
					after.setCharAt(len-1, temp);
					break;
				case 'E':
					//swap
					for(int j = 0; (j + 1) * 2 <= len; j++){

						temp = after.charAt(j);
						after.setCharAt(j, after.charAt(j + (len + 1) / 2  ));
						after.setCharAt(j + (len + 1) / 2 , temp);
					}
					break;
				case 'A':
					//reverse
					after = new StringBuilder(after.toString()).reverse();
					break;
				case 'P':
					//decrease
					for(int j = 0; j < len; j++){
						temp = after.charAt(j);
						if(temp >= '0' && temp <= '9'){
							if(temp == '0') temp = '9';
							else temp--;
						}
						after.setCharAt(j, temp);
					}
					break;
				case 'M':
					//increase
					for(int j = 0; j < len; j++){
						temp = after.charAt(j);
						if(temp >= '0' && temp <= '9'){
							if(temp == '9') temp = '0';
							else temp++;
						}
						after.setCharAt(j, temp);
					}
					break;
				}
			}
			System.out.println(after.toString());
		}
	}

	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 12000
// AOJ 1308 Awkward Lights
// 2018.3.8 bal4u

#include <stdio.h>
#include <string.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

#define N 630

// solve A X = C
int A[N][N], X[N], C[N];
int B[N][N];				// working

int gauss_jordan(int n)
{
	int i, j, k, t, pivot;

	for (i = 0; i < n; i++) for (j = 0; j < n; j++) B[i][j] = A[i][j];
	for (i = 0; i < n; i++) B[i][n] = C[i];

	for (i = 0; i < n; i++) {
		pivot = -1, t = -1;
		for (j = i; j < n; j++) if (B[j][i] > t) pivot = j, t = B[j][i];
		if (pivot < 0 || !t) continue;

		for (j = 0; j <= n; j++) {					// swap(B[i],B[pivot]);
			t = B[i][j], B[i][j] = B[pivot][j], B[pivot][j] = t;
		}

		for (j = 0; j < n; j++) if (i != j && B[j][i]) {
	        for (k = i; k <= n; k++) B[j][k] = (B[j][k]+B[i][k]) & 1;
		}
	}

	for (i = 0; i < n; i++) {
		X[i] = B[i][n];
		if (!B[i][i] && B[i][n]) return 0;
	}
	return 1;
}

#define ABS(a)	((a)>=0?(a):-(a))
#define ID(r,c)	((r)*m+(c))
int  s[28][28];

int main()
{
	int m, n, d, i, j, r, c, t;

	while (m = in()) {
		n = in(), d = in();
		memset(A, 0, sizeof(A)), memset(C, 0, sizeof(C));

		for (i = 0; i < n; i++) for (j = 0; j < m; j++) s[i][j] = in();
	
		for (i = 0; i < n; i++) for (j = 0; j < m; j++) {
			if (s[i][j]) C[ID(i,j)] = 1;
			for (r = 0; r < n; r++) for (c = 0; c < m; c++) {
				t = ABS(r-i)+ABS(c-j);
				if (t == d || t == 0) A[ID(i,j)][ID(r,c)] = 1;
			}
		}
		putchar('0' + gauss_jordan(m*n));
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 4680
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  string n;
  cin >> n;
  ull len = n.size();
  ll sum = 0;
  rep(i,len){
    sum += n[i] - '0';
  }
  if(sum % 9 == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int A, B; cin >> A >> B;
	if (A > B) swap(A, B);
	// A <= B

	if ((A + B) % 2 == 0) cout << (A + B) / 2 << endl;
	else cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<utility>
#include<vector>


using namespace std;



int main() {
	int n,tmp1,tmp2,size;
	int cnt_arrived=0;
	pair<int, int> ptmp;
	priority_queue<pair<int, int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
	cin >> n;
	int** mat = new int* [n];
	vector<pair<int, int>>* list_adjacent = new vector<pair<int, int>>[n];
	int* dist = new int[n];
	for (int i = 0;i < n;i++) {
		cin >> tmp1 >> size;
		for (int j = 0;j < size;j++) {
			cin >> tmp1 >> tmp2;
			list_adjacent[i].push_back(make_pair(tmp1, tmp2));
		}
		dist[i] = -1;
	}
	pq.push(make_pair(0, 0));
	while (cnt_arrived < n) {
		ptmp = pq.top();
		pq.pop();
		if (dist[ptmp.second] == -1) {
			cnt_arrived++;
			dist[ptmp.second] = ptmp.first;
			for (int i = 0;i < list_adjacent[ptmp.second].size();i++) {
				pq.push(make_pair(ptmp.first + list_adjacent[ptmp.second][i].second, list_adjacent[ptmp.second][i].first));
			}
		}
	}
	for (int i = 0;i < n;i++) {
		cout << i << " " << dist[i] << endl;
	}
}



Measured memory_bytes: 11736
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>

using namespace std;


int main()
{
  long double L;
  cin >> L;

  long double ldL = L+1.0E-14;

  long double l3 = ldL*ldL*ldL/(27.0+1.0E-14);

  cout << setprecision(16) << l3 << endl;

  return 0;
}


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

int main(){
    long r,d,x_init;
    cin >> r >> d >> x_init;

    long x = x_init;
    for(int i=0; i<10; i++){
        x = r*x - d; 
        cout << x << endl;
    }

    return 0;
}

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

int main(){

    int a, b;
    cin >> a >> b;

    int c;
    string as, bs, cs;
    as = to_string(a);
    bs = to_string(b);
    cs = as + bs;
    c = stoi(cs);

    for (int i=0; i<100100+1; i++){
        int temp;
        temp = i*i;
        if (temp == c) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int ans;
int mn = 1000;
int main()
{
    for (int i = 0; i < 5; i++)
    {
        int x;
        cin >> x;
        ans += x / 10;
        if (x % 10)
        {
            ans++;
            mn = min(x % 10, mn);
        }
    }
    mn %= 10;
    if (mn != 0)
        ans--;
    cout << ans * 10 + mn << endl;
    return 0;
}

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

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

    double ans;
    if (n % 2 == 0)
    {
        ans = 1.0 / 2.0;
        cout << ans << endl;
    }
    else
    {
        double tmp = n - n / 2;
        ans = tmp / (double)n;
        cout << ans << endl;
    }
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));
    vector<ll> sums(N+1);
    ll cnt = 0, ans = 0;;
    rep(i, N) {
        sums[i+1] += A[i] + sums[i];
        if (sums[i+1] - sums[i] > 2 * sums[i]) {
            ans = i;
        }
    }
    cout << N - ans << endl;
    return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int ma1=0,ma2=0,p1=-1,a;
	for (int i = 0; i < n; ++i)
	{
		cin>>a;
		if (a>ma1)
		{
			ma2=ma1;
			ma1=a;
			p1=i;
		}
		else if (a>ma2)
		{
			ma2=a;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		if (i==p1)
		{
			cout<<ma2<<endl;
		}
		else
		{
			cout<<ma1<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1664
/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-11-5 20:19:57
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main()
{
  string S;
  cin >> S;
  int ans = 700;
  for (auto x : S)
  {
    if (x == 'o')
    {
      ans += 100;
    }
  }
  cout << ans << endl;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))
#define endl '\n'

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <ll, ll> pll;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 0x3f3f3f3f;
const int MAX = 100005;
const int MAX1 = 1005;
const int MAX2 = 105;
const int LEN = 105;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1000000007;
//g++ -std=c++11 your_file.cpp -o your_program

ll mypow(ll a, ll b){
	ll ans=1;
	while(b){
		if(b&1)
			ans=(ans*a)%MOD;
		b/=2;
		a=(a*a)%MOD;
	}
	return ans;
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ifstream in("");
	ofstream out("");
	clock_t begin = clock();
	int a, b, x;
  	cin >> a >> b >> x;
  	if (a * a * b / 2 >= x){
  		double y = (double)(2 * x) / ((double)a * b);
  		double res = atan(y / (double)b) * (double)180 / (double)Pi;
  		cout << fixed << setprecision(10) << 90 - res << endl;
  	}
  	else {
  		double y = (double)2 * b - ((double)(2 * x) / ((double)a * a));
  		double res = atan((double)a / y) * (double)180 / (double)Pi;
  		cout << fixed << setprecision(10) << 90 - res << endl;
  	}
	clock_t end = clock();
    double esecs = double(end - begin) / CLOCKS_PER_SEC;
    //cout << esecs << " seconds" << endl;
	return 0;	
}

Measured memory_bytes: 256
import sys

input = input().split()
total = int(input[0])
front = int(input[1])

if(total<1 or total>100):
  sys.stderr.write('Error occurred!')
elif(front<1 or front > total):
  sys.stderr.write('Error occurred!')
else:  
  locationFromBack = (total-front) + 1
  print(locationFromBack)

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



int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(int i=0;i<3;i++){
        if(s.at(i) == 'R') ans++; 
    }
    if(s.at(1)=='S'&&(s.at(0)=='R'||s.at(2)=='R')) ans = 1;

    cout << ans << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
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 (b<a) { a = b; return 1; } return 0; }
typedef long long ll;

using namespace std;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main(){
    int N;
    cin >> N;
    vector<pll> ps;
    rep(i, N){
        ll a, b;
        cin >> a >> b;
        pll p = {a, b};
        ps.push_back(p);
    }
    sort(ps.begin(), ps.end(), [](pll a, pll b){return a.first + a.second > b.first + b.second ;});
    ll ans = 0;
    rep(i, N){
        if(i % 2 == 1){
            ans -= ps[i].second;
        }else{
            ans += ps[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2420
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
long long k,s,yz,ans,t,p;//yz：y+z的和；ans：记方案的变量；t记 y+z的和与k的差；p就是一共的可能性（yz+1） 
using namespace std;
int main()
{
	cin>>k>>s;
	for(int x=0;x<=k;x++)
	{
		if(x>s) break;//假如x比s都大，那就退出吧 
		yz=s-x;
		p=yz+1;
		if(yz<=k) ans+=p;
		else
		{
			t=yz-k;
			if(p-t*2>=0)ans+=p-t*2;//也有可能 这个非法的可能性比一共的可能性都大，所以当一共的可能性比非法的可能性大时才执行 
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
l, r = gets.chomp.split.map(&:to_i)

res = 2019
vars = [2019, r-l+1].min

(0...vars).each do |li|
    (li+1...vars).each do |ri|
        lv = l + li
        rv = l + ri
        var = (lv * rv) % 2019
        res = var if var < res
    end
end

puts res


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,a.size()) cin>>a[i];
    sort(a.begin(),a.end(),greater<int>());
    int alice=0,bob=0;
    rep(i,a.size())
    {
        if(i%2==0)
        {
            alice+=a[i];
        }
        else bob+=a[i];
    }
    cout<<abs(alice-bob)<<endl;;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int r;
	
	cin>>r;
	
	cout<<r*r*3<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int N,D,X,a,ans=0;
  cin>>N>>D>>X;

  for(int i=0;i<N;i++){
    cin>>a;
    ans+=(D-1)/a+1;
  }

  cout<<ans+X<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
#define totori signed
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
ll dx[4]={0,1,-1,0};
ll dy[4]={1,0,0,-1};

template < typename Monoid >
struct Segtree{
    using FM = function < Monoid(Monoid, Monoid) >;
    using FA = function < void(Monoid&, Monoid) >;
    int N;
    vector<Monoid> dat;
    
    const FM fm;
    const FA fa;
    const Monoid M1;

    Segtree(int n,const FM fm, const FA fa, const Monoid &M1): fm(fm), fa(fa), M1(M1){
        N = 1;
        while(N < n) N *= 2;
        dat.assign(2*N,M1);
    }

    void set(int idx, const Monoid &x){
        dat[idx+N-1] = x;
    }

    void build(){
        for(int i=N-2; i>=0; i--){
            dat[i] = fm(dat[2*i+1], dat[2*i+2]);
        }
    }

    void update(int idx, const Monoid &x){
        idx += N-1;
        fa(dat[idx],x);
        while(idx > 0){
            idx = (idx-1)/2;
            dat[idx] = fm(dat[idx*2 + 1], dat[idx*2+2]);
        }
    }

    Monoid get(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return M1;
        if(a<=l && r<=b) return dat[k];
        else{
            Monoid vl = get(a,b,k*2+1,l,(l+r)/2);
            Monoid vr = get(a,b,k*2+2,(l+r)/2,r);
            return fm(vl,vr);
        }
    }
    Monoid get(int a,int b){ return get(a,b,0,0,N); }

    Monoid at(int k) {return dat[k+N-1];}

    void debug(){
        for(int i=N-1;i<dat.size();i++){
            cerr << dat[i] << ", ";
        }
        cerr << "\n";
    }
};

// Range Minimum Query
auto fm = [](ll a,ll b){ return max(a,b); };
auto fa = [](ll& a, ll b){ a=max(a,b); };
Segtree<ll> seg(3000054, fm, fa, 0);

// Range Sum Query
// auto fm = [](ll a,ll b){ return a+b; };
// auto fa = [](ll& a, ll b){ a+=b; };
// Segtree<ll> seg(n, fm, fa, 0);


int ma = 3000001;
totori main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    int n,k;
    cin>>n>>k;
    int ans = 0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        int ret = 1;
        int l = max(0,a-k);
        int r = min(ma,a+k+1);
        chmax(ret,1+seg.get(l,r));
        seg.update(a,ret);
        chmax(ans,ret);
    }
    cout << ans << endl;

}

Measured memory_bytes: 68508
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;

void solve() {
	ll w, h, x, y; cin >> w >> h >> x >> y;
	ld ans = w * h / (ld)2.0;
	int c = 0;
	if (x*2 == w && y*2 == h) {
		c = 1;
	}
	cout << ans << " " << c << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
	return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector <string> A(N);
    vector <string> B(M);
    bool isFail = false;
    for (int i=0; i<N; i++) cin >> A.at(i);
    for (int i=0; i<M; i++) cin >> B.at(i);
    for (int i=0; i<=N-M; i++) {
        for (int j=0; j<=N-M; j++) {
            isFail = false;
            for (int k=0; k<M; k++) {
                for (int l=0; l<M; l++) {
                    if (A.at(i+k).at(j+l) != B.at(k).at(l)) {
                        isFail = true;
                        break;
                    }
                    else if (k==M-1 && l==M-1) {
                        cout << "Yes\n";
                        return 0;
                    }
                }
                if (isFail) break;
            }
        }
    }
    cout << "No\n";
}

Measured memory_bytes: 256