akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

template <typename T>
struct edge
{
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x)
    {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

//Weighted edge set
template <typename T>
using Edges = vector<edge<T>>;

//Weighted graph
template <typename T>
using WeightedGraph = vector<Edges<T>>;

//Unweighted graph (adjacency matrix)
//Initialize : vector<vector<int>>(N, vector<int>(N, 0))
template <typename T>
using UnweightedGraph = vector<vector<T>>;

//distance matrix
template <typename T>
using Matrix = vector<vector<T>>;

int N, Q;
vector<int> weight, visited;
UnweightedGraph<int> G;

void bfs()
{
    queue<int> pq;
    pq.push(0);
    while (!pq.empty())
    {
        int v = pq.front();
        pq.pop();
        visited[v] = true;
        for (auto &u : G[v])
        {
            if (visited[u] == false)
            {
                weight[u] += weight[v];
                pq.push(u);
            }
        }
    }
    return;
}

int main()
{
    cin >> N >> Q;
    G = UnweightedGraph<int>(N);
    weight = vector<int>(N);
    visited = vector<int>(N);
    for (int i = 1; i < N; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    for (int i = 0; i < Q; i++)
    {
        int p, x;
        cin >> p >> x;
        p--;
        weight[p] += x;
    }

    bfs();

    for (int i = 0; i < N; i++)
    {
        cout << weight[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 16372
#解説AC
def main():
    N = int(input())
    adj = [list(map(int, input().split())) for _ in range(N)]

    dp = [0] * (2**N)
    for s in range(1, 2**N):
        tmp = 0
        for i in range(N):
            for j in range(i+1, N):
                if s>>i & 1 and s>>j & 1:
                    tmp += adj[i][j]
        t = (s-1) & s
        while t:
            tmp2 = dp[t] + dp[s^t]
            if tmp2 > tmp:
                tmp = tmp2
            t = (t - 1) & s
        dp[s] = tmp

    print(dp[-1])


if __name__ == '__main__':
    main()


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


int32_t main()
{
    int n,l;
    cin >> n >> l;

    int sum = 0;
    int mn = 10000;
    int realmn =10000;
    for(int i=1;i<=n;++i)
    {
        sum += l-1 + i;
        if(abs(l-1 + i) < mn)
        {
        	mn = abs(l-1 + i);
        	realmn = l-1+i;
        }
        //mn = min(mn,abs(l-1 + i));
    }

    cout<<sum - realmn<<endl;
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	string str;
	cin >> str;
	int b[26] = {0};

	for(int i=0 ; i<str.size() ; i++)
		b[str[i]-'a']++;

	for(int i=0 ; i<26 ; i++)
	{
		if(b[i]&1)
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
    
int main()
{
    int n, max=0, sum=0;
    cin >> n;
    while(n--) {
      int L; cin >> L;
        sum += L;
        if (max < L)
          max = L;
    }
    sum -= max;
    if (max<sum)
    {
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }   
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;


int main(){
    ll n;
    cin >> n;
    vector<ll> p(n);
    rep(i, n)   cin >> p[i];
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i, n)   a[i] = i+1;
    rep(i, n)   b[i] = n-i;

    rep(i, n){
        for(ll j = p[i]-1; j < n; j++)    a[j] += i+1;
        for(ll j = p[i]-1; 0 <= j; j--)   b[j] += i+1;
    }

    string pt = "";
    rep(i, n){
        cout << pt << a[i];
        pt = " ";
    }
    cout << endl;
    pt = "";
    rep(i, n){
        cout << pt << b[i];
        pt = " ";
    }
    cout << endl;
    

    return 0;
}

Measured memory_bytes: 1152
using System;

class Program
    {
        static void Main(string[] args)
        {

            string[] num = Console.ReadLine().Split();
            double A = int.Parse(num[0]);
            double B = int.Parse(num[1]);

            var ans = Math.Ceiling((B - 1) / (A - 1));

            Console.WriteLine(ans);
        }
    }

Measured memory_bytes: 11220
use proconio::input;

fn main() {
	input! {
		n: i32,
		d: i64,
	}
	
	let mut ans = 0;
	
	for _i in 0..n {
		input! {
			x: i64,
			y: i64,
		}
		if x * x + y * y <= d * d {
			ans += 1;
		}
	}
	
	println!("{}", ans);
}

Measured memory_bytes: 4912
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long mod = 1e9 + 7;
    int s;
    cin >> s;
    long long dp[s + 2];
    for(int i = 0; i <= s; i++){
        dp[i] = 0;
    }
    dp[0] = 1;
    for(int i = 1; i <= s; i++){
        for(int j = 0; j <= i - 3; j++){
            dp[i] = (dp[i] + dp[j]) % mod;
        }
    }
    cout << dp[s];
    return 0;
}

Measured memory_bytes: 3616
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int ans = 0;
        int r = k/2;
        int q = k%2;
        if (q==0) 
            ans = r * r;
        else
            ans = (r+1) * r;
        System.out.println(ans);

        sc.close();
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	map<ll, int> mp;
	for(int i = 0; i < n; ++i) {
		ll a;
		cin >> a;
		mp[a]++;
	}
	
	vector< pair<ll, int> > p;
	for(auto& x : mp) {
		if( x.second >= 2 ) {
			p.push_back( make_pair(x.first, x.second) );
		}
	}
	
	if( p.empty() ) { 
		cout << 0 << endl;
		return 0;
	}
	
	ll ans = 1LL;
	int en = p.size();
	
	if( p[en - 1].second >= 4 ) ans = p[en - 1].first * p[en - 1].first;
	else ans = p[en - 1].first * p[en - 2].first;
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 6528
var
	s:String;
	i,m,t,n:Longint;
begin
	readln(s);
	n:=length(s);
	m:=n;
	for i:=1 to n-1 do begin
		if s[i]<>s[i+1]then begin
			t:=i;
			if t<n-i then t:=n-i;
			if m>t then m:=t;
		end;
	end;
	writeln(m);
end.

Measured memory_bytes: 256
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];


int main()
{
    ll n,i,j,cc=0;
    cin>>j>>n;ll ara[n];for(i=0;i<n;i++)cin>>ara[i],cc+=ara[i];
    cout<<(cc>=j ? "Yes" : "No")<<endl;
return 0;
}


Measured memory_bytes: 5760
# Fast IO (only use in integer input)

# import os,io
# input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

import heapq

T = int(input())
for _ in range(T):
    N = int(input())
    frontCamel = []
    backCamel = []
    indifferentCamel = []
    Happiness = 0
    for _ in range(N):
        k,l,r = map(int,input().split())
        if l > r:
            frontCamel.append((k,l-r))
            Happiness += r
        elif r > l:
            backCamel.append((N-k,r-l))
            Happiness += l
        else:
            indifferentCamel.append((k,0))
            Happiness += l
    frontQ = []
    backQ = []
    frontCamel.sort(key = lambda x:x[0])
    backCamel.sort(key = lambda x:x[0])
    for Camel in frontCamel:
        if Camel[0] == 0:
            continue
        if Camel[0] > len(frontQ):
            heapq.heappush(frontQ,Camel[1])
        else:
            if frontQ[0] < Camel[1]:
                heapq.heapreplace(frontQ,Camel[1])
    for Camel in backCamel:
        if Camel[0] == 0:
            continue
        if Camel[0] > len(backQ):
            heapq.heappush(backQ,Camel[1])
        else:
            if backQ[0] < Camel[1]:
                heapq.heapreplace(backQ,Camel[1])
    Happiness += sum(frontQ)
    Happiness += sum(backQ)
    print(Happiness)


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

using namespace std;

int main()
{
	//
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n, w;
    cin>>n>>w;
    long long int wt[n], val[n];
    for(int i=0; i<n; i++) cin>>wt[i]>>val[i];

    vector<vector<long long int>> dp(n+1, vector<long long int>(w+1, 0));
	for(long long int i=0; i<=n; i++){
		for(long long int j=0; j<=w; j++){
			if(i==0 || j==0)
				dp[i][j] = 0;
			else{
				if(wt[i-1] <= j)
					dp[i][j] = max(dp[i-1][j], dp[i-1][j-wt[i-1]]+val[i-1]);
				else
					dp[i][j] = dp[i-1][j];
			}
		}
	}
	cout<<dp[n][w]<<endl;
    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in(),M=in();
	vector<int> P(N,-1);
	REP(i,M){
		int s=in(),c=in();
		if(s==1 && c==0 && N>1){
			out(-1);
			return 0;
		}
		if(P[s-1]!=-1){
			if(P[s-1]!=c){
				out(-1);
				return 0;
			}
		}
		P[s-1]=c;
	}
	REP(i,N){
		if(P[i]==-1){
			if(!i && N>1) P[i]=1;
			else P[i]=0;
		}
		cout<<P[i];
	}
	out();
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, x, a[30]; bool dp[1000001], prime[1000001];
int main() {
	for(int i = 2; i <= 1000000; i++) prime[i] = true;
	for(int i = 2; i <= 1000; i++) {
		if(!prime[i]) continue;
		for(int j = i * i; j <= 1000000; j += i) prime[j] = false;
	}
	while(scanf("%d%d", &n, &x), n) {
		for(int i = 0; i < n; i++) scanf("%d", &a[i]); sort(a, a + n);
		for(int i = 0; i < x; i++) dp[i + 1] = false; dp[0] = true;
		for(int i = 1; i <= x; i++) {
			for(int j = 0; j < n && i >= a[j]; j++) {
				if(dp[i - a[j]]) {
					dp[i] = true; break;
				}
			}
		}
		bool flag = false;
		for(int i = x; i >= 1; i--) {
			if(dp[i] && prime[i]) {
				printf("%d\n", i); flag = true; break;
			}
		}
		if(!flag) printf("NA\n");
	}
}

Measured memory_bytes: 4524
#include <algorithm>
#include <cstdio>
typedef long long ll;
ll arr[100005], lazy[100005], coef[100005];
int main()
{
	// freopen("AGC003-E.in", "r", stdin);
	int n, q;
	scanf("%d%d", &n, &q);
	arr[0] = n;
	for (int i = 1; i <= q; i++)
		scanf("%lld", arr + i);
	q = 0;
	for (int i = 0; arr[i]; i++)
	{
		while (q && arr[i] <= arr[q - 1])
			q--;
		arr[q++] = arr[i];
	}
	coef[q - 1] = 1;
	for (int i = q - 1; i >= 0; i--)
	{
		ll k = arr[i];
		while (true)
		{
			int pos = std::upper_bound(arr, arr + i, k) - arr - 1;
			if (pos < 0)
				break;
			coef[pos] += coef[i] * (k / arr[pos]);
			k %= arr[pos];
		}
		if (k)
			lazy[k - 1] += coef[i];
	}
	for (int i = n - 1; i >= 0; i--)
		lazy[i] += lazy[i + 1];
	for (int i = 0; i < n; i++)
		printf("%lld\n", lazy[i]);
	return 0;
}


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

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

    sort(jobs.begin(), jobs.end());
    ll endTime = 0;
    bool success = true;
    for(int i = 0; i < N; i++){
        endTime += jobs[i].second;
        if(endTime > jobs[i].first){
            success = false;
        }
    }

    if(success){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 9592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
int gcd(int a, int b){if (a%b == 0){return(b);}else{return(gcd(b, a%b));}}
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;
long long modinv(long long a, long long m=MOD) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m; if (u < 0) u += m;return u;}
/*MODの割り算の際にa/＝b;をa *= modinv(b,MOD);とする。*/

int main(){

    int N;cin >> N;
    int a;cin >> a;
    Rep(i,N-1){
        int b;cin >> b;
        a = gcd(a,b);
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 3612
package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)
	if n%2 > 0 {
		fmt.Println("No")
	} else if n > 1 {
		t1 := s[:n/2]
		t2 := s[n/2:]
		if t1 == t2 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	} else {
		fmt.Println("No")
	}
}

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

#define fori(i,a,b)    for(int i=a;i<=b;i++)
#define ford(i,a,b)   for(int i=a;i>=b;i--)
#define all(a)        a.begin(), a.end()
#define in(c,x)       ((c).find(x) != (c).end())
#define isp(c,x)      (find(all(c),x) != (c).end())
#define pb             push_back
#define ppb            pop_back
#define sz(x)          (int)x.size()
#define fill(a,v)      memset(a, v, sizeof a)
#define fs first
#define sc second
#define ub upper_bound
#define lb lower_bound
#define en '\n'

typedef long long int lli;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair< int, int > pii;
typedef pair< lli, lli > plli;
typedef list<int> li;
typedef map<int, int> mi;
typedef map<lli, lli> mlli;
lli gcd(lli a,lli b){return (!b)?a:gcd(b,a%b);}
int t = 1; int ti;




const int N = 1e5 + 5;
lli mw, w[105], v[105], n, dp[105][N];


void solve(){
    cin>>n>>mw;

    fori(i, 1, n)
    cin>>w[i]>>v[i];

    fori(i, 0, mw){
        dp[0][mw] = 0;
    }

    fori(i, 0, n){
        dp[i][0] = 0;
    }


    fori(ni, 1, n){
        fori(wi, 1, mw){
            if(w[ni] <= wi){
                dp[ni][wi] = max(dp[ni][wi], dp[ni-1][wi-w[ni]] + v[ni]);
            }

            dp[ni][wi] = max(dp[ni][wi], dp[ni-1][wi]);
        }
    }

    cout<<dp[n][mw];
}
//THINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // cin>>t;

    // for(ti= 1; ti <= t; ti++)
    solve();

//    cout<<"\nTHINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL";
}

Measured memory_bytes: 79360
n = gets.to_i
a = 2
b = 1
c = 0

def aaa(n, a, b, c)
  return 1 if n == 1
  i = 1
  while (n > i)
    c = a + b
    a = b
    b = c
    i += 1
  end
  return c
end

puts aaa(n, a, b, c)

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){

    int n;
    cin >> n;

    int x = (double)n * 100 / 108;
    if( 1.08 * x  < n + 1 && 1.08 * x >= n ){
        cout << (int)x << endl;
    }
    else if(1.08 * (x+1)  < n + 1 && 1.08 * (x+1) >= n){
        cout << x + 1 << endl;
    }
    else if(1.08 * (x-1)  < n + 1 && 1.08 * (x-1) >= n){
        cout << x - 1 << endl;
    }
    else{
        cout << ":(" << endl;
    }


}

Measured memory_bytes: 256
a,b,c,x,y=map(int,input().split())
ans=[0]*3
ans[0]+=min(x,y)*c*2
if x>y:
    ans[0]+=(x-y)*a
else:
    ans[0]+=(y-x)*b
ans[1]+=c*2*max(x,y)
ans[2]+=x*a+y*b
print(min(ans))

Measured memory_bytes: 3064
#pragma comment (linker, "/STACK:256000000")
 
#define _USE_MATH_DEFINES
#define _CRT_NO_DEPRECEATE
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <memory.h>
#include <sstream>
#include <cassert>
#include <ctime>
#include <complex>
 
//#include <random>
 
using namespace std;
 
 
double PI = 3.1415926535897932384626433832795;
long double EPS = 1e-12;
 
typedef unsigned int uint32;
typedef long long int64;
typedef unsigned long long uint64;
 
typedef pair<int, int> pii;
const int MAXN = 2000;
const int ROOT = 333;


int n, x;
int64 a[MAXN], b[MAXN];

void solve()
{
	cin >> n >> x;
	for(int i = 0; i < n; ++i)
	{
		cin >> a[i];
		b[i] = a[i];
	}
	int64 ans = 1e18;
	for(int j = 0; j < n; ++j)
	{
		for(int i = n - 1; i >= 0; --i)
		{
			b[(i + j) % n] = min(b[(i + j) % n], a[i]); 
		}
		int64 sum = 0;
		for(int i = 0; i < n; ++i)
			sum += b[i];
		ans = min(ans, sum + x *(int64) j);
	}

	cout << ans;
}

 
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _MY_DEBUG
    freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
#else
    //freopen(TASK ".in", "rt", stdin); freopen(TASK ".out", "wt", stdout);
#endif
    srand(1313);
	
	int t = 1;
	//cin >> t;

	for(int i = 0; i < t; ++i)
	{
		solve();
		
	}
	
    return 0;
}   

Measured memory_bytes: 256
/************************************************************
	> File Name: b.cpp
	> Author: TSwiftie
	> Mail: 2224273204@qq.com 
	> Created Time: Sat 04 Apr 2020 04:54:33 PM CST
************************************************************/

#pragma GCC optimize(2)
#include <bits/stdc++.h>
#include <ext/rope>
#define lowbit(x) (x&-x)
#define SZ(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define lc (o<<1)
#define rc (o<<1|1)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 0x3f3f3f3f;
const ll INF_ll = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1.0);
const double EPS = 1e-8;
signed main(void){
	IOS;
	ll x;
	cin >> x;
	ll ans = x/500*1000+(x%500)/5*5;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
from itertools import permutations
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    c=SI()
    print(chr(ord(c)+1))

main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int r,g;cin >> r >> g;
	cout << 2*g-r << endl;
}

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

const lint MOD = 1e9 + 7;
string s1, s2;

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

    lint ans = 1, cur = 0;
    if(s1[0] == s2[0]) {ans *= 3; cur++;}
    else {ans *= 6; cur += 2;}

    while(cur<n){
        if(s1[cur] == s2[cur]){
            if(s1[cur-1] == s2[cur-1]) {ans *= 2;}
            cur++;
        }
        else{
            if(s1[cur-1] == s2[cur-1]) {ans *= 2;}
            else {ans *= 3;}
            cur += 2;
        }
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  int n;
    scanf("%d%",&n);
  int Sum=0;
  int Min=1000000;
  for(int i=0;i<n;++i){
    int a;
      scanf("%d",&a);
    if(a%10!=0){
      chmin(Min,a);
    }
      Sum+=a;
  }

  if(Sum%10==0){
    Sum-=Min;
  }
  int ans=max(0,Sum);
  printf("%d\n",ans);
}

Measured memory_bytes: 256
n=int(input())
l=[[]for i in range(n)]
ans=set()
ll=[set() for i in range(n)]
c=1
ab=[]
from collections import Counter
ans2=Counter()
for i in range(n-1):
    a,b=[int(j)-1 for j in input().split()]
    ab.append((a,b))
    l[a].append(b)
    #l[b].append(a)

for i in range(n):
    c=1
    for j in l[i]:
        while True:
            if (c not in ll[j]) and (c not in ll[i]):
                ll[j].add(c)
                ll[i].add(c)
                ans.add(c)
                ans2[(i,j)]=c
                break
            else:
                c+=1
print(len(ans))
#print(ans)
#print(ans2)
for i,j in ab:
    print(ans2[(i,j)])






Measured memory_bytes: 66840
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    int min1,min2;
    if(a<=b)
        min1=a;
    else
        min1=b;
    if (min1==a)
    {
        if(b<=c)
            min2=b;
        else
            min2=c;
    }
    else
    {
        if(a<=c)
            min2=a;
        else
            min2=c;
    }

    cout<<min1+min2;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	double dis = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	cout << fixed << setprecision(5) << dis;
	return 0;
}


Measured memory_bytes: 3288
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    vector<char>s, t;
    for (int i = 0; i < S.size(); i++)s.push_back(S[i]);
    for (int i = 0; i < T.size(); i++)t.push_back(T[i]);
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    string ansS, ansT;
    for (int i = 0; i < s.size(); i++)ansS += s[i];
    for (int i = 0; i < t.size(); i++)ansT += t[i];

    if (ansS < ansT)cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#if defined(LOCAL)
#define PROBLEM_NAME "e"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define I(x, ...) (x)
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define I(x, ...) (x)
#define C(x, ...) ;
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ii = pair<int,int>; using lu = unsigned long long; using l = long long;
using vs = vector<string>; using vii = vector<ii>;
using vl = vector<l>; using vvl = vector<vl>; using vvvl = vector<vvl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)
#define VVL(x, a, b, i) vvl x(a, vl(b, l(i)));
#define VVVL(x, a, b, c, i) vvvl x(a, vvl(b, vl(c, l(i))));

void solve(istream& cin, ostream& cout) {
  l n, k, q; cin >> n >> k >> q;
  vl v(n); F(i, 0, n) cin >> v[i];
  auto start = v;
  sort(all(start));
  I(start);
  l z = INF;
  F(i, 0, n - q - k + 2) {
    if (i and start[i] == start[i - 1]) continue;
    l x = start[i];
    I(x);
    auto w = v;
    vl pick;
    l a = 0;
    while (a < n) {
      while (a < n and w[a] < x) a++;
      l b = a + 1;
      while (b < n and w[b] >= x) b++;
      I(a, b);
      if (I(b - a - k + 1) > 0) {
        sort(w.begin() + a, w.begin() + b);
        F(j, 0, b - a - k + 1) pick.emplace_back(w[a + j]);
      }
      a = b;
    }
    if (pick.size() < q) continue;
    sort(all(pick));
    z = min(z, pick[q - 1] - pick[0]);
  }
  cout << z << endl;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 384
#include<stdio.h>

int fib[44];
int fibonacci (int n){
  int f,i=2;
  fib[0]=1;
  fib[1]=1;
  for(i=2;i<=n;i++){
    fib[i]=fib[i-1]+fib[i-2];
  }
  return fib[n];
}

int main(){
  int n;
  scanf("%d",&n);
  printf("%d\n",fibonacci(n));
  return 0;
}



Measured memory_bytes: 2108
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int H, W, K;
    in3(H, W, K);

    vs c(H);
    inN(c, H);

    ll black = 0;
    rep(i, H)
    {
        rep(j, W)
        {
            if (c[i][j] == '#') black++;
        }
    }

    ll count = 0;

    rep(bith, (1 << H))
    {
        rep(bitw, (1 << W))
        {
            ll tmp = 0;

            rep(i, H)
            {
                rep(j, W)
                {
                    if ((bith & (1 << i) || bitw & (1 << j)) && c[i][j] == '#')
                    {
                        tmp++;
                    }
                }
            }

            if (black - tmp == K)
            {
                count++;
            }
        }
    }

    outl(count);

    return 0;
}

Measured memory_bytes: 3664
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		string S = GetString();
		bool[] exists = new bool[26]; 
		for(int i = 0; i < S.Length; i++)
			exists[(int)(S[i] - 'A')] = true;

		if(exists[(int)('N' - 'A')] ^ exists[(int)('S' - 'A')])
		{
			Console.WriteLine("No");
			return;
		}
		if(exists[(int)('W' - 'A')] ^ exists[(int)('E' - 'A')])
		{
			Console.WriteLine("No");
			return;
		}
		Console.WriteLine("Yes");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 11092
import java.util.Scanner;
import java.util.ArrayList;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();

        int x = a*b;
        int y = a+b;
        int z = a-b;
        if(x >= y && x >= z) {
            System.out.println(x);
        }else if(y > x && z <=y) {
            System.out.println(y);
        }else {
            System.out.println(z);
        }
    }

}

Measured memory_bytes: 22228
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head, tail,n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b){ return a < b ? a : b;}

int main(){
  int elaps = 0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);

  for(i = 1; i<=n; i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head = 1;
  tail = n + 1;

  while(head != tail){
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if( u.t > 0) enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}



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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;
ll A, B, C, D;

int main() {
	cin >> N;
	cin >> A >> B >> C >> D;
	if (A > B) swap(A, B);
	B -= A;

	for (int i = 0; i < N; ++i) {
		ll Ma = i * D - (N - 1 - i) * C;
		ll ma = i * C - (N - 1 - i) * D;
		if (ma <= B && B <= Ma) {
			puts("YES");
			return 0;
		}
	}

	puts("NO");

	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = [list(map(str, input().split())) for _ in range(n)]

ac_cnt = 0
wa_cnt = 0
tle_cnt = 0
re_cnt = 0
for i in range(n):
    if A[i][0] == "AC":
        ac_cnt += 1
    if A[i][0] == "WA":
        wa_cnt += 1
    if A[i][0] == "TLE":
        tle_cnt += 1
    if A[i][0] == "RE":
        re_cnt += 1
print('AC x '+ str(ac_cnt))
print("WA x " + str(wa_cnt))
print("TLE x " + str(tle_cnt))
print("RE x " + str(re_cnt))

Measured memory_bytes: 88668
/* 
 * Project: okio Marine & Nichido Programing Contest 2020 A - Nickname
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/06/13
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstring>
using namespace std;

char s[20];

void solve() {

    for (int i=0;i<3;i++) {
        printf("%c", s[i]);
    }
    printf("\n");

}

int main() {

    scanf("%s", s);

    solve();

}

Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  int n;
  cin>>n;
  vector<long long int> hoge(n);
  for(long long int i=0; i<n; i++){
    cin>>hoge.at(i);
  }
  sort(hoge.begin(),hoge.end());
  vector<int> ans(n);
  bool can=true;
  for(int i=0; i<n; i++){
    if(n%2==0){
      if(hoge.at(i)%2!=0){
        ans.at(hoge.at(i))++;
      }else{
        can=false;
      }
    }else{
      if(hoge.at(i)%2==0){
        ans.at(hoge.at(i))++;
      }else{
        can=false;
      }
    }
  }

  if(can){
    long long int pre=1;
    for(int i=0; i<n; i++){
      if(ans.at(i)==0){
        continue;
      }
      if(n%2==0){
        if(ans.at(i)==2){
          pre*=2;
          pre%=1000000007;
        }else{
          pre=0;
          break;
        }
      }else{
        if(ans.at(i)==2){
          pre*=2;
          pre%=1000000007;
        }else if(!(ans.at(i)==1&&i==0)){
          pre=0;
          break;
        }
      }
    }
    cout<<pre<<endl;
  }else{
    cout<<0<<endl;
  }
}

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

int main() {
  char d, e, f;
  cin >> d >> e >> f;
  vector<char> T = {d, e, f};
  vector<char> U = {'a', 'b', 'c'};
  sort(T.begin(), T.end());
  if (T == U) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
ans = 0

for i in range(1,len(p)-1):
    if (p[i-1]<=p[i] and p[i]<=p[i+1]) or (p[i+1]<=p[i] and p[i]<=p[i-1]):
        ans = ans + 1

print(ans)


Measured memory_bytes: 3060
ref = {"1":".,!? ",
       "2":"abc",
       "3":"def",
       "4":"ghi",
       "5":"jkl",
       "6":"mno",
       "7":"pqrs",
       "8":"tuv",
       "9":"wxyz"}

n = int(raw_input())

for _ in range(n):
    ans = ""
    inputs = map(str, raw_input().split('0'))

    for i in inputs:
        if len(i) > 0:
            k = i[0]
            ans += ref[k][(len(i) - 1) % len(ref[k])]
    print ans

Measured memory_bytes: 6252
#include<bits/stdc++.h>
using namespace std;
char s[101];
int a,b,l;
int main()
{
  scanf("%s",s);
  l=strlen(s)-1;
  for(a=0;a<=l;a++) if(s[a]=='C') break;
  for(b=l;b>=0;b--) if(s[b]=='F') break;
  if((a<l)&&(b>0)&&(b>a)) printf("Yes");else printf("No");
  return 0;
}

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

bool pal(string s) {
    string t = s;
    reverse(t.begin(), t.end());
    return s == t;
}

int main() {
    string s;
    cin >> s;
    ll n = s.length();
    if (n % 2 == 0) {
        cout << "No";
    }
    else {
        string a = s.substr(0, n / 2);
        string b = s.substr((n + 3) / 2 - 1);
        if (pal(a) && pal(b) && pal(s)) {
            cout << "Yes";
        }
        else {
            cout << "No";
        }
    }
    return 0;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr = (input.trim()).split("\n");

const binarySearch = (key, arr, N) => {
  left = 0
  right = N
  while (left < right) {
    mid = Math.floor((left + right) / 2)
    if (key < arr[mid]) {
        right = mid
    } else if (key > arr[mid]) {
        left = mid + 1
    } else {
      return 1
    }
  }
  return 0
}


(function() {
  const N1 = Number(Arr[0])
  const arr1 = Arr[1].split(" ").map(Number);
  // const N2 = Number(Arr[2])
  const arr2 = Arr[3].split(" ").map(Number);
  console.log(arr2.map(e => binarySearch(e, arr1, N1)).reduce((a, b) => a + b, 0));
})();



Measured memory_bytes: 34884
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int sum(int x){
  int d,s=0;
  while(x){
    d=x%10;
    s+=d;
    x/=10;
  }
  return s;
}
int main() {
  int N,A,B,ans=0;
  cin>>N>>A>>B;
  for(int i=1;i<=N;i++){
    if(A<=sum(i)&&sum(i)<=B) ans+=i;
  }
  cout<<ans<<endl;
}


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

using namespace std;

const int MAX = 101;
int n;
int a[MAX];

void print() {
    for (int i = 0; i < n; i++) {
        if (i > 0) printf(" ");
        printf("%d", a[i]);
    }
    printf("\n");
}

void solve() {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            if (a[j] > a[i]) {
                int t = a[i];
                for (int k = i-1; k >= j; k--) {
                    a[k+1] = a[k];
                }
                a[j] = t;
                break;
            }
        }
        print();
    }
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    solve();
    return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define ar array

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int &x : a) cin >> x;
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < k; i++) ans += a[i];
    cout << ans << '\n';
}

Measured memory_bytes: 3640
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)




int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    REP(i, n){
        int p;
        cin >> p;
        p--;
        x[p] = i;
    }
    
    int mx = 0, c = 0, k = 0;
    REP(i, n){
        if(k < x[i]){
            k = x[i];
            c++;
        }
        else{
            mx = max(c, mx);
            k = x[i];
            c = 1;
        }
    }
    mx = max(c, mx);
    
    cout << n - mx << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using lint = long long;
const int INF = 1e9;
typedef pair<lint, lint> P;

signed main(){
  lint N, D, A; cin >> N >> D >> A;
  vector<P> m(N);
  for(int i = 0; i < N; i++) cin >> m[i].first >> m[i].second;
  sort(m.begin(), m.end());
  queue<P> que;
  lint ans = 0, counter = 0;
  for(int i = 0; i < N; i++){
    while(que.size() && que.front().first < m[i].first){
      counter -= que.front().second;
      que.pop();
    }
    m[i].second -= counter * A;
    if(m[i].second < 0) continue;
    lint num = (m[i].second + A - 1) / A;
    ans += num; counter += num;
    que.push(P(m[i].first + 2 * D, num));
  }
  cout << ans << endl;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define Cout(s) cout<<s<<endl
typedef long long ll;
using namespace std;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

ll a = 0, b = 0, c, d, n, k = 0;
string s, t;



int main()
{
	ll a=0, n;
	cin >> n; ll cnt = 0, ans = 0;
	for(ll i=0;i<n;i++)
	{
		cin >> a >>b;
		if (cnt < a)
		{
			cnt = a; ans = b;
		}
	}

	cout << ans+cnt << endl;

	return 0;
}

Measured memory_bytes: 384
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque




def main():
    s = input()
    t = 'CODEFESTIVAL2016'
    ans = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            ans += 1
    print(ans)



if __name__ == '__main__':
    main()



Measured memory_bytes: 38380
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n+1];
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 1; i <= n; i++){
            a[i] = Integer.parseInt(sc.next());
            map.put(i+a[i], map.getOrDefault(i+a[i], 0) +1);
        }
        long ans = 0;
        for(int j = 1; j <= n; j++){
            ans += map.getOrDefault(j-a[j], 0);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 69432
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		while(true) {
			int N = sc.nextInt();
			int M = sc.nextInt();
			if(N == 0 && M == 0) break;
			int []P = new int[N + 1];
			int max = 0;
			List<Integer> list = new ArrayList<Integer>();
			for(int i = 1; i <= N; i++) {
				P[i] = sc.nextInt();
			}
			Arrays.sort(P);
			for(int i = 0; i <= N; i++) {
				for(int j = 0; j <= N; j++) {
					int t = P[i] + P[j];
					if(t <= M) {
						list.add(t);
					}else {
						break;
					}
				}
			}
			Collections.sort(list);
			int l = list.size();
			for(int i = 0; i < l; i++) {
				int res = M - list.get(i);
				int left = -1;
				int right = l;
				while(right - left > 1) {
					int mid = (right + left) / 2;
					if(res >= list.get(mid)) {
						left = mid;
					}else {
						right = mid;
					}
				}
				max = Math.max(max, list.get(i) + list.get(left));
			}
			sb.append(max).append("\n");
		}
		sc.close();
		System.out.print(sb.toString());
	}
}


Measured memory_bytes: 123564
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>

using namespace std;

int main() {
        
            int n;
        cin >> n;
        int sum = 0;
        int *a= new int [n], *b= new int [n-1];
        for (int i = 0; i < n - 1; i++) cin >> b[i];
        sum += b[0];
        for (int i = 1; i < n - 1; i++) {
            if (b[i] > b[i - 1])
                sum += b[i - 1];
            else sum += b[i];
        }
        cout << sum + b[n - 2];
    }
     
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n; cin >> n;
  vector<vector<pair<int, int>>> a(n);
  for(int i = 0; i < n; i++){
    int A; cin >> A;
    for(int j = 0; j < A; j++){
      int x, y; cin >> x >> y;
      x--;
      a[i].emplace_back(x, y);
    }
  }

  int ans = 0;
  for(int i = 0; i < 1 << n; i++){
    vector<int> v(n, -1);
    bool judge = true;
    int cnt = 0;
    for(int j = 0; j < n; j++){
      if(i >> j & 1){
        cnt++;
        if(v[j] == 0) judge = false;
        for(auto p : a[j]){
          if(v[p.first] == -1){
            v[p.first] = p.second;
          }else {
            if(v[p.first] != p.second) judge = false;
          }
        }
      }
    }
    for(int j = 0; j < n; j++){
      if((i >> j & 1) && v[j] == 0) judge = false;
      if(!(i >> j & 1) && v[j] == 1) judge = false;
      if(v[j] == 1){
        for(auto p : a[j]){
          if(v[p.first] != p.second) judge = false;
        }
      }//else if(h[j] != 1) judge = false;
    }
    if(judge) ans = max(ans, cnt);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
  int n;
  cin>>n;
  cout<<"ABC"<<n<<endl;
	return 0;
}


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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input();
		var n = p[0].ToLong();
		var a = p[1].ToLong();
		var b = p[2].ToLong();
		
		if(n<=a+b)
		{
			Console.WriteLine(Math.Min(n, a));
			return;
		}
		else
		{
			long k = a + b;
			long c = n / k;
			long d = n % k;
			
			if(d <= a)
			{
				Console.WriteLine(c * a + d);
			}
			else
			{
				Console.WriteLine(c * a + a);
			}
		}
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}


Measured memory_bytes: 11092