akhauriyash/Code-Regression huggingface dataset:
//fifer a tak luboin
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <unordered_map>
#include <map>
#include <set>
#include <bits/stdc++.h>
 
#define ll long long
#define mp make_pair
#define pb push_back
#define s second
#define f first
#define endl "\n"
 
using namespace std; 
 
const ll inf = 1e14;
const int mod = 998244353;
const int N = (int)100100;
const double eps = 1e-10;                                     
const double pi = acos(-1.0);
int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() { 
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
    //freopen("bacon.in", "r", stdin);
    //freopen("bacon.out", "w", stdout);
    int n;
    cin >> n;
    int odd = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 2 != 0) odd++;
    }

    cout << fixed << setprecision(7) << double(odd) / double(n) << endl;
    
    return 0;    
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

ll dp[55][5000];

int main() {
    INIT;

    ll N, A;
    cin >> N >> A;
    vector<ll> x(N);

    rep(i, N) {
        cin >> x[i];
        x[i] -= A;
    }

    rep(i, 55) rep(j, 5000) dp[i][j] = 0;

    ll BUFF = 2500;
    dp[0][BUFF] = 1;

    rep(i, N) {
        for (ll s = 0; s + x[i] < 5000; s++) {
            if (dp[i][s] == 0) continue;
            dp[i + 1][s] += dp[i][s];
            dp[i + 1][s + x[i]] += dp[i][s];
        }
    }

    cout << dp[N][BUFF] - 1 << endl;

    return 0;
}

Measured memory_bytes: 5784
#ABC179-c

import sys,math,collections,itertools
input = sys.stdin.readline

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

def fact_fast(n):
    arr = []
    temp = n
    i=2
    if temp%i==0:
        cnt=0
        while temp%i==0:
            cnt+=1
            temp //= i
        arr.append([i, cnt])
    i =3
    while i*i<=temp:
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
        i += 2
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

N = int(input())
cnt = 0
for c in range(1,N-1):
    arr = fact_fast(N-c)
    tmp = 1
    for ar in arr:
        tmp *= (ar[1]+1)
    cnt += tmp
cnt +=1
print(cnt)


Measured memory_bytes: 69100
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001;
const int NMAX=8;
const int mod = 1000000007;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division

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, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
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];
  }
}comb(100005);

mint f(int n, int k){
	if (n<0)return 0;
	mint a=comb(n,k);
	a*=comb.fact[k];
	return a;

}

int n,k;
mint ans;
vector<vector<int>>g(100005);

int dfs(int u,int v=-1){


		for(int to:g[u]){

			if (to==v)continue;
	//		cout<<to<<endl;
			dfs(to,u);
		}

	int n1,k1;

//cout<<res<<'r'<<u<<'u'<<endl;
//cout<<n1<<'n'<<k1<<'k'<<endl;
			if (v==-1){
				n1=g[u].size()+1;
				k1=k;
			}
			else {
				n1=g[u].size()-1;
				k1=k-2;
			}
		//	combination c(k1);
			mint res=f(k1,n1);
			ans*=res;
			return 0;



}

int main()
{

	cin>>n>>k;


	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	ans=1;
	dfs(0);
	cout<<ans.x;


}


Measured memory_bytes: 10752
array = gets.split(" ").map(&:to_i)
biskets = gets.split(" ").map(&:to_i)
evens = []
odds = []
biskets.each do |i|
  if i.even?
    evens << i
  else
    odds << i
  end
end
sum_e = 0
sum_o = 0  
odds.length.step(0,-1) do |i|
  child = 1
  mother = 1
  i.times do |num|
    child *= (odds.length - num)
    mother *= (num + 1)
  end
  if i.even?
    sum_e += (child / mother)
  else
    sum_o += (child / mother)
  end
end
if array[1].even?
  puts sum_e * (2 ** evens.length)
else
  puts sum_o * (2 ** evens.length)
end

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

using namespace std;
using ll = long long;

int main() {
    string w;
    cin >> w;
    vector<bool> c(26,1);
    int n = w.size();
    bool check = 1;

    for(int i = 0; i < n; i++) {
        c.at(w.at(i) - 'a') = c.at(w.at(i) - 'a')^true;
    }
    for(int i = 0; i < 26; i++) {
        if(!c.at(i)) {
            check = 0;
        }
    }
    if(check) {
    cout << "Yes" << endl;
    } else {
    cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
*/#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
/*namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/#define lli long long int
#define uli unsigned long long int
#define INF 9999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000010
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  long long A,B,C,D,E,F,N,K,M,Z,sum=0,num=0,flag=0;string S,T;
  cin >> K;
  Out(10-K/200);
}

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

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

int h, w, n;

bool clearable(vector<string> _bd) {
    vector<string> bd = _bd;
    while (1) {
        // 落下
        vector<int> ty(w, h-1);
        for (int y=h-1; y>=0; --y) {
            for (int x=0; x<w; ++x) {
                if (_bd[y][x] != '.') {
                    bd[y][x] = '.';
                    bd[ty[x]][x] = _bd[y][x];
                    ty[x]--;
                }
            }
        }
        _bd = bd;

        bool updated = false;
        
        // 消滅
        for (int i=0; i<2; ++i) {
            vector<vector<int>> c(h, vector<int>(w, 0));
            for (int y=h-1; y>=0; --y) {
                for (int x=w-1; x>=0; --x) {
                    int px = x+dx[i];
                    int py = y+dy[i];
                    if (_bd[y][x] == '.') {
                        c[y][x] = 0;
                    } else if (h <= py || w <= px || _bd[y][x] != _bd[py][px]) {
                        c[y][x] = 1;
                    } else {
                        c[y][x] = c[py][px] + 1;
                    }
                }            
            }
            for (int y=0; y<h; ++y) {
                for (int x=0; x<w; ++x) {
                    if (c[y][x] < n) continue;
                    updated = true;
                    for (int j=0; j<c[y][x]; ++j) {
                        bd[y+dy[i]*j][x+dx[i]*j] = '.';
                    }
                }
            }
        }
        if ( ! updated) break;
        _bd = bd;
    }
    // 判定
    for (int y=0; y<h; ++y) {
        for (int x=0; x<w; ++x) {
            if (_bd[y][x] != '.') return false;
        }
    }
    return true;
}

int main() {
    cin >> h >> w >> n;
    vector<string> bd(h);
    for (int i=0; i<h; ++i) {
        cin >> bd[i];
    }
    for (int y=0; y<h; ++y) {
        for (int x=0; x<w-1; ++x) {
            swap(bd[y][x], bd[y][x+1]);
            if (clearable(bd)) {
                cout << "YES" << endl;
                return 0;
            }
            swap(bd[y][x], bd[y][x+1]);
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3220
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

int n,m,cnt;
vector<int> v[200010];
bool vis[200010];

inline void dfs(int x)
{
	cnt++;vis[x]=1;
	for(int i=0;i<v[x].size();i++) if(!vis[v[x][i]]){
		dfs(v[x][i]);
	}
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int x,y;cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	int ans=0;
	for(int i=1;i<=n;i++) if(!vis[i]){
		cnt=0;dfs(i);ans=max(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}

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

public class Main {
    int N, W;
    int[][] items;

    long solve() {
        long[] dp = new long[W+1];
        long max = 0L;
        for (int i = 0; i < N; i++) {
            int weight = items[i][0];
            int value = items[i][1];
            for (int j = W - weight; j >= 1; j--) {
                if (dp[j] > 0) {
                    dp[j+weight] = Math.max(dp[j+weight], dp[j] + value);
                    max = Math.max(max, dp[j+weight]);
                }
                if (j == weight) {
                    dp[j] = Math.max(dp[j], value);
                }
            }
        }
        for (int i = 0; i < N; i++) {
            max = Math.max(max, items[i][1]);
        }
        return max;
    }

    void main(FastScanner in, PrintWriter out) {
        N = in.nextInt();
        W = in.nextInt();
        items = new int[N][2];

        for (int i = 0; i < N; i++) {
            items[i][0] = in.nextInt();
            items[i][1] = in.nextInt();
        }
        out.println( solve() );
    }

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Main m = new Main();
        m.main(in, out);
        out.close();
        in.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream in) { br = new BufferedReader(new InputStreamReader(in)); }
        public int nextInt() { return Integer.parseInt(next()); }
        public long nextLong() { return Long.parseLong(next()); }
        public double nextDouble() { return Double.parseDouble(next()); }
        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try { st = new StringTokenizer(br.readLine()); }
                catch (IOException e) { e.printStackTrace(); }
            }
            return st.nextToken();
        }
        public String nextLine() {
            String str = "";
            try { str = br.readLine();
            } catch (IOException e) { e.printStackTrace(); }
            return str;
        }
        public void close() throws IOException { br.close(); }
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main()
{
    int a,i,tem1,rem,tem2,d=0;
    scanf("%d",&a);
    for(i=1;i<=a;i++)
    {
        int c=0;
        tem1=i;
        while(tem1!=0)
        {
                ++c;
                tem1/=10;

        }

        if(c%2!=0)
            ++d;

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


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

int main()
{
    double w, h, x, y;
    cin >> w >> h >> x >> y;

    double s = w * h / 2;

    int ans = 0;
    if (w / 2 == x && h / 2 == y)
    {
        ans = 1;
    }

    printf("%.10f %d\n", s, ans);

    return 0;
}

Measured memory_bytes: 256
def temperature(meter,t):
      temp = t - meter*0.006
      return temp


N = int(input())
s = input().split()
T = int(s[0])
A = float(s[1])
H = input().split()
tempera = [0]*N
for n in range(N):
    tempera[n] = temperature(int(H[n]),T)
for m in range(N):
    tempera[m] = abs(tempera[m]-A)
Min = min(tempera)
print(tempera.index(Min)+1)

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

int main(){
  while(true){
    int H, W;
    cin >> H >> W;
    if(H == 0 && W == 0) break;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if(i == 0 || i == H - 1) cout << '#';
        else if(j == 0 || j == W - 1) cout << '#';
        else cout << '.';
      }
      cout << endl;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final long[] x = new long[n];
        final long[] y = new long[n];

        for (int i = 0; i < n; i++) {
            x[i] = scanner.nextLong();
            y[i] = scanner.nextLong();
        }

        double result = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (j == i) {
                    continue;
                }

                final long a = (x[i] - x[j]) * (x[i] - x[j]);
                final long b = (y[i] - y[j]) * (y[i] - y[j]);
                result += Math.sqrt(a + b);
            }
        }

        System.out.println((n - 1) * result / (n * (n - 1)));
    }
}


Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int main(){
int a;
int b;
int c;
int t;
cin >> a >> b >> c;
if(a<b){
  t = a;
  a = b;
  b = t;

}
if(a<c){
  t = a;
  a = c;
  c = t;

}

if(a == (b+c)){
  cout << "Yes" << endl;
}else{
  cout << "No" << endl;
}
}

Measured memory_bytes: 256
'use strict';
(function(stdin) {
	var line  = stdin.toString();
	var result = (function(data) {
		return data
			.map(function(v) {
				return createTable(v[0],v[1]);
			}).join('\n');

		function createTable(rownum,colnum) {
			var table = [];
			for (var row = 0; row < rownum; row++) {
					(row === 0 || row === rownum -1) 
						? table.push(createLine(colnum,'#'))
						: table.push(createLine(colnum,'.'))
						;
			}
			table.push('');
			return table.join('\n');
		}

		function createLine(colnum,ch) {
			var line = '#';
			for (var col = 0; col < colnum -2 ; col++)
				line += ch;
			return line.concat('#');
		}

	}(
		line.split('\n0 0')[0]
		.split('\n')
		.map(function(v) {return v.split(' ').map(Number);})
	));
	console.log(result);

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 10864
#include<iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int a[100];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		if (i == n - 1) {
			cout << a[0]<<endl;
		}
		else {
			cout << a[n - i - 1] << " ";
		}
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>

using namespace std;

int main(){
	char a[10],b[10],c[10];
	int n, m;
	int A, B,C;
	vector<int> X;
	while (1){
		cin >> n >> m;
		if (n == 0 && m == 0){
			break;
		}
		X.push_back(n);
		while (1){
			int x = 0;
			for (size_t i = 0; i < 10; i++)
			{
				a[i] = 0;
				b[i] = 0;
				c[i] = 0;
			}
			while (n){
				c[x] = n % 10;
				n /= 10;
				x++;
			}
			sort(c, c + m);
			for (size_t i = 0; i < m; i++)
			{
				a[i] = c[i];
				b[m - i - 1] = c[i];
			}
			A = 0;
			B = 0;
			for (size_t i = 0; i < m; i++)
			{
				A *= 10;
				A += a[i];
				B *= 10;
				B += b[i];
			}
			auto i=find(X.begin(),X.end(),B - A);
			if (i != X.end()){
				cout <<i-X.begin()<< " " << *i << " " << X.end() - i<< endl;
				break;
			}
			X.push_back( B - A);
			n = B - A;
		}
		X.clear();
	}
}

Measured memory_bytes: 1216
#sum を計算しておく
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
q=int(input())
bc=[]
for i in range(q):
    bc.append([int(i) for i in input().split()])

import collections
collect = collections.Counter(a)

ans=0
for k,v in collect.items():
    ans += (k * v)
for i in bc:
    if i[0] in collect:
        if i[1] in collect:
            ans += ((i[1]-i[0]) * collect[i[0]])
            collect[i[1]] += collect.pop(i[0],0)
        else:
            ans += ((i[1]-i[0]) * collect[i[0]])
            collect[i[1]] = collect.pop(i[0],0)
    print(ans)

Measured memory_bytes: 100436
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n,x,t;
    cin >> n >> x >> t;
    int rest = (n+x-1)/x;
    cout << rest*t << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
typedef long long ll;
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define HERE cout<<"         here"
#define out(value) cout<<value<<en

int main(){
  int a,b;
  cin>>a>>b;

  if(a<b){
    int tmp;
    tmp=a;
    a=b;
    b=tmp;
  }

  int c=a-b;
  if(c>=2) {
    cout<<":("<<en
  }else {
    cout<<"Yay!"<<en
  }
  RE
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        //System.out.println(N.charAt(N.length() -1));
        if(N.charAt(N.length() -1) == 's'){
            System.out.println(N + "es");
        }else{
            System.out.print(N + "s");
        }
    }
}


Measured memory_bytes: 38416
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

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

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/
const int MAX = 2001;
string grid[MAX];
int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED

    int a; string s;
    cin >> a >> s;
    if (a < 3200) {
        cout << "red";
    } else {
        cout << s;
    }
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


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

int main() {
  int n,x,y,p;
  cin>>n;
  vector<int> h(n), dp(n,0);
  for (int i = 0; i < n; i++) {
    cin>>h.at(i);
  }
  dp[1]=abs(h[1]-h[0]);
  for (int i = 2; i < n; i++) {
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout << dp.at(n-1) << endl;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e18;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define lb(x,a) lower_bound(all(x),a)
#define ub(x,a) upper_bound(all(x),a)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
 ll n;
  cin >> n;
  ll now=0;
  rep(i,0,n) {
   ll a,b;
    cin >> a >> b;
    if(a==b) now++;
    else now=0;
   if(now>=3) {
     cout << "Yes" << endl;
     return;
   }
  }
 
  cout << "No" << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

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

using namespace std;

int main(void){
vector<string> str(3);
for(int i = 0; i < 3; i++) cin >> str[i];
for(int i = 0; i < 3; i++) cout << (char)(str[i][0] + 'A' - 'a');
cout << endl;
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

// 1をはさむ0のマス間の最大距離を返せばよい
// つまり1の最大連続回数+1が答え
// ex.  (st->0->1->1->0->1->0->g)ならば0->1->1->0を超えられれば良いので3が答え
int main(void)
{
	int iNum;		// マスの数
	int iMasu;		// マスの数字
	int iTmpMax;	// 1の連続回数
	int iMax;		// 1の最大連続回数
	
	int iCnt;
	int iAns;
	
	// 入力：マスの数
	scanf("%d", &iNum);
	
	// 1の最大連続数を数える
	iMax = 0;
	iTmpMax = 0;
	for(iCnt = 0; iCnt < iNum; iCnt++)
	{
		// 入力：マスの数字
		scanf("%d", &iMasu);
		
		switch(iMasu)
		{
			case 0:
				if(iTmpMax == 0)
				{
					continue;
				}
				else
				{
					if(iMax < iTmpMax)
					{
						iMax = iTmpMax;
					}
					iTmpMax = 0;
				}
				break;
			case 1:
				iTmpMax++;
				break;
		}
	}
	if(iMax < iTmpMax)
	{
		iMax = iTmpMax;
	}
	
	// サイコロの面数を計算
	iAns = iMax + 1;
	
	// 出力：必要なサイコロの面数
	printf("%d\n", iAns);
	
	return(0);
}


Measured memory_bytes: 2100
s=str(input())
s=list(s)
while True:
  del s[len(s)-1]
  if len(s)%2==0:
    count=0
    for i in range(0,int(len(s)/2)):
      if s[i]==s[i+int(len(s)/2)]:
        count=count+1
    if count==int(len(s)/2):
      print(len(s))
      break

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

using namespace std;

int main() {
  int H, W;
  cin >> H >> W;

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

  vector<int> okLineH, okLineW;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (a[i][j] == '#') {
        okLineH.push_back(i);
        break;
      }
    }
  }
  cout << endl;
  for (int i = 0; i < W; i++) {
    for (int j = 0; j < H; j++) {
      if (a[j][i] == '#') {
        okLineW.push_back(i);
        break;
      }
    }
  }
  cout << endl;

  for(int i = 0; i < okLineH.size(); i++) {
    for(int j = 0; j < okLineW.size(); j++) {
      cout << a[okLineH[i]][okLineW[j]];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#include<cstring>
#define ll long long
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>QUE;//きゅー
int length(char* str) {
	int len = strlen(str);
	return len;
}
ll GCD(ll a,ll b)
{

    ll r, tmp;

    /* 自然数 a > b を確認・入替 */
    if (a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法 */
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }


    return b;
}
ll LCM(ll a,ll b)
{

    ll r, x, tmp;
    ll i, j;
    ll lcm;
    i = a;
    j = b;

    /* 自然数 a > b を確認・入替 */
    if (a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法 */
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    lcm = (i / b) * j;

    return lcm;
}

int main()
{
    int A, B;
    cin >> A >> B;
    cout << 6 - A - B << endl;
}


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

int main() {
    while(true) {
        int n,m; scanf("%d%d", &n, &m);
        if(n==0) break;

        static int stones_at[150][10];
        static int stones_slip[150][10];
        static int stones_len[150];
        for(int i = 0; i < n; i++) {
            scanf("%d", stones_len+i);
            for(int j = 0; j < stones_len[i]; j++) {
                scanf("%d%d", stones_at[i]+j, stones_slip[i]+j);
            }
        }

        static int dp[150][10][80];
        for(int i = 0; i < n; i++)
            for(int j = 0; j < stones_len[i]; j++)
                for(int k = 0; k <= m; k++)
                    dp[i][j][k] = INT_MAX/2;

        for(int j = 0; j < stones_len[0]; j++)
            dp[0][j][m] = 0;
        for(int j = 0; j < stones_len[1]; j++)
            dp[1][j][m-1] = 0;

        for(int i = 1; i < n; i++) {
            for(int j = 0; j < stones_len[i]; j++) {
                for(int jf = 0; jf < stones_len[i-1]; jf++)
                    for(int k = 0; k <= m; k++)
                        dp[i][j][k] = min(dp[i][j][k], dp[i-1][jf][k]+
                                          (stones_slip[i][j]+stones_slip[i-1][jf])*abs(stones_at[i][j]-stones_at[i-1][jf]));
                if(i==1) continue;
                for(int jf = 0; jf < stones_len[i-2]; jf++)
                    for(int k = 0; k < m; k++)
                        dp[i][j][k] = min(dp[i][j][k], dp[i-2][jf][k+1]+
                                          (stones_slip[i][j]+stones_slip[i-2][jf])*abs(stones_at[i][j]-stones_at[i-2][jf]));
            }
        }

        int min_val = INT_MAX;
        for(int j = 0; j < stones_len[n-2]; j++)
            for(int k = 1; k <= m; k++)
                min_val = min(min_val, dp[n-2][j][k]);
        for(int j = 0; j < stones_len[n-1]; j++)
            for(int k = 0; k <= m; k++)
                min_val = min(min_val, dp[n-1][j][k]);

        printf("%d\n", min_val);
    }
    return 0;
}

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

typedef long long ll;
#define MAX_N 40
#define MAX_A 10
#define INF 1000000000001
ll dp[MAX_N+1][MAX_N*MAX_A+1][MAX_N*MAX_A+1];

int main(){	
	long long M_a;
	long long N;
	long long M_b;
	scanf("%lld",&N);
	vector<long long> c(N-1+1);
	vector<long long> a(N-1+1);
	vector<long long> b(N-1+1);
	scanf("%lld",&M_a);
	scanf("%lld",&M_b);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
		scanf("%lld",&b[i]);
		scanf("%lld",&c[i]);
	}

	for (int i = 0; i <= MAX_N*MAX_A; i++) {
		for (int j = 0; j <= MAX_N*MAX_A; j++) {
			dp[0][i][j] = INF;
		}
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= MAX_N*MAX_A; j++) {
			for (int k = 0; k <= MAX_N*MAX_A; k++) {
				dp[i][j][k] = dp[i-1][j][k];
				if (j == a[i-1] && k == b[i-1]) {
					dp[i][j][k] = min(dp[i][j][k], c[i-1]);
					continue;
				}
				if (j-a[i-1] >= 0 && k-b[i-1] >= 0) {
					// if (dp[i][j][k]>dp[i][j-a[i]][k-b[i]]+c[i]) cout << i << " " << j << " " << dp[i-1][j-a[i]][k-b[i]]+c[i] << endl;
					dp[i][j][k] = min(dp[i][j][k], dp[i-1][j-a[i-1]][k-b[i-1]]+c[i-1]);
				}
				// if (j <= 4 && k <= 4) cout << i << " " << j << " " << k << " " << dp[i][j][k] << endl;
			}
		}
		// cout << dp[i][1][2] << endl;
	}

	ll res = INF;
	for (int i = 1; max(i*M_a, i*M_b) <= MAX_N*MAX_A; i++) {
		if (dp[N][i*M_a][i*M_b] != 0) res = min(res, dp[N][i*M_a][i*M_b]);
	}

	if (res == INF) cout << "-1" << endl; else cout << res << endl;

	return 0;
}



Measured memory_bytes: 51712
import sys
from math import factorial
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    x, y = map(int, input().rstrip().split())
    # 全部 i + 1, j + 2が最初だったとする
    # a + 2b = x, 2a + b = y
    # =>
    # a = x - 2b
    # b = y - 2a
    # =>
    # b = y - 2x + 4b
    # 3b = 2x - y
    # b = (2x - y) / 3
    # a = (2y - x) / 3
    if (2 * x - y) % 3 != 0 or (2 * y - x) % 3 != 0:
        print(0)
        return
    a = (2 * x - y) // 3
    b = (2 * y - x) // 3
    if a < 0 or b < 0:
        print(0)
        return
    # (a + b) C min(a, b)
    # => (a + b)! / (min(a, b) ! * (a + b - min(a, b)) !
    mod = 10**9 + 7
    ans = (factorial_mod(a + b, mod) * pow(factorial_mod(min(a, b), mod), mod - 2, mod)
           * pow(factorial_mod(a + b - min(a, b), mod), mod - 2, mod)) % mod
    print(ans)


def factorial_mod(a, mod):
    ans = 1
    for v in range(1, a + 1):
        ans *= v
        ans %= mod
    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 9052
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
int main(){
    string a,b;
    cin >> a >>b;
    string ans = a+b;
    double ans_ = sqrt(stoi(ans));
    if(ceil(ans_) == floor(ans_)){
        cout << "Yes" << endl;
    }
    else cout << "No" <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <climits>
#include <numeric>
#include <algorithm>

using namespace std;

int main()
{
    int64_t N, K;
    cin >> N >> K;
    if(K >= N){
        cout << "0\n";
        return 0;
    }
    vector<int64_t> hs(N);
    for(auto& h : hs) cin >> h;
    sort(begin(hs), end(hs));
    cout << accumulate(begin(hs), end(hs) - K, 0L) << '\n';
}


Measured memory_bytes: 1792
import java.util.*;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);  
   	int n = sc.nextInt();
    int as[] = new int[n+2];
    int acs[] = new int[n];
    int ap = 0;
    int in,out;
    
    as[0] = 0;
    as[1] = sc.nextInt();
    ap += Math.abs(as[1]);
    in = as[1];
    
    for(int i = 2;i <= n;i++) {
      as[i] = sc.nextInt();
      out = as[i] - as[i-1];
      ap += Math.abs(out);
      if(in * out < 0)acs[i-2] = Math.abs(in) + Math.abs(out) -Math.abs(as[i]-as[i-2]);
      else acs[i-1] = 0;
      in = out;
    }  
    as[n+1] = 0;
    out = as[n+1] - as[n];
    ap += Math.abs(out);
    if(in * out < 0)acs[n-1] = Math.abs(in) + Math.abs(out) -Math.abs(as[n+1]-as[n-1]);
    else acs[n-1] = 0;
    
    for(int i = 0;i < n;i++){
      System.out.println(ap - acs[i]);
    }
    
    

  }
}


Measured memory_bytes: 60936
import sys
MOD=10**9+7


h,w,k=map(int,input().split())

dp=[[0]*w for _ in range(h+1)]

dp[0][0]=1

#初期値が0の辞書
zentan1=[0]*(w-1)
zentan2=[0]*(w)

for i in range(2**(w-1)):
    if "11" not in str(bin(i)):
        
        s=(str(bin(i))[2:]).zfill(w-1)
        for index,ss in enumerate(s):        
            #print(index,ss)
            if ss=="1":
                zentan1[index]+=1
            else:
                if index==0:
                    zentan2[index]+=1
                elif index==len(s)-1:
                    zentan2[index+1]+=1
                    if s[index-1]=="0":
                        zentan2[index]+=1
                else:
                    if s[index-1]=="0":
                        zentan2[index]+=1
        #print(zentan1)
        #print(zentan2)






        """
        j=0
        while j<w-1:
            #print(j)
            if i>>j & 1:
                #print(j)
                zentan1[j]+=1
            j+=1
        """

#print("11",zentan1)
#print("00",zentan2)

for i in range(1,h+1):
    x=0
    while x<w:
        for index,mv in enumerate([-1,0,1]):
            if 0<= x+mv < w:
                if index==1:
                    dp[i][x]+=dp[i-1][x+mv]*zentan2[x]
                elif index==0:
                    dp[i][x]+=dp[i-1][x+mv]*zentan1[x-1]
                elif index==2:
                    dp[i][x]+=dp[i-1][x+mv]*zentan1[x]

        x+=1
    #print(dp[i])
print(dp[h][k-1]%MOD)


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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;

int N;
V<int> S;

int main() {
    cin >> N;
    S.resize(N);
    for(int i = 0; i < N; i++) cin >> S[i];
    sort(all(S));
    int sum = accumulate(all(S), 0);

    for(int i = 0; i < N; i++){
        if(sum % 10 != 0){
            cout << sum << endl;
            return 0;
        }
        if(S[i] % 10 != 0) sum -= S[i];
    }
    cout << 0 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <utility>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int n, d[100005];
    cin >> n;
    for(int i=0;i<n;i++) cin >> d[i];

    sort(d,d+n);
    cout << d[n/2]-d[n/2-1] << endl;

    return 0;
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 1001001001001001000;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    if (n%2) {
        printf("No\n");
        return 0;
    } else {
        rep(i,n/2) {
            if (s[i] != s[i+n/2]) {
                printf("No\n");
                return 0;
            }
        }
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 3576
n=int(input())
c_0=0
c_1=0
c_2=0
c_3=0
for i in range(n):
    s=input()
    if s=="AC":
        c_0+=1
    elif s=="WA":
        c_1+=1
    elif s=="TLE":
        c_2+=1
    else:
        c_3+=1
print("AC x "+str(c_0))
print("WA x "+str(c_1))
print("TLE x "+str(c_2))
print("RE x "+str(c_3))

Measured memory_bytes: 9208
package main

import (
        "bufio"
        "fmt"
        "os"
        "sort"
        "strconv"
        "strings"
)

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
        sc.Scan()
        return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
        buf := make([]byte, 0, 1000000)
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func strSprit(str string) []string {
        cols := strings.Split(str, " ")
        return cols
}

func parseInt(str string) int {
        n, _ := strconv.Atoi(str)
        return n
}

func intSprit(str string) []int {
        strs := strSprit(str)
        cols := make([]int, len(strs))
        for i, v := range strs {
                cols[i] = parseInt(v)
        }
        return cols
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

type Pair struct {
        h, c int
}

type Pairs []Pair

func (p Pairs) Len() int {
        return len(p)
}
func (p Pairs) Less(i, j int) bool {
        return p[i].h < p[j].h
}
func (p Pairs) Swap(i, j int) {
        p[i], p[j] = p[j], p[i]
}

func main() {
        line := nextLine()

        spl := intSprit(line)

        N := spl[0]
        K := spl[1]

        m := make(map[int]int, N)

        for i := 0; i < N; i++ {
                n := parseInt(nextLine())
                if _, ok := m[n]; ok {
                        m[n] += 1
                } else {
                        m[n] = 1
                }
        }
        nums := []Pair{}

        for h, v := range m {
                nums = append(nums, Pair{h, v})
        }

        sort.Sort(Pairs(nums))

        t := 0
        l := 0
        r := 1
        min := 1000000000
        if nums[0].c > K {
                fmt.Println(0)
        } else {
                t += nums[0].c
        }
        for i := 1; i < len(nums); i++ {
                t += nums[i].c
                r = i
                if t >= K {
                        for t >= K {
                                if nums[r].h-nums[l].h < min {
                                        min = nums[r].h - nums[l].h
                                }
                                t -= nums[l].c
                                l++
                        }
                }
        }
        fmt.Println(min)
}



Measured memory_bytes: 11776
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
//int dx[] = {1, 0}, dy[] = {0, 1};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0 ,1, 1, 1, 0, -1, -1, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int n, W;
int w[101], v[101];
ll dp[101][N];
ll f(int i, int cost){
    if(cost < 0)
        return -1e18;
    if(i == n)
        return 0;
    ll &ans = dp[i][cost];
    if(ans == -1){
        ans = max(f(i + 1, cost), f(i + 1, cost - w[i]) + v[i]);
    }return ans;
}
int main(){
    //FL;
    FIN;
    cin >> n >> W;
    for(int i = 0; i < n; i++)
        cin >> w[i] >> v[i];
    for(int i = n; i >= 0; i--){
        for(int cost = 0; cost <= W; cost++){
            ll &ans = dp[i][cost];    
            if(i == n){
                ans = 0;
                continue;
            }
            ans = max(ans, dp[i + 1][cost]);
            if(cost - w[i] >= 0)
                ans = max(ans, dp[i + 1][cost - w[i]] + v[i]);
        }
    }
    cout << dp[0][W] << '\n';
    EjecuteTime;
    return 0;
}       

Measured memory_bytes: 82648
N = int(input())
As = list(map(int,input().split()))
mi=0
ma=0
r = []
for i in range(N):
 rate = As[i]//400
 if rate < 8:
     if not rate in r:
         r.append(rate)
         mi += 1
         ma += 1
 else:
     ma+=1
if mi == 0:
    mi =1
print(mi,ma)

Measured memory_bytes: 61932
public class Main {

    private static void solve() {
        int n = ni();
        int k = ni();
        char[] s = ns();
        
        s[k - 1] = (char)(s[k - 1] - 'A' + 'a');
        System.out.println(s);
    }

    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            @Override
            public void run() {
                long start = System.currentTimeMillis();
                String debug = args.length > 0 ? args[0] : null;
                if (debug != null) {
                    try {
                        is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }
                reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
                solve();
                out.flush();
                tr((System.currentTimeMillis() - start) + "ms");
            }
        }, "", 64000000).start();
    }

    private static java.io.InputStream is = System.in;
    private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
    private static java.util.StringTokenizer tokenizer = null;
    private static java.io.BufferedReader reader;

    public static String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new java.util.StringTokenizer(reader.readLine());
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    private static double nd() {
        return Double.parseDouble(next());
    }

    private static long nl() {
        return Long.parseLong(next());
    }

    private static int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = ni();
        return a;
    }

    private static char[] ns() {
        return next().toCharArray();
    }

    private static long[] nal(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nl();
        return a;
    }

    private static int[][] ntable(int n, int m) {
        int[][] table = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                table[i][j] = ni();
            }
        }
        return table;
    }

    private static int[][] nlist(int n, int m) {
        int[][] table = new int[m][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                table[j][i] = ni();
            }
        }
        return table;
    }

    private static int ni() {
        return Integer.parseInt(next());
    }

    private static void tr(Object... o) {
        if (is != System.in)
            System.out.println(java.util.Arrays.deepToString(o));
    }
}

Measured memory_bytes: 23252
/* Sriram S. Nair */
/* MNNIT Allahabad */
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
double p[3005];
double dp[3005][3005];
double visited[3005][3005];
int n;
double solve(int i, int heads){
	if(i==n+1){
		if(heads>n/2){
			return 1;
		}
		else{
			return 0;
		}
	}
	if(visited[i][heads]){
		return dp[i][heads];
	}
	double p1=p[i] * solve(i+1, heads+1);
	double p2=(1-p[i]) * solve(i+1, heads);
	visited[i][heads]=1;
	return dp[i][heads] = p1+p2;
}
int main(){
	cin>>n;
	memset(visited, 0, sizeof(dp));
	for(int i=1;i<=n;i++){
		cin>>p[i];
	}
	cout<<setprecision(10);
	cout<<fixed;
	cout<<solve(1, 0);
	return 0;
}

Measured memory_bytes: 141440