akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
#define int long long
	int n,k,a[10000];
	scanf("%lld%lld",&n,&k);
	for(int i=0;i<n;i++)scanf("%lld",a+i);
	sort(a,a+n);
	int sum=0,ans=0;
	for(int i=n-1;i>=0;i--)
		if(sum+a[i]<k)sum+=a[i],ans++;
		else ans=0;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys

n,m,x = map(int,input().split())
arr = np.array([list(map(int,input().split())) for i in range(n)])

c = arr.T[0] # c[n-1]まで
a = arr.T[1:].T # a[n-1][m-1]まで


ans = np.inf
for i in range(2**n):
    ability = np.zeros(m, np.int64)
    cost = 0
    for j in range(n):
        if (i>>j)&1: ability += a[j] ; cost += c[j]
    #print(ability, cost)
    if all(i>=x for i in ability): ans = min(ans,cost)

ans = -1 if ans==np.inf else ans
print(ans)


Measured memory_bytes: 27260
//Rectangle Cutting

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define nxvarep(n,x,a) ll n,x;cin>>n>>x;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<ll,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    double w,h,x,y;cin>>w>>h>>x>>y;
    cout<<w*h/2<<spa;
    if(x==w/2&&y==h/2)cout<<1<<nnn;
    else cout<<0<<nnn;
    return 0;
}

Measured memory_bytes: 256
import itertools

n = int(input())
lis = list(map(int, input().split()))
k = list(itertools.accumulate(lis))
x = sum(lis)

ans = 100100100100100100

for i in range(n-1):
    t = k[i]
    t2 = x - t
    
    ans = min(ans, abs(t-t2))

print(ans)


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

int main(){
string str;
  cin>>str;
  int n;
  n=stoi(str);
  int ans=0;
  for(int i=1; i<=n; i++){
    str=to_string(i);
    if(str.size()%2==1) ans++;
  }
  cout<<ans<<endl;
  return 0;
}
  

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


int main() {
    string S;
    cin >> S;
    if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
        cout << "Yes" << endl;
    } else cout << "No" << endl;
}


Measured memory_bytes: 3556
import sys
import math
import collections
from collections import deque
k = int(input())
#a, b = map(int, sys.stdin.readline().split())
#s = input()
#x = sys.stdin.readline().split()

a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(a[k-1])


Measured memory_bytes: 3564
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w;
    cin >> h >> w;
    vector<vector<pair<int, int>>> edge(10);
    vector<VI> dis(10, VI(10, INF));
    int c;
    FOR(i, 0, 10)FOR(j, 0, 10) {
        cin >> c;
        if (i == j)continue;
        edge[i].push_back({ j,c });
        dis[i][j] = c;
    }
    VI a(h* w);
    FOR(i, 0, h* w)cin >> a[i];

    FOR(i, 0, 10)dis[i][i] = 0;
    FOR(k, 0, 10)FOR(i, 0, 10)FOR(j, 0, 10)chmin(dis[i][j], dis[i][k] + dis[k][j]);

    int ans = 0;
    for (int i : a)if (i > -1)ans += dis[i][1];
    cout << ans << "\n";
}

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

int main(){
  int X, Y;
  cin >> X >> Y;
  int a;
  for(int i = 0; i <=100; i++){
    for(int j = 0; j <= 100; j++){
      a = 2* i + 4 * j;
      if(Y == a && i+j == X){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int cnt = 0;
		for(int i=0;i<N;i++){
			if(A[i] % 2 == 1 && i % 2 == 0){
				cnt++;
			}
		}
		Console.WriteLine(cnt);
		
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 27548
N = int(input())

M = 10**5

L = [0]*M


for i in map(int,input().split()):
  L[i] += 1

c = sum(L[:3])
b = c

for i,j in zip(range(3,M),range(M-3)):
  c += L[i]
  c -= L[j]
  b = max(b,c)

print(b)

Measured memory_bytes: 11480
#include<iostream>
#include<cmath>
#define PI 3.14159265359

using namespace std;

int main(){
  int d, a = 90, a2; 
  double x,y;
  char c;
  while(cin >> d >> c >> a2){
    if(d == 0 && a == 0) break;
    else{
      double rad = a * (PI / 180.0);
      x += d * cos(rad);
      y += d * sin(rad);
      a += a2;
    }
  }
  cout << -(int)x << "\n" << (int)y << endl;
}

Measured memory_bytes: 1168
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLine >>= print . solve

solve :: [Int] -> Int
solve [a, b, t] = (t `div` a) * b

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 380
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();

        if (a == 0 && b == 0 || c == 0 && d == 0) {
            System.out.println(0);
            return;
        } else if (a > 0 && d < 0) {
            System.out.println(a * d);
            return;
        } else if (b < 0 && c > 0) {
            System.out.println(b * c);
            return;
        } else if (a == 0 && d < 0 || c == 0 && b < 0) {
            System.out.println(0);
            return;
        } else if (a >= 0 || c >= 0) {
            System.out.println(b * d);
            return;
        } else if (a < 0 && b > 0 && c < 0 && d > 0) {
            System.out.println(Math.max(a * c, b * d));
            return;
        } else {
            System.out.println(a * c);
            return;
        }

    }

}


Measured memory_bytes: 35644
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN, datK) = readLine.split(" ").map(_.toInt)
    val datA = readLine.split(" ").map(_.toInt)

    val scA = datA.groupBy(identity).mapValues(_.length).toList.sortBy(_._2)
    val rewriteK = math.max(0, scA.length - datK)

    def countup(result: Int, num:Int, ls: List[(Int, Int)]): Int = {
      if (num == 0) result
      else countup(result + ls.head._2, num - 1, ls.tail)
    }
    val ans = countup(0, rewriteK, scA)

    println(ans)
  }
}


Measured memory_bytes: 144076
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define quickIO()	{cin.tie(0);	cout.sync_with_stdio(false);}
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<(int)n;i++)
#define REP(i,n)	for(int i=0;i<=(int)n;i++)
#define srep(i,a,n)	for(int i=a;i<(int)n;i++)
#define SREP(i,a,n)	for(int i=a;i<=(int)n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll sqrtll(ll x) {
	ll left = 0, right = x;
	rep(i, 100) {
		ll mid = (left + right) >> 1;
		if (mid*mid <= x)	left = mid;
		else	right = mid;
	}
	return left;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	printf("Case #%d: ", x)
#define DEBUG 0
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0,0 };
const int dy[] = { 0,1,0,-1,0 };

bool isPrime[100010];
bool isSimilar[100010];

int main() {
	// エラトステネスの篩で10^5まで素数を列挙
	REP(i, 100000)	isPrime[i] = isSimilar[i] = true;
	isPrime[0] = isPrime[1] = isSimilar[0] = isSimilar[1] = false;
	SREP(i, 2, 100000) {
		if (isPrime) {
			for (int j = 2; i*j <= 100000; j++) {
				isSimilar[i*j] = isPrime[i*j] = false;
			}
		}
	}
	// isSimilarを作る
	REP(i, 100000) {
		if (isPrime[i] & isPrime[(i + 1) / 2])	isSimilar[i] = true;
		else	isSimilar[i] = false;
	}
	// 普通にカウントすると死ぬので、cnt[i]:iまでのisSimilar[j]=trueの個数という配列を用意
	vint cnt(100010);
	SREP(i, 1, 100000) {
		cnt[i] = cnt[i - 1] + isSimilar[i];
	}
	// やっと入力を受ける
	int q;	cin >> q;
	while (q--) {
		int l, r;	cin >> l >> r;
		// cnt[r]-cnt[l-1]で十分
		cout << cnt[r] - cnt[l - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
N,M=map(int,input().split())
H=list(map(int,input().split()))
OK=[True]*N
for m in range(M):
    a,b=map(int, input().split())
    if H[a-1] <= H[b-1]: OK[a-1] = False
    if H[b-1] <= H[a-1]: OK[b-1] = False
print(OK.count(True))

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

int main()
{
    int a1, a2, a3, sum;
    cin >> a1 >> a2 >> a3;
    sum = a1 + a2 + a3;
    if (sum <= 21)
    {
        cout << "win";
    }
    else
    {
        cout << "bust";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int n;
int p[20010];
int a[20010];
int b[20010];

int main(){

  n = in();
  REP( i , n ){
    p[i] = in() - 1;
  }
  FOR( i , 1 , n ){
    int t = p[n-1-i];
    a[t+1] += i;
    a[n] -= i;
    b[0] += i;
    b[t] -= i;
  }
  REP( i , n ){
    a[i+1] += a[i];
    b[i+1] += b[i];
  }
  REP( i , n ){
    if( i != 0 ){
      printf( " " );
    }
    printf( "%lld" , a[i] + i + 1 );
  }
  printf( "\n" );

  REP( i , n ){
    if( i != 0 ){
      printf( " " );
    }
    printf( "%lld" , b[i] + n - i );
  }
  printf( "\n" );

  return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int sl(const void *a,const void*b){
    return *(int*) a - *(int*) b;
}
int ls(const void *a,const void*b){
    return *(int*) b - *(int*) a;
}
int main(){
	char s[101],t[101];
	scanf("%s%s",s,t);
	int u[101],v[101],i;
	for(i=0;i<strlen(s);i++){
	    u[i]=(s[i]-'a');
	}
	qsort(u,strlen(s),sizeof(int),sl);
	
	for(i=0;i<strlen(t);i++){
	    v[i]=(t[i]-'a');
	}
	qsort(v,strlen(t),sizeof(int),ls);
	
	for(i=0;i<strlen(s)&&i<strlen(t);i++){
	    if(u[i]<v[i]){
	        printf("Yes");
	        return 0;
	    }
	}
	if(u[i-1]==v[i-1]&&(i-1)<strlen(t)&&(strlen(t)>strlen(s))){
	    printf("Yes");
	    return 0;
	}
	printf("No");
	return 0;
}


Measured memory_bytes: 128
/// meowa 

#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define low lower_bound
#define upp upper_bound
#define sort(a) sort(a.begin(), a.end())
#define reverse(a) reverse((a).begin(), (a).end());
#define sz(x) (int) x.size()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF = 1e9 + 1e2;
  
//ll
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void stndrtn() {
#ifdef AM
    freopen(".in", "r", stdin);
#endif        
}                   

const bool flag = 0;

void ma1n() {
    int n;
    cin >> n;
    vector<int> l(n);
    for (int& x : l) {
        cin >> x;
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) { 
            for (int k = j+1; k < n; ++k) {
                int a = l[i], b = l[j], c = l[k];
                if (a == b || a == c || b == c) {
                    continue;
                }
                if (a < b+c && b < a+c && c < a+b) {
                    ans++;
                }
            }
        }
    }
    cout << ans;
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        ma1n(); 
    }
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
int main(){
  char s[5]={0};
  scanf("%s", s);
  
  if( (s[0]==s[1] && s[1]==s[2])
    ||(s[1]==s[2] && s[2]==s[3]) ){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 1700
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

struct Data{
    int A;
    string S;
    
    bool operator<( const Data& right ) const {
        return A == right.A ? S < right.S : A < right.A;
        //return A < right.A;
    }
};

int Func(){
    int x = 0;
    return x;
}

int main(){
    int M;
    long long d, c, digit, dc_all;
    digit = 0;
    dc_all = 0;
    
    // 入力
    cin >> M;
    for (int i=0;i<M;i++) {
        cin >> d >> c;
        digit += c;
        dc_all += d*c;
    }
    
    // cout << digit << " " << dc_all << endl;
    
    long long temp = dc_all/9;
    int aaa = dc_all%9;
    if (aaa==0) {
        temp -= 1;
    }
    
    cout << digit - 1 + temp << endl;
    
    return 0;
}

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



dsl={}
for i in range(n):
    sp=input().split()
    if sp[0] in dsl.keys():
        dsl[sp[0]].append([i,int(sp[1])])
    else:
        dsl[sp[0]]=[[i,int(sp[1])]]
l=sorted(dsl.items())
for i in range(len(l)):
    l[i][1].sort(key=lambda x:-x[1])
    for dd in l[i][1]:
        print(dd[0]+1)


Measured memory_bytes: 3064
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;

class Main {
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
  
    static boolean is_palindrome(String s){
        for (int i=0;i<=s.length()/2 ;i++ ) {
            if(s.charAt(i)!=s.charAt(s.length()-1-i)){
                return false;
            }
        }
        return true;
    }
	public static void main (String[] args) {
	    FastReader ob = new FastReader();
	    String s = ob.next();
	    int n = s.length();
	    //System.out.println(is_palindrome(s.substring(0,((n-1)/2))));
	    //System.out.println(is_palindrome(s.substring(((n+3)/2)-1,n)));
	    if(is_palindrome(s) && is_palindrome(s.substring(0,((n-1)/2))) && is_palindrome(s.substring(((n+3)/2)-1,n))){
	        System.out.println("Yes");
	        
	    }
	    else{
	        System.out.println("No");
	    }
	}
}

Measured memory_bytes: 23380
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

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

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

    int a[N];
    REP(0, i, N) {
        cin >> a[i];
    }

    sort(a, a + N);

    cout << a[N - 1] - a[0] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
#define N 100010
char a[N];
int s1[N],s2[N],t1[N],t2[N];
int main()
{
    int i,j,k,x,y,flag,n,m,k1,k2;
    int r1,r2;
    scanf("%s",a);
    scanf("%d%d",&n,&m);
    k=strlen(a);
    i=0;
    while(a[i]=='F'&&i<k)
    {
        n--;
        i++;
    }
    if(i==k)
    {
        if(n==0&&m==0)
        printf("Yes\n");
        else
        printf("No\n");
        return 0;
    }
    flag=0;
    k1=0;
    k2=0;
    x=0;
    y=0;
    for(;i<k;i++)
    {
        if(a[i]=='T')
        {
            if(flag==0)
            {
                if(x>0)
                s1[k1++]=x;
                x=0;
                flag=1;
            }
            else
            if(flag==1)
            {
                if(y>0)
                s2[k2++]=y;
                y=0;
                flag=0;
            }
        }
        else
        if(a[i]=='F')
        {
            if(flag==0)
            x++;
            else
            if(flag==1)
            y++;
        }
    }
    if(flag==0)
    {
        if(x>0)
        s1[k1++]=x;
        x=0;
        flag=1;
    }
    else
    if(flag==1)
    {
        if(y>0)
        s2[k2++]=y;
        y=0;
        flag=0;
    }
    r1=0;
    for(i=0;i<k1;i++)
    r1=r1+s1[i];
    r2=0;
    for(i=0;i<k2;i++)
    r2=r2+s2[i];
    n=fabs(n);
    m=fabs(m);
    if(r1<n||r2<m)
    {
        printf("No\n");
        return 0;
    }
    memset(t1,0,sizeof(t1));
    memset(t2,0,sizeof(t2));
    t1[r1]=1;
    for(i=0;i<k1;i++)
    for(j=r1;j>=s1[i];j--)
    t1[j-s1[i]]=t1[j]||t1[j-s1[i]];
    t2[r2]=1;
    for(i=0;i<k2;i++)
    for(j=r2;j>=s2[i];j--)
    t2[j-s2[i]]=t2[j]||t2[j-s2[i]];
    if(t1[(r1+n)/2]&&t2[(r2+m)/2]&&(r1+n)%2==0&&(r2+m)%2==0)
    printf("Yes\n");
    else
    printf("No\n");
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<list>
#include<vector>
#include<cmath>

#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;


int main(){

    int n;
    unsigned long long k;
    cin >> n >> k;

    unsigned long long a[1000002];
    rep(i,0,1000002)a[i] = 0;
    int num, quantity;
    rep(i,0,n){
        cin >> num >> quantity;
        a[num] += quantity;
    }

    unsigned long long count = 0;
    int itr = 1;
    while(count<k){
        count += a[itr];
        itr++;
    }

    cout << itr-1 << endl;



}


Measured memory_bytes: 8064
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<cmath>
#include<queue>
using namespace std;
int main(){
    long long x,y,ans,sum=0;
    scanf("%lld %lld",&x,&y);
    ans=((long long)(y/x));
    while(ans>=1)ans/=2,sum++;
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

// Union-Find 木 (Verified: AtCoder Typical Contest 001 B)
struct UnionFind {
private:
    const int n;
    int __size;
    vector<int> uf, edge_cnt;
public:
    // 初期化 UnionFind uni(n) のように宣言すれば良い
    UnionFind(int _n) : n(_n), __size(_n), uf(_n, -1), edge_cnt(_n, 0) {}
    // find (木の根を求める)
    int find(int x) {return (uf[x] < 0) ? x : uf[x] = find(uf[x]);}
    // x と y が同じ集合に属するかどうか
    bool same(int x, int y) {return find(x) == find(y);}
    // x が属する集合の要素数
    int size(int x) {return -uf[find(x)];}
    // 集合はいくつあるか
    int size()      {return __size;}
    int edge(int x) {return edge_cnt[find(x)];}
    // x と y の属する集合を併合
    void unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) {
            edge_cnt[x]++;
            return;
        }
        __size--;
        if(uf[y] < uf[x]) swap(x, y);
        uf[x] += uf[y]; edge_cnt[x] += edge_cnt[y] + 1; uf[y] = x;
    }
};

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

    UnionFind uf(N);
    rep(i,0,M) {
        int u, v; cin >> u >> v;
        u--; v--;
        uf.unite(u, v);
    }

    int vertices = max(uf.size(0), uf.size(1));
    set<int> S;
    S.insert(uf.find(0));
    S.insert(uf.find(1));

    int ans = 0;
    rep(k,0,2) {
        int V = uf.size(k);
        int comp = V * (V - 1) / 2;
        // printf("k = %lld, rest = %lld\n", k, comp - uf.edge(k));
        ans += comp - uf.edge(k);
    }

    int V = 0, E = 0;
    rep(i,2,N) {
        int f = uf.find(i);
        if(S.count(f)) continue;
        S.insert(f);
        // printf("find %lld (size = %lld)\n", i+1, uf.size(i));
        ans += uf.size(i) * vertices;

        V += uf.size(i);
        E += uf.edge(i);
    }
    int comp = V * (V - 1) / 2;
    ans += comp - E;

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

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b);
int main(void){
    int n,X; cin >> n >> X;
    int x[n+5];
    x[0] = X;
    for(int i = 1; i <= n; i++) cin >> x[i];
    sort(x, x+n+1);
    int mi = abs(x[1] -x[0]);
    for(int i = 1; i <= n; i++){
        int d = abs(x[i] -x[i-1]);
        mi = (mi > d) ? gcd(mi, d) : gcd(d,mi);
    }   
    cout << mi << endl;

}

int gcd(int a, int b){
    // a > b
    if(b == 0) return a;
    else return gcd (b, a%b);
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

//

int main(void){
	ll n,w,a1,a,v,ans=0,dp[110][310];
	bool visit[110][310];
	rep(j,110)rep(k,310){
		dp[j][k]=0;//dp[今まで何個とったか][Σ(とった奴-a[0])]=Σvalue
		visit[j][k]=0;
	}
	visit[0][0]=1;
	cin>>n>>w;
	reg(i,1,n){
		cin>>a>>v;
		if(i==1)a1=a;
		a-=a1;
		irep(j,i){
			rep(k,301){
				if((j+1)*a1+k+a>w)break;
				if(visit[j][k]){
					dp[j+1][k+a]=max(dp[j+1][k+a],dp[j][k]+v);
					visit[j+1][k+a]=1;
					ans=max(ans,dp[j+1][k+a]);
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let (A, B): (Vec<i64>, Vec<i64>) = {
        let (mut A, mut B) = (vec![], vec![]);
        for _ in 0..N {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            A.push(iter.next().unwrap().parse().unwrap());
            B.push(iter.next().unwrap().parse().unwrap());
        }
        (A, B)
    };

    let s = B.iter().sum::<i64>();
    let m = (0..N)
        .filter(|&i| A[i] > B[i])
        .min_by_key(|&i| B[i])
        .map_or(s, |i| B[i]);
    let ans = s - m;

    println!("{}", ans);
}


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

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_n = 4000+10;

int sumr[max_n];
int sumg[max_n];
int sumb[max_n];

int N;

int main(void) {
    cin>>N;
    string s;
    cin>>s;

    for(int i = N-1;i >= 0;i--) {
        sumr[i] += sumr[i+1];
        sumg[i] += sumg[i+1];
        sumb[i] += sumb[i+1];

        if(s[i] == 'R') {
            sumr[i]++;
        } else if(s[i] == 'G') {
            sumg[i]++;
        } else {
            sumb[i]++;
        }

    }

    Int sum = 0;
    for(int i = 0;i < N-2;i++) {
        for(int j = i+1;j < N-1;j++) {
            int k = j+1;
            if(s[i] == s[j])
                continue;

            if(s[i] == 'R') {
                if(s[j] == 'G') {
                    sum += sumb[k];
                    if(2*j-i < N && s[2*j-i] == 'B')
                        sum--;
                } else if(s[j] == 'B') {
                    sum += sumg[k];
                    if(2*j-i < N && s[2*j-i] == 'G')
                        sum--;
                }
            } else if(s[i] == 'G') {
                if(s[j] == 'R') {
                    sum += sumb[k];
                    if(2*j-i < N && s[2*j-i] == 'B')
                        sum--;
                } else if(s[j] == 'B') {
                    sum += sumr[k];
                    if(2*j-i < N && s[2*j-i] == 'R')
                        sum--;
                }
            } else { //b
                if(s[j] == 'R') {
                    sum += sumg[k];
                    if(2*j-i < N && s[2*j-i] == 'G')
                        sum--;
                } else if(s[j] == 'G') {
                    sum += sumr[k];
                    if(2*j-i < N && s[2*j-i] == 'R')
                        sum--;
                }
            }
        }
    }

    cout<<sum<<endl;

    return 0;
}



Measured memory_bytes: 3252
#include<iostream>

using namespace std;

int main() {
	long long A, B;
	int K;
	cin >> A >> B >> K;

	for (int i = 0; i < K; i++) {
		if (i % 2 == 0) {
			//高橋君ターン
			if (A % 2 == 1) {
				A = A - 1;
			}
			A = A / 2;
			B = B + A;
		}
		else {
			//青木君ターン
			if (B % 2 == 1) {
				B = B - 1;
			}
			B = B / 2;
			A = A + B;
		}
	}

	cout << A << " " << B << endl;
}


Measured memory_bytes: 256
N = gets.to_i
cnt = 0
sosu = (2..5555).to_a.select {|i| ret = true; (2...i).each {|j| ret = false if i % j == 0 }; ret }
sosu = sosu.select {|i| i % 5 == 1 }
N.times.each {|i| print "#{sosu[i]} " }

Measured memory_bytes: 1788
#include <iostream>

using namespace std;

int main(void) {
	int ryou[4][3][10] = { 0 };

	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		int b, f, r, v;
		cin >> b >> f >> r >> v;

		ryou[b - 1][f - 1][r - 1] += v;

		if (ryou[b - 1][f - 1][r - 1] < 0) {
			ryou[b - 1][f - 1][r - 1] = 0;
		}
	}

	for (int x = 0; x < 4; x++) {
		for (int y = 0; y < 3; y++) {
			for (int z = 0; z < 10; z++) {
				cout << " " << ryou[x][y][z];
			}
			cout << endl;
		}
		if (x == 3) {
			break;
		}
		cout << "####################" << endl;
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N, K; cin >> N >> K;
  string S; cin >> S;

  char mich = 'z'; rep(i,N) mich = min(mich,S[i]);
  string ts = S; reverse(all(ts));
  S += ts;
  int count[2*N+1] = {}; per(i,2*N) count[i] = S[i]==mich ? count[i+1]+1 : 0;
  int maco = 0; rep(i,N) maco = max(maco, count[i]);
  // debug(count, count+2*N+1);

  string mist = S.substr(0,N);
  rep(i,N) {
    if (count[i]==maco) {
      mist = min(mist, S.substr(i,N));
    }
  }
  // cout << mist << endl;
 

  string result;
  int p2 = 1, now = maco;
  while (now<=N) { now*=2; p2++; }

  if (K>=p2) rep(i,N) result += mich;
  else {
    rep(i,maco*pow(2,K-1)) result += mich;
    result += mist.substr(maco);
    result = result.substr(0,N);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
const int MAXN = 20005;
const int INF = 1e9;
int n;
int A[MAXN], B[MAXN], P[MAXN];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", P + i);
    B[P[1]] = 0;
    for (int i = 2; i <= n; i++)
        B[P[i]] = B[P[i - 1]] + 40000 * (P[i - 1] - P[i]) + 1;
    int _min = INF;
    for (int i = 1; i <= n; i++)
        _min = min(_min, B[i]);
    for (int i = 1; i <= n; i++)
        B[i] = B[i] - _min + 1;
    for (int i = 1; i <= n; i++)
        printf("%d ", 40000 * i);
    putchar('\n');
    for (int i = 1; i <= n; i++)
        printf("%d ", B[i]);
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
int main()
{
	int m1, d1, m2, d2;
	cin>>m1>>d1>>m2>>d2;
	if(month[m1-1] == d1)
		cout<<1<<endl;
	else
		cout<<0<<endl;
		
	return 0;
}

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

int n, ans;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    int i = 1;
    while(i <= n) i *= 2;
    cout << i/2 << endl;
    return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    auto n = readInt();
    long[] a, b;
    foreach(i; iota(n)) {
        auto ab = readInts();
        a ~= ab[0];
        b ~= ab[1];
    }
    long ans;
    foreach_reverse(i; iota(n)){ 
        a[i] += ans;
        if(a[i] % b[i] != 0) {
            ans += b[i] - (a[i] % b[i]);
        }
    }
    writeln(ans);
}



Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }   
    int ans = 0;
    REP(i, n){
        bool flag = true;
        REP(j, i){
            if(j < i && h[j] > h[i]) flag = false;
        }
        if(flag) ans++;
        // if(flag) DEBUG(i);
    }
    pr(ans);
}

Measured memory_bytes: 256
n,k,q = map(int,input().split())
li = []
for i in range(q):
    li.append(int(input()))
li2 = [k]*n
li2 = [x-q for x in li2]

for i in range(q):
    li2[li[i]-1] += 1

for i in range(n):
    if li2[i]>0:
        print("Yes")
    else:
        print("No")
    

Measured memory_bytes: 11832
#include <bits/stdc++.h>
using namespace std;
int main() {
	string o,e;
  	cin>>o>>e;
  
  	int last=o.size()-e.size();
  
  if(last==0){
  	for(int i=0;i<o.size();i++){
    	    cout<<o.at(i)<<e.at(i);
    }
    return 0;
  }
  
  if(last!=0){
  	for(int i=0;i<o.size()-1;i++){
    	    cout<<o.at(i)<<e.at(i);
    }
    cout<<o.at(o.size()-1);
    return 0;
  }
  
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

int func(int x) {
	if (x % 2 != 0)return 0;
	return 1 + func(x / 2);
}
int gcd(int x, int y) {
	if (x > y)return gcd(y, x);
	return x ? gcd(y%x, x) : y;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N,X,x[100010], y[100010],ans;
	cin >> N >> X;
	REP(i, N) {
		cin >> x[i];
		y[i] = abs(X - x[i]);
		if (i == 0)ans = y[i];
		ans = gcd(ans, y[i]);
	}
	cout << ans << endl;
	return 0;
}


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

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

 typedef long long ll;
 const long long INF = 1LL << 60;



 int main()
 {
    int n;
    
    while(1)
    {
        cin >> n;
        if(n == 0) break;

        vector<ll> dp(n+1, 0);
        dp.at(0) = 1;

        for(int i = 1; i < n+1; i++)
        {
            dp.at(i) += (ll)(dp.at(i-1));
            if(i > 1) dp.at(i) += (ll)(dp.at(i-2));
            if(i > 2) dp.at(i) += (ll)(dp.at(i-3));
        }

        dp.at(n) = (dp.at(n) + 10 - 1) / 10;
        ll ans = (ll)(dp.at(n) + 365 - 1) / 365;
        cout << ans << endl;
    }



    return 0;
 }


Measured memory_bytes: 3092
n=int(input())
a=[int(x) for x in input().split()]
flg=True
for i in a:
    if i%2 == 0:
        if i%3 == 0 or i%5 == 0:
         flg=True
        else:
         flg=False
         break

if flg:
    print("APPROVED")
else:
    print("DENIED")

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

// #define multitest 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.first << ", " << p.second << ']';
	return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
	std::cerr << name << " { ";
	for (const auto &v : arg)
		cerr << v << ' ';
	cerr << " }\n";
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;
auto TimeStart = chrono::steady_clock::now();

const int nax = 2e5 + 10;

void solve()
{
	int a, b;
	cin >> a >> b;
	cout << max(a + b, max(a - b, a * b));
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
#ifdef WIN32
	cerr << "\n\nTime elapsed: " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " seconds.\n";
#endif
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<vector<int>> F(N,vector<int>(10));
  for(int i=0; i<N; i++){
    for(int j=0; j<10; j++){
      cin >> F.at(i).at(j);
    }
  }
  vector<vector<int>> P(N,vector<int>(11));
  for(int i=0; i<N; i++){
    for(int j=0; j<=10; j++){
      cin >> P.at(i).at(j);
    }
  }
  
  vector<int> I(1023,0);
  for(int i=1; i<1024; i++){
    vector<int> c(N,0);
    for(int j=0; j<N; j++){
      for(int k=0; k<10; k++){
        if((i&(1<<k))&&F.at(j).at(k)){
          c.at(j)++;
        }
      }
    }
    for(int j=0; j<N; j++){
      I.at(i-1)+=P.at(j).at(c.at(j));
    }
  }
  sort(I.begin(),I.end());
  cout << I.at(1022) << endl;
}

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

#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1,i,j,k;
    //cin>>t;
    while(t--)
    {
        int n,count=0,sum=0,flag=0,maxi=-1,mini=1e18;
        cin>>n;
        string s;
        cin>>s;
        vector<int> r,g,b;
        for(i=0;i<n;i++)
        {
            if(s[i]=='R') r.push_back(i);
            else if(s[i]=='G') g.push_back(i);
            else b.push_back(i);
        }
        
        i=0;j=0;k=0;
        map<int,int> mp1,mp2,mp3;
        for(i=0;i<g.size();i++)
        {
            mp1[g[i]]++;
        }
        for(i=0;i<r.size();i++)
        {
            for(k=0;k<b.size();k++)
            {
                if((b[k]+r[i])%2==0)
                {
                    //cout<<(b[k]+r[i])/2<<"\n";
                    if(mp1.find((b[k]+r[i])/2)!=mp1.end())
                    {
                        count++;
                    }
                }
            }
        }
        for(i=0;i<r.size();i++)
        {
            mp2[r[i]]++;
        }
        for(i=0;i<g.size();i++)
        {
            for(k=0;k<b.size();k++)
            {
                if((b[k]+g[i])%2==0)
                {
                    //cout<<(b[k]+r[i])/2<<"\n";
                    if(mp2.find((b[k]+g[i])/2)!=mp2.end())
                    {
                        count++;
                    }
                }
            }
        }
        for(i=0;i<b.size();i++)
        {
            mp3[b[i]]++;
        }
        for(i=0;i<r.size();i++)
        {
            for(k=0;k<g.size();k++)
            {
                if((g[k]+r[i])%2==0)
                {
                    //cout<<(b[k]+r[i])/2<<"\n";
                    if(mp3.find((g[k]+r[i])/2)!=mp3.end())
                    {
                        count++;
                    }
                }
            }
        }
        cout<<g.size()*r.size()*b.size()-count;
    }
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s          second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep0(a,n)  for(int i=0;i<n;i++)cin>>a[i]
#define si(x)       cin>>x
#define sii(x,y)    cin>>x>>y
#define siii(x,y,z) cin>>x>>y>>z
#define ahell   998244353
#define hell 1000000007
#define N 1000001
#define fl 1.0000000000
//#define mod 998244353
#define cntbit(a) __builtin_popcountl(a)
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
vector<int>adj[100005];
int indeg[100005],lpath[100005];
main()
{
  ios
int n,m,i;
int j;
int u,v,q;
int test=1;
//si(test);

while(test--)
{
  cin>>n;
  double p[n];
  for(i=0;i<n;i++)
    cin>>p[i];

double dp[n+1][n+1];

for(i=0;i<=n;i++)
    for(j=0;j<=n;j++)
        dp[i][j]=0.00;

  dp[0][0]=1.00-p[0];
  dp[0][1]=p[0];

  for(i=1;i<n;i++)
    {
        for(j=0;j<=i+1;j++)
        {
            if(j==0)dp[i][j]=dp[i-1][j]*(1.00-p[i]);
            else
            dp[i][j]=dp[i-1][j]*(1.00-p[i])+dp[i-1][j-1]*(p[i]);
        }
    }

    double ans=0.00;
    for(i=n/2+1;i<=n;i++)
        {//cout<<dp[n-1][i]<<" ";
            ans+=(dp[n-1][i]);
        }

    cout<<setprecision(20)<<ans;

}

}


Measured memory_bytes: 76380
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://onlinejudge.u-aizu.ac.jp/challenges/search/volumes/0632>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
ll solve(){
    ll N,M,D; cin >> N >> M >> D;
    ll res = 0;
    vector<vector<char>> masu(N+2,vector<char>(M+2,'#'));
    for(int i = 1; i <= N;i++){
        for(int j = 1; j <= M;j++){
            cin >> masu[i][j];
        }
    }
    for(int i = 1; i <= N;i++){
        for(int j = 1; j <= M;j++){
            [&]{
                for(int k = 0; k < D;k++){
                    if(masu[i][j+k] == '#'){return;}
                }
                res++;
            }();
            [&]{
                for(int k = 0; k < D;k++){
                    if(masu[i+k][j] == '#') return;
                }
                res++;
            }();
        }
    }
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}



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

int vec[21][21];
int B[21];

int main() {
  int N,M,C;
 cin >> N >> M >> C;
  for(int j = 1; j <= M; j++){
      cin >> B[j];
    }
    int count = 0;
  for(int i = 1; i <= N; i++){
    int sum=0;
    for(int j = 1; j <= M; j++){
      cin >> vec[i][j];
      sum+=vec[i][j]*B[j];
      }
 if(sum+C > 0) count++;
  }
  cout << count << endl;


}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);        
        double w = stdIn.nextDouble();
        double h = stdIn.nextDouble();
        double x = stdIn.nextDouble();
        double y = stdIn.nextDouble();
        System.out.println(w*h/2 + " "+ (x == w/2 && y == h/2 ? 1 : 0));
    }
}


Measured memory_bytes: 25172