akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
	int a[3] , k , j;
	int max;

	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	scanf("%d", &k);

	j = a[0];
	max = 0;
	if (j < a[1]) {
		j = a[1];
		max = 1;
	}
	if (j < a[2]) {
		j = a[2];
		max = 2;
	}
	
	for (int i = 0; i < k; i++) {
		a[max] *= 2;
	}

	printf("%d\n", a[0] + a[1] + a[2]);

	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define ll long long
#define INF 1e9 + 1
#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;

int main() {
    int n, q, t;
    string name;
    queue<pair<string, int> > Q;
    cin >> n >> q;
    REP(i, n) {
        cin >> name >> t;
        Q.push(make_pair(name, t));
    }

    pair<string, int> u;
    int elaps = 0, a;

    while (!Q.empty()) {
        u = Q.front();
        Q.pop();
        a = min(u.second, q);
        u.second -= a;
        elaps += a;
        if (u.second > 0) {
            Q.push(u);
        } else {
            cout << u.first << " " << elaps << endl;
        }
    }
}


Measured memory_bytes: 6292
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var result =
                Math.Max(
                    Math.Max(
                        input[0] + input[1],
                        input[0] - input[1]
                    ),
                    input[0] * input[1]
                );
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long n;
    cin>>n;
    long a[n],i,c=0;
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n-1;i++)
    {
        if(a[i]==a[i+1])
        {
            c=1;
            break;
        }
    }
    if(c==0)
        cout<<"YES";
    else
        cout<<"NO";

    return 0;
}


Measured memory_bytes: 1792
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 1e5 + 5;

int n;
int arr[N];

int main()
{
  cin >> n;
  for(int i = 0 ; i < n ; i++) {
    cin >> arr[i];
  }
  vector<int> dp(n + 1);
  dp[0] = 0;
  for(int i = 1; i < n; i++) {
    dp[i] = abs(arr[i] - arr[i - 1]) + dp[i - 1];
    if(i > 1) dp[i] = min(dp[i], abs(arr[i] - arr[i - 2]) + dp[i - 2]);
  }
  cout << dp[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.*;

public class Main {
    public static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }


    }

    public static void main(String[] args) {
        FastReader s = new FastReader();
        Main obj = new Main();

       int h=s.nextInt();
       int n=s.nextInt();
       int[] arr=new int[n];
       int sum=0;
       for(int i=0;i<n;i++)
       {
           arr[i]=s.nextInt();
           sum+=arr[i];
       }
       if(sum>=h)
           System.out.println("Yes");
       else
           System.out.println("No");


    }






}

Measured memory_bytes: 33816
#include <iostream>
#include <iomanip>
#include <stdio.h>
using namespace std;
int main(void){
   int a,b,c;
   cin>>a>>b>>c;
   int ans = 0;
  for(int i=a; i<=b; i++){
   if(c%i == 0){
       ans++;
   }
  }
   cout<<ans<<endl;
}



Measured memory_bytes: 3100
#include <iostream>
#include<math.h>
 
using namespace std;
int main(){
  int n,f;
  cin>>n;
  for(int i=0;i<8;i++){
    f+=(n%int(pow(10,(i+1))))/int(pow(10,i));
  }
  if(n%f==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

using namespace std;

using ll = long long;
using vvll = vector<vector<ll>>;
using vll = vector<ll>;
using vpll = vector<pair<ll, ll>>;

using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    string s1, s2;
    cin >> s1 >> s2;
    vvi dp(s1.size() + 1, vi(s2.size() + 1, 0));
    for (int i = 1; i <= s1.size(); i++) {
        for (int j = 1; j <= s2.size(); j++) {
            if (s1[i - 1] == s2[j - 1]) {
                dp[i][j] = 1 + dp[i - 1][j - 1];
            } else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    string r = "";
    for (int i = s1.size(), j = s2.size(); i > 0 and j > 0;) {
        if (s1[i - 1] == s2[j - 1]) {
            r.append(s1, i - 1, 1);
            i--;
            j--;
        } else if (dp[i][j - 1] < dp[i][j]) {
            i--;
        } else {
            j--;
        }
    }
    if (r != "")
        reverse(r.begin(), r.end());
    else {
        cout << "";
        return 0;
    }
    cout << r;
    return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> ans;
    int temp = a;
    while (true)
    {
        int hoge = temp % b;
        temp += a;
        rep(i, ans.size())
        {
            if (ans[i] == hoge)
                goto here;
        }
        ans.push_back(hoge);
    }
here:
    rep(i, ans.size())
    {
        if (ans[i] == c)
        {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<VL> VVL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

ll Max=-1000000000,Min=1e9+1;
       
int main(){
    int a,b,x=0,y=0,z=0,n,m,h,k,w,sum2=0,ans=0;
    string s,t;
    bool f=true;
    cin >> n >> k;
    rep(i,n){
        cin >> x;
        if(x < abs(k-x))
            ans += 2*x;
        else{
            ans += 2*abs(k-x);
        }
    }
    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
N = input()
rabits = map(int,raw_input().split())
_rabits = [r - 1 for r in rabits]
count = 0
for i in range(N):
    j = _rabits[i]
    if _rabits[j] == i and i < j:
        count+=1
        #print('(%d,%d)' % (rabits[i],rabits[j]))
print count

Measured memory_bytes: 12140
package main

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

// const abcd = "abcdefghijklmnopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

// var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1}
// var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1}

// var dx = [...]int{0, 1, 0, -1}
// var dy = [...]int{1, 0, -1, 0}

var inf int = 1e13
var mod = 1000000007

// ---------------------------------------------------------
func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	n := next.Int()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = next.Int()
	}
	ans := 0
	var dfs func([]int, int)
	dfs = func(b []int, c int) {
		if c == n {
			if pow(b)%2 == 0 {
				ans++
			}
		} else {
			for i := -1; i < 2; i++ {
				b[c] = a[c] + i
				dfs(b, c+1)
			}
		}
	}
	dfs(a, 0)

	fmt.Println(ans)
}

func pow(a []int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		r *= a[i]
	}
	return r
}

// ---------------------------------------------------------

// Pair is liked C++ pair
type Pair struct {
	a, b int
}

// Pairs is sorted by []Pair struct
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a < p[j].a {
		return true
	} else if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return false
}

// -------------------------------
func in(c, a, z int) bool {
	return c >= a && c < z
}

func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}

func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func sum(a ...int) int {
	r := a[0]
	if len(a) > 1 {
		for i := 1; i < len(a); i++ {
			r += a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ---------- buffered scanner -----------------------------------------
type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) Int64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main(){
    long long n;
    cin >> n;
    long long ans = 2*n;
    for(long long i=1; i<=sqrt(n); i++){
        if(!(n%i)){
            if(ans > n/i + i) ans = n/i + i - 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 *
 * @author Usuario
 */
public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String x = in.nextLine();
        int cN = 0;
        int cS = 0;
        int cE = 0;
        int cW = 0;
        char ultimo = 'A';
        for (int i = 0; i < x.length(); i++) {
            ultimo = x.charAt(i);
            switch (ultimo) {
                case 'N':
                    cN++;
                    break;
                case 'S':
                    cS++;
                    break;
                case 'E':

                    cE++;
                    break;
                case 'W':
                    cW++;
                    break;
            }
        }

        if (((cN > 0 && cS > 0) || (cN == 0 && cS == 0)) && ((cE > 0 && cW > 0) || (cE == 0 && cW == 0))) {
            System.out.println("Yes");
            return;
        } 
        
        
        System.out.println("No");
    }

}

Measured memory_bytes: 22868
import collections # deque, Counter
import itertools # accumulate, compress, permutations(nPr), combinations(nCr)
# import bisect
import math # factorical（階乗)
# import heapq
# from fractions import gcd # >=Python3.5 # lcm（最小公倍数） = (a*b)//gcd(a,b)
# from fractions import Fraction
# from math import gcd # <Python3.5

# input = sys.stdin.readline
# def main():

#---------------------------------------------------------

n  = int(input())
li = [list(map(int,input().split())) for i in range(n)]

cnt = math.factorial(n-1)
ans = 0

chkli = itertools.permutations(range(n),2)

for i, v in enumerate(chkli):
    ans += ((abs((li[v[0]][0]) - (li[v[1]][0])) ** 2) + (abs((li[v[0]][1]) - (li[v[1]][1])) ** 2)) **.5 * cnt

print(ans/(math.factorial(n)))

Measured memory_bytes: 9716
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define pb push_back
#define mp make_pair
typedef pair<int,int> ii;
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	set<string> s;
	for(int i=0;i<n;i++)
	{
		string s1;
		cin>>s1;
		s.insert(s1);
	}
	cout<<s.size()<<endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<string>prise(N);
  for(int i=0;i<N;i++){
    cin >> prise.at(i);
  }
  int minus=0;
  sort(prise.begin(),prise.end());
  for(int i=1;i<N;i++){
    if(prise.at(i-1)==prise.at(i)){
      minus++;
    }
  }
  cout << N-minus << endl;
}

Measured memory_bytes: 9548
#include<iostream>
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
LL div(LL arr[], LL n) 
{ 
    unordered_set<LL> s; 
    LL max_ele = LLONG_MIN,i,j; 
    for (i = 0; i < n; i++) { 
        s.insert(arr[i]);
        max_ele = max(max_ele, arr[i]); 
    } 
    unordered_set<LL> res; 
    for ( i = 0; i < n; i++) { 
        if (arr[i] != 0) {  
            for (j = arr[i] * 2; j <= max_ele; j += arr[i]) { 
                if (s.find(j) != s.end()) 
                    res.insert(j); 
            } 
        } 
    } 
    unordered_map<LL,LL> mp; 
    for ( i = 0; i < n; i++) 
        mp[arr[i]]++; 
  
    unordered_map<LL,LL>::iterator it; 
    vector<LL> ans; 
    for (it = mp.begin(); it != mp.end(); it++) { 
        if (it->second >= 2) { 
            if (res.find(it->first) == res.end()) { 
                LL val = it->second; 
                while (val--) 
                    ans.push_back(it->first); 
            } 
        } 
        if (res.find(it->first) != res.end()) { 
            LL val = it->second; 
            while (val--) 
                ans.push_back(it->first); 
        } 
    } 
    return ans.size();
} 
int main()
{
	LL n;
	cin>>n;
	LL a[n];
	set<LL>s;
	map<LL,LL>m;
	for(LL i=0; i<n; i++)
	{
		cin>>a[i];
	}
	if(n==1)
	{
		cout<<1<<endl;
		return 0;
	}
	LL ans=n;
	ans-=div(a,n);
	cout<<ans<<"\n";
	
	

}


Measured memory_bytes: 32392
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
typedef long long int ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef pair<ll, ll>P;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];
 
ll par[100000], depth[100000];
static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}
#define yo 100001
//------------------変数-----------------------//
//-------------------関数----------------------//
 
ll ketawa(ll b, ll nn) {
	if (nn < b) {
		return nn;
	}
	return ketawa(b, nn / b) + nn%b;
}
int main() {

ll n;cin>>n;ll cnt=0;
REP(i,n){ll hoge,piyo;cin>>hoge>>piyo;cnt+=abs(hoge-piyo)+1;}cout<<cnt<<endl;
}

Measured memory_bytes: 256
a,b,c,d,e = map(int,input().split())
ans = 0

if a == 0:
    ans = 1

if b == 0:
    ans = 2

if c == 0:
    ans = 3

if d == 0:
    ans = 4

if e == 0:
    ans = 5

print(ans)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
vector<int> mp[105000];
int N, M;
int P[105000], Y[105000];
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 1; i <= M; i++) {
        cin >> P[i] >> Y[i];
        mp[P[i]].push_back(Y[i]);
    }
    for(int i = 1; i <= N; i++) {
        sort(mp[i].begin(), mp[i].end());
    }
    for(int i = 1; i <= M; i++) {
        string p = to_string(P[i]);
        auto itr = lower_bound(mp[P[i]].begin(), mp[P[i]].end(), Y[i]);
        int j = distance(mp[P[i]].begin(), itr) + 1;
        string x = to_string(j);
        while(p.size() < 6) p = "0" + p;
        while(x.size() < 6) x = "0" + x;
        cout << p << x << "\n";
    }
    return 0;
}


Measured memory_bytes: 7936
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define FF first
#define SS second
using namespace std ;
 
const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

#define N 10000005

lli cnt[N];

void solve()
{
    loopl(i,2,N)
    {
        cnt[i]++;
        for(lli j=i;j<N;j+=i)
            cnt[j]++;
    }

    lli n;
    cin>>n;

    cnt[1]=1;
    lli ans=0;

    loopl(i,1,n+1)
    {ans += cnt[i]*i; }

    cout<<ans<<endl;
}   

int main()
{
/////////////////////////////////////
    fastio;
////////////////////////////////////  

    lli t;
    t=1;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 81776
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MAXN = 200500;

ll t[MAXN];

ll pref[MAXN];
ll arr[MAXN];
ll n, k;
vector <ll> coord;

ll f(int x)
{
	return x & (-x);
}

ll get(int ind)
{
	ll res = 0;

	for (;ind != -1; ind -= f(ind + 1))
		res += t[ind];

	return res;
}

void upd(int ind, int val)
{
	for (;ind < (int)coord.size(); ind += f(ind + 1))
		t[ind] += val;
}

int main()
{
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
	{
		cin >> arr[i];
		arr[i] -= k;
	}

	coord.push_back(0);

	for (int i = 0; i < n; ++i)
	{
		pref[i + 1] = pref[i] + arr[i];
		coord.push_back(pref[i + 1]);
	}


	sort(coord.begin(), coord.end());
	coord.resize(unique(coord.begin(), coord.end()) - coord.begin());


	for (int i = 0; i < n + 1; ++i)
	{
		pref[i] = lower_bound(coord.begin(), coord.end(), pref[i]) - coord.begin();
	}

	ll res = 0;
	for (int i = 0; i < n + 1; ++i)
	{
		res += get(pref[i]);
		upd(pref[i], 1);
	}

	cout << res << '\n';
	return 0;	
}


Measured memory_bytes: 6640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,T;
	cin>>N>>T;
	int c[N],t[N];
	for(int i=0;i<N;i++){
		cin>>c[i]>>t[i];
	}
	int ans=1000000000;
	for(int i=0;i<N;i++){
		if(t[i]<=T){
			ans=min(ans,c[i]);
		}
	} 
	if(ans==1000000000){
		cout<<"TLE";
		return 0;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cstdio>
using namespace std;

typedef pair<string,bool> P;

int main()
{

  string worm;

  while(cin >> worm && worm != "0")
    {

      map<string,bool> state_record;
      queue<string> worm_state;
      bool NAflag = false;
      bool flag = false;
      int rank = 0;

      worm_state.push(worm);

      while(!flag && !NAflag)
        {

          string temp;
          int state_num = worm_state.size();
          int count = 0;

          NAflag = true;

          for(int j = 0; j < state_num && !flag;j++)
            {

              if(state_record[worm_state.front()] == true)
                {
                  worm_state.pop();
                  continue;
                }
              for(int i = 0; i < worm.length() - 1 && !flag; i++)
                {

                  temp = worm_state.front();

                  if(!temp.compare(i, 2, "rg") || !temp.compare( i, 2, "gr"))
                    {
                      temp.replace(i,2,"bb");
                      worm_state.push(temp);
                    }
                  else if(!temp.compare(i, 2, "rb") || !temp.compare(i, 2, "br"))
                    {
                      temp.replace(i,2,"gg");
                      worm_state.push(temp);
                    }
                  else if(!temp.compare(i, 2, "gb") || !temp.compare(i, 2, "bg"))
                    {
                      temp.replace(i,2,"rr");
                      worm_state.push(temp);
                    }

                  count = 0;

                  for(int t = 0; t < worm.length(); t++) if(temp[0]==temp[t]) count++;

                  if(count == worm.length()) flag = true;

                }

              state_record[worm_state.front()] = true;

              worm_state.pop();

              NAflag = false;

            }

          if(!worm_state.empty()) rank++;

          if(flag) cout << rank << endl;

          if(NAflag) cout << "NA" << endl;

        }

      state_record.clear();

    }

  return 0;

}

Measured memory_bytes: 2868
import math
a,b,x=map(int,input().split(" "))
if x>a**2*b/2:
    V=a**2*b-x
    L=2*V/(a**2)
    print(math.degrees(math.atan(L/a)))
else:
    L=2*x/(a*b)
    print(math.degrees(math.atan(b/L)))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N;
  cin>>N;
  cout<<(N+1)/2<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastio;
    int x, a, b;
    cin >> x >> a >> b;
    x -= a;
    cout << x % b << endl;
}

Measured memory_bytes: 3644
s = input()
K = int(input())
alpha = "bcdefghijklmnopqrstuvwxyza"
dic = {j : 25 - i for i, j in enumerate(alpha)}
inv_dic = {j : i for i, j in dic.items()}
s_ls = [dic[_s] for _s in s]
remain = K
ind = 0
len_s = len(s)
while ind < len_s and remain > 0:
    _s = s_ls[ind]
    if _s <= remain:
        remain -= _s
        s_ls[ind] = 0
    ind += 1
if remain > 0:
    s_ls[ind - 1] = (s_ls[ind - 1] - remain) % 26
print("".join([inv_dic[_s] for _s in s_ls]))

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

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<pair<int, int>, int> PP;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    A--;
    ll d = (C * D)/ GCD(C, D);
    ll cntA = A - (A / C + A / D - A / d);
    ll cntB = B - (B / C + B / D - B / d);
    cout << cntB - cntA << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 0
constexpr int kMod = 1000000007;
typedef long long LL;

constexpr int kNmax = 1e5 + 1;
LL sum[kNmax];

int main() {
  int n; std::cin >> n;
  std::cin >> sum[0];
  for (int i = 1; i < n; ++i) {
    LL a; std::cin >> a;
    sum[i] = sum[i-1] + a;
  }

#if DEBUG
  for (int i = 0; i < n; ++i) {
    std::cout << sum[i] << " ";
  }
  std::cout << std::endl;
#endif

  LL cnt1 = 0, cnt2 = 0;
  LL offset = 0;
  for (int i = 0; i < n; ++i) {
    LL v = sum[i] + offset;
    if (i%2 == 0) {
      if (v <= 0) {
        offset += (-v+1);
        cnt1 += (-v+1);
      }
    } else {
      if (v >= 0) {
        offset -= v+1;
        cnt1 += v+1;
      }
    }
  }

  offset = 0;
  for (int i = 0; i < n; ++i) {
    LL v = sum[i] + offset;
    if (i%2 == 0) {
      if (v >= 0) {
        offset -= v+1;
        cnt2 += v+1;
      }
    } else {
      if (v <= 0) {
        offset += (-v+1);
        cnt2 += (-v+1);
      }
    }
  }

  std::cout << std::min(cnt1, cnt2) << std::endl;
}


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

int main(){
	int A,B,C;
       cin >> A >> B >> C;
	if(A>=B && A>=C){
	 cout <<10*A + B + C <<endl;
	}
	else if(B>=C){
	 cout << A + 10*B + C << endl;
	}else {
	 cout << A + B + 10*C << endl;
       }
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, W: "List[int]"):

    res = float('inf')
    for i in range(len(W)):
        res = min(res, abs(sum(W[0:i])-sum(W[i:])))

    print(res)



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, W)

if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
constexpr int inf = 1000000;
constexpr int def = inf;
int N;
int R,G,B;
int main(){
    vector<int> v(3);
    cin>>v[0]>>v[1]>>v[2]>>N;
    vector<int> dp(3005);
    dp[0] = 1;
    for(int i=0;i<3;++i){
        for(int j=0;j<=N;++j){
            if(j + v[i] <= N) dp[j+v[i]] += dp[j];
        }
    }
    cout << dp[N] << endl;
    return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}
		return ans;
	}
	static long[] splitL() throws IOException
	{
		String[] cmd=br.readLine().split(" ");
		long[] ans=new long[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Long.valueOf(cmd[i]);
		}
		return ans;
	}
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		br=new BufferedReader(new InputStreamReader(System.in));
		long[]ar=splitL();
		long n=ar[0];
		long a=ar[1];
		long b=ar[2];
		long x=n/(a+b);
		long y=n%(a+b);
		long res=x*a+Math.min(y, a);
		System.out.println(res);
	}
}


Measured memory_bytes: 32608
#include<stdio.h>
int main(void)
{
	int a[5], time = 0;
	int i;
	int temp[5] = { 0 }, co = 0, min;

	for (i = 0; i < 5; i++) {
		scanf("%d", &a[i]);
	}
	min = a[0] % 10;
	for (i = 0; i < 5; i++) {
		if (a[i] % 10 <= min % 10 && a[i] % 10 != 0) {
			min = a[i];
		}
	}
	for (i = 0; i < 5; i++) {
		if (min == a[i]) {
			co++;
		}
	}
	for (i = 0; i < 5; i++) {
		if (a[i] != min) {
			time = time + a[i];
			if (a[i] % 10 != 0) {
				time = time + (10 - a[i] % 10);
			}
		}
		else {
			if (co >= 2) {
				time = time + a[i];
				if (a[i] % 10 != 0) {
					time = time + (10 - a[i] % 10);
				}
				co--;
			}
			else {
				time = time + min;
			}
		}
	}
	printf("%d\n", time);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int n;
cin >> n;
int sum = 0;
rep(i,n) {
    int l,r;
    cin >> l >> r;
    sum += r-l+1;
}

cout << sum << endl;

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace  std;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
int main(){
    int N, K; cin>>N>>K;
    vector<int> A(N), dp(K+1, 0);
    REP(i, N) cin>>A[i];
    for(int i=1; i<=K; i++){
        for(int j=0; j<N; j++){
            dp[i] |= A[j]<=i and !dp[i-A[j]];
        }
    }
    if(dp[K]) cout <<"First" <<endl;
    else cout <<"Second"<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int n,m,x,ma[20][20]={},ans=-1,f[20]={},pr[20]={};

bool check(){
	int i;
	for(i=1;i<=m;++i)
		if(f[i]<x)
			return 0;
	return 1;
}

int min(int x,int y){
	if(x==-1)
		return y;
	if(x>y)
		return y;
	return x;
}

void dfs(int deep,int co){
	if(check()){
		ans=min(ans,co);
		return;
	}
	if(deep==n+1){
		return;
	}
	int i;
	dfs(deep+1,co);
	for(i=1;i<=m;++i)
		f[i]+=ma[deep][i];
	dfs(deep+1,co+pr[deep]);
	for(i=1;i<=m;++i)
		f[i]-=ma[deep][i];
	
}

int main(){
	cin>>n>>m>>x;
	int i,j;
	for(i=1;i<=n;++i){
		cin>>pr[i];
		for(j=1;j<=m;++j)
			cin>>ma[i][j];
	}
	dfs(1,0);
	cout<<ans;
	
	
	return 0;
}

Measured memory_bytes: 3632
import sys
line = sys.stdin.readline()
num = []
while line:
	a,op,b = line.split()
	if op == "+":
		num.append(int(a)+int(b))
	elif op == "-":
		num.append(int(a)-int(b))
	elif op == "*":
		num.append(int(a)*int(b))
	elif op == "/":
		num.append(int(a)/int(b))
	else:
		break
	line = sys.stdin.readline()
for i in num:
	print str(i)

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin>>n>>s;
  int r=0,g=0,b=0;
  rep(i,n){
    if(s[i]=='R'){
      r++;
    }
    else if(s[i]=='G'){
      g++;
    }
    else{
      b++;
    }
  }
  ll sum=1LL*r*g*b;
  rep(i,n-2){
    REP(j,i,n){
      if(j+j-i<n){
        if(s[i]!=s[j] && s[i]!=s[j+j-i] && s[j]!=s[j+j-i]){
          sum--;
        }
      }
    }
  }
  cout<<sum<<'\n';
  return(0);
}


Measured memory_bytes: 3620
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

import math

a,b,h,m=nm()

dh = (h+m/60)/12*360
dm = m/60*360

theta = abs(dh-dm)
if theta >= 180:
  theta = 360-theta

ans = a**2+b**2-2*a*b*math.cos(math.radians(theta))

print(math.sqrt(ans))

Measured memory_bytes: 9456
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;

const int MOD = 1e9 + 7;
ll pSum[200001];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N, K; cin >> N >> K;
	for (int i = 0; i < 200000; i++) pSum[i + 1] = (pSum[i] + i + 1);


	ll ans = 0;
	for (int i = K; i <= N + 1; i++) 
		ans = (ans + (pSum[N] - pSum[N - i]) - pSum[i - 1] + 1 + MOD) % MOD;
	cout << ans << '\n';
	return 0;
}

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

using namespace std;

int dp[101][20000];
int main(){
    int n,W;
    cin >> n >> W;
    vector<int> v(n);
    vector<int> w(n);
    for(int i=0;i<n;i++)cin >> v[i] >> w[i];
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=W;j++){
            if(j-w[i]>=0&&dp[i][j-w[i]]!=0){
                dp[i+1][j] = max(dp[i+1][j],dp[i][j-w[i]]+v[i]);
            }
        }
        for(int j=0;j<=W;j++){
            dp[i+1][j] = max(dp[i][j],dp[i+1][j]);
        }
    }
    int ans = 0;
    for(int i=0;i<=W;i++){
        ans = max(dp[n][i],ans);
    }
    cout << ans-1 << endl;
    return 0;
}


Measured memory_bytes: 7424
//use std::convert::TryInto;
#![allow(dead_code)]

fn main(){
    let nk: Vec<i32> = input_vec();
    let k = nk[1];
    let mut p: Vec<i32> = input_vec();
    // input end

    let mut ans = 0;
    p.sort();
    for i in 0..k {
        ans += p[i as usize];
    }
    println!("{}", ans);
}


/*
 * input function
 */
fn input<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


fn input_vec<T: std::str::FromStr>() -> Vec<T> {
    input::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap()).collect()
}

fn input_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| input_vec()).collect()
}

Measured memory_bytes: 2108
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	a,b,n = readline() |> split |> parseMap
	if n%b==0
		x = n-1
		println(div(a*x,b)-a*div(x,b))
	else
		x = n
		y = div(n,b)*b-1
		println(max(div(a*x,b)-a*div(x,b),div(a*y,b)-a*div(y,b)))
	end
end

main()

Measured memory_bytes: 163752
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N,K;
  cin>>N>>K;
  long long a[N+110]={};
  long long b[N]={};
  for  (int i=0; i<N+109; i++){
  a[i+1]=1000000000;
  cin>>b[i];}
  a[0]=0;
   for (int i=0; i<N; i++){
   for(int j=1;j<=K;j++){
  a[j+i]=min(a[j+i],abs(b[i+j]-b[i])+a[i]);}}
  
    cout<<a[N-1]<<endl;}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>

using namespace std;

int s_sort(int A[], const int N){
    int cnt = 0;
    
    for(int i = 0; i < N; ++i){
        int min = i;
    
        for(int j = i; j < N; ++j)
            if(A[j] < A[min])
            min = j;
            if(i != min){
                swap(A[i],A[min]);
                ++cnt;
            }
    }
    
    return cnt;
}

int main(){
    int N;
    scanf("%d",&N);
    int A[N];
    for(int i = 0; i < N; ++i)
       scanf("%d", &A[i]);
       
    int cnt = s_sort(A,N);
    
    for(int i = 0; i < N; ++i){
        if(i) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n%d\n",cnt);
    
    return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

int gcd(int a, int b) {
  return b ? gcd(b, a % b) : a;
}

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

  LL ans = gcd(a[0], a[1]);
  for (int i = 2; i < n; i ++) {
    ans = gcd(ans, a[i]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    ll n, m, c[100010];
    bool b[100010];
    cin >> n >> m;
    for (int i = 0; i <= n; i++) b[i] = true;
    for (int i = 0; i < m; i++) {
        ll a;
        cin >> a;
        b[a] = false;
    }
    
    c[0] = 1;
    for (int i = 1; i <= n; i++) {
        if (!b[i]) c[i] = 0;
        else if (i == 1) c[i] = c[i - 1];
        else c[i] = c[i - 1] + c[i - 2];
        c[i] %= 1000000007;
    }
    
    cout << c[n] << endl;
    
}


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

#define endl '\n';
typedef long long ll;

void solve() {
	int interval, quant, end_time;
	cin >> interval >> quant >> end_time;
	int ans = end_time / interval * quant;
	cout << ans;
}

int main() {
	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf()); 
	#endif
	solve();
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int i,ans=0;
  for(i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main(){
    int n;cin>>n;
    vector<int>v(n);
    vector<int>c(n);
    rep(i,n)cin>>v[i];
    rep(i,n)cin>>c[i];
    int max = 0;
    rep(i,n){
        if(v[i]>c[i]){
            max += v[i]-c[i];
        }
    }
    cout<<max<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int a, b;

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

    void run() {
        FastReader sc = new FastReader();
        a = sc.nextInt();
        b = sc.nextInt();
        solve();
    }

    void solve() {
        if (a <= b) {
            System.out.println(a);
        } else {
            System.out.println(a - 1);
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 22612
N=int(input())
labc=[]
for i in range(N):
    labc.append(list(map(int,input().split())))
ldp=[[0,0,0] for i in range(N)]
ldp[0][0]=labc[0][0]
ldp[0][1]=labc[0][1]
ldp[0][2]=labc[0][2]
for i in range(1,N):
    ldp[i][0]=max(ldp[i-1][1],ldp[i-1][2])+labc[i][0]
    ldp[i][1]=max(ldp[i-1][2],ldp[i-1][0])+labc[i][1]
    ldp[i][2]=max(ldp[i-1][0],ldp[i-1][1])+labc[i][2]
print(max(ldp[N-1]))


Measured memory_bytes: 47408
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
ll hell=pow(10,9)+7;
void solve(){
	ll n;
	cin>>n;
	ll res=1,sum=1,tr=1;
	for(ll i=0;i<n;i++){
		res=(res*10)%hell;
		sum=(sum*9)%hell;
		tr=(tr*8)%hell;
	}
	res-=2*sum-tr;
	res%=hell;
	if(res<0)
		res+=hell;
	cout<<res;

}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++){
        solve();
    }
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}

Measured memory_bytes: 3772
#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define M 1000000007
#define SI(x) scanf("%d", &x)
#define PI(x) printf("%d\n", x)
#define SL(x) scanf("%I64d", &x)
#define PL(x) printf("%I64d\n", x)
#define PB push_back
#define MP make_pair
 
using namespace std;
 
int main()
{
 
    string s1, s2;
    cin >> s1 >> s2;
 
    if(s1.length() > s2.length())
        return cout << "GREATER", 0;
 
    if(s1.length() < s2.length())
        return cout << "LESS", 0;
 
    for(int i = 0; i<s1.length(); i--)
    {
        if(s1[i]>s2[i])
            return cout << "GREATER", 0;
 
        if(s2[i]>s1[i])
            return cout << "LESS", 0;
    }
 
    cout << "EQUAL";
}

Measured memory_bytes: 256
N, M = map(int, input().split())
lst = []

for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        lst.append(b)
    elif b == N:
        lst.append(a)
        
lst.sort()
flg = 0

for i in range(len(lst) - 1):
    if lst[i] == lst[i + 1]:
        flg = 1
        break
        
if flg:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 59736
#include<stdio.h>
#include<string.h>

int main(){
	long long a,b;
	char c;
	scanf("%lld %c %lld",&a,&c,&b);
	if(c=='+'){
		printf("%lld",a+b);
	}
	else{
		printf("%lld",a-b);
	}
}

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

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

//    long long A[N], B[N], C[N];
    vector<long long> A(N), B(M), C(M);
    for (long long i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    vector<pair<long long, long long> > pairs(M);
    long long cnt = 0;
    for(int i = 0; i< M; i++){
        //インデックスと値をpairとして保存する
        //i=2のときのsecondを取り出すには、pairs[2].secondとする．
        cin >> B[i] >> C[i];
        cnt += B[i];
        pairs[i] = make_pair(C[i], B[i]);
    }
    sort(pairs.begin(), pairs.end(), greater<pair<long long, long long> >());

    int k = 0;
    for (int i = 0; i < N; i++){
        if(pairs[k].first > A[i]){
            A[i] = pairs[k].first;
            pairs[k].second--;
            if(pairs[k].second == 0) k++;
            if(k > cnt) break;
        }else{
            break;
        }
    }

    long long sums = 0;
    for (int i = 0; i < N; i++)
    {
        sums += A[i];        
    }
    cout << sums << endl;
    
}

Measured memory_bytes: 4224
#include <iostream>
using namespace std;
int main()
{
	long long int N;
	cin >> N;
	long long int result = 0;
	
	for(long long int i = 1;i*i<=N;i++){
		if(N%i==0){
			result = i+N/i-2;
		}
	}
	
	std::cout << result <<  std::endl;
	
}


Measured memory_bytes: 256