akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
	
	
	int a[5];
	int b[5];
	int i,min,min_i,sum;
	
	for(i=0;i<5;i++){
		cin >> a[i]; 
	}
	
	for(i=0;i<5;i++){
		b[i]=a[i]%10;
	}	
	
	min=10;
	for(i=0;i<5;i++){
		if(b[i]<min&&b[i]!=0){
			min=b[i];
			min_i=i;
		}
	}
	
	for(i=0;i<5;i++){
		if(i==min_i){
			sum+=a[i];
		}
		else{
			while(a[i]%10!=0){
				a[i]++;
			}
		sum+=a[i];
		}
		
	}
	
	cout << sum << endl;
	
return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long ans,n,k,a[2010],tmp[2010],tmp1[2010];
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
	{
		for(int o=0;o<n;o++)
		{
			if(a[i]>a[o] && i<o)
			{
				tmp[i]+=((k*(k+1))/2)%1000000007;
				tmp[i]%=1000000007;
			}	
			else if(a[i]>a[o] && i>o)
			{
				tmp[i]+=((k*(k-1))/2)%1000000007;
				tmp[i]%=1000000007;
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		ans+=tmp[i];
		ans%=1000000007;
	}
	cout<<ans<<endl;		
} 

Measured memory_bytes: 256
#define FOR(i, a, b) for(int i=a; i<b; i++)
#include<cstdio>
#include<algorithm>
#include<utility>
#include<string>
#include<cstdlib>

int main(){
    int s, w;

    scanf("%d %d", &s, &w);

    if(s > w){
        printf("safe\n");
    }else{
        printf("unsafe\n");
    }
    return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}


int main() {
    int x;
    cin >> x;
    if(x == 0) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}


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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while( cur != nil && cur->key != key ){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void delete(int key){
  NodePointer t = listSearch(key);
  if ( t == nil ) return;
  deleteNode(t);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if(!( 0 <= key && key <= 2000000000)){printf("error") ;}
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
    if ( size > 1000000 ) { printf("error"); }
  }

  
  if(!( np+nd <= 2000000)){printf("error") ;}
  if(!( nd <= 20)){printf("error") ;}
  printList();


  return 0;
}

Measured memory_bytes: 31788
N,k,*A = $<.read.split.map{ _1.to_i-1 }
A.pop A.size-N-1
C = [c=0]
R = [i=0]
R << i and C[i] = c+=1  until o=C[i=A[i]]
o = 0  if k < c
R.shift o
p R[(k-o+1)%R.size] + 1

Measured memory_bytes: 32048
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let M: usize = sc.get();
    let H: Vec<usize> = sc.vec(N);
    let mut adj = vec![Vec::new(); N];
    for _ in 0..M {
        let A: usize = sc.get::<usize>()-1;
        let B: usize = sc.get::<usize>()-1;
        adj[A].push(B);
        adj[B].push(A);
    }
    let mut ans = 0usize;
    let mut visited = vec![false; N];
    for i in 0..N {
        if visited[i] {
            continue;
        }
        let mut ok = true;
        for &n in &adj[i] {
            if H[i] <= H[n] {
                ok = false;
            }
        }
        if ok {
            for &n in &adj[i] {
                visited[n] = true;
            }
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

public class Main {

	private static Scanner in;
	private static int n;
	private static int W;
	private static int[] w;
	private static int[] v;
	private static long[][] dp;
	
	public static void main(String[] args) {
		in = new Scanner(System.in);
		n = in.nextInt();
		W = in.nextInt();
		w = new int[n];
		v = new int[n];
		
		for(int i=0; i<n; i++) {
			w[i] = in.nextInt();
			v[i] = in.nextInt();
		}
		dp = new long[n+1][W+1];
		
		for(int i=0; i<dp.length; i++) {
			Arrays.fill(dp[i], -1);
		}
		System.out.println(solve(0, W));

	}
	
	private static long solve(int i, int wLeft) {
//		System.out.println(i+" "+f);
		if (wLeft<0) return -(long)1e15;
		if (i==n) return 0;
		
		if (dp[i][wLeft]!=-1) return dp[i][wLeft];
		
		long ans = 0;
		
		ans = Math.max(ans, solve(i+1, wLeft-w[i])+v[i]);
		ans = Math.max(ans, solve(i+1, wLeft));
		
		return dp[i][wLeft]=ans;
	}

}


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

const int N_MAX = 100;
int N;
int x[N_MAX];
int y[N_MAX];
long double pr[N_MAX];
bool used[N_MAX];

int main(void)
{
    cin >> N;
    REP(i, N) cin >> x[i] >> y[i];
    if (N == 2) {
        printf("0.5\n0.5\n");
        return 0;
    }
    int m = INT_MAX;
    int A;
    REP(i, N) {
        if (m > x[i]) {
            m = x[i];
            A = i;
        }
    }


    PRINT(A);
    while (true) {

    long double cos_phi_min = 100;
    int B0, C0;
    REP(B, N) {
        REP(C, N) {
            long double a2 = pow(x[C] - x[B], 2) + pow(y[C] - y[B], 2);
            long double c2 = pow(x[A] - x[B], 2) + pow(y[A] - y[B], 2);
            long double b2 = pow(x[A] - x[C], 2) + pow(y[A] - y[C], 2);
            long double c = sqrt(c2);
            long double b = sqrt(b2);
            long double cos_phi = (b2 + c2 - a2) / (2 * b * c);
            if (cos_phi < -1L) {
                cos_phi = -1L;
            }
            if (cos_phi_min > cos_phi) {
                cos_phi_min = cos_phi;
                B0 = B;
                C0 = C;
            }
        }
    }
    PRINT(A);
    PRINT(B0);
    PRINT(C0);
    long double phi = acos(cos_phi_min);
    pr[A] = (M_PI - phi) / (2 * M_PI);
    used[A] = true;
    if (used[B0]) {
        if (used[C0]) {
            break;
        } else {
            A = C0;
        }
    } else {
        A = B0;
    }
    
    }

    REP(i, N) {
        printf("%.20Lf\n", pr[i]);
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;

#define fs first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,ll> P2;

int n,h[16],w[16],ty,tx;
string s[4];
map<ll,bool> memo;
ll ans,tmp;
vector<ll> st;

inline int color(ll a,ll b){
  bool v[3];
  for(int k=0;k<3;k++)v[k] = false;
  for(int k=0;k<16;k++){
    if( ((a>>(2*k))&3LL) && ((b>>(2*k))&3LL)){
      v[((b>>(2*k))&3LL)-1] = true;
    }
  }
  int cnt = 0;
  for(int k=0;k<3;k++)if(v[k])cnt++;
  return cnt;
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++)cin >> h[i] >> w[i];
  for(int i=0;i<4;i++)cin >> s[i];

  ans = 0;
  for(int i=0;i<4;i++)
    for(int j=0;j<4;j++){
      if(s[i][j] == 'R')ans += 1LL<<(2*(i*4+j));
      if(s[i][j] == 'G')ans += 2LL<<(2*(i*4+j));
      if(s[i][j] == 'B')ans += 3LL<<(2*(i*4+j));
    }

  for(int i=0;i<n;i++){
    for(int j=-h[i]+1;j<4;j++){
      for(int k=-w[i]+1;k<4;k++){
	tmp = 0;
	for(int y=0;y<h[i];y++){
	  for(int x=0;x<w[i];x++){
	    ty = y+j; tx = x+k;
	    if(ty<0 || tx<0 || 4<=ty || 4<=tx)continue;
	    tmp |= 1LL<<(2*(ty*4+tx));
	  }
	}
	st.push_back(tmp);
      }
    }
  }
  sort(st.begin(),st.end());
  st.erase(unique(st.begin(),st.end()),st.end());

  memo.clear();memo[0] = true;
  priority_queue<P2,vector<P2>,greater<P2> > q;
  q.push(P2(P(3,0),ans));

  while(q.size()){
    P2 p = q.top(); q.pop();
    
    for(int i=0;i<st.size();i++){
      tmp = p.sc;
      if(color(st[i],tmp) == 1){
	tmp &= -1LL^(3LL*st[i]);
	if(tmp==0){
	  cout << p.fs.sc + 1 << endl;
	  return 0;
	}
	if(memo.find(tmp)==memo.end()){
	  memo[tmp] = true;	  
	  q.push(P2(P(p.fs.sc+color((1LL<<32)-1,tmp)+1,p.fs.sc+1),tmp));
	}
      }
    }
  }
}

Measured memory_bytes: 5424
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	if(n==1){
		cout << 1 << endl;
		return 0;
	}
	n--;
	int ans=0;
	while(n){
		ans++;
		n/=3;
	}
	cout << ans << endl;
}


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

vector<long> ans;

void dfs(long n, int d) {
  if (d == 11) {
    return;
  }
  int mi = max(0L, n % 10 - 1);
  int mx = min(9L, n % 10 + 1);
  for (int i = mi; i <= mx; i++) {
    ans.push_back(n * 10 + i);
    dfs(n * 10 + i, d + 1);
  }
}

int main() {
  int K;
  cin >> K;
  for (int i = 1; i <= 9; i++) {
    ans.push_back(i);
    dfs(i, 1);
  }
  sort(ans.begin(), ans.end());
  cout << ans.at(--K) << "\n";
}

Measured memory_bytes: 10604
import sys
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))


for z in range(X+1, Y+1): # X < z <= Y
    if max(x) < z and min(y) >= z:
        print("No War")
        sys.exit()
print("War")
        

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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

ll od(ll x) {
	if (x % 2 != 0) { return 0; }
	return od(x / 2) + 1;
}

int main() {
	ll N;
	ll D[2];
	cin >> N >> D[0] >> D[1];

	vector<vector<ll>> c(2*N, vector<ll>(2*N,0));

	rep(k, 2) {
		
		ll d = od(D[k]);
		ll h = 1 << (d / 2);
		

		rep(i, 2 * N)rep(j, 2 * N) {
			if (d % 2 == 0 && (i / h + j / h) % 2 == 1) { c[i][j] += 1 << k; }
			if (d % 2 == 1 && (i / h) % 2 == 1) { c[i][j] += 1 << k; }
		}
	}

	ll count[4] = {};
	rep(i, 2*N)rep(j, 2*N) count[c[i][j]]++;

	ll K = 0;
	repn(i, 3) if (count[i] > count[K]) { i = K; }

	ll t = 0;
	rep(i, 2 * N) {
		rep(j, 2 * N) {
			if (c[i][j] == K) {
				cout << i << " " << j << endl;
				t++;
				if (t == N * N) { break; }
			}
		}
		if (t == N * N) { break; }
	}

}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
int main(){
    int N;
    cin >> N;
    vector<int> a(N+2);
    FORq(i,1,N){
        cin >> a[i];
    }

    int ans = 0;
    FORq(i,1,N){
        if (a[a[i]] == i) ans++;
    }

    cout << ans/2 << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int n,k,q,Cnt;
LL Sum;
LL A[505],C[505];
LL Pre[505],Erp[505];
LL B[5005];
bool Check(LL x) {
	LL tmp=Sum/x;
	for(int i=1; i<=n; ++i)
		C[i]=A[i]%x;
	sort(C+1,C+1+n);
	for(int i=1; i<=n; ++i)
		Pre[i]=Pre[i-1]+C[i];
	for(int i=n; i>=1; --i)
		Erp[i]=Erp[i+1]+(x-C[i]);
	for(int i=0; i<=n; ++i)
		if(Pre[i]==Erp[i+1])return Pre[i]<=k;
	return false;
}
int main() {
	scanf("%d%d",&n,&k);
	for(int i=1; i<=n; ++i)
		scanf("%d",A+i),Sum+=A[i];
	sort(A+1,A+1+n);
	for(int i=1; 1LL*i*i<=Sum; ++i)
		if(Sum%i==0)B[++Cnt]=i,B[++Cnt]=Sum/i;
	sort(B+1,B+1+Cnt,greater<int>());
	for(int i=1; i<=Cnt; ++i)
		if(Check(B[i]))return !printf("%lld",B[i]);
}

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

int main() {
    string s, t;
    cin >> s >> t;
    string ans = "{";
    if (s.size() < t.size()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    for (int i = 0; i <= s.size() - t.size(); i++) {
        string tmp(s.size(), '?');
        for (int j = 0; j < i; j++)
            tmp[j] = (s[j] == '?') ? 'a' : s[j];

        bool flag = true;
        for (int j = 0; j < t.size(); j++) {
            if (s[i + j] == '?' || s[i + j] == t[j])
                tmp[i + j] = t[j];
            else {
                flag = false;
                break;
            }
        }
        if (!flag)
            continue;
        for (int j = i + t.size(); j < s.size(); j++) {
            tmp[j] = (s[j] == '?') ? 'a' : s[j];
        }

        if (ans > tmp) ans = tmp;
    }
    cout << ((ans == "{") ? "UNRESTORABLE" : ans) << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
 
//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if(a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if(a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end


 
int main(){
  int a,b; scanf("%d%d",&a,&b);
  printf("%d\n",max({a+b,a-b,a*b}));
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int constexpr N = 505;
int g[N][N];

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, m;
  cin >> n >> m;
  for(int i = 1; i <= n; ++i) {
    for(int j = 1; j <= m; ++j) {
      cin >> g[i][j];
    }
  }

  vector<pair<pair<int, int>, pair<int, int>>> ans;
  for(int i = 1; i <= n; ++i) {
    for(int j = 1; j < m; ++j) {
      if(g[i][j] % 2 == 0) continue;
      g[i][j + 1]++;
      ans.push_back({{i, j}, {i, j + 1}});
    }
  }

  for(int i = 1; i < n; ++i) {
    if(g[i][m] % 2 == 0) continue;
    g[i + 1][m]++;
    ans.push_back({{i, m}, {i + 1, m}});
  }
  cout << ans.size() << '\n';
  for(auto & e : ans) {
    cout << e.fi.fi << ' ' << e.fi.se << ' ' << e.se.fi << ' ' << e.se.se << '\n';
  }
}


Measured memory_bytes: 5232
#include <stdio.h>
#include<math.h>
#include <string.h>
#include <ctype.h>

int main(){
char moji[102];
int i,n,t,f;

f=0;
while(scanf("%s",moji)!=EOF){
t=0;
n=strlen(moji);
for(i=0;i<n/2;i++){
if(moji[i]!=moji[n-1-i]){
t=1;
break;
}
}
if(t==0){
f++;
}
}
printf("%d\n",f);
return 0;
}

Measured memory_bytes: 968
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	string s;
	cin >> s;
	s[5] = s[13] = ' ';
	cout << s << endl;
}



Measured memory_bytes: 256
using System;
    using System.Linq;

    class Program
    {
        static void Main(string[] args)
        {
            //input
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            decimal m = int.Parse(input[1]);
            string[] input2 = Console.ReadLine().Split(' ');
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(input2[i]);
            }

            decimal touhyouSuu = a.Sum(x => x);
            var ninkiTouhyouSuu = (decimal)(touhyouSuu / (4 * m));

            Array.Sort(a);
            Array.Reverse(a);

            for (int i = 0; i < m; i++)
            {
                if (a[i] < ninkiTouhyouSuu)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    }

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

using namespace std;
typedef long long ll;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	ll n,m,r,p;
  cin >> n >> m;
  vector<ll> a(n,0);
  vector<ll> b(n,0);
//  vector <pair<ll, string> > v;
  for (int i=0; i<m; i++){
    ll temp;
    string c;
    cin>>temp>>c;
    if (a[temp-1]>=1) continue;
    else if (c=="AC"){
      a[temp-1]+=1;
    }
    else if (c=="WA"){
      b[temp-1]+=1;
    }
  }
  r=0;p=0;
  for (int i=0; i<n; i++){
    if (a[i]==1){
      r+=1;
      p+=b[i];
    }
  }


  cout<<r<<' '<<p<<endl;
}


Measured memory_bytes: 1792
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter};
use std::io::*;
use std::ops::*;
use std::*;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        {
            let entries = [$(&stringify!([$arg]:), &$arg as &Debug),*];
            stderr().write_fmt(format_args!("{:#?}\n", entries)).unwrap();
        }
    };
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn main() {
    let N = read!(usize);
    let mut A = read!(i64; N);

    let mut l = 0;
    let mut k = 0;
    while l < N {
        if A[l] % 2 == 0 {
            k += A[l] / 2;
            l += 1;
        } else {
            let mut r = l + 1;
            while r < N && A[r] != 0 && A[r] % 2 == 0 {
                r += 1;
            }

            if r == N || A[r] == 0 {
                A[l] -= 1;
            } else {
                A[l] -= 1;
                A[r] -= 1;
                k += 1;
            }
        }
    }

    println!("{}", k);
    return;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
#define YES "YES"
#define NO "NO"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int A,B,C;
int main(){
    cin >>A>>B>>C;
    if(A*B*C==5*7*5) pr("YES");
    else pr("NO");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll n;
int main(){
	scanf("%lld",&n);
	printf("%lld",n*(n+1)/2);
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


ll weight[12], lower[12], upper[12];
void init()
{
	weight[0] = 0;
	weight[1] = 1;
	for (int i = 2; i < 12; ++i)
		weight[i] = -10 * weight[i-1];
	lower[0] = upper[0] = 0;
	for (int i = 1; i < 12; ++i)
	{
		lower[i] = lower[i-1];
		upper[i] = upper[i-1];
		if (weight[i] > 0)
			upper[i] += 9 * weight[i];
		else
			lower[i] += 9 * weight[i];
	}
}
int find(ll n, int place)
{
	for (int i = 0; i < 10; ++i)
		if (i*weight[place]+lower[place-1] <= n
			&& n <= i*weight[place]+upper[place-1])
			return i;
	puts("unko");
	exit(1);
}
int main()
{
	init();

	int n;
	while (scanf("%d", &n), n)
	{
		int res = 0;
		for (int i = 11; i >= 1; --i)
		{
			int d = find(n, i);
			res = res*10 + d;
			n -= d * weight[i];
		}
		printf("%d\n", res);
	}

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void){
    int num[10010]={0};
    int i,max=0;
    while(1){
        scanf("%d",&num[max]);
        if(num[max])
            max++;
        else
            break;
    }
    for(i=0;i<max;i++){
        printf("Case %d: %d\n",i+1,num[i]);
    }
    return 0;
}

Measured memory_bytes: 648
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: i32,
        x: [i32; n],
    }
    if let Some(v) = (1..101).map(|i| x.iter().fold(0, |sum, j| sum + (i - j).pow(2))).min() {
        println!("{}", v);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int n,k;
  cin >> n>>k;
  vector<int> p(n);
  rep(i,n){
    cin >> p[i];
  }
  double ans=0;
  double ans1=0;
  rep(j,k){
    double temp=0;
    rep(l,p[j]){
      temp += l+1;
    }
    ans1 +=temp/p[j];
  }
  if(ans<ans1){ans=ans1;}
  int i=k;
  do{
    double temp1=0;
    double temp2=0;
    rep(j,p[i]){
      temp1 += j+1;
    }
    rep(j,p[i-k]){
      temp2 += j+1;
    }
    ans1 +=temp1/p[i];
    ans1 -=temp2/p[i-k];
    i++;if(ans<ans1){ans=ans1;}
  }while(i<n);

  printf("%.10f\n",ans);
  return 0;
}

Measured memory_bytes: 1024
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <queue>

template<typename T>
class TBinaryHeap
{
    std::vector<T> FArray;
public:
    TBinaryHeap()
    {
        FArray.reserve(2000000);
        FArray.resize(1); // dummy
    }
    void push(const T& Value)
    {
        std::size_t Index = FArray.size();
        FArray.push_back(Value);
        while(Index > 1){
            std::size_t Parent = Index / 2;
            if(FArray[Index] < FArray[Parent]) return;
            std::swap(FArray[Index], FArray[Parent]);
            Index = Parent;
        }
    }
    void pop()
    {
        assert(FArray.size() >= 1);
        FArray[1] = FArray.back();
        FArray.pop_back();

        std::size_t Size = FArray.size();
        std::size_t Index = 1;
        while(Index < Size){
            std::size_t Left = Index * 2;
            std::size_t Right = Left + 1;
            if(Left >= Size) break;
            std::size_t Target = Right >= Size ? Left : FArray[Left] > FArray[Right] ? Left : Right;
            if(FArray[Target] <= FArray[Index]) break;
            std::swap(FArray[Index], FArray[Target]);
            Index = Target;
        }
    }
    const T& top()
    {
        return FArray[1];
    }
};
int main()
{
    char Line[19];
    int Value;

    // std::priority_queue<int> S;
    TBinaryHeap<int> S;
    while(1){
        std::fgets(Line, 19, stdin);
        if(Line[0] == 'i'){
            S.push(std::atoi(&Line[7]));
        }else
        if(Line[1] == 'x'){
            std::printf("%d\n", S.top());
            S.pop();
        }else{
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 6316
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,g[3][3],a[3][3],b[3][3],c[3][3],p=1e9+7,aa[500001];
void fz(){
	ll i,j;
	for(i=0;i<=2;i++)
	 for(j=0;j<3;j++)g[i][j]=a[i][j];
}
void get(){
	ll i,j,k;
	for(i=0;i<3;i++)
	 for(j=0;j<3;j++){
	 	c[i][j]=0;
	 	for(k=0;k<3;k++)c[i][j]=c[i][j]+b[i][k]*g[k][j];
	 }
	for(i=0;i<3;i++)
	 for(j=0;j<3;j++)b[i][j]=c[i][j]%p;
}
void ch(){
	ll i,j,k;
	for(i=0;i<3;i++)
	 for(j=0;j<3;j++){
	 	c[i][j]=0;
	 	for(k=0;k<3;k++)c[i][j]=c[i][j]+g[i][k]*g[k][j];
	 }
	for(i=0;i<3;i++)
	 for(j=0;j<3;j++)g[i][j]=c[i][j]%p;
}
void solve(ll x){
	fz();
	while(x){
		if(x&1)get();
		ch();
		x/=2;
	}
}
int main(){
	ll i,j;
	scanf("%lld%lld",&n,&m);
	for(i=1;i<=m;i++)scanf("%lld",&aa[i]);
	a[0][0]=1;a[0][1]=2;a[0][2]=1;
	a[1][1]=1;a[1][2]=1;
	a[2][2]=2;a[2][0]=1;a[2][1]=2;
	sort(aa+1,aa+m+1);
	b[0][0]=b[1][1]=b[2][2]=1;
	for(i=1;i<=m;i++){
		solve(aa[i]-aa[i-1]-1);
		fz();
		g[2][0]=0;g[2][1]=0;g[2][2]=1;
		get();
	}
	solve(n-aa[m]-1);
	printf("%lld",(b[0][2]+b[1][2]*2+b[2][2])%p);
}
/*
暴力拆dp式子貌似也行。。
然而有更巧妙的方法 
*/

Measured memory_bytes: 1152
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int INF = 1e10 + 5;

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n, m, k;
        cin >> n >> m >> k;
        string s[n];
        for (auto && x : s)
            cin >> x;

        int ans = INF;
        int N = (1 << (n - 1));
        for (int mask = 0; mask < N; mask++) {
            int cnt = __builtin_popcount(mask);
            int curr = cnt;
            int cuts = cnt + 1;

            vector<int> white(cuts, 0);
            vector<int> ri(n);
            int idx = 0;
            for (int i = 0; i < n; i++) {
                ri[i] = idx;
                if(mask & (1LL << i)) 
                    idx++;
            }

            for (int i = 0; i < m; i++) {
                vector<int> gg(cuts, 0);
                for (int j = 0; j < n; j++) {
                    gg[ri[j]] += (s[j][i] == '1');
                }
     
                bool bad = false;
                bool ok = true;
                for (int j = 0; j < cuts; j++) {
                    if (gg[j] > k) {
                        bad = true;
                        break;
                    }
                    if (white[j] + gg[j] > k) {
                        ok = false;
                        break;
                    }
                }
     
                if (bad) {
                    curr = INF;
                    break;
                }
     
                if (!ok) {
                    curr++;
                    white = gg;
                } else {
                    for (int j = 0; j < cuts; j++)
                        white[j] += gg[j];
                }
            }
     
            ans = min(ans, curr);
        }

        cout << ans << '\n';
    }
    
    return 0;
}



Measured memory_bytes: 3652
n, m = map(int, input().split())
p = [int(i) for i in input().split()]
graph = [[] for _ in range(n+1)]
group = [0]*(n+1)
ans = 0
for _ in range(m):
    x, y = map(int, input().split())
    graph[x].append(y)
    graph[y].append(x)
for i, num in enumerate(p,1):
    space = [i]
    for point in space:
        if group[point]:
            continue
        group[point] = i
        space.extend(graph[point])
    ans += group[num] == group[i]
print(ans)

Measured memory_bytes: 28900
n, m, l = map(int, input().split())

# n * m
A = []
for _ in range(n):
    A.append([int(_) for _ in input().split()])

# m * l
B = []
for _ in range(m):
    B.append([int(_) for _ in input().split()])


# n * l
C = [[0 for _ in range(l)] for _ in range(n)]

for col in range(n):
    for row in range(l):
        for i in range(m):
            C[col][row] += A[col][i] * B[i][row]

for C_row in C:
    for i, num_row in enumerate(C_row):
        if i != len(C_row) - 1:
            print(num_row, end=" ")
        else:
            print(num_row, end="")
    print()

        

"""
A = 
[[1, 2], [0, 3], [4, 5]]
 
B = 
[[1, 2, 1],
 [0, 3, 2]]

C = ?
"""



Measured memory_bytes: 7060
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

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

    string s; cin >> s;
    int n = s.size();
    int ans1 = n, ans2 = n;
    rep(i,n) if(s[i] == '1') ans1 = min(ans1,max(i,n-i-1));
    rep(i,n) if(s[i] == '0') ans2 = min(ans2,max(i,n-i-1));
    cout << max(ans1,ans2) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf=1e9+7;
int a[2];
int main()
{
    //freopen("input.txt","r",stdin);
    ios::sync_with_stdio(false);
    string s;cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='p')a[1]++;
        else a[0]++;
    }
    cout<<floor((a[0]-a[1])/2);
    return 0;
}


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

int main() {
	long long int n, x, s, t, tt;
	cin >> n >> x;
	s = n;
	if (n < 2 * x) {
		x = n - x;
	}
	t = n - x;
	while (t >= x && x > 0) {
		s += 2 * (t / x) * x;
		tt = t % x;
		t = x;
		x = tt;
	}
	cout << s - t << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define eachdo(e,array) for(const auto& e : array)
#define lower_index(v,a) (int)distance(v.begin(), lower_bound((v).begin(),(v).end(),a))
template<class T> bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
typedef long long ll;
const ll INF=1e18;
const ll MOD=1e9+7;

int main(){
    ll N;cin>>N;
    vector<ll> a(N);rep(i,N) cin>>a[i];
    sort(a.begin(),a.end());
    ll res=0;
    for(ll i=0;i<N-2;++i)for(ll j=i+1;j<N-1;++j){
        ll loc=lower_index(a,a[i]+a[j]);
        res+=loc-j-1;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){

    int N, H, W;
    cin >> N >> H >> W;

    int count = 0;
    int A, B;
    for (int i=0; i < N; i++) {
        cin >> A >> B;
        if (A >= H && B >= W) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
/*********************************************
* 20.05.19 AtCoder Beginner Contest 153
* 
* 
*********************************************/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int (i)=1;(i)<=(n);i++)
#define rez(i,n) for(int (i)=0;(i)<(n);i++)
#define et "\n"

class CRun{
private:
    void IO_faster();
public:
    char problem_num;
    
    CRun(){
        problem_num = 'D';
    }; 
    ~CRun(){};
    void build();
    void solve_A(); void solve_B(); void solve_C(); 
    void solve_D(); void solve_E(); void solve_F();
};

void CRun::IO_faster(){
    ios::sync_with_stdio(0); cin.tie(NULL);
}

/*********************************************
A - Serval vs Monster
敵の体力H
味方の攻撃1回で体力をA減らせる
勝つための攻撃回数は？
*********************************************/
void CRun::solve_A(){
    int H; cin >> H;
    int A; cin >> A;
    
    int ans = 0;
    //ans += (H % A > 0 ? H / A + 1 : H / A);
    ans += (H - 1) / A + 1;
    cout << ans;
}

/*********************************************
B - Common Raccoon vs Monster
モンスターの体力H
N種類の攻撃で敵のHPをAN減らせる
同じ攻撃を使わずに敵を倒せるか？
*********************************************/
void CRun::solve_B(){
    
    int H; cin >> H;
    int N; cin >> N;
    int A[N]; rez(i,N) cin >> A[i];
    
    int sum = 0;
    for (auto &ix : A) sum += ix;
    
    string ans[] = {"Yes", "No"};
    if (sum >= H) {
        cout << ans[0];
    }
    else {
        cout << ans[1];
    }
    
}

/*********************************************
C - Fennec vs Monster
N개체의 적, H_N 만큼의 체력
공격 : 적을 1개체 골라서 체력을 1만큼 줄임
필살 : 적을 1개체 골라서 체력을 0으로 만듦
K회만큼 필살기를 쓸 수 있을 때, 승리하는 공격의 최소횟수는?
*********************************************/
void CRun::solve_C(){
    this->IO_faster();
    int enemy_num; cin >> enemy_num;
    int ultimate_cnt; cin >> ultimate_cnt;
    int enemy_hp[enemy_num]; rez(i,enemy_num) cin >> enemy_hp[i];
    
    ll ans = 0;
    sort(enemy_hp, enemy_hp + enemy_num, greater<int>());
    for (int ix = ultimate_cnt; ix < enemy_num; ix++) {
        ans += enemy_hp[ix];
    }
    cout << ans;
}

/*********************************************
D - Caracal vs Monster
적의 체력 H
적을 1개체 선택해서 공격가능. 
- 몬스터의 체력이 1이라면, 그 몬스터의 체력은 0이 된다
- 몬스터의 체력이 1보다 크면, 소멸하고 체력이 X/2인 몬스터가 2체 생성
승리하기 위한 최소 공격횟수?
*********************************************/
void CRun::solve_D(){
    ll H; cin >> H;
    int power = 0;
    while (H > 0) {
        H>>=1;
        power += 1;
    }
    
    long ans = 0;
    while (power-- > -1) {
        ans += pow(2,power);
    }
    
    cout << ans << et;
}

/*********************************************

*********************************************/
void CRun::solve_E(){
    
}

/*********************************************

*********************************************/
void CRun::solve_F(){
    
}

int main(){
    CRun run;
    switch (run.problem_num) {
        case 'A' : run.solve_A();
        case 'B' : run.solve_B();
        case 'C' : run.solve_C();
        case 'D' : run.solve_E();
        case 'E' : run.solve_D();
        case 'F' : run.solve_F();
    }
}



Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
$a = explode(' ', trim(fgets(STDIN)));
$x = $y = $z = 0;
foreach ($a as $b) {
	if ($b % 2) {
		$x++;
	} elseif ($b % 4) {
		$y++;
	} else {
		$z++;
	}
}
echo $z < $x - 1 || $z == $x - 1 && $y > 0 ? 'No' : 'Yes';

Measured memory_bytes: 12792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a*b>c*d)
        cout<<a*b<<endl;
    else
        cout<<c*d<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";
#ifndef ONLINE_JUDGE
#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);
#else
#define freopen ios_base::sync_with_stdio(0);cin.tie(0); //Alperen_T
#endif

int main(){
	char arr[200001];
	cin >> arr;

	long long int len = strlen(arr), nums[2020] = {1}, ans = 0;;
	int mods[len], dp[200005] = {0};;

	mods[len - 1] = 1, mods[len - 2] = 10;

	for(int i = len - 3; i >= 0; i--){
		mods[i] = (mods[i + 1] * 10) % 2019;
	}

	for(int i = len - 1; i >= 0; i--){
		dp[i] = (dp[i + 1] + ((arr[i] - '0') * mods[i])) % 2019;
		nums[dp[i]]++;
	}

	for(int i = 0; i < 2020; i++){
		ans += (nums[i] * (nums[i] - 1)) / 2;
	}

	cout << ans;
} 

Measured memory_bytes: 5372
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        Arrays.setAll(array, i -> sc.nextInt());
        Arrays.sort(array);
        boolean[] dp = new boolean[array[n - 1] + 1];
        Arrays.fill(dp, true);
        for (int i = 0; i < n; i++) {
            int v = array[i];
            if (i > 0 && array[i] == array[i - 1]) {
                dp[v] = false;
                continue;
            }
            for (int j = 2; j * v <= array[n - 1]; j++) {
                dp[j * v] = false;
            }
        }
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (dp[array[i]]) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 61564
#include <stdio.h>
#include <string>
using namespace std;
int store[2 * 100000 + 1];
int main() {
	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &store[i]);
	}
	string ans = "";
	for (int i = N - 1; i >= 0; i -= 2) {
		ans += to_string(store[i]);
		ans += " ";
	}
	int start = 0;
	if (N % 2 != 0) {
		start = 1;
	}
	for (int i = start; i < N; i += 2) {
		ans += to_string(store[i]);
		ans += " ";
	}
	ans = ans.substr(0, ans.length() - 1);
	printf("%s\n", ans.c_str());
	return 0;
}

Measured memory_bytes: 4996