akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int maxn = 2e5 + 10;
int N;
string S;
set<string> s;
int main()
{
    scanf("%d", &N);
    while(N--)
    {
        cin >> S;
        s.insert(S);
    }
    printf("%d\n", s.size());
    return 0;
}


Measured memory_bytes: 19356
#include<bits/stdc++.h>
typedef long long ll;
#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7
#define pb           push_back
#define pi           acos(-1)
using namespace std;
//ll arr[105],arr1[105];
ll t;

int main()
{
    ll a,b,c,d,e,f,g,i,j;
    string s,ss,ee;
    cin>>s>>a;
    f=0;
    for(i=0;i<a;i++)
    {
        cin>>b;
        if(b==1)f++;
        else
        {
            string p;
            cin>>c>>p;
            if(c==1&&f%2==0)ss+=p;
            else if(c==1&&f%2==1)ee+=p;
            else if(c==2&&f%2==0)ee+=p;
            else ss+=p;
        }
    }
    if(f%2)reverse(ee.begin(),ee.end()),reverse(s.begin(),s.end()),cout<<ee<<s<<ss<<endl;
    else reverse(ss.begin(),ss.end()),cout<<ss<<s<<ee<<endl;
}


Measured memory_bytes: 1088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << "\n"; }
#define YN(f) cout << (f ? "YES" : "NO") << "\n"
#define Yn(f) cout << (f ? "Yes" : "No") << "\n"
#define yn(f) cout << (f ? "yes" : "no") << "\n"
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using ti3 = tuple<int, int, int>;
using tl3 = tuple<ll, ll, ll>;

int main() {
	int N, K; cin >> N >> K;
	vector<int> p(N); rep(i, N) cin >> p.at(i);
	vector<double> q(N); rep(i, N) q[i] = (1.0 + (double)p[i]) / 2.0;	
	dbv(q);
	double sum = 0.0; rep(i, K) sum += q[i];
	double ans = sum;
	rep2(i, K, N) {
		sum = sum + q[i] - q[i - K];
		ans = max(ans, sum);
	}
	cout << setprecision(10);
	cout << ans << endl;
}

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

int main() {
    while(true){
        ll m,n;
        cin>>m>>n;
        if(m==0&&n==0)break;
        vector<bool> is_prime(1e7+1,true);
        ll cnt=0;
        ll tmp;
        for(ll p=m;p<=1e7;p++){
            if(cnt==n){
                tmp=p;
                break;
            }
            if(!is_prime[p])continue;
            for(ll k=p*2;k<=1e7;k+=p)is_prime[k]=false;
            cnt++;
        }
        for(ll i=tmp;i<1e7;i++){
            if(is_prime[i]){
                cout<<i<<endl;
                break;
            }
        }
    }
}



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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

short dp[301][301][301];
string ss;

int dfs(int l, int r, int k) {
    if (dp[l][r][k] != -1) return dp[l][r][k];
    if (l == r) return 1;
    if (l > r) return 0;


    int ans = 0;
    if (k > 0) {
        ans = max(ans, dfs(l + 1, r - 1, k - 1) + 2); // replace l or r
    }
    ans = max(ans, dfs(l + 1, r, k)); // abandon l
    ans = max(ans, dfs(l, r - 1, k)); // abandon r

    if (ss[l] == ss[r]) {
        ans = max(ans, dfs(l + 1, r - 1, k) + 2);
    }
    return dp[l][r][k] = ans;
}

void solve(string S, ll K) {
    ss = S;
    memset(dp, -1, sizeof(dp));
    
    cout << dfs(0, S.size() - 1, K) << endl;
}

int main() {
    ll K;
    string S;
    cin >> S;
    scanf("%lld", &K);
    solve(S, K);
    return 0;
}



Measured memory_bytes: 53504
package main

import "fmt"

func main() {
	var s string
	var k int
	fmt.Scan(&s, &k)
	one := 0
	value := ""
	for _, i := range s {
		tmp := string(i)
		if tmp != "1" {
			value = tmp
			break
		}
		one++
	}
	if k <= one {
		fmt.Println(1)
	} else {
		fmt.Println(value)
	}
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int,int>;
//加算代入演算子は+=！！！！！

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    rep(i, n - 1) { //0~4
        if(s.at(i) != s.at(i + 1)) ans++; //01,12,23,34,45x
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;

int main(){
	int n;
	long long int result = 100000;
	cin >> n;
	for (; n > 0; --n) {
		result += result / 20 + 999;
		result -= result % 1000;
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
 
int main(){
	ll n;
  	cin>>n;
  	ll arr[n];
  	for(int i=0;i<n;i++)
      cin>>arr[i];
  	ll ans=0;
  	for(int i=1;i<n;i++){
      ans+=max(0ll, arr[i-1]-arr[i]);
      arr[i] = max(arr[i], arr[i-1]);
    }
  	cout<<ans;
}

Measured memory_bytes: 5156
// 物极必反

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 5e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const long double EPS = 1e-14;
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug(){
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main(){
    // freopen(".in", "r", stdin);
    // freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long x; cin >> x;

    for(long long i = 360, j = 0; j < 1000000; i += 360, j++){
        if(i % x == 0) return cout << i / x, 0;
    }

    return 0;
}


Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main(){
  int A, B, C, ans;

  cin >> A >> B >> C;

  if(A == B){
    ans = C;
  }else if(A == C){
    ans = B;
  }else if(B == C){
    ans = A;
  }

  cout << ans << endl;

  return 0;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string n = sc.Next();

        string answer = "";
        for (int i = 0; i < 3; i++)
        {
            if (n[i] == '1')
            {
                answer += "9";
            }
            else if (n[i] == '9')
            {
                answer += "1";
            }
            else
            {
                answer += n[i].ToString();
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
int main()
{
	//declare the variables//
	int a, b, c;

	//scan the numbers of the colors//
	scanf("%d %d %d", &a, &b, &c);

	//judge weather or not same numbersare included//
	if (a == b) {
		if (a == c) {
			printf("1\n");
		}

		else if (a != c) {
			printf("2\n");
		}
	}

	else if (a != b) {
		if (a == c) {
			printf("2\n");
		}

		else if (a != c) {
			if (b == c) {
				printf("2\n");
			}

			else if (b != c) {
				printf("3\n");
			}
		}
	}

	return(0);
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

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

	sort(friendliness.rbegin(), friendliness.rend());

	long long ans = friendliness[0];
	n -= 2;
	int i = 1;
	while (n > 1) {
		ans += 2 * friendliness[i];
		++i;
		n -= 2;
	}

	ans += n * friendliness[i];

	cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 4000
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

def po(x):
  p=x
  while p>10:
    p=p-10
  return p

k=[po(a),po(b),po(c),po(d),po(e)]
f=min(k)


s=a+b+c+d+e+40-po(a)-po(b)-po(c)-po(d)-po(e)+f

print(s)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define clear(a) memset(a,0,sizeof(a))
#define full(a) memset(a,0x3f,sizeof(a))
#define iosfast cin.tie(NULL),cout.tie(NULL),ios::sync_with_stdio(false)
#define fornext(x,i) for(int i=head[x]; i; i=nxt[i])
#define mset(a,b) memset(a,b,sizeof(a))
#define dbg cout<<"c "
using namespace std;
typedef long long ll;
int n,h,w;

int main() {
	cin>>h>>w>>n;
	cout<<ceil((double)n/max(h,w) );
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

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

        System.out.println(Math.max(Math.max(a + b, a - b), a * b));
        return;
    }
}


Measured memory_bytes: 23124
from collections import deque

N, M = map(int, input().split())
d = {i:[] for i in range(1, N+1)}

for _ in range(M):
    A, B = map(int, input().split())
    d[A].append(B)
    d[B].append(A)

q = deque([1])
INF = 10**20
dist = [INF]*(N+1)
dist[1] = 0
par = [-1]*(N+1)
par[1] = 0

while q:
    a = q.popleft()
    for b in d[a]:
        if dist[b] > dist[a]+1:
            dist[b] = dist[a]+1
            par[b] = a
            q.append(b)

print("Yes")
for i in range(2, N+1):
    print(par[i])

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

int main(int argc, char const *argv[])
{
	int n;
	long long t,a;
	cin>>n>>t>>a;
	t*=1000LL;
	a*=1000LL;
	long long h[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>h[i];
	}
	long long mi=1000000000000000LL;
	int ans=-1;
	for (int i = 0; i < n; ++i)
	{
		if (mi>abs(t-6LL*h[i]-a))
		{
			mi=abs(t-6LL*h[i]-a);
			ans=i+1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n, r;
int main() {
    cin>>n>>r;

    if(n>=10) cout<<r<<endl;
    else cout<<r+(100*(10-n))<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    string S,T;
    cin >> S >> T;
    int A,B;
    cin >> A >> B;
    string U;
    cin >> U;
    if(S==U) A--;
    else B--;
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

aa = inputs[0][0]
bb = inputs[0][1]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
end


puts [aa+bb, aa-bb, aa*bb].max


Measured memory_bytes: 1916
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

#define rep(i,n) for(int i=0;i<int(n);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,i,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

void solve(){
	int n, m;
	string s[105], t[105];
	cin >> n;
	rep(i,n)
		cin >> s[i];

	cin >> m;
	rep(i,m)
		cin >> t[i];

	int ans = 0;
	rep(i,n){
		int tmp = 0;
		rep(j,n){
			if(s[i] == s[j]){
				tmp++;
			}
		}
		rep(j,m){
			if(s[i] == t[j]){
				tmp--;
			}
		}
		ans = max(ans,tmp);
	}

	cout << ans << endl;

}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    double x,sub=0;
    string u;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>x>>u;
        if(u=="JPY"){sub+=x;}
        else{sub+=380000*x;}
    }
    cout<<sub<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vc vector
#define a first
#define b second
#define pb push_back
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)

/////////////////////////////////////////////////////////

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

/////////////////////////////////////////////////////////

void Main(){
  string Y; cin >> Y;
  Y = "0" + Y;
  int N = Y.size();
  vc<ll> dp1(N+1, INF), dp2(N+1, INF);
  dp1[0] = 0;
  rep(i, 1, N + 1){
    int k = Y[N-i] - '0';
    chmin(dp1[i], dp1[i-1] + k);
    chmin(dp2[i], dp1[i-1] + (10 - k));
    if(k == 9){
      chmin(dp2[i], dp2[i-1]);
    }else{
      chmin(dp1[i], dp2[i-1] + k + 1);
      chmin(dp2[i], dp2[i-1] + (10 - (k + 1)));
    }
  }
  cout << dp1[N] << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();

  return 0;
}


Measured memory_bytes: 16968
#include<stdio.h>
#include<stdlib.h>
 
#define MAX 251
//#define NIL -1
 
int main(void){
  int i,n,left,right;
  int A[MAX];
 
  scanf("%d", &n);
  for(i=1; i<n+1; i++) scanf("%d", &A[i]);
 
  for(i=1; i<n+1; i++){
    printf("node %d: key = %d, ", i, A[i]);
    if(i/2 != 0) printf("parent key = %d, ", A[i/2]);
    if(i*2 <= n) printf("left key = %d, ", A[i*2]);
    if(i*2+1 <= n) printf("right key = %d, ", A[i*2+1]);
    printf("\n");
  }
 
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main() {
  ios::sync_with_stdio(0); 
  cin.tie(0); 

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (a <= c && b > c) cout << min(b, d) - c << "\n";
  else if (c <= a && d > a) cout << min(b, d) - a << "\n";
  else cout << 0 << "\n";
}


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

int main() {
    int x, y;
    cin >> x >> y;
    while(!(x == 0 && y == 0)) {
        if (x < y) cout <<  x << " " << y << endl;
        else cout << y << " " << x << endl;
        cin >> x >> y;
    }
}


Measured memory_bytes: 3004
n = input()
nums = map(int,raw_input().split())
x = 2
checklist = [0 for i in xrange(n)]
table = []
while x<=max(nums):
    i=0
    while i<n:
        if nums[i]%x==0:
            checklist[i]=0
            nums[i] = nums[i]/x
        else:
            checklist[i]=1
        i+=1
    if 0 in checklist:
        table.append(x)
    else:
        x+=1
ans = 1
# print nums
# print table
if len(table)==0:
    for num in nums:
        ans *= num
else:
    for num in nums:
        ans *= num
    for y in table:
        ans *= y
print ans

Measured memory_bytes: 6448
import math, itertools
n = int(input())
l= []
for _ in range(n):
    l.append(list(map(int, input().split())))
s = [i for i in range(n)]
lis = list(itertools.permutations(s, n))
j = 0
sm = 0
for i in range(len(lis)):
    for j in range(n-1):
        sm += ((l[lis[i][j]][0]-l[lis[i][j+1]][0])**2+(l[lis[i][j]][1]-l[lis[i][j+1]][1])**2)**0.5
print(sm/math.factorial(n))

Measured memory_bytes: 8180
n,k = map(int,input().split())

ans = 0

for i in range(1,n+1):
    #print(i)
    if i == k:
        ans += n-k+1
        break
    for j in range(1,200000):
        if i * (2**j) >= k:
            ans += (1/2)**j
            #print(ans)
            break

ans = ans * 1.0/n

print(ans)

Measured memory_bytes: 2940
#include <iostream>

int main()
{
	int n, x;
	for (;;) {
		std::cin >> n >> x;
		if (n==0 && x==0) break;
		int count {};
		for (int i=1; i<=n; ++i)
			for (int j=i+1; j<=n; ++j)
				for (int k=j+1; k<=n; ++k)
					if (i+j+k == x) ++count;
		std::cout << count << '\n';
	}
}

Measured memory_bytes: 3084
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int w = sc.nextInt();
    long dp[] = new long[w+1];
    dp[0] = 0;
    int wt[] = new int[n];
    int v[] = new int[n];
    for (int i=0; i<n; i++) {
      wt[i] = sc.nextInt();
      v[i] = sc.nextInt();
    }
    long ans = 0;
    for (int i=0; i<n; i++) {
      for (int W=w; W-wt[i]>=0; W--) {
        dp[W] = Math.max(dp[W], dp[W-wt[i]] + v[i]);
        ans = Math.max(ans, dp[W]);
      }
    }
    System.out.println(ans);
  }
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll ,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

int n,m;
int main(){
	cin >> n >> m;
	vector<int>c(m);
	for(int i = 0; i < m; i++)cin >> c[i];

	int dp[50050];
	for(int i = 0; i < n+1; i++)dp[i] = INTMAX;
	dp[0] = 0;
	for(int i = 0; i < n+1; i++){
		for(int j = 0; j <= c[m-1]; j++){
			if(i - c[j] >= 0){
				int tmp = dp[i - c[j]] + 1;
				dp[i] = min(tmp , dp[i]);
			}
		}
	}
	// for(int i = 0; i < n+1; i++)cout << dp[i] << " ";
	// cout << endl;
	cout << dp[n] << endl;
}


Measured memory_bytes: 3304
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  char s[100];
  scanf("%s",s);
  int n =strlen(s);
  //printf("%d\n",n);
 

  int ans=1;
  for(int i=0;i<(n-1)/2;i++){
    if(s[i]!=s[n-1-i]){
      ans=0; break;}}
  for(int i=0;i<(n-1)/4;i++){
    if(s[i]!=s[(n-1)/2-1-i]){
      ans=0; break;}}
  /*
  for(int i=(n+3)/2-1;i<n;i++){
    if(s[i]!=s[n-1-(i-(n+3)/2+1)]){
    ans=0; break;}}*/

  if(ans==1){
    printf("Yes\n");}
  else{
    printf("No\n");}

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a<b?a:b)
#define ll long long
inline int read(){
	int f=1,x=0;char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(c<='9'&&c>='0'){
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
 
inline void file(){
	freopen("1.in","r",stdin);
	freopen("1.out","w",stdout);
}
 
using namespace std;
const ll maxn=1e6+10;
ll a[maxn],b[maxn];
 
int main(){
	ll k,n,h;
	//scanf("%lld%lld",&n,&h);
	cin>>n>>h;
	for(register ll i=1;i<=n;++i)
		cin>>a[i]>>b[i];
	sort(b+1,b+n+1);
	sort(a+1,a+n+1);
	for(register ll i=1;i<=n;++i)
		b[i]=max(b[i],a[n]);
	ll ovo=0;
	for(register ll i=n;i>=1;--i){
		ovo+=b[i];
		if(ovo>=h){
			printf("%lld",n-i+1);
			return 0;
		}
	}
	if(ovo<h){
		h-=ovo;
		printf("%lld",n+(h/a[n])+(h%a[n]==0?0:1));
	}
	return 0;
}


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

#define endl '\n'

void solve(){
    long long a,b; cin >> a >> b;
    cout << a*b;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1; //cin >> t;
    while(t--) solve();
}

Measured memory_bytes: 3652
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e6+7;
const int N = 1e5+7;


void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

    
int main()
{
    
        int n;
        scf(n);
        
        if(n>=400&&n<=599)
        prin(8);
        
        else if(n>=600&&n<=799)
        prin(7);
        
        else if(n>=800&&n<=999)
        prin(6);
        
            
        else if(n>=1000&&n<=1199)
        prin(5);
        
            
        else if(n>=1200&&n<=1399)
        prin(4);
        
            
        else if(n>=1400&&n<=1599)
        prin(3);
        
            
        else if(n>=1600&&n<=1799)
        prin(2);
        
            
        else if(n>=1800&&n<=1999)
        prin(1);
        
    
}
    
        

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

using namespace std;

void Main() {
    long long x;
    cin >> x;

    long long ans = 0LL;
    if (x <= 6) {
        ans += 1;
    }
    else if (x <= 11) {
        ans += 2;
    }
    else { // 11 < x
        ans += 2 * (x / 11LL);
        long long res = x % 11;
        if (0 < res && res <= 6) {
            ans += 1;
        }
        else if (6 < res) {
            ans += 2;
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int const N = 500000, md = 998244353;
int fc[N + 1], inv[N + 1], fcin[N + 1];

int ch(int n, int r) { return (ll)fc[n] * fcin[r] % md * fcin[n - r] % md; }
void ad(int &x, int y) { if ((x += y) >= md)x -= md; }

int pw(int x, int p){
	int an = 1;
	while (p){
		if (p & 1)an = (ll)an * x % md;
		x = (ll)x * x % md;
		p >>= 1;
	}
	return an;
}

int main(){
	fc[0] = 1;
	f(i, 1, N + 1)fc[i] = (ll)fc[i - 1] * i % md;
	inv[1] = 1;
	f(i, 2, N + 1)inv[i] = md - md / i * (ll)inv[md % i] % md;
	fcin[0] = 1;
	f(i, 1, N + 1)fcin[i] = (ll)fcin[i - 1] * inv[i] % md;
	int n, m;
	scanf("%d%d", &n, &m);
	if (n > m)swap(n, m);
	int an = 0;
	f(i, 0, n + 1){
		int z = (ll)pw(m + 1, n - i) * pw(n + 1, m - i) % md * ch(n, i) % md * ch(m, i) % md * fc[i] % md;
		if (i & 1)z = md - z;
		ad(an, z);
	}
	printf("%d\n", an);
}

Measured memory_bytes: 6144
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

const double EPS = 1e-9;

bool iszero( double a )
{
	return a < EPS;
}

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

	while ( true )
	{
		int x, y, z;
		cin >> x >> y >> z;

		if ( !( x | y | z ) )
		{
			break;
		}

		VI vs( x );
		EACH( v, vs )
		{
			cin >> v;
		}

		vector< PII > ys( y + 1, MP( 0, 0 ) );
		REP( i, 0, z )
		{
			int n, e, a;
			cin >> n >> e >> a;

			ys[n] = MP( e, a );
		}

		vector< vector< double > > dp( y + 1, vector<double>( y * 100 + 1, 0 ) );
		dp[0][0] = 1;

		REP( i, 0, y )
		{
			REP( j, 0, y * 100 + 2 )
			{
				if ( iszero( dp[i][j] ) )
				{
					continue;
				}

				REP( k, 0, x )
				{
					int ni = min( y, i + vs[k] );
					int nj = j;

					switch ( ys[ ni ].fst )
					{
						case 1:
							ni += ys[ ni ].snd;
							ni = min( ni, y );
							break;
						case 2:
							nj += ys[ ni ].snd;
							break;
						case 3:
							nj -= ys[ ni ].snd;
							nj = max( nj, 0 );
							break;
					}

					dp[ ni ][ nj ] += dp[i][j] / x;
				}
			}
		}

		double res = 0;

		REP( i, 0, y * 100 + 1 )
		{
			res += dp.back()[i] * i;
		}

		cout << (int)res << endl;
	}

	return 0;
}

Measured memory_bytes: 3188
#include<stdio.h>
int main()
{
  int n,i,sum;
  sum=0;
  scanf("%d",&n);
  
  int a[n],b[n],c[n];
  for(i=0;i<n;++i)
  {scanf("%d",&a[i]);}
  
  for(i=0;i<n;++i)
  {scanf("%d",&b[i]);
  sum=sum+b[i];
  }
  
  for(i=0;i<n;++i)
  {scanf("%d",&c[i]);
  }
  
  for(i=0;i<n;++i)
  {
  if(a[i+1]-a[i]==1) sum=sum+c[a[i]-1];  
  }
  
  printf("%d",sum);
return 0;  
}

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

#define llong long long /*{{{*/
#define ii pair<int, int>
#define xx first
#define yy second
#define len(x) ((int)x.size())
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )

template<typename a> ostream& operator<<(ostream& cout, const vector<a>& b) {
  cout << "[";
  if (len(b)) cout << b[0];
  rep1(i, len(b) - 1) cout << ", " << b[i];
  return cout << "]";
}

template<typename u, typename v> ostream& operator<<(ostream& cout, const pair<u, v> a) {
  return cout << "(" << a.xx <<", " << a.yy << ")";
}/*}}}*/


int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n, m; cin >> n >> m;
  llong ans = 1;
  for (llong i = 1; i * i <= m; ++i) {
    if (m % i) continue;
    if (i >= n) ans = max(ans, m / i);
    if (m / i >= n) ans = max(ans, i);
  }
  cout << ans;
  
  return 0;
}


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

int main(){
  int N,K;
  cin>>N>>K;
  int sum=1;
  
  sum*=K;
  for(int i=1;i<N;i++){
    sum*=K-1;
  }
  
  cout<<sum<<endl;
}
  

Measured memory_bytes: 256
n = int(input())
numbers = list(map(int, input().split()))

flag = None
s = 1
for i, x in enumerate(numbers):
    if i == 0:
        continue
    if x == numbers[i-1]:
        continue
    if x > numbers[i-1]:
        if flag is None:
            flag = 1
        if flag == 0:
            s += 1
            flag = None
    elif x < numbers[i-1]:
        if flag is None:
            flag = 0
        if flag == 1:
            s += 1
            flag = None
print(s)



Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int A,B,C,temp;
	cin>>A>>B>>C;
	if(B<A){
		cout<<0;
	}
	else{
		temp=B/A;
		if(temp>C){
			cout<<C;
		}
		else{
			cout<<temp;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl v(n);
	rep(i,n)cin>>v[i];
	ll ans=0;
	rep(i,n){
		range(j,i+1,n){
			ans+=v[i]*v[j];
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        double B = sc.nextDouble();
        int b = (int)Math.floor(B*100+0.5);
        System.out.println(A*(b/100)+(A*(b%100))/100);
    }
}


Measured memory_bytes: 37216
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n, k = MII()
    aa = MII()
    for i in range(k, n):
        if aa[i] > aa[i-k]:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 31692
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N;
  cin >> N;
  set<i64> ans;
  ans.insert(2);
  ans.insert(N);
  if (2 < N)
    ans.insert(N - 1);
  for (i64 i = 2; i * i <= N; i++)
  {
    if ((N - 1) % i == 0)
    {
      ans.insert(i);
      ans.insert((N - 1) / i);
    }
    i64 n = N;
    while (i <= n)
      if (n % i == 0)
        n /= i;
      else
        n %= i;
    if (n == 1)
      ans.insert(i);
  }
  cout << ans.size() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

//https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_b

int main()
{
    std::ios::sync_with_stdio(false); // toggler av synkronisjon mellom c og c++ data streams. kan ikke blade de etter skrudd av
    std::cin.tie(NULL);               //gj;r at man ikke venter på cout og de can printe samtidig tror jeg

    float N;
    std::cin >> N;

    int min = ((N - 10) * 0.926 - 1);
    int max = ((N + 10) * 0.926 + 1);

    for (int i = min; i < max; i++)
    {
        int nGuess = i * 1.08;
        if (nGuess == N)
        {
            std::cout << i << "\n";
            return 0;
        }
    }

    std::cout << ":(\n";
}


Measured memory_bytes: 3744
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

using i8 = std::int_least8_t;
using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u8 = std::uint_least8_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

void main_() {
  u32 a, b, t;
  std::cin >> a >> b >> t;
  std::cout << b * (t / a) << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 768
N = int(input())
p = list(map(int, input().split()))

cnt = 0

for i in range(len(p)):
    if p[i] == i+1:
        if p[i] == N:
            p[i-1], p[i] = p[i], p[i-1]
        else:
            p[i], p[i+1] = p[i+1], p[i]
        cnt += 1

print(cnt)


Measured memory_bytes: 20608
N,M,Q = map(int,input().split())

train = [[0 for i in range(N+1)] for j in range(N+1)]
for m in range(M):
    L,R = map(int,input().split())
    train[L][R] += 1

c = [[0 for i in range(N+1)] for j in range(N+1)]
for i in range(1,N+1):
    cnt = 0
    for j in range(1,N+1):
        c[i][j] = train[i][j] + c[i-1][j] + c[i][j-1] - c[i-1][j-1]

for x in range(Q):
    p,q = map(int,input().split())
    print(c[q][q]-c[q][p-1]-c[p-1][q]+c[p-1][p-1])

Measured memory_bytes: 15528
W,H,x,y,r=map(int,input().split())

if (r+y)>H:
    print("No")
    
elif (r+x)>W:
    print("No")

elif (y-r)<0:
    print("No")
    
elif (x-r)<0:
    print("No")
    
else :
    print("Yes")


Measured memory_bytes: 5596
while True:
	N=int(input())
	if N==0:
		break
	a,b=0,0
	for i in range(N):
		info=input().split()
		A,B=int(info[0]),int(info[1])
		if A>B:
			a+=(A+B)
		elif A<B:
			b+=(A+B)
		else:
			a+=A
			b+=B
	print(str(a)+" "+str(b))

Measured memory_bytes: 7520
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mk make_pair
#define pb push_back
#define vi vector<int>
#define x first
#define y second
#define ms(a,b)  memset(a, b, sizeof(a))
#define rep(i,a,b)  for(int i=a;i<b;i++)
// #define M (int)1e9 + 7
signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    string inp[n];
    for(int i=0;i<n;i++)cin>>inp[i];
    int dp[n][m],M=1000000007;
    // memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++)for(int j=0;j<m;j++)dp[i][j]=0;
    dp[0][0]=1;
    for(int i=1;i<m;i++)
        if(inp[0][i-1]=='.' && inp[0][i]=='.')dp[0][i]=dp[0][i-1];
    for(int i=1;i<n;i++)
        if(inp[i-1][0]=='.' && inp[i][0]=='.')dp[i][0]=dp[i-1][0];
    for(int i=1;i<n;i++)
        for(int j=1;j<m;j++){
            if(inp[i][j]=='.'){
                if(inp[i-1][j]=='.')dp[i][j]=(dp[i][j]%M + dp[i-1][j]%M)%M;
                if(inp[i][j-1]=='.')dp[i][j]=(dp[i][j]%M + dp[i][j-1]%M)%M;
            }
        }
    cout<<dp[n-1][m-1];
    return 0;
}

Measured memory_bytes: 9088
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>

using namespace std;
int main(){
	int p,q,r;

	scanf("%d %d %d",&p,&q,&r);

	if(p>=q && p>=r)printf("%d",q+r);
	else if(q>=p && q>=r)printf("%d",p+r);
	else if(r>=p && r>=q)printf("%d",p+q);

	return 0;
}

Measured memory_bytes: 256
program number_of_multiples
  implicit none
  integer :: l, r, d, i, x = 0
  read(*,*) l, r, d
  do i = l, r
    if (mod(i, d) == 0) x = x + 1
  end do
  write(*,'(i0)') x
end program number_of_multiples

Measured memory_bytes: 2928
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x&&x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS*max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x*x + y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;


#if 1

static bool dp[2][16000+10];

bool ok( const vector <int>& ud, int goal)
{

	const int S = SZ(ud);
	if (S == 0)
	{
		return goal == 0;
	}

	memset(dp, 0, sizeof(dp));
	const int GETA = 8000+2;
	dp[0][GETA] = true;


	int now;
	int next;
	for (int i=0;i<S;++i)
	{
		now = i % 2;
		next = 1 - now;

		memset(dp[next], 0, sizeof(dp[next]));
		for (int y = -GETA; y <= GETA; y++)
		{
			if (dp[now][y+GETA])
			{
				dp[next][y + GETA + ud[i]] = true;
				dp[next][y + GETA - ud[i]] = true;
			}
		}
	}

	return dp[next][goal + GETA];
}

int main()
{
	string s;

	cin >> s;
	s += 'T';

	int x, y;
	cin >> x >> y;

	vector <int> ud, lr;

	int turn = 0;
	int forward = 0;
	for (int i=0;i<SZ(s);++i)
	{
		if (s[i] == 'T')
		{

			if (turn == 0)
			{
				x -= forward;
			}
			else if (turn % 2 == 1)
			{
				ud.push_back(forward);
			}
			else
			{
				lr.push_back(forward);
			}

			turn++;

			forward = 0;
		}
		else
		{
			forward++;
		}
	}

	if (ok(ud, y) && ok(lr, x))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;






}

#else

int main()
{
	int N;
	scanf("%d", &N);

	map <int, int> mp;
	for (int i = 0; i < N; ++i)
	{
		int tmp;
		scanf("%d", &tmp);

		mp[tmp]++;
	}

	int ans = 0;

	for (auto& a : mp)
	{
		if (a.second > a.first)
		{
			ans += a.second - a.first;
		}
		else if (a.second < a.first)
		{
			ans += a.second;
		}
	}


	printf("%d\n",ans);

	return 0;

}

#endif



Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

void yakusuu(int num, vector<int> &kouho)
{
	for (int i = 1; i * i <= num; i++) {
		if (num % i == 0) {
			kouho.push_back(i);
			kouho.push_back(num / i);
		}
	}
}

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}

	sort(a.begin(), a.end());
	int num0 = a.at(0);
	int num1 = a.at(1);

	vector<int> kouho;
	yakusuu(num0, kouho);
	yakusuu(num1, kouho);
	
	int ans = 1;
	for (int kouho_ele : kouho) {
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			if (a.at(i) % kouho_ele != 0) {
				cnt++;
			}
			if (cnt > 1) {
				break;
			}
		}
		if (cnt <= 1) {
			ans = max(ans, kouho_ele);
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#define int long long
using namespace std;
inline int read(){
	int x=0,w=0;char c=getchar();
	while(!isdigit(c))w|=c=='-',c=getchar();
	while(isdigit(c))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return w?-x:x;
}
int a,b,ans;
signed main(){
	a=ans=read();b=read();
	b=min(b,a-b);
	a=a-b;
	do{
		ans+=b*2*(a/b);
		int t=a;
		a=b;
		b=t%b;
	}while(b);
	printf("%lld",ans-a);
	return 0;
}

Measured memory_bytes: 3700
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

int main() {
	int H, W;
	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (i == 0) cout << "#";
				else if (i == H - 1) cout << "#";
				else if (j == 0) cout << "#";
				else if (j == W - 1) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 2992
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N, H, W;
  std::cin >> N >> H >> W;
  std::cout << (N - H + 1) * (N - W + 1) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void){
    int N,ans = 0;
    cin >> N;
    int L[N];
    for(int i = 0;i < N;i++){
        cin >> L[i];
    }
    sort(L,L + N);
    for(int i = 0;i < N;i++){
        for(int j = i + 1;j < N;j++){
            for(int k = j + 1;k < N;k++){
                if(L[k] >= L[i] + L[j]){
                    break;
                }else{
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#define INF 1e9
#define eps 1e-6
typedef long long ll;

int a, b;

inline int max(int a, int b){
	return a > b ? a : b;
}

int main(){

	scanf("%d%d", &a, &b);
	for(int i = b - a + 1; i <= b + a - 1; i++)
		printf("%d ", i);

	return 0;
}


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



int main (){
    ll n;
    cin >> n;
    string s;
    while(1){
        if (n <= 0){
            break;
        }
        n--;
        s += 'a' + n % 26;
        n/=26;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3616
def water(a, l, r):
    for i in range(l, r+1):
        a[i] -= 1


N = int(input())
a = list(map(int, input().split()))
cnt = 0
while True:
    l = N
    r = N-1
    for i in range(N):
        if a[i] != 0:
            l = i
            break

    if l == N:
        break
    else:
        for i in range(l, N):
            if a[i] == 0:
                r = i-1
                break
        
    water(a, l, r)
    cnt += 1

print(cnt)


Measured memory_bytes: 3064