akhauriyash/Code-Regression huggingface dataset:
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int L[2002][26];
	int R[2002][26];
	string str;cin>>str;
	int i,j,c,n=str.size();
	str.insert(str.begin(),'#');
	str.pub('#');
	for(c=0;c<26;c++){
		int gen=0;
		for(i=0;i<=n+1;i++){
			L[i][c]=gen;
			if(str[i]-'a'==c){gen=i;}
		}
		gen=n+1;
		for(i=n+1;i>=0;i--){
			R[i][c]=gen;
			if(str[i]-'a'==c){gen=i;}
		}
	}
	llint ans=-2;
	static llint dp[2002][2002]={0};
	dp[0][n+1]=1;
	for(i=0;i<=n+1;i++){
		for(j=n+1;j>=i;j--){
			dp[i][j]%=mod;
			ans+=dp[i][j];
			if(i<j){ans+=dp[i][j];}
			ans%=mod;
			for(c=0;c<26;c++){dp[R[i][c]][L[j][c]]+=dp[i][j];}
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 26840
const Main = (input) => {
  const dataArray = input.split('\n');
  const number = Number(dataArray[0]);
  const s = dataArray[1];
  if(number >= 3200){
    console.log(s);
  } else {
    console.log('red');
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
N,K=map(int,input().split())
A=list(map(int,input().split()))
d=[[0]*(K+2) for i in range(N+1)]
d[0]=[0]+[1]*(K+1)
m=10**9+7
for i in range(N):
    for j in range(K+1):
        d[i+1][j+1]=(d[i][j+1]-d[i][max(0,j-A[i])]+d[i+1][j])%m
print((d[-1][-1]-d[-1][-2])%m)

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

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

    vector<int> weights(n, 0);
    vector<int> vals(n, 0);

    int total_val = 0;
    for(int i=0; i<n; ++i)
    {
        cin >> weights[i] >> vals[i];
        total_val += vals[i];
    }

    // n * max_val table which stored minimum weight required to get that value
    vector<vector<long long int>> dp(n, vector<long long int>(total_val+1, 0));
    dp[0][vals[0]] = weights[0];
    int ans = vals[0];

    for(int i=1; i<n; ++i)
    {
        for(int j=1; j<total_val+1; ++j)
        {
            if(j < vals[i]) dp[i][j] = dp[i-1][j];
            else if(j == vals[i])
            {
                if(dp[i-1][j] == 0) dp[i][j] = weights[i];
                else dp[i][j] = min(dp[i-1][j], (long long int) weights[i]);
            }
            else
            {
                int other = j - vals[i];
                if(dp[i-1][j] == 0 && dp[i-1][other] == 0) dp[i][j] = 0;
                else if(dp[i-1][j] == 0) dp[i][j] = dp[i-1][other] + weights[i];
                else if(dp[i-1][other] == 0) dp[i][j] = dp[i-1][j];
                else dp[i][j] = min(dp[i-1][j], dp[i-1][other] + weights[i]);
            }
            if(dp[i][j] <= w && dp[i][j] != 0) ans = max(ans, j);
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
inline void Yes(){cout << "Yes" << endl;}
inline void No(){cout << "No" << endl;}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){cout << "YES" << endl;}
inline void NO(){cout << "NO" << endl;}
inline void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){
   
    int n;
    scanf("%d", &n);
    string s;
    cin >> s; 

    int cnt = 0;
    rep(i, n){
        if(s[i] != s[i+1]) ++cnt;
    }
    ppp(cnt);
   
   
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
const long long MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


bool is_prime(ll N){
    
    if (N == 1) return false;
    
    int sqn = sqrt(N);
    
    for(auto i = 2; i<=sqn; i++){
        if (N % i == 0) return false;
    }
    return true;
}

int main() {
    ll n,m;cin>>n>>m;
    
    if(is_prime(m)){
        cout<<1<<endl;
        return 0;
    }
    if(n==1){
        cout<<m<<endl;
        return 0;
    }
    ll mx = 1;
    for(auto i = 2LL;i<=sqrt(m);i++){
        
        if(m%i!=0)continue;
        
        if(m/i >=n){
            mx = max(mx,i);
        }
        if(m/(m/i) >=n){
            mx = max(mx,(m/i));
        }
        
    }
    
    cout<<mx<<endl;
    
    
    
    return 0;
}






Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include <algorithm>

using namespace std;

int main(){
  int n; cin>>n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i]-i;
  }
  
  sort(b.begin(),b.end());
  int median=b[b.size()/2];
  long int sum=0;
  for(int i=0;i<n;i++){
    sum+=abs(b[i]-median);
  }
  
  cout<<sum;
  
  return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int totalPrice = 0;
        int totalCount = 0;
        int saleCount = 0;
        while (true) {
            String line = reader.readLine();
            if (line == null || line.isEmpty()) {
                break;
            }
            String[] values = line.split(",");
            int price = Integer.parseInt(values[0]);
            int count = Integer.parseInt(values[1]);
            totalPrice += price * count;
            totalCount += count;
            saleCount++;
        }
        out.println(totalPrice);
        out.println((int) ((double) totalCount / saleCount + 0.5));
    }
}

Measured memory_bytes: 9188
def main():
    s = str(input())
    t = str(input())
    if set(t) <= set(s):
        x = -1
        counter = 0
        for i in t:
            x = s.find(i, x+1)
            if x == -1:
                counter += 1
                x = s.find(i)
        print(x+1+counter*len(s))
    else:
        print(-1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a ; i <= b; ++ i) 
const int N = 2e5 + 5, M = N , mo = 1e9 + 7 ;
const ll inf = 1e17 ;
using namespace std ;

struct poi {
    int l, r, ans ;
} a[N], b[N] ;
multiset <int> S ;
int n, bit[N] ;

bool cmpl(poi a, poi b) {
    return a.l < b.l ;
}

bool cmpr(poi a, poi b) {
    return a.r < b.r ;
}

int solve() {
    rep(i, 0, M - 5) bit[i] = 0 ;
    rep(i, 1, n) ++ bit[a[i].l], -- bit[a[i].r] ;
    rep(i, 1, M - 5) bit[i] += bit[i - 1] ;
    int res = 0 ;
    rep(i, 0, M - 5) res = max(res, bit[i]) ;
    return res ;
}

void put(int x) {
    for ( ; x <= M - 5 ; x += x & (- x)) bit[x] ++ ;
}

int get(int x) {
    int res = 0 ;
    for ( ; x ; x -= x & (- x)) res += bit[x] ;
    return res ;
}

int l[N],r[N];

int SOLVE() {
	rep(i,1,M-5) bit[i]=0;
    sort(a + 1, a + n + 1, cmpl) ;
    rep(i, 1, n) a[i].ans = n ;
    rep(i, 1, n) {
        a[i].ans -= get(a[i].l) ;
        put(a[i].r) ;
    }
    rep(i, 0, M - 5) bit[i] = 0 ;
    sort(a + 1, a + n + 1, cmpr) ;
    for (int i = n ; i; -- i) {
        a[i].ans -= get(M - 5 - a[i].r) ;
        put(M - 5 - a[i].l) ;
    }
    int res = 0 ;
    rep(i, 1, n) res = max(res, a[i].ans) ;
    return res ;
}

int main() {
    scanf("%d", &n) ;
    rep(i, 1, n) scanf("%d%d", &a[i].l, &a[i].r) ;
//    int r=SOLVE();
    printf("%d %d\n", SOLVE(), solve()) ;
    return 0 ;
}


Measured memory_bytes: 6344
#include <bits/stdc++.h>
#define N 100003
#define what_is(x) cerr << #x << " is " << x << endl;

using namespace std;

int main() {
	// for fast input output using cin cout
	std::ios_base::sync_with_stdio(false);

	// size of array
	// input
	int n;
	cin>>n;
	vector <int> a(n);
	vector <int> b(n);
	vector <int> c(n);
	for (int i = 0; i < n; ++i)
		cin>>a[i];
	for (int i = 0; i < n; ++i)
		cin>>b[i];
	for (int i = 0; i < n; ++i)
		cin>>c[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	int k = 0;
	long long ans = 0;
	long long chash[N] = {0};
	for (int i = 0; i < b.size(); ++i)
	{
		while (k < c.size() && c[k] <= b[i])
			k++;

		chash[i] = c.size() - k;
	}
	for (int i = b.size()-2; i >= 0; --i)
	{
		chash[i] += chash[i+1];
	}
	
	int j = 0;
	for (int i = 0; i < a.size(); ++i)
	{
		while (j < b.size() && b[j] <= a[i])
			j++;
		ans += chash[j];

		// what_is(j);
		// what_is(chash[j]);
	}

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

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

ll n;
vll a(100000);

int main() {
  cin >> n;
  REP(i, n) cin >> a.at(i);
  ll x = a.at(n-1);
  ll i = -1;
  REP(j, n-1) {
    if (a.at(j) <= x) {
      i++;
      ll tmp = a.at(j);
      a.at(j) = a.at(i);
      a.at(i) = tmp;
    }
  }
  ll tmp = a.at(n-1);
  a.at(n-1) = a.at(i+1);
  a.at(i+1) = tmp;
  REP(j, n) {
    if (j != i+1) cout << a.at(j);
    else cout << '[' << a.at(j) << ']';
    if (j != n-1) cout << ' ';
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3432
#include<bits/stdc++.h>
using namespace std;
int n, W, v, w, a, dp[101][10001];

int main() {
	scanf("%d %d", &n, &W);
	fill(dp[0], dp[0]+n*100+1, 1001001001);
	dp[0][0] = 0;
	for (int i = 0; i < n; ++i) {
		scanf("%d %d", &v, &w);
		for (int j = 0; j <= n*100; ++j) {
			if (j<v) dp[i+1][j] = dp[i][j];
			else dp[i+1][j] = min(dp[i][j], dp[i][j-v]+w);
		}
	}
	for (int j = 0; j <= n*100; ++j)
		if (dp[n][j]<=W) a = j;
	printf("%d\n", a);
}

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

using namespace std;

int main(){

  ll n,k;
  
  priority_queue<ll> h;
  
    ll ans = 0;
  
  cin >> n >> k;
  
  rep(i,n){
    
    ll a;
    cin >> a;
    
    h.push(a);
    ans += a;
  }
  
  rep(i,k){
    ans -= h.top();
    h.pop();
  }
  
  if(ans <= 0)ans = 0;
  
    cout << ans << endl;
    return 0;
}




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

int main()
{
    int n,ans;

    cin >> n;
    vector<int> a(n),aa(n);
    rep(i, n) {
        cin >> a[i];
        aa[i] = a[i];
    }
    sort(aa.begin(), aa.end(), greater<int>());
    rep(i, n) {
        if (a[i] == aa[0]) {
            cout << aa[1] << endl;
        }
        else {
            cout << aa[0] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4812
#![allow(non_snake_case, unused)]
use std::io::*;
use std::str::FromStr;
use std::collections::*;

const MAX: usize = 1000005;

fn main() {
    let cin = stdin();
    let mut sc = Scanner::new(cin.lock());
    let n: usize = sc.next();
    let a: Vec<usize> = sc.vec(n);

    let mut g = a[0];
    for i in 1..n {
	g = gcd(g, a[i]);
    }

    if g != 1 {
	println!("not coprime");
	return;
    }

    let primes = sieve(MAX);
    let mut used = vec![false; MAX];

    for i in 0..n {
	let ok = check(&mut used, a[i], &primes);
	if !ok {
	    println!("setwise coprime");
	    return;
	}
    }
    println!("pairwise coprime");
}

fn check(used: &mut [bool], a: usize, primes: &[usize]) -> bool {
    let mut tmp = a;
    while tmp > 1 {
	let n = primes[tmp];
	if used[n] {
	    break;
	}
	while tmp % n == 0 {
	    tmp /= n;
	}
	used[n] = true;
    }
    tmp <= 1
}

pub fn gcd(x: usize, y: usize) -> usize {
    let mut a = x;
    let mut b = y;

    while b > 0 {
	let tmp = a % b;
	a = b;
	b = tmp;
    }
    a
}

pub fn sieve(n: usize) -> Vec<usize> {
    let mut res: Vec<usize> = (0..n + 1).collect();
    let end = (n as f64).sqrt() as usize;
    for i in 2..=end {
	if res[i] == i {
	    for j in ((i * i)..=n).step_by(i) {
		res[j] = i;
	    }
	}
    }
    res
}

// Scanner
struct Scanner<R: std::io::Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
	Scanner { reader: reader }
    }

    fn read<T: FromStr> (&mut self) -> Option<T> {
	let token = self
	    .reader
	    .by_ref()
	    .bytes()
	    .map(|c| c.unwrap() as char)
	    .skip_while(|c| c.is_whitespace())
	    .take_while(|c| !c.is_whitespace())
	    .collect::<String>();
	if token.is_empty() {
	    None
	} else {
	    token.parse::<T>().ok()
	}
    }

    fn next<T: FromStr>(&mut self) -> T {
	if let Some(s) = self.read() {
	    s
	} else {
	    writeln!(stderr(), "Terminated with EOF").unwrap();
	    std::process::exit(0);
	}
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
	(0..n).map(|_| self.next()).collect()
    }

    fn char(&mut self) -> char {
	self.next::<String>().chars().next().unwrap()
    }
}


Measured memory_bytes: 17676
#include <bits/stdc++.h>
using namespace std;
#define lp(i, x, n) for (int i = x; i < (int)n; ++i)
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define ll long long
#define N 100001
#define mod 1000000007
ll n, h, ar1[N];
int main() {
        cin >> n>> h;
        ll mx = -1;
        lp (i, 0, n) {
                ll a, b;
                cin >> a>> b;
                mx = max(a, mx);
                ar1[i] = b;
        }
        sort(ar1, ar1 + n);
        ll i = n - 1, ans = 0;
        while (i >= 0) {
                if (h <= 0 || mx >= ar1[i]) {
                        break;
                }
                h -= ar1[i--];
                ans++;
        }
        if (h > 0) { ans += ceil((double)h / mx); }
        cout << ans;
        return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <numeric>
#include <iomanip>
#define ll long long
#define pi 3.14159265358979323846
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};
/*
 vector<vector<ll>> g(n+1);
    for(ll i = 0; i < m; i++){
        ll a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<ll> dist(n+1, -1);
    queue<ll> que;
    que.push(1);
    dist[1] = 0;
    while(!que.empty()){
        ll v = que.front();
        que.pop();
        for(ll nv : g[v]){
            if(dist[nv]!=-1) continue;
            dist[nv] = dist[v]+1;
            que.push(nv);
        }
    }
*/

int main(){
    ll n;
    cin >> n;
    map<ll, ll> a{}, b{};
    for(ll i = 0; i < n; i++){
        ll c;
        cin >> c;
        if(i%2==0) a[c]++;
        else b[c]++;
    }
    vector<p> va, vb;
    va.push_back(p(0, -1));
    vb.push_back(p(0, -1));
    for(auto &z : a){
        ll x = z.first, y = z.second;
        va.push_back(p(y, x));
    }
    sort(va.begin(), va.end());
    for(auto &z : b){
        ll x = z.first, y = z.second;
        vb.push_back(p(y, x));
    }
    sort(vb.begin(), vb.end());
    ll ans = 0;
    if(va[va.size()-1].second!=vb[vb.size()-1].second)
        ans = (n/2-va[va.size()-1].first)+(n/2-vb[vb.size()-1].first);

    else if(va[va.size()-1].second==vb[vb.size()-1].second){
        ll x = (n/2-va[va.size()-1].first)+(n/2-vb[vb.size()-2].first);
        ll y = (n/2-vb[vb.size()-1].first)+(n/2-va[va.size()-2].first);
        ans = min(x, y);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8824
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll n,W; cin >> n >> W;
	vector<ll> w(n), v(n);
	for(ll i = 0; i < n; i++) cin >> w[i] >> v[i];
	vector<vector<ll>> dp(n, vector<ll>(W+1));
	for(ll i = w[0]; i <= W; i++) dp[0][i] = v[0];
	for(ll i = 1; i < n; i++) for(ll j = 0; j <= W; j++){
		dp[i][j] = dp[i-1][j];
		if(j - w[i] >= 0) dp[i][j] = max(v[i] + dp[i-1][j - w[i]], dp[i][j]);
	}
	cout << dp[n-1][W] << endl;
}

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

int main()
{
    int n, a[51];
    stack<int> s;

    while( cin >> n )
    {
        if( n == 0 )
            break;

        for( int i = 0; i < n; i++ )
        {
            cin >> a[i];
            if( s.empty() )
                s.push(a[i]);
            else if( s.size() == 1 )
            {
                if( a[i] - s.top() == 1 )
                {
                    s.push('-');
                    s.push(a[i]);
                }
                else
                {
                    cout << s.top() << " ";
                    s.pop();
                    s.push(a[i]);
                }
            }
            else
            {
                if( a[i] - s.top() == 1 )
                {
                    s.pop();
                    s.push(a[i]);
                }
                else
                {
                    int x = s.top();
                    s.pop();
                    char y = s.top();
                    s.pop();
                    int z = s.top();
                    s.pop();
                    cout << z << y << x << " ";

                    s.push(a[i]);
                }
            }
        }
        if( s.size() == 1 )
        {
            cout << s.top() << endl;
            s.pop();
        }
        else
        {
            int x = s.top();
            s.pop();
            char y = s.top();
            s.pop();
            int z = s.top();
            s.pop();
            cout << z << y << x << endl;
        }
    }
    return 0;
}



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

int sum_digit(int n){
  if( n == 0 ) return 0;
  else return n%10 + sum_digit(n/10);
}

int main()
{
  int i,N,K,syurui = 0; cin >> N >> K;
  vector<int> A(200001);
  for(i = 0; i < N; i++){
  	int Ai; cin >> Ai;
    if(A.at(Ai) == 0) syurui++;
    A.at(Ai)++; 
  }
  
  sort(A.begin(),A.end());
  
  i = 0;
  int count = 0;
  while(syurui > K){
  	while(A.at(i) != 0){
      A.at(i)--;
      if(A.at(i) == 0) syurui--;
      count++;
    }
    i++;
  }
  cout << count++;
}

Measured memory_bytes: 1024
#include <iostream>
#include <set>

#define long long long

int main(void){
    std::multiset<long> vs1, vs2;
    long Q;
    std::cin >> Q;
    long qi = 0;
    long med = -1;
    long sum_abs = 0;
    long bias = 0;
    for(long ii = 0; ii < Q; ++ii){
        long q;
        std::cin >> q;
        if(q == 1){
            long v, b;
            std::cin >> v >> b;
            qi++;
            bias += b;
            if(qi == 1){
                vs1.insert(v);
                med = v;
            } else if(qi == 2){
                long w = *vs1.begin();
                if(w <= v){
                    vs2.insert(v);
                } else {
                    vs1.clear();
                    vs1.insert(v);
                    vs2.insert(w);
                }
                med = *vs1.begin();
                sum_abs = *vs2.begin() - med;
            } else {
                auto vs1_size = vs1.size(), vs2_size = vs2.size();
                if(*vs1.rbegin() >= v){
                    vs1.insert(v);
                    if(vs1.size()-2 >= vs2.size()){
                        long w = *vs1.rbegin();
                        vs1.erase(--vs1.end());
                        vs2.insert(w);
                    }
                } else {
                    vs2.insert(v);
                    if(vs2.size() > vs1.size()){
                        long w = *vs2.begin();
                        vs2.erase(vs2.begin());
                        vs1.insert(w);
                    }
                }
                long new_med = *vs1.rbegin();
                sum_abs += std::abs(new_med - v);
                sum_abs += std::abs(static_cast<long>((new_med - med) * (vs1_size - vs2_size)));
                med = new_med;
            } // end of insertion
        } else {
            std::cout << med << " " << sum_abs + bias << std::endl;
        }
    }
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <deque>
using namespace std;
#define rep(i,n) for (ll i=0;i<n;i++)
typedef long long ll;

int N;
int T;
int c[110];
int t[110];

int main() {
	cin >> N >> T;
	rep(i, N) cin >> c[i] >> t[i];
	bool j = false;
	int ans = 0;
	rep(i, N) {
		if (!j && t[i] <= T) {
			ans = c[i];
			j = true;
		}
		else if (t[i] <= T) {
			ans = min(ans, c[i]);
		}
	}
	if (j) cout << ans << endl;
	else cout << "TLE" << endl;
	return 0;
}


Measured memory_bytes: 256
from sys import stdin
import numpy as np
from numba import njit
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    s=readline().strip()
    ans=s.count("R")*s.count("G")*s.count("B")
    s=np.array([0 if s[i]=="R" else 1 if s[i]=="G" else 2 for i in range(n)],dtype=np.int64)

    print(f(n,ans,s))

@njit("i8(i8,i8,i8[:])")
def f(n,ans,s):
    for i in range(n):
        for j in range(i+1,n):
            k=2*j-i
            if k>=n: break
            if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
                ans-=1
    return ans

if __name__=="__main__":
    main()

Measured memory_bytes: 109796
/*input
happy,newyear,enjoy
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int a,b,c;
	cin>>a>>b>>c;
	if(b+b==a+c)cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double a,b,c,d,e,f;
    double x,y;
    while(cin>>a>>b>>c>>d>>e>>f){
        x=(e*c-b*f)/(a*e-d*b);
        y=(a*f-c*d)/(a*e-d*b);
        if(x==-0)x=0;
        if(y==-0)y=0;
        printf("%.3lf %.3lf\n",x,y);
    }
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll h,w;
ll direction2[4][2]={{1,0},{0,1},{0,-1},{-1,0}};
bool valid(int a,int b)
{
    if(a>=1&&a<=h&&b>=1&&b<=w)return true;
    else return false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s[0]!='A'){
        cout<<"WA";return 0;
    }
    ll x=0;
    for(int i=2;i<s.size()-1;i++){
        if(s[i]=='C')x++;
        if(x>1){
            cout<<"WA";return 0;
        }
    }
    if(x==0){cout<<"WA";return 0;}
    for(int i=1;i<s.size();i++){
        if(s[i]!='C'&&s[i]>='A'&&s[i]<='Z'){
            cout<<"WA";return 0;
        }
    }
    cout<<"AC";
}


Measured memory_bytes: 3612
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long
#define lli long long int

using namespace std;
using P = pair<int,int>;

int main(){

  ll X, Y;
  cin >> X >> Y;

  ll n = 0;

  while (X <= Y){
    n++;
    X *= 2;
  }

  cout << n << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int K, X, lower, upper, N;
	cin >> K >> X;
	upper = min({X + K - 1, 1000000});
	lower = max({ X - K + 1, -1000000 });
	for (N = lower; N < upper; N++) {
		cout << N << ' ';
	}
	cout << N << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int ryokin_table[7][7]={
	{   0, 300, 500, 600, 700,1350,1650},
	{   6,   0, 350, 450, 600,1150,1500},
	{  13,   7,   0, 250, 400,1000,1350},
	{  18,  12,   5,   0, 250, 850,1300},
	{  23,  17,  10,   5,   0, 600,1150},
	{  43,  37,  30,  25,  20,   0, 500},
	{  58,  52,  45,  40,  35,  15,   0}
};

int get_distance(int a,int b) {
	if(a<=b) {
		return ryokin_table[b-1][a-1];
	} else {
		return ryokin_table[a-1][b-1];
	}
}

int get_ryokin(int a,int b) {
	if(a<=b) {
		return ryokin_table[a-1][b-1];
	} else {
		return ryokin_table[b-1][a-1];
	}
}

int is_hangaku_time(int h,int m) {
	if(h==18)return 1;
	if(h==17 && m>=30)return 1;
	if(h==19 && m<=30)return 1;
	return 0;
}

int get_hangaku(int ryokin) {
	int hangaku=ryokin*10/2;
	if(hangaku%500!=0)hangaku+=(500-hangaku%500);
	return hangaku/10;
}

int main(void) {
	int in_ic,out_ic;
	int in_h,in_m;
	int out_h,out_m;
	int is_hangaku;
	int now_ryokin;
	int hangaku_ryokin;
	while(1) {
		scanf("%d",&in_ic);
		if(in_ic==0)break;
		scanf("%d%d",&in_h,&in_m);
		scanf("%d",&out_ic);
		scanf("%d%d",&out_h,&out_m);
		if((is_hangaku_time(in_h,in_m) || is_hangaku_time(out_h,out_m)) &&
			get_distance(in_ic,out_ic)<=40)is_hangaku=1;
		else is_hangaku=0;
		now_ryokin=get_ryokin(in_ic,out_ic);
		hangaku_ryokin=get_hangaku(now_ryokin);
		printf("%d\n",(is_hangaku?hangaku_ryokin:now_ryokin));
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)


int main(){
    int n;
    cin >> n;
    map<int,int> m;
    rep(i,n){
        int tmp;
        cin >> tmp;
        if (0 < tmp && tmp < 400) m[0]++;
        else if (400 <= tmp && tmp < 800) m[1]++;
        else if (800 <= tmp && tmp < 1200) m[2]++;
        else if (1200 <= tmp && tmp < 1600) m[3]++;
        else if (1600 <= tmp && tmp < 2000) m[4]++;
        else if (2000 <= tmp && tmp < 2400) m[5]++;
        else if (2400 <= tmp && tmp < 2800) m[6]++;
        else if (2800 <= tmp && tmp < 3200) m[7]++;
        else if (3200 <= tmp ) m[8]++;
    }
    int mx=0;
    int kind = 0;
    int mn = 100;
    for (auto w:m){
        if (w.first == 8) continue;
        kind++;
    }
    if (kind == 0 && m[8] > 0){
        cout << 1 << " " << m[8] << endl;
    }
    else{
        cout << kind << " " << m[8] + kind << endl; 
    }
    return 0;    
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int n, C, fir, L[7], ord[7];

int F[1 << 5][444][444];

int Solve() {
    memset(F, 0, sizeof F);
    F[0][0][0] = 1;
    for(int s = 0; s < (1 << (n - 1)) - 1; s++)
        for(int i = 0; i < C * n; i++)
            for(int k = 0; k <= i; k++) if(F[s][i][k])
                for(int nxt = 0; nxt < n - 1; nxt++) if(!((s >> nxt) & 1))
                    for(int j = i / n * n + ord[nxt] + (ord[nxt] < i % n) * n; j < C * n; j += n)
                        F[s + (1 << nxt)][j][k >= j - L[nxt] * n ? j : k] += F[s][i][k];
    int ans = 0;
    for(int i = (C - fir) * n; i < C * n; i++)
        for(int j = (C - fir) * n; j <= i; j++)
            ans += F[(1 << (n - 1)) - 1][i][j];
    return ans;
}

int main() {
    scanf("%d%d", &n, &C);
    for(int i = 0; i < n; i++) scanf("%d", &L[i]);
    sort(L, L + n);
    fir = L[n - 1];
    for(int i = 0; i < n - 1; i++) ord[i] = i + 1;
    double ans = 0, tmp = 0;
    do {
        ans += Solve();
    } while(next_permutation(ord, ord + n - 1));
    for(int i = 1; i < n; i++) ans /= i;
    printf("%.15lf\n", ans / pow(C, n - 1));
    return 0;
}


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

#define all(v) v.begin(), v.end()
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

int main() {
    string s; cin >> s;
    map<char, int> m;
    for(int i = 0; i < s.size(); i++){
        m[s[i]]++;
    }
    bool flag = true;
    for(int i = 0; i < m.size(); i++){
        if(m[i] % 2 != 0){
            flag = false;
            break;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

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

void solve() {
	string str;
	cin >> str;
	for (int i = 0; i < str.size(); i++) {
		if (str[i] == '1') {
			str[i] = '9';
		} else if (str[i] == '9') {
			str[i] = '1';
		} else {
			abort();
		}
	}
	cout << str;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif
	solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define eps 1e-9
#define mod 1000000007
#define pi 3.14159265359
#define inf 1e18

using namespace std;

typedef long long ll;
typedef long double ld;

int dp[200005][4];
int w, h, n;
string s, t;

bool check(int i)
{
    if (dp[i][0]<=0)
        return false;
    if (dp[i][1]>=w+1)
        return false;
    if (dp[i][2]<=0)
        return false;
    if (dp[i][3]>=h+1)
        return false;
    return true;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int x, y;

    cin>>h>>w>>n;
    cin>>x>>y;
    cin>>s;
    cin>>t;
    s = "0" + s;
    t = "0" + t;
    dp[0][0] = y;
    dp[0][1] = y;
    dp[0][2] = x;
    dp[0][3] = x;

    for (int i=1; i<s.size(); i++)
    {
        dp[i][0] = dp[i-1][0];
        dp[i][1] = dp[i-1][1];
        dp[i][2] = dp[i-1][2];
        dp[i][3] = dp[i-1][3];

        // wants to move out of the board
        if (s[i] == 'L')
        {
            dp[i][0] = dp[i-1][0] - 1;
        }
        if (s[i] == 'R')
        {
            dp[i][1] = dp[i-1][1] + 1;
        }
        if (s[i] == 'U')
        {
            dp[i][2] = dp[i-1][2] - 1;
        }
        if (s[i] == 'D')
        {
            dp[i][3] = dp[i-1][3] + 1;
        }

        if (!check(i))
        {
            cout<<"NO";
            return 0;
        }

        // wants to prevent moving out the board
        if (t[i] == 'L')
        {
            dp[i][1] = max(1, dp[i][1] - 1);
        }
        if (t[i] == 'R')
        {
            dp[i][0] = min(dp[i][0] + 1, w);
        }
        if (t[i] == 'U')
        {
            dp[i][3] = max(1, dp[i][3] - 1);
        }
        if (t[i] == 'D')
        {
            dp[i][2] = min(dp[i][2] + 1, h);
        }

    }

    cout<<"YES";
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  long long power = 1;
  for (int i = 1; i <= N; i++) {
    power *= i;
    power %= 1000000007;
  }
  cout << power << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>

using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7;
int dp[105][4][4][4];

int main(){
  int N;
  cin >> N;
  
  // 0,1,2でない値。無視できる組み合わせ
  dp[0][3][3][3] = 1;
  
  for (int l = 0; l < N; l++) {
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        for (int k = 0; k < 4; k++) {
          for (int d = 0; d < 4; d++) {
            if (j == 0 && k == 1 && d == 2) continue;
            if (j == 1 && k == 0 && d == 2) continue;
            if (j == 0 && k == 2 && d == 1) continue;
            if (i == 0 && k == 1 && d == 2) continue;
            if (i == 0 && j == 1 && d == 2) continue;
            
            dp[l + 1][j][k][d] = (dp[l + 1][j][k][d] + dp[l][i][j][k]) % MOD;
          }
        }
      }
    }
  }
  
  ll ret = 0;
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        ret = (ret + dp[N][i][j][k]) % MOD;
      }
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)

int main(){ 
    
   int x,flag1,flag2,flag3,flag4;
   string str1;

   cin>>x;
   flag1=flag2=flag3=flag4=0;
   REP(i,x){
       cin>>str1;
       if(str1=="AC")flag1++;
       else if(str1=="WA")flag2++;
       else if(str1=="TLE")flag3++;
       else if(str1=="RE")flag4++;
   }
   cout<<"AC"<<" "<<"x"<<" "<<flag1<<endl;
   cout<<"WA"<<" "<<"x"<<" "<<flag2<<endl;
   cout<<"TLE"<<" "<<"x"<<" "<<flag3<<endl;
   cout<<"RE"<<" "<<"x"<<" "<<flag4<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll h,w;
matrix a;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	std::cout<<std::fixed<<std::setprecision(30);
	cin>>h>>w;
	vector<string> vs;
	vs.resize(h);
	rep(i,h){
		cin>>vs[i];
	}
	Vi tmp;
	string ts;
	rep(i,w){
		ts.pb('.');
	}
	rep(i,h){
		if(vs[i]==ts){
			tmp.pb(i);
		}
	}
	reverse(all(tmp));
	rep(i,tmp.size()){
		vs.erase(vs.begin()+tmp[i]);
	}
	vector<string> vs2(w,string(vs.size(),' '));
	rep(i,vs.size()){
		rep(j,w){
			vs2[j][i]=vs[i][j];
		}
	}
	tmp.clear();
	ts.clear();
	rep(i,vs.size()){
		ts.pb('.');
	}
	rep(i,vs2.size()){
		if(vs2[i]==ts){
			tmp.pb(i);
		}
	}
	reverse(all(tmp));
	rep(i,tmp.size()){
		vs2.erase(vs2.begin()+tmp[i]);
	}
	vector<string> as(vs2[0].size(),string(vs2.size(),' '));
	rep(i,vs2.size()){
		rep(j,vs2[0].size()){
			as[j][i] = vs2[i][j];
		}
	}
	rep(i,as.size()){
		print(as[i]);
	}
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

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


Measured memory_bytes: 2044
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  string s; cin >> s;
  if(s[s.length() - 1] == 's'){s.pb('e'); s.pb('s');}
  else s.pb('s');
  cout << s << endl;

}


Measured memory_bytes: 3052
import java.io.*;
import java.util.*;  
public class Main {
	static int div=(1000000000+7);
	static int H, W;
	static char[][] grid;
	static long[][] memo;
	public static long dp(int x, int y)
	{
		if(memo[x][y]!=-1)return memo[x][y];
		return memo[x][y]=((x + 1==H || grid[x+1][y]=='#'?0:dp(x+1,y)) + (y + 1==W || grid[x][y+1]=='#'?0:dp(x, y+1)))%div;
	}
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		StringTokenizer st = new StringTokenizer(br.readLine());
		H = Integer.parseInt(st.nextToken()); W = Integer.parseInt(st.nextToken());
		grid = new char[H][W]; memo = new long[H][W]; 
		for (int i = 0; i < H; i++) {
			String temp = br.readLine();
			for (int j = 0; j < W; j++) {
				grid[i][j]= temp.charAt(j);
				memo[i][j]=-1;
			}
		}
		memo[H-1][W-1]=1;pw.println(dp(0,0));
		pw.close();
	}
}

Measured memory_bytes: 40472
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main(){
int n,m,c;cin>>n>>m>>c;
int b[m];
int a[n][m];
int i,j,k;

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

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

int ans=0;
for(i=0;i<n;i++){
  int tmp=0;
  for(j=0;j<m;j++){
    tmp+=a[i][j]*b[j];
  }
  tmp+=c;
  //cout << tmp << endl;
  if(tmp>0) ans++;
}
cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#define ll long long
// 팰린드롬은 결국 문자 2개의 매칭의 연속이다.
// 결국 요문제는 valid한 매칭을 최대화 시켜서
// 매칭에 포함되지 않는 문자를 최소화 시키는 문제로 바꿔 풀 수 있다.
using namespace std;
const ll MAXN = 2005;
pair<ll,ll> dp[MAXN][MAXN]; ll k,n; ll vis[MAXN][MAXN],lt,rt;
string s;
void better(pair<ll,ll> &dp1,pair<ll,ll> dp2){
    if(dp1.first > dp2.first) dp1 = dp2;
    else if(dp1.first == dp2.first) dp1.second += dp2.second;
    if(dp1.second > 2e18){
        dp1.second = 2e18;
    }
}
pair<ll,ll> go(ll l,ll r){
    if(vis[l][r]) return dp[l][r];
    vis[l][r] = 1;
    dp[l][r] = make_pair(1e9,0);
    if(l >= r)return dp[l][r] = make_pair(0,1);
    if(s[l] == s[r]) better(dp[l][r],go(l+1,r-1));
    else{
        pair<ll,ll> t = go(l+1,r); t.first++;
        better(dp[l][r],t);
        t = go(l,r-1); t.first++;
        better(dp[l][r],t);
    }
    return dp[l][r];
}
void make(int l,int r,string &ans,long long K){
    if(lt > rt)return;
    if(l == 0 && r == n && dp[l][r].second < k){
        ans.clear(); ans = "NONE"; return;
    }
    if(s[l] == s[r]){
        ans[lt++] = s[l]; ans[rt--] = s[l];
        make(l+1,r-1,ans,K);
    }
    else if(dp[l+1][r].first > dp[l][r-1].first){
        ans[lt++] = s[r]; ans[rt--] = s[r];
        make(l,r-1,ans,K);
    }
    else if(dp[l][r-1].first > dp[l+1][r].first){
        ans[lt++] = s[l]; ans[rt--] = s[l];
        make(l+1,r,ans,K);
    }
    else{
        if(s[l] == s[r]){
            ans[lt++] = s[l]; ans[rt--] = s[r];
            make(l+1,r-1,ans,K);
        }
        if(s[l] < s[r]){
            if(dp[l+1][r].second >= K){
                ans[lt++] = s[l]; ans[rt--] = s[l];
                make(l+1,r,ans,K);
            }
            else{
                K -= dp[l+1][r].second;
                ans[lt++] = s[r]; ans[rt--] = s[r];
                make(l,r-1,ans,K);
            }
        }
        if(s[l] > s[r]){
            if(dp[l][r-1].second >= K){
                ans[lt++] = s[r]; ans[rt--] = s[r];
                make(l,r-1,ans,K);
            }
            else{
                K -= dp[l][r-1].second;
                ans[lt++] = s[l]; ans[rt--] = s[l];
                make(l+1,r,ans,K);
            }
        }
    }
}
int main(){
    
    
    cin>>s>>k;
    n = s.length(); n--;
    pair<ll,ll> d = go(0,n);
    ll add = d.first;
    string ans; ans.resize(s.length() + add,'a');
    lt = 0; rt = ans.size()-1;
    make(0,n,ans,k);
    cout<<ans<<endl;
    
    return 0;
}



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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int a = Integer.parseInt(strArr[0]);
		int b = Integer.parseInt(strArr[1]);
		if (b % a == 0)
			System.out.println((a + b));
		else
			System.out.println((b - a));
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


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

int main() {

    int n;
    cin >> n;
    int arr[n];
    int sm = 0;
    for (int i=0; i<n; i++) {
        cin >> arr[i];
        sm += arr[i];
    }
    sort(arr, arr+n);
    sm -= arr[n-1];
    if (arr[n-1] < sm) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n;
  cin >> n;
  int l[n];
  for(int i = 0; i < n; i++) cin >> l[i];

  int mx = 1, sum = 0;
  for(int i = 0; i < n; i++){
    sum += l[i];
    mx = max(mx, l[i]);
  }

  if(mx < (sum - mx)) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

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

func main() {
	a, _ := strconv.Atoi(input())
	b, _ := strconv.Atoi(input())
	c, _ := strconv.Atoi(input())

	ans := 0
	if c <= a+b+1 {
		ans += c
	} else {
		ans += a + b + 1
	}
	ans += b

	fmt.Println(ans)
}


Measured memory_bytes: 640
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	double pi = acos(-1);
	int R;
	cin >> R;


	cout << setprecision(12) << pi * R * 2 << endl;



	Would you please return 0;
}

Measured memory_bytes: 3796