akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 100005;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

template <typename T> inline void cmax(T &x, T y) {
	if (x < y) x = y;
}

int n, m, a[MAXN << 1];

inline int par(int l, int r) {
	int ret = 0;
	for (; l < r; ++l, --r) {
		cmax(ret, (a[l] + a[r]) % m);
	}
	return ret;
}

inline int check(int mid) {
	return max(par(1, mid * 2), par(mid * 2 + 1, n));
}

void init() {
	read(n); read(m);
	n <<= 1;
	for (int i = 1; i <= n; ++i) {
		read(a[i]);
	}
	sort(a + 1, a + n + 1);
}

void solve() {
	int L = 0, R = n, p = R;
	while (L <= R) {
		int mid = (L + R) >> 1;
		bool flag = 1;
		for (int l = mid * 2 + 1, r = n; l < r; ++l, --r) {
			if (a[l] + a[r] < m) {
				flag = 0; break;
			}
		}
		if (flag == 1) {
			p = mid;
			R = mid - 1;
		} else {
			L = mid + 1;
		}
	}
	printf("%d\n", check(p));
}

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



Measured memory_bytes: 1152
#include<iostream>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;

  int i;
  int a[n];
  double sum=0;
  for (i = 0; i < n;i++){
    cin >> a[i];
    sum = sum + a[i];
  }
  double t = sum /( m * 4);


  int o = 0;
  for (i = 0;i<n;i++){
    if(a[i]>=t)
      o++;
  }

  if(o>=m)
    cout << "Yes" << endl;
    else
      cout << "No";
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, h, m float64
	fmt.Scan(&a, &b, &h, &m)

	pi := math.Acos(-1)

	// 角度を求める
	th := (h*60+m)/720 * 2*pi //時針
	//tm := m/60 * 2*pi  //分針
	tm := (h*60+m)/60 * 2*pi  //分針

	xh := a*math.Cos(th) //時針差表
	yh := a*math.Sin(th)

	xm := b*math.Cos(tm) //時針差表
	ym := b*math.Sin(tm)

	dx := xh - xm
	dy := yh - ym
	fmt.Println(math.Sqrt(dx*dx + dy*dy))

}


Measured memory_bytes: 1820
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vpl vector<pair<long long,long long>>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
long long MOD = 1000000007;
const long double pi = 3.1415926535897932;
#define pb push_back
#define mp make_pair
#define mt make_tuple
using Grid = vector<vector<char>>;
#define vc vector<char>
//(mod m)でのaの逆元を計算する
//a/b(mod m)=a(mod m)*modinv(b,m)
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
//a^n modを計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// modnCr
ll modnCr(ll n, ll r, ll mod) {
  ll res = 1;
  rep (i, r) {
    res = res * (n - i) % mod * modpow(i + 1, mod - 2, mod) % mod;
  }
  return res;
}

//UF
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=modpow(2,n,MOD);
    ans--;
    ans-=modnCr(n,a,MOD);
    ans-=modnCr(n,b,MOD);
    cout<<(ans+MOD*10)%MOD<<endl;
}


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    int A,B,cost;
    scanf("%d %d", &A,&B);
    if(A>=13 && A<=100)
        cost=B;
    else if(A<=12 && A>=6)
        cost=B/2;
    else if(A>=0 && A<=5)
        cost=0;

    printf("%d", cost);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define LL long long 
const int N=1e5+9;
using namespace std;
LL a[N],b[N],n,k,ans;
int pos[50],app[N],tot;
bool pd(int who,int difang)
{
	int flag=1;
	for(int i=30;i>=pos[difang];--i)
	   if(app[i]==0&&(a[who]&(1LL<<i)))
	      flag=0; 
	
	if(difang==tot)
	{
	 for(int i=pos[difang]-1;i>=0;--i)
	 if((a[who]&(1LL<<i)))
	  flag=0;
	 return flag;
    }
//if(difang==1&&who==3)
//{
//   system("pause");	
//}	
	for(int i=pos[difang]-1;i>=pos[difang+1];--i)
	 if((a[who]&(1LL<<i)))
	  flag=0;
	
	return flag;
	
}
int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;++i) scanf("%lld%lld",&a[i],&b[i]);
	
	for(int i=30;i>=0;--i)
	 if((1LL<<i)&k) pos[++tot]=i;

//for(int i=1;i<=tot;++i)
// printf("pos[%d]:%d\n",i,pos[i]);	
  
	for(int i=0;i<=tot;++i)
	{
	   if(i) app[pos[i]]=1;
	   LL now=0;
	   for(int j=1;j<=n;++j)
	   {
	   	 if(i)
		  {
		   if(pd(j,i)) 
            now=now+b[j];
	      }
		 else 
		  {
		     int flag=1;
				 for(int p=30;p>=pos[1];--p)
		       if((a[j]&(1ll<<p)))
		        flag=0;
			   if(flag) now=now+b[j];	
		  } 
	   }
	   ans=max(ans,now);
	}
	
	printf("%lld\n",ans);
	return 0;
}

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

int GCD(int a, int b)
{
 if(a%b == 0)
  return b;

 GCD(b, a%b);
}

int LCM(int a, int b)
{
 int c = GCD(a, b);

 return a*(b/c);
}

int main()
{
 int a, b;

 while( cin >> a >> b){
  cout << GCD(a, b) << ' ' << LCM(a, b) << '\n';
 }

 return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    REP(i, H+1) {
        int num0 = i * A + (H-i) * (W-A);
        REP(j, W+1) {
            if(j * B + (W-j) * (H-B) == num0) {
                vector<int> col0rest(W);
                REP(k, W) {
                    if(k < j) {
                        col0rest[k] = B;
                    } else {
                        col0rest[k] = H-B;
                    }
                }
                REP(x, H) {
                    int row0rest = 0;
                    if(x < i) {
                        row0rest = A;
                    } else {
                        row0rest = W-A;
                    }
                    REP(y, W) {
                        if(col0rest[y] > 0 && row0rest > 0) {
                            cout << "0";
                            col0rest[y]--;
                            row0rest--;
                        } else {
                            cout << "1";
                        }
                    }
                    cout << endl;
                }
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define trace(x) cout << '>' << #x << ':' << x << "\n" 
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << "\n" 
#define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n" 
#define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n" 
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl '\n' 
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 1e5 + 10;

int main()
{
    fastIO;
    int n;
    cin >> n;

    cout << (powmod(10,n) - 2 * powmod(9,n) % mod +  powmod(8,n) + mod) % mod << endl;
    return 0;
}

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

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

    ll ans = 1;
    ll divider = pow(10,9)+7;

    for(ll i = 1; i <= N; i++)
    {
        ans *= i;
        ans %= divider;
    }

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int s;
    cin>>s;
    int a[4];
    a[0]=s%10;
    a[1]=s/10%10;
    a[2]=s/100%10;
    a[3]=s/1000;
    for(int i=0;i<=3;i++){
    	for(int j=0;j<=3;j++){
    		if(a[i]==a[j]&&(i-j==1||j-i==1)){
    			cout<<"Bad"<<endl;
				return 0; 
    		}
    	}
    }
    cout<<"Good";
	return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


void solve(long long L) {
    int t = 1, k = 0;
    while (t <= L) {
        t *= 2;
        k++;
    }
    int N = k;
    vector<tuple<int, int, int>> v;
    for (int i = 0; i < k - 1; ++i) {
        v.push_back(make_tuple(i + 1, i + 2, 0));
        v.push_back(make_tuple(i + 1, i + 2, 1LL << i));
    }
    for (int i = 0; i < k - 1; ++i) {
        if (L & (1LL << i)) {
            int p = (1LL << (i + 1)) - 1;
            v.push_back(make_tuple(i + 1, N, L & ~p));
        }
    }
    cout << N << " " << v.size() << endl;
    for (auto e: v) {
        cout << get<0>(e) << " " << get<1>(e) << " " << get<2>(e) << endl;
    }
}

signed main(){
	ios::sync_with_stdio(false);
    long long L;
    scanf("%lld",&L);
    solve(L);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s;
    cin >> s;
    string y = s.substr(0,4);
    string m = s.substr(5,2);
    int ny = stoi(y);
    int nm = stoi(m); 
    if(ny <= 2018 || ny == 2019 && nm < 5) puts("Heisei");
    else puts("TBD");
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8


def main():
    n = int(input())
    lh = list(map(int, input().split()))
    h_max = 0
    ret = 0
    for h in lh:
        if h >= h_max:
            ret += 1
        h_max = max(h_max, h)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  int i;
  int a,b;
  cin >> n >> m;
  vector<pair<int,int> >p(m);
  for(i=0;i<m;i++){
    cin >> a >> b;
    p[i].first = min(a,b);
    p[i].second = max(a,b);
  }
  sort(p.begin(),p.end());
  int current = 0;
  int last = 9999999;
  i = 0;
  int ans = 0;
  for(current = 0;current<=n;current++){
    while(i<m && p[i].first == current){
      if(last > p[i].second)last = p[i].second;
      i++;
    }
    if(current == last-1){
      last = 9999999;
      ans++;
    }

  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>

using namespace std;

typedef long long ll;
const int Max = 1e5 + 5;
ll n, m, t, k, i, j, p, q, flag, ans;
int a[Max];

int main(){
	while(scanf("%lld %lld", &n, &m) == 2){
		if(m % n == 0) cout << n + m << endl;
		else cout << m - n << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n, k;
    int ans = 0;
    cin >> n >> k;

    int *h = new int[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }

    for (int i = 1; i <= n; i++) {
        if (h[i] >= k) {
            ans++;
        }
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
    vector<pair<ll, ll>> ap(n);
    ll a;
    rep(i,n) {
        cin >> a;
        ap[i] = make_pair(a, i);
    }
    sort(ap.begin(), ap.end());
    reverse(ap.begin(), ap.end());
    vector<vector<ll>> dp(n+1, vector<ll>(n+1));
    rep(i,n) rep(j,i+1) {
        dp[i+1][j]   = max(dp[i+1][j],   dp[i][j] + ap[i].first * abs(n-1 - (i-j) - ap[i].second));
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + ap[i].first * abs(ap[i].second - j));
    }
    ll ans = 0;
    rep(i,n+1) ans = max(ans, dp[n][i]);
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 34616
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    string aidu = "AIDUNYAN";
    string aizu = "AIZUNYAN";
    sort(aidu.begin(), aidu.end());

    string s;
    cin >> s;
    int n = s.size();
    int i = 0;
    while(i < n){
        string t = s.substr(i, aidu.size());
        sort(t.begin(), t.end());

        if(t == aidu){
            s.replace(i, aizu.size(), aizu);
            i += aidu.size();
        }
        else{
            ++ i;
        }
    }
    cout << s << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[]) {
  string A;
  int count[26] = {0};
  ll ans = 1;

  cin >> A;

  count[A[0] - 'a'] ++;
  FOR1(i, 1, A.size()) {
    ans += i - count[A[i] - 'a'];
    count[A[i] - 'a'] ++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char []s = sc.next().toCharArray();
		char []t = sc.next().toCharArray();
		
		int []c1 = new int [26 +'a'];
		int []c2 = new int [26 +'a'];
		
		for(int i = 'a' ; i < 26 +'a' ;i++) {
			c1[i] = -1;
			c2[i] = -1;
		}
		
		int n = s.length;
		int m = t.length;
		
		for(int i = 0 ; i < n ;i++) {
			c1[s[i]]++;
		}
		
		for(int i = 0 ; i < m ;i++) {
			c2[t[i]]++;
		}
		
		Arrays.sort(c1);
		Arrays.sort(c2);
		
		boolean flag = true;
		for(int i = 'a' ; i < 'a' + 26 ; i++) {
			if(c1[i] != c2[i]) {
				flag = false;
				break;
			}
		}
		
		if(flag) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
		
	}

}


Measured memory_bytes: 28776
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<ctime>
#define ll long long

using namespace std;
inline int Get() {int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}while('0'<=ch&&ch<='9') {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}return x*f;}

char s[100005];
int mid,n;
int top;
struct edge {
	int x,y;
};
int main() {
	scanf("%s",s+1);
	if(s[1]=='0') {cout<<-1;return 0;}
	n=strlen(s+1);
	mid=n/2;
	for(int i=1;i<=mid;i++) {if(s[i]!= s[n-i]) {cout<<-1;return 0;}}
	if(s[n]=='1') {cout<<-1;return 0;}
	int top=1;
	cout<<1<<' '<<2<<'\n';
	top=2;
	for(int i=2;i<n;i++) {
		if(s[i]=='1') {
			cout<<top<<" "<<i+1<<"\n";
			top=i+1;
		} else {
			cout<<top<<' '<<i+1<<"\n";
		}
	}
	
	return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<set>
#include<vector>
#include<array>
#include<algorithm>
#include<chrono>

int const INF = 1e9;

uint64_t xor64(void) {
  static uint64_t x = 88172645463325252ULL;
  x = x ^ (x << 7);
  return x = x ^ (x >> 9);
}

auto b_cl = std::chrono::system_clock::now();
inline double get_time() {
  auto e_cl = std::chrono::system_clock::now();
  double msec = std::chrono::duration_cast<std::chrono::milliseconds>(e_cl - b_cl).count();
  return msec;
}

struct state {
  int score_k;
  int type;
  int last[26];
  int score;
  std::vector<state>::iterator prev;
  bool operator< (state const& rhs) const { return score_k > rhs.score_k; } // reverse order
};

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int D; std::cin >> D;
  int c[26];
  for(auto& ci: c) std::cin >> ci;
  std::vector<std::array<int,26>> s(D);
  for(int d = 0; d < D; ++d) {
    for(auto& si: s[d]) std::cin >> si;
  }
  int const B = 750;
  int const K = 2;
  std::vector<int> t(D);
  
  std::vector<std::vector<state>> states(D+1);
  auto beam_step = [&](int d, int k) {
    auto& prev = states[d];
    auto& curr = states[d+1];
    curr.reserve(prev.size()*26);
    int dd = std::min(d+k, D-1);
    for(auto it = prev.begin(); it != prev.end(); ++it) {
      for(int T = 0; T < 26; ++T) {
        curr.push_back(*it);
        state& st = curr.back();
        st.prev = it;
        st.last[T] = d;
        st.type = T;
        st.score_k = st.score + s[d][T];
        for(int cx = 0; cx < 26; ++cx) {
          st.score_k -= c[cx]*(d+dd - 2*st.last[cx])*(dd-d+1)/2;
        }
      }
    }
    std::sort(curr.begin(), curr.end());
    if(curr.size() > B) curr.resize(B);
    for(auto& st: curr) {
      st.score += s[d][st.type];
      for(int cx = 0; cx < 26; ++cx) {
        st.score -= c[cx]*(d - st.last[cx]);
      }
    }
  };
  
  auto beam_search = [&](int k) {
    states.assign(D+1, std::vector<state>());
    states[0].emplace_back();
    states[0][0].score = 0;
    states[0][0].score_k = 0;
    std::fill_n(states[0][0].last, 26, -1);
    for(int d = 0; d < D; ++d) beam_step(d, k);
    auto it = states[D].begin();
    for(int d = D-1; d >= 0; it = it->prev, --d) {
      t[d] = it->type;
    }
  };
  beam_search(K);
  for(auto ti: t) std::cout << ti+1 << "\n";
  return 0;
}


Measured memory_bytes: 889076
//#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand rng
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define M_PI 3.14159265358979323846
typedef long long ll;



int main() {
	//fios;
	int n;
	cin >> n;
	int a = 0, b = 0, c = 0, d = 0;
	for(int i = 0; i < n; i++) {
		string str;
		cin >> str;
		if(str == "AC") a++;
		if(str == "WA") b++;
		if(str == "TLE") c++;
		if(str == "RE") d++;
	}
	cout << "AC x " << a <<endl;
	cout << "WA x " << b <<endl;
	cout << "TLE x " << c << endl;
	cout << "RE x " << d << endl;

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    ll n;
    cin >> n;
    int mn = 55;
    for (ll i = 1; i*i <= n; i++) {
        if (n%i == 0) {
            ll a = i, b = n/i;
            int f = 1+max(log10(a), log10(b));
            mn = min(mn, f);
        }
    }
    cout << mn << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
    static double e = 1e-8;
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while(true){
            int N=sc.nextInt();
            int M=sc.nextInt();
            int P=sc.nextInt();
            if(N+M+P==0)break;
            int[] a = new int[N];
            double sum=0;
            int s = 0;
            for (int i = 0; i < N; i++) {
                a[i]=sc.nextInt();
                sum+=a[i];
                s+=a[i];
            }
            if(a[M-1]==0){
                System.out.println(0);
                continue;
            }
            sum*=100;
            sum=sum*(100-P)/100.0;
            sum+=e;
            sum = sum/a[M-1];
            int ans = (int)(sum+e);
            System.out.println(ans);
            
        }
    }

}

Measured memory_bytes: 27724
#include<bits/stdc++.h>
#define ll long long
#define db long double
#define fi first
#define se second
#define  pb push_back
#define  pob pop_back
#define W while
#define fn(i,x) for(int i=0;i<x;i++)
#define fs(i,s,x) for(int i=s;i<x;i++)
#define fr(i,x) for(int i=x;i>=0;i--)
#define fit(it,s) for(auto it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 1000000007
#define MAX 1005
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    
    ll m,k;
    cin >> m >> k;
    vll v,v2;
    ll o =pow(2,m);
    for(int i=0;i<o;i++){
      v.pb(i);
      v2.pb(i);
    }
    if(k == 0){
      for(int i=0;i<v.size();i++) cout << v[i] << " " << v[i] << " ";
         return 0;
    }
    ll th = o-1;
    if(m==1 and k==1){
      cout <<"-1";
      return 0;
    }
    if(k > th){
      cout << "-1";
      return 0;
    }
    deque<ll> d;
    d.push_back(k);
    for(int i=0;i<v.size();i++){
       if(i!=k){
         d.push_back(v[i]);
         d.push_front(v[i]);
       }
    }
    d.pb(k);
    while(!d.empty()){
      cout << d.front() << " ";
      d.pop_front();

    }


    return 0;

}

Measured memory_bytes: 5996
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n-1;i>s;i--)
#define rep_re(i,s,n)for(ll i = n-1;i>=s;i--)
ll MOD = 1e9 + 7;

ll s[5];
ll c[5];
ll v[4]; 

int main() {
	ll n, m; cin >> n >> m;

	rep(i, 0, 4)v[i] = -1;

	rep(i, 0, m) {
		cin >> s[i] >> c[i];
	}

	rep(i, 0, m) {
		if (v[s[i]] != -1) {
			if (v[s[i]] != c[i]) {
				cout << -1 << endl;
				return 0;
			}
		}
		else {
			v[s[i]] = c[i];
		}
	}

	//rep(i, 1, 4) {
	//	if (v[i] == -1) {
	//		v[i] = 0;
	//	}
	//}

	//if (n == 3 && v[1] == 0 2] == 0||
	//	n == 2 && v[1] == 0) {
	//	cout << -1 << endl;
	//	return 0;
	//}

	if (n == 3) {
		if (v[1] == 0) {
			cout << -1 << endl;
			return 0;
		}
		if (v[1] == -1)v[1] = 1;
		if (v[2] == -1)v[2] = 0;
		if (v[3] == -1)v[3] = 0;

		cout << v[1]*100 + v[2]*10 + v[3] << endl;
	}
	else if (n == 2) {
		if (v[1] == 0) {
			cout << -1 << endl;
			return 0;
		}
		if (v[1] == -1)v[1] = 1;
		if (v[2] == -1)v[2] = 0;

		cout << v[1]*10 + v[2] << endl;
	}
	else if (n == 1) {
		if (v[1] == -1)v[1] = 0;
		cout << v[1]<< endl;
	}



	return 0;
}


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

int main(){
    int tri[11][11];
    char top[11];
    char o;
    while(cin >> o){
	tri[0][0] = o - '0' ;
	for(int i = 1; i <10; i++)
	{
	    cin >> top[i];
	    tri[0][i] = top[i] - '0';
	}
	int cont = 1;
	for(int i = 9; i > 0; i--){
	    for(int j = 0; j < i; j++){
		if(tri[cont-1][j] + tri[cont-1][j+1] > 9)
		    tri[cont][j] = tri[cont-1][j] + tri[cont-1][j+1] -10 ;
		else tri[cont][j] = tri[cont-1][j] + tri[cont-1][j+1];
	    }
	    cont++;
    }
	cout << tri[9][0] << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <stdlib.h>

#define MAX 100000

using namespace std;

int partition(int A[],int p,int r){

  int i;
  int j;
  int x;
  int temp;

  x = A[r];
  i = p-1;

  for(j = p;j < r;j++){
    if(A[j] <= x){
      i = i+1;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }

  temp = A[i+1];
  A[i+1] = A[r];
  A[r] = temp;
  return i+1;
}

int main(){

  int i;
  int n;
  int q;
  int *A;

  A = (int*)malloc(sizeof(int)*MAX);

  cin >> n;

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

  q = partition(A,0,n-1);

  for(i = 0;i < n-1;i++){
    if(i == q){
      cout << '[' << A[i] << "] ";
    }
    else{
      cout << A[i] << ' ';
    }
  }
  cout << A[n-1] << endl;

  free(A);

  return 0;
}

Measured memory_bytes: 1536
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int hill;
  vector<int> ar;
  for(int i=0;i<10;i++){
    cin >> hill;
    ar.push_back( hill );
  }
  sort( ar.begin() , ar.end() , greater<int>() ); // 降順ソート
  for(int i=0;i<3;i++){
    cout << ar[i] << endl;
  }
  ar.clear();
}

Measured memory_bytes: 1216
#include<stdio.h>
#include<stdlib.h>
#define ll long long
int asc(const void *a,const void *b){return *(long long *)b-*(long long*)a;}
int main(){
    ll x,y,a,b,c,i,ans=0;
    scanf("%lld%lld%lld%lld%lld",&x,&y,&a,&b,&c);
    ll p[a],q[b],r[c];
    for(i=0;i<a;i++) scanf("%lld",&p[i]);
    for(i=0;i<b;i++) scanf("%lld",&q[i]);
    for(i=0;i<c;i++) scanf("%lld",&r[i]);
    qsort(p,a,sizeof(long long),asc);
    qsort(q,b,sizeof(long long),asc);
    qsort(r,c,sizeof(long long),asc);
    ll to[a+b+c];
    for(i=0;i<x;i++) to[i]=p[i];
    for(;i<x+y;i++) to[i]=q[i-x];
    for(;i<x+y+c;i++) to[i]=r[i-x-y];
    qsort(to,i,sizeof(long long),asc);
    for(ll j=0;j<x+y;j++)
        ans+=to[j];
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 7660
def gcd(x, y):
    if x < y:
        return gcd(y, x)
    if y == 0:
        return x
    return gcd(y, x % y)
N = int(input())
A = list(map(int, input().split()))
B = [A[0]] * N
C = [A[N - 1]] * N
for i in range(N - 1):
    B[i + 1] = gcd(B[i], A[i + 1])
    C[N - i - 2] = gcd(C[N - i - 1], A[N - i - 2])
ans = max(B[N - 2], C[1])
for i in range(N - 2):
    ans = max(ans, gcd(B[i], C[i + 2]))
print(ans)

Measured memory_bytes: 14076
#include<bits/stdc++.h>
#define ll long long 
#define INF 1e9+5
using namespace std;
int min_cost(vector<int> &temp,int N,vector<int> &dp){
	dp[0] = 0 ; 
	dp[1] = abs(temp[1]-temp[0]); 
	for(int i = 2 ; i < N ; i++){
		dp[i] = min(dp[i-1]+abs(temp[i]-temp[i-1]),(dp[i-2]+abs(temp[i]-temp[i-2])));
	}
	return dp[N-1];
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int N ; 
	cin >> N ; 
	vector<int> temp(N,0); 
	vector<int> dp(N,INF);
	for(int i = 0 ; i <N ; i++){
		cin >> temp[i]; 
	}
	cout << min_cost(temp,N,dp); 
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    string s = in();
    vint v(30);
    for (char c : s)
    {
        ++v[c - 'a'];
    }
    rep(i, 26)
    {
        if (v[i] == 0)
        {
            cout << char(i + 'a') << endl;
            return;
        }
    }
    puts("None");
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for (int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

ll dp[16][2048];

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

    int N, K;
    cin >> N >> K;

    vector<P> vec(N);

    REP(i, N)
    {
        cin >> vec[i].fi >> vec[i].se;
    }

    vector<ll> acc[10];

    sort(ALL(vec), greater<P>());

    REP(i, 10)
    {
        acc[i].push_back(0);
    }

    REP(i, N)
    {
        acc[vec[i].se - 1].push_back(vec[i].fi);
    }

    REP(i, 10)
    {
        FOR(j, 1, acc[i].size())
        {
            acc[i][j] += acc[i][j - 1];
        }
    }

    REP(i, 10)
    {
        REP(j, acc[i].size())
        {
            acc[i][j] += j * (j - 1);
        }
    }

    memset(dp, -1, sizeof(dp));

    dp[0][0] = 0;

    REP(g, 10)
    {
        REP(i, K + 1)
        {
            REP(k, acc[g].size())
            {
                if(K < i + k) continue; 
                if(dp[g][i] == -1) continue;

                dp[g + 1][i + k] = max(dp[g + 1][i + k], dp[g][i] + acc[g][k]);
            }
        }
    }

    cout << dp[10][K] << endl;

    return 0;
}


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

void bubbleSort(int A[], int N) {
    int flag = 1;
    int count = 0;
    
    while(flag) {
        flag = 0;
        for (int j = N-1; j > 0; j--) {
            if (A[j] < A[j-1]) {
                swap(A[j], A[j-1]);
                count++;
                flag = 1;
            }
        }
    }
    
    for (int i=0; i<N; i++) {
        if (i != 0) cout << " ";
        cout << A[i];
    }
    cout << "\n" << count << "\n";
}   
    /*
1   bubbleSort(A, N) // N 個の要素を含む 0-オリジンの配列 A
2   flag = 1 // 逆の隣接要素が存在する
3   while flag
4     flag = 0
5     for j が N-1 から 1 まで
6       if A[j] < A[j-1]
7         A[j] と A[j-1] を交換
8         flag = 1
    */
    
int main() {
    int N, A[100];
    cin >> N;
    for(int i=0; i<N; i++) cin >> A[i];
    
    bubbleSort(A, N);
    
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"

ll g[3010][3010], dp[3010][3010][5];
int r,c,k,x,y;

ll solve(int rr, int cc, int cnt)
{
    if(rr>r || rr<1 || cc>c || c<1) return 0;
    if(dp[rr][cc][cnt]!= -1) return dp[rr][cc][cnt];

    ll ans=0;
    ans = max({solve(rr,cc+1,cnt), solve(rr+1, cc, 0), ans});
    if(cnt<3)
        ans = max({g[rr][cc]+solve(rr,cc+1,cnt+1), g[rr][cc]+solve(rr+1, cc, 0), ans});

    dp[rr][cc][cnt]=ans;
    return ans;
}
int main()
{
    memset(dp, -1, sizeof(dp));
    cin>>r>>c>>k;
    for(int i=0; i<k; i++)
    {
        cin>>x>>y;
        cin>>g[x][y];
    }

    cout<<solve(1,1,0);
}


Measured memory_bytes: 428544
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <stack>
#include <climits>

using namespace std;

#define rep(i,n,m) for(int i=n; i<=m; i++)
#define per(i,n,m) for(int i=n; i>=m; i--)
#define printi(x) printf("%d ", x)
#define printiln(x) printf("%d\n", x)
#define printiarray(a,n) for(int i=0; i<n-1; i++){printf("%d ", a[i]);} printf("%d\n", a[n-1])
#define scani(x) scanf("%d", &x)
#define scaniarray(a,n) for(int i=0; i<n; i++){scanf("%d", &a[i]);}
#define scans(str) scanf("%s",str)
#define scanc(ch) scanf("%c", &ch)

int main() {
    //INPUT
    int n, q;
    
    scani(n);
    int S[n];
    scaniarray(S,n);
    
    scani(q);
    int T[q];
    scaniarray(T,q);
    
    //SEARCH
    int count = 0;
    
    rep(i,0,q-1) {
        int r = n;
        int l = -1;
        int mid;
    	//printiln(T[i]);
        while(l+1 < r) {
            mid = (r+l) / 2;
        	//printi(l);
        	//printi(mid);
        	//printiln(r);
        	if(S[mid] == T[i]) {
            	//printf("found\n");
                count++;
                break;
            } 
        	if(S[mid] > T[i]) {
        		r = mid;
        		continue;
        	}
        	if(S[mid] < T[i]) {
        		l = mid;
        		continue;
        	}
              
        }
    	//printf("\n");
        
    }
    
    
    
    
    
    //OUTPUT
    printiln(count);
    
    
    
    return 0;
}


Measured memory_bytes: 3276
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main { 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		String[] line = sc.nextLine().split(" ");
		
		ArrayList<Integer> inputRowList = new ArrayList();
		for(int i = 0;i<line.length;i++) {
			inputRowList.add(Integer.parseInt(line[i]));
		}
		
		ArrayList<Integer> orderedList = (ArrayList<Integer>) inputRowList.clone();
		Collections.sort(orderedList);
		
		int count = 0;
		for(int i = 0;i<inputRowList.size();i++) {
			if(inputRowList.get(i) != orderedList.get(i)) {
				count++;
			}
		}
		
		String result = "";
		if(count <= 2) {
			result = "YES";
		}else {
			result = "NO";
		}
		System.out.println(result);
		
		
		
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

/* 
*/
//================== INPUT ========================
string S;
//=================================================
//=================================================
void input()
{
    cin >> S;
}
//=================================================

void solve()
{

    // dp[i][j] : i番目まで & あまりがj


    vector<vector<int>> dp(100003, vector<int>(13,0));
    int N = S.size();
    dp[0][0] = 1;
    for (int i = 0; i < N; ++i)
    {
        int num = ((S[i] == '?') ? (-1LL) : (S[i] - '0'));

        if (num == -1)
        {
            // S[i] : '?' の場合
            for (int j = 0; j < 10; ++j)
            {
                for (int k = 0; k < 13; ++k)
                {
                    dp[i][k] %= MOD;
                    dp[i + 1][(10 * k + j) % 13] += dp[i][k];
                }
            }
        }
        else
        {
            // S[i] : num の場合
            for (int k = 0; k < 13; ++k)
            {
                dp[i][k] %= MOD;
                dp[i + 1][(10 * k + num) % 13] += dp[i][k];
            }
        }
    }

    cout << (dp[N][5] % MOD) << endl;
}


//=================================================
signed main()
{
    input();
    solve();
    return 0;
}

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

public class MainApp
{

	static public void Main()
	{

		int[] a = Arrayint();
		int b = a[0];
		a[0] = a[1];
		a[1] = b;
		b = a[0];
		a[0] = a[2];
		a[2] = b;


		Console.WriteLine(a[0] + " " + a[1] + " " + a[2]);
	

	}


	private static string[] Arraystring()
	{
		return Console.ReadLine().Split(' ');
	}

	private static string Onestring()
	{
		return Console.ReadLine();
	}

	private static int Oneint()
	{
		return int.Parse(Console.ReadLine());
	}

	private static int[] Arrayint()
	{
		return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
	}
}

Measured memory_bytes: 11348
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>


using namespace std;


int main() {
	long long int A, B, C;
	string ans = "NO";

	cin >> A >> B >> C;
	
	for (int i = 1; i <= B; i++) {
		if (A * i % B == C) {
			ans = "YES";
			break;
		}
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 256
//In the name of God

#include <bits/stdc++.h>
using namespace std;

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

const int N = 1e5+10 , mod = 1e9+7 , K = 100;

int pw[N] , dp[N][K];

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   cout << fixed << setprecision(9);
   string s;
   int d;
   cin >> s >> d;
   int n = s.length();
   dp[0][0] = 1;
   for(int i = 1 ; i <= n ; i++){
      for(int j = 0 ; j < 10 ; j++){
         for(int k = 0 ; k < d ; k++)
            (dp[i][k] += dp[i - 1][((k - j) % d + d) % d]) %= mod;
      }
   }
   int ret = 0;
   int nw = 0;
   for(int i = 0 ; i < n ; i++){
      int x = s[i] - 48;
      for(int j = 0 ; j < x ; j++){
         int lst = nw;
         lst += j;
         lst %= d;
         ret += dp[n - 1 - i][(d - lst) % d];
         ret %= mod;
      }
      nw += x;
      nw %= d;
   }
   ret--;
   if(nw == 0)
      ret++;
   cout << (ret + mod) % mod;
   return 0;
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>

int main(void){
	double x1,y1,x2,y2,z,ans;

	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);

	z=pow(x1-x2,2)+pow(y1-y2,2);
	ans=pow(z,0.5);

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


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


using namespace std;

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

    cin >> a;

    while (a >= 500) {
        a -= 500;
        ans += 1000;
    }
    while (a >= 5) {
        a -= 5;
        ans += 5;
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=0;i<c;i++){
        if(i%2==0){
            if(a%2!=0)a--;
            a=a/2;
            b+=a;
        }else{
            if(b%2!=0)b--;
            b=b/2;
            a+=b;
        }
    }
    printf("%d %d\n",a,b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int N,A;cin>>N>>A;
  int x[60];
  for(int t=1;t<=N;t++)cin>>x[t];

  static lint dp[60][60][3000];   //dp[i][j][k]:=i枚目までにj枚選び、合計ｋになる選び方。
  memset(dp,0,sizeof(dp));
  for(int i=0;i<=N;i++)dp[i][0][0]=1;

  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      for(int k=0;k<=N*50;k++){

        if(x[i]>k){
          dp[i][j][k]=dp[i-1][j][k];
        }else{
          dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i]];
        }

      }
    }
  }

  lint ans=0;
  for(int t=1;t<=N;t++){
    ans+=dp[N][t][t*A];
  }

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


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

ll mod = 1000000007;

int main() {

    int N;
    Scd(N);
    vi a(N);
    Rep(i,N) Scd(a[i]);

    ll ans = 1;
    int cnt;
    vi r(3,0);
    Rep(i,N){
        cnt = 0;
        Rep(ri,3){
            if( r[ri] == a[i] ){
                if( !cnt ) r[ri]++;
                cnt++;
            }
        }
        ans *= cnt;
        ans %= mod;
    }

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

    return 0;
}



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

using namespace std;

typedef long long int ll;

const ll MAXN = 1e5 + 5;

vector < vector < ll > > adj(MAXN, vector < ll > ());
vector < bool > used(MAXN, false);
vector < ll > v;

void dfs(ll u){
  used[u] = true;
  for(auto to : adj[u]){
    if(!used[to]){
      dfs(to);
    }
  }
  v.push_back(u);
}

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

  ll n, m;
  cin >> n >> m;
  for(int i = 0; i < n + m - 1; i++){
    ll u, v;
    cin >> u >> v;
    adj[u].push_back(v);
  }

  for(int i = 1; i <= n; i++){
    if(!used[i]){
      dfs(i);
    }
  }
  reverse(v.begin(), v.end());

  vector < ll > ans(n + 1, 0);
  for(int i = n - 1; i >= 0; i--){
    for(auto to : adj[v[i]]){
      if(ans[to] == 0){
        ans[to] = v[i];
      }
    }
  }

  for(int i = 1; i <= n; i++) cout << ans[i] << endl;
}


Measured memory_bytes: 11252
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
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;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;
using namespace atcoder;

void solve(){
	int n,m;
	cin>>n>>m;
	vector<ll>a(n),b(m);
	rep(i,n)cin>>a[i];
	rep(i,m)cin>>b[i];
	auto v=convolution<998244353>(a,b);
	rep(i,n+m-2+1){
		if(i)cout<<" ";
		cout<<v[i];
	}
	cout<<"\n";
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 27296
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int N;

void _main() {
  cin >> N;
  int ans = 1;
  while (ans * 2 <= N) ans *= 2;
  cout << ans << "\n";
}

Measured memory_bytes: 256
import sys

def main():
	input = sys.stdin.readline

	N = int(input().strip())
	S = list(map(int,input().strip().split()))

	S.sort(reverse=True)
	parent = S[0]

	numlist = []
	for i in range(N):
		numlist.append(2**i)

	count = [0 for i in range(N)]
	countcom = [1 for i in range(N)]

	slime = []
	for i in range(N):
		temp = [0 for i in range(2**i)]
		slime.append(temp)
		slime[i][0] = parent

	ans = 'Yes'
	for i in range(1,2**N):
		flag = False
		for level in range(N):
			if count[level]<numlist[level]:
				if slime[level][count[level]]>S[i]:
					flag = True
					count[level] = count[level]+1
					levelt = level+1
					while levelt<=N-1:
						slime[levelt][countcom[levelt]] = S[i]
						countcom[levelt] = countcom[levelt]+1
						levelt = levelt+1
					break

		if flag==False:
			ans = 'No'
			break

	print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 103628
#include <stdio.h>
int main()
{
    int a,b,c,x,y;
    scanf("%d %d %d", &a, &b, &c);
    x=b-a;
    y=c-b;

    if(x==y)
    {
        printf("YES");
    }
    else{
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 2116
h, w = gets.chomp.split.map(&:to_i)
# 回数が偶数か奇数かで分けられる 奇数->裏返し 偶数->変わらず
# 奇数になるのはどちらも3以上のときorいずれかが1のとき
# 前者では外周以外が奇数になる
if h==1 && w == 1
  puts 1
elsif h==1 || w==1
  puts [h, w].max-2
elsif h==2 || w==2
  puts 0
else
  puts h*w-(2*w+2*(h-2))
end

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
     ll a,b;
     cin>>a>>b;
     ll i,j;
     ll ans=0;
     for(i=a; i<=b ;i++)
     {
         string s = to_string(i);
         ll flag=0;
         for(j=0;j<s.length()/2;j++)
         {
             if(s[j]!=s[s.length()-j-1])
             {
                 flag=1;
                 break;
             }
         }
         if(flag==0)
         {
             ans++;
         }

    }

    cout<<ans;
}


Measured memory_bytes: 256