akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();

		int[] a = new int[N];

		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt() - (i + 1);
		}

		Arrays.sort(a);

		int median;
		if (N % 2 == 1) {
			median = a[N / 2];
		} else {
			median = (a[N / 2 - 1] + a[N / 2]) / 2;
		}

		long ans = 0;
		for (int i = 0; i < N; i++) {
			ans += Math.abs(a[i] - median);
		}

		out.println(ans);

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 66536
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		sc.close();

		if (y >= r && y <= h-r && x >=r && x <= w-r){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}






	}

}



Measured memory_bytes: 26408
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
static const int MAX_N = 200000;
static const int NUM_A = 26;

char A[MAX_N + 1];
ll num_alphabet[NUM_A];

void solve(){
	ll n = strlen(A);
	for(int i = 0; i < n; i++){
		num_alphabet[A[i] - 'a']++;
	}
	ll num = 0;
	for(int i = 0; i < NUM_A; i++){
		num += num_alphabet[i] * (num_alphabet[i] - 1) / 2;
	}
	printf("%lld\n", n * (n - 1) / 2 - num + 1);
}

int main(){
	scanf("%s", A);
	solve();
	return 0;
}


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

const double eps = 0.001;

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

int main(){
    int n;
    while(cin>>n && n){
        vector<pair<int,int>> v(n);
        rep(i,n){
            cin >> v[i].second;
            int t=0;
            rep(j,4){
                int m,s;cin>>m>>s;
                t+=m*60+s;
            }
            v[i].first = t;
        }
        sort(v.begin(), v.end());
        cout << v[0].second << endl;
        cout << v[1].second << endl;
        cout << v[v.size()-2].second << endl;
    }
}

Measured memory_bytes: 1236
K=int(input())
A = [[] for j in [0]*(10**5)]
A[0]=[1,2,3,4,5,6,7,8,9]
B=9
C=0
while B<=K:
 for i in range(len(A[C])):
  if A[C][i]%10>0:
   A[C+1].append(A[C][i]*10+(A[C][i]%10)-1)
  A[C+1].append(A[C][i]*10+(A[C][i]%10))
  if A[C][i]%10<9:
   A[C+1].append(A[C][i]*10+(A[C][i]%10)+1)
 B+=len(A[C+1])
 C+=1
print(A[C][len(A[C])-B+K-1])


Measured memory_bytes: 56244
N, M = map(int, input().split())
from collections import defaultdict
g = defaultdict(int)
for i in range(N):
    l = list(map(int, input().split()))
    for j in range(1, l[0]+1):
        g[l[j]] += 1

ans = 0
for i, v in g.items():
    if v == N:
        ans += 1

print(ans)

Measured memory_bytes: 3444
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::Read;
use std::io::{stdout, BufWriter, Write};
 
fn main() {
    let mut buf = String::new();
    
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
 
    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();
 
    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();
 
    
    let n: usize = iter.next().unwrap().parse().unwrap();
    
    let p : Vec<u32> = (0..n).map(|_| {
        iter.next().unwrap().parse().unwrap()
        }).collect();
    
    let mut cnt = 0;
    
    for i in 1..n-1 {
        if p[i-1] < p[i] && p[i] < p[i+1] {
            cnt += 1;
        }
        if p[i-1] > p[i] && p[i] > p[i+1] {
            cnt += 1;
        }
    }
    //println!("{:?}", p);
    println!("{}", cnt);
}

Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int i,j,k,n,m;
int main(){
	scanf("%d",&n);
	for (i=1,k=0;k<n;i++) k+=i;
	printf("%d\n",i-1);
	return 0;
}

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

#define ll long long

int main()
{
    ll n;
    cin >> n;
    
    ll sum = 0;
    
    for(ll i = 1; i <= n; i++)
    {
        if(i % 3 != 0 && i % 5 != 0)
        {
            sum += i;
        }
    }
    
    cout << sum;

    return 0;
}


Measured memory_bytes: 3600
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public Main() {
        Scanner scan = new Scanner(System.in);

        Stack stack = new Stack(200);

        while(scan.hasNext()){
            String str = scan.next();
            stack.push(str);
        }
        System.out.println(stack.pop());
    }

    public static void main(String[] args) {
        new Main();
    }

    private class Stack{
        private int top = 0;
        private int stack[];

        public Stack(int size){
            stack = new int[size];
        }

        public void push(int n){
            stack[top++] = n;
        }

        public void push(String str){
            if(isInteger(str)){
                int n = Integer.parseInt(str);
                push(n);
            }else{
                int o1 = pop();
                int o2 = pop();

                if(str.equals("+")){
                    push(o2+o1);
                }
                else if(str.equals("-")){
                    push(o2-o1);
                }else{
                    push(o2*o1);
                }
            }
        }

        public int pop(){
            return stack[--top];
        }

        public boolean isInteger(String str) {
            try {
                Integer.parseInt(str);
            } catch(NumberFormatException e) {
                return false;
            }
            return true;
        }

    }

}

Measured memory_bytes: 19200
a, b = map(int, input().split())

r0 = a
r1 = b
x0 = 1
x1 = 0
y0 = 0
y1 = 1
while r1 > 0:
    q1 = r0 // r1
    r2 = r0 % r1
    x2 = x0 - q1 * x1
    y2 = y0 - q1 * y1
    r0 = r1
    r1 = r2
    x0 = x1
    x1 = x2
    y0 = y1
    y1 = y2
print(x0,y0)

Measured memory_bytes: 7692
#include <stdio.h>
int fib(int );
int main(){
  int n,F[45],i;
  scanf("%d",&n);

  F[0]=1;
  F[1]=1;
  for (i = 2; i<= n;i++){
    F[i] = F[i-2] + F[i -1];
  }

  printf("%d",F[n]);
  printf("\n");
  return 0;
}

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

int main() {
    int N;
    string S;
    bool flag = false;

    cin >> N;

    rep(i, N) {
        cin >> S;
        if (S == "Y") {
            flag = true;
        }
    }

    if (flag)
        cout << "Four";
    else cout << "Three";

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();
			char[] t = "CODEFESTIVAL2016".toCharArray();

			int c = 0;
			for (int i = 0; i < s.length; i++) {
				if (s[i] != t[i]) c++;
			}

			out.println(c);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public int[] nextIntArray1Index(int n) {
			int[] res = new int[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public long[] nextLongArray1Index(int n) {
			long[] res = new long[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextLong();
			}
			return res;
		}

		public double[] nextDoubleArray(int n) {
			double[] res = new double[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextDouble();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 23380
#include<stdio.h>
#include<string.h>
int main(void){

	int n,i,ans=0;
	char sar[21],ring[21],temp[21];

	scanf("%s%d",sar,&n);

	for(i=0;i<n;i++){
		scanf("%s",ring);
		strcpy(temp,ring);
		strcat(ring,temp);

		if(strstr(ring,sar) != NULL) ans++;
	}

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

	return 0;
}

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

int main(){
	int a, b;
	char op;
	bool flg = true;
	while (flg){
		cin >> a >> op >> b;
		switch (op){
		case '+':
			cout << a + b << endl;
			break;
		case '-':
			cout << a - b << endl;
			break;
		case '*':
			cout << a * b << endl;
			break;
		case '/':
			if (b != 0) cout << a / b << endl;
			break;
		case '?':
			flg = false;
		}
	}
}

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

using namespace std;
char s[100];
int  main(){
    int n;
    scanf("%d",&n);
    scanf("%s",&s);
    int sum =0 ;
    for(int i = 2; i <n;i++){
        if(s[i] == 'C' && s[i-1] == 'B' && s[i-2] == 'A') sum++;
    }
    printf("%d",sum);

}


Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define MAX_W 100
#define MAX_H 100

char field[MAX_H][MAX_W + 1];
int w, h;

void
dfs(int x, int y, char p)
{
	const int dx[4] = {1, 0, -1, 0};
	const int dy[4] = {0, 1, 0, -1};

	field[y][x] = '.';
	for (int i = 0; i < 4; ++i)
	{
		int nx = x + dx[i], ny = y + dy[i];
		if (0 <= nx && nx < w && 0 <= ny && ny < h && field[ny][nx] == p)
			dfs(nx, ny, p);
	}
}

int
solve()
{
	const char p[3] = {'@', '#', '*'};
	int count = 0;
	for (int i = 0; i < 3; ++i)
	{
		for (int y = 0; y < h; ++y)
		{
			for (int x = 0; x < w; ++x)
			{
				if (field[y][x] == p[i])
				{
					dfs(x, y, p[i]);
					count++;
				}
			}
		}
	}

	return count;
}

int
main(int argc, char **argv)
{
	while (true)
	{
		scanf("%d%d", &h, &w);
		if (w == 0 && h == 0)
			break;

		for (int i = 0; i < h; ++i)
			scanf("%s", &field[i][0]);

		printf("%d\n", solve());
	}

	return 0;
}

Measured memory_bytes: 2804
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY
#====PriorityQueue====

class PriorityQueue
    attr_accessor:heap,:size,:fanc
    def initialize(size,init,&fanc)
      @fanc=fanc
      @size=0
      @heap=Array.new(size){ init }
    end

    def push(x)
        i=@size
        @size+=1
        while i>0
            par=(i-1)/2
            break if @fanc.call(@heap[par],x)!=1
            @heap[i]=@heap[par]
            i=par
        end
        @heap[i]=x
    end

    def pop()
        min_v=@heap[0]
        i=0
        @size-=1
        x=@heap[@size]
        while i*2+1<@size
            left=i*2+1
            right=i*2+2
            left=right if right<@size and @fanc.call(@heap[left],@heap[right])==1
            break if @fanc.call(x,@heap[left])!=1
            @heap[i]=@heap[left]
            i=left
        end
        @heap[i]=x
        return min_v
    end
end
N,M=get_i
A=get_i
pq=PriorityQueue.new(N,-INF){|x,y| y<=>x}
A.each do|a|
    pq.push(a)
end
M.times do
    v=pq.pop/2
    pq.push(v) 
end
ans=0
until pq.size.zero?
    ans+=pq.pop 
end
puts ans

Measured memory_bytes: 22540
#include<cstdio>
#include<iostream>
#include<cctype>
#include<algorithm>
#include<stack>
#include<cstdlib>
using namespace std;
int main() {
	int count=0,s,n, q, S[10000], T[500];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S[i];
	}
	cin >> q;
	for (int i = 0; i <q; i++) {
		cin >> T[i];
	}
	for (int i = 0; i < q; i++) {
		for (int j = 0; j < n; j++) {
			if (S[j] == T[i]) {
				count++;
				break;
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3112
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
    int n, q;
    cin >> n >> q;
    vector<ll> a(n);
    for(int i = 0; i < n; i++)  cin >> a[i];
    while(q-- > 0){
        ll x;
        cin >> x;
        int l = 0, r = 0;
        ll sum = 0, ans = 0;
        while(l < n){
            while(r < n && sum + a[r] <= x) sum += a[r++];
            ans += r-l;
            if(l == r)  l = ++r;
            else        sum -= a[l++];
        }
        cout << ans << endl;
    }
    return 0;
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;

  int64_t sum = 0;

  for (int64_t i = 1; i <= n; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      sum += i;
    }
  }
  std::cout << sum << std::endl;
  return 0;
}


Measured memory_bytes: 3632
N = int(input())
x = [0]*N
u = [0]*N
for n in range(N):
    a = list(input().split())
    x[n] = float(a[0])
    u[n] = a[1]
S = 0
    
for n in range(N):
    if u[n] == 'JPY':
        S += x[n]
    elif u[n] == 'BTC':
        S += x[n] * 380000.

print(S)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
int top[101][101];

int main(){
  int n, m, x, y, i, j;

  scanf("%d", &n);
  for(i=1; i<=n; i++){
    scanf("%d", &x);
    scanf("%d", &m);
    for(j=1; j<=m; j++){
      scanf("%d", &y);
      top[x][y] = 1;
    }
  }
  for(i=1; i<=n; i++)
    for(j=1; j<=n; j++)
      printf("%d%c", top[i][j], j==n ? '\n':' ');
  return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int n;
ll a[100100];
int q;
ll sum[100100];
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)sum[a[i]]++;
	ll res=0;
	cin>>q;
	rep(i,n)res+=a[i];
	rep(i,q)
	{
		int b,c;
		cin>>b>>c;
		res-=b*sum[b];
		res+=c*sum[b];
		sum[c]+=sum[b];	
		sum[b]=0;
		cout<<res<<endl;
	}
	return 0;
}



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

const int N = 1e5 + 9;

int n, a[N];
bool p;

int main () {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	for (int i = 1; i <= n; ++i) if (i + 1 > a[i + 1]) {
		for (int j = i + 1; j <= n && a[j] == i; ++j) p ^= 1;
		p |= (a[i] - i) & 1;
		return puts(p ? "First" : "Second"), 0;
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF 1LL<<60

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    string S, T;
    cin >> S >> T;
    if(T.length() != S.length() + 1) {
        cout << "No" << endl;
        return 0;
    }
    REP(i, S.length()) {
        if(S[i] != T[i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < b) {
            System.out.println("a < b");
        } else if (a == b) {
            System.out.println("a == b");
        } else {
            System.out.println("a > b");
        }
    }
}


Measured memory_bytes: 26172
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
using namespace std;

int P;
vector<long long> A;
vector<long long> inv, C;
vector<long long> ans;

template<class T>
T pow(T base, int p, T mod = -1) {
	if (p == 0)return 1;
	if (p == 1)return mod == -1 ? base % mod : base;
	int b = 1, c = 0;
	while (b <= p) {
		b *= 2;
		c++;
	}
	T* arr2 = new T[c];   //T[n] = T^(2^n)
	arr2[0] = mod == -1 ? base % mod : base;
	for (int n = 1; n < c; n++) {
		if (mod != -1)arr2[n] = (arr2[n - 1] * arr2[n - 1]) % mod;
		else arr2[n] = arr2[n - 1] * arr2[n - 1];
	}
	c--;
	T ans = arr2[c];
	b /= 2;
	p -= b;
	while (p > 0) {
		c--;
		b /= 2;
		if (p >= b) {
			if (mod != -1)ans = (ans * arr2[c]) % mod;
			else ans = ans * arr2[c];
			p -= b;
		}
	}
	return ans;
}

void solve() {
	cin >> P;
	A.resize(P);
	for (int p = 0; p < P; p++)cin >> A[p];
	if (P == 2) {
		cout << A[0] << endl <<(A[0] + A[1]) % P << endl;
		return;
	}
	inv.resize(P);
	inv[0] = 0;
	for (int p = 1; p < P; p++) inv[p] = pow(p, P - 2, P);
	C.resize(P + 1);
	C[0] = 1, C[1] = P-1;
	for (int p = 2; p < P; p++) {
		C[p] = (C[p-1]*(P-p)*inv[p]) % P;
	}
	ans.resize(P, 0);
	if (A[0] == 1) {
		ans[P - 1] = P - 1;
		ans[0] = 1;
	}
	for(int n = 1;n < P;n++){
		if (A[n] == 0)continue;
		for (int k = 0; k < P; k++) {
			long long temp = C[k] * pow(P - n, P - 1 - k,P);
			temp %= P;
			ans[k] = (ans[k] +P - temp) % P;
		}
		ans[0]++;
		ans[0] %= P;
	}
	for (int i = 0; i < P; i++)cout << ans[i] << endl;
	return;
}

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

using namespace std;

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 vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )
#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (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 int dy[] = { 0, 1, 0, -1 };
const int dx[] = { 1, 0, -1, 0 };

bool clearable( VS &board, const int n )
{
	const int H = board.size(), W = board[0].size();

	bool vanished, moved;
	do
	{
		vanished = false;
		moved = false;
		set<PII> toVanish;

		bool falled;
		do
		{
			falled = false;
			REP( i, 0, H - 1 )
			{
				REP( j, 0, W )
				{
					if ( board[i][j] != '.' && board[ i + 1 ][j] == '.' )
					{
						falled = true;
						moved = true;
						swap( board[i][j], board[ i + 1 ][j] );
					}
				}
			}
		} while ( falled );

		REP( i, 0, H )
		{
			REP( j, 0, W )
			{
				if ( board[i][j] == '.' )
				{
					continue;
				}

				REP( d, 0, 4 )
				{
					bool lined = true;

					int y = i, x = j;
					REP( depth, 0, n )
					{
						if ( !( 0 <= y && y < H && 0 <= x && x < W ) )
						{
							lined = false;
							break;
						}
						lined &= board[i][j] == board[y][x];
						y += dy[d];
						x += dx[d];
					}

					if ( !lined )
					{
						continue;
					}

					y = i;
					x = j;
					REP( depth, 0, n )
					{
						toVanish.insert( MP( y, x ) );
						y += dy[d];
						x += dx[d];
					}
				}
			}
		}

		FOR( pos, toVanish )
		{
			vanished = true;
			board[ pos.fst ][ pos.snd ] = '.';
		}
	}
	while ( vanished || moved );

	REP( i, 0, H )
	{
		REP( j, 0, W )
		{
			if ( board[i][j] != '.' )
			{
				return false;
			}
		}
	}

	return true;
}

string solve()
{
	int h, w, n;
	cin >> h >> w >> n;

	VS board( h );
	FOR( line, board )
	{
		cin >> line;
	}

	REP( i, 0, h )
	{
		REP( j, 0, w - 1 )
		{
			VS tmp = board;
			swap( tmp[i][j], tmp[i][ j + 1 ] );
			if ( clearable( tmp, n ) )
			{
				return "YES";
			}
		}
	}

	return "NO";
}

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

	cout << solve() << endl;

	return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  int p[n];
  for ( int i = 0; i < n; i++ ) {
    cin >> p[i];
  }
  sort(p, p+n);
  int ans = 0;
  for ( int i = 0; i < k; i++ ) {
    ans += p[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin>>str;
  if(str.size()%2){
    for(int j=0;j<str.size();j+=2){
      int flag=1;
      for(int i=0;i<((str.size()-1-j)/2);i++){
	if(str[i]!=str[i+((str.size()-1-j)/2)]){
	  flag=0;
	}
      }
      if(flag){
	int num=j+1;
	cout<<str.size()-num<<endl;
	break;
      }
    }
  }else{
    for(int j=2;j<str.size();j+=2){
      int flag=1;
      for(int i=0;i<((str.size()-j)/2);i++){
	if(str[i]!=str[i+((str.size()-j)/2)]){
	  flag=0;
	}
      }
      if(flag){
	int num=j;
	cout<<str.size()-num<<endl;
	break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    string s,t;
    cin >> s >> t;
    if(t.substr(0,s.size())==s){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>> 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define mp make_pair
#define pll pair <lli,lli>
#define vll vector <lli>
#define pq2 priority_queue<pair<lli,lli>>
#define f first
#define s second
#define pb push_back
#define pf push_front
#define minii LLONG_MAX
const long double pi = 3.1415926535898;
#define dec greater<lli>()
const lli mod=1000000007;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0)
    return 1;
    else
    {
        lli c=modpower(a,b/2)%mod;
        if (b%2)
        return (((a*c)%mod)*c)%mod;
        else
        return (c*c)%mod;
    }
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i*i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=i*i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}
int main()
{
    fio;
    lli n,k;
    cin>>n>>k;
    lli dp[100004];
    for (int i=0;i<100004;i++)
    dp[i]=1e15;
    lli x,y,z;
    dp[0]=0;z=0;
    for (int i=0;i<n;i++)
    {
        cin>>y>>x;
        z+=x;
        for (int j=z;j>=x;j--)
        {
            dp[j]=min(dp[j],y+dp[j-x]);
        }
    }
    for (int i=100000;i>=0;i--)
    {
        if (dp[i]<=k)
        {cout<<i;exit(0);}
    }
    return 0;
}

Measured memory_bytes: 4392
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    a--;b--;c--;d--;
    string s;
    cin>>s;
    int y=0;
    for(int i=a;i<max(c,d);i++){
        if(s[i]=='.'){
            y=0;
        }
        else{
            y++;
        }
        if(y==2){
            cout<<"No"<<endl;return 0;
        }
    }
    if(c<d){
        cout<<"Yes"<<endl;return 0;
    }
    int x=0;
    for(int i=max(b-1,0);i<=d+1;i++){
        if(s[i]=='#'){
            x=0;
        }
        else{
            x++;
        }
        if(x==3){
            cout<<"Yes"<<endl;return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
//n=\prod_i l[i]^e[i] (i=j\iff l[i]=l[j])
int factorize(int n, int l[], int e[]){
    int k=n,i=0;
    if(k%2==0){
        int e2=0;
        while(k%2==0){
            e2++;
            k/=2;
        }
        l[i]=2;
        e[i]=e2;
        i++;
    }
    for(int q=3;q*q<=n;q+=2){
        if(k%q==0){
            int ei=0;
            while(k%q==0){
                ei++;
                k/=q;
            }
            l[i]=q;
            e[i]=ei;
            i++;
            if(k==1)break;
        }
    }
    if(k>1){
        l[i]=k;
        e[i]=1;
        i++;
    }
    return i;
}
int eall[100]={};
int main(){
    int n,l[10],e[10],cntr[5]={2,4,14,24,74},cnt[5]={};
    scanf("%d",&n);
    for(int i=2;i<=n;i++){
        int k=factorize(i,l,e);
        for(int j=0;j<k;j++)eall[l[j]]+=e[j];
    }
    for(int i=2;i<=n;i++){
        for(int j=0;j<5;j++){
            if(eall[i]>=cntr[j])cnt[j]++;
        }
    }
    //p^4q^4r^2
    int ans=cnt[1]*(cnt[1]-1)/2*(cnt[0]-2);
    //p^14q^4
    ans+=cnt[2]*(cnt[1]-1);
    //p^24q^2
    ans+=cnt[3]*(cnt[0]-1);
    //p^74
    ans+=cnt[4];
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.lang.*;


public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        TreeSet<Integer>[] digits = new TreeSet[10];
        for(int d=0; d<10; d++) digits[d] = new TreeSet<>();
        for(int n=0; n<N; n++) digits[S.charAt(n)-'0'].add(n);

        int answer = 0;

        for(int a=0; a<10; a++) for(int b=0; b<10; b++) for(int c=0; c<10; c++){
            try{Integer A = digits[a].first();
                Integer B = digits[b].higher(A);
                Integer C = digits[c].higher(B);
                if(!C.equals(null)) answer++;
            }catch(Exception e){}
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 25176
s = input()
t = input()
min_num = len(t)
for i in range(len(s)-len(t)+1):
    num = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            num += 1
    if min_num >= num:
        min_num = num

print(min_num)

Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int mod = 1000000007;

int main() {
    int n, k;
    cin >> n >> k;

    ll ans;
    if (k % 2 == 1) {
        ll d = n / k;
        ans = d * d * d;
    } else {
        k /= 2;
        ll d = n / k;
        ll even = d / 2;
        ll odd = (d + 1) / 2;
        ans = even * even * even + odd * odd * odd; 
    }

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

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

using namespace std;

#define int long long

const int N = 2e5 + 100, MOD = 1e9 + 7;

int fac[N], inv[N];
int n, m, k, ans;

int sum(int a, int b) {
    return (a + b + MOD) % MOD;
}

int mul(int a, int b) {
    return 1LL * a * b % MOD;
}

int power(int a, int p) {
    int res = 1;
    for (; p; p /= 2) {
	if (p % 2)
	    res = mul(res, a);
	a = mul(a, a);
    }
    return res;
}

int C(int k, int n) {
    return 1LL * fac[n] * inv[k] % MOD * inv[n - k] % MOD;
}

int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    fac[0] = 1;
    for (int i = 1; i < N; i++)
	fac[i] = mul(fac[i - 1], i);
    for (int i = 0; i < N; i++)
	inv[i] = power(fac[i], MOD - 2);
    cin >> n >> m >> k;
    int dp[n + 10][m + 10] = {};
    for (int i = 1; i <= m; i++)
	dp[1][i] = dp[1][i - 1] + i - 1;
    for (int i = 2; i <= n; i++) {
	dp[i][1] = sum(sum(dp[i - 1][1], mul(i - 2, m)), m * (m + 1) / 2 % MOD);
	for (int j = 2; j <= m; j++)
	    dp[i][j] = sum(dp[i][j - 1], sum(mul(j - 1, i), -mul(i - 1, m - j + 1)));
    }
    for (int i = 1; i <= n; i++)
	for (int j = 1; j <= m; j++)
	    ans = sum(ans, dp[i][j]);
    return cout << mul(ans, C(k - 2, m * n - 2)), 0;
}

Measured memory_bytes: 20608
import sys
input = sys.stdin.readline
n = int(input())
p0, p1 = map(int, input().split())
p = [p0, p1]
for _ in range(1, n):
    _, tmp = map(int, input().split())
    p.append(tmp)
# M[i]: p[i-1] * p[i]size

dp = [[0]*(n+1) for _ in range(n+1)]
#dp[i][j]: M[i]...M[j] の掛け算最小回数

for i in range(0, n+1):
    dp[i][i] = 0
# for i in range(1, n+1):
#     for j in range(i+1, n+1):
#         for k in range(i, j):
#             # M[i]...M[k], M[k+1]...M[j]
#             dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + p[i-1]*p[k]*p[j])
# print(dp[1][n])

for w in range(2, n+1):
    for i in range(1, n+1):
        j = i+w-1
        if j >= n+1:
            continue
        res = 1e30
        for k in range(i, j):
            res = min(
                res,
                dp[i][k] + dp[k+1][j] + p[i-1] * p[k] * p[j]
            )
        dp[i][j] = res
print(dp[1][n])


Measured memory_bytes: 5696
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const int inf = 1<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

int main () {
  int N; cin >> N;
  vi A(N+1), B(N);
  rep(i,N+1) cin >> A.at(i);
  rep(i,N) cin >> B.at(i);

  ll ans = 0;
  rep(i,N) {
    int left = min(A.at(i),B.at(i));
    ans += left;
    A.at(i) -= left;
    B.at(i) -= left;

    int right = min(A.at(i+1),B.at(i));
    ans += right;
    A.at(i+1) -= right;
    B.at(i) -= right;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cctype>
#include<queue>
#include<cstdio>
#include<cmath>
#include<sstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<ctime>
#include<cstdlib>
#include<map>
#include<utility>
#include<iomanip>
#include<set>
#include<stack>
//#include<Windows.h>
using namespace std;
typedef long long ll;typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vii;typedef vector<pii> vpi;
typedef vector<ll> vll;typedef vector<pll> vpl;
typedef queue<int> qii;typedef queue<pii> qpi;
int n,k,d[10];
bool like[10];
string s;
bool check(){
	int t=n;
	while(t!=0){
		int u=t%10;
		t/=10;
		if(like[u]) return false;
	}
	return true;
}
int main()
{
// 	freopen("","r",stdin);
	cin>>n>>k;
	for(int i=0;i<k;i++) {cin>>d[i];like[d[i]]=true;}
	while(!check())
		n++;
	cout<<n<<endl;
	return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll n, t;
  cin >> n >> t;
  ll result = 10000;
  ll num = 0;
  ll a, b;
  for(i = 0; i < n; i++){
    cin >> a >> b;
    //cout << result spa a << endl;
    if(b <= t && result > a){
      result = a;
      //cout << result << endl;
    }
    
  }
  
  if(result == 10000)
    cout << "TLE" << endl;
  else
    cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop, heapify
import copy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


s = S()
if s[-1] == "s":
    print(s + "es")
else:
    print(s + "s")


Measured memory_bytes: 67876
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

int main()
{
  string s, t;
  cin >> s >> t;

  ll count = 0;
  rep(i,s.size()) {
    if (s[i] != t[i]) {
      count++;
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vll vector<ll>
int main()
{
  ll n;
  cin>>n;
  n-=1;
  vll arr(n);
  for(ll i=0;i<n;i++)
    cin>>arr[i];
  ll sum=0;
  if(n==1)
    cout<<arr[0]*2;
  else
  {
    sum=arr[0];
    for(ll i=1;i<n;i++)
    sum+=min(arr[i],arr[i-1]);
    sum+=arr[n-1];
  cout<<sum;}
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int n;
    cin >> n;
    int ans = pow(3, n), m=1, tmp;
    for(int i=0; i<n; i++){
        cin >> tmp;
        if(tmp%2==0){
            m *= 2;
        }
    }
    cout << ans - m << endl;
    return 0;
}

Measured memory_bytes: 4008
var primes,sum:array[0..100020] of longint;
var prime:array[0..100020] of boolean;
var n,m,i,j,x,num,y:longint;
begin
  prime[0]:=true;prime[1]:=true;
  for i:=2 to 100000 do
  begin
    if not prime[i] then begin inc(num);primes[num]:=i;end;
    for j:=1 to num do
    begin
      if i*primes[j]>100000 then break;
      prime[i*primes[j]]:=true;
      if i mod primes[j]=0 then break;
    end;
  end;
  fillchar(sum,sizeof(sum),0);
  for i:=1 to 100000 do if (not prime[i]) and (not prime[(i+1) div 2])
  then begin sum[i]:=sum[i-1]+1;//writeln(i);
  end
  else sum[i]:=sum[i-1];
  read(m);
  for i:=1 to m do begin read(x,y);writeln(sum[y]-sum[x-1]);end;
end.

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>

using namespace std;

int main(){
    int a, b;
    int v, w;
    int t;

    cin >> a >> v;
    cin >> b >> w;
    cin >> t;

    int diffDis;

    if(b > a){
        diffDis = b - a;
    }
    else{
        diffDis = a - b;
    }

    int speedDif = v - w;

    if(speedDif <= 0){
        cout << "NO";
        return 0;
    }

    long double time = ((long double)diffDis)/speedDif;


    if(time > t){
        cout << "NO";
        return 0;
    }

    cout << "YES";
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main () {
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	if (a * b >= c * d) {
		printf("%d\n", a * b);
	}
	else {
		printf("%d\n", c * d);
	}
	return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, p[8], q[8], a = 0, b = 0;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++) cin >> p[i];
    for (int i = 0; i < n; i++) arr[i] = i + 1;
    while(true) {
        a++;
        
        bool good = true;
        for (int i = 0; i < n; i++) if (arr[i] != p[i]) good = false;
        if (good) break;
      	next_permutation(arr,arr+n);
    }
    for (int i = 0; i < n; i++) cin >> q[i];
    for (int i = 0; i < n; i++) arr[i] = i + 1;
    while(true) {
        b++;
        
        bool good = true;
        for (int i = 0; i < n; i++) if (arr[i] != q[i]) good = false;
        if (good) break;
      	next_permutation(arr,arr+n);
    }
    cout << abs(b - a) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
   
using namespace std;
typedef long long int ll;
  
int main()
{
	int s=0, t=0;
    for(int i=0; i<3; i++){
		int a;
		scanf("%d", &a);
		if(a==5) s++;
		if(a==7) t++;
	}
	if(s==2 && t==1){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
  for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
  for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup \
  cin.tie(0);  \
  ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (int i = 0; i < v.size(); ++i) {
    is >> v[i];
  }
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < v.size() - 1; ++i) {
    os << v[i] << " ";
  }
  if (v.size() > 0) {
    os << v[v.size() - 1] << endl;
  }
  return os;
}

int main() {
  string t;
  cin >> t;
  int sz = t.size();
  REP(i,sz){
    if (t[i] == '?'){
      t[i] = 'D';
    }
  }
  cout << t << endl;
}

Measured memory_bytes: 3724
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        int n,k,count = 0;
        
        Scanner sc = new Scanner(System.in);
        
        n = sc.nextInt();
        k = sc.nextInt();
        
        for(int i = 0; i < n; i++){
            int h = sc.nextInt();
            if(h >= k) count++;
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 47704
from collections import defaultdict
from itertools import product

H, W, N = map(int, input().split())
cnt = defaultdict(int)
D = tuple(product((-1, 0, 1), repeat=2))

for _ in range(N):
    a, b = map(int, input().split())
    for dh, dw in D:
        h = a + dh
        w = b + dw
        if 2 <= h <= H - 1 and 2 <= w <= W - 1:
            cnt[(h, w)] += 1

ans = [0] * 10
for c in cnt.values():
    ans[c] += 1
ans[0] = (H - 2) * (W - 2) - sum(ans)
print(*ans, sep='\n')


Measured memory_bytes: 166868
#include<stdio.h>
#define size 1000000

	struct process{
		char name[10];
		int time;
	};
	struct process p[size],now_process;
	int head,tail;

	void enqueue(struct process new_process){
		p[tail]=new_process;
		tail=tail+1;
	}

	struct process dequeue(){
		struct process out_process=p[head];
		head=head+1;
		return out_process;
	}



int main(void){
	int n,q;
	int clock=0;
	scanf("%d",&n);
	scanf("%d",&q);
	int i;
	for(i=0;i<n;i++){
		scanf("%s",p[i].name);
		scanf("%d",&p[i].time);
	}
	head=0;
	tail=n;
	while(head!=tail){
		now_process=dequeue();
		if(now_process.time<=q){
			clock=clock+now_process.time;
			printf("%s %d\n",now_process.name,clock);
		}else{
			now_process.time=now_process.time-q;
			clock=clock+q;
			enqueue(now_process);
		}
	}

	return 0;
}

Measured memory_bytes: 4688
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
	string str;
	cin>>str;
	bool c=false;
	for(int i=0;i<str.length();i++){
		if(str[i]=='C'){
			c=true;
		}
		if(str[i]=='F'&&c==true){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.TreeMap;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int cnt = 0;
    int max = 0;
    int ans = 0;
    if (N == 1) {
      System.out.println(1);
      return;
    }
    for (int i = 1; i <= N; i++) {
      cnt = 0;
      int A = i;
      while (A % 2 == 0) {
        A /= 2;
        cnt++;
      }
      if (cnt > max) {
        ans = i;
        max = cnt;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23380
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;

int main() {
	int n;

	vector<long long> v;
	set<long long> table;

	cin >> n;
	for (int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
		if (table.count(temp) == 0) {
			table.insert(temp);
		}
		else {
			v.push_back(temp);
			table.erase(temp);
		}
	}

	sort(v.begin(), v.end());

	if (v.size() < 2) {
		cout << 0 << endl;
	}
	else {
		cout << v[v.size() - 1] * v[v.size() - 2] << endl;
	}

	return 0;
}

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


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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

struct lr{
    int l,r;
    bool operator<(const lr& a) const{
        if(r!=a.r)return r<a.r;
        else return l < a.l;
        
    }
};

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

    vector<lr> lis(M);
    rep(i,0,M){
        int a,b;
        cin>>a>>b;
        lr tmp;
        tmp.l = a;
        tmp.r = b;
        lis[i] = tmp;
    }
    sort(all(lis));
    ll ans = 1;
    int rmin = INF;
    rep(i,0,M){
        if(rmin <=lis[i].l){
            rmin = lis[i].r;
            ans++;
        }
        else{
            rmin= min(rmin,lis[i].r);
        }
    }
    cout<<ans;
    return 0;
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    string S;
    cin >> S;
    int ans=0;
    if(S.size()==1){
        P(0);
        return 0;
    }
    REP(i,0,S.size()-1){
        if(S[i]!=S[i+1]) ans++;
    }
    P(ans);
}

Measured memory_bytes: 512