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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];

bool X[N][N];

void initialize() {
    for ( int i = 0; i < N; i++ ) { row[i] = FREE; col[i] = FREE; }
    for ( int i = 0; i < 2 * N - 1; i++ ) { dpos[i] = FREE; dneg[i] = FREE; }
}

void printBoard() {
    for ( int i = 0; i < N; i++ ) {
        for ( int j = 0; j < N; j++ ) {
            if ( X[i][j] ) {
                if ( row[i] != j ) return;
            }
        }
    }
    for ( int i = 0; i < N; i++ ) {
        for ( int j = 0; j < N; j++ ) {
            cout << ( ( row[i] == j ) ? "Q" : "." );
        }
        cout << endl;
    }
}

void recursive(int i) {
    if ( i == N ) {
        printBoard(); return;
    }
    
    for ( int j = 0; j < N; j++ ) {
        if ( NOT_FREE == col[j] ||
             NOT_FREE == dpos[i + j] ||
             NOT_FREE == dneg[i - j + N - 1]) continue;
        row[i] = j; col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
        
        recursive(i + 1);
        
        row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
    }
}

int main() {
    initialize();
    
    for ( int i = 0; i < N; i++ )
      for ( int j = 0; j < N; j++ ) X[i][j] = false;
      
    int k; cin >> k;
    for ( int i = 0; i < k; i++ ) {
        int r, c; cin >> r >> c;
        X[r][c] = true;
    }
    
    recursive(0);
    
    return 0;
}


Measured memory_bytes: 3124
#include<stdio.h>

int main(){
    int a=0;
    int b=0;
    scanf("%d %d",&a,&b);
    if(a>b)
        printf("a > b\n");
    else if(a<b)
        printf("a < b\n");
    else
        printf("a == b\n");
    return 0;
}

Measured memory_bytes: 1776
def main():
    line = list(map(int,input().split()))
    H1 = line[0]
    M1 = line[1]
    H2 = line[2]
    M2 = line[3]
    K = line[4]
    h = H2-H1
    m = M2 - M1
    if m < 0:
        h -= 1
        m %= 60
    k = h*60+m-K
    print(k)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9188
#include<bits/stdc++.h>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
//lower_bound like o_set.find_by_order(val) strictly less then val
//upper_bound like o_set.order_of_key(MAX)– o_set.order_of_key(val)
//if u need multiset elements then use second parameter as time and think 
//typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define se second
#define fi first
#define pai acos(-1)
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x,s) for(i=x;i>=s;i--)
#define fit(itr,s) for(itr=s.begin();itr!=s.end();itr++)
#define W while
#define pp pair<ll,ll>
#define ppi pair<int,int>
#define vl vector<ll>
#define vll vector<pp >
#define vi vector<int>
#define vii vector<ppi>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#define boost  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const int MAX=2e5+5;
const ll MM=1e16;
const ll mod=998244353;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

ll expo(ll x,ll n,ll M=mod)
{
    ll ans=1;
    while(n>0)
    {
        if(n&1){ans=(ans*x)%M;}
                x=(x*x)%M;
                n>>=1;
    }
    return ans;
}

void solve()
{
    ll n,m,i,j,k;
    cin>>n;
    vl a(n);
    fn(i,n)cin>>a[i];
    sort(all(a));
    reverse(all(a));
    ll ans=0,count=1;
    ans+=a[0];
    if(count==(n-1))
    {cout<<ans<<endl;return;}
    fs(i,1,n)
    {
        
        ans+=a[i];
        count++;
        if(count==(n-1))break;
        ans+=a[i];
        count++;
        if(count==(n-1))break;
    }
    cout<<ans<<endl;
}

int main()
{
  boost;
  ll t=1;
// cin>>t;
  while(t--)
  {
      solve();
  }
}


Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<vector<int>> x(N), y(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        for (int j = 0; j < A[i]; j++) {
            int a, b;
            cin >> a >> b;
            a--;
            x[i].push_back(a);
            y[i].push_back(b);
        }
    }

    int ans = 0;
    for (int bit = 0; bit < (1 << N); bit++) {
        bool flag = true;
        for (int i = 0; i < N; i++) {
            int mask = (1 << i);
            if (mask & bit) {  // i 番目が正直だと仮定
                for (int j = 0; j < A[i]; j++) {
                    if (y[i][j] == 1) {
                        if ((bit & (1 << x[i][j])) == 0) {
                            flag = false;
                        }
                    } else {
                        if ((bit & (1 << x[i][j])) > 0) {
                            flag = false;
                        }
                    }
                }
            }
        }
        if (flag) {
            chmax(ans, __builtin_popcount(bit));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
#include <map>

template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

using lint = long long;

void solve() {
    int n;
    std::cin >> n;

    std::map<std::pair<lint, lint>, std::vector<int>> cnt;
    mint zero = 0;

    while (n--) {
        lint x, y;
        std::cin >> x >> y;

        if (x == 0 && y == 0) {
            zero += 1;
            continue;
        }

        if (x < 0 || (x == 0 && y < 0)) {
            x = -x, y = -y;
        }

        int side = 0;
        if (y <= 0) {
            side = 1;
            auto nx = -y;
            auto ny = x;
            x = nx, y = ny;
        }

        if (x == 0) {
            y /= y;
        } else if (y == 0) {
            x /= x;
        } else {
            auto g = std::gcd(x, y);
            x /= g, y /= g;
        }

        auto p = std::make_pair(x, y);
        if (!cnt.count(p)) cnt[p] = std::vector(2, 0);
        cnt[p][side] += 1;
    }

    mint ans = 1;
    for (const auto& p : cnt) {
        ans *= mint(2).pow(p.second[0]) + mint(2).pow(p.second[1]) - 1;
    }
    ans += zero;

    std::cout << ans - 1 << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 25392
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

#ifdef EBUG
#define debug(x) cout << "\033[31m" << #x << ": " << x << "\033[0m\n";
#else
#define debug(x)
#endif

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

ll x, y;
int main() {
  cin >> x >> y;
  // 2 * (x - k) + 4 * k == y
  rep(i, x + 1) {
    if (2 * (x - i) + 4 * i == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#define ll long long
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  int arr1[]={1,3,5,7,8,10,12};
  int arr2[]={4,6,9,11};
  int arr3[]={2};
  int a,b;
  cin >> a >> b;
  if(a==2 || b==2)
    cout << "No" << endl;
  else
  {
    int p=0,q=0;
    for(int i=0;i<7;i++)
    {
      if(arr1[i]==a)
        p=1;
    }
    for(int i=0;i<7;i++)
    {
      if(arr1[i]==b)
        q=1;
    }
    if(q==1 && p==1)
      cout << "Yes" << endl;
    else
    {
      int r=0,s=0;
      for(int j=0;j<4;j++)
      {
        if(arr2[j]==a)
          r=1;
      }
      for(int j=0;j<4;j++)
      {
        if(arr2[j]==b)
          s=1;
      }
      if(r==1 && s==1)
        cout << "Yes" << endl;
      else
        cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main{
        public static void main(String[]args){
                Scanner scan = new Scanner(System.in);
                int n = scan.nextInt();scan.nextLine();
                String s = scan.nextLine();
                int sLength = 1;
                for(int i = 0; i < n-1; i++){
                        if(s.charAt(i) != s.charAt(i+1)){
                                sLength++;
                                }
                        }
                System.out.println(sLength);
                }
        }


Measured memory_bytes: 26316
/* ABC139-B
   Takatan */

#include<stdio.h>
int main(void){
    int plug, need, count;
    count = 0;

    scanf( "%d %d" , &plug, &need);
    
    while(need>1){
        need = need - plug + 1;
        count++;
    }

    printf( "%d\n" , count);
}

Measured memory_bytes: 128
#include<stdio.h>
const int INFTY = 2000000000;
int cnt=0;

void show(int *S, int &n){
	for(int i=0; i<n; ++i){
		if(i>0)
			printf(" ");
		printf("%d", S[i]);
	}	
}

void merge(int *S, int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;

	int L[n1+1];
	int R[n2+1];

	for(int i=0; i<n1; ++i){
		L[i] = S[left + i];
	}
	for(int i=0; i<n2; ++i){
		R[i] = S[mid + i];
	}
	L[n1] = INFTY;
	R[n2] = INFTY;
	int i = 0;
	int j = 0;

	for(int k=left; k<right; ++k){
		cnt += 1;
		if(L[i] <= R[j]){
			S[k] = L[i];
			i += 1; 
		}else{
			S[k] = R[j];
			j += 1;
		}
	}
}

void mergeSort(int *S, int left, int right){
	if(left + 1 < right){
		int mid = (left + right) / 2;
		mergeSort(S, left, mid);
		mergeSort(S, mid, right);
		merge(S, left, mid, right);
	}
}

int main(){
	int n;
	scanf("%d", &n);

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

	mergeSort(S, 0, n);
	show(S, n);
	printf("\n%d\n", cnt);

	return 0;
}


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

int N,dp[150000],V[150000];

int main(){	
	cin>>N;
	dp[0]=0;
	dp[1]=0;
	V[0]=150000;
	for(int i=1;i<=N;i++)
	cin>>V[i];
	for(int i=2;i<=N;i++)
	{
		dp[i]=min(dp[i-1]+abs(V[i]-V[i-1]),dp[i-2]+abs(V[i]-V[i-2]));
	}
	cout<<dp[N];
}

Measured memory_bytes: 1024
data = input().split()
x = int(data[0])
n = int(data[1])

p = input().split()
for i in range(n):
	p[i] = int(p[i])

if n == 0:
	print(x)
	exit()
if not x in p:
	print(x)
	exit()

for i in range(102)[1:]:
	if not (x-i) in p:
		print(x-i)
		exit()
	elif not (x+i) in p:
		print(x+i)
		exit()


Measured memory_bytes: 9200
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
ll dp[N];
int solve() 
{
	//happy coding

	int n,k;
		cin>>n>>k;
		ll a[n+2];
		for(int i=1;i<=n;i++){
			cin>>a[i];
		}

		dp[1] = 0;
		for(int i=2;i<=min(n,k+1);i++){
			dp[i] = abs(a[i]-a[1]);
		}
		//cout<<dp[2]<<endl;
		for(int i=k+2;i<=n;i++){
			ll mn = INT_MAX;
			for(int j=i-1;j>=i-k;j--){
				mn = min(mn, dp[j]+abs(a[j]-a[i]));
			}

			dp[i] = mn;
		}

		cout<<dp[n]<<endl;


	
	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const int INF = 1001001000;
const double EPS = 0.000000001;

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

bool pC(const P& pair1, const P& pair2) {
    return pair1.second > pair2.second;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  VI a(m);
  VI b(m);
  VI cost(m);
  VVI d(n, VI(n, INF));
  REP(i, n){
    d[i][i] = 0;
  }
  REP(i, m){
    cin >> a[i] >> b[i] >> cost[i];
    a[i]--; b[i]--;
    d[a[i]][b[i]] = cost[i];
    d[b[i]][a[i]] = cost[i];
  }

  for(int k = 0; k < n; k++){
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
  }
  int ans = m;
  REP(i, m){
    bool flag = false;
    REP(j, n){
      if(d[j][a[i]] + cost[i] == d[j][b[i]]) flag = true;
    }
    if(flag) ans--;
  }

  out(ans);


  return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
)

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

func perf(rem, i, pi, ci int) int {
	return min(rem, (i+1)*100*pi+ci) / pi
}

func main() {
	var D, G int
	fmt.Scan(&D, &G)
	ps := make([]int, D)
	cs := make([]int, D)
	for i := range ps {
		fmt.Scan(&ps[i])
		fmt.Scan(&cs[i])
	}

	ans := G
	for mask := 0; mask < 1<<uint(D); mask++ {
		rest_max := -1
		s := 0
		num := 0
		for i := 0; i < D; i++ {
			if mask>>uint(i)&1 == 1 {
				s += 100*(i+1)*ps[i] + cs[i]
				num += ps[i]
			} else {
				rest_max = i
			}
		}
		if s < G {
			s1 := 100 * (rest_max + 1)
			need := (G - s + s1 - 1) / s1
			if need >= ps[rest_max] {
				continue
			}
			num += need
		}
		ans = min(ans, num)
	}
	fmt.Println(ans)
}


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

long long int n, arr[405], cvp, dp[405][405];

long long int sum(int a, int b){
	long long int res=0;
	for(int i=a;i<=b;i++)res+=arr[i];
		return res;
}

int main(void){
	cin>>n;
	for(int i=0;i<n;i++)cin>>arr[i];
	for(int i=0;i<n;i++){
		dp[i][i]=0;
		for(int j=i-1;j>-1;j--){
          dp[j][i]=-1;
          long long int pre=sum(j, i);
			for(int h=j;h<i;h++){
				if(dp[j][i]!=-1)dp[j][i]=min(dp[j][i], dp[j][h]+dp[h+1][i]+pre);
				else dp[j][i]=dp[j][h]+dp[h+1][i]+pre;
            }

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


Measured memory_bytes: 1536
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[8]={1,1,0,-1,-1,-1,0,1};
const int dy[8]={0,1,1,1,0,-1,-1,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w; cin >> h >> w;
    vector<string> f(h); for(auto& e : f) cin >> e;

    rep(y, h){
        rep(x, w){
            if(f[y][x] == '#') continue;

            int cur = 0;
            rep(i, 8){
                int xx = x + dx[i];
                int yy = y + dy[i];
                if(xx < 0 or w <= xx or
                   yy < 0 or h <= yy) continue;

                if(f[yy][xx] == '#') cur++;
            }

            f[y][x] = (char)('0' + cur);
        }
    }

    for(auto& e : f){
        cout << e << endl;
    }
    

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int  mx=310;
long double dp[310][310][310];
 int main()
 {int n;
 cin>>n;
     int cnt1=0,cnt2=0,cnt3=0;
     int a[n];
     for(int i=0;i<n;i++)
     {
         cin>>a[i];
     }
     for(int i=0;i<n;i++)
     {
         if(a[i]==1)
         {cnt1+=1;}
         if(a[i]==2)
         {cnt2+=1;}
         if(a[i]==3)
         {cnt3+=1;}
     }
    
  
     {  for(int k=0;k<mx;k++)
         
         {
           
             for(int j=0;j+k<mx;j++ )
             {
             
        
                 for(int i=0;i+j+k<mx;i++)
                 {	if(i+j+k>mx)
             	continue;
             	if(i==0&&j==0&&k==0)
             	continue;
                 	
                 	dp[i][j][k]+=n*1.0/(i+j+k);
                 if(i)
                 dp[i][j][k]+=dp[i-1][j][k]*(i*1.0/(i+j+k));
                 if(j)
                 dp[i][j][k]+=dp[i+1][j-1][k]*(j*1.0/(i+j+k));
                 if(k)
                 dp[i][j][k]+=dp[i][j+1][k-1]*(k*1.0/(i+j+k));}
             }
         }
     }
     cout<<setprecision(10)<<dp[cnt1][cnt2][cnt3];

     
 }

Measured memory_bytes: 465152
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int input = sc.nextInt();
    
    if(input % 2 == 0) System.out.println(input * input / 4);
    else System.out.println((int)(input/2) * (input+1)/2);
  }
}

Measured memory_bytes: 21972
#include"bits/stdc++.h"
using namespace std;

int main()
{
  //**整数の入力
  int A,B;
  cin >> A >> B;
  
  //**計算
  if(A+B >= A-B){
    if(A+B >= A*B){
      cout << (A+B) << endl;}
    else{
      cout << (A*B) << endl;}
  }else{
    if(A-B >= A*B){
      cout << (A-B) << endl;}
    else{
      cout << (A*B) << endl;}
  }
  return 0;
}

  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T,typename U> 
using gmap = cc_hash_table<T, U, hash<T> >;

//INSERT ABOVE HERE
signed AGC023_A(){
  using ll = long long;
  int n;
  scanf("%d",&n);
  vector<ll> a(n);
  for(int i=0;i<n;i++) scanf("%lld",&a[i]);

  unordered_map<ll, ll> m;
  ll ans=0,s=0;
  m[s]++;
  for(int i=0;i<n;i++){
    s+=a[i];
    ans+=m[s];
    m[s]++;
  }

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

signed main(){
  AGC023_A();
  return 0;
}


Measured memory_bytes: 10056
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M = LI()
    ab = [LI_() for _ in range(M)]
    ab.sort(key=lambda x: x[1])

    # 区間スケジューリング
    ans = 0
    # print(ab)
    right = -1
    for a, b in ab:
        if right <= a:
            right = b
            ans += 1

    print(ans)

if __name__ == '__main__':
    resolve()


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

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

int main(){
  int64_t A, B, K;
  cin >> A >> B >> K;

  cout << max(int64_t(0), A-K) << " " << max(int64_t(0), B-max(int64_t(0), K-A));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<int> vi;

signed main(){
    string T,P;
    bool c;
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> T >> P;
    rep(i,(int)T.size()-(int)P.size()+1) {
        c = true;
        for(int j=0;j<(int)P.size();j++) {
            if(T[i+j]!=P[j]) {
                c = false;
                break;
            }
        }
        if(c) {
            cout << i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3252
#include <stdio.h>
#include <stdlib.h>

#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	if(a >= 0){
		return a % p;
	}
	else{
		return p + a % p;
	}
}
/*
int power(int a, int n){
	if(n == 0){
		return 1;
	}
	else if(n % 2 == 1){
		return MOD(a * power(a, n - 1));
	}
	else{
		return power(MOD(a * a), n / 2);
	}
}

int inverse(int a){
	return power(a, p - 2);
}*/

typedef struct {
	int x;
	int y;
}pair;

//a ≠ 0 かつ b / a ≠ 0 を仮定
pair inverse_sub(int a, int b){
	pair ans, sub;
	if(a == 1){
		ans.x = 1;
		ans.y = 0;
	}
	else{
		sub = inverse_sub(b % a, a);
		ans.x = MOD(sub.y - (b / a) * sub.x);
		ans.y = sub.x;
	}
	return ans;
}

int inverse(int a){
	return inverse_sub(a, p).x;
}

signed main(){
	int n, a, i, l, r, ans;
	scanf("%lld", &n);
	int *aplace = (int *)malloc(sizeof(int) * n);
	for(i = 0; i < n; i++){
		aplace[i] = -1;
	}
	for(i = 0; i <= n; i++){
		scanf("%lld", &a);
		a--;
		if(aplace[a] != -1){
			l = aplace[a];
			r = i;
		}
		aplace[a] = i;
	}
	int *fact = (int *)malloc(sizeof(int) * (n + 2));
	int *fact_inv = (int *)malloc(sizeof(int) * (n + 2));
	fact[0] = 1;
	fact_inv[0] = 1;
	for(i = 1; i <= n + 1; i++){
		fact[i] = MOD(i * fact[i - 1]);
		fact_inv[i] = inverse(fact[i]);
	}/*
	for(i = 0; i <= n + 1; i++){
		printf("fact[%lld] = %lld\n", i, fact[i]);
	}
	printf("\n");
	for(i = 0; i <= n + 1; i++){
		printf("fact_inv[%lld] = %lld\n", i, fact_inv[i]);
	}
	printf("\n");
	for(i = 0; i <= n + 1; i++){
		printf("fact[%lld] * fact_inv[%lld] = %lld\n", i, i, MOD(fact[i] * fact_inv[i]));
	}
	printf("\n");
	printf("(l, r) = (%lld, %lld)\n", l, r);*/
	for(i = 1; i <= n + 1; i++){
		ans = MOD(fact[n + 1] * MOD(fact_inv[i] * fact_inv[n + 1 - i]));
		if(l + n - r >= i - 1){
			ans = MOD(ans - MOD(fact[l + n - r] * MOD(fact_inv[i - 1] * fact_inv[l + n - r - i + 1])));
		}
		printf("%lld\n", ans);
	}
}

Measured memory_bytes: 3456
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T, typename U> inline void chmax(T &x, U y) { if (x < y) x = y; }
template<typename T, typename U> inline void chmin(T &x, U y) { if (x > y) x = y; }


int main() {
    string s;
    cin >> s;
    int x = 0, y = 0;
    for (auto&& c : s) {
        if (c == 'S') {
            x++;
        }
        else {
            if (x > 0) x--;
            else y++;
        }
    }
    printf("%d\n", x + y);

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

#define NUM 3

int main()
{
	char s[NUM] = {};
	int count=0;

	for (int i=0; i<NUM; i++) {
		scanf("%c", &s[i]);
		if ('1' == s[i]) {
			count++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 128
n = int(input())
dat = []
import fractions

for i in range(n):
    a, b = map(int, input().split())
    c = fractions.gcd(a, b)
    #a, b = a // c, b // c # 約分する
    dat.append( (a, b) )

a, b = 1, 1

import math
for i in range(n):
    x, y = dat[i]
    c = max( (a + x - 1) // x, (b + y - 1) // y)
    #print("{0},{1}: c= {4} : {2},{3}".format(x, y, a,b,c))
    a, b = x * c, y * c
print(a + b)


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

#define int long long 

const int N = 2e5 + 10;

class union_find {
public:
	vector<int> par;
	vector<int> size;
	int components = 0;

	union_find(int n) {
		if (n > 0) {
			init(n);
		}
	}

	void init(int n) {
		par.resize(n + 1, 1);
		size.assign(n + 1, 1);
		components = n;
		for (int i = 0; i <= n; i++) {
			par[i] = i;
		}
	}

	int find(int x) {
		if (par[x] == x) {
			return x;
		}
		return par[x] = find(par[x]);
	}

	void merge(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return;
		if (size[x] < size[y]) swap(x, y);
		components--;
		size[x] += size[y], par[y] = x;
	}
};

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    int n, m; cin >> n >> m;
    union_find dsu(n);

    for (int i = 0; i < m; i++) {
    	int u, v;
    	cin >> u >> v;
    	--u, --v;
    	dsu.merge(u, v);
    }
    int max_groups = 0;
    for (int i = 0; i < n; i++) {
    	int cur = dsu.find(i);
    	max_groups = max(max_groups, dsu.size[cur]);
    }
    cout << max_groups << endl;
}

Measured memory_bytes: 6372
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")
 
#include <bits/stdc++.h>
using namespace std;
 
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
// #define ost tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define    int                      long long int
#define    ld                       long double
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL),cout.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int ttt; cin >> ttt; while(ttt--)
#define    ff                       first
#define    ss                       second
#define    all(container)            container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    sp(x)                    setprecision(x)
#define    bp(x)                    __builtin_popcount(x)
#define    endl                     "\n"
int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

int32_t main()
{
    speed upp
    int n,m,x,y;
    cin>>n>>m;
    vector<int>v[n+1];
    int a[n+1];
    f(i,1,n)
        cin>>a[i];
    f(i,1,m)
    {
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    int ans=0;
    f(i,1,n)
    {
        if(sz(v[i])==0)
            ans++;
        else
        {
            int c=1;
            f(j,0,sz(v[i])-1)
                if(a[i]<=a[v[i][j]])
                    c=0;
            if(c)
                ans++;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 10252
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long mod_pow(long long a,long long n)
{
    if(n==0)
        return 1;
    long long p=mod_pow(a,n/2);
    long long a1=(p*p)%mod;
    if(n%2)
        return a*a1;
    else return a1;
}

int main()
{
    string s,t;
    cin>>s>>t;
    long long count1=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]==t[i])
            count1++;
    }
    cout<<count1;
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 112345;
vector<int> g[MAX_N];
int deg[MAX_N];
int dp[MAX_N];

int main2() {
  REP(i, MAX_N) g[i].clear();
  CLR(deg, 0);
  CLR(dp, 0);

  int N = nextInt();
  int M = nextInt();
  REP(i, M) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;
    g[a].push_back(b);
    ++deg[b];
  }

  queue<int> q;
  REP(i, N) if (deg[i] == 0) {
    q.push(i);
  }
  while (!q.empty()) {
    int cur = q.front(); q.pop();
    for (int nxt : g[cur]) {
      chmax(dp[nxt], dp[cur] + 1);
      if (--deg[nxt] == 0) {
        q.push(nxt);
      }
    }
  }

  int ans = *max_element(dp, dp + N);
  cout << ans << endl;

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;

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

const string abc = "ABC";

int main() {
    int n;
    string s;
    cin >> n >> s;

    int ans = 0;
    for(int i = 0; i < n; ++i){
        int cnt = 0;
        for(int j = 0; j < abc.size(); ++j){
            if(s[i + j] == abc[j]){
                cnt++;
            }
        }
        if(cnt == 3){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
const double pi = 3.14159265359;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n, m;
char a[111][111];
char b[111][111];

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

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

	for (int i = 0;i < m;i++) {
		for (int j = 0;j < m;j++) {
			cin >> b[i][j];
		}
	}

	int flag = 0;

	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n;j++) {
			flag = 1;
			for (int ii = 0;ii < m;ii++) {
				for (int jj = 0;jj < m;jj++) {
					if (a[i + ii][j + jj] != b[ii][jj]) flag = 0;
				}
			}
			if (flag) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long int;

ll mygcd(ll a, ll b){
    if(a < b){
        ll tmp = a;
        a = b;
        b = tmp;
    }

    while(b > 0){
        int r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int main(){
    ll a, b;
    cin >> a >> b;
    ll gcdab = mygcd(a, b);
    cout << gcdab * (a/gcdab) * (b/gcdab) << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

typedef pair<int, string> P;

map<string, P> fam;

vector<string> s;
vector<string> name;
int N, Q;

void output(){
  string op;
  for(int i = 0 ; i < Q ; i++){
    string relation, X, Y;
    for(int j = 0 ; j < 6 ; j++){
      cin >> op;
      if(j == 0) X = op;
      if(j == 3) relation = op;
      if(j == 5) Y = op;
    }
    Y.erase(Y.end()-1);
    
    if(relation == "parent"){
      relation = "child";
      swap(X, Y);
    }
    if(relation == "descendant"){
      relation = "ancestor";
      swap(X, Y);
    }
    
    bool ans = false;
    
    if(relation == "child"){
      ans = fam[X].second == Y;
    }
    else if(relation == "ancestor"){
      while(fam[Y].first != 0){
	if(fam[Y].second == X){
	  ans = true;
	  break;
	}
	Y = fam[Y].second;
      }
    }
    else if(relation == "sibling"){
      int gen = fam[Y].first;
      string par = fam[Y].second;
      for(map<string, P>::iterator it = fam.begin() ; it != fam.end() ; it++){
	if(it->first == X){
	  if(it->second.first == gen && it->second.second == par){
	    ans = true;
	    break;
	  }
	}
      }
    }
    if(ans) cout << "True" << endl;
    else cout << "False" << endl;
  }
}

int main(){
  while(cin >> N >> Q, N|Q){
    fam.clear();
    s.clear();
    name.clear();
    cin.ignore();
    string tmp;
    for(int i = 0 ; i < N ; i++){
      getline(cin, tmp);
      s.push_back(tmp);
    }
    
    name = s;
    
    for(int i = 0 ; i < N ; i++){
      while(name[i][0] == ' ') name[i].erase(name[i].begin());
      /*
      for(int j = 0 ; j < (int)name[i].size() ; j++){
	if(name[i][j] == ' ') name[i].erase(name[i].begin()+j);
      }
      */
    }
    
    for(int i = 0 ; i < N ; i++){
      int gen = 0;
      for(int j = 0 ; j < (int)s[i].size() ; j++){
	if(s[i][j] != ' ') break;
	gen++;
      }
      for(int j = i ; j >= 0 ; j--){
	if(s[j][gen-1] != ' '){
	  fam[ name[i] ] = P(gen, name[j]);
	  break;
	}
      }
    }
    
    output();
    cout << endl;
    /*
    for(map<string, P>::iterator it = fam.begin() ; it != fam.end() ; it++){
      cout << it->first << ' ' << it->second.first << ' ' << it->second.second << endl;
    }
    */
  }
  return 0;
}

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

int main() {
    string sdash, t;
    cin >> sdash >> t;

    int sl = sdash.length();
    int tl = t.length();
    
    string ans = "UNRESTORABLE";

    for (int i = 0; i + tl - 1 < sl; i++) {
        string c;
        for (int j = 0; j < sl; j++) {
            if (i <= j && j <= i + tl - 1) {
                if (sdash[j] != '?' && sdash[j] != t[j - i]) break;
                else c += t[j - i];
            } else {
                if (sdash[j] == '?') c += 'a';
                else c += sdash[j];
            }
        }
        if (c.length() == sl && (ans == "UNRESTORABLE" || ans > c)) ans = c;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384626433832795

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

struct node {
	int p = -1, s = -1, deg = 0, dep = -1, h = -1;
	vi c;
};

vector<node> G;
vector<int> record;
vector<bool> visited;

void presearch(int n) {
	cout << " " << n;
	if (G[n].c[0] != -1) {
		presearch(G[n].c[0]);
	}
	if (G[n].c[1] != -1) {
		presearch(G[n].c[1]);
	}
}
void inosearch(int n) {
	if (G[n].c[0] != -1) {
		inosearch(G[n].c[0]);
	}
	cout << " " << n;
	if (G[n].c[1] != -1) {
		inosearch(G[n].c[1]);
	}
}
void possearch(int n) {
	if (G[n].c[0] != -1) {
		possearch(G[n].c[0]);
	}
	if (G[n].c[1] != -1) {
		possearch(G[n].c[1]);
	}
	cout << " " << n;
}
int main() {
	int n, ina, inb, inc;
	cin >> n;
	G.resize(n);
	rep(i, n) {
		cin >> ina >> inb >> inc;
			G[ina].c.push_back(inb);
		if (inb != -1) {
			G[inb].p = ina;
		}
		G[ina].c.push_back(inc);
		if (inc != -1) {
			G[inc].p = ina;
		}
		if (inb!=-1&&inc!=-1) {
			G[inc].s = inb;
			G[inb].s = inc;
		}
	}
	rep(i, n) {
		if (G[i].p == -1) {
			cout << "Preorder" << endl;
			presearch(i);
			cout << endl << "Inorder" << endl;
			inosearch(i);
			cout << endl<< "Postorder" << endl;
			possearch(i);
		}
	}
	cout << endl;
}


Measured memory_bytes: 3156
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use std::mem::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::usize;

#[allow(unused_macros)]
macro_rules! read_cols {
    ($($t:ty),+) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();

        let mut it = line.trim()
            .split_whitespace();

        ($(
            it.next().unwrap().parse::<$t>().ok().unwrap()
        ),+)
    }}
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    line.trim().to_string().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    line.trim()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n = read::<i64>();

    let mut s = (n as f64).sqrt() as i64;
    if (s + 1) * (s + 1) <= n {
        s += 1;
    }

    println!("{}", s * s);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }
 
ll x,y;
 
ll cal(int b1, int b2)
{
  ll xx = (b1 ? -x : x);
  ll yy = (b2 ? -y : y);
  if(xx<=yy) return yy-xx+b1+b2;
  else return inf;
}
 
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> x >> y;
  ll ans = cal(0,0);
  ans = min(ans, cal(0,1));
  ans = min(ans, cal(1,0));
  ans = min(ans, cal(1,1));
  cout << ans << endl;
  return 0;
}

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

int main()
{
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
  {
    cout << "vowel" << endl;
  }
  else
  {
    cout << "consonant" << endl;
  }
  
}

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

int main()
{
  vector<vector<int>> A(3, vector<int>(3));

  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      cin >> A.at(i).at(j);
    }
  }

  int N;

  cin >> N;

  vector<int> b(N);

  for (int i = 0; i < N; i++)
  {
    cin >> b.at(i);
  }

  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      for (int k = 0; k < 3; k++)
      {
        if (A.at(j).at(k) == b.at(i))
        {
          A.at(j).at(k) = 0;
          goto endloop;
        }
      }
    }
  endloop:;
  }

  bool result = false;

  for (int i = 0; i < 3; i++)
  {
    if (A.at(i).at(0) == 0 && A.at(i).at(1) == 0 && A.at(i).at(2) == 0)
    {
      result = true;
    }
    if (A.at(0).at(i) == 0 && A.at(1).at(i) == 0 && A.at(2).at(i) == 0)
    {
      result = true;
    }
  }

  if (A.at(0).at(0) == 0 && A.at(1).at(1) == 0 && A.at(2).at(2) == 0)
  {
    result = true;
  }
  if (A.at(0).at(2) == 0 && A.at(1).at(1) == 0 && A.at(2).at(0) == 0)
  {
    result = true;
  }

  if (result)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] arr = br.readLine().split(" ");
			int h = Integer.parseInt(arr[0]);
			int w = Integer.parseInt(arr[1]);

			if (h==0&&w==0){
				break;

			}

			for(int i = 0;i<h;i++){
				
				if(i%2==0){
					for(int j=0;j<w;j++){
						if(j%2==0){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				
				if(i%2!=0){
					for(int j=0;j<w;j++){
						if(j%2!=0){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.println("");
			}
			System.out.println("");

		}

	}



}

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

int a[200000],b[200000],c[200000];

int main(){
	int n,K;cin>>n>>K;
	if(K*2>n+1){
		puts("-1");return 0;
	}
	rep(i,n)c[i]=K+2*n+i;
	set<int>se;
	rep(i,2*n)se.insert(K+i);
	int A=K,B=K+2*n-1;
	for(int i=K-1;i>=0;i--){
		a[i]=A;se.erase(A);
		b[i]=B;se.erase(B);
		A++;
		B-=2;
	}
	for(int i=n-1;i>=K;i--){
		a[i]=A;se.erase(A);
		b[i]=*se.rbegin();se.erase(--se.end());
		A++;
	}
	rep(i,n){
		printf("%d %d %d\n",a[i],b[i],c[i]);
	}
}

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

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  if (A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

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

  ll a, b, c;
  cin >> a >> b >> c;

  //毒入りが少ない
  if(c <= b){
    cout << b+c << endl;
  }
  else{
    if(c > a+b){
      //cout << a+b << endl;
      //b+1+a+1
      ll tmp = c - (b+1);
      tmp -= a;
      cout << b+c-tmp << endl;
    }
    else{
      cout << b+c << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>

using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    cin >> S;
    if (S=="ABC")
    {
        cout << "ARC";
    }
    else
    {
        cout << "ABC";
    }
    
    
    return 0;
}


Measured memory_bytes: 3620