akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
// #include<unordered_map>
#include<set>
// #include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define ln() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007; // 998244353 , 1000000007
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
	bool operator>(const edge& right) const {
		return cost > right.cost;
	}
};

struct point {
	ll x, y, idx;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
	bool operator>(const point& right) const {
		return x == right.x ? y > right.y : x > right.x;
	}
};

ll bisect_left(ll arr[], ll arr_size, ll key) {
	return distance(arr, lower_bound(arr, arr + arr_size, key));
}

ll bisect_left(vector<ll> vc, ll key) {
	return lower_bound(vc.begin(), vc.end(), key) - vc.begin();
}

ll pow_mod(ll a, ll x) {
	if (x == 0) return 1;
	if (x == 1) return a % MOD;
	ll ret = pow_mod(a, x / 2);
	if (x % 2 == 0) ret = (ret*ret) % MOD;
	else ret = ((a % MOD) * ((ret*ret) % MOD)) % MOD;
	return ret;
}

void build_mod_fact(ll arr[], ll n) {
	arr[0] = 1;
	repi(i, 1, n + 1) {
		arr[i] = (arr[i - 1] * i) % MOD;
	}
	return;
}

void build_mod_fact_inv(ll arr_fact[], ll arr_fact_inv[], ll n) {
	arr_fact_inv[n] = pow_mod(arr_fact[n], MOD - 2);
	repd(i, n - 1, -1) {
		arr_fact_inv[i] = (arr_fact_inv[i + 1] * (i + 1)) % MOD;
	}
	return;
}

ll comb_mod(ll n, ll r, ll arr_fact[], ll arr_fact_inv[]) {
	return (((arr_fact[n] * arr_fact_inv[n - r]) % MOD) * arr_fact_inv[r]) % MOD;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}


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

ll n, k, t, ans = MAX_10p18;
vector<ll> h;


int main() {
	cin >> n >> k;
	repi(i, 0, n) {
		cin >> t;
		h.push_back(t);
	}
	sort(h.begin(), h.end());
	repi(i, k - 1, n) {
		ans = min(ans, h[i] - h[i - (k - 1)]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  int sum = 0;
  sum = a.size();
 // unique()を使う準備としてソートが必要
  sort(a.begin(), a.end());
 // unique()をしただけでは後ろにゴミが残るので、eraseで削除する
  a.erase(unique(a.begin(), a.end()), a.end() );
  if(sum == a.size()){
    cout << "YES";
  }else{
  	cout << "NO";
  }
}

Measured memory_bytes: 1024
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")


using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int k;
int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> k;
	cout << a[k - 1];












	return 0;
}


Measured memory_bytes: 3624
N, M=list(map(int, input().split()))
s_c=[]
for _ in range(M):
    s_c.append( list(map(int, input().split())) )
if N==1:
    for n in range(10):
        check=True
        for (s, c) in s_c:
            if n!=c:
                check=False
        if check==True:
            print(n)
            exit()
    print(-1)
elif N==2:
    for n in range(10, 100):
        check=True
        for (s, c) in s_c:
            if (n//(10**(2-s)) )%10!=c:
                check=False
        if check==True:
            print(n)
            exit()
    print(-1)
elif N==3:
    for n in range(100, 1000):
        check=True
        for (s, c) in s_c:
            if (n//(10**(3-s)) )%10!=c:
                check=False
        if check==True:
            print(n)
            exit()
    print(-1)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int pow2(int n){
	long m = 1;
	for(int i = 0; i < n; i++){
		m = (m*2) % 1000000007;
	}
	return int(m);
}

int main(){
	int N;
	cin >> N;
	int A[N];
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	sort(A, A+N);
	int flag = 1;
	int s = N%2;
	if(s == 1){
		if(A[0] != 0){
			flag = 0;
		}
	}
	for(int i = s; i < N; i += 2){
		if(flag == 0){
			break;
		}
		if(A[i] != i+1 || A[i+1] != i+1){
			flag = 0;
		}
	}
	cout << pow2(N/2) * flag << "\n";
}

Measured memory_bytes: 640
#![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: Vec<char> = sc.chars();
    if N[0] == '7' || N[1] == '7' || N[2] == '7' {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define EPS (1e-7)
#define INF 1e9

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

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

const ll mod=1e9+7;
const int MAX_N=200001;

int main(){
	int n;
	cin>>n;
	ll L[100];
	L[0]=2;
	L[1]=1;
	for(int i=2;i<100;i++){
		L[i]=L[i-1]+L[i-2];
	}
	cout<<L[n]<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG


signed main() {
  int N; cin >> N;
  string S; cin >> S;
  
  int e = 0;
  rep(i, N) if(S[i] == 'E') e++;
  
  vector<int> ans(N, 0);
  int k = 0;
  rep(i, N) {
    if(S[i] == 'E') {
      ans[i] = e-k-1 + i-k;
      k++;
    } else {
      ans[i] = e-k + i-k;
    }
  }
  //rep(i, N) cout << ans[i];
  
  sort(all(ans));
  cout << ans[0] << endl;

}


Measured memory_bytes: 3076
using System;
using System.Collections.Generic;
class Solve{
    int N;
    int[] T;
    int[] A;
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    void Calc(){
        getinput();
        long a = 1;
        long b = 1;
        for(int i=0;i<N;i++){
            if((a-1)/T[i] >= (b-1)/A[i]){
                b = ((a-1)/T[i]+1)*A[i];
                a = ((a-1)/T[i]+1)*T[i];
            }
            else{
                a = ((b-1)/A[i]+1)*T[i];
                b = ((b-1)/A[i]+1)*A[i];
            }
        }
        Console.WriteLine(a+b);
    }
    void getinput(){
        string[] str;
        N = int.Parse(Console.ReadLine());
        T = new int[N];
        A = new int[N];
        for(int i=0;i<N;i++){
            str = Console.ReadLine().Split(' ');
            T[i] = int.Parse(str[0]);
            A[i] = int.Parse(str[1]);
        }
    }    
}

Measured memory_bytes: 2904
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double acc = 1e-6;
main(){
    int n;
    cin >> n;
    int a[n];
    ll freq[n] = {0ll};
    ll sum=0ll;
    for(int i=0;i<n;i++){
        cin >> a[i];
        freq[ a[i]-1 ]++;
    }
    for(int i=0;i<n;i++){
        sum+=freq[i]*(freq[i]-1ll)/2ll ;
    }

    for(int i=0;i<n;i++){
        ll res = sum-freq[a[i]-1]*(freq[a[i]-1]-1ll)/2ll ;
        res = (freq[a[i]-1]>0ll) ? res+(freq[a[i]-1]-1ll)*(freq[a[i]-1]-2ll)/2ll : res ;
        cout << res << endl;
    }
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n,mx = 0,sum = 0;
    cin >> n;
    int a[n];
    for(int i = 0;i < n;i++){
        cin >> a[i];
        mx = max(mx,a[i]);
        sum += (a[i] - 1);
    }
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

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


int main(){
  int n,m,i,j;
  int c[22];
  int dp[50010];

  scanf("%d %d",&n,&m);
  for(i = 1; i <= m ; i++){
    scanf("%d",&c[i]);
  }
  for(i = 0 ; i <= n ; i++){
    dp[i] = 99999;
  }
  dp[0] = 0;
  for(i = 1; i <= m ; i++){
    for(j = 0 ; j+c[i] <= n ; j++){
      dp[j+c[i]] = min(dp[j]+1,dp[j+c[i]]);
    }
  }
  printf("%d\n",dp[n]);
      
  return 0;
}



Measured memory_bytes: 2108
import sys
input = sys.stdin.readline
from bisect import bisect_right
def main():
    N, D, A = map( int, input().split())
    XH = []
    X = []
    for _ in range(N):
        x, h = map( int, input().split())
        XH.append( (x, (h+(A-1))//A))
        X.append(x)
    XH.sort()
    X.sort()
    T = [0]*(N+1)
    j = 0
    now = 0
    ans = 0
    for i in range(N):
        x, h = XH[i]
        now -= T[i]
        if now >= h:
            continue
        else:
            T[ bisect_right(X,x+D*2)] += h-now
            ans += h - now
            now = h
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 40240
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>
#include <time.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n;
  cin >> n;
  pair<int, pair<int, int> > h[100001];

  rep(i, 0, n) {
    cin >> h[i].second.first >> h[i].second.second;
    h[i].first = h[i].second.first + h[i].second.second;
  }

  sort(h, h + n);
  int t = 0, a = 0;
  for(int i = 0; i < n; i++) {
    if(i % 2 == 0) {
      t += h[n - i - 1].second.first;
    }else {
      a += h[n - i - 1].second.second;
    }
  }

  cout << t - a << endl;
}


Measured memory_bytes: 2560
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] count = new int[100000];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            count[a[i]]++;
        }
        int max = count[0] + count[1] + count[2];
        for (int i = 2; i < 99999; i++) {
            if (max < count[i - 1] + count[i] + count[i + 1])
                max = count[i - 1] + count[i] + count[i + 1];
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 62148
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  int count=0,a=N;
  while(a>0){
    a/=10;count++;
  }
  
  int sum=0;
  a=N;
  for(int i=0;i<count;i++){
    sum+=a%10;
    a=(a-a%10)/10;
  }
  
  if(N%sum==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
    int h = 0, w = 0;
 
    while(1)
    {
        cin >> h >> w;
        if(((h>0) && (h<=300)) ||
           ((w>0) && (w<=300)))
        {
               for(int i = 0; i< h;i++)
               {
                   for(int j = 0; j < w; j++)
                   {
                       cout << "#";
                   }
                   cout << endl;
               }
               cout << endl;
        }
        else if((h == 0) && (w == 0))
        {
            break;
        }      
    }
    return 0;
}


Measured memory_bytes: 3096
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       




        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var h = Read();
            long ans = 0;
            long count = 1;
            while (h > 0)
            {
                h /= 2;
                ans += count;
                count *= 2;
            }
            Console.WriteLine(ans);




            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
//#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int x;
	cin >> x;

	if (x >= 400 && x <= 599)
		cout << "8" << endl;
	if (x >= 600 && x <= 799)
		cout << "7" << endl;
	if (x >= 800 && x <= 999)
		cout << "6" << endl;
	if (x >= 1000 && x <= 1199)
		cout << "5" << endl;
	if (x >= 1200 && x <= 1399)
		cout << "4" << endl;
	if (x >= 1400 && x <= 1599)
		cout << "3" << endl;
	if (x >= 1600 && x <= 1799)
		cout << "2" << endl;
	if (x >= 1800 && x <= 1999)
		cout << "1" << endl;
}

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

void solve(long long n, std::vector<long long> a){
    deque<ll> ans;
    for(ll i=0; i< n; i++){
        if(i%2 == 0) ans.push_front(a[i]);
        else ans.push_back(a[i]);
    }
    if(n%2==0) {
        for(auto it = ans.rbegin(); it != ans.rend(); it++)
            cout << *it << " ";
    }
    else{
        for(auto it = ans.begin(); it!= ans.end(); it++)
            cout << *it << " " ;
    }
    cout << endl;
}

int main(){
    long long n;
    scanf("%lld",&n);
    std::vector<long long> a(n);
    for(int i = 0 ; i < n ; i++){
        scanf("%lld",&a[i]);
    }
    solve(n, std::move(a));
    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int H, W; cin >> H >> W;
  vector<string> A(H); REP(i, H) cin >> A[i];
  vector<int> vec_x = {1, 0, -1, 0};
  vector<int> vec_y = {0, 1, 0, -1};

  string ans = "Possible";
  REP(i, H) {
    REP(k, W) {
      if(i == H - 1 && k == W - 1) {
        if(A[i - 1][k] == '#' && A[i][k - 1] == '#') {
          ans = "Impossible";
        }
        break;
      }
      if(A[i][k] == '#') {
        if(i + 1 >= H) {
          if(A[i][k + 1] == '.') {
            ans = "Impossible";
          }
        } else if(k + 1 >= W) {
          if(A[i + 1][k] == '.') {
            ans = "Impossible";
          }
        } else {
          if((A[i + 1][k] == '#' && A[i][k + 1] == '#') || 
          (A[i + 1][k] == '.' && A[i][k + 1] == '.')) {
            ans = "Impossible";
          }
        }

        if(i - 1 >= 0 && k - 1 >= 0) {
          if(A[i][k - 1] == '#' && A[i - 1][k] == '#') ans = "Impossible";
        }
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;

struct TRAMP{
	char mark;
	int number;
};

int main(){
	int n,min;
	char buf[3];
	scanf("%d",&n);

	TRAMP selectArray[n],bubbleArray[n];

	for(int i = 0; i < n; i++){
		scanf("%s",buf);
		selectArray[i].mark = buf[0];
		selectArray[i].number = buf[1] - '0';
		bubbleArray[i] = selectArray[i];
	}

	for(int i = n-1; i >= 0; i--){
		for(int j = 0; j < i; j++){
			if(bubbleArray[j].number > bubbleArray[j+1].number) swap(bubbleArray[j], bubbleArray[j+1]);
		}
	}

	for(int i = 0; i < n-1; i++){
		min = i;
		for(int j = i+1; j < n; j++){
			if(selectArray[j].number < selectArray[min].number){
				min = j;
			}
		}
		if(i != min){
			swap(selectArray[i],selectArray[min]);
		}
	}

	for(int i = 0; i < n-1; i++) printf("%c%d ",bubbleArray[i].mark,bubbleArray[i].number);
	printf("%c%d\n",bubbleArray[n-1].mark,bubbleArray[n-1].number);
	printf("Stable\n");
	for(int i = 0; i < n-1; i++) printf("%c%d ",selectArray[i].mark,selectArray[i].number);
	printf("%c%d\n",selectArray[n-1].mark,selectArray[n-1].number);

	int p;
	for(p=0; p < n; p++){
		if(selectArray[p].number != bubbleArray[p].number || selectArray[p].mark != bubbleArray[p].mark)
			break;
	}
	if(p == n){
		printf("Stable\n");
	}else{
		printf("Not stable\n");
	}

	return 0;
}

Measured memory_bytes: 1040
#include <stdio.h>

int main(void) {
	int n;
	int ans = 1, x = 1;

	scanf("%d", &n);

	for (int i = 1; i < n; i++) {
		for (int j = 0; j < i; j++) x *= 2;
		if (n >= x) {
			ans = x;
			x = 1;
		}
		else break;
	}

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

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long[] march = new long[5];
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            if (s.startsWith("M")) {
                march[0]++;
            } else if (s.startsWith("A")) {
                march[1]++;
            } else if (s.startsWith("R")) {
                march[2]++;
            } else if (s.startsWith("C")) {
                march[3]++;
            } else if (s.startsWith("H")) {
                march[4]++;
            }
        }
        long ans = 0;
        for (int i = 0; i < 5; i++) {
            for (int j = i + 1; j < 5; j++) {
                for (int k = j + 1; k < 5; k++) {
                    ans += march[i] * march[j] * march[k];
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 42488
W, H, N = map(int, input().split(' '))
minx = 0
maxx = W
miny = 0
maxy = H
for i in range(N):
    x, y, a = map(int, input().split(' '))
    if a == 1:
        minx = max(minx, x)
    elif a == 2:
        maxx = min(maxx, x)
    elif a == 3:
        miny = max(miny, y)
    else:
        maxy = min(maxy, y)
if minx <= maxx and miny <= maxy:
    print((maxx-minx) * (maxy-miny))
else:
    print(0)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=a;i<(b);++i)
#define CLEAR(a,v) memset(a,v,sizeof(a))
#define SORT(a) sort(a,a+sizeof(a)/sizeof(a[0]))
#define SORTV(v) sort(v.begin(),v.end())
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> v(N), sv(N);
    REP(i,N){
        cin >> v[i];
        sv[i] = v[i];
    }
    SORTV(sv);
    int ret = 0;
    REP(i,N){
        int k = lower_bound(sv.begin(),sv.end(),v[i]) - sv.begin() - i;
        if(k%2 != 0){
            ret++;
        }
    }
    ret/=2;
    cout << ret << endl;
}

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

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

	int mlen = 0;
	for (int i = 0; i < s.length(); i++) {
		int same = 0;
		for (int j = 0; j < t.length(); j++) {
			if (i+j >= s.length()) break;
			if (s.at(i+j) != t.at(j)) break;
			same++;
		}
		mlen = max(mlen, same);
	}

	cout << s.length() + t.length() - mlen << endl;
	return 0;
}


Measured memory_bytes: 256
n = range(1,int(input())+1)

def calc_div(n):
    cnt = 0
    while n/2 !=0:
        cnt += 1
        if n%2 != 1:
            n = n/2
        else:
            break
    return cnt

list = []
for i in n:
    j = calc_div(i)
    list.append(j)

max_value = max(list)
max_index = list.index(max_value)
print(n[max_index])

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
	    List<long> input = IO.GetLongList();
	    long n = input[0];
	    long m = input[1];
	    List<long> a = IO.GetLongList();
	    //a.ForEach(k => Console.WriteLine(k));
	    long l = 1;
	    a.ForEach(k=>{
	        l=Lcm(l,k/2);
	    });
	    if(l>m){
           Console.WriteLine(0);
           return;
        }
	    if(a.Any(x => (l/(x/2))%2==0)){
	        Console.WriteLine(0);
	        return;
	    }
	    Console.WriteLine(Math.Ceiling((double)((int)(m/l))/2));
	}
	
	static long Gcd(long a, long b)
    {
        var v = new[] { a, b };
        while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
        return v[0];
    }
    
    static long Lcm(long a, long b)
    {
        return a / Gcd(a, b) * b;
    }
    
    }

static class IO
{
    static public string GetString() { return Console.ReadLine(); }
    static public int GetInt() { return int.Parse(Console.ReadLine()); }
    static public long GetLong() { return long.Parse(Console.ReadLine()); }
    static public List<string> GetStringList() { return Console.ReadLine().Split(' ').ToList(); }
    static public List<int> GetIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
    static public List<long> GetLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
    static public void WriteStrings<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
}

Measured memory_bytes: 33244
import java.util.*;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        System.out.println(Math.min(Math.min(a + b, b + c), c + a));
    }
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
int main() {
    long test=1;
    // cin>>test;
    while(test--)
    {
	long n,m,i,j,a,b,c,d,ans=0;
    cin>>a>>b;
    vector<long> vec(a,0);
    for(i=0;i<b;i++)
    {
        cin>>n>>m;
        vec[n-1]++;
        vec[m-1]++;
    }
    for(i=0;i<a;i++)
    cout<<vec[i]<<endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
	Scanner scn = new Scanner(System.in);
	int a = scn.nextInt();
      String s = scn.next();
      if(a<3200){
        s = "red";
      }
      System.out.println(s);
	}
}


Measured memory_bytes: 35556
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<20)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  
  char a[H+2][W+2];
  for(int i=0;i<H;i++){
    for(int j=0;j<W; j++){
      cin >> a[i+1][j+1];
    }
  }
  for(int i=0;i<H+2;i++){
    a[i][0] = '#';
    a[i][W+1] = '#';
  }
  for(int j=0;j<W+2;j++){
    a[0][j] = '#';
    a[H+1][j] = '#';
  }
  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2; j++){
      cout << a[i][j];
    }
    cout << endl;
  }
  /*
  vector<string> vec(H);
  for(int i=0;i<H;i++){
    cin >> vec.at(i);
  }
  for(int i=0;)
  */
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int n,i,flag,tmp,count=0;
  int buf[101];
  scanf("%d",&n);
  for(i=0;i<n;i++){
	  scanf("%d",&buf[i]);
  }
  flag=1;
  while(flag){
	  flag=0;
	  for(i=n-1;i>0;i--){
		  if(buf[i]<buf[i-1]){
			  tmp=buf[i];
			  buf[i]=buf[i-1];
			  buf[i-1]=tmp;
			  flag=1;
			  count++;
		  }
	  }
  }

  for(i=0;i<n;i++){
	  printf("%d",buf[i]);
	  if(i==n-1) printf("\n");
	  else printf(" ");
  }  
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
#define int long long
#define itn int
signed main(void){
    int a,b; cin>>a>>b;
    cout<<max({a+b, a-b, a*b} )<<endl;
}


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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

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

	ll ans = 0;
	for (ll i = 1, end = std::sqrt(n); i <= end; ++i) {
		auto i2 = n / i;
		if (i2 <= 0 || n % i != 0)
			continue;

		--i2;
		auto i1 = i - 1;

		if (i1 > 0 && n / i1 == n % i1)
			ans += i1;
		if (i2 > 0 && i != i2 && n / i2 == n % i2)
			ans += i2;
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t N;
  cin >> N;
  vector<pair<int64_t, int>> table;
  
  int y = 0;
  while (N % 2 == 0) {
    N /= 2;
    y++ ;
    if ( N % 2 != 0) {
     table.emplace_back(2,y);
    }
   }
  
  int64_t i = 3;
  while (i*i < N ) {
    int x = 0;
    while (N % i == 0) {
      N /= i;
      x++ ;
    }
    if (x != 0) {
    table.emplace_back(i,x);
    }
    i += 2;
  }
  
  if (N != 1) {
    table.emplace_back(N, 1);
  }
  
  
  /*for (int i = 0; i < table.size(); i++) {
   	cout << table.at(i).first << " " << table.at(i).second <<endl;
  }*/
  
  int ans = 0;
  
  for (int i = 0; i < table.size(); i++) {
    int y = table.at(i).second;
    int b = 1;
    while (y >= b ) {
      ans++ ;
      y -= b; 
      b++ ;
    }
  }
  
   cout << ans << endl;
  
  return 0;
}


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

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    if((b-a) % 2 == 0){
        cout << "Alice" << endl;
    }else{
        cout << "Borys" << endl;
    }
    return 0;
}



Measured memory_bytes: 3572
N = int(input().strip())
h_list = [int(x.strip()) for x in input().split()]
v_dict = {}

count = 0
for i in range(N):
    # i - j == h_list[i+1] + h_list[j+1]
    # -> i - h_list[i+1] == j + h_list[j+1]
    hi = h_list[i]
    val_i = i - hi
    
    if (val_i in v_dict):
        count += v_dict[val_i]
    
    val_j = i + hi
    if (val_j in v_dict):
        v_dict[val_j] = v_dict[val_j] + 1
    else:
        v_dict[val_j] = 1

print(count)

Measured memory_bytes: 40348
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,c;
    cin>>a;
    a*=a;
    a*=3;
    cout<<a;
}

Measured memory_bytes: 3584
#include<stdio.h>
int main()
{
  char s[3];
  double x,goukei=0;
  int n,i;
  
  scanf("%d\n",&n);
  
  for(i=0;i<n;i++){
    scanf("%lf %s\n",&x,s);
    if(s[0]=='J'){
      goukei=goukei+x;
    }
    else if(s[0]=='B'){
      goukei=goukei+x*380000;
    }
  }
  
  printf("%f", goukei);
  
  return 0;
}

Measured memory_bytes: 128
# coding: utf-8

import sys

for line in sys.stdin:
    a, b, c, d, e, f = map(float, line.strip().split())
    y = (c*d-a*f)/(b*d-a*e)
    x = (c - b*y) / a
    print("%.3lf %.3lf" % (x, y))



Measured memory_bytes: 5592
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int ans = 0;
	for(int i = 0; i < 5; ++i) {
		int x;
		cin >> x;
		
		if( x == 0 ) ans = i + 1;
	}
	
	cout << ans << endl;
	return 0;
}


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

long long gcd(int a,int b)
{
if(a%b==0)
return b;
else return(gcd(b,a%b));
}


int main()
{
long long sum=0;
int K;
cin>>K;
for (int i=1;i<=K;i++)
{for (int j=1;j<=K;j++)
    {for (int k=1;k<=K;k++)
        sum+=gcd(i,gcd(j,k));
    }
}
cout <<sum;
}

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

int main() {
  int a, b, f = 1;
  string s;
  cin >> a >> b >> s;
  for(int i = 0; i < a; i++)
    if(s.at(i) == '-')
      f = 0;
  if(s.at(a) != '-')
    f = 0;
  for(int i = a + 1; i < a + b + 1; i++)
    if(s.at(i) == '-')
      f = 0;
  if(f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



int main(){
    int n;
    cin >> n;
    for(int i=111;i<=999;i+=111){
        if(i>=n){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
use proconio::input;

// use std::f64::consts::PI;
// use std::cmp::*;
// use std::collections::*;
// use proconio::marker::Chars;
// const MOD: u64 = 1000000007;
// const INF_I64: i64 = 92233720368547758;
// const INF_USIZE: usize = 18446744073709551;

#[allow(unused_macros)]
macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

#[allow(unused_macros)]
macro_rules! print_vec {
    ($vec:expr) => {
        for (i, &v) in $vec.iter().enumerate() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", v);
        }
        println!();
    };
}

fn main() {
    input! {
        m:u32,
        k:u32
    }
    if m <= 1 {
        if k == 0 {
            if m == 1 {
                println!("0 0 1 1");
            }
            if m == 0 {
                println!("0 0");
            }
        } else {
            println!("-1")
        }
        return;
    }

    if k >= 2u32.pow(m) {
        println!("-1");
        return;
    }
    let mut ans = vec![k];
    let tmp = 2u32.pow(m);

    for j in 0..2 {
        for i in 0..tmp {
            let x = if j == 1 { tmp - i - 1 } else { i };
            if x != k {
                ans.push(x);
            }
        }
        if j == 0 {
            ans.push(k);
        }
    }
    print_vec!(ans);
}


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

int main()
{
	while (true)
	{
		int count = 0;
		int n, m;
		int x = 10, y = 10;
		bool table[21][21] = {};

		cin >> n;
		if (n == 0) return 0;
		for (int i = 0; i < n; i++)
		{
			int X, Y;
			cin >> X >> Y;
			table[X][Y] = true;
		}

		cin >> m;
		for (int i = 0; i < m; i++)
		{
			char d;
			int p;
			cin >> d >> p;

			while (p--)
			{
				if (d == 'N') y++;
				if (d == 'E') x++;
				if (d == 'S') y--;
				if (d == 'W') x--;
				if (table[x][y]) count++;
				table[x][y] = false;
			}
		}

		if (count == n)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#define FL "a"
using namespace std;
typedef long long ll;
typedef long double dd;
const int N=2e5+10;
const int mod=1e9+7;
inline ll read(){
  ll d=0,w=1;char ch=getchar();
  while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
  if(ch=='-')w=-1,ch=getchar();
  while(ch<='9'&&ch>='0')d=d*10+ch-48,ch=getchar();
  return d*w;
}
inline void file(){
  freopen(FL".in","r",stdin);
  freopen(FL".out","w",stdout);
}

int n,m;
int pw[N],fac[N],ifac[N],inv[N];
inline void upd(int &a,int b){a+=b;if(a>=mod)a-=mod;}
inline void dec(int &a,int b){a-=b;if(a<0)a+=mod;}
inline int poww(int a,int b){
  int res=1;
  for(;b;b>>=1,a=1ll*a*a%mod)
    if(b&1)res=1ll*res*a%mod;
  return res;
}
inline void init(){
  fac[0]=fac[1]=ifac[0]=ifac[1]=inv[0]=inv[1]=pw[0]=1;
  for(int i=2;i<N;i++){
    inv[i]=mod-1ll*(mod/i)*inv[mod%i]%mod;
    fac[i]=1ll*i*fac[i-1]%mod;
    ifac[i]=1ll*inv[i]*ifac[i-1]%mod;
  }
  for(int i=1;i<N;i++)
    pw[i]=1ll*inv[2]*pw[i-1]%mod;
}
inline int C(int n,int m){return n<m?0:1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;}

int Tw[N],Tb[N];

int main()
{
  init();
  n=read();m=read();
  for(int i=1;i<=n+m;i++){
    upd(Tb[i]=1ll*C(i-1,n-1)*pw[i]%mod,Tb[i-1]);
    upd(Tw[i]=1ll*C(i-1,m-1)*pw[i]%mod,Tw[i-1]);
  }
  for(int i=1,res;i<=n+m;i++){
    upd(res=Tw[i-1],1ll*(1-Tw[i-1]-Tb[i-1]+mod+mod)%mod*inv[2]%mod);
    printf("%d\n",res);
  }
  return 0;
}


Measured memory_bytes: 6912
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

/*-- template --*/

int main() {
    string S; cin >> S;
    int K; cin >> K;
    vector<string>ans;
    for(int i = 0; i < S.size(); ++i) {
        for(int j = 0; j < min(K, int(S.size() - i)); ++j) {
            ans.pb(S.substr(i, j + 1));
        }
    }
    sort(ans.begin(), ans.end());
    int count = 1;
    rep(i, ans.size()) {
        if(count == K){
            cout << ans[i] << endl;
            return 0;
        }
        if(ans[i] != ans[i + 1]) {
            ++count;
        }
    }
}


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

vector<bool> seen(200005,false);
vector<int> counter;
void dfs(vector<vector<int>> const& vec, int v){
    seen.at(v) = true;
    for (int i = 0; i < vec.at(v).size(); i++){
        if (seen.at(vec.at(v).at(i))){
            continue;
        }
        counter[vec[v][i]] += counter[v];
        dfs(vec, vec.at(v).at(i));
    }
}

int main(){
    int N,Q;
    cin >> N >> Q;
    vector<vector<int> > to(N,vector<int> (0));
    
    for (int i = 0; i < N - 1; i++){
        int a,b;
        cin >> a >> b;
        to[a - 1].push_back(b - 1);
        to[b - 1].push_back(a - 1);
    }
    
    counter.assign(N,0);
    for (int i = 0; i < Q; i++){
        int p,x;
        cin >> p >> x;
        counter[p - 1] += x;
    }
    dfs(to, 0);
    
    for (int i = 0; i < N; i++){
        cout << counter[i] << " ";
    }
    
    
}


Measured memory_bytes: 29696
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[])
{
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i=0; i<N; i++) {
    cin >> h[i];
  }
  
  vector<int> v(N, 0);
  for (int i=N-2; i >= 0; i--) {
    int best = 1000000000;
    for (int j=i+1; j < N && j <= i+K; j++) {
      int tmp = h[i] - h[j];
      if (tmp < 0) tmp = -tmp;
      tmp += v[j];
      if (tmp < best) best = tmp;
      //cout << i << "," << j << ":" << best << "\n";
    }
    //cout << i << "=" << best << "\n";
    v[i] = best;
  }
  /*
  for (int i=0; i<N; i++) {
    cout << v[i] << " ";
  }
  */
  cout << v[0] << "\n";
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define db double
#define inf 10000001
#define infm 50001
#define INF (int)1e8 
#define mod (int)(1e9+7)
#define pi acos(-1)
#define rd(n) {n=0;char ch;int f=0;do{ch=getchar();if(ch=='-'){f=1;}}while(ch<'0'||ch>'9');while('0'<=ch&&ch<='9'){n=(n<<1)+(n<<3)+ch-48;ch=getchar();}if(f)n=-n;}
using namespace std;

int p[inf],ckp[inf],pcnt;
const int lim=10000000;

void pre_work(void){
    ckp[0]=ckp[1]=1;
    for (int i=2;i<=lim;i++){
        if (!ckp[i]){
            p[++pcnt]=i;
        }
        for (int j=1;j<=pcnt && p[j]*i<=lim;j++){
            ckp[p[j]*i]=1;
            if (i%p[j]==0){
                break;
            }
        }
    }
    return;
}

int S,T;

struct edge{
    int nxt,y,s;
}e[infm*2];
int ecnt=1,head[infm],h[infm];

void addedge(int x,int y,int s){
    ecnt++;
    e[ecnt].nxt=head[x];
    e[ecnt].y=y;
    e[ecnt].s=s;
    head[x]=ecnt;
    return;
}

void ae(int x,int y,int s){
    addedge(x,y,s);
    addedge(y,x,0);
    return;
}

queue <int> q;
int dep[inf];

int dfs(int u,int flow){
    if (!flow || u==T){
        return flow;
    }
    int ans=0;
    for (int i=h[u];i;i=e[i].nxt){
        h[u]=i;
        int v=e[i].y,s=e[i].s,now;
        if (dep[v]!=dep[u]+1){
            continue;
        }
        now=dfs(v,min(flow,s));
        if (now){
            ans+=now;
            flow-=now;
            e[i].s-=now;
            e[i^1].s+=now;
            if (!flow){
                break;
            }
        }
    }
    return ans;
}

int dinic(void){
    int ans=0;
    while (1){
        while (!q.empty()){
            q.pop();
        }
        memcpy(h,head,sizeof(head));
        memset(dep,-1,sizeof(dep));
        dep[S]=0;
        q.push(S);
        while (!q.empty()){
            int u=q.front(),v,s;
            q.pop();
            for (int i=head[u];i;i=e[i].nxt){
                v=e[i].y,s=e[i].s;
                if (dep[v]<0 && s){
                    dep[v]=dep[u]+1;
                    q.push(v);
                }
            }
        }
        if (dep[T]<0){
            break;
        }
        ans+=dfs(S,INF);
    }
    return ans;
}

int n;
int a[inf];
int L[inf],R[inf];

int main(){
    pre_work();
    rd(n)
    int x,mx=0;
    for (int i=1;i<=n;i++){
        rd(x)
        a[x]++;
        mx=max(mx,x);
    }
    int cntl=0,cntr=0;
    for (int i=1;i<=mx+1;i++){
        if (a[i]!=a[i-1]){
            if (i&1){
                L[++cntl]=i;
            }
            else{
                R[++cntr]=i;
            }
        }
    }
    S=0,T=cntl+cntr+1;
    for (int i=1;i<=cntl;i++){
        ae(S,i,1);
    }
    for (int i=1;i<=cntr;i++){
        ae(i+cntl,T,1);
    }
    for (int i=1;i<=cntl;i++){
        for (int j=1;j<=cntr;j++){
            if (!ckp[abs(L[i]-R[j])]){
                ae(i,j+cntl,1);
            }
        }
    }
    int mxf=dinic();
    int ans=mxf;
    ans+=(cntl-mxf)/2*2+(cntr-mxf)/2*2;
    ans+=((cntl-mxf)&1)*3;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 125184
#include<stdio.h>
#define N 8

int M[N+1][N+1];
int mark[N+1];

void set(int a,int b,int t,int d){
  int k;

  for(k = 1;k <= N;k++){
    if(k == b) M[a][k] = t;
    else M[a][k] += d;

    if(k == a) M[k][b] = t;
    else M[k][b] += d;
  }

  for(k = 1;(a+k) <= N && (b+k) <= N;k++) M[a+k][b+k] += d;

  for(k = 1;(a-k) > 0 && (b-k) > 0;k++) M[a-k][b-k] += d;

  for(k = 1;(a-k) > 0 && (b+k) <= N;k++) M[a-k][b+k] += d;

  for(k = 1;(a+k) <= N && (b-k) > 0;k++) M[a+k][b-k] += d;
}

int can(int i){
  int j;
  for(j = 1;j <= N;j++){
    if(M[i][j] == 8) return -1;
  }
  return 1;
}

int redo(int a){
  int i,j;
  if(mark[a] == 0){
    for(j = 1;j <= N;j++){
      if(M[a][j] == 8){
        set(a,j,0,-1);
        break;
      }
    }
    for(i = j+1;i <= N;i++){
      if(M[a][i] == 0){
        set(a,i,8,1);
        return a;
        }
    }
    if(i == N+1 && can(a) == 1) redo(a-1);
  }
  else if(mark[a] == 1) redo(a-1);
}

int main(){
  int n,i,j,k,flag = 0;

  for(i = 0;i <= N;i++){
    for(j = 0;j <= N;j++){
      M[i][j] = 0;
    }
    mark[i] = 0;
  }

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%d%d",&j,&k);
    set(j+1,k+1,8,1);
    mark[j+1] = 1;
  }

  for(i = 1;i <= N;i++){
    if(can(i) == 1){
      for(j = 1;j <= N;j++){
        if(M[i][j] == 0){
          set(i,j,8,1);
        }
      }
      if(j == N+1 && can(i) == 1) i = redo(i-1);
    }
    else continue;
  }


  for(i = 1;i <= N;i++){
    for(j = 1;j <= N;j++){
      if(M[i][j] == 8)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
  return 0;
}



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll A, B;
    ll AB;
    ll count = 1;
    cin >> A >> B;
    AB = __gcd(A, B);
    for(ll i = 2;i * i <= AB;i++) {
        if(AB % i == 0) {
           count++;
           while(AB % i == 0) AB /= i;
        }
    }
    if(AB > 1) count++;
    cout << count << endl;
    return 0;
}


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

#define size 100005

int main()
{
    long long int n, ttl, i, j, temp, arr[size], h=0;
    scanf("%lld%lld", &n, &ttl);

    for(i=1; i<=n; i++)
        scanf("%lld", &arr[i]);
    
    for(i=1; i<=n; i++)
    {
        for(j=i; j<=n; j++)
        {
            if(arr[i]>arr[j])
            {
                temp = arr[i];
                arr[i] = arr[j];
                arr[j] = temp;
            }
        }
    }

    for(i=1; i<n; i++)
    {
        if((ttl-arr[i])>=0)
        {
            h++;
            ttl -= arr[i];
        }
    }
    if(ttl==arr[n])
        h++;
    printf("%d", h);

    return 0;
}

Measured memory_bytes: 1740
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int input = sc.nextInt();
        BigDecimal decimal = new BigDecimal(input);
        BigDecimal res = decimal.multiply(new BigDecimal(100)).divideToIntegralValue(new BigDecimal(108));
        int v = res.intValue();
        while (true){
            int rest = (int)(v * 1.08);
            if (rest < input){
                v += 1;
            } else if (rest == input){
                System.out.println(v);
                break;
            } else if (rest > input){
                System.out.println(":(");
                break;
            }
        }
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 111111;
signed 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];
    int ban=1;
    for(auto k:a)if(k%2==0)ban*=2;
    cout<<pow(3,n)-ban<<endl;
}

Measured memory_bytes: 512