akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {
  private interface Solver {
    int solve(int W, List<Integer> values, List<Integer> weights);
  }

  private static class PrefixSolver implements Solver {
    @Override
    public int solve(int W, List<Integer> values, List<Integer> weights) {
      int[] dp = new int[W + 1];
      for (int i = 1; i <= values.size(); ++i) {
        for (int j = W; j >=0; --j) {
          int v = values.get(i - 1);
          int w = weights.get(i - 1);
          if (j - w >= 0) {
            dp[j] = Math.max(dp[j], dp[j - w] + v);
          }
        }
      }
      return dp[W];
    }
  }

  private static final Pattern SPLIT = Pattern.compile("\\s");
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    List<Integer> weights = new ArrayList<>();
    List<Integer> values = new ArrayList<>();
    List<Integer> NW = Stream.of(SPLIT.split(scanner.nextLine())).map(Integer::valueOf)
        .collect(Collectors.toList());
    final int N = NW.get(0);
    final int W = NW.get(1);
    for (int i = 0; i < N; ++i) {
      List<Integer> collect = Stream.of(SPLIT.split(scanner.nextLine())).map(Integer::valueOf)
          .collect(Collectors.toList());
      values.add(collect.get(0));
      weights.add(collect.get(1));
    }
    System.out.println(new PrefixSolver().solve(W, values, weights));
  }
}

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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int n , y ;

int main() {
  cin >> n >> y ;
  forn( int , i , 0 , n + 1 ){
    forn( int , j , 0 , n + 1 ){
       int z = n - ( i + j ) ;
       if( z < 0 ) continue ;
       if( i * 10000 + j * 5000 + z * 1000 == y ){
        cout << i << " " << j << " " << z ;
        return 0 ;
       }
    }
  }
  cout << "-1 -1 -1" ;
}


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

int n;
int h[100100], dp[100100];

int max(int a, int b) {
    return (a > b ? a : b);
}

int min(int a, int b) {
    return (a < b ? a : b);
}
 
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &h[i]);
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        dp[i] = 1e9;
        for (int j = i - 1; j >= max(0, i - 2); j--) {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }
    printf("%d\n", dp[n - 1]);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

vint e[100005];
vint in, w;
void update(int v) {
    int sz = e[v].size();
    rep(i, sz) in[e[v][i]]--;
}

int main() {
    int n;
    cin >> n;
    in.resize(n, 0);
    w.resize(n);
    vpair e2;
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        e[a].push_back(b);
        e[b].push_back(a);
        in[a]++;
        in[b]++;
        e2.emplace_back(a, b);
    }

    vint c(n);
    rep(i, n) cin >> c[i];
    sort(all(c));

    vbool flg(n, false);
    rep(i, n) {
        int mn = INF;
        int id = -1;
        rep(j, n) {
            if (flg[j]) continue;
            if (mn > in[j]) {
                mn = in[j];
                id = j;
            }
        }
        w[id] = c[i];
        flg[id] = true;
        update(id);
    }

    ll ans = 0;
    rep(i, n-1) ans += min(w[e2[i].fi], w[e2[i].se]);
    cout << ans << endl;
    rep(i, n) printf("%d%s", w[i], i != n-1 ? " " : "\n");
    return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, p[200010];
pair<int,int> x[200010];
multiset<int> st1, st2;
ll ans = 1000000000000000000;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i].first >> x[i].second;
		if (x[i].first > x[i].second)swap(x[i].first, x[i].second);
		st1.insert(x[i].first);
		st2.insert(x[i].second);
	}
	sort(x, x + n);
	for (int i = 0; i < n; i++) {
		ans = min(ans, (ll)(*st1.rbegin() - *st1.begin())*(*st2.rbegin() - *st2.begin()));
		st1.erase(st1.lower_bound(x[i].first));
		st1.insert(x[i].second);
		st2.erase(st2.lower_bound(x[i].second));
		st2.insert(x[i].first);
	}
	cout << ans << endl;
}


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

int main() {
  // ここにプログラムを追記
  int s1,s2,s3,N;
    
  cin >> N;
  
  s1 = N/100;
  s2 = (N-(s1*100))/10;
  s3 = (N-(s1*100)-(s2*10));
  
  cout << s1+s2+s3 << endl;
}

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

#define ll long long
#define pb push_back
#define pii pair<int, int>
#define sz size()

#ifdef LOCAL
template<class T1, class T2>
ostream &operator<<(ostream &os,const pair<T1,T2> &p){os<<'{'<<p.first<<", "<<p.second<<'}';return os;}
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>void __f(const char* name,Arg1&& arg1){cerr<<name<<" : "<<arg1<<"\n";}
template<typename Arg1,typename... Args>void __f(const char* names,Arg1&& arg1,Args&&... args)
{const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" , ";__f(comma+1, args...);} 
#define traceloop(x,a){cerr<<#a<<": ";for(ll _=0;_<x;_++)cerr<<a[_]<<" ";cerr<<"\n";}
#else
#define trace(...) 69
#define traceloop(...) 69
#endif

const int N = 1 << 21;
const int MOD = 1e9 + 7;
vector<int> dp(N);

void add(int &x, int y)
{
	x += y;
	if(x >= MOD)
		x -= MOD;
}

int main()
{
	ios::sync_with_stdio(0);
	int i, j, k, n;

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

	dp[0] = 1;
	for(int mask = 0; mask < (1 << n); ++mask)
	{
		i = __builtin_popcount(mask);

		for(j=0;j<n;++j)
			if(a[i][j] and ((1 << j) & mask) == 0)
				add(dp[mask ^ (1 << j)], dp[mask]);
	}

	cout << dp[(1 << n) - 1];

	return 0;
}

Measured memory_bytes: 11224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

const int MAX_V = 3e2;
vector<vector<ll>> cost(MAX_V, vector<ll>(MAX_V, INF));

void warshall_floyd(){
    rep(k, MAX_V){
        rep(i, MAX_V){
            rep(j, MAX_V){
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }
}

int main(){
    int N, M; ll L;
    cin >> N >> M >> L;
    rep(i, M){
        int A, B, C;
        cin >> A >> B >> C;
        A--, B--;
        cost[A][B] = C, cost[B][A] = C;
    }
    rep(i, N) cost[i][i] = 0;
    warshall_floyd();
    rep(i, N){
        rep(j, N){
            if(i != j && cost[i][j] <= L) cost[i][j] = 1;
            else cost[i][j] = INF;
        }
    }
    warshall_floyd();
    int Q;
    cin >> Q;
    rep(i, Q){
        int s, t;
        cin >> s >> t;
        s--, t--;
        if(cost[s][t] == INF) cout << -1 << endl;
        else cout << cost[s][t]-1 << endl;
    }
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
	ll N;
	cin>>N;
	vector<ll> v(N);
	int in;
	cin>>v[0];
	FOR(i,1,N){
		cin>>in;
		v[i] = v[i-1] + in;
	}


	ll la,lb,ra,rb,res=v[N-1];
	ll L=0,R=2;
	vector<ll> key(4);
	FOR(i,2,N-1){
		while(abs(v[i-1]-v[L]-v[L])>abs(v[i-1]-v[L+1]-v[L+1])){
			L++;
		}
		while(abs(v[N-1]-v[R]-v[R]+v[i-1])>abs(v[N-1]-v[R+1]-v[R+1]+v[i-1])){
			R++;
		}
		rb=v[N-1]-v[R];
		ra=v[R]-v[i-1];
		lb=v[i-1]-v[L];
		la=v[L];

		key[0]=la;
		key[1]=lb;
		key[2]=ra;
		key[3]=rb;
		sort(key.begin(),key.end());
		if(key[3]-key[0]<res) res=key[3]-key[0];
		//cout<<"L="<<L<<" i="<<i<<" R="<<R<<endl;

		//cout<<la<<" "<<lb<<" "<<ra<<" "<<rb<<endl;

	}
	cout<<res<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(long long i=0;i<n;i++)
#define INF (1ll<<58)

	
int main(){
	long long n,m;
	while(cin >> n >> m && n){
		long long land[200][200] , ship[200][200] ;
		rep(i,200)rep(j,200)land[i][j] = ship[i][j] = INF;
		rep(i,200)land[i][i] = ship[i][i] = 0;
		
		rep(i,m){
			string l;
			long long a,b,c; cin >> a >> b >> c >> l;
			a--,b--;
			if(l=="L")land[a][b] = land[b][a] = min(c,land[a][b]);
			else      ship[a][b] = ship[b][a] = min(c,ship[a][b]);
		}
		rep(k,n)rep(i,n)rep(j,n)land[i][j] = min(land[i][j],land[i][k]+land[k][j]);
		rep(k,n)rep(i,n)rep(j,n)ship[i][j] = min(ship[i][j],ship[i][k]+ship[k][j]);
		
		long long r; cin >> r;
		long long R[1000];	
		rep(i,r)cin >> R[i] , R[i]--;
		
		long long dp[2][200];
		rep(j,2)rep(k,200)dp[j][k] = INF;
		dp[0][R[0]] = 0;
		
		rep(bit,r-1){
			rep(cur,n){
				rep(next,n){
					long long newCost = dp[bit%2][cur] + land[R[bit]][cur] + ship[cur][next] + land[next][R[bit+1]];
					dp[(bit+1)%2][next] = min( dp[(bit+1)%2][next],newCost);
				}
				dp[(bit+1)%2][cur] = min(dp[(bit+1)%2][cur],dp[bit%2][cur]+land[R[bit]][R[bit+1]]);
			}
			rep(j,200)dp[bit%2][j] = INF;
		}
		long long ret = INF;
		rep(i,n){
			ret = min(dp[(r-1)%2][i],ret);
		}
		cout << ret << endl;
		
	}
}

Measured memory_bytes: 1556
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define irep(i, n) for(int i = n-1; i >= (int)0; i--)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n),b(n);
    rep(i,n)std::cin >> a[i];
    rep(i,n)std::cin >> b[i];
    int ans=0,dum=0;
    rep(i,n){
        dum=0;
        rep(j,i+1)dum+=a[j];
        rrep(j,i,n)dum+=b[j];
        ans=max(ans,dum);
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(void){
    int A[4]={6,4,3,2};
    REP(i,4){
        int a,b;
        cin>>a>>b;
        cout<<A[a-1]*1000*b<<endl;
    }
}





Measured memory_bytes: 3096
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
const int N = 1e5 +10;
const double eps = 1e-10;
int n;
double v1[N],p[N],v2[N],th[N];
double pw;
double dcmp(double x)
{
    if(fabs(x)<eps)return 0;
    if(x<0)return -1;
    return 1;
}
double fun(double x)
{
    double ans = 0;
    for(int i=0; i<n; i++)
    {
        double temp  = th[i] - x*v1[i];
        if(dcmp(temp)<=0)continue;
        temp  = temp / v2[i];
        ans+=temp*p[i];
    }
    return ans + x*pw;
}
int main()
{
    while(~scanf("%d",&n)&&n)
    {
        scanf("%lf",&pw);

        for(int i=0; i<n; i++)
        {
            scanf("%lf%lf%lf%lf",&v1[i],&p[i],&v2[i],&th[i]);
        }
        double l = 0, r = 100000;
        int kas = 1;
        while(kas<200)
        {
            double mid = (l+r)/2.0;
            double midmid = (mid+r)/2.0;
            if(dcmp(fun(mid)-fun(midmid))<0)
                r = midmid;
            else l = mid;
            kas++;
        }
        printf("%lf\n",fun(l));
    }
    return 0;
}

Measured memory_bytes: 4356
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>
#define m 1000000007
int main()
{
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
}

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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int N;
    cin >> N;
    vector<int> p(N);
    vector<int> q(N);
    REP(i, N)
    {
        cin >> p.at(i);
        q.at(i) = p.at(i);
    }
    sort(q.begin(), q.end());

    int cnt = 0;
    REP(i, N)
    {
        if (p.at(i) != q.at(i))
            cnt++;
    }

    if (cnt <= 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

using namespace std;

typedef long long LL;
#define N 120000

const LL mod=1000000007;
LL n,ans,a[N],b[N],d[N],cnt[N],f[N];
bool vis[N];

int main(){
	scanf("%lld",&n);
	for (LL i=1;i<=n;++i){
		scanf("%lld",a+i);
		++d[a[i]];
	}
	for (LL i=1;i<=n;++i){
		if (d[i]>2){puts("0"); return 0;}
		if (d[i]<2||vis[i]) continue;
		vis[i]=1; b[a[i]]=i;
		for (LL j=a[i];j!=i;j=a[j]){
			if (vis[j]){puts("0"); return 0;}
			vis[j]=1; b[a[j]]=j;
		}
	}
	ans=1;
	for (LL i=1;i<=n;++i)
		if (!d[i]){
			LL j=i,len1=0,len2=1;
			for (;!vis[j];j=a[j]){vis[j]=1; ++len1;}
			for (j=b[j];d[j]<2;j=b[j]) ++len2;
			if (len1>len2){puts("0"); return 0;}
			if (len1<len2) ans=ans*2%mod;
		}
	for (LL i=1;i<=n;++i)
		if (!vis[i]){
			vis[i]=1;
			LL len=1;
			for (LL j=a[i];!vis[j];j=a[j]){vis[j]=1; ++len;}
			++cnt[len];
		}
	for (LL i=1;i<=n;++i){
		LL t=i!=1&&(i&1)?2:1;
		f[0]=1; f[1]=t;
		for (int j=2;j<=cnt[i];++j) f[j]=(f[j-1]*t+f[j-2]*(j-1)%mod*i)%mod;
		ans=ans*f[cnt[i]]%mod;
	}
	printf("%lld\n",ans);
	
	return 0;
}
			

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

int K; string S;
void input()
{
    cin>>K>>S;
}

void solve()
{
    if(S.length()<=K) cout<<S<<endl;
    else{
        for(int i=0;i<K;++i) cout<<S[i];
        cout<<"..."<<endl;
    }
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>
#include <tuple>
#include <map>
#include <cassert>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> ds(n);
    for(int i = 0; i < n; ++i){
        cin >> ds.at(i);
    }
    sort(ds.begin(), ds.end());
    ll index = ds.size() / 2;
    cout << max(0LL, (ds.at(index) - ds.at(index - 1))) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<queue>
#include<algorithm>
#define maxn 100005
#define LL long long
#define INF (LL)1e16
using namespace std;
int x,y,z,n;
LL sau[maxn],sag[maxn],scu,ans=-INF;
struct node { int a,b,c; } a[maxn];
bool cmp(node p,node q) { return p.a-p.b<q.a-q.b; }
priority_queue<int,vector<int>,greater<int> > au,ag;
int main()
{
	scanf("%d%d%d",&x,&y,&z); n=x+y+z;
	for(int i=1;i<=n;i++) 
	{
		scanf("%d%d%d",&a[i].a,&a[i].b,&a[i].c);
		a[i].a-=a[i].c,a[i].b-=a[i].c;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=n;i;i--)
	{
		sau[i]=sau[i+1]+1ll*a[i].a;
		au.push(a[i].a);
		if(au.size()>x) { sau[i]-=au.top(); au.pop(); }
	}
	for(int i=1;i<=n;i++)
	{
		sag[i]=sag[i-1]+1ll*a[i].b;
		ag.push(a[i].b);
		if(ag.size()>y) { sag[i]-=ag.top(); ag.pop(); }
	}
	for(int i=1;i<=n;i++) scu+=1ll*a[i].c;
	for(int i=y;i<=n-x;i++) ans=max(ans,sau[i+1]+sag[i]);
	printf("%lld\n",ans+scu);
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;++i) {
    cin >> a[i];
  }
  vector<ll> diff(n-1);
  for(int i=0;i<n-1;++i) {
    diff[i] = a[i+1] - a[i];
  }
  vector<ll> ans(n);
  for(int i=0;i<n-1;i+=2) {
    ans[i+2] = ans[i] + diff[i] * 2;
  }
  ans[n-2] = ans[0] - diff[n-2] * 2;
  for(int i=n-2;i>1;i-=2) {
    ans[i-2] = ans[i] - diff[i-2] * 2;
  }
  ll add = (2 * a[0] - ans[0] - ans[1]) / 2;
  for(int i=0;i<n;++i) {
    ans[i] += add;
  }
  printv(ans);
}


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

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

    ll sum1 = 0;
    ll sum2 = 0;

    ll cnt1 = 0;
    ll cnt2 = 0;

    ll a;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        sum1 += a;
        sum2 += a;
        if (i % 2 == 0)
        {
            if (sum1 <= 0)
            {
                cnt1 += 1 - sum1;
                sum1 = 1;
            }

            if (sum2 >= 0)
            {
                cnt2 += sum2 + 1;
                sum2 = -1;
            }
        }
        else
        {
            if (sum1 >= 0)
            {
                cnt1 += sum1 + 1;
                sum1 = -1;
            }

            if (sum2 <= 0)
            {
                cnt2 += 1 - sum2;
                sum2 = 1;
            }
        }
    }

    cout << min(cnt1, cnt2) << endl;
}

Measured memory_bytes: 256
require 'prime'

X = gets.to_i

beki = []

(1..1000).each do |b|
  (2..100).each do |k|
    beki << b ** k if b ** k <= 1000
  end
end

beki.uniq!.sort!
puts beki.reverse.bsearch { |x| -x >= -X }


Measured memory_bytes: 2684
h, w = map(int, input().split())
a = [input() for _ in range(h)]
dic = {}
for i in a:
    for j in range(w):
        po = i[j]
        if po in dic.keys():
            dic[po] += 1
        else: dic[po] = 1
odd = 0
mod4 = 0
for i in dic:
    if dic[i] % 2:
        odd += 1
    if dic[i] % 4:
        mod4 += 1
if h % 2 == 0 and w % 2 == 0:
    if not mod4:
        print('Yes')
    else: print('No')
elif h % 2 and w % 2:
    if odd == 1 and mod4 <= (h//2+w//2+1):
        print('Yes')
    else: print('No')
else:
    if h % 2: k = w//2
    else: k = h//2
    if odd == 0 and mod4 <= k:
        print('Yes')
    else: print('No')

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main(){
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  for(int i = 0; i < 4; i++){
    reverse(divide[i].begin(), divide[i].end());
  }
  bool can = true;
  for(int i = 0; i < s.size();){
    bool can2 = false;
    for(int j = 0; j < 4; j++){
      string d = divide[j];
      if(s.substr(i, d.size()) == d){
        can2 = true;
        i += d.size();
      }
    }
    if(!can2){
      can = false;
      break;
    }
  }
  
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;
void a()
{
    string s;
    cin >> s;
    map<char, int> count;
    for (int i = 0; i < 4; i++)
    {
        if (count.count(s[i]) == 0)
        {
            count.insert(make_pair(s[i], 1));
        }
        else
        {
            count.at(s[i]) += 1;
        }
    }
    if (count.size() == 2 && count.at(s[0]) == 2)
        cout << "Yes";
    else
    {
        cout << "No";
    }
    return;
}
int main(void)
{
    a();
}

Measured memory_bytes: 256
import math

A, B = input().split()

A = int(A)
B_p = int(B.split(".")[0])
B_c = int(B.split(".")[1])

if (A == 0) or (B == 0):
  print(0)
else:
  ABp = A * B_p
  ABc = int(str(A * B_c)[:-2]) if len(str(A * B_c))>2 else 0
  print(ABp+ABc)

Measured memory_bytes: 61964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    VI a(n); cin >> a;
    int ans = 0;
    bool flag = true;
    while (flag) {
        flag = false;
        FOR(i, 1, n)if (a[i - 1] > a[i]) {
            swap(a[i - 1], a[i]);
            ++ans;
            flag = true;
        }
    }
    FOR(i, 0, n)cout << a[i] << ENDL(i, n);
    cout << ans << "\n";
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	ll n, d;
	cin >> n >> d;
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		ll x, y;
		cin >> x >> y;
		if (x * x + y * y <= d * d) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3620
import java.lang.StringBuilder

fun main(args: Array<String>){
    val (SX, SY, TX, TY) = readLine()!!.split(" ").map { it.toInt() }
    val go = StringBuilder()
    val back = StringBuilder()
    repeat(TX - SX){
        go.append("R")
        back.append("L")
    }
    repeat(TY - SY){
        go.append("U")
        back.append("D")
    }
    println(go.toString() + back.toString() + "DR" + go.toString() + "UL" + "UL" + back.toString() + "DR")
}

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

#define x first
#define y second
#define endl '\n'
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()
#define show(x) cout<<(#x)<<" is "<<(x)<<endl

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set=tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef vector<vector<int>> matrix;

const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=5e5+123;
const int M=1e6+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

int a[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    double d=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        d+=a[i];
    }
    d/=n;
    double mn=inf;
    int j=-1;
    for(int i=0;i<n;i++){
        if(abs(a[i]-d)<mn){
            mn=abs(a[i]-d);
            j=i;
        }
    }
    cout<<j;
    return 0;
}


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define MOD 1000000007
typedef pair<li, li> PI;

li cnt[42];
bool bk[42];
li n;
li k;

inline li calc(li x) {
	if (x >= 0 && !bk[x]) {
		return 0;
	}
	li res = 0;
	rep(i, 42) {
		if (i < x) {
			res += (1ll << i) * max(cnt[i], n - cnt[i]);
		} else if (i == x) {
			// force 0
			res += (1ll << i) * cnt[i];
		} else {
			// force k
			res += (1ll << i) * (bk[i] ? n - cnt[i] : cnt[i]);
		}
	}
	return res;
}

int main(void)
{
	cin >> n >> k;
	rep(i, n) {
		li a;
		cin >> a;
		rep(j, 42) {
			cnt[j] += ((a & (1ll << j)) > 0 ? 1 : 0);
		}
	}
	rep(i, 42) {
		bk[i] += ((k & (1ll << i)) > 0);
	}

	li res = 0;
	rep(i, 42) {
		res = max(res, calc(i));
	}
	res = max(res, calc(-1));
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main (int argc, char *argv[]) {
    int N;

    cin >> N;

    vector<pair<int,int>> v;

    for (int i = 0; i < N; ++i) {
        int tmp;
        cin >> tmp;
        v.push_back(make_pair(tmp ,i));
    }

    sort(v.begin(), v.end(), [](pair<int, int> lhs, pair<int, int> rhs)
    {
        return lhs.first > rhs.first;
    });

    for (int i = 0; i < N; ++i) 
    {
        for (auto e : v)
        {
            if (e.second == i)
            {
                continue;
            }
            else
            {
                cout << e.first << endl;
                break;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 3312
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,a,b,h;
    cin >>a>>b>>h;

    ans=(a+b)*h/2;

    cout <<ans<<endl;

    return 0;

}

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

vector<ll> to[3003];
ll cn[2020];

int main(){
    ll n,x,y;cin>>n>>x>>y;
    rep(i,0,n-1){
        to[i].push_back(i+1);
        to[i+1].push_back(i);
    }
    x--;y--;
    to[x].push_back(y);
    to[y].push_back(x);
    vector<vector<ll> > dis(n,vector<ll>(n,-1));
    queue<ll> q;
    rep(i,0,n){
        q.push(i);
        dis[i][i]=0;
        while(!q.empty()){
            ll v=q.front();
            q.pop();
            for(auto nx:to[v]){
                if(dis[i][nx]!=-1)continue;
                dis[i][nx]=dis[i][v]+1;
                q.push(nx);
            }
        }
        
    }
    rep(i,0,n){
        rep(j,i,n){
            cn[dis[i][j]]++;
        }
    }
    rep(i,1,n)cout<<cn[i]<<endl;

}







Measured memory_bytes: 31744
#include <bits/stdc++.h>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to; int cost; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}

signed main()
{
   int N; cin >> N;
   V<int> A(N);
   REP(i, N) {
      cin >> A[i];
   }

   V<int> last(21, -1);
   int MAX = -1, sum = 0;
   FOR(i, 0, N) {
      FOR(k, 0, 21) {
         if (A[i] >> k & 1) {
            MAX = max(MAX, last[k]);
            last[k] = i;
         }
      }
      sum += (i - MAX);
   }
   cout << sum << endl;

   return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static void Main(string[] args) {
        //入力
        //int N = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        int A = int.Parse(s.Split(' ')[0]);
        int B = int.Parse(s.Split(' ')[1]);
        //検証



        //出力
        Console.WriteLine(Math.Max(Math.Max(A + B, A - B), A * B));
    }
}

Measured memory_bytes: 13140
// https://atcoder.jp/contests/abc100/tasks/abc100_b

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>

using namespace std;


int main (int argc, char* argv[]) {
	long long d, n;
	cin >> d >> n;

	if (n == 100) n++;

	long long base = pow(100, d);
	cout << base * n << endl;
}


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

int main(){
	
	int n,y,i,j,k;
	
	cin>>y>>n;
	
	for(i=0;i<=n/10000;i++)
	 for(j=0;j<=n/5000;j++){
	 	k=y-i-j;
	 	if(k>=0&&i*10000+j*5000+k*1000==n){
	 		cout<<i<<" "<<j<<" "<<k;
	 		return 0;
	 	}
	 }
	 cout<<"-1 -1 -1"<<endl;
	 
	 return 0;
}

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

using ll = long long;

void solve(long long N){
    N %= 1000;
    cout<<(1000 - N) % 1000<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

#define DIV 1000000007

map<long long, long long> prime;

/*
 *素因数分解
 */
void prime_factor(long long num){
	long long bak = num;
	for(int i = 2; i*i <= num; i++){
		while(bak % i == 0){
			//i is prime
			prime[i]++;
			bak /= i;
		}
	}
	if(bak > 1){
		prime[bak]++;
		//bak is prime
	}
}


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

	for(int i = 1; i <= N; i++){
		prime_factor(i);
	}
	long long ans = 1;
	for(map<long long,long long>::iterator it = prime.begin(); it != prime.end(); it++){
		ans *= (1 + it->second);
		ans %= DIV;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    char A[10];
    if (S.length() >= 10) {
        cout << "NO" << endl;
        return 0;
    }
    int j = 0;

    if (S[0] != 'A') {
        A[0] = 'A';
        j++;
        rep(i, 3){
            A[i+j] = S[i];
        }
    } else {
        rep(i, 4) {
            A[i] = S[i];
        }
    }
    if (S[4-j] != 'A') {
        j++;
        A[4] = 'A';
        A[5] = S[5-j];
    } else {
        for (int i = 4; i < 6; i++) {
            A[i] = S[i-j];
        }
    }
    if (S[6-j] != 'A') {
        j++;
        A[6] = 'A';
        A[7] = S[7-j];
    } else {
        for (int i = 6; i < 8; i++) {
            A[i] = S[i-j];
        } 
    }
    if (S.length() < 8-j) {
            A[8] = S[8-j];
        } else {
            A[8] = 'A';
        }
    rep(i, 9) {
        //cout << A[i];
    }
    string str(A, 9);
    //dump(str);
    if (str == "AKIHABARA") {
        cout << "YES" << endl;
    } else {
        cout << "NO" <<  endl;
    }

    return 0;
}


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

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  vector<int> num(k);

  for(int i = 0; i < k; i++) {
    num.at(i) = a + i;
    if(a + i > b)
      break;
    cout << a + i << endl;
  }
  for(int i = k-1; i > -1; i--) {
    int same = 0;
    for(int j = 0; j < k; j++) {
     if(b - i == num.at(j) ) {
       same++;
       break;
     }
    }
    if(b - i < a)
      return 0;
    if(same == 0)
      cout << b - i << endl;
  }
}

Measured memory_bytes: 256
import copy
N,x = map(int,input().split())
a = list(map(int,input().split()))
b = copy.deepcopy(a)
ans = 0
if a[0]>x:
    ans+=a[0]-x
    a[0] = x
for i in range(N-1):
    if a[i]+a[i+1]>x:
        ans += (a[i]+a[i+1])-x
        a[i+1] -= (a[i]+a[i+1])-x

print(ans)

Measured memory_bytes: 89324
#include <bits/stdc++.h>
using namespace std;
int a[30];
char s[105];
int main() {
    scanf("%s",s);
    int n=strlen(s);
    for (int i=0;i<n;i++) {
        a[s[i]-'a']++;
    }
    for (int i=0;i<26;i++) {
        if (a[i]%2==1) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 256
x = input()
count_s = 0
ans = 0
for i in range(len(x)):
    if x[i] == 'S':
        count_s += 1
    if x[i] == 'T':
        if count_s == 0:
            ans += 1
        else:
            count_s -= 1
ans += count_s
print(ans)


Measured memory_bytes: 3500
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,t,a;
  cin >> n >> t >> a;
  long double near = 1000000;
  int pos;
  rep(i, n){
    int h;
    cin >> h;
    long double tem = t - (long double)h * 0.006;
    if(near > abs(tem - a)){
      near = abs(tem - a);
      pos = i + 1;
    }
  }
  cout << pos << endl;
}

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

int main(){
    int N;
    cin >> N;
    vector<string> blue_card(N);
    rep(i,N){
        cin >> blue_card[i];
    }
    int M;
    cin >> M;
    vector<string> red_card(M);
    rep(i,M){
        cin >> red_card[i];
    }
    int max_money = 0;
    rep(i,N){
        int money = 1;
        for(int j = i + 1; j < N; j++){
            if(blue_card[i] == blue_card[j]){
                money++;
            }
        }
        rep(j,M){
            if(blue_card[i] == red_card[j]){
                money--;
            }
        }
        max_money = max(max_money, money);
    }
    cout << max_money << endl;
}



Measured memory_bytes: 256
// Author: Shusuke Ueda
// AtCoder Beginner Contest 135 - Problem A

#include <iostream>

int main() {
    int a, b;
    std::cin >> a >> b;
    if ((a + b) % 2 == 0) {
        std::cout << (a + b) / 2 << std::endl;
    } else {
        std::cout << "IMPOSSIBLE" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
/****************************************************************
# @Author:      iLovePKU_zbtxdy
# @DateTime:    2020-02-06 21:50:15
# @Description: Think twice. Code once. 
# @More: Once lots of AC, try Brute-force,dynamic programming
****************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define close std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define eps 1e-8
typedef long long ll;
const int maxn = 1e6+10;
const int INF = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
ll mod = 1e9+7;
int main()
{
    string s[3];
    for(int i = 0; i < 3;i++){cin >> s[i];cout << s[i][0];}
    cout << endl; 
    
    system("pause");
}
/***************************************************************************
*stuff you should look for
*int overflow, array bounds
*special cases (n=1?), set tle
*do smth instead of nothing and stay organized
***************************************************************************/

Measured memory_bytes: 504
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int main(){
	long long n,k;
	cin>>n>>k;
	cout<<min(n%k,k-n%k)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<deque>

using namespace std;

#define sz(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;++i)
#define per(i,a,b) for(int i=b-1;i>=a;--i)
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
/////////////////////

int const N = 2e5 + 41;
ll a[N];
int n;
ll k;
vector<pll> v;
int p[N];

int F[N];

void upd(int x, int v){
	while(x < N){
		F[x] += v;
		x |= (x + 1);
	}
}

int get(int x){
	int r = 0;
	while(x >= 0){
		r += F[x];
		x = (x & (x + 1)) -1;
	}
	return r;
}

void solve(){
	cin >> n >> k;
	rep(i, 0, n){
		cin >> a[i];
		a[i] -= k;
	}
	ll cur = 0;
	v.pb(mp(0, -1));
	rep(i, 0, n){
		cur += a[i];
		v.pb(mp(cur, i));
	}
	sort(v.begin(), v.end());
	rep(i, 0, sz(v)) p[v[i].second] = i;

	ll ans = 0;
	rep(i, 0, sz(v)) if(v[i].second == -1){
		upd(i, 1);
		break;
	}
	rep(i, 0, n){
		ans += get(p[i]);
		upd(p[i], 1);
	}
	cout << ans << endl;
}


int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();


	return 0;
}

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

int main() {

    int n;
    scanf("%d",&n);
    vector<int> dp(3);
    for(int day = 0;day  < n;++day){
        vector<int> new_dp(3,0);
        vector<int> c(3);
        for(int i = 0;i < 3;++i) scanf("%d",&c[i]);
        for(int i = 0;i < 3;++i){
            for(int j = 0;j < 3;++j){
                if(i != j){
                    new_dp[j] = max(new_dp[j], dp[i] + c[j]);
                }
            }
        }
        dp = new_dp;
    }
    printf("%d\n",max({dp[0],dp[1],dp[2]}));
	return 0;
}


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

#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

const int N = 100010;

typedef long long LL;

void chkmax(LL &x, LL y){
	x = x > y ? x : y;
}

int n;
int op[N], A[N];
LL dp[N][3];

int main(){
	scanf("%d%d", &n, &A[1]);
	For(i, 2, n){
		char s[3];
		scanf("%s%d", s, &A[i]);
		op[i] = s[0] == '-';
	}

	For(i, 0, n) For(j, 0, 2) dp[i][j] = -(1ll << 60);
	dp[0][0] = 0;

	For(i, 1, n) For(j, 0, 2){
		LL val = dp[i - 1][j];
		For(k, 0, j)
			if(!op[i]) chkmax(dp[i][k], val + (k & 1 ? -A[i] : A[i]));
			else if(k != 2) chkmax(dp[i][k + 1], val + (k & 1 ? A[i] : -A[i]));
	}
	printf("%lld\n", max(dp[n][0], max(dp[n][1], dp[n][2])));
	
	return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;
     
     
    public class Main {
        public static void main(String[] args) {
     
            Scanner sc = new Scanner(System.in);
            int s = sc.nextInt();
            int w = sc.nextInt();

            if (w>=s){
                System.out.println("unsafe");
            } else {
                System.out.println("safe");
            }
        }
    }

Measured memory_bytes: 35688
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin >> a;

	vector<string> vec(a);
    vector<int> ans(4);
	for (int i = 0; i < a; i++) {
		cin >> vec.at(i);
	}
    for (int i = 0; i < a; i++) {
        if(vec.at(i)=="AC"){
            ans.at(0)+=1;
        }else if(vec.at(i)=="WA"){
            ans.at(1)+=1;
        }else if(vec.at(i)=="TLE"){
            ans.at(2)+=1;
        }else if(vec.at(i)=="RE"){
            ans.at(3)+=1;
        }
	}
    cout<<"AC x " << ans.at(0) << endl;
    cout<<"WA x " << ans.at(1) << endl;
    cout<<"TLE x " << ans.at(2) << endl;
    cout<<"RE x " << ans.at(3) << endl;
}



Measured memory_bytes: 6424
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int> >
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int> >
#define VPII vector<pair<int,int> >

#define INT ll

using namespace std;
/*........................................Define functions.........................................*/


/*....................................Define global variables .....................................*/



/*.........................................kemkemG0................................................*/
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);


	int N;
	cin>>N;
	VI P(N),P2(N);
	REP(i,N){cin>>P[i];}
	P2=P;

	sort(ALL(P));

	int cnt=0;

	REP(i,N){
		if(P[i]!=P2[i])cnt++;
	}

	YESNO(cnt==2||cnt==0)

	









		

		return 0;
}




Measured memory_bytes: 3652