akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
ll gcd(ll a, ll b); 
  
// To compute x raised to power y under modulo m 
ll power(ll x,ll y, ll m); 
  
// Function to find modular inverse of a under modulo m 
// Assumption: m is prime 
ll modInverse(ll a, ll m) 
{ 
    return power(a, m-2, m);  
} 
  
// To compute x^y under modulo m 
ll power(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x * p) % m; 
} 
  
// Function to return gcd of a and b 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b%a, a); 
} 
int main()
{
	ll x,n,k,i,ans;
	cin>>n>>k;
	vi a;
	for(i=0;i<n;i++)
	{
		cin>>x;
		a.pb(x);
	}
	sort(a.rbegin(),a.rend());
	ans=0;
	for(i=min(n,k);i<n;i++)
	{
		ans=ans+a[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define N 100000
#define ll long long
const ll mod=1e9+7;
int f[2*N+5],sx[2*N+5],sy[2*N+5];
int getf(int x)
{
    return f[x]==x? x: f[x]=getf(f[x]);
}
int main()
{
    int n,y,x;
    scanf("%d",&n);
    for(int i=1;i<=2*N;i++)f[i]=i;
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&x,&y);
        int fx=getf(x),fy=getf(y+N);
        if(fx!=fy)
            f[fx]=fy;
    }
    for(int i=1;i<=N;i++)
        sx[getf(i)]++;
    for(int i=N+1;i<=2*N;i++)
        sy[getf(i)]++;
    ll ans=0;
    for(int i=1;i<=2*N;i++)
        ans+=1ll*sx[i]*sy[i];
    cout<<ans-n;
    return 0;
}


Measured memory_bytes: 2176
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k; // ??????????????°????????????????????°??°
llong T[MAX]; // i????????????????????????

// ?????§?????????P ??? k ??°?????????????????§?????????????????????????????????
int check(llong P){
	int i=0;
	for(int j=0;j<k;j++){
		llong s = 0; // ???????????????????????§????????????????????????
		while(s + T[i] <= P){ // s????????§?????????P??\?????§????????°???????????????
			s += T[i];
			i++;
			if(i==n) return n;
		}
	}
	return i;
}

int solve(){
	llong left = 0;
	llong right = 100000 * 10000; // ??????????????°?????????????????????????§??????
	llong mid;
	while(right - left > 1){
		mid = (left + right) / 2;
		int v = check(mid); // mid == P ????±??????????????????????????????§??????
		if(v >= n) right = mid;
		else left = mid;
	}

	return right;
}

main(){
	cin >> n >> k;
	for(int i=0;i<n;i++) cin >> T[i];
	llong ans = solve();
	cout << ans << endl;
}

Measured memory_bytes: 3868
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
//DP用
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;
}
const long long INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int divide = 0;
    int flag = 0;
    for(int i = 0; i < n-1; i++) {
        if(flag == 0) {
            if(a[i] < a[i+1]) {
                flag = 1;
            }else if(a[i] > a[i+1]) {
                flag = 2;
            }
        }else if(flag == 1) {
            if(a[i] > a[i+1]) {
                divide++;
                flag = 0;
            }
        }else if(flag == 2) {
            if(a[i] < a[i+1]) {
                divide++;
                flag = 0;
            }
        }
        
    }
    cout << divide+1;
    return 0;
}


Measured memory_bytes: 640
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    let mut v2 = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let v = s.trim().split_whitespace()
            .map(|e| e.parse().ok().unwrap()).collect();
        v2.push(v);
    }
    v2
}


fn c179(){

    let n:usize = read();
    //let mut result :Vec<(usize,usize,usize)> = Vec::new();
    let mut result = 0;
    for a in (1..=n) {
        result += (n-1)/a;

    }
    println!("{:?}",result);
}

fn main() {
    c179();
}


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

using namespace std;
using ll = long long;

ll cost (ll i,ll j,ll h[]){
return abs(h[i]-h[j]);

}
int main()
{
    ll n,k;
    cin>>n>>k;
    ll h[n+1];
    for(ll i=1;i<=n;i++){
        cin>>h[i];
    }
    ll dp[n+1];
    dp[1]=0;
    dp[0]=0;
    dp[2]= abs(h[1]-h[2]);
    for(ll i=3;i<=n;i++){
            dp[i]=INT_MAX;
        for(ll j=1;j<=k;j++){
            if(i-j>0)
            dp[i]=min(dp[i],dp[i-j]+cost(i,i-j,h));
        }

    }
    cout<<dp[n];
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int>ans = { 2,7,17,37,47,67,97,107,127,137,157,167,197,227,257,277,307,317,337,347,367,397,457,467,487,547,557,577,587,607,617,647,677,727,757,787,797,827,857,877,887,907,937,947,967,977,997,1087,1097,1117,1187,1217,1237,1277,1297,1307 };
	for (int i = 0; i < n; i++) {
		if (i == 0)cout << ans.at(i);
		else cout << " " << ans.at(i);
	}
}

Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=200005;
vector<int>adj[M];
int vis[M];
int ses=0,cnt=0;
void dfs(int u)
{
    cnt++;
    vis[u]=1;
    for(auto v:adj[u])
    {
        if(vis[v]==0)
        {
            dfs(v);
        }
    }
}
 main()

{
    fast
    int n,m;
    cin>>n>>m;
    f(i,1,m)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    f(i,1,n)
    {
        if(vis[i]==0)
        {
            cnt=0;
            dfs(i);
            ses=max(ses,cnt);
        }
    }
    cout<<ses<<"\n";
    return 0;

}





































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

int main(){
    cin >> X;
    for(ll a = -1000; a < 1000; a++){
        for(ll b = -1000; b < 1000; b++){
            if( a - b > 0 ){
                if((a*a*a*a*a - b*b*b*b*b == X)){
                    cout << a << " " << b << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

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

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

using namespace std;
using lint=long long;

int main(){
	lint n; scanf("%lld",&n);
	vector<lint> a(n);
	rep(i,n) scanf("%lld",&a[i]);

	lint sum=0;
	rep(i,n) sum+=a[i];
	if(sum%(n*(n+1)/2)!=0) return puts("NO"),0;

	lint m=sum/(n*(n+1)/2),cnt=0;
	rep(i,n){
		lint d=a[(i+1)%n]-a[i];
		if(m-d<0 || (m-d)%n!=0) return puts("NO"),0;
		cnt+=(m-d)/n;
	}
	puts(cnt==m?"YES":"NO");

	return 0;
}


Measured memory_bytes: 1024
#include <map>
#include <array>
#include <string>
#include <iostream>

using std::map;
using std::cin;
using std::cout;
using std::endl;
using std::array;
using std::string;

using dice_t = array<int,6>;
using order_t = array<int,4>;

void turn(dice_t &dice,order_t i) {
	int tmp = dice[i[0]];
	dice[i[0]] = dice[i[1]];
	dice[i[1]] = dice[i[2]];
	dice[i[2]] = dice[i[3]];
	dice[i[3]] = tmp;
}

int main() {
	map<string,order_t> oper {
		{"North",{0,1,5,4}},
		{"South",{0,4,5,1}},
		{"East",{0,3,5,2}},
		{"West",{0,2,5,3}},
		{"Left",{1,3,4,2}},
		{"Right",{1,2,4,3}}
	};
	while (true) {
		int n;
		cin >> n;
		if (n == 0) {
			break;
		}
		cin.ignore();
		dice_t dice = {1,2,3,4,5,6};
		int sum = 1;
		while (n--) {
			string dir;
			cin >> dir;
			turn(dice,oper[dir]);
			sum += dice[0];
		}
		cout << sum << endl;
	}
}

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

int main() {
	int t;
	string S;
	cin >> S;

	t = (S.at(5)-'0')*10 + (S.at(6)-'0');

	if(t < 5)
		cout << "Heisei";
	else
		cout << "TBD";
	cout << endl;
}

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


int main()
{    
    string S;
    cin >> S;
    
    int Q;
    cin >> Q;

    int a=1;
    string F="";
    string B="";
    for (int i = 0; i < Q; ++i) {
        int q;
        cin >> q;

        if (q==1){
            a*=-1;
        }
        if (q==2){
            int q;
            cin >> q;
            char c;
            cin >> c;
            if (a==1){
                if (q==1){
                    F+=c;
                    
                }
                if (q==2){
                    B+=c;
                    
                }
            }
            if (a==-1){
                if (q==1){
                    B+=c;
                    
                }
                if (q==2){
                    F+=c;
                   
                }
            }
        }
    }

    if (a==-1){
        reverse(S.begin(),S.end());
        reverse(B.begin(),B.end());
        cout << B+S+F << endl;
    }
    if (a==1){
        reverse(F.begin(),F.end());
        cout << F+S+B << endl;
    }
    return 0;
}

Measured memory_bytes: 1348
#include <iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int n,m;
	n=a+b;
	m=c+d;
	if(n>m)
	cout<<"Left";
	if(n<m)
	cout<<"Right";
	if(n==m)
	cout<<"Balanced";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

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

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

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;

map<string, int> memo;

using P=pair<int, int>;

/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}



const int INF = 1001001001;



int main() {
	string s;
	cin >> s;
	cout << s[0] << s[1] << s[2];
	return 0;
}













Measured memory_bytes: 3632
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
  int a, b, ans = 0;

  cin >> a >> b;

  ans += a -1;

  if(b >= a)
    cout << ans + 1 << endl;
  else
    cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
from collections import deque
section = input()
depth = 0
area = 0
depthArr = deque()
areaArr = deque()
for i, drct in enumerate(section):
    if drct == '\\':
        depth += 1
        depthArr.append(i)
    # ???°?´???????£???§?£???????????£?????£???????????£????
    elif 0 < depth and drct == '/':
        if len( depthArr ):
        	# ???°?´?????¢???????£?????£?????£????x?\???§???¨???£?????£???¨?£????
            j = depthArr.pop()
            # ???????\?????£???????????£?????£???£?£???????????£???¨?£???????????\?????£???????????£?????\?§???£?????£???????????£?????\???§???¨???£?????\?????£?????£?????£?????£?????£?????????¢?§?????£?????£?????£????
            pool =  i - j
            area += pool
            while len(areaArr):
                preJ, prePool = areaArr.pop()
                if j <= preJ:
                    pool += prePool
                else:
                    areaArr.append((preJ, prePool))
                    break
            areaArr.append((j, pool))
 
print(area)
output = []
output.append(len(areaArr))
for arr in areaArr:
    output.append(arr[1])
print(*output)


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

using namespace std;

int main() {
  int n;
  cin >> n;
  int res = 0;
  int cnt = 0;
  int mi = 2e9;
  while (n--) {
    int a;
    cin >> a;
    if (mi >= a) {
      cnt++;
    } else {
      res = max(res, cnt);
      cnt = 1;
    }
    mi = a;
  }
  cout << max(res, cnt) - 1 << endl;
}

Measured memory_bytes: 256
// package app;

import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

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

        final String N = sc.next();
        // final int M = sc.nextInt();
        // final int N = sc.nextInt();
        // final int A = sc.nextInt();
        // final int B = sc.nextInt();
        // final int D = sc.nextInt();

        int cnt = 0;
        boolean goodNum = false;
        char tmp = 'z';
        for (int i = 0; i < N.length(); i++) {
            if (tmp == N.charAt(i)) {
                cnt++;
                if (cnt >= 3) {
                    goodNum = true;
                    break;
                }
            } else {
                tmp = N.charAt(i);
                cnt = 1;
            }
        }

        // System.out.println();
        System.out.println(goodNum ? "Yes" : "No");

        // System.out.println(A <= X && A + B >= X ? "YES" : "NO");

    }
}

Measured memory_bytes: 21972
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int n, A[MAX], s;
int B[MAX], T[VMAX + 1];

int solve() {
	int ans = 0;

	bool V[MAX];
	for (int i = 0; i < n; i++) {
		B[i] = A[i];
		V[i] = false;
	}
	sort(B, B + n);
	for (int i = 0; i < n; i++)T[B[i]] = i;
	for (int i = 0; i < n; i++) {
		if (V[i])continue;
		int cur = i;
		int S = 0;
		int m = VMAX;
		int an = 0;
		while (1) {
			V[cur] = true;
			an++;
			int v = A[cur];
			m = min(m, v);
			S += v;
			cur = T[v];
			if (V[cur])break;
		}
		ans += min(S + (an - 2)*m, m + S + (an + 1)*s);
	}

	return ans;
}

int main() {
	cin >> n;
	s = VMAX;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		s = min(s, A[i]);
	}
	int ans = solve();
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3180
class Factorial():
    def __init__(self, mod=10**9 + 7):
        self.mod = mod
        self._factorial = [1]
        self._size = 1
        self._factorial_inv = [1]
        self._size_inv = 1
    
    def __call__(self, n):
        '''n! % mod '''
        return self.fact(n)
    
    def fact(self, n):
        '''n! % mod '''
        if n >= self.mod:
            return 0
        self.make(n)
        return self._factorial[n]
    
    def fact_inv(self, n):
        '''n!^-1 % mod '''
        if n >= self.mod:
            raise ValueError('Modinv is not exist! arg={}'.format(n))
        self.make_inv(n)
        return self._factorial_inv[n]
    
    def comb(self, n, r):
        ''' nCr % mod '''
        if r > n:
            return 0
        t = self.fact_inv(n-r)*self.fact_inv(r) % self.mod
        return self(n)*t % self.mod
    
    def comb_with_repetition(self, n, r):
        ''' nHr % mod '''
        t = self.fact_inv(n-1)*self.fact_inv(r) % self.mod
        return self(n+r-1)*t % self.mod
    
    def perm(self, n, r):
        ''' nPr % mod '''
        if r > n:
            return 0
        return self(n)*self.fact_inv(n-r) % self.mod
    
    @staticmethod
    def xgcd(a, b):
        ''' return (g, x, y) such that a*x + b*y = g = gcd(a, b) '''
        x0, x1, y0, y1 = 0, 1, 1, 0
        while a != 0:
            (q, a), b = divmod(b, a), a
            y0, y1 = y1, y0 - q * y1
            x0, x1 = x1, x0 - q * x1
        return b, x0, y0
    
    def modinv(self, n):
        g, x, _ = self.xgcd(n, self.mod)
        if g != 1:
            raise ValueError('Modinv is not exist! arg={}'.format(n))
        return x % self.mod
    
    def make(self, n):
        if n >= self.mod:
            n = self.mod
        if self._size < n+1:
            for i in range(self._size, n+1):
                self._factorial.append(self._factorial[i-1]*i % self.mod)
            self._size = n+1
    
    def make_inv(self, n):
        if n >= self.mod:
            n = self.mod
        self.make(n)
        if self._size_inv < n+1:
            for i in range(self._size_inv, n+1):
                self._factorial_inv.append(self.modinv(self._factorial[i]))
            self._size_inv = n+1

mod = 10**9 + 7
fact = Factorial(mod)

n, k, *A = map(int, open(0).read().split())
A.sort()
s = 0
for i, a in enumerate(A[k-1:], k-1):
    s += fact.comb(i, k-1) * a
    s %= mod
for i, a in enumerate(A[:n-k+1][::-1], k-1):
    s -= fact.comb(i, k-1) * a
    s %= mod
print(s)

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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second

typedef pair<int, int> PII;
typedef long long ll;

const int MOD = 1e9+7;

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);

	string s;
	cin >> s;
	int cur=0;
	for (char c : s) {
		cur+=(c-'0');
		cur%=9;
	}
	if (cur) cout << "No\n";
	else cout << "Yes\n";
}

Measured memory_bytes: 3712
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
int s[100];
int vis[100];
int main()
{
	int n,m,i,j,a,b; int ss=0; int kk=0;
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
	cin>>a>>b;
    if(vis[a]==0)
    {
    	vis[a]=1;
    	s[a]=b;
	}
	if(vis[a]==1&&s[a]!=b)
	{
		ss=1;
	}
	}
	if(ss)
	{printf("-1\n");return 0;}
	if(n==1&&vis[1]==1&&s[1]==0)
	{
		printf("0\n"); return 0;
	}
	if(n!=1&&vis[1]==1&&s[1]==0)
	{printf("-1\n");return 0;}
	if(vis[1]==0&&n!=1)
	{
		s[1]=1;
	}
	for(i=1;i<=n;i++)
	printf("%d",s[i]);

	}

Measured memory_bytes: 256
import math
def kaisuu(hoge):
	a = sorted(hoge)
	A = a[2]
	B = a[1]
	C = a[0]
	return math.floor(A-((B+C)/2))


X = list(map(int, (input()).split()))

count = 0
for i in X:
	if i % 2 == 0:
		count+=1

if count == 0 or count == 3:
	print(kaisuu(X))
elif count == 1:
	for i in range(3):
		if X[i] % 2 == 1:
			X[i]+=1
	print(kaisuu(X)+1)
else:
	for i in range(3):
		if X[i] % 2 == 0:
			X[i]+=1
	print(kaisuu(X)+1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 string s;
 cin>>s;
 int n=s.size();
 if(n==2){
  cout<<s<<endl;
 }
 else{
  reverse(s.begin(),s.end());
  cout<<s<<endl;
 }
 return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <tuple>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; --i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;

  ll ans = LLINF;
  for(ll i=1; i*i<=n; i++) {
    if(n % i == 0) {
      ans = min(ans, (i - 1) + (((n / i) - 1)));
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#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 <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
 
typedef struct{
  int t,b,n,w,s,e;
}die;
 
die rot;
 
main(){
  int n;
  while(cin>>n){
    if(n==0)break;
    rot.t=1;
    rot.n=2;
    rot.w=3;
    rot.b=6;
    rot.s=5;
    rot.e=4;
    int k;
    while(n--){
      string in;
      cin>>in;
      switch(in[0]){
      case 'n':
        k=rot.t;
        rot.t=rot.s;
        rot.s=rot.b;
        rot.b=rot.n;
        rot.n=k;
        break;
      case 's':
        k=rot.t;
        rot.t=rot.n;
        rot.n=rot.b;
        rot.b=rot.s;
        rot.s=k;
        break;
      case 'w':
        k=rot.t;
        rot.t=rot.e;
        rot.e=rot.b;
        rot.b=rot.w;
        rot.w=k;
        break;
      case 'e':
        k=rot.t;
        rot.t=rot.w;
        rot.w=rot.b;
        rot.b=rot.e;
        rot.e=k;
        break;
      }
    }
    cout<<rot.t<<endl;
  }
}

Measured memory_bytes: 0
S = set(input())

if len(S) == 4:
    print('Yes')
elif len(S) == 3 or len(S) == 1:
    print('No')
else:  # len(S)==2
    if S == {'N', 'S'} or S == {'E', 'W'}:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 2940
//???????????????
//???mnway=cnt???????????????cnt=mnway?????????????????????
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
const int MX=100;
typedef bitset<MX> BS;
int H,W,N;
int ans;
bool used[MX];
vector<BS> cs;
bool incl(BS& a,BS& b){return (a&b)==b;}
void dfs(BS now,int t){
	if(ans<=t) return;
	if(now.none()){
		chmin(ans,t);
		return;
	}
	int mnway=MX,arg=-1;
	rep(i,H*W) if(now[i]){
		int cnt=0;
		rep(j,N) if(!used[j]){
			if(cs[j][i]) cnt++;
		}
		if(cnt<mnway){
			mnway=cnt;
			arg=i;
		}
	}
	assert(arg>=0);
	rep(i,N) if(!used[i]&&cs[i][arg]){
		used[i]=1;
		dfs(now&(~cs[i]),t+1);
		used[i]=0;
	}
}
int main(){
	while(true){
		cin>>W>>H;
		if(H==0) break;
		cs.clear();
		BS s;
		rep(i,H) rep(j,W){
			bool x;
			cin>>x;
			s.set(i*W+j,x);
		}
		rep(i,H) rep(j,W){
			for(int d=10;d>=1;d--){
				bool can=1;
				if(i+d-1>=H||j+d-1>=W) can=0;
				if(can){
					rep(x,d) rep(y,d) if(!s[(i+x)*W+j+y]) can=0;
				}
				if(can){
					BS b;
					rep(x,d) rep(y,d) b.set((i+x)*W+j+y);
					cs.pb(b);
					break;
				}
			}
		}
		N=cs.size();
		bool gomi[MX]={};
		rep(i,N) rep(j,N) if(i!=j){
			if(incl(cs[i],cs[j])) gomi[j]=1;
		}
		vector<BS> tmp;
		rep(i,N) if(!gomi[i]) tmp.pb(cs[i]);
		cs=tmp;
		N=cs.size();
//		rep(i,N) show(cs[i]);
		ans=N;
		rep(i,N) used[i]=0;
		dfs(s,0);
//		show(cnt);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 2984
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);++i)


#define huge 1000000007
typedef long long ll;

int main(void) {
	
	ll N = 0;
	ll A = 0;
	ll X = 0;
	ll Y = 0;
	int x[50] = {};
	//string w;
	int count = 0;
	int sum = 0;
	
	cin >> N >> X >> Y;

	if (N == X && X == Y) {
		cout << 1 << endl;
	}
	else if (N != X && X != Y && N != Y) {
		cout << 3 << endl;
	}
	else {
		cout << 2 << endl;
	}
	
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
 public static void main(String args[]){
   Scanner sc = new Scanner(System.in);
   int H = sc.nextInt();
   int N = sc.nextInt();
   int[] A = new int[N];
   int sum=0;
   
   for(int i=0;i<N;i++){
     A[i]=sc.nextInt();
     sum=sum+A[i];
   }

   if(sum>=H){
     System.out.println("Yes");
   }else {
     System.out.println("No");
   }
 
 }
}


Measured memory_bytes: 50880
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a, b, c;
    cin >> a >> b >> c;
    if (a % 2 && b % 2 && c % 2)
    {
        cout << min(a * b, min(a * c, b * c)) << '\n';
    }
    else
    {
        cout << 0 << '\n';
    }
}


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

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define array(N, t) (t*)calloc(N, sizeof(t))
#define ll long long
#define INF ((1LL << 62) - (1LL << 31))
#define max(p, q)((p) > (q) ? (p) : (q))
#define min(p, q)((p) < (q) ? (p) : (q))

char N[200010];
int main(){
  scanf("%s", N);
  int sum = 0;
  for (int i = 0; N[i] != '\0'; i += 1) sum += N[i] - '0';
  if (sum % 9 == 0) {
    puts("Yes");
  } else {
    puts("No");
  }
}


Measured memory_bytes: 1836
import java.io.*;
import java.util.*;

public class Main implements Runnable {
	public static void main (String[] args) {new Thread(null, new Main(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int n = fs.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) a[i] = fs.nextLong();
		long[] terms = new long[n];
		for(int i = 0; i < n; i++) {
			if(i % 2 == 0) terms[0] += a[i];
			else terms[0] -= a[i];
		}
		terms[0] /= 2;
		for(int i = 1; i < n; i++) {
			terms[i] = a[i-1]-terms[i-1];
		}
		for(int i = 0; i < n; i++) terms[i] *= 2;
		for(int i = 0; i < n; i++) {
			if(i > 0) out.print(" ");
			out.print(terms[i]);
		}
		out.println();
		
		
		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

}

Measured memory_bytes: 36148
#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;

long long e[7];

int main(){
    for(int i = 0; i < 7; i++){
        cin >> e[i];
    }
    long long a, b, c, d;
    a = e[0];
    b = e[1];
    c = e[3];
    d = e[4];
    long long ans = 0ll;
    ans += (a / 2ll) * 4ll;
    a %= 2ll;
    ans += b * 2ll;
    ans += (c / 2ll) * 4ll;
    c %= 2ll;
    ans += (d / 2ll) * 4ll;
    d %= 2ll;
    if(a + c + d == 3ll){
        ans += 6ll;
    }
    else if(a + c == 2ll){
        if(e[4] >= 2ll){
            ans += 2ll;
        }
    }
    else if(a + d == 2ll){
        if(e[3] >= 2ll){
            ans += 2ll;
        }
    }
    else if(c + d == 2ll){
        if(e[0] >= 2ll){
            ans += 2ll;
        }
    }
    cout << ans / 2 << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <random>
using namespace std;

class xor128{
  public:
    static constexpr unsigned min(){ return 0; }
    static constexpr unsigned max(){ return 1e9; }
    unsigned operator()(){ return random(); }
    xor128(){ random_device rd; w = rd(); }
    xor128(unsigned s){ w = s; }
  private:
    unsigned x = 123456789, y = 362436069, z = 521288629, w;
    unsigned random() {
      unsigned t;
      t = x ^ (x << 11);
      x = y; y = z; z = w;
      return w = (w ^ (x >> 19)) ^ (t ^ (t >> 8));
    }
};

int n;
double x[111], y[111];

int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  cin >> n;
  for(int i = 0; i < n; ++i) cin >> x[i] >> y[i];

  double ans = 0.0;
  xor128 xs = 1;
  uniform_real_distribution<double> real(-1.0, 1.0);
  for(int unko = 0; unko < 10000; ++unko) {
    x[n] = real(xs), y[n] = real(xs);

    double px = 0.0, py = 0.0;
    for(int i = 0; i < n; ++i)
      if(x[i]*x[n] + y[i]*y[n] >= 0) px += x[i], py += y[i];
    ans = max(ans, px*px + py*py);
  }
  cout << fixed << setprecision(15) << sqrt(ans);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	vector<Int> A(N);
	for (Int i = 0; i < N; i++) {
		cin >> A[i];
	}

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

	Int temp = A[0];
	Int cnt = 0;
	Int num = 0;
	vector<Int> card(N);
	for (Int i = 0; i < N; i++) {
		if (A[i] == temp) {
			cnt++;
		}
		if(A[i]!=temp){
			card[num] = cnt;
			temp = A[i];
			num++;
			cnt = 1;
		}
		if (i == N - 1) {
			card[num] = cnt;
		}
	}

	Int diff = 0;
	for (Int i = 0; i <= num; i++) {
		diff += card[i] - 1;
	}

	/*Int ans;
	if (diff % 2) {
		ans = num;
	}
	else {
		ans = num+1;
	}

	cout << ans << "\n";*/

	cout << (diff % 2 ? num : num + 1) << "\n";

}

Measured memory_bytes: 1792
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
from fractions import gcd

NN = 202020
MOD = 10**9+7
INF = float("inf")

n = int(input())
A = [list(map(int, input().split())) for i in range(n)]
B = [list(map(int, input().split())) for i in range(n)]

used = [False]*n
A.sort()
B.sort()
count = 0
for i in range(len(B)):
    cand = [-1, -1]
    cand_idx = -1
    for j in range(len(A)):
        if A[j][0] < B[i][0]:
            # print(used[j], cand[1], A[j][1])
            if (not used[j]) and (cand[1] < A[j][1] < B[i][1]):
                cand = A[j]
                cand_idx = j
        else:
            break

    if cand_idx != -1:
        count += 1
        used[cand_idx] = True

print(count)


Measured memory_bytes: 64620
n,y=map(int,input().split())
flag=False

for i in range(n+1):
    for j in range(n-i+1):
        k=n-i-j
        if y==1000*i+5000*j+10000*k:
            print(k,j,i)
            flag=True
            break
    if flag==True:
        break
else:
    print(-1,-1,-1)

Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007

ll N;
string S;
ll L[40];
ll R[40];


int main() {
    scanf("%lld",&N);
    L[1] = 0;
    R[1] = 1;
    repi(i,2,40){
        if (i % 2){
            L[i] = L[i-1];
            R[i] = R[i-1]+pow(2,i-1);
        }
        else{
            L[i] = L[i-1]-pow(2,i-1);
            R[i] = R[i-1];
        }
    }
    ll s = 0;
    repi(i,1,40){
        if (N >= L[i] && N<= R[i]){
            s = i;
            break;
        }
    }
    ll temp = N;
    while (s > 1){
        if (s % 2){
            if (temp >= L[s-1] && temp <= R[s-1]){
                S += '0';
                s--;
            }
            else{
                S+='1';
                temp -= pow(2,s-1);
                s--;
            }
        }
        else{
            if (temp >= L[s-1] && temp <= R[s-1]){
                S += '0';
                s--;
            }
            else{
                S+='1';
                temp += pow(2,s-1);
                s--;
            }
        }
    }
    if (temp == 1) S+= '1';
    else S+='0';
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,start,lim) for(lld i=start;i<lim;i++)
#define repd(i,start,lim) for(lld i=start;i>=lim;i--)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld ",x)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define br printf("\n")
#define sz(a) lld((a).size())
#define YES printf("YES\n")
#define NO printf("NO\n")
#define all(c) (c).begin(),(c).end()
#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define MOD         1000000007
#define PI          3.14159265358979323
using namespace std;
typedef long double ldb;
typedef long long lld;
lld powm(lld base,lld exp,lld mod=MOD) {lld ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
lld ctl(char x,char an='a') {return (lld)(x-an);}
char ltc(lld x,char an='a') {return (char)(x+an);}
#define bit(x,j) ((x>>j)&1)
typedef vector<lld> vlld;
typedef pair<lld,lld> plld;
typedef map<lld,lld> mlld;
typedef set<lld> slld;
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mxm(a,b) a = max(a,b)
#define mnm(a,b) a = min(a,b)
#define endl '\n'
#define fre freopen("1.in","r",stdin); freopen("1.out","w",stdout);
#define N 1000005
int main()
{
    //sync;
    lld n;
    cin>>n;
    cout<<(n>999?"ABD":"ABC");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int dp[101000];
int main()
{
    int n, k;
    cin >> n >> k;
    //dp[i]:0なら負け１なら勝ちもし遷移先に0があるなら勝ち遷移先に１しかないなら負け
    vector<int> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    for (int i = 1; i <= k; i++)
    {
        int res = 0;
        for (auto j : a)
        {
            if (j > i)
            {
                continue;
            }
            if (dp[i - j] == 0)
            {
                res = 1;
            }
        }
        dp[i] = res;
    }
    if (dp[k])
    {
        cout << "First" << endl;
    }
    else
    {
        cout << "Second" << endl;
    }
    return 0;
}

Measured memory_bytes: 640
from collections import deque
D=deque(input().rstrip())
Q=int(input())
count=0
for _ in range(Q):
	Y=list(input().split())
	if Y[0]=="1":
		count=(count+1)%2
	else:
		if Y[1]=="1":
			if count==0:
				D.appendleft(Y[2])
			else:
				D.append(Y[2])
		else:
			if count==0:
				D.append(Y[2])
			else:
				D.appendleft(Y[2])
D=list(D)
if count==0:
	print("".join(D))
else:
	D.reverse()
	print("".join(D))

Measured memory_bytes: 8436
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int main()
{
    int N, D;
    cin >> N >> D;
    int ans = 0;
    vector<vector<int>> X(N,vector<int>(D));
    for(int i=0; i<N; i++){
        for(int j=0; j<D; j++){
            cin >> X.at(i).at(j);
        }
    }
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            int dist = 0;
            for(int h=0; h<D; h++){
                dist += (X.at(i).at(h)-X.at(j).at(h))*(X.at(i).at(h)-X.at(j).at(h));
            }
            if(int(sqrt(dist))*int(sqrt(dist))==dist){
                ans += 1;
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int x, y;
    cin >> x >> y;

    bool ok = false;
    if ((y - 2 * x) % 2 == 0 && (4 * x - y) % 2 == 0)
        if (y - 2 * x >= 0 && 4 * x - y >= 0)
            ok = true;

    puts(ok ? "Yes" : "No");
    return 0;
}


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

int main(){
	double weight;
      while(cin >> weight){

	if(weight<=48.00) printf("light fly\n");
	if(weight>48.00 && weight<=51.00) printf("fly\n");
	if(weight>51.00 && weight<=54.00) printf("bantam\n");
	if(weight>54.00 && weight<=57.00) printf("feather\n");
	if(weight>57.00 && weight<=60.00) printf("light\n");
	if(weight>60.00 && weight<=64.00) printf("light welter\n");
	if(weight>64.00 && weight<=69.00) printf("welter\n");
	if(weight>69.00 && weight<=75.00) printf("light middle\n");
	if(weight>75.00 && weight<=81.00) printf("middle\n");
	if(weight>81.00 && weight<=91.00) printf("light heavy\n");
	if(weight>91.00) printf("heavy\n");
      }
}

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

int main(){
  vector<uint64_t> lucas(88);
  int N;
  cin >> N;
  lucas.at(0) = 2;
  lucas.at(1) = 1;
  for(int next = 2; next < N+1; ++next){
    lucas.at(next) = lucas.at(next-1)+lucas.at(next-2);
  }
  cout << lucas.at(N) << endl;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> p(n+2,0);
	REP(i,n){
		cin >> p[i];
	}
	int count = 0;
	int adj = 0;
	map<int,int> mp;
	REP(i,n) {
		if (i == p[i]) count++;
		if (i == p[i] && i+1 == p[i+1] && mp[i] == 0) {
			adj++;
			mp[i+1]++;
		}
	}
	
	int temp = count - adj*2;
	int ans = temp + adj;
	cout << ans << endl;
	
    return 0;
}



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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c)
    cout << 1 << endl;
  else if (a == b || b == c || c == a)
    cout << 2 << endl;
  else
    cout << 3 << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
H = list(map(int,input().split()))
dp = [10**10]*n
dp[0] = 0
for i in range(1,n):
    for j in range(k+1):
        if i-j < 0:
            continue
        else: 
            dp[i] = min(dp[i],dp[i-j]+abs(H[i]-H[i-j]))
print(dp[n-1])

Measured memory_bytes: 52448
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

typedef struct
{
  int front;
  int rear;
  int data[MAX][2];
} queue;

queue que;

void initQueue(queue *p)
{
  p->front = p->rear = 0;
}

bool emptyQueue(queue *p)
{
  return p->front == p->rear;
}

bool fullQueue(queue *p)
{
  return (p->front - 1 == p->rear) || (p->front == 0 && p->rear == MAX - 1);
}

void queuePop(queue *p)
{
  if (emptyQueue(p))
  {
    printf("UnderFlow\n");
    exit(1);
  }
  else
  {
    p->front++;
    if (p->front == MAX)
      p->front = 0;
  }
}

void queuePush(queue *p, int node, int parent)
{
  if (fullQueue(p))
  {
    printf("OverFlow\n");
    exit(1);
  }
  else
  {
    p->data[p->rear][0] = node;
    p->data[p->rear][1] = parent;
    p->rear++;
    if (p->rear == MAX)
      p->rear = 0;
  }
}

typedef struct list {
  int node;
  struct list *next;
} list;

list *graph[MAX];

void initGraph(void) {
  for (int i = 0; i < MAX; i++)
    graph[i] = NULL;
}

void addEdge(int node1, int node2)
{
  list *new1 = (list *)malloc(sizeof(list *));
  new1->node = node2;
  new1->next = graph[node1];
  graph[node1] = new1;

  list *new2 = (list *)malloc(sizeof(list *));
  new2->node = node1;
  new2->next = graph[node2];
  graph[node2] = new2;
}

int main(void) {
  int N, u, v, a, b;
  scanf("%d %d %d", &N, &u, &v);
  initGraph();
  rep(i, 0, N) {
    scanf("%d %d", &a, &b);
    addEdge(a, b);
  }

  int aoki[MAX]; // 青木くんのその頂点までの最短移動距離
  queue ki;
  initQueue(&ki);
  queuePush(&ki, v, 0);
  aoki[v] = 0;
  while ( !emptyQueue(&ki) ) {
    int n = ki.data[ki.front][0]; // 今
    int p = ki.data[ki.front][1]; // 親
    queuePop(&ki);
    int count = 0;
    for (list *c = graph[n]; c != NULL; c = c->next) {
      if (c->node == p) continue;
      aoki[c->node] = aoki[n] + 1;
      queuePush(&ki, c->node, n);
      count++;
    }
    if (count == 0) aoki[n] = 0;
  }

  int taka[MAX]; // 高橋くんのその頂点までの最短移動距離
  initQueue(&ki);
  queuePush(&ki, u, 0);
  taka[u] = 0;
  while ( !emptyQueue(&ki) ) {
    int n = ki.data[ki.front][0]; // 今
    int p = ki.data[ki.front][1]; // 親
    queuePop(&ki);
    for (list *c = graph[n]; c != NULL; c = c->next) {
      if (c->node == p) continue;
      taka[c->node] = taka[n] + 1;
      queuePush(&ki, c->node, n);
    }
  }

  int ans = 0;
  rep(node, 1, N + 1) {
    // 同じ回数で到達
    if (taka[node] > aoki[node]) continue;
    ans = max(ans, aoki[node]);
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 8704
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int N = Integer.parseInt(sc.next());
        long[] h = new long[N];
        for (int i = 0; i < N; i++) {
            h[i] = Long.parseLong(sc.next());
        }
        int max = 0;
        int cnt = 0;
        
        for (int i = 0; i < N - 1; i++) {
            if (h[i] >= h[i+1]) {
                cnt++;
                max = Math.max(max, cnt);
            } else {
                cnt = 0;
            }
        }
        
        out.println(max);
        
        out.flush();
    }
}

Measured memory_bytes: 48668