akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int seconds = Integer.parseInt(br.readLine());

		int hh = seconds / (60 * 60);
		int mm = seconds % (60 * 60) / 60;
		int ss = seconds % (60 * 60) % 60;

		System.out.println(hh + ":" + mm + ":" + ss);
	}
}

Measured memory_bytes: 24096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep(i,n) FOR(i,0,n-1)
#define int long long
#define MOD 998244353
#define MAXN  100005
#define P pair<int,int>

signed main(){
	
	int n;cin>>n;
	int a[n];
	rep(i,n) 
	{
		cin>>a[i];
		a[i]--;
	}
	int ans = 0;
	rep(i,n)
	{
		if(a[i] < i) continue;
		if(a[a[i]] == i) ans++;
	}
	cout << ans << endl;
}

//cout << ans << endl;

Measured memory_bytes: 1024
import java.util.*;

public class Main {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        while(true) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            int p = sc.nextInt();
            if (n == 0) {
                break;
            }
            int[] arr = new int[n + 1];
            int total = 0;
            for (int i = 1; i <= n; i++) {
                arr[i] = sc.nextInt();
                total += arr[i] * 100;
            }
            total = total * (100 - p) / 100;
            if (arr[m] == 0) {
                sb.append(0).append("\n");
            } else {
                sb.append(total / arr[m]).append("\n");
            }
        }
        System.out.print(sb);
    }
}


Measured memory_bytes: 36180
#include<cstdio>
#include<algorithm>

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

using namespace std;

typedef long long ll;

int main(){
	int n; scanf("%d",&n);
	static int l[499999],r[499999];
	rep(i,n-1) scanf("%d%d",l+i,r+i), l[i]--, r[i]--;

	static int depth[499999];
	rep(u,n-1){
		if(l[u]!=n-1) depth[l[u]]=depth[u]+1;
		if(r[u]!=n-1) depth[r[u]]=depth[u]+1;
	}

	static int leaf[500000]; // leaf[u] := ( 頂点 u を根とする部分木の葉の数 )
	static ll dp1[500000]; // dp1[u] := ( 頂点 u を根とする部分木について, セーブ機能を使わないときの答え ), u より上の頂点は無いものと思う
	static ll dp2[500000]; // dp2[u] := ( 頂点 u を根とする部分木についての最適解 ), u より上の頂点は無いものと思う
	leaf[n-1]=1;
	for(int u=n-2;u>=0;u--){
		leaf[u]=leaf[l[u]]+leaf[r[u]];

		dp1[u]=leaf[u]+dp1[l[u]]+dp1[r[u]];

		dp2[u]=1+dp2[l[u]]+depth[u]+1+dp2[r[u]];
		dp2[u]=min(dp2[u],leaf[l[u]]+dp1[l[u]]+1+dp2[r[u]]);
		dp2[u]=min(dp2[u],leaf[r[u]]+dp1[r[u]]+1+dp2[l[u]]);
	}

	printf("%lld\n",dp2[0]);

	return 0;
}

Measured memory_bytes: 16648
import java.util.*;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long p = sc.nextLong();
		if (n == 1) {
			System.out.println(p);
			return;
		}
		long res = 1;
		for (int i = 2; Math.pow(i, n) <= p; i++) {
			if (p % Math.pow(i, n) == 0) res = i;
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 10e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//
struct C
{
  int A,B;
};
C c[100010];
signed main()
{
  ios();
  int N,M;
  cin >> N >> M;
  rep(i,N) cin >> c[i].A >>c[i].B;
  sort(c,c+N,[](C a, C b){return a.A < b.A;});
  int cnt = 0;
  rep(i,N)
  {
    int pre = M;
    M -= c[i].B;
    if(M <= 0)
    {
      cnt += c[i].A * pre;
      break;
    }
    cnt += c[i].A * c[i].B;
  }
  cout << cnt << endl;
}


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

long long d[200][200];

void warshall_floyd(int n) {
  for (int k = 0; k < n; k++){       
    for (int i = 0; i < n; i++) {    
      for (int j = 0; j < n; j++) {  
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main(){
    for(int i=0;i<200;++i){
        for(int j=0;j<200;++j){
            if(i==j)d[i][j]=0;
            else d[i][j]=1e18;
        }
    }
    int n,m,r;cin>>n>>m>>r;
    vector<int>R(r);
    for(int i=0;i<r;++i){
        cin>>R[i];
        R[i]--;
    }
    sort(R.begin(),R.end());
    for(int i=0;i<m;++i){
        long long a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        d[a][b]=c;
        d[b][a]=c;
    }
    warshall_floyd(n);
    long long ans=1e18;
    do{
        long long sum=0;
        for(int i=1;i<r;++i){
            sum+=d[R[i-1]][R[i]];
        }
        ans=min(ans,sum);
    }while(next_permutation(R.begin(),R.end()));
    cout<<ans<<endl;
}


Measured memory_bytes: 3888
n = int(input())
a = n//4
b = n//7
flag = False
for i in range(a+1):
    for j in range(b+1):
        if i * 4 + j * 7 == n:
            flag = True
            break
    if flag == True:
        break
print("Yes" if flag == True else "No")

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

int m,k;

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> m >> k;

  if (k >= (1<<m) || (m == 1 && k >= 1)) {
    cout << -1 << endl;
    return 0;
  }

  vi g1,g2;
  for (int i = 0; i < (1<<m); i++) {
    if ((k & i) && popcnt(i) == 1) g1.push_back(i);
    else g2.push_back(i);
  }

  for (int v : g1) printf("%d ", v);
  for (int v : g2) printf("%d ", v);
  for (int i = g1.size()-1; i >= 0; i--)
    printf("%d ", g1[i]);
  for (int i = g2.size()-1; i >= 0; i--)
    printf("%d%c", g2[i], " \n"[i==0]);

  return 0;
}


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

int main()
{
    int sigma(int x);
    int a, b;
    cin >> a >> b;
    int c = sigma(b-a-1);
    cout << c-a << endl;
    return 0;
}

int sigma(int x){
    if(x == 0){
        return 0;
    }
    else{
        int sum = 0;
        while(x>0){
            sum += x;
            x--;
        }
        return sum;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define lld long long int 

//-4%3=-1



int main() {
	// your code goes here
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t;
    //cin>>t;
    t=1;
    while(t--)
    {
        int n;
        int arr[100001],dp[100001];
        memset(dp,INT_MAX,sizeof(dp));
        cin>>n;
        for(int i=1;i<=n;i++)
        cin>>arr[i];
        dp[1]=arr[1];
        dp[2]=abs(arr[1]-arr[2]);
        if(n>=2)
        dp[3]=min(abs(arr[1]-arr[3]),dp[2]+abs(arr[2]-arr[3]));
        for(int i=4;i<=n;i++)
        {
            dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
        }
        cout<<dp[n];
    }
}



Measured memory_bytes: 1024
fun main(args : Array<String>) {
  val (n, m, x) = readLine()!!.split(" ").map { it.toInt() }
  var count = 0
  readLine()!!.split(" ").forEach {
    if (it.toInt() > x) {
      print(listOf(count, m - count).min())
      return
    } else count++
  }
}

Measured memory_bytes: 37776
A,B = map(int,input().split(" "))
DIF = B - A
if (A % 4 == 0 and B % 4 == 0) or DIF == 0:
    print(B)
else:
    list = []
    for i in range(A,A+4):
        if i % 4 != 0:
            list.append(i)
        elif i % 4 == 0:
            break
    flag = 0
    for i in range(B-3,B+1):
        if i % 4 != 0 and flag == 0:
            pass
        elif i % 4 == 0:
            list.append(i)
            flag = 1
        elif i % 4 != 0 and flag == 1:
            list.append(i)
    #print(list)
    total = 0
    for i in range(len(list)):
        num = list[i]
        #print(num ^ total)
        total = total ^ num 
    print(total)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        while (true) {
            int H = sc.nextInt();
            int W= sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            int i,j;
            for(i=0;i<H;i++){
                for (j=0;j<W;j++){
                    if((i+j)%2==0){
                        System.out.printf("#");
                    }else if((i+j)%2==1){
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }

        sc.close();
    }

}


Measured memory_bytes: 62220
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,M;
  cin >> N >> M;
  vector<int> goods(N);
  int sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> goods.at(i);
    sum += goods.at(i);
  }
  sort(goods.begin(),goods.end());
  reverse(goods.begin(), goods.end());
  if(4*M*goods.at(M-1) >= sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#pragma warning(disable : 4996)

using namespace std;

int n, a[100000]; long long s[200000];

inline int reader()
{
	int ret = 0;

	while (true)
	{
		char c = getchar();

		if (c == '\n') break;

		ret = (ret << 1) + (ret << 3) + c - 48;
	}

	return ret;
}

long long sum(int l, int r)
{
	return s[r] - s[l];
}

int main()
{
	n = reader();

	for (int i = 0; i < n; i++) a[i] = reader();

	s[0] = 0; for (int i = 1; i < 2 * n; i++) s[i] = s[i - 1] + a[(i - 1) % n];

	long long ret = 0, sums = s[n];

	for (int i = 0; i < n; i++)
	{
		int posr1 = lower_bound(s, s + 2 * n + 1, s[i] + sums / 3) - s;
		int posl1 = posr1 - 1;
		int posr2 = lower_bound(s, s + 2 * n + 1, s[i] + sums * 2 / 3) - s;
		int posl2 = posr2 - 1;

		ret = max(ret, min({ sum(i, posl1), sum(posl1, posl2), sum(posl2, i + n) }));
		ret = max(ret, min({ sum(i, posr1), sum(posr1, posl2), sum(posl2, i + n) }));
		ret = max(ret, min({ sum(i, posl1), sum(posl1, posr2), sum(posr2, i + n) }));
		ret = max(ret, min({ sum(i, posr1), sum(posr1, posr2), sum(posr2, i + n) }));
	}

	printf("%lld\n", ret);

	return 0;
}

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

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
A, B, C, K = map(int, readline().split())


def solve():
    if K <= A:
        return K
    elif K <= A + B:
        return A
    else:
        r = K - A - B
        return A - r


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 9236
#include <stdio.h>

void main(void){
  int N,M,i,j,n,s=0;
  int A[20],B[20],C;
  scanf("%d %d %d",&N,&M,&C);
  for(i=0;i<M;i++){
    scanf("%d",&B[i]);
  }
  for(i=0;i<N;i++){
    n=C;
    for(j=0;j<M;j++){
      scanf("%d",&A[j]);
      n=n+A[j]*B[j];
    }
    if(n>0)s+=1;
  }
  printf("%d",s);
}


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

using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int ac=0,wa=0;
    vector<int> list(n,0);
    vector<int> p(m);
    vector<string> s(m);
    for(int i = 0;i<m;i++){
        cin >> p[i] >> s.at(i);
        if(list[p[i]] >= 0){
            if(s.at(i) == "AC"){
                ac++;
                wa = wa + list[p[i]];
                list[p[i]] = -1;
            }else{
                list[p[i]]++;
            }
        }
    }
    cout << ac << " " <<  wa << endl;

}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        string str[8];
        for(int j=0;j<8;j++)cin>>str[j];
        int x,y;
        cin>>x>>y;
        str[y-1][x-1]='2';
        while(1){
            int co=0;
            for(int j=0;j<8;j++){
                for(int k=0;k<8;k++){
                    if(str[j][k]=='2'){
                        co=1;
                        str[j][k]='0';
                        for(int l=1;l<=3;l++){
                           if(j-l>-1&&str[j-l][k]=='1')str[j-l][k]='2';
                           if(j+l<8&&str[j+l][k]=='1')str[j+l][k]='2';
                           if(k-l>-1&&str[j][k-l]=='1')str[j][k-l]='2';
                           if(k+l<8&&str[j][k+l]=='1')str[j][k+l]='2';
                        }
                    }
                }
            }
            if(co==0)break;
        }
        cout<<"Data "<<i<<":"<<endl;
        for(int j=0;j<8;j++)cout<<str[j]<<endl;
    }
}

Measured memory_bytes: 1208
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int W1 = W;
        int H1 = H;
        int W0 = 0;
        int H0 = 0;
        int N = sc.nextInt();
        int[][] A = new int[N][3];
        for(int i = 0; i<N; i++){
            A[i][0] = sc.nextInt();
            A[i][1] = sc.nextInt();
            A[i][2] = sc.nextInt();
        }
        for(int i = 0; i<N; i++){
            switch (A[i][2]){
                case 1:
                    if(A[i][0] > W0){
                        W0 = A[i][0];
                    }
                    break;
                case 2:
                    if(A[i][0] < W1){
                        W1 = A[i][0];
                    }
                    break;
                case 3:
                    if(A[i][1] > H0){
                        H0 = A[i][1];
                    }
                    break;
                case 4:
                    if(A[i][1] < H1){
                        H1 = A[i][1];
                    }
                    break;
            }
        }
        int ans = 0;
        if(H1 > H0 && W1 > W0){
            ans = (H1 - H0) * (W1 - W0);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23888
#include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;
 
int main(){
 
    int T,H,S,seconds,seconds3;
 
    while(true){
        scanf("%d %d %d",&T,&H,&S);
        if(T == -1 && H == -1 && S == -1)break;
        seconds = 7200 - (3600*T + 60*H + S);
        seconds3 = 3*seconds;
        printf("%02d:%02d:%02d\n",seconds/3600,(seconds%3600)/60,(seconds%3600)%60);
        printf("%02d:%02d:%02d\n",seconds3/3600,(seconds3%3600)/60,(seconds3%3600)%60);
    }
 
    return 0;
}


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


void insertionSort(int a[], int n) {
	for (int i = 0;i < n;i++) {
		int v = a[i], j = i - 1;
		
		while (j >= 0 && v < a[j])
		{
			a[j + 1] = a[j];
			j--;
		}
		
		a[j + 1] = v;
		
		for (int j = 0;j < n;j++) {
			if (j != n - 1) {
				cout << a[j] << " ";
			}
			else {
				cout << a[j] << endl;
			}
		}
	}
}


int main()
{
	int n, a[100];
	cin >> n;

	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	insertionSort(a, n);

    return 0;
}



Measured memory_bytes: 3092
#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>;

const int MAX_N = 200005;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

//m^n
mint f(int m,int n) {
	if (0 == n) {
		return 1;
	}
	mint x = f(m,n / 2);
	x *= x;
	if (1 == n %2) {
		x *= (mint)m;
	}
	return x;
}
// nCa
mint choose(int n,int a) {
	mint x = 1;
	mint y = 1;
	for (int m = 0;m<a;++m) {
		x *= (mint)(n - m);
		y *= (mint)(a - m);
	}
	return x / y;
}

int main() {
	int N, A, B;
	cin >>N>>A>> B;
	mint ans = f(2,N);
	ans -= 1;
	ans -= choose(N, A);
	ans -= choose(N, B);
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 3604
while True:
    m,f,r=map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif m+f >= 80:
        print('A')
    elif m+f < 80 and m+f >= 65:
        print('B')
    elif m+f < 65 and m+f >= 50:
        print('C')
    elif m+f < 50 and m+f >= 30:
        if r >= 50:
            print('C')
        else:
            print('D')
    elif m+f < 30:
        print('F')
        



Measured memory_bytes: 5596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		String s1=scn.next();
		String s2=scn.next();
		int max=0;
		for(int i=0;i<=s1.length()-s2.length();i++){
			int scnt=0;
			for(int j=0;j<s2.length();j++){
				if(s1.charAt(i+j)==s2.charAt(j)){
					scnt++;
				}
			}
			max=Math.max(max, scnt);
		}
		System.out.println(s2.length()-max);
	   

	}

}

Measured memory_bytes: 35656
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	ll N, T;
	cin >> N >> T;

	vpll AB(N);
	for (int i = 0; i < N; i++)cin >> AB[i].first >> AB[i].second;
	sort(AB.begin(), AB.end());


	vvll dp(N); // i個の料理、j分以内に食べ終わる満足度の最大値

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j <= T; j++)
		{
			dp[i].emplace_back(0);
		}
	}

	for (int t = 0; t < T; t++)
	{
		if (AB[0].first <= t)
		{
			dp[0][t] = AB[0].second;
		}
	}


	vll after_max(N); // i以降の料理で最大のおいしさ
	for (int i = 0; i < N; i++)
	{
		after_max[i] = 0;
	}

	after_max[N - 1] = AB[N - 1].second;

	for (int i = N - 2; i >= 0; i--)
	{
		after_max[i] = max(after_max[i + 1], AB[i].second);
	}


	vll last(N);
	last[0] = AB[0].second;
	after_max.emplace_back(0);

	for (int i = 1; i < N; i++)
	{
		bool used = false;

		for (int t = 0; t < T; t++)
		{
			if (t - AB[i].first >= 0)
			{
				dp[i][t] = max(dp[i - 1][t], dp[i - 1][t - AB[i].first] + AB[i].second);
				if (dp[i - 1][t] < dp[i - 1][t - AB[i].first] + AB[i].second)
				{
					used = true;
				}
			}
			else
			{
				dp[i][t] = dp[i - 1][t];

			}

			if (t == T - 1)
			{
				if (used)
				{
					last[i] = dp[i][t] + after_max[i + 1];
				}
				else
				{
					last[i] = dp[i][t] + after_max[i];
				}
			}

		}
	}

	ll ans = 0;
	for (int i = 0; i < N; i++)
	{
		ans = max(ans, last[i]);
	}


	cout << ans << endl;

}





Measured memory_bytes: 82944
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

// 切り上げ割り算
template <typename T>
T ceil_div(T a, T b) {
    return a > 0 && b > 0 ? (a + b - 1) / b : a / b;
}

int main() {
    ll t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    if (a1 > b1) {
        swap(a1, b1);
        swap(a2, b2);
    }
    ll s = a1 * t1 + a2 * t2;
    ll t = b1 * t1 + b2 * t2;
    if (s == t) cout << "infinity" << endl;
    else if (s < t) cout << 0 << endl;
    else {
        ll d1 = (b1 - a1) * t1;
        ll d = s - t;
        if (d1 % d == 0) cout << d1 / d * 2 << endl;
        else cout << d1 / d * 2 + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let mut reader = acio::Reader::new();
    let a: u32 = reader.read();
    let p: u32 = reader.read();
    println!("{}", (a * 3 + p) / 2);
}

/// IO Module for AtCoder
#[allow(dead_code)]
mod acio {
    use std::fmt::Debug;
    use std::io::{stdin, Stdin};
    use std::str::FromStr;

    pub struct Reader {
        input: Stdin,
        stack: Vec<String>,
    }

    impl Reader {
        pub fn new() -> Self {
            Reader {
                input: stdin(),
                stack: vec![],
            }
        }

        pub fn read_by<F>(&mut self, count: usize) -> Vec<F>
        where
            F: FromStr,
            <F as FromStr>::Err: Debug,
        {
            let mut v = vec![];
            for _ in 0..count {
                v.push(self.read());
            }
            return v;
        }

        pub fn read<F>(&mut self) -> F
        where
            F: FromStr,
            <F as FromStr>::Err: Debug,
        {
            if self.stack.is_empty() {
                let mut line = self.read_line();
                self.stack.append(&mut line);
                self.stack.reverse();
            }
            self.stack.pop().unwrap().parse().unwrap()
        }

        fn read_line(&mut self) -> Vec<String> {
            let mut buf = String::new();
            self.input.read_line(&mut buf).unwrap();
            buf.split_whitespace().map(|s| s.to_string()).collect()
        }
    }
}


Measured memory_bytes: 4352
// B.

#include <iostream>
#include <sstream>

using namespace std;

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	int w;
	cin >> w;
	int len = (int)s.length();
	for (int i = 0; i < len; i += w) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int month[12] = {0,3,4,0,2,5,0,3,6,1,4,6};
  int m,d;
  while(cin >>m>>d,m||d){
    d = (d+month[m-1])%7;
    if(d == 1){cout <<"Thursday"<<endl;}
    if(d == 2){cout <<"Friday"<<endl;}
    if(d == 3){cout <<"Saturday"<<endl;}
    if(d == 4){cout <<"Sunday"<<endl;}
    if(d == 5){cout <<"Monday"<<endl;}
    if(d == 6){cout <<"Tuesday"<<endl;}
    if(d == 0){cout <<"Wednesday"<<endl;}
  }
  return 0;
}

Measured memory_bytes: 1152
fn gcd(a: usize, b: usize) -> usize {
    if b > a {
        gcd(b, a)
    } else if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn lcm(a: usize, b: usize) -> usize {
    a / gcd(a, b) * b
}

fn solve() {
    let n = read();
    let mut a = 1;
    for _ in 0..n {
        let b = read();
        a = lcm(a, b);
    }
    println!("{}", a);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2232
# coding: utf-8
import sys
# import random
# import bisect
# import math
import numpy as np
# from fractions import gcd
# import itertools

"""Template"""


class IP:
    """
    入力を取得するクラス
    """

    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x // y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

    def gcd(self, x, y):
        if y == 0:
            return x
        else:
            return self.gcd(y, x % y)

    def lcm(self, x, y):
        return (x * y) // self.gcd(x, y)


"""ここからメインコード"""


def make_divisors(n):
    # divisors = []
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            # divisors.append(i)
            return i
            # if i != n // i:
            #     divisors.append(n//i)


def n_to_10(X, n):
    if int(X / n):
        return n_to_10(int(X / n), n) + str(X % n)
    return str(X % n)


def main():
    ip = IP()
    id = Idea()
    """この下から書いてね"""
    n = int(input())
    print(n ** 3)



main()


Measured memory_bytes: 21596
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
score=0
m=[]
for i in range(k):
    if t[i]=='r':
        score+=p
        m.append('p')
    elif t[i]=='s':
        score+=r
        m.append('r')
    else:
        score+=s
        m.append('s')
for i in range(k,n):
    if t[i]=='r' and m[i-k]!='p':
        score+=p
        m.append('p')
    elif t[i]=='s' and m[i-k]!='r':
        score+=r
        m.append('r')
    elif t[i]=='p' and m[i-k]!='s':
        score+=s
        m.append('s')
    else:
        m.append('penis')

print(score)


Measured memory_bytes: 4212
s=input()
n=len(s)
a=b=-1
for i in range(n-1):
    if s[i]==s[i+1]:
        a,b=i+1,i+2
        break
    elif i+2<n and s[i]==s[i+2]:
        a,b=i+1,i+3
        break

print(a,b)


Measured memory_bytes: 9160
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int a[5], b[5];

signed main() {
	rep(i,5) cin >> a[i];
	rep(i,5) b[i] = (a[i]+9)/10 * 10;
	int s = accumulate(b,b+5,0), res = 1<<30;
	rep(i,5) chmin(res, s-b[i] + a[i]);
	cout << res << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
h = [int(i) for i in input().split()] # 配列で数字

ans = 0
start = 0
end = 0

ans = 0
while True:
    left = -1
    for i in range(n):
        if h[i]:
            left = i
            break
    if left == - 1:
        break

    right = n
    for i in range(left, n):
        if h[i] == 0:
            right = i
            break

    right_min = min(h[left:right])
    ans += right_min
    for i in range(left, right):
        h[i] -= right_min

print(ans)

Measured memory_bytes: 38768
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1]*n
        
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
        
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x,y = y,x
            
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        
    def size(self, x):
        return -self.parents[self.find(x)]
    
    
    def roots(self):
        return [i for i,x in enumerate(self.parents) if x < 0]
    
    def group_count(self):
        return len(self.roots())

    
n, m = map(int,input().split())

g = [[]*(n+1) for _ in range(n+1)]

uf = UnionFind(n)

# 友人関係のみ UnionFind でまとまる
# グラフに友人関係追加
for i in range(m):
    a,b = map(int,input().split())
    uf.union(a-1,b-1)

print(uf.group_count()-1)

Measured memory_bytes: 19172
import bisect
A,B,Q=map(int,input().split())
INF=10**18
S=[-INF]+[int(input()) for i in range(A)]+[INF]
T=[-INF]+[int(input()) for i in range(B)]+[INF]
for q in range(Q):
    x=int(input())
    i=bisect.bisect_left(S,x)
    j=bisect.bisect_left(T,x)
    ans=INF
    for s in [S[i-1],S[i]]:
        for t in [T[j-1],T[j]]:
            d1=abs(s-x)+abs(s-t)
            d2=abs(t-x)+abs(s-t)
            ans=min(ans,d1,d2)
    print(ans)

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using Point = pair<int, int>;
const int INF = (int)1e9;

int N, M;
bool g[8][8];

int main(void){
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            g[i][j] = false;
        }
    }

    for(int i = 0; i < M; i++){
        int a, b; cin >> a >> b;
        g[--a][--b] = true; g[b][a] = true;
    }

    int arr[8];
    for(int i = 0; i < N; i++) arr[i] = i;
    int res = 0;

    do{
        // for(int i = 0; i < N; i++) cout << arr[i];
        // cout << '\n';

        for(int i = 0; i < N-1; i++){
            if(not g[arr[i]][arr[i+1]]) break;
            if(i == N-2) res++;
        }
    }while(next_permutation(arr+1, arr+N));

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
typedef long long ll;
const ll mod = 1e9 + 7;

int main() {
    string s;
    getline(cin, s);

    for (int i: irange(0, (int) s.size(), 2)) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i = 0; i< (n); i++)
#define REP(i,n) for (int i = 1; i<= (n); i++)
#define MAX_MOD 1000000007LL
#define MOD 998244353LL
const long double PI = acos(-1);
using ll = long long;
using ld = long double;
using namespace std;

int main() {
    ld a, b, h, m;
    cin >> a >> b >> h >> m;
    ld arg_h = ld(h*60 + m)/720 * 2*PI;
    ld arg_m = ld(m)/60 * 2*PI;
    ld h_x = a*cos(arg_h), h_y = a*sin(arg_h);
    ld m_x = b*cos(arg_m), m_y = b*sin(arg_m);
    ld dx = h_x - m_x, dy = h_y - m_y;
    ld ans = sqrt(dx*dx + dy*dy);
    printf("%.10Lf", ans);
    return 0;
}


/*
int main() {
    ld a, b, h, m;
    cin >> a >> b >> h >> m;
    ld arg = abs(m*6 - (h*60 + m)*0.5);
    ld rad = arg*acos(-1)/180;
    ld ans = sqrt(a*a + b*b - 2*a*b*cos(rad));
    printf("%.100Lf", ans);
    return 0;
}
*/

Measured memory_bytes: 4144
#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std;


int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int gcd(int a,int b){
    if(a<b){
        int tmp=a;
        a=b;
        b=tmp;
    }
    int r=a%b;
    while(b!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return a;
}
int main(void){
    int n;
    int i;
    cin >>n;
    vector<int> r(n+1,0);
    vector<int> l(n+1,0);
    vector<int> a(n,0);
    for(i=0;i<n;i++){
        cin >> a.at(i);
    }
    for(i=0;i<n;i++){
        l[i+1]=GCD(l[i],a[i]);
    }
    for(i=n;i>0;i--){
        r[i-1]=GCD(r[i],a[i-1]);
    }
    unsigned max=0;
    for(i=0;i<n;i++){
        if(GCD(l[i],r[i+1])>max){
            max=GCD(l[i],r[i+1]);
        }
    }
    printf("%d",max);
}

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

ll dp[2000][2001];

int main() {
  int n;
  cin >> n;
  vector<pair<ll, ll> > a(n);
  rep(i, n) {a[i].second = i; cin >> a[i].first;}
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  dp[0][0] = a[0].first * (n-1 - a[0].second);
  dp[0][1] = a[0].first * a[0].second;
  for (int i=1; i<n; i++) for (int j=0; j<=i+1; j++) {
    if (i+1 == j) dp[i][j] = dp[i-1][j-1] + a[i].first * (a[i].second - j + 1);
    else if (j == 0) dp[i][j] = dp[i-1][0] + a[i].first * (n-1-i - a[i].second);
    else dp[i][j] = max(dp[i-1][j] + a[i].first * (n-1-i+j - a[i].second),
                        dp[i-1][j-1] + a[i].first * (a[i].second - j + 1));
  }
  ll ans = 0; 
  rep(i, n+1) if (ans < dp[n-1][i]) ans = dp[n-1][i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 26228
var reader = require('readline').createInterface ({
    input: process.stdin,
    output: process.stdout
});

var lines = [];
reader.on('line', (line) => {
    lines.push(line);
});

reader.on('close', () => {
    var line = lines[0];
    var elems = line.split(' ');
    var A = elems[1];
    var B = elems[2];
    var C = B - A - 1;
    if (C % 2 == 1) {
        console.log('Alice');
    } else if (C % 2 == 0) {
        console.log('Borys');
    }
});

Measured memory_bytes: 7500
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll h;
  cin>>h;
  ll k=1;
  while(k<h){
    k=k*2+1;
  }
  COUT(k);
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    A = list(map(int, input().split()))

    l = [0] * N
    for i in A:
        l[i - 1] += 1

    for i in l:
        print(i)

if __name__ == '__main__':
    main()


Measured memory_bytes: 99928
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define endl "\n"
#define mod 1000000007
#define INF 1e18
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define w(x) int x; cin >> x; while (x--)

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void rwf()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int xpowery(int x, int y)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans * x) % mod;
		x = (x * x) % mod;
		y = y / 2;
	}
	return ans;
}

int32_t main()
{
	IOS;
	//rwf();

	double w, h, x, y;
	cin >> w >> h >> x >> y;

	cout << fixed << setprecision(6) << (w * h) / 2 << " ";

	if (2 * x == w && 2 * y == h)
		cout << "1";
	else
		cout << "0";

	return 0;
}

Measured memory_bytes: 256
def is_prime(X):
    if X <= 1:
        return False
    else:
        for i in range(2, int(X**0.5) + 1):
            if X % i == 0:
                return False
        return True


X = int(input())
num = X

while True:
    if is_prime(num):
        print(num)
        exit()
    else:
        num += 1


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

int main()
{
	int a, b, ab, x, y;
	cin >> a >> b >> ab >> x >> y;

	int ans1 = a * x + b * y;


	int max_num = max(x, y);
	if (max_num % 2 == 1) max_num++;

	int ans2 = (ab * 2) * max_num;


	int min_num = min(x, y);

	int ans3 = ((ab * 2) * min_num) + (a * (x - min_num) + b * (y - min_num));

	cout << min({ ans1, ans2, ans3 }) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>

int main() {
	int a = 0, b = 0, c = 0, d = 0;
	int ar[10000] = {};	
	std::string str;
	std::cin >> a >> b >> c >> d;
	if (std::abs(b - a) <= d && std::abs(c - b) <= d) {
		std::cout << "Yes" << std::endl;
	}
	else {
		if (std::abs(c - a) <= d) {
			std::cout << "Yes" << std::endl;
			return 0;
		}
		std::cout << "No" << std::endl;
	}

		return 0;
}

Measured memory_bytes: 256
// 8/22 リアルタイム参加
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
    int H, W, M;
    cin >> H >> W >> M;

    vector<P> row(H), col(W);
    rep(h, H) row[h] = P(0, h);
    rep(w, W) col[w] = P(0, w);

    vector<map<int, int>> target(H);

    rep(i, M) {
        int h, w;
        cin >> h >> w;
        h--; w--;

        target[h][w]++;

        row[h].first++;
        col[w].first++;
    }

    sort(row.rbegin(), row.rend());
    sort(col.rbegin(), col.rend());

    int max_h = row[0].second;
    int max_w = col[0].second;

    // cout << "here?" << endl;

    if (target[max_h][max_w] > 0) {
        // int i = 1;
        // int j = 1;

        bool ok = false;

        for (int i = 1; i < row.size(); i++) {
            if (row[0].first != row[i].first) break;
            if (target[row[i].second][max_w] == 0) {
                ok = true;
                break;
            }
        }

        for (int j = 1; j < col.size(); j++) {
            if (col[0].first != col[j].first) break;
            if (target[max_h][col[j].second] == 0) {
                ok = true;
                break;
            }
        }

        if (ok) {
            cout << row[0].first + col[0].first << endl;
        } else {
            cout << row[0].first + col[0].first - 1 << endl;
        }
    } else {
        cout << row[0].first + col[0].first << endl;
    }
}

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

int main()
{
    ll L, R;
    cin >> L >> R;

    ll limit = min(L + 2019, R);
    ll ans = 2019;
    for (ll i = L; i <= limit; i++)
    {
        for (ll j = i + 1; j <= limit; j++){
            ans = min(ans, (i * j) % 2019);
        }
    }
    cout << ans << endl;
    return 0;
}

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


int main()
{
	int a;
	double s=0;
	cin>>a;
	double b[a];
	for(int i=0;i<a;i++)
	{
		cin>>b[i];
		b[i]=1/b[i];
		s+=b[i];
	}
	cout<<1/s;
	return 0;
}

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

int main()
{
    while (1){
        int n;

        scanf(" %d", &n);
        if (n == 0){
            break;
        }

        int score[n];

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

        int sum = 0;
        double ave;
       
        for (int i = 0; i < n; i++){
            sum += score[i];
        }
        
        ave = (double)sum / n;

        double alpha = 0;

        for (int i = 0; i < n; i++){
            alpha += pow(score[i] - ave, 2);
        }

        printf("%lf\n", sqrt(alpha/n));
    }

    return 0;
}
    

Measured memory_bytes: 2724
MAX_INT = int(1e5)


def main():
    Q = int(input())
    primes = [True] * (MAX_INT + 1)
    primes[0] = False
    primes[1] = False
    for i in range(2, MAX_INT+1):
        if not primes[i]:
            continue
        for j in range(i*i, MAX_INT+1, i):
            primes[j] = False
    cumsum = [0] * (MAX_INT + 1)
    for i in range(2, MAX_INT+1):
        cumsum[i] = cumsum[i-1]
        if primes[i] and primes[(i+1)//2]:
            cumsum[i] += 1
    for _ in range(Q):
        l, r = map(int, input().split())
        print(cumsum[r] - cumsum[l-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 4980
#include <bits/stdc++.h>
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define pb push_back
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fst first
#define snd second
#define mset(a,v) memset((a),(v),sizeof(a))
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
using namespace std;
typedef long long ll;
const int N=200500;
int k,n;
ll dp[100500],h[N];
ll f(int i){
	if(i==n-1)return 0;
	ll &r=dp[i];
	if(r!=-1)return r;
	r=1LL<<50;
	fore(j,1,k+1)if(i+j<n)r=min(r,f(i+j)+abs(h[i+j]-h[i]));
	return r;
}
int main(){FIN;
	cin>>n;
	k=2;
	//cin>>k;
	fore(i,0,n)cin>>h[i];
	memset(dp,-1,sizeof dp);
	cout<<f(0)<<"\n";
}

Measured memory_bytes: 6528
#include<stdio.h>
int main(void)
{
    int count=0,n,x,i=1,j=1,z=1,k=1,l=1,N[30000],X[30000];
    while(1){
        scanf("%d %d",&n,&x);
        if(n==0&&x==0)break;
        N[i]=n;
        X[i]=x;
        i++;
        l++;
    }

    for(z=1;z<l;z++){
        for(i=1;i<=N[z];i++){
            for(j=i+1;j<=N[z];j++){
                for(k=j+1;k<=N[z];k++){
                    if(i+j+k==X[z]){
                        count++;

                    }
                }
            }
        }
        printf("%d\n",count);
        count=0;
    }



    return 0;
}

Measured memory_bytes: 1828