akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int MAX = (int)(4800 + 5);

int n;

int board[MAX];

int ans, ans_;

int main(void){
  // Here your code !
  scanf("%d", &n);

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

  bool range[8 + 5];
  int overrange = 0;

  for (int i = 0; i < 8 + 5; ++i) {
    range[i] = false;
  }

  for (int i = 1; i <= 4800; ++i) {
    if (1 <= i && i < 400) {
      range[0] |= (board[i] > 0) ? true : false;
    }
    else if (400 <= i && i < 800) {
      range[1] |= (board[i] > 0) ? true : false;
    }
    else if (800 <= i && i < 1200) {
      range[2] |= (board[i] > 0) ? true : false;
    }
    else if (1200 <= i && i < 1600) {
      range[3] |= (board[i] > 0) ? true : false;
    }
    else if (1600 <= i && i < 2000) {
      range[4] |= (board[i] > 0) ? true : false;
    }
    else if (2000 <= i && i < 2400) {
      range[5] |= (board[i] > 0) ? true : false;
    }
    else if (2400 <= i && i < 2800) {
      range[6] |= (board[i] > 0) ? true : false;
    }
    else if (2800 <= i && i < 3200) {
      range[7] |= (board[i] > 0) ? true : false;
    }
    else if (3200 <= i) {
      overrange += board[i];
    }
  }

  int cnt = 0;

  for (int i = 0; i < 8; ++i) {
    if (range[i]) cnt += 1;
  }

  if (cnt == 0) {
    ans = 1;
    ans_ = overrange;
  }
  else {
    ans = cnt;
    ans_ = ans + overrange;
  }

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

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define N 3
#define N2 9

struct Puzzle{
	int f[N2];
	int space;
	string path;

	bool operator < (const Puzzle &p)const{
		for (int i = 0; i < N2; ++i) {
			if(f[i]==p.f[i])continue;
			return f[i]>p.f[i];
		}
		return false;
	}
};

static const int dx[4]={-1,0,1,0};
static const int dy[4]={0,-1,0,1};
static const char dir[4]={'u','l','d','r'};

bool isTarget(Puzzle p){
	for (int i = 0; i < N2; ++i) {
		if(p.f[i]!=(i+1))return false;
	}
	return true;
}

string bfs(Puzzle s){
	queue<Puzzle> Q;
	map<Puzzle,bool> V;
	Puzzle u,v;
	s.path="";
	Q.push(s);
	V[s]=true;
	while(!Q.empty()){
		u=Q.front();Q.pop();
		if(isTarget(u))return u.path;
		int sx=u.space/N;
		int sy=u.space%N;
		for(int r=0;r<4;r++){
			int tx=sx+dx[r];
			int ty=sy+dy[r];
			if(tx<0||ty<0||tx>=N||ty>=N)continue;
			v=u;
			swap(v.f[u.space],v.f[tx*N+ty]);
			v.space=tx*N+ty;
			if(!V[v]){
				V[v]=true;
				v.path+=dir[r];
				Q.push(v);
			}
		}
	}
	return "unsolvable";
}
int main(){
	Puzzle in;
	for (int i = 0; i < N2; ++i) {
		cin>>in.f[i];
		if(in.f[i]==0){
			in.f[i]=N2;//set space
			in.space=i;
		}
	}
	string ans=bfs(in);
	cout<<ans.size()<<endl;
	return 0;
}

Measured memory_bytes: 30528
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    String s=in.next();
    if(s.compareTo("ABC")==0)
    {
      System.out.println("ARC");
    }
    else
    {
      System.out.println("ABC");
    }
  }
}

Measured memory_bytes: 35620
#include <iostream>

using namespace std;
int main(){

    string f;
    cin>>f;
    int i,n=f.length(),flag=0;
     for(i=0;i<n;i++)
     {
        if(i%2==0 && f[i]!='h')
              flag=1;
        if(i%2==1 && f[i]!='i')
              flag=1;
      }
if (flag==1| n%2==1)
    cout<<"No";
else
     cout<<"Yes";
      
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  
  vector<int> c(m);
  
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      
      c[a-1]++;
    }
  }
  
  cout << count(c.begin(), c.end(), n) << endl;
}

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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

const int W = (int) 1e5 + 7;
int n, wLimit;
ll maxProfit[W];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> wLimit;
  for (int i = 1; i <= n; i++) {
    int w, profit;
    cin >> w >> profit;
    for (int j = wLimit; j >= w; j--) {
      maxProfit[j] = max(maxProfit[j], maxProfit[j - w] + profit);
    }
  }
  cout << maxProfit[wLimit] << "\n";
  return 0;
}


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

int main(void) {
    int a, b;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b;
    cout << ((a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)? "Possible" : "Impossible") << "\n";
    return 0;
}

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

int main()
{
	string s, t;
	cin >> s >> t;
	int len = s.length();
	if( s == t ) {
		cout << "Yes" << endl;
		return 0;
	}
	for( int i = 0; i < len; i++ ) {
		s = s[len-1] + s.substr(0, len-1);
		if( s == t ) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
int64_t N,K;
cin>>N>>K;
vector <int64_t> H(N);
for(int i=0; i<N; i++){
    cin>>H[i];
}
sort(H.begin(),H.end());
reverse(H.begin(), H.end());
if(N<=K){
    cout<<"0"<<endl;
    return 0;
}else{
    int64_t at=0;
    for(int64_t i=K; i<N; i++){
        at+=H[i];
    }
    cout<<at<<endl;
}
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
  int a,l,x;
  while( cin >> a >> l >> x ){
    double result = a * sqrt( l*l - a * a / 4.0 ) / 2.0 +
      ( l * sqrt( ( (l+x) * (l+x) / 4.0 ) - l * l/4.0 )  ) ;
    printf("%.10f\n",result);
  }

  return 0;
}

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

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


    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        System.out.println(a[n / 2] - a[n / 2 - 1]);

    }
}


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

int main(){
  int n;cin>>n;
  string w;cin>>w;
  set <string> s;
  s.insert(w);
  for(int i=1;i<n;i++){
    char x=w[w.size()-1];
    cin>>w;
    char y=w[0];
    if(s.count(w)||x!=y){cout<<"No";return 0;}
    else s.insert(w);
  } 
  cout<<"Yes";
}

Measured memory_bytes: 256
N=int(input())
n=N//15
ans=60*(n**2)
if N%15==1:
	ans+=(1+15*(n))
elif N%15==2 or N%15==3:
	ans+=(3+30*(n))
elif N%15==4 or N%15==5 or N%15==6:
	ans+=(7+45*(n))
elif N%15==7:
	ans+=(14+60*(n))
elif N%15==8 or N%15==9 or N%15==10:
	ans+=(22+75*(n))
elif N%15==11 or N%15==12:
	ans+=(33+90*(n))
elif N%15==13:
	ans+=(46+105*(n))
elif N%15==14:
	ans+=(60+120*(n))
print(ans)

Measured memory_bytes: 9236
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

#define ll long long
using vt = int; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define MOD 1000000007

int main() {
	int a, b;
	cin >> a >> b;
	if (a + b == 3) cout << 3;
	else if (a + b == 4) cout << 2;
	else cout << 1;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  if(N==1){
    printf("Hello World\n");
  }
  
  if(N==2){
    int A, B;
    cin >> A;
    cin >> B;
    printf("%d\n", A+B);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
long long n,a,b;
int main(){
  cin >> n >> a >> b;
  if(b-a < 0 || b-a > n){
    cout << 0 << endl;
  }else{
    cout << (a+b+(b*(n-2)))-(a+b+(a*(n-2)))+1 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    string s,t;cin >> s >> t;
    vector<vector<int>> dp(3010,vector<int>(3010,0));
    
    //dpテーブル
    rep(i,s.size()) rep(j,t.size()){
        if(s[i] == t[j])chmax(dp[i+1][j+1],dp[i][j] + 1);
        chmax(dp[i+1][j+1],dp[i+1][j]);
        chmax(dp[i+1][j+1],dp[i][j+1]);
    }

    //復元
    int i = s.size(); int j = t.size();
    string ans = "";
    while(i > 0 && j > 0){
        
        if(dp[i][j] == dp[i][j-1]){
            j--;
        }
        else if(dp[i][j] == dp[i-1][j]){
            i--;
        }
        else{
            ans = s[i-1] + ans;
            i--;
            j--;
        }
    }

    cout << ans << endl;

}



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

int main() {
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;

    if (S == U) cout << A - 1 << " " << B << endl;
    else cout << A << " " << B - 1 << endl;
}

Measured memory_bytes: 256
import java.util.*;
//import java.util.Math.*;

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

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int w[] = new int[n];
    int max = 0;
    int acc = 0;
    int left, right;
    int p;
    int sum = 0;
    int cnt = 0;
    
    for(int i = 0; i < n; i++){
        w[i] = sc.nextInt();
        acc = acc + w[i];
        max = Math.max(max,w[i]);
    }
    
    left = max;
    right = acc;
    while(left < right){
        p = (left + right) / 2;
        sum = 0;
        cnt = 0;
        
        for(int i = 0; i < n; i++){
            //System.out.println(i + " " + sum + " " + cnt + " " + p);
            if((sum + w[i]) > p){
                sum = w[i];
                cnt++;
            }else{
                sum = sum + w[i];
            }
            
            if(cnt == k){
                break;
            }
        }
        
        if(cnt == k){
            left = p + 1;
        }else{
            right = p;
        }
    }
//    System.out.println(sum + " " + max);
    System.out.println(left);


    }

}



Measured memory_bytes: 70300
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
int p[25];
int main(void)
{
  int n;
  cin >> n;
  int ans=0;
  for(int i=0;i<n;i++)
  {
    cin >> p[i];
  }
  for(int i=1;i<n-1;i++)
  {
    if((p[i]>p[i-1] && p[i]<p[i+1]) || (p[i]>p[i+1] && p[i]<p[i-1]) ) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    double n; cin>>n;
    vector<double> v(n);
    rep(i,n) cin>>v[i];
    sort(all(v));
    double ans=v[0];
    repi(i,1,n) ans=(ans+v[i])/2;
    cout<<ans;
}

Measured memory_bytes: 3796
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
using namespace std;
const int INF = 1e9;
typedef long long lint;
const lint LINF = 1e18;
const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

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

	cout<<"No"<<endl;
}


Measured memory_bytes: 1284
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#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 ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, M;
  cin >> N >> M;
  vector<string> S(N);
  REP(i, N) cin >> S[i];
  mf_graph<int> graph(N*M+2);
  REP(i, N) REP(j, M) {
    if(S[i][j] == '#') continue;
    if((i+j)%2 == 0) {
      graph.add_edge(N*M, i*M+j, 1);
      if(i != 0 && S[i-1][j] == '.') graph.add_edge(i*M+j, (i-1)*M+j, 1);
      if(i != N-1 && S[i+1][j] == '.') graph.add_edge(i*M+j, (i+1)*M+j, 1);
      if(j != 0 && S[i][j-1] == '.') graph.add_edge(i*M+j, i*M+j-1, 1);
      if(j != M-1 && S[i][j+1] == '.') graph.add_edge(i*M+j, i*M+j+1, 1);
    } else graph.add_edge(i*M+j, N*M+1, 1);
  }
  cout << graph.flow(N*M, N*M+1) << "\n";
  auto edges = graph.edges();
  REP(i, edges.size()) {
    if(edges[i].flow == 0 || edges[i].from == N*M || edges[i].to == N*M+1) continue;
    int mi = min(edges[i].from, edges[i].to);
    int ma = max(edges[i].from, edges[i].to);
    if(ma - mi != M) {
      S[mi/M][mi%M] = '>';
      S[ma/M][ma%M] = '<';
    } else {
      S[mi/M][mi%M] = 'v';
      S[ma/M][ma%M] = '^';
    }
  }
  REP(i, N) cout << S[i] << "\n";
}

Measured memory_bytes: 5540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;

    vector<ll> p(a),q(b),r(c);

    for(int i = 0; i < a; i++){
        cin >> p[i];
    }
    for(int i = 0; i < b; i++){
        cin >> q[i];
    }
    for(int i = 0; i < c; i++){
        cin >> r[i];
    }

    sort(p.begin(),p.end());
    reverse(p.begin(),p.end());
    p.resize(x);

    sort(q.begin(),q.end());
    reverse(q.begin(),q.end());
    q.resize(y);

    sort(r.begin(),r.end());
    reverse(r.begin(),r.end());

    vector<ll> all(p.size()+q.size()+r.size());

    

    all.insert(all.end(),p.begin(),p.end());
    all.insert(all.end(),q.begin(),q.end());
    all.insert(all.end(),r.begin(),r.end());
    sort(all.begin(),all.end());
    reverse(all.begin(),all.end());

    ll ans = 0;
    
    for(int i = 0; i < x+y;i++){
        ans += all[i];
    }

    cout << ans << endl;




    



    




}

Measured memory_bytes: 9088
import java.io.*

val pw = PrintWriter(System.out)
const val MOD = 1000000007L
const val INF = 2147483647
const val LINF = 9223372036854775807L

fun main(args: Array<String>) {
    solve()
    pw.flush()
}

fun solve() {
    val (n, k) = nextLongList()
    val ans = min(n % k, abs(n % k - k))
    println(ans)

}


fun println(v: String) {
    pw.println(v)
}

fun print(v: String) {
    pw.print(v)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ").toMutableList()
fun nextIntList(index: Int = 0) = next().split(" ").map { it.toInt() + index }.toMutableList()
fun nextLongList(index: Long = 0L) = next().split(" ").map { it.toLong() + index }.toMutableList()
fun nextDoubleList() = next().split(" ").map { it.toDouble() }.toMutableList()

fun ary(n: Int, init: String = "") = Array(n) { init }
fun intAry(n: Int, init: Int = 0) = IntArray(n) { init }
fun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }
fun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }
fun ary2(n: Int, m: Int, init: String = "") = Array(n) { Array(m) { init } }
fun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }
fun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }
fun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }
fun ary3(n: Int, m: Int, k: Int, init: String = "") = Array(n) { Array(m) { Array(k) { init } } }
fun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }
fun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }
fun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }

fun abs(n: Int): Int = Math.abs(n)
fun abs(n: Long): Long = Math.abs(n)
fun abs(n: Double): Double = Math.abs(n)
fun max(vararg values: Int) = if (values.isEmpty()) -INF else values.max()!!
fun max(vararg values: Long) = if (values.isEmpty()) -LINF else values.max()!!
fun min(vararg values: Int) = if (values.isEmpty()) INF else values.min()!!
fun min(vararg values: Long) = if (values.isEmpty()) LINF else values.min()!!

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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 1e9+7;
bool isp(int x){
    for(int i = 2 ; i <= sqrt(x) ; i++){
        if(x % i == 0)return 0;
    }
    return 1;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin >> x;
    while(!isp(x))x++;
    cout << x << '\n';
}

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

typedef long long ll;
const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    int ansi = a.back();
    a.erase(a.end()-1);
    int mn = INF;
    int ansj;
    for (int i=0;i<n-1;i++){
        if (mn>abs(2*a[i]-ansi)){
            ansj = a[i];
            mn = abs(2*a[i]-ansi);
        }
    }
    cout << ansi << " " << ansj << "\n";
}

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

int main(){
    ll n;
    cin >> n;
    ll a[n];
    for(ll i = 0; i < n; i++){
        cin >> a[i];
    }
    ll cou = 1;
    ll min = a[0];
    for(ll i = 1; i < n; i++){
        if(min >= a[i]){
            cou++;
            min = a[i];
        }
    }

    cout << cou << endl;
}

Measured memory_bytes: 1792
def check(p):
    i = 0
    for _ in range(k):
        total = 0
        while total+n_list[i] <=p:
            total += n_list[i]
            i += 1
            if i == n:
                return n
    return i

def solve():
    left   = 0
    right  = 10**5 * 10**4
    middle = 0
    while right - left > 1:
        middle = (left+right)//2
        temp_ans = check(middle)
        if temp_ans >= n:
            right = middle
        else:
            left  = middle
    return right

n,k = map(int,input().split())
n_list = [int(input()) for _ in range(n)]
ans = solve()
print(ans)


Measured memory_bytes: 9560
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <string.h>

using namespace std;
#define ll long long int

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll n,m,sum,temp;
	cin>>n>>m;
	ll a[n];
	sum=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>temp;
		sum+=temp;
		a[i]=temp;
	}
	sort(a,a+n);
	reverse(a,a+n);
	// for (int i = 0; i < n; ++i)
	// {
	// 	cout<<a[i]<<" ";
	// }
	// cout<<endl;
	// cout<<sum<<" "<<sum/(4*m)<<endl;
	ll flag=0;
	for (int i = 0; i < m; ++i)
	{
		if(sum%(4*m)){
			if(a[i]<=(sum/(4*m)))
				flag=1;
		}
		else{
			if(a[i]<(sum/(4*m)))
				flag=1;
		}
		// cout<<a[i]<<" "<<flag<<endl;
	}
	if (flag)
		cout<<"No";
	else
		cout<<"Yes";
	return 0;
}


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

using namespace std;
#define ll long long
#define ld long double
#define mp make_pair

void print(auto &a)
{
    for (auto s: a) cout<<s<<' ';
    cout<<endl;
}

void get(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cin>>a[i];
}

const int p =  1e9 + 7;


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

int add(int a, int b) {
    ll s = (a+b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}



vector<int> Z(string s)
{
int n = s.length();
vector<int> z(n);
int L = 0, R = 0;
for (int i = 1; i < n; i++) {
  if (i > R) {
    L = R = i;
    while (R < n && s[R-L] == s[R]) R++;
    z[i] = R-L; R--;
  } else {
    int k = i-L;
    if (z[k] < R-i+1) z[i] = z[k];
    else {
      L = i;
      while (R < n && s[R-L] == s[R]) R++;
      z[i] = R-L; R--;
    }
  }
}
return z;
}





int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<int> a(n);
    get(a);
    vector<vector<int>> pos(200020);
    for (int i = 0; i<n; i++) pos[a[i]].push_back(i);
    
    vector<ll> answer(n+1);
    answer[0] = 1;
    for (int i = 0; i<n; i++)
    {
        int k = lower_bound(pos[a[i]].begin(), pos[a[i]].end(), i) - pos[a[i]].begin();
        //cout<<k<<endl;
        if (k==0) answer[i+1] = answer[i];
        else
        {
            int t = pos[a[i]][k-1];
            if (i==t+1) answer[i+1] = answer[i];
            else answer[i+1] = add(answer[i], answer[t+1]);
        }
    }
    cout<<answer[n];
    
}

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

int main(){
  int N,M,C;
  cin>>N>>M>>C;
  vector<int> B(M);
  vector<vector<int>> A(N,vector<int>(M));
  for(int i=0;i<M;++i){cin>>B.at(i);}
  for(int i=0;i<N;++i){for(int j=0;j<M;++j){cin>>A.at(i).at(j);}}

  int count=0;
  for(int i=0;i<N;++i){
    int sum=C;
    for(int j=0;j<M;++j){
      sum=sum+B.at(j)*A.at(i).at(j);
    }
    if(sum>0){
      ++count;
    }
  }

  cout<<count<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		if(s.matches("(dream|dreamer|erase|eraser)+")) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 34296
#include <iostream>
#include <algorithm>

using namespace std;

int x[100001], d[100001];
int a[100001], pos[70][100001];

int main() {
	int n, m;
	long long k;

	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> x[i];

	cin >> m >> k;
	for (int i = 1; i <= m; ++i) cin >> a[i];

	for (int i = 1; i < n; ++i) d[i] = i;

	for (int i = 1; i <= m; ++i)
		swap(d[a[i] - 1], d[a[i]]);
	for (int i = 1; i < n; ++i)
		pos[0][d[i]] = i;
	
	for (int i = 1; i <= 61; ++i)
		for (int j = 1; j < n; ++j)
			pos[i][j] = pos[i - 1][pos[i - 1][j]];

	for (int i = 1; i < n; ++i) {
		int p = i;
		long long t = k;
		for (int j = 61; j >= 0; --j)
			if (t >= (1LL << j)) {
				t -= (1LL << j);
				p = pos[j][p];
			}
		d[p] = x[i + 1] - x[i];
	}

	long long sum = x[1];
	cout << sum << '\n';
	for (int i = 1; i < n; ++i) {
		sum += d[i];
		cout << sum << '\n';
	}

	return 0;
}

Measured memory_bytes: 27008
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  double n; cin >> n;
  if ((int)n%2) {
    COUT( (n+1) / (2*n));
  } else {
    COUT(0.5);
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,w;
    cin>>n>>w;
    ll a[n],b[n];
    for(int i=0;i<n;i++){
    	cin>>a[i]>>b[i];
    }
    vector<pair<ll,ll> > v1,v2;
    ll m=n/2,maki=(1<<m);
    for(int bit=0;bit<maki;bit++){
    	ll vsum=0,wsum=0;
    	for(int i=0;i<m;i++)if(bit>>i&1){
    		vsum+=a[i];
    		wsum+=b[i];
    	}
    	if(wsum<=w)v1.push_back({wsum,-vsum});
    }
    sort(be(v1));
    ll niko=v1.size();
    ll s=1;
    for(int i=1;i<niko;i++)if(v1[s-1].first<v1[i].first&&v1[s-1].second>v1[i].second)v1[s]=v1[i],s++;
    for(int i=0;i<s;i++){
    	v1[i].second=-v1[i].second;
    }
    niko=m;
    m=n-m;maki=(1<<m);
    for(int bit=0;bit<maki;bit++){
    	ll vsum=0,wsum=0;
    	for(int i=0;i<m;i++)if(bit>>i&1){
    		vsum+=a[i+niko];
    		wsum+=b[i+niko];
    	}
    	if(wsum<=w)v2.push_back({wsum,-vsum});
    }
    sort(be(v2));
    m=1;maki=v2.size();
    for(int i=1;i<maki;i++)if(v2[m-1].first<v2[i].first&&v2[m-1].second>v2[i].second)v2[m]=v2[i],m++;
    for(int i=0;i<m;i++){
    	v2[i].second=-v2[i].second;
    }
    ll ans=0;
    vector<ll> c;
    for(int i=0;i<m;i++){
    	c.pb(v2[i].first);
    }
    for(int i=0;i<s;i++){
    	ans=max(ans,v1[i].second+v2[(upper_bound(be(c),w-v1[i].first)-c.begin()-1)].second);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 43768
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) x.size()
#define int ll 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
int n;
vector <int> g[N];
int ans[N];
set <int> s;
map <pii, int> m;
void dfs (int v, int p, int col) {
  	int x = 0;
  	s.in (col);
  	for (auto to : g[v]) {
  		if (to != p) {
  			x ++;
  			if (x == col) x ++;
  			ans[m[mp (min (v, to), max (v, to))]] = x;
  			dfs (to, v, x);
  		}
  	}
}
void solve () {
	cin >> n;
	for (int i = 1; i < n; i ++) {
		int l, r;
		cin >> l >> r;
		if (l > r) swap (l, r);
		m[mp (l, r)] = i;
		g[l].pb (r);
		g[r].pb (l);
	}
	dfs (1, 1, -1);
	cout << (int)sz (s) - 1 << endl;
	
	for (int i = 1; i < n; i ++) cout << ans[i] << endl;
}
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//	cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

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

g = [[] for _ in range(n)]
for i in range(n-1):
	u,v,w=map(int,input().split())
	u,v=u-1,v-1
	g[u].append((v,w))
	g[v].append((u,w))

color = [-1]*n
color[0]=0

import queue

q=queue.Queue()
q.put(0)

while not q.empty():
	now=q.get()

	for ne,weight in g[now]:
		if color[ne]!=-1:
			continue
		if weight%2==0:
			color[ne]=color[now]
		else:
			color[ne]=abs(color[now]-1)
		q.put(ne)

for i in range(n):
	print(color[i])

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

#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto &it : v)
#define all(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using vpii = vector<Pii>;
using vpll = vector<Pll>;

const ll mod=1e9+7;
const int intINF=INT_MAX;
const ll  longINF=LONG_LONG_MAX;


main()
{
        string s,t; cin>>s>>t;
        sort(all(s));
        sort(all(t),greater<char>());
        if(s<t)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef double ld;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=20;
map<pii,ll> f[N][N];
ll ans=1e18;
int a[N],n;

void cmin(ll &x,ll y){
	if(y<x)x=y;
}

ll solve(int l,int r,int x,int y){
	if(l+1==r)return 0;
	if(l+2==r)return (ll)a[l+1]*(x+y);
	if(f[l][r].count(mp(x,y)))
		return f[l][r][mp(x,y)];
	ll res=1e18;
	rep(k,l+1,r-1)
		cmin(res,solve(l,k,x,x+y)+solve(k,r,x+y,y)+(ll)a[k]*(x+y));
	f[l][r][mp(x,y)]=res;
	return res;
}

int main(){
	read(n);
	rep(i,1,n)read(a[i]);
	cout<<a[1]+a[n]+solve(1,n,1,1)<<endl;
	return 0;
}

Measured memory_bytes: 8320
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		String result = "";
		if(s.charAt(s.length()-1) == 's'){
		    result = s + "es";
		}else{
		    result = s + "s";
		}
		
		// 出力
		System.out.println(result);
		
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}

}


Measured memory_bytes: 25288
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;

const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


void solve(){

    ll s;
    cin >> s;
    COMinit();

    ll ans = 0;
    rep(n,s/3){
        ll x = s-3*(n+1);
        ans = ans + COM(x+n,x);
        ans = ans % MOD;
    }
    cout << ans << endl;

}

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


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int n;
    cin >> n;
    vector<int> x(n), y(n), per(n);
    rep(i, n) cin >> x[i] >> y[i];

    rep(i, n) per[i] = i;
    double ans = 0;
    int cnt = 0;
    do
    {
        cnt++;
        rep(i, n - 1)
        {
            ans += sqrt(pow(x[per[i + 1]] - x[per[i]], 2.0) + pow(y[per[i + 1]] - y[per[i]], 2.0));
        }

    } while (next_permutation(all(per)));

    printf("%6lf\n", ans / cnt);
    return 0;
}


Measured memory_bytes: 3848
// C - Build Stairs 2019/8/17

#include<stdio.h>

int main(void){
    int n,a,max=0,i;
    scanf("%d",&n);
    scanf("%d",&max);
    for(i=1;i<n;i++){
        scanf("%d",&a);
        if((max-a)>1){
            printf("No\n");
            return 0;
        }
        if(max<a){
            max=a;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
N=int(input())
A=list(map(int,input().split()))
asum=[0 for i in range(0,N+1)]
for i in range(1,N+1):
    asum[i]=A[i-1]+asum[i-1]

dp=[[0 for i in range(0,N+1)] for j in range(0,N)]

for i in range(0,N):
    if N>i+1:
        dp[i][2]=A[i]+A[i+1]

for j in range(3,N+1):
    for i in range(0,N):
        if N>i+j-1 and j!=3:
            ans=min(A[i]+asum[i+j]-asum[i+1]+dp[i+1][j-1],asum[i+j-1]-asum[i]+dp[i][j-1]+A[i+j-1])
            test=min(dp[i][k]+dp[i+k][j-k]+asum[i+k]-asum[i]+asum[i+j]-asum[i+k] for k in range(2,j-1))
            dp[i][j]=min(ans,test)
        elif N>i+j-1:
            dp[i][j]=min(A[i]+asum[i+j]-asum[i+1]+dp[i+1][j-1],asum[i+j-1]-asum[i]+dp[i][j-1]+A[i+j-1])


print(dp[0][N])


Measured memory_bytes: 46684
def toString(s):
    return "".join([chr(x + ord('a')) for x in s])


def func(s, mx, N):
    if len(s) == N:
        print(toString(s))
        s.pop()
        return
    for i in range(mx+2):
        s.append(i)
        func(s, max(mx, i), N)
    s.pop()


def main():
    N = int(input())
    func([0], 0, N)


if __name__ == "__main__":
    main()


Measured memory_bytes: 66648
n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]

count = 0
t, x, y = 0, 0, 0
for i in range(n):
    ti, xi, yi = l[i][0], l[i][1], l[i][2]
    dl = abs(x - xi) + abs(y - yi)
    dt = ti - t
    if dt % dl == 0:
        count += 1
        t, x, y = ti, xi, yi
        continue
    else:
        break

if count == n:
    print('Yes')
else:
    print('No')


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

int judge(int x){
    bool can = true;
    bool cancan = false;
    int y=sqrt(x) + 1;
    for(int i=2;i<y;i+=1){
        if(x%i==0){
            can = false;
        }
    }
    if(can){
        //cout << "sosuu" << endl;
        cancan = true;
    }
    return cancan;

}
int main(){
    int x;
    cin >> x;
    for(int i=x;;i++){
        bool can;
        can = judge(i);
        if(can){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
def main():
    A, B, K = map(int, input().split())

    if K < A:
        A = A - K
    elif K <= A + B:
        B = B - K + A
        A = 0
    else:
        A, B = 0,0

    print('{} {}'.format(A, B))

if __name__ == '__main__':
    main()

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

int  main(){

  long long a,b,k; cin >> a >> b >> k;
  long long temp = a;
  a = max(0LL,a-k);
  k = max(0LL,k - temp);
  b = max(0LL,b-k);
  cout << a << " " << b << '\n';
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 1000
int main(){  
 
   int i,j,k,l,N;
   int A[MAX];
    
   scanf("%d",&N);
   
   for(i=1;i<=N;i++){
    
    scanf("%d",&A[i]);
    
   }
 
     printf("%d",A[1]);
     
     for(i = 2;i <= N;i++){
      
      printf(" %d",A[i]);
     
    }
     
     printf("\n");
  
    for (i = 2 ; i< N+1; i++){
    
     l = A[i];
    
     j = i - 1;
     
     while (j >= 0 && A[j] > l){
       
     A[j+1] = A[j];
       
        j--;
     
     A[j+1] = l;
     
   }
      
     printf("%d",A[1]);
     
    for(k = 2;k < N+1;k++){
       
      printf(" %d",A[k]);
    
     }
    
      printf("\n");
   
   }

   return 0;   

}

Measured memory_bytes: 1796
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep(i,n)    for(ll i=1; i<=n; i++)
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n'
#define no cout<<"No"<<'\n'
using namespace std;

int main()
{
    godspeed

    ll i,j,a,b,x;
    cin>>a>>b>>x;
    if(a>x||a+b<x)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;

    return 0;
}





Measured memory_bytes: 3564
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int N = in.nextInt();
        ArrayList <Integer> cards = new ArrayList<>();


        for (int i =0; i < N; i++)
        {
            cards.add(in.nextInt());
        }

        Collections.sort(cards,Collections.reverseOrder());

        int Maxscore = 0;

        for (int i =0; i < cards.size(); i ++)
        {
            if (i%2==0)
            {
                Maxscore += cards.get(i);
            }
            else
                {
                    Maxscore -= cards.get(i);
                }
        }
        System.out.println(Maxscore);
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

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

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

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

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

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


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


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

    ll cnt = 0;
    ll k = K;
    int n = N;
    while (1) {
        n = n / k;
        if (n != 0) {
            cnt++;
        } else {
            break;
        }
    }

    cout << cnt + 1 << endl;

}


Measured memory_bytes: 3612
n = int(input())
A = list(map(int, input().split()))

multi_4 = 0
multi_2 = 0
odd = 0
for a in A:
    if a % 4 == 0:
        multi_4 += 1
    elif a % 2 == 0:
        multi_2 += 1
    else:
        odd += 1

if multi_2 > 0:
    if odd > multi_4:
        print('No')
    else:
        print('Yes')
else:
    if odd > multi_4 + 1:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 20056
#include<bits/stdc++.h>
#define int long long
using namespace std ;
int read() {
  int x = 0 , f = 1 ;
  char c = getchar() ;
  while(c < 48 || c > 57) {
    if(c == '-') f = -1 ;
    c = getchar() ;
  }
  while(c > 47 && c < 58) {
    x = (x << 1) + (x << 3) + (c & 15) ;
    c = getchar() ;
  }
  return x * f ;
}
void print(int x) {
  if(x < 0) x = -x , putchar('-') ;
  if(! x) { putchar('0') ; }
  static char st[30] ; int stp = 0 ;
  while(x) { st[++ stp] = x % 10 ^ 48 ; x /= 10 ;}
  while(stp) { putchar(st[stp --]) ; }
  putchar('\n') ;
}
int n ;
const int N = 200 + 10 ;
struct Node {
  int x , y ;
} b[N][N] ;
int a[N] ;
int ans = 0 , pd[N] ;
int c() {
  for(int i = 1 ; i <= n ; i ++) {
    if(! pd[i]) continue ;
    for(int j = 1 ; j<= a[i] ; j ++) {
      if(pd[b[i][j].x] != b[i][j].y)
      return 0 ;
    }
  }
  return 1 ;
}
void dfs(int x , int y) {
  if(x == n + 1) {
    if(y > ans && c()) ans = y ;
    return ;
  }
  pd[x] = 0 ;
  dfs(x + 1 , y) ;
  pd[x] = 1 ;
  dfs(x + 1 , y + 1) ;
  
}
signed main() {
  n = read() ;
  for(int i = 1 ; i <= n ; i ++) {
    a[i] = read() ;
    for(int j = 1 ; j <= a[i] ; j ++) {
      b[i][j].x = read() ; b[i][j].y = read() ;
    }

  }
  dfs(1 , 0) ;
  cout << ans << '\n' ;
  return 0 ;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from itertools import chain

MAX = 10 ** 18


def solve(N: int, A: "List[int]"):
    A = sorted(A)
    answer = 1
    for a in A:
        answer *= a
        if answer > MAX:
            return -1
    return answer


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # N, A = map(int, line.split())
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    answer = solve(N, A)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 22852
#include <bits/stdc++.h>
#define fir first
#define sec second
#define mp std::make_pair
#define Pair std::pair<int, std::string>

typedef long long ll;

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

std::map< Pair, int > map;
std::vector<int> g[N];

int n;
char s[N];
int f[N][20];

int main() {
    scanf("%s", s + 1);
    n = strlen(s + 1);
    f[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        if (s[i] == '?') {
            for (int digit = 0; digit < 10; digit++) {
                for (int j = 0; j < 13; j++) {
                    (f[i][(j * 10 + digit) % 13] += f[i - 1][j]) %= MOD;
                }
            }
        } else {
            int digit = s[i] - '0';
            for (int j = 0; j < 13; j++) {
                (f[i][(j * 10 + digit) % 13] += f[i - 1][j]) %= MOD;
            }
        }
    }
    printf("%d\n", f[n][5]);
    return 0;
}

Measured memory_bytes: 10496
#include<stdio.h>
int main()
{int m,n,max,a,b,c;
  while(scanf("%d %d",&m,&n)!=EOF)
  { a=m+n;
    max=a;
    b=m-n;
    c=m*n;
    if(b>max)
    max=b;
    if(c>max)
    max=c;
    printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
  using namespace std;
   
  #define ll long long
  #define pb push_back
  #define mp make_pair
  #define ff first
  #define ss second


   
void func(){

ll a[3];
cin>>a[0]>>a[1]>>a[2];
cout<<a[2]<<" "<<a[0]<<" "<<a[1]<<endl;


}
   
   
  int main(){
          ios_base::sync_with_stdio(false);
          cin.tie(0);
          cout.tie(0);
   
       /* #ifndef ONLINE_JUDGE
        freopen("input.txt", "r" , stdin);
        freopen("output.txt", "w" , stdout);
        #endif*/
   
     ll t=1;
     //cin>>t;
     while(t--)
     func();
   }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define md 1000000007
#define inf 1e18
#define rep(i,a,b) for(int i=a;i<b;++i)
using namespace std;
#define M 1000010


int32_t main(){
	
	
	string s;cin>>s;
	int sum=0;
	rep(i,0,s.size())sum+=(s[i]-'0');
	cout<<(sum%9==0?"Yes":"No");
	
	
	
	
    return 0;
}

Measured memory_bytes: 3740
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
P ans[100];
bool solve(LL a[50], int N, bool rev) {
	memset(ans, 0, sizeof(ans));
	LL Max = a[0];
	int pos = 0;
	for (int i = 1; i < N; i++) {
		if (Max < a[i]) {
			Max = a[i];
			pos = i;
		}
	}
	if (Max < 0) return 0;
	int cnt = 0;
	for (int i = 0; i + 1 < N; i++) {
		while (a[i] > a[i + 1]) {
			if (cnt >= 2 * N) return 0;
			ans[cnt].first = pos;
			ans[cnt].second = i + 1;
			cnt++;
			a[i + 1] += Max;
			if (Max < a[i + 1]) {
				Max = a[i + 1];
				pos = i + 1;
			}
		}
	}
	cout << cnt << endl;
	for (int i = 0; i < cnt; i++) {
		if (rev) cout << (N - ans[i].first) << " " << (N - ans[i].second) << endl;
		else cout << (ans[i].first + 1) << " " << (ans[i].second + 1) << endl;
	}
	return 1;
}
int main() {
	int N;
	cin >> N;
	LL a[50], b[50];
	for (int i = 0; i < N; i++) cin >> a[i];
	for (int i = 0; i < N; i++) b[i] = -a[N - 1 - i];
	if (solve(a, N, 0)) return 0;
	solve(b, N, 1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define rep(i,n,z) for(int i=z;i<n;i++)
#define rrep(i,z) for(int i=z;i>=0;i--)
#define nl cout<<endl
#define vi vector<int>
#define vlli vector<long long int>
#define umap unordered_map
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ipair pair <int,int>
#define llipair pair <lli,lli>
#define pq priority_queue
#define displaymatrix(a,m,n) for(int i=0;i<m;i++){for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vlli a(n);rep(i,n,0)cin>>a[i]
#define ainput(a,n) rep(i,n,0)cin>>a[i]
#define SO(a) sort(a.begin(),a.end())
#define all(x) (x).begin(),(x).end()
#define SOP(a,comp) sort(a.begin(),a.end(),comp)
#define inf INT_MAX
#define endl '\n'
 
int main()
{
    fastio;
    lli n,m,x;
    cin>>n>>m>>x;

    vlli cost(n);

    lli val[n][m];

    rep(i,n,0){
        cin>>cost[i];

        rep(j,m,0)cin>>val[i][j];
    }

    lli ans = LLONG_MAX/2;

    for(int i = 0;i < (1LL << n);i ++){
        vlli tot(m,0);
        lli cur = 0;


        for(int j = 0;j < n;j++){
            if((i&(1<<j) )== 0)continue;

            cur += cost[j];

            for(int k = 0;k < m;k++){
                tot[k] += val[j][k];
            }
        }

        int f = 1;

        rep(j,m,0)f &= (tot[j] >= x);

        // cout<<i<<" "<<cur<<endl;

        if(f)ans=min(ans,cur);
    }
    if(ans == LLONG_MAX/2)cout<<-1<<endl;
    else cout<<ans<<endl;
}


Measured memory_bytes: 3640
import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

bool test (int a, int b, int c, int d) {
  while (true) {
    //health, strength
    c -= b;
    if (c <= 0) return true;
    a -= d;
    if (a <= 0) return false;
  }
}

void main() {
  int a, b, c, d;
  readf (" %d %d %d %d", a, b, c, d);
  writeln (test (a, b, c, d) ? "Yes" : "No");
}



Measured memory_bytes: 3080