akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=1e5+7;
vi G[maxn];
int ans2=0;
int cur;
bool ok;
int dfs(int u,int fa=-1)
{
    vi sonlen;
    for(auto v:G[u])if(v!=fa)
    {
        int ret=dfs(v,u);
        sonlen.push_back(ret+1);
    }
    if(fa==-1&&G[u].size()%2==0)
    {
        sort(sonlen.begin(),sonlen.end());
        for(int l=0,r=sonlen.size()-1;l<r;l++,r--)
            if(sonlen[l]+sonlen[r]>cur) ok=0;
        return 0;
    }
    if(sonlen.size()%2==0) sonlen.push_back(0);
    sort(sonlen.begin(),sonlen.end());
    int L=0,R=sonlen.size()-1,ret=-1;
    while(L<=R)
    {
        int mid=L+R>>1;
        bool yes=1;
        for(int l=0,r=sonlen.size()-1;l<r;l++,r--)
        {
            if(l==mid) l++;
            if(r==mid) r--;
            if(sonlen[l]+sonlen[r]>cur) yes=0;
        }
        if(yes){
            ret=mid;
            R=mid-1;
        }
        else L=mid+1;
    }
    if(ret==-1){
        ok=0;
        ret=0;    
    }
    return sonlen[ret];
}
int main()
{
    int n;
    cin>>n;
    for(int i=1,u,v;i<n;i++)
    {
        cin>>u>>v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int ans1=0,odd=0;
    for(int i=1;i<=n;i++)
        if(G[i].size()&1) odd++;
    ans1=odd/2;
    int L=1,R=n-1,ans2=-1;
    while(L<=R)
    {
        cur=L+R>>1;
        ok=1;
        int ret=dfs(1);
        //dbg(cur,ok);
        if(ret>cur) ok=0;
        if(ok)
        {
            ans2=cur;
            R=cur-1;
        }
        else L=cur+1;
    }
    cout<<ans1<<" "<<ans2<<'\n';
}

Measured memory_bytes: 13696
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
using namespace std;
int main(){
 char s[21];
 scanf("%s",s);
  
 printf("%c%c%c\n",s[0],s[1],s[2]);
  
return 0;}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define ll long long
#define inf 1e9+10
#define eps 1e-7
using namespace std;
inline int read(){
	int x=0;int f=1;char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)) {x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
const int MAXN=1e6+10;
int a[MAXN],n,k;
int main(){
	n=read();k=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
	}
	sort(a+1,a+n+1);
	int l,r;int ans=inf;
	l=n-k+1;r=n;
	while(l){
		//cout<<l<<' '<<r<<' '<<a[l]<<' '<<a[r]<<endl;
		if(a[l]>=0){
			ans=min(ans,a[r]);
		}
		else{
			if(a[r]>=0){
				ans=min(ans,min(a[r]*2+abs(a[l]),a[r]+abs(a[l]*2)));
			}
			else ans=min(ans,abs(a[l]));
		}
		l--;r--;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int i=1;
	while(1){
		int x; cin >>x;
		if(x ==0)break;
		cout << "Case" << " "<<i<<":"<<" "<<x<<endl;
		i++;
	}
}


Measured memory_bytes: 3100
#include<stdio.h>

int main(void){
  int P,Q,R,min;
  scanf("%d %d %d",&P,&Q,&R);
  min=P+Q;
  if(P+R<min){min=P+R;}
  if(R+Q<min){min=R+Q;}
  printf("%d\n",min);

  return 0;
}


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

using namespace std;

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

namespace IntegerMath
{
  int64_t floor_div(int64_t x, int64_t y) {
    return x / y;
  }

  int64_t ceil_div(int64_t x, int64_t y) {
    return (x / y) + min(static_cast<int64_t>(1), x % y);
  }

  int64_t sqrt(int64_t x) {
    return static_cast<int64_t>(
      ::floorl( ::sqrtl( 
        static_cast<long double>(x)
      ) )
    );
  }

  int64_t log2(int64_t x) {
    return static_cast<int64_t>(
      ::floorl( ::log2l( 
        static_cast<long double>(x)
      ) )
    );
  }    

  int64_t log10(int64_t x) {
    return static_cast<int64_t>(
      ::floorl( ::log10l( 
        static_cast<long double>(x)
      ) )
    );
  }

  int64_t number_of_digits(int64_t x) {
    return static_cast<int64_t>(
      ::ceill( ::log10l( 
        static_cast<long double>(x + 1)
      ) )
    );
  }

  uint64_t gcd(uint64_t a, uint64_t b)
  {
    uint64_t n = std::min(a, b), m = std::max(a, b);
    return (n == 0) ? m : gcd(m % n, n);
  }

  uint64_t lcm(uint64_t a, uint64_t b)
  {
    uint64_t d = gcd(a, b);
    return (a % d == 0) ? (a / d) * b : a * (b / d);
  }
};

int main()
{
  uint64_t N, M;
  cin >> N >> M;
  
  vector<uint64_t> a(N);
  N_TIMES(n, N) { cin >> a[n]; }
  
  uint64_t p = 0;
  vector<uint64_t> b = a;
  
  while (true) {
    bool odd_flag = true, even_flag = true;
    N_TIMES(n, N) {
      if ((b[n] & 1) == 0) {
        odd_flag = false;
      } else {
        even_flag = false;
      }
    }
    
    if (odd_flag) {
      break;
    } else if (even_flag) {
      N_TIMES(n, N) { b[n] = b[n] >> 1; }
      ++p;
    } else {
      cout << 0 << endl;
      return 0;
    }
  }
  
  set<uint64_t> s;
  N_TIMES(n, N) { s.insert(b[n]); }
  
  bool overflow_flag = false;
  uint64_t X_min = 1 << (p - 1);
  for(uint64_t x : s) {
    uint64_t lcm = IntegerMath::lcm(X_min, x);
    
    if (lcm < X_min) {
      overflow_flag = true;
      break;
    }
    
    X_min = lcm;
  }
  
  if (overflow_flag) {
    cout << 0 << endl;
    return 0;
  }
  
  if (M < X_min) {
    cout << 0 << endl;
    return 0;
  }
  
  uint64_t ans = (M - X_min + 1) / (X_min << 1);
  if ((M - X_min + 1) % (X_min << 1) > 0) { ++ans; }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, x;
    while(cin >> n >> x) {
        if (n == 0 && x == 0) return 0;
        ll ans = 0;
        for(int i = 1; i <= n; i++) {
            for(int j = i+1; j <= n; j++) {
                for(int k = j+1; k <= n; k++) if(i + j + k == x) ans++;
            }
        }
        cout << ans << endl;
    }
}



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

int main() {
  int N;
  scanf("%d", &N);
  string S;
  cin >> S;

  int ans = 0;
  for (int i = 1; i < N; i++) {
    int count = 0;
    string X = S.substr(0, i);
    string Y = S.substr(i, N - i);

    set<char> X_set, Y_set;
    for (char c : X) X_set.insert(c);
    for (char c : Y) Y_set.insert(c);

    for (char x : X_set) {
      if (Y_set.count(x) > 0) count++;
    }
    
    ans = max(ans, count);
  }

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	string st; cin >> st;
	int ans = 0;
	for (int l = 0; l < st.size(); ++l) {
		if (st[l] == 'O') {
			int r = l;
			while (r!=st.size()&&st[r] == 'O') {
				r++;
			}
			int len = r - l;
			if (l - len >= 0 && r + len <= st.size()) {
				bool ok = true;
				for (int t = 0; t < len; ++t) {
					if (st[l - t - 1] != 'J')ok = false;
					if (st[r + t] != 'I')ok = false;
				}
				if (ok)ans = max(ans, len);
			}
			l += len - 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3948
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> pl;
const int INF=100000001;

int main(){
  int n; cin>>n;
  vector<ll> dp(n,0);
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
    dp[0]+=a[i];
  }
  for(int i=1;i<n-1;i+=2){
    dp[0]-=2*a[i];
  }
  rep(i,n-1){
    dp[i+1]=2*a[i]-dp[i];
  }
  rep(i,n){
    cout<<dp[i]<<(i==n-1?"\n":" ");
  }
  return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

const int MX = 5010;

bool dp1[MX][MX], dp2[MX][MX];
int acm[MX][MX];

int main() {
    int N, K;
    cin >> N >> K;
    V<int> a(N);
    rep(i, N) cin >> a[i];

    dp1[0][0] = 1;
    rep(i, N) {
        rep(j, MX) if (dp1[i][j]) {
            dp1[i + 1][j] = 1;
            if (j + a[i] < MX) {
                dp1[i + 1][j + a[i]] = 1;
            }
        }
    }

    dp2[N][0] = 1;
    for (int i = N - 1; i >= 0; --i) {
        rep(j, MX) if (dp2[i + 1][j]) {
            dp2[i][j] = 1;
            if (j + a[i] < MX) {
                dp2[i][j + a[i]] = 1;
            }
        }
    }

    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= K; ++j) {
            acm[i][j + 1] = acm[i][j] + dp2[i][j];
        }
    }

    int ans = 0;
    rep(i, N) {
        bool f = 0;
        for (int s = 0; s <= K; ++s) {
            if (dp1[i][s]) {
                if (i == 2) debug(s);
                int x = acm[i + 1][K - s] -
                        (K - a[i] - s >= 0 ? acm[i + 1][K - a[i] - s] : 0);
                if (x) {
                    debug(i, s);
                    f = 1;
                }
            }
        }
        ans += f;
    }
    cout << N - ans << endl;

    return 0;
}

Measured memory_bytes: 150260
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<string>
#include<cstring>
#include<sstream>
using namespace std;int main(){
int n,a,b,ans=0;
cin>>n>>a>>b;
for(int i=1;i<=n;i++){
	int sum=0;
	string c;
	stringstream s;
	s<<i;
	s>>c;
	
	for(int j=0;j<c.size();j++){
		sum+=c[j]-'0';
	}
	if(sum>=a&&sum<=b){
		ans+=i;
	}
	
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);


int main()
{
    IOS();
    ll r,c,d;
    string S="RYGB";
    cin>>r>>c>>d;
    REP(i,r)
    {
      REP(j,c)
      {
        int t=(((i+j)/d)&1)*2+(((i-j+c)/d)&1);
        cout<<S[t];
      }
      cout<<endl;
    }
}


Measured memory_bytes: 512
import numpy as np
N=int(input())
X=list(map(int, input().split()))
X.sort()
Y=sum(X)/N
if Y-int(Y)>0.5:
    Y=int(Y)+1
else:
    Y=int(Y)
X=[(i-Y)**2 for i in X]
print(sum(X))

Measured memory_bytes: 12448
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
 
int main() {
    int n;
    cin>>n;
    cout<<(n+1)/2-1<<endl;
}

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n): fact(n+1), ifact(n+1){
    assert(n < mod);
    fact[0] = 1;
    for (int i=1; i<=n; ++i)fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i=n; i>=1; --i) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k){
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n-k];
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  combination c(n+5);
  mint ans = 0;
  rep(ri, 2){
    rep(i, n){
      mint now = c(i, k-1);
      if(ri == 1) now = -now;
      ans += now * a[i];
    }
    reverse(a.begin(), a.end());
  }
  cout << ans.x << endl;
  return 0;
}


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

const int MOD = 998244353;
vector<long long> fact, fact_inv;

long long pow_mod(long long x, long long n) {
    long long res = 1;
    while (n) {
        if (n & 1) res = res * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

long long cmb(int n, int r) {
    if (r < 0 || r > n) return 0;
    return (fact[n] * (fact_inv[r] * fact_inv[n - r] % MOD)) % MOD;
}

int main() {
    int N, M, K;  cin >> N >> M >> K;

    // fact, fact_inv の前処理
    fact.resize(N + 1);
    for (int i = 0; i <= N; ++i) {
        if (i == 0) fact[i] = 1;
        else fact[i] = fact[i - 1] * i % MOD;
    }
    fact_inv.resize(N + 1);
    for (int i = N; i >= 0; --i) {
        if (i == N) fact_inv[i] = pow_mod(fact[N], MOD - 2);
        else fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;
    }

    long long ans = 0;
    for (int k = 0; k <= K; ++k) {
        ans = (ans + (cmb(N - 1, k) * pow_mod(M - 1, N - k - 1) % MOD) * M % MOD) % MOD;
    }
    cout << ans << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ans = 1;
    bool inc = false, dec = false;
    for (int i = 0; i < n - 1; i++) {
        if (a[i] < a[i + 1])
            inc = true;
        else if (a[i] > a[i + 1])
            dec = true;
        if (inc && dec) {
            ans++;
            inc = false;
            dec = false;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.io.BufferedReader

fun main() {
    val mod = 1_000_000_007L
    fun modPow(n: Long, k: Int, m: Long = mod): Long {
        if (k == 0) {
            return 1L
        }
        var half = modPow(n, k shr 1, m)
        half *= half
        if (k and 1 == 1) {
            half %= m
            half *= n
        }
        return half % m
    }

    val br = System.`in`.bufferedReader()
    val length = br.readInt()
    val maxNum = br.readInt()

    val factorial = LongArray(maxNum + 1) { 1L }
    val invFactorial = LongArray(maxNum + 1) { 1L }
    for (x in 1..maxNum) {
        factorial[x] = (factorial[x - 1] * x) % mod
        invFactorial[x] = modPow(factorial[x], (mod - 2).toInt())
    }
    fun choose(n: Int, k: Int): Long {
        val ret = (factorial[n] * invFactorial[k]) % mod
        return (ret * invFactorial[n - k]) % mod
    }

    var tot = 0L
    var sign = 1
    for (x in 0..length) {
        var part = choose(length, x) * choose(maxNum - x, length - x)
        part %= mod
        part *= factorial[length - x]
        part %= mod

        tot += sign * part
        tot += mod
        tot %= mod
        sign *= -1
    }
    tot *= factorial[maxNum]
    tot %= mod
    tot *= invFactorial[maxNum - length]
    tot %= mod
    print(tot)
}

private const val SPACE_INT = ' '.toInt()
private const val ZERO_INT = '0'.toInt()
private const val NL_INT = '\n'.toInt()

private fun BufferedReader.readInt(): Int {
    var ret = read()
    while (ret <= SPACE_INT) {
        ret = read()
    }
    val neg = ret == '-'.toInt()
    if (neg) {
        ret = read()
    }
    ret -= ZERO_INT
    var read = read()
    while (read >= ZERO_INT) {
        ret *= 10
        ret += read - ZERO_INT
        read = read()
    }

    while (read <= SPACE_INT && read != -1 && read != NL_INT) {
        mark(1)
        read = read()
    }
    if (read > SPACE_INT) {
        reset()
    }
    return if (neg) -ret else ret
}

Measured memory_bytes: 42388
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int A, B, C;

  cin >> A >> B >> C;

  if (A == B)
    cout << C << endl;
  else if (B == C)
    cout << A << endl;
  else
    cout << B << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		String[] temp   = scanner.nextLine().split(" ");

		int N = Integer.parseInt(temp[0]);
		int W = Integer.parseInt(temp[1]);

		int wgh = 0;
		long val = 0;

		long[][] dp  = new long[N + 1][W + 1];

		for(int i = 0; i <= W; i ++) {

			dp[0][i] = 0;

		}


		for(int i = 1; i <= N; i++) {
			String[] tmp = scanner.nextLine().split(" ");
			wgh = Integer.parseInt(tmp[0]);
			val = Long.parseLong(tmp[1]);

			for(int w = 1; w <= W; w++) {

				if(w >= wgh) dp[i][w] = Math.max(dp[i - 1][w], dp[i - 1][w - wgh] + val);
				else dp[i][w] = dp[i - 1][w];

			}
		}

		System.out.println(dp[N][W]);


	}

}


Measured memory_bytes: 124748
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll r, D, X;
    cin >> r >> D >> X;
    
    ll tmp = X;
  	for(ll i = 0; i < 10; i++){
        cout << tmp * r - D << endl;
        tmp = tmp * r - D;
    }


}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int i, number, count = 0;
    number = Integer.parseInt(sc.next());
    int[] num_array = new int[number];
    for(i = 0; i < number; i++) num_array[i] = Integer.parseInt(sc.next());
    for(i = 0; i < number; i++) {
      if(i + 1 != num_array[i]) count++;
    }
    if(count == 0 || count == 2) System.out.println("YES");
    else System.out.println("NO");
  }
}


Measured memory_bytes: 23124
import sys
N,M=map(int, sys.stdin.readline().split())
SC=[ map(int, sys.stdin.readline().split()) for _ in range(M) ]

def judge(s,c,n):
    n=str(n)
    c=str(c)
    l=len(n)
    if l<s: return False
    if l!=N:return False
    if n[s-1]==c:
        return True
    else:
        return False

if M==0:
    if N==3: print 100
    elif N==2: print 10
    elif N==1: print 0
    quit()

for n in range(1000):
    for s,c in SC:
        if not judge(s,c,n):
            break
    else:
        print n
        quit()
else:
    print -1

Measured memory_bytes: 29036
import java.util.*;

public class Main {
    static Scanner sc;
    public static void main(String[] args) {
        sc=new Scanner(System.in);
        //a();
        //b();
        //c();
        d();
    }
    public static void a(){
        int a=sc.nextInt();int b=sc.nextInt();
        System.out.println((a>9||b>9)?-1:a*b);
    }
    public static void b(){
        int n=sc.nextInt();
        int po[]=new int[81];
        boolean b=false;
        for(int i=0;i<9;i++)
        for(int j=0;j<9;j++)if((i+1)*(j+1)==n)b=true;
        System.out.println(b?"Yes":"No");
    }
    public static void c(){
        long n=sc.nextLong();
        long q=(long)Math.sqrt(n);
        long index=n;
        for(int i=2;i<=q;i++){
            if(n%i==0)index=i;
        }
        System.out.println(index+(n/index)-2);
    }
    public static void d(){
        int a=sc.nextInt();
        int b=sc.nextInt();
        int x=sc.nextInt();
        if((double)2*x/(a*a)-b>=0){
            double bb=((double)2*x)/(a*a)-b;
            System.out.println(Math.atan((-bb+b)/a)*180/Math.PI);
        }
        else{
            double aa=((double)2*x)/(a*b);
            System.out.println(Math.atan(((double)b)/aa)*180/Math.PI);
        }
        
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define sc3(a,b,c)  cin>>a>>b>>c
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


int BIT[28][MAXN+5];
ll get(ll p,ll P){
	ll ans=0;
	if(p==0)re 0;
	do{
		ans+=BIT[P][p];
	}while((p-=(p&-p))>0);
	return ans;
}
void upd(ll p,ll P,ll v){
	do{
		BIT[P][p]+=v;
	}while((p+=(p&-p))<=MAXN);
}
ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	
	string s; sc(n);
	sc(s);
	fs(i,s){	
		upd(i+1,s[i]-'a',1);
	}
	sc(q);
	while(q--){	//debug(q);
		sc(v);
		char yy;
		
		if(v==1){
			sc2(x,yy);
			upd(x,s[x-1]-'a',-1);
			s[x-1]=yy;
			//debug(yy);
			upd(x,s[x-1]-'a',1);
		}
		else{
			sc2(x,y);
			ans=0;
			fu(i,'a','z'){
				v=0;
				v+=get(y,i-'a');
				v-=get(x-1,i-'a');
				if(v)ans++;
			}
			pr(ans);
		}
	}
	
	
	
	
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

Measured memory_bytes: 101276
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
int deg[111111];
struct edge
{
	int to;
	int next;
}e[333333];
int pe=111111;
void insert(int a,int to)
{
	e[pe]=(edge){to,e[a].next};
	e[a].next=pe++;
	deg[a]++;
}
#include<cassert>
#include<set>
struct kk
{
	int v;
};
bool operator <(const kk &x,const kk &y)
{
	return x.v>y.v;
}
bool cmp(const kk &x,const kk &y)
{
	return x.v>y.v;
}
std::multiset<kk> s;
int f[111111];
int v[111111],pv;
bool dfs(int o,int fa,int k)
{
	for(register int p=e[o].next;p;p=e[p].next)
		if(e[p].to!=fa)if(dfs(e[p].to,o,k)==0)return 0;
	if(o==1)
	{
		pv=0;
		for(register int p=e[o].next;p;p=e[p].next)
			v[++pv]=f[e[p].to]+1;
		if(deg[o]&1)v[++pv]=0;
		assert(pv%2==0);
		std::sort(v+1,v+pv+1);
		for(register int i=1,j=pv;i<j;++i,--j)
			if(v[i]+v[j]>k)return 0;
	}
	else
	{
		pv=0;
		if(deg[o]&1)v[++pv]=0;
		for(register int p=e[o].next;p;p=e[p].next)
			if(e[p].to!=fa)v[++pv]=f[e[p].to]+1;
		std::sort(v+1,v+pv+1);
		int ans=0;
		for(register int l=1,r=pv,mid=l+r>>1;l<=r;mid=l+r>>1)
		{
			for(register int x=mid==1?2:1,y=mid==pv?pv-1:pv;x<y;)
			{
				if(v[x]+v[y]>k)goto skip;
				++x,--y;
				if(x==mid)++x;
				if(y==mid)--y;
			}
			ans=mid;
			r=mid-1;
			continue;
			skip:;
			l=mid+1;
		}
		if(ans==0)return 0;
		f[o]=v[ans];
	}
	return 1;
}
bool chk(int mid)
{
	return dfs(1,1,mid);
}
int main()
{
	int n=io::F();
	for(register int i=1;i<n;++i)
	{
		int x=io::F(),y=io::F();
		insert(x,y);
		insert(y,x);
	}
	int cc=0;
	for(register int i=1;i<=n;++i)if(deg[i]&1)++cc;
	printf("%d ",cc/2);
	chk(3);
	int ans=0;
	for(register int l=1,r=n-1,mid=l+r>>1;l<=r;mid=l+r>>1)
		if(chk(mid))ans=mid,r=mid-1;
			else l=mid+1;
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 7296
#include <iostream>
 
int main(){
	int a,b,c;
  	std::cin>>a;
  	std::cin>>b;
  	std::cin>>c;
  	int count =0;
  	if(count<((float)c+0.5)){
      for(float i=1.0;(i*a)<((float)(c+0.5));i+=1.0){
          count +=b;
      }
    }
  	std::cout<<count;
  	return 0;
}

Measured memory_bytes: 256
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.List
import Control.Monad
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Builder as BSB
import System.IO
import Data.Monoid
import Data.Array.Unboxed
import Data.Array.ST
import Control.Monad.ST

words_BSB :: [BSB.Builder] -> BSB.Builder
words_BSB xs = mconcat $ intersperse (BSB.char7 ' ') xs

lines_BSB :: [BSB.Builder] -> BSB.Builder
lines_BSB xs = mconcat $ map (<> BSB.char7 '\n') xs

solveRec :: STUArray s (Int, Int) Int -> Int -> Int -> U.Vector Int -> ST s Int
solveRec table !s 2 xs = do let [i,j] = U.toList xs
                            writeArray table (i,j) s
                            return (s+1)
solveRec table !s 3 xs = do let [i,j,k] = U.toList xs
                            writeArray table (i,j) s
                            writeArray table (i,k) s
                            writeArray table (j,k) (s+1)
                            return (s+2)
solveRec table !s n xs = do forM_ [1,3..n-1] $ \d -> do
                              forM_ [0..n-1-d] $ \i -> do
                                writeArray table (xs U.! i,xs U.! (i+d)) s
                            let m = n `quot` 2
                            solveRec table (s+1) (n - m) $ U.map (xs U.!) (U.fromList [0,2..n-1])
                            solveRec table (s+1) m $ U.map (xs U.!) (U.fromList [1,3..n-1])

main = do
  n <- readLn
  let result = runSTUArray $ do
        table <- newArray ((1,1),(n,n)) 0
        solveRec table 1 n $ U.enumFromN 1 n
        return table
  BSB.hPutBuilder stdout $ lines_BSB [words_BSB $ [ BSB.intDec (result ! (i,j)) | j <- [i+1..n]] | i <- [1..n-1]]


Measured memory_bytes: 7036
#include <stdio.h>

int main(void){
	int d[101];
	d[100]=101;
	int n;
	int s=0;

	scanf("%d", &n);

	for(int i=0; i<n; i++){
		scanf("%d", &d[i]);
	}
	
	for(int i=0; i<n; i++){
			for(int j=i+1; j<n; j++){
				if(d[i] == d[j]){
						s++;
						break;
				}
			}
	}

	int a = n - s;
	if(a==0) a=1;

	printf("%d", a);
	scanf("%d", &n);

	return 0;
}

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

typedef long long ll;

using namespace std;

template <class T>
T GCD(T a, T b) { return b == 0 ? a : GCD(b, a%b); }

int main()
{
  int N; cin >> N;
  vector<ll> A(N);
  ll ans = 0;
  while (N--) {
    ll a; cin >> a;
    ans = GCD(ans, a);
  }

  cout << ans;
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

        String S = sc.next();
        int n = Integer.parseInt(sc.next());

        for (int i = 0; i < n; i++) {
            String op = sc.next();

            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());

            String bs = S.substring(0, a);
            String ms = S.substring(a, b + 1);
            String as = S.substring(b + 1);

            switch (op) {
                case "replace":
                    S = bs + sc.next() + as;
                    break;
                case "reverse":
                    StringBuilder tmp = new StringBuilder();
                    for (int j = ms.length() - 1; j >= 0; j--) {
                        tmp.append(ms.charAt(j));
                    }

                    S = bs + tmp.toString() + as;
                    break;
                case "print":
                    System.out.println(S.substring(a, b + 1));
                    break;
            }
        }
    }
}

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

int main () {
    long n;
    long m = 1;

    scanf("%ld", &n);

    int cl = ceil(sqrt(n));
    for (int i = 1; i <= cl; ++i) {
        if (n % i == 0 && m + n/m > i + n/i) {
            m = i;
        }
    }

    printf("%ld\n", m + n/m - 2);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long 
using namespace std;

const int N = 2e6 + 7, mod = 1e9 + 7, offset = 1e6 + 2;

int dp[N], n;


int get(int idx) {
	idx += offset;
	return idx < 0 ? 0 : dp[idx];
}

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = -offset; i <= 0; i++) {
		dp[i + offset] = (1 + dp[i + offset - 1]) % mod;
	}
	dp[1 + offset] = (n + dp[offset]) % mod;
	int k = (n - 1) * (n - 1) % mod;
	for(int i = 2; i <= n; i++) {
		dp[i + offset] = (get(i - 1) - get(i - 2) + mod) % mod;
		dp[i + offset] += k + (get(i - 3) - get(i - n - 2) + mod) % mod;
		dp[i + offset] %= mod;
		dp[i + offset] = (dp[i + offset] + dp[i + offset - 1]) % mod;
	}

	cout << (dp[n + offset] - dp[n + offset - 1] + mod) % mod << endl;

}

Measured memory_bytes: 19232
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	int sum;
	int mini;
	int sec;
	
	sum = 0;
	for (i = 0; i < 4; i++){
		scanf("%d", &n);
		sum += n;
	}
	
	mini = sum / 60;
	sec = sum % 60;
	
	printf("%d\n%d\n", mini, sec);
	
	return (0);
}

Measured memory_bytes: 1772
#include<iostream>

using namespace std;

long long pf[100005], arr[100005], nplus[100005];

int main(){
    int N, K;
    cin >> N >> K;

    for(int i=1; i<=N; i++) {
        cin >> arr[i];
        if(arr[i] > 0) nplus[i] = nplus[i-1] + arr[i];
        else nplus[i] = nplus[i-1];
    }

    for(int i=1; i<=K; i++) pf[1]+= arr[i];

    for(int i=2; i<=N-K+1; i++) pf[i] = pf[i-1] + arr[i+K-1] - arr[i-1];

    long long maks = 0;
    for(int i=1; i<=N-K+1; i++){
        long long temp;
        if (pf[i] < 0) temp = nplus[i-1] + nplus[N] - nplus[K+i-1] ;
        else temp = pf[i] + nplus[i-1] + nplus[N] - nplus[K+i-1] ;

        if(temp > maks) maks = temp;
    }

    cout << maks << endl;

}

Measured memory_bytes: 5976
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#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 pb push_back
#define fi first
#define se second
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const int inf=0x3fffffff;
const ll mod=1000000007;
const int maxn=100000+100;
int head[maxn];

int main(){
    int a,b,c;
    int d1=0,d2=0;
    cin>>a>>b>>c;
    if(a==5) d1++;
    else if(a==7) d2++;
    if(b==5) d1++;
    else if(b==7) d2++;
    if(c==5) d1++;
    else if(c==7) d2++;
    if(d1==2&&d2==1) puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;

public class Main {

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

        Scanner in = new Scanner(System.in);

        boolean result = true;
        int n = in.nextInt();

        int tPrev = 0;
        int xPrev = 0;
        int yPrev = 0;

        for (int i = 0; i<n; i++) {
            int t = in.nextInt();
            int x = in.nextInt();
            int y = in.nextInt();

            result = ((t-tPrev)%2 == Math.abs(x+y-xPrev-yPrev)%2) && result;
            result = (Math.abs(x+y-xPrev-yPrev) <= (t-tPrev)) && result;

            tPrev = t;
            xPrev = x;
            yPrev = y;
        }

        if (result)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 86924
#include <stdio.h>
#define NIL -1
#define MAX 45

int F[MAX];

void makeFibonacci(int n){
  int i;
  F[0] = 1;
  F[1] = 1;
  for(i = 2; i <= n; i++ ){
    F[i] = F[i-2] + F[i-1];
  }
 printf("%d\n",F[i-1]);
}

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

  makeFibonacci(n);
  
  return 0;
}

Measured memory_bytes: 596
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var a = sc.nextLong();
        var b = sc.nextLong();

        WriteLine(Calc(b) ^ Calc(a-1));
    }

    long Calc(long a) {
        a++;
        var ans = 0L;
        for (int i = 0; i < 41; i++) {
            var pow = (long)Pow(2, (i + 1));
            var cnt = (a / pow) * (pow / 2);
            cnt += Max(0, (a % pow) - (pow / 2));
            if (cnt % 2 == 1) {
                ans += (long)Pow(2, i);
            }
        }
        return ans;
    }
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;


int main(){
	int N,K; string S;
	cin >> N >> S >> K;
	for(int i=0; i<S.size(); i++){
		if(S[K-1]!=S[i])
		S[i]='*';
	}
	cout << S << endl;
		}

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

int main(){
	int n;
	cin >> n;
	map<string, int> mp;
	rep(i,n){
		string s;
		cin >> s;
		mp[s]++;
	}
	int ans = 0;
	for(auto p : mp){
		ans++;
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 19228
sx, sy, tx, ty = map(int, input().split())

dif_x = tx - sx
dif_y = ty - sy

ans = 'U' * dif_y + 'R' * dif_x + 'D' * dif_y + 'L' * (dif_x + 1)\
     + 'U' * (dif_y + 1) + 'R' * (dif_x + 1) + 'D' + 'R' + 'D' * (dif_y + 1) + 'L' * (dif_x + 1) + 'U'

print(ans)

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

using namespace std;
int n,m,cnt=0,s,t;
const int maxn=1e5+5;
int to[maxn<<1],nex[maxn<<1],head[maxn];
int dis[maxn][3];
void add(int u,int v)
{
    to[++cnt]=v,nex[cnt]=head[u],head[u]=cnt;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v);
    }
    memset(dis,-1,sizeof(dis));
    scanf("%d%d",&s,&t);
    queue<pair<int,int> > q;
    q.push({s,0});
    dis[s][0]=0;
    while(!q.empty())
    {
        pair<int,int> t=q.front();
        q.pop();
        int u=t.first;
        int len=t.second;
        for(int i=head[u];i;i=nex[i])
        {
            int ll=(len+1)%3;
            int v=to[i];
            if(dis[v][ll]>=0)
                continue;
            dis[v][ll]=dis[u][len]+1;
            q.push({v,ll});
        }
    }
    if(dis[t][0]>=0)
        dis[t][0]/=3;
    printf("%d",dis[t][0]);
    return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N;
  cin >> N;
  vector<pair<int,int>> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i].first;
    A[i].second=i;
  }

  sort(A.begin(),A.end());
  int cur=1;
  int l=-1;
  for(int i=0;i<N;i++){
    if(A[i].first==cur && l<A[i].second){
      ++cur; l=A[i].second;
    }
  }
  if(cur==1){
    cout << -1 << endl;
  }else{
    cout << N-cur+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
from itertools import permutations
A_list = []
for i in range(5):
    A = int(input())
    A_list.append(A)
nes = [0,1,2,3,4]
iterator = []
for i in permutations(nes):
    iterator.append(i)
min1 = 10**9
for i in iterator:
    temp = 0
    for j in i:
        if temp%10 != 0:
            temp += (10-temp%10)
        temp += A_list[j]
    if temp < min1:
        min1 = temp
print(min1)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <array>
using namespace std;
typedef long long ll;

int n, dp[100][5][5][5], mod = 1e9 + 7;
array<array<int, 3>, 3> forb3 = {
    array<int, 3>{0, 2, 1},
    array<int, 3>{0, 1, 2},
    array<int, 3>{2, 0, 1}
};
array<array<int, 4>, 8> forb4 = 
{
    array<int, 4>{0, 0, 2, 1},
    array<int, 4>{0, 1, 2, 1},
    array<int, 4>{0, 2, 2, 1},
    array<int, 4>{0, 3, 2, 1},
    array<int, 4>{0, 2, 0, 1},
    array<int, 4>{0, 2, 1, 1},
    array<int, 4>{0, 2, 2, 1},
    array<int, 4>{0, 2, 3, 1}
};
int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >=  0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
void adds(int& a, int b) { a = add(a, b); }
void subs(int& a, int b) { a = sub(a, b); }
void muls(int& a, int b) { a = mul(a, b); }
void maxs(int& a, int b) { a = max(a, b); }
void mins(int& a, int b) { a = min(a, b); }
int pwr(int a, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(a, pwr(a, p - 1));
    return pwr(mul(a, a), p / 2);
}
int inv(int a) { return pwr(a, mod - 2); }


int make(int k, int p1, int p2, int p3) {
    if(k == n)
        return 1;
    if(dp[k][p1][p2][p3] != -1)
        return dp[k][p1][p2][p3];
    int sum = 0;
    for(int i = 0; i < 4; ++i) {
        array<int, 4> a4 = {p3, p2, p1, i};
        array<int, 3> a3 = {p2, p1, i};
        bool f = 0;
        for(int j = 0; j < 3; ++j)
            if(a3 == forb3[j])
                f = 1;
        for(int j = 0; j < 8; ++j)
            if(a4 == forb4[j])
                f = 1;
        if(f)
            continue;
        adds(sum, make(k + 1, i, p1, p2));
    }
    return dp[k][p1][p2][p3] = sum;
}

int main() {
    cin >> n;
    memset(dp, -1 , sizeof dp);
    cout << make(0, 4, 4, 4) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
 
using namespace std;
 
int main(){
    string s;
    cin>>s;
    set<char> hoge;
    string ans="yes";
    
    for(auto a:s){
        int pre=hoge.size();
        hoge.insert(a);
        if(pre==hoge.size()){
            ans="no";
            break;
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;


const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;}

bool isOK(int mid,ll a,ll b){
    if(mid*a*2<=(b-mid)*a){
        return true;
    }
    return false;
}
int main()
{
    ll h, w;
    cin >> h >> w;
    if((h*w)%3==0){
        cout << 0 << endl;
        return 0;
    }
    ll ans=min(w,h);
    int left,right;
    left=0;right=h;
    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (isOK(mid,w,h))
            left = mid;
        else
            right = mid;
    }
    ans = min({ans, max((left - 1) * w, (h - left + 1) * int(w / 2) + (w % 2 == 0 ? 0 : (h - left + 1))) - min((left - 1) * w, (h - left + 1) * int(w / 2))});
    ans = min({ans, max((left)*w, (h - left) * int(w / 2) + (w % 2 == 0 ? 0 : (h - left))) - min((left)*w, (h - left) * int(w / 2))});
    ans = min({ans, max((left + 1) * w, (h - left - 1) * int(w / 2) + (w % 2 == 0 ? 0 : (h - left - 1))) - min((left + 1) * w, (h - left - 1) * int(w / 2))});
    left = 0;
    right = w;
    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (isOK(mid, h,w))
            left = mid;
        else
            right = mid;
    }
    ans = min({ans, max((left - 1) * h, (w - left + 1) * int(h/2) + (h % 2 == 0 ? 0 : (w - left + 1))) - min((left - 1) * h, (w - left + 1) * int(h/2))});
    ans = min({ans, max((left)*h, (w - left) * int(h/2) + (h % 2 == 0 ? 0 : (w - left))) - min((left)*h, (w - left) * int(h/2))});
    ans = min({ans, max((left + 1) * h, (w - left - 1) * int(h/2) + (h % 2 == 0 ? 0 : (w - left - 1))) - min((left + 1) * h, (w - left - 1) * int(h/2))});
    cout << ans << endl;
}

Measured memory_bytes: 3608
fun main() {
    val l = readLine()!!.split(' ').map { it.toDouble() }
    val hr = (l[2]+l[3]/60)/12
    val min = l[3]/60
    val pi = 6.28318530718
    val x = l[0]*l[0] + l[1]*l[1] - 2*l[0]*l[1]*Math.cos((hr-min)*pi)
    println(Math.sqrt(x))
}


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

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            long count = Integer.parseInt(br.readLine());
            long result = 0;
            for (long i = 1; i <= count; i++) {
                if (i % 3 == 0 && i % 5 == 0) {
                    continue;
                } else if (i % 3 == 0) {
                    continue;
                } else if (i % 5 == 0) {
                    continue;
                } else {
                    result += i;
                }
            }

            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 26024
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  int d = 0;
  int x;
  rep(i, N) {
    cin >> x;
    d += std::min(x, std::abs(x-K)) * 2;
  }

  cout << d << endl;

  return 0;
}


Measured memory_bytes: 256