akhauriyash/Code-Regression huggingface dataset:
/*
    quid-pro-quo: LOGIC for AC
    written by: codercell07
    LANG: C++ 11
    Problem: random
*/
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL)
#define testcases freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
#define ui unsigned int
#define ll long long
#define pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define sz(x) (int)x.size()
#define pq priority_queue /*maxim at top(max-heap)*/
#define pqmax priority_queue<int, vector<int>, greater<int>> /*minim at top(min-heap)*/
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define asc(x) sort(all(x))
#define desc(x) sort(all(x), greater<int>())
#define time_el (double)time/CLOCKS_PER_SEC
using namespace std;
const int MAX=2e6; //dummy, make sure change as per constraints
const ll M=1e9+7, inf=1e18;
const char nl='\n';
 
ll apbmc(ll a, ll b, ll c){ a%=c; ll res=1; while(b){ if(b&1) res=res*a%c; a=a*a%c; b>>=1; } return res;}
ll apb(ll x, ll y){ ll temp; if(y==0) return 1;  temp=apb(x, y/2); if(y%2==0) return temp*temp;  else return temp*temp*x;}
 


void solve(){   
    //clock_t time;
    int n; cin>>n;
    vector<pii> v;
    for(int i=0; i<n; i++){
        int x, y; cin>>x>>y;
        v.pb({x, y});
    }
    for(int i=0; i<n-2; i++){
        if(v[i].F==v[i].S and v[i+1].F==v[i+1].S and v[i+2].F==v[i+2].S){
            cout<<"Yes";
            return;
        }
    }
    cout<<"No";
}
int main(){
    fastio;
    // #ifndef ONLINE_JUDGE
    //     testcases;
    // #endif // !DEBUG
    cout<<fixed<<setprecision(10);
    
    //int t; cin>>t; while(t--) solve();    
    solve();

    return 0;
}
//points to check:
//  * check for constraints, mainly array!
//  * EDGE CASES
//  * check for integer overflow, use long long!
//  * learn, do, solve, share something, NOW!

Measured memory_bytes: 3656
N = int(input())
A = list(map(int,input().split()))
S = [0] * (10 ** 5 + 2)
for i,a in enumerate(A):
    S[a] = i + 1
    # print(A[i] + 1)
    # print(a)

for n in range(1,N + 1):
    if n == N + 1 or n == N:
        print(S[n])
    else:
        print(S[n],end=" ")


Measured memory_bytes: 20412
#include <iostream>

using namespace std;
int mas[100005];
int main()
{
    int n,k,q,in;
    cin>>n>>k>>q;
    for(int i=0; i<q; i++){
        cin>>in;
        mas[in]++;
    }
    for(int i=0; i<n; i++){
        if(k-q+mas[i+1]>0){
            cout<<"Yes\n";
        }else{
            cout<<"No\n";
        }
    }
}


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


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define forn(i , n) for(int i=0;i<n;i++)


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

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

using namespace std;
typedef long long ll;
const int maxn = 1000000 + 10;
const ll mod = 1000000000 + 7;

map<string, int> mp;
int main() {
    string a, b;
    cin >> a >> b;
    int x, y;
    cin >> x >> y;
    string s;
    cin >> s;
    if (s == a) x--;
    if (s == b) y--;
    cout << x << " " << y << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func scanNumArrays(len_n int, len_m int) (arrays [][]int) {
	arrays = make([][]int, len_n)
	for i := 0; i < len_n; i++ {
		arrays[i] = make([]int, len_m)
	}
	for i := 0; i < len_n; i++ {
		for j := 0; j < len_m; j++ {
			arrays[i][j] = nextInt()
		}
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	d := nextInt()
	x := scanNumArrays(n, d)

	count := 0
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			distance := 0
			check := 0.
			for k := 0; k < d; k++ {
				distance += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k])
			}
			check = math.Sqrt(float64(distance))
			if math.Floor(check) == check {
				count++
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 640
def getline():
    input_line = input()
    input_list = input_line.split()
    return input_list

temp = getline()
S = temp[0]
T = temp[1]

temp = getline()
A = int(temp[0])
B = int(temp[1])

rm = input()
if S == rm:
    A -= 1
else:
    B -= 1

print(A, B)

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

using namespace std;

typedef long long ll; 
typedef long double ld;

int main() {
	
	// make input and output more efficient
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	
	ld A;
	ld B;
	
	cin >> A;
	
	cin >> B;
		
	ll answer = floor(A * B);
	
	cout << answer << "\n";	
	
	return 0;
}

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

const int DIM = 200005;

char str1[DIM], str2[DIM];

bool solve (int N, int ps, char str1[], char str2[], char mv1, char mv2, int L)
{
	int lef = 1, rig = L;
	for (int i = N; i >= 1; --i) {
		if (str2[i] == mv1) { rig = min(rig + 1, L); }
		if (str2[i] == mv2) { lef = max(lef - 1, 1); }
		if (str1[i] == mv1) { ++lef; }
		if (str1[i] == mv2) { --rig; }
		if (lef > rig) { return false; }
	}
	return lef <= ps and ps <= rig;
}

int main (void) 
{
	int H, W, N, px, py; 
	cin >> H >> W >> N >> px >> py >> (str1 + 1) >> (str2 + 1);
	cout << ((solve(N, px, str1, str2, 'U', 'D', H) and
			  solve(N, py, str1, str2, 'L', 'R', W)) ? "YES" : "NO") << endl;
	return 0; 
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define MOD 998244353
#define fi first
#define se second
#define IT vector < int > :: iterator
using namespace std;

const int NR = 2e5 + 10 , oo = 2e9 ;


void pres ()    {
    #ifndef ONLINE_JUDGE
    freopen("date.in", "r", stdin);
   // freopen("date.out", "w", stdout);
    #endif

}

int maxim , a [ 150 ][ 150 ] , n , b [ 150 ][ 150 ] ;

 main()	{
     int i , j ;
  //  pres();
    cin >> n ;
    if ( n <= 2 ) return cout << -1 , 0 ;
    for ( i = 2 ; i <= n ; ++ i )   {
        a [ 1 ][ i ] = i - 1 ;
    }
    for ( i = 2 ; i <= n ; ++ i )   {
        maxim = 1 ;
        for ( j = 1 ; j < i ; ++ j )    {
            a [ i ][ j ] = a [ j ][ i ] + 1 ;
            if ( a [ i ][ j ] == n )    a [ i ][ j ] = 1 ;
            maxim = a [ i ][ j ];
        }
        maxim ++ ;
        for ( j = i + 1 ; j <= n ; ++ j )   {
            if ( maxim == n )   maxim = 1 ;
            a [ i ][ j ] = maxim ;
            maxim ++ ;
        }
    }

    for ( i = 1 ; i <= n ; ++ i )
    for ( j = 1 ; j <= n ; ++ j )   {
    if ( i == j ) continue ;
    b [ i ][ a [ i ][ j ] ] = j ;

    }

    for ( i = 1 ; i <= n ; ++ i , cout << '\n' )
    for ( j = 1 ; j < n ; ++  j )
    cout << b [ i ][ j ] << ' ' ;
    return 0 ;


}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> a(N);
    REP(i, N) cin >> a[i];

    int ans = INF;

    REP(i, N){
        int X = a[i];
        vector<int> rm;
        vector<int> s(N);
        int len = 0;
        REP(j, N+1){
            if(j == N || a[j] < X){
                sort(s.begin(), s.begin()+len);
                REP(k, len-K+1){
                    rm.pb(s[k]);
                }
                len = 0;
            }else{
                s[len++] = a[j];
            }
        }
        if(rm.size() < Q) continue;
        sort(All(rm));
        chmin(ans, rm.at(Q-1)-X);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
  int a,b,c,t;
  scanf("%d%d%d",&a,&b,&c);
  if(a<b){
    t=a;a=b;b=t;
  }
  if(b<c){
    t=b;b=c;c=t;
  }
  if(a<b){
    t=a;a=b;b=t;
  }
 
 printf("%d",a-c);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;

string solve(int N, vector<int> &v, const vector<string>& s)
{
	string ans;

	auto val = [&](int i, int k) -> int& {
		return v[s[i][k] - 'A'];
	};

	if (v[0] + v[1] + v[2] == 0) {
		return ans;
	}

	if (v[0] + v[1] + v[2] == 1) {
		for (int i = 0; i < N; ++i) {
			if (val(i, 0) == 0 && val(i, 1) == 0) {
				ans.clear();
				return ans;
			}
			if (val(i, 0) == 0) {
				ans += s[i][0];
				val(i, 0) += 1;
				val(i, 1) -= 1;
			}
			else {
				ans += s[i][1];
				val(i, 1) += 1;
				val(i, 0) -= 1;
			}
		}
		return ans;
	}

	for (int i = 0; i < N; ++i) {
		if (val(i, 0) == 0 && val(i, 1) == 0) {
			ans.clear();
			return ans;
		}
		if (val(i, 0) == 0 && val(i, 1) > 0) {
			ans += s[i][0];
			val(i, 0) += 1;
			val(i, 1) -= 1;
		}
		else if (val(i, 1) == 0 && val(i, 0) > 0) {
			ans += s[i][1];
			val(i, 1) += 1;
			val(i, 0) -= 1;
		}
		else if (v[0] + v[1] + v[2] == 2 && val(i, 0) == 1 && val(i, 1) == 1 && i + 1 < N && s[i] != s[i + 1]) {
			if (s[i][0] == s[i + 1][0]) {
				ans += s[i][0];
				val(i, 0) += 1;
				val(i, 1) -= 1;
			}
			else if (s[i][1] == s[i + 1][1]) {
				ans += s[i][1];
				val(i, 1) += 1;
				val(i, 0) -= 1;
			}
			else {
				if (s[i][0] == 'B') {
					ans += s[i][0];
					val(i, 0) += 1;
					val(i, 1) -= 1;
				}
				else {
					ans += s[i][1];
					val(i, 1) += 1;
					val(i, 0) -= 1;
				}
			}
		}
		else {
			if (val(i, 0) < val(i, 1)) {
				ans += s[i][0];
				val(i, 0) += 1;
				val(i, 1) -= 1;
			}
			else {
				ans += s[i][1];
				val(i, 1) += 1;
				val(i, 0) -= 1;
			}
		}
	}

	return ans;
}

int main()
{
	int N, A, B, C;
	cin >> N >> A >> B >> C;
	vector<string> s(N);
	for (auto& x : s) {
		cin >> x;
	}
	vector<int> v = { A, B, C };
	auto ans = solve(N, v, s);
	if (ans.empty()) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
		for (auto ch : ans) {
			cout << ch << endl;
		}
	}
}


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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        int N;
        cin >>N;
        vector<int> A(N, 0);
        Rep0(i, N)
                cin >>A.at(i);
        //
        Sort(A);
        int AMax=A.back();
        vector<bool> AA(AMax+1, false);
        int S=0;
        Rep0(i, N) {
                int a=A.at(i);
                if (!AA.at(a)) {
                        if ((i<N-1)&&(a!=A.at(i+1)))
                                S++;
                        if (i==N-1)
                                S++;
                        for (int j=a; j<=AMax; j +=a)
                                AA.at(j)=true;
                }
        }
        cout <<S <<endl;
        return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	vector <ll> arr(3);
	ll n;
	for (int z=0;z<3;z++){
		cin >> arr[z];
	}
	sort(arr.begin(),arr.end());
	cout << arr[0]+arr[1] << endl;
	cin >> n;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
#define F first
#define S second
using namespace std;
using namespace atcoder;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
ll Mod = 1000000007;
int main() {
  int T;
  cin >> T;
  for (int t = 0; t < T; t++) {
    ll N,M,A,B;
    cin >> N >> M >> A >> B;
    ll ans = floor_sum(N,M,A,B);
    cout << ans << endl;
  }
  return 0;
}

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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

int main() {
  _upgrade;
  int n;
  cin >> n;
  vector<int> A(n);
  for (auto &a : A) {
    cin >> a;
  }
  vector<int> range(n, 0);
  LL res = 0;
  for (int i = 0; i < n; i++) {
    if (i + A[i] < n) {
      range[i + A[i]]++;
    }
    if (i - A[i] >= 0) {
      res += range[i - A[i]];
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 4780
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int r = (int) Math.ceil(Math.sqrt(n));
        long tmp = n;
        for (int i = r; i > 0; i--) {
            if(n % i == 0){
                tmp = n / i;
                break;
            }
        }
        int ans = String.valueOf(tmp).length();

        System.out.println(ans);
        sc.close();
    }

}


Measured memory_bytes: 21716
# -*- coding: utf-8 -*-
# モジュールのインポート
import sys


def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    N = int(input())
    x, y = [], []
    for i in range(N):
        x_i, y_i = list(map(int, input().split()))
        x.append(x_i)
        y.append(y_i)

    return N, x, y


def main(N: int, x: list, y: list) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 点の数(2 <= N <= 2 * 10**5)
        x (list): x座標(1 <= x_i <= 10**9)
        y (list): y座標(1 <= y_i <= 10**9)
    """
    # 求解処理
    max_z = -sys.maxsize
    min_z = sys.maxsize
    max_w = -sys.maxsize
    min_w = sys.maxsize
    for x_i, y_i in zip(x, y):
        z_i = x_i + y_i
        max_z = max(max_z, z_i)
        min_z = min(min_z, z_i)
        w_i = x_i - y_i
        max_w = max(max_w, w_i)
        min_w = min(min_w, w_i)
    ans = max(max_z - min_z, max_w - min_w)

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N, x, y = get_input()

    # メイン処理
    main(N, x, y)


Measured memory_bytes: 24880
n = int(input())
r = []
for _ in range(n):
    r.append(int(input()))

m = r[0]
ans = - float('inf')
for i in range(1, n):
    ans = max(ans, r[i] - m)
    if r[i] <= m:
        m = r[i]
    # print('i', i)
    # print('m', m)
    # print('r[]', r[i])
    # print('r[i] - m', r[i] - m)
    # print('ans', ans)
print(ans)


Measured memory_bytes: 13592
module Main where

import           Control.Monad

main :: IO ()
main = do
    [h, _] <- (map read . words) <$> getLine :: IO [Int]
    list   <- map (map read . words) <$> (replicateM h) getLine :: IO [[Int]]
    let res1    = (map goRight . enumerate2d) list
    let list2   = (map snd) res1
    let result1 = (concatMap fst) res1
    let res2    = (goRight . map last) list2
    let result2 = fst res2
    let result  = concat [result1, result2]

    putStr
        $ (unlines . (((show . length) result) :) . map
              (unwords . (\((a, b), (c, d)) -> (map show) [a, b, c, d]))
          )
              result

    return ()
goRight
    :: [((Int, Int), Int)] -> ([((Int, Int), (Int, Int))], [((Int, Int), Int)])
goRight []           = ([], [])
goRight [x         ] = ([], [x])
goRight (a : b : xs) = if even (snd a)
    then let res = goRight (b : xs) in mapSnd (a :) res
    else
        let res = goRight (mapSnd (+ 1) b : xs)
        in  ((fst a, fst b) : (fst res), mapSnd (subtract 1) a : (snd res))

enumerate :: [a] -> [(Int, a)]
enumerate = zip [1 ..]

enumerate2d :: [[a]] -> [[((Int, Int), a)]]
enumerate2d =
    (map (\(y, a) -> (map (\(x, b) -> ((y, x), b)) . enumerate) a) . enumerate)

mapTuple :: (t1 -> a) -> (t2 -> b) -> (t1, t2) -> (a, b)
mapTuple f1 f2 (a, b) = (f1 a, f2 b)

mapFst :: (t1 -> a) -> (t1, b) -> (a, b)
mapFst = flip mapTuple id

mapSnd :: (t2 -> b) -> (a, t2) -> (a, b)
mapSnd = mapTuple id


Measured memory_bytes: 78332
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Go_ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=1e3+100;
const ll mod=1e9+7;

ll bigmod(ll a,ll pr)
{
    if(pr==0) return  1;
    else if(pr==1) return a;
    ll x=bigmod(a,pr/2);
    x=(x*x)%mod;
    if(pr & 1ll) x=(x*a)%mod;
    return x;
}

ll fun(ll n,ll k)
{
    ll x=1,y=1;
    for(ll i=n;i>=(n-k+1);i--) x=(x * i)%mod;
    for(ll i=2;i<=k;i++) y=(y * i)%mod;
    
    y=bigmod(y,mod-2);
    x=(((x*y)%mod)+mod)%mod;
    return x;
    
}

int main()
{
    Go_
    ll a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    
    cin>>n>>a>>b;
    ll ans=bigmod(2,n);
    ans=((ans-1)%mod +mod)%mod;
    ans=((ans - fun(n,a)%mod)+mod)%mod;
    ans=((ans - fun(n,b)%mod)+mod)%mod;
    
    cout<<ans<<endl;
    
    
}

Measured memory_bytes: 256
_,M,X = list(map(int,input().split()))
a = list(map(int,input().split()))

'''
for i,c in enumerate(a):
    if X < c:
        print(min(i,M-i))
        break
'''
import bisect
i = bisect.bisect_left(a,X)
print(min(i,M-i))

Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int A, P;

int main() {
	cin >> A >> P;
	cout << (A * 3 + P) / 2 << endl;
	return 0;
}

Measured memory_bytes: 3564
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio, std.bitmanip;


class SegmentTree {
    int[] table;
    int N, table_size;
    
    this(int n) {
        N = n;
        table_size = 1;
        while (table_size < n) table_size *= 2;
        table_size *= 2;
        table = new int[](table_size);
    }

    void add(int pos, int num) {
        add_rec(0, 0, table_size/2-1, pos, num);
    }

    void add_rec(int i, int left, int right, int pos, int num) {
        table[i] += num;
        if (left == right)
            return;
        auto mid = (left + right) / 2;
        if (pos <= mid)
            add_rec(i*2+1, left, mid, pos, num);
        else
            add_rec(i*2+2, mid+1, right, pos, num);
    }

    int sum(int pl, int pr) {
        return sum_rec(0, pl, pr, 0, table_size/2-1);
    }
    
    int sum_rec(int i, int pl, int pr, int left, int right) {
        if (pl > right || pr < left)
            return 0;
        else if (pl <= left && right <= pr)
            return table[i];
        else
            return
                sum_rec(i*2+1, pl, pr, left, (left+right)/2) +
                sum_rec(i*2+2, pl, pr, (left+right)/2+1, right);
    }
}

void main() {
    alias Tuple!(int, "l", int, "r") Seg;
    
    int N, M;
    scanf("%d %d", &N, &M);
    int l, r;
    auto segs = new Seg[][](M+1);
    foreach (i; 0..N) {
        scanf("%d %d", &l, &r);
        segs[r-l+1] ~= Seg(l, r);
    }

    
    auto st = new SegmentTree(M+2);

    foreach (d; 1..M+1) {
        foreach (s; segs[d-1]) {
            N -= 1;
            st.add(s.l, 1);
            st.add(s.r+1, -1);
        }
        
        int ans = N;
        for (int i = d; i <= M; i += d) {
            ans += st.sum(0, i);
        }
        ans.writeln;
        //writeln(d, " ", ans, " ", N);
    }


}


Measured memory_bytes: 9852
#include <stdio.h>
#include <string.h>
#define N 1000
int main()
{
  char c[N],d[N],C_s[N],D_s[N];
  int i=0,j=0,k=0,Ccount=0,Dcount=0,t=0;

  scanf("%s",c);
  Ccount=strlen(c);
  scanf("%s",d);
  Dcount=strlen(d);
  //printf("%d %d\n",Ccount,Dcount);                                            
  for(i=0;i<Ccount-Dcount+1;i++)
    {
      k=i;
      for(j=0;j<Dcount;j++)
        {
          if(c[k]==d[j])
            {
              t++;
            }
          k++;
        }
      if(t==Dcount) printf("%d\n",i);
      t=0;
    }
  return 0;
}

Measured memory_bytes: 540
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <cmath>

#define INF 100000000
#define MOD 1000000007
using namespace std;


int main(){
    int az[26]={};
    char x;
    while (cin>>x) {
        if(x>='a' && x<='z'){
            az[x-'a']++;
        }else if(x>='A' && x<='Z'){
            az[x-'A']++;
        }else{
            continue;
        }
    }
    
    for(int i=0; i<26; i++){
        cout << (char)('a'+i) << " : " << az[i] << endl;
    }
    return 0;
}



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

namespace ABC138A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());

            String s;

            s = Console.ReadLine();

            if (a < 3200)
                Console.WriteLine("red");

            else
                Console.WriteLine(s);

            Console.ReadKey();

        }
    }
}

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

int main(){
  string S;
  cin >> S;
  
  ll num=(ll)stoll(S);
  string S2=S.substr(0,1);

  if(S.size()==1){
    cout << S << endl;
    return 0;
  }
  int i,co=0;
  for(i=1;i<(int)S.size();i++){
    string S3=S.substr(i,1);
    co+=stoi(S3);
    if(stoi(S3)!=9)
      break;
  }
 // cout << S.at(i) << endl;
 // cout << i << endl;
  if(i==S.size()){
    cout << co+stoi(S2) << endl;
    return 0;
  }
    
  	//cout << S.at(0) << endl;
    cout << ((int)S.size()-1)*9+(ll)stoi(S2)-1<< endl;
    

 // cout << pow(10,1)<< endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll K = 0;
ll t;
ll ret = 0;
string s;

ll enemy(ll h) {
  if (h <= 0) return 0;
  else if (h == 1) return 1;
  else return 1 + enemy(h/2) * 2;
}

void input() {
  IN(N);
}

void solve() {
  ret = enemy(N);
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
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; }


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

    const ll INF=1LL<<60;
    vector<vector<ll>> dp(110,vector<ll>(100010,0));
    vector<ll> w(110), v(110);
    REP(i, N){
        cin>>w[i]>>v[i];
    }
    REP(i, N){
        REP(wsum, W+1){
            if(wsum>=w[i]) chmax(dp[i+1][wsum], dp[i][wsum-w[i]]+v[i]);
            chmax(dp[i+1][wsum], dp[i][wsum]);
        }
    }
    
    cout << dp[N][W] << endl;    return 0;
}

Measured memory_bytes: 87296
import re
N = int(input())
S = input()

#case1
CT=0
for j in range(len(S)):
    if S[j] == ".":
        CT+=1

#NG: #.
#OK: .#
CH=0
A=CT+CH
for i in range(len(S)):
    if S[i] == ".":
        CT-=1
    if S[i] == "#":
        CH+=1

    A=min(CT+CH, A)


print(A)


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

int main() {
  int N;
  bool b=false;
  cin >> N;

  for (int i = 0; i < N; i++) {
    char a;
    cin >> a;
    
    if (a == 'Y') {
      b = true;
    }
  }
  
  if (b) {
    cout << "Four" << endl;
  }
  
  else {
    cout << "Three" << endl;
  }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF ((ll)(1e15))

using namespace std;

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

const int MAX_N = 1000;
vector<IL> G[MAX_N]; // P(to,cost)

ll dist[MAX_N];

int main()
{
	rep (i, MAX_N) G[i].clear();
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int N, M; cin >> N >> M;
	rep (i, M){
		int a, b; ll c; cin >> a >> b >> c;
		--a, --b;
		G[a].push_back(IL(b,-c));
	} // end rep

	rep (i, N){
		dist[i] = INF;
	} // end rep

	bool negative = false;
	dist[0] = 0LL;
	rep (iter, 2 * N){
		rep (v, N){
 			if (dist[v] == INF) continue;
			for (int j = 0; j < (int)G[v].size(); ++j){
				int u = G[v][j].first;
				ll c = G[v][j].second;
				if (dist[u] > dist[v] + c){
					dist[u] = dist[v] + c;
					if (u == N - 1 && iter >= N - 1){
						negative |= true;
					} // end if
				} // end if
			} // end for
		} // end rep
	} // end rep

	if (!negative){
		cout << -dist[N - 1] << endl;
	}else{
		cout << "inf" << endl;
	} // end if

	return 0;
}

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

int main(){
    int n,h,m,s;
    cin >> n;
    
    h = n / 3600;
    m = (n % 3600) / 60;
    s = n - h*3600 - m*60;
    
    cout << h << ":" << m << ":" << s << endl;    
};



Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define fastIO ios::sync_with_stdio(false);cin.tie(0);
#define ll long long
#define f(i, l, r) for(i = l; i < r; i++)
#define fd(i, l, r) for(i = l; i > r; i--)
#define mod 1000000007
#define pb push_back
using namespace std;
typedef pair <int, int> pi;

int main(){
	fastIO
    int test = 1;
    // cin >> test;
    while(test--){
        int n; cin >> n;
        int i, j, arr_h[n];
        f(i,0,n) cin >> arr_h[i];
        int cost[n] = {0};
        cost[1] = abs(arr_h[1] - arr_h[0]);
        f(i,2,n){
            cost[i] = min(cost[i-1] + abs(arr_h[i] - arr_h[i-1]), cost[i-2] + abs(arr_h[i] - arr_h[i-2]));
        }
        cout << cost[n-1];
    }
}


Measured memory_bytes: 1024
import sys


def typical_stairs():
    n, m = map(int, input().split())
    dangerous = set(int(sys.stdin.readline()) for _ in range(m))
    mod = 1000000007
    dp = [0] * (n + 1)
    dp[0] = 1
    if 1 not in dangerous:
        dp[1] = 1
    for i in range(2, n + 1):
        if i not in dangerous:
            dp[i] = dp[i - 2] + dp[i - 1]
    print(dp[-1] % mod)


if __name__ == '__main__':
    typical_stairs()


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

using namespace std;

typedef long long ll;

struct BIT {
  vector<ll> data;
  int N;

  BIT(int n) {
    N = n;
    data = vector<ll>(N+1);
  }

  void add(int i, ll x) {
    for (int k = i; k <= N; k += k&-k) data[k] += x;
  }

  ll sum(int i) {
    ll res = 0;
    for (int k = i; k > 0; k -= k&-k) res += data[k];
    return res;
  }
};

int N, Q;
;
int main() {

  cin >> N >> Q;
  BIT bit(N);

  for (int i = 0; i < Q; i++) {
    int c, x, y;
    cin >> c >> x >> y;
    if (c == 0) bit.add(x, y);
    else cout << bit.sum(y)-bit.sum(x-1) << endl;
  }

  return 0;

}



Measured memory_bytes: 4400
def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    ans = 0
    mod = 10 ** 9 + 7
    for d in range(61):
        # d桁目ごとに考える
        x = 0
        for a in A:
            if (a >> d) & 1:
                x += 1
        ans += x * (n-x) * 2**d
        ans %= mod
    print(ans)

if __name__ == '__main__':
    main()


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

int main(){
	int m,f,r;
	

	while(1){
		cin >> m >> f >>r;
		if( m==-1 && f==-1 && r==-1) break;
		
		if( m== -1 || f== -1 ){ 
			cout << 'F' << "\n";
		}else if( m+f>=80 ){
			cout << 'A' << "\n";
		}else if( m+f<80 && m+f>= 65){
			cout << 'B' << "\n";
		}else if( m+f<65 && m+f>= 50){
			cout << 'C' << "\n";
		}else if( m+f<50 && m+f>= 30){
			if( r>=50 ){
				cout << 'C' << "\n";
			}else{
				cout << 'D' << "\n";
			}
		}else{
			cout << 'F' << "\n";
		}
	}

	return 0;
}

Measured memory_bytes: 1120
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;

/*----------macros----------*/

//input, output================
#define fastio                          \
std::ios::sync_with_stdio(false);       \
std::cin.tie(nullptr);                  \
std::cout.tie(nullptr)

#define endl '\n'
#define fcout(a)                        \
cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef vector<int>     Vi;
typedef vector<ll>      Vl;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF    = (ll)1e9 + 1;
constexpr ll INFll  = (ll)1e18 + 1;
constexpr ll MOD1   = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define psb push_back
#define epb emplace_back
#define psf push_front
#define mkp make_pair
#define fst first
#define snd second

//others================
#define sz(x)                           \
(int) x.size()

#define all(x)                          \
(x).begin(), (x).end()

#define rall(x)                         \
(x).rbegin(), (x).rend()

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

#define reps(i, n)                      \
for(int i = 1; (i) <= (n); ++(i))

#define rrep(i, n)                      \
for(int i = n - 1; (i) >= 0 ; --(i))

#define repbit(bit, n)                  \
for(int bit = 0; (bit) < (1 << (n)); ++(bit))

#define ifbit(bit, i)                   \
if((bit) & (1 << (i)))

#define CtoI(c)                         \
int((c)) - int('0')

#define ItoC(c)                         \
char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b)
{ return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b)
{ return a > b && (a = b, true); }

// Vi  dx = {1, 0, -1, 0},
//     dy = {0, 1, 0, -1};

// Vi  dx2 = { 1,1,0,-1,-1,-1,0,1 },
//     dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
fastio;

    string s; cin >> s;
    if((s[0] == s[1] and s[1] != s[2] && s[2] == s[3]) ||
       (s[0] == s[2] && s[0] != s[1] && s[1] == s[3]) ||
       (s[0] == s[3] && s[0] != s[1] && s[1] == s[2])){
           cout << "Yes" << endl;
           return 0;
       }

       cout << "No" << endl;

return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    const char L = '(';
    const char R = ')';
    
    int n; cin >> n;
    string s; cin >> s;

    int cnt = 0,mx = 0;
    REP(i,s.size()) {
        if (s[i] == R) {
            cnt++;
            if (cnt > mx) mx = cnt;
        }
        else cnt--;
    }
    string l(mx,L);
    s = l + s;

    cnt = 0; mx = 0;
    for(int i = s.size()-1; i >= 0; i--) {
        if (s[i] == L) {
            cnt++;
            if (cnt > mx) mx = cnt;
        }
        else cnt--;
    }
    string r(mx,R);
    s += r;

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
#define INF 114514
using namespace std;



int main(){
	int n, m, i, j;
	cin >> n >> m;
	int t[101], point[101] = { 0 };
	int b[101][1001] = { 0 };
	for (i = 0; i < m; i++) cin >> t[i];
	for (i = 0; i < m; i++) {
		int cnt = 0;
		for (j = 0; j < n; j++) {
			cin >> b[i][j];
			if (b[i][j] == t[i]) {
				point[j]++;
			}
			else {
				cnt++;
			}
		}
		point[t[i]-1] += cnt;
	}
	for (i = 0; i < n; i++) {
		cout << point[i] << endl;
	}
	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> jobs(m);//行数だけ指定
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    if (a > m) continue;
    jobs[m-a].push_back(b);/*後ろ(m日目から)見て、m-a日に選択できる仕事の利益bを
    行列jobのm-a行目に入れる*/
  }
  priority_queue<int> q;
  ll ans = 0;
  for (int i = m-1; i >= 0; --i) {
    for (int b : jobs[i]) {
      q.push(b);
    }
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

static const double eps = 10e-8;

int main(){

	int i,n;
	double h,w;
	
	while(~scanf("%d",&n)){
		if(n==0) break;
		double diff = 1000000;
		int res=10000000;

		for(int j=0;j<n;j++){
			scanf("%d %lf %lf",&i,&h,&w);
			if(diff > abs(22.0-(w / ((h/100.0)*(h/100.0))))){
				diff = abs(22.0-(w / ((h/100.0)*(h/100.0))));
				res = i;
			}
			else if(diff == abs(22.0-(w / ((h/100.0)*(h/100.0))))){
				res = min(res,i);
			}
		}
		printf("%d\n",res);
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main(void) {
  int n;
  cin >> n;
  vector<ll> a(n + 1), b;
  rep(i, n + 1) cin >> a[i];
  b.push_back(0);
  rep(i, n) {
    int tmp;
    cin >> tmp;
    b.push_back(tmp);
  }
  b.push_back(0);
  ll ans = 0;
  rep(i, n + 1) {
    int toubatsu = min(a[i], b[i]);
    ans += toubatsu;
    a[i] -= toubatsu;
    toubatsu = min(a[i], b[i + 1]);
    ans += toubatsu;
    b[i + 1] -= toubatsu;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2168
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

using namespace std;

int main() {
  int h, w;

  while (cin >> h >> w) {
    if (h == 0 && w == 0) { break; }
    int size = h*h + w*w;

    int ans_h = 200, ans_w = 200, ans_size = 100005;

    for (int hh = 1; hh <= 150; hh++) {
      for (int ww = hh+1; ww <= 150; ww++) {
        int ssize = hh*hh + ww*ww;

        if ( ssize < size) { continue; }
        if ( ssize == size && hh <= h) { continue; }

        if ( ssize < ans_size || (ssize == ans_size && hh < ans_h) ) {
          ans_h = hh;
          ans_w = ww;
          ans_size = ssize;
        }
      }
    }
    cout << ans_h << " " << ans_w << endl;
  }

  return 0;
}


Measured memory_bytes: 3076
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()

int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k <= a) {
		cout << k << endl;
	}
	else if (k <= a + b) {
		cout << a << endl;
	}
	else {
		cout << a - (k - a - b) << endl;;
	}

}


Measured memory_bytes: 3192
#include <iostream>
    #include <string>
    #include <algorithm>
    #include <functional>
    #include <vector>
    #include <stack>
    #include <queue>
    #include <set>
    #include <map>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <cassert>
    #define int long long
    #define double long double
    using namespace std;
    typedef pair<int, int> P;
     
    int sx, sy, gx, gy;
    int n;
    int x[200000], y[200000];
    vector<P> p;
    int dp[200002];		//dp[length] = min(max)
    const double PAI = 3.141592653589793238;
     
    signed main()
    {
    	int i;
    	
    	cin >> sx >> sy >> gx >> gy;
    	cin >> n;
    	for (i = 0; i < n; i++) cin >> x[i] >> y[i];
    	
    	if (sx > gx) { swap(sx, gx); swap(sy, gy); }
    	if (sy > gy) {
    		sy *= -1;
    		gy *= -1;
    		for (i = 0; i < n; i++) { y[i] *= -1; }
    	}
    	
    	for (i = 0; i < n; i++) {
    		if (sx <= x[i] && x[i] <= gx && sy <= y[i] && y[i] <= gy) {
    			p.push_back(P(x[i], y[i]));
    		}
    	}
    	sort(p.begin(), p.end());
    	
    	//LIS
    	int INF = 1145141919810;
    	for (i = 0; i <= n + 1; i++) dp[i] = INF;
    	for (i = 0; i < p.size(); i++) {
    		dp[upper_bound(dp, dp + n + 1, p[i].second) - dp] = p[i].second;
    	}
    	int Count = lower_bound(dp,dp+n+1,INF)-dp;
    	double ans;
    	
    	if (min(gx - sx, gy - sy) + 1 > Count) {
    		ans = (gy - sy + gx - sx) * 100 - Count * (20.0 - PAI * 5.0);
    	}
    	else {
    		ans = (gy - sy + gx - sx) * 100 - (Count - 1.0) * (20 - PAI * 5) + (PAI * 10 - 20);
    	}
    	
    	printf("%.20Lf\n", ans);
    	return 0;
    }

Measured memory_bytes: 9456
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {

        ModScanner ms = new ModScanner();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int n = ms.nextInt();
        int w = ms.nextInt();
        int[] wt = new int[n];
        int[] val = new int[n];
        for (int i = 0; i < n; i++) {
            wt[i] = ms.nextInt();
            val[i] = ms.nextInt();
        }

        long[] dp = new long[w + 1];

        for (int i = 0; i < n; i++) {
            for (int j = w; j >= wt[i]; j--) {
                dp[j] = Math.max(dp[j], val[i] + dp[j - wt[i]]);
            }
        }

        out.println(dp[w]);
        out.close();
    }


}

class ModScanner {

    BufferedReader br;
    StringTokenizer st;

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

    String nextToken() throws Exception {
        while (st == null || !st.hasMoreElements()) {
            st = new StringTokenizer(br.readLine());

        }
        return st.nextToken();
    }

    String nextString() throws Exception {
        return br.readLine();
    }


    int nextInt() throws Exception, Exception {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }

}


Measured memory_bytes: 34576
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define MAX 200000
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int par1[MAX], rank1[MAX], par2[MAX], rank2[MAX];
int n;

void init(int par[]){
  for(int i = 0; i < n; i++)
    par[i] = i;
}

int find(int x, int par[]){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x], par);
  }
}

void unite(int x, int y, int par[], int rank[]){
  x = find(x, par);
  y = find(y, par);

  if(x == y)
    return;

  if(rank[x] > rank[y]){
    par[y] = x;
  }else{
    par[x] = y;
    if(rank[x] == rank[y])
      rank[y]++;
  }

}

int same(int x, int y,int par[]){
  return find(x, par) == find(y, par);
}

int main(){

  int k, l;
  scanf("%d %d %d", &n , &k, &l);

  init(par1); init(par2);
  REP(i,k){
    int p, q;
    scanf("%d %d", &p, &q);
    p--; q--;
    unite(p, q, par1, rank1);
  }

  REP(i,l){
    int r, s;
    scanf("%d %d", &r, &s);
    r--; s--;
    unite(r, s, par2, rank2);
  }

  map<pii, int> mp;
  REP(i,n){
    mp[pii(find(i, par1), find(i, par2))]++;
  }

  REP(i,n){
    printf("%d ", mp[pii(find(i, par1), find(i, par2))]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 13696
object Main extends App {
  readInt
  println( readLine.split(" ").map(_.toInt).scanLeft((0, 0))(
    {case((v1,r),v2) => (v2, if(v1>=v2) r+1 else 0)}: Function2[(Int,Int),Int, (Int,Int)]
  ).map(_._2).max )
}

Measured memory_bytes: 52576
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<ll,ll>

using namespace std;
typedef long long ll;

int main(void) {
	int N, K, S; cin >> N >> K >> S;
	vint a(N);

	rep(i, N) {
		if (i < K) {
			a[i] = S;
		}
		else {
			if (S == 1e9) {
				a[i] = S - 1;
			}
			else {
				a[i] = S + 1;
			}
		}
	}
	rep(i, N) {
		cout << a[i]<<' ';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1664
<?php
    define('MOD', 998244353);

    $rng = [];
    fscanf(STDIN, "%d %d", $N, $K);
    for ($i = 0; $i < $K; $i++) {
        fscanf(STDIN, "%d %d", $L, $R);
        $rng[] = [$L, $R + 1];
    }
 
    $dp = array_fill(0, $N, 0);
    $dp[0] = 1;
    $dp[1] = -1;
 
    for ($i = 0; $i < $N; $i++) {
        if ($i > 0) {
            $dp[$i] += $dp[$i - 1];
            $dp[$i] %= MOD;
        }
        for ($j = 0; $j < $K; $j++) {
            [$l, $r] = $rng[$j];
            if ($i + $l < $N) {
                $dp[$i + $l] += $dp[$i];
                $dp[$i + $l] %= MOD;
            }
            if ($i + $r < $N) {
                $dp[$i + $r] -= $dp[$i];
                if ($dp[$i + $r] < 0) {
                    $dp[$i + $r] += MOD;
                } 
            }
        }
    }
    printf("%d", $dp[$N - 1]);


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

using namespace std;

int main(){
  int H,W; cin>>H>>W;
  vector<vector<char> > v(H+2,vector<char>(W+2,'#'));

  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cin>>v[i][j];
    }
  }

  for(int i=0;i<=H+1;i++){
    for(int j=0;j<=W+1;j++){
      cout<<v[i][j];
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
long long k;
int main() {
           cin>>k>>s;
           if(s.size()<=k) cout<<s;
           else {
                      for(long long i=0;i<k;i++)
                      cout<<s[i];
                      cout<<"...";
           }
}

Measured memory_bytes: 3636