akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
const ll INF = 1ll << 60;

vector<vector<ll>> warshall_floyd(int n, vector<vector<ll>> &g)
{
    auto ret = g;
    rep(k, n)
    {
        rep(i, n)
        {
            rep(j, n)
            {
                if (ret[i][k] == INF || ret[k][j] == INF)
                    continue;
                if (ret[i][k] + ret[k][j] < ret[i][j])
                {
                    ret[i][j] = ret[i][k] + ret[k][j];
                }
            }
        }
    }
    return ret;
}

int main()
{
    int n, m, r;
    cin >> n >> m >> r;
    vector<int> p(r);
    rep(i, r)
    {
        cin >> p[i];
        p[i]--;
    }
    sort(ALL(p));
    vector<vector<ll>> g(n, vector<ll>(n, INF));
    rep(i, n) g[i][i] = 0;
    rep(i, m)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        g[a][b] = c;
        g[b][a] = c;
    }
    ll ans = INF;
    auto cost = warshall_floyd(n, g);
    do
    {
        ll cur = 0;
        rep(i, r - 1)
        {
            cur += cost[p[i]][p[i + 1]];
        }
        ans = min(ans, cur);
    } while (next_permutation(ALL(p)));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 896
n,k = map(int,input().split())
p = list(map(int,input().split()))
expected_p = [0]*n
ans_list = []
for i in range(n):
  expected_p[i] = (1+p[i])*p[i]/2/p[i]
ans = sum(expected_p[0:k])
ans_list.append(ans)
for j in range(k,n):
  ans -= expected_p[j-k]
  ans += expected_p[j]
  ans_list.append(ans)
print(max(ans_list))

Measured memory_bytes: 80008
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s,t;
	cin >> s;
	for (size_t i = 0; i < s.size(); i++)
	{
		if (s.at(i)!='x')
		{
			t += s.at(i);
		}
	}
	for (size_t i = 0; i < t.size()/2; i++)
	{
		if (t.at(i)!=t.at(t.size()-1-i))
		{
			cout << -1;
			return 0;
		}
	}
	vector<int> spot(t.size() + 1);
	int chking = 0;
	for (size_t i = 0; i < s.size(); i++)
	{
		if (chking<t.size()&&s.at(i)==t.at(chking))
		{
			chking++;
		}
		else
		{
			spot.at(chking)++;
		}
	}
	int ans=0;
	for (size_t i = 0; i < spot.size()/2; i++)
	{
		ans += abs(spot.at(i) - spot.at(spot.size() - 1 - i));
	}
	cout << ans;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
  int N, K;
  scanf("%d %d", &N, &K);
  vector<int> h(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &h[i]);
  }
  
  sort(h.begin(), h.end());

  int minval = 1e9;
  for (int i = 0; i + K - 1 < N; ++i) {
    int val = h[i + K - 1] - h[i];
    if (val < minval) minval = val;
  }

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

Measured memory_bytes: 640
/*
	Created by : imay_10
	" It won't be EASY, but I'll make it "
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

// Utility for fast exponentiation
ll mpow(ll a,ll b,ll m){
    ll res=1;
    //a%=m;
    while(b){
    	if(b%2) res=res*a%m;
		a=a*a%m;
		b/=2;
	}
	return res;
}

// Utility for modular inverse
ll inv(ll a,ll m){
	return mpow(a,m-2,m);
}

// Utility for GCD Calculation
ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

// Utility for binomial coefficient
ll ncr(ll n,ll k)
{
    if(n<k)
        return 0;
    ll C[n + 1][k + 1];
    ll i,j;
    for(i=0;i<=n;i++){
        for(j=0;j<=min(i,k);j++){
            if (j==0 || j==i)
                C[i][j]=1;
            else
                C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
    return C[n][k];
}

void solve(){
	//code
	int n;
	cin>>n;
	int d1[n],d2[n];
	for(int i=0;i<n;i++){
		cin>>d1[i]>>d2[i];
	}
	int ok=0;
	for(int i=0;i<n-2;i++){
		if(d1[i]==d2[i] and d1[i+1]==d2[i+1] and d1[i+2]==d2[i+2]){
			ok=1;
			break;
		}
	}
	if(ok) cout<<"Yes";
	else cout<<"No";
}

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


Measured memory_bytes: 3648
# Q2
S=str(input())
#print(S)

K='keyence'
#print(len('keyence'))
ans=0

'''
print('first=',S[0:6])
print('last=',S[len(S)-7:])
if S[0:7]==K:
    ans=1
if S[len(S)-7:]==K:
    ans=1
'''

for i in range(7+1):
#    print(S[0:i]+S[len(S)-7+i:])
    if S[0:i]+S[len(S)-7+i:]==K:
        ans=1

        
if ans==1:    
    print('YES')
else:
    print('NO')


Measured memory_bytes: 38256
func factorial(x:Int)->Int{return (1...x).reduce(1){$0*$1%1000000007}}
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N, M) = (input[0], input[1])
print(factorial(N)*factorial(M)*(N==M ? 2:abs(N-M)<2 ?1:0)%1000000007)

Measured memory_bytes: 4208
N,M = map(int,input().split())
if N == 1 or M == 1 :
    if N*M == 1 :
        print(1)
    else :
        print(N*M-2)
elif N == 2 or M == 2 :
    print(0)
else :
    print((N-2)*(M-2))


Measured memory_bytes: 2940
#include<cstdio> 
#include<cctype>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 1e5 + 3;
int n,m;
inline int read(){
	int v = 0,c = 1;char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-') c = -1;
		ch = getchar();	
	}
	while(isdigit(ch)){
		v = v * 10 + ch - 48;
		ch = getchar();	
	}
	return v * c;	
}
int main(){
	long long a,b;
	cin >> a >> b;
	if((a + 1) / 2 >= b) cout << "YES";
	else printf("NO");
	return 0;
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
#define LEN(x) ll(x.length()) //lengthをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<ll> num;
    char ex = '1';
    ll cnt = 0;
    REP(i, n){
        if(ex == s[i]) cnt++;
        else{
            num.PB(cnt);
            ex = s[i];
            cnt = 1;
        }
    }
    num.PB(cnt);
    if(ex == '0') num.PB(0);
    ll ans = 0;
    ll left = 0, right = 2 * k;
    REP(i, min(SIZE(num), right+1)) ans += num[i];
    left += 2;
    right += 2;
    ll tmp = ans;
    while(right < SIZE(num)){
        tmp -= num[left-2] + num[left-1];
        tmp += num[right-1] + num[right];
        ans = max(ans, tmp);
        left += 2;
        right += 2;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4440
#include <stdio.h>
#include <vector>
#include <iostream>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, k, i, c=0;
    cin >> n >> k;
    
    for (i=0;i<n;i++){
        int t;
        cin >> t;
        if (t >= k){
            c++;
        }
    }
    cout << c << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pair<int, int> > vp;
typedef pair<int, int> pr;
typedef tuple<int, int, int> ti;

#define FOR(i, a, b) for (int i = (a), _b = (b); i < _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i > _a; i--)
#define pb push_back
#define print(v) cout << v << '\n'
#define pr_vec(v)   for (int i = 0; i != v.size(); i++) cout << v[i] << ' '
#define vin(v)  for (auto &i: v)    cin >> i

ld pi = 3.141592653589793238;
ll M = 1e9 + 7;

int gcd(int a, int b) {
    if (a == 0) return b;

    return gcd(b % a, a);
}

bool is_prime(ll n) {
    if (n == 2) return true;
    if (n < 2) return false;
    if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2) {
        if (n % i == 0) return false;
    }

    return true;
}

bool is_palindrome(string s) {
    return equal(s.rbegin(), s.rend(), s.begin());
}


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

    ll t, n, m, k, q, x, y;
    string s;
    bool flag;

    cin >> n;
    vll v(n);
    vin(v);

    unsigned long long prod = 1;
    unsigned long long up = 1000000000000000000;

    sort(v.begin(), v.end());

    for (int i = 0; i != v.size() ; i++) {
        if (prod == 0)  break;
        if (v[i] > up / prod) {
            print(-1);
            return 0;
        }
        prod *= v[i];
    }

    print(prod);

    return 0;
}

Measured memory_bytes: 4000
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int a, b, c;
  cin >> a >> b >> c;
  set<int> st;
  st.insert(a);
  st.insert(b);
  st.insert(c);
  cout << st.size() << endl;
} 






Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a = str(input())
print(700+100*a.count("o"))


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

int main(){
  int N;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++) cin>>vec.at(i);
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int sum=0;
  for(int i=0;i<N;i++){
    if(i%2==0) sum +=vec.at(i);
    else sum -=vec.at(i);
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes() {
  cout << "Yes" << endl;
  return;
}

void no() {
  cout << "No" << endl;
  return;
}

ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

void solve() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a < b || d < b) {
    no();
    return;
  }
  if (c >= b - 1) {
    yes();
    return;
  }
  ll g = gcd(b, d);
  ll r = (a - b + 1) % g;
  if (r == 0 || r + b - c - 2 >= g) {
    no();
    return;
  }
  yes();
}

int main() {
  ll t;
  cin >> t;
  while (t--) solve();
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
ll n,a,b;
int main(){
    scanf("%lld %lld %lld",&n,&a,&b);
    ll ans=n/(a+b)*a+min(a,n%(a+b));
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
char c[1000][1000];
bool went[1000][1000];
int ans,n,m;
void go(int x,int y){
    if(x>=n||y>=m||x<0||y<0)return ;
    if(c[x][y]=='#')return;
    if(went[x][y])return;
    went[x][y]=true;
    go(x+1,y);
    go(x,y+1);
    go(x-1,y);
    go(x,y-1);
    ans++;
    return ;
}
int main(){
    bool f;
    while(1){
        scanf("%d%d",&m,&n);
        if(n==0&&m==0)return 0;
        f=true;
        ans=0;
        for(int i=0;i<n;i++)scanf("%s",c[i]);
        for(int i=0;i<n;i++)for(int j=0;j<m;j++)went[i][j]=false;
        for(int i=0;i<n&&f;i++)for(int j=0;j<m&&f;j++)if(c[i][j]=='@'){
            go(i,j);
            f=false;
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 2620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N;
		N= sc.nextInt();
		int a[]=new int[N];
		for (int i=0;i<N;i++) {
			a[i] = sc.nextInt();
		}
		int min = 100000000;
		for (int i=1;i<=100;i++) {
			int sum=0;
			for (int j=0;j<N;j++) {
				sum += (a[j]-i)*(a[j]-i);
			}
			if (sum<min) {
				min =sum;
			}
		}
		System.out.println(min);
	}

}

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

typedef long long llt;

const int MaxN = 40 + 5, MaxS = 18;
const llt Mod = 1000000007;

int N, T;
llt dp[MaxN][1 << MaxS];

void init() {
  int x, y, z;
  scanf("%d %d %d %d", &N, &x, &y, &z);
  T |= (1 << (x - 1));
  T = (T << y) | (1 << (y - 1));
  T = (T << z) | (1 << (z - 1));
}

inline void add(llt &x, llt y) { x = (x + y) % Mod; }

inline llt Fast_pow(llt low, llt high) {
  llt res = 1;
  while (high) {
    if (high & 1) res = res * low % Mod;
    high >>= 1;
    low = low * low % Mod;
  }
  return res;
}

void solve() {
  dp[0][0] = 1;
  for (int i = 0; i < N; ++i)
    for (int S = 0; S < (1 << MaxS); ++S) {
      if ((S & T) == T) continue;
      for (int j = 1; j <= 10; ++j) {
        int Q = S;
        for (int k = 17; k >= 18 - j; --k) Q = Q &~ (1 << k);
        Q = (Q << j) | (1 << (j - 1));
        add(dp[i + 1][Q], dp[i][S]);
      }
    }

  llt ans = 0;
  for (int S = 0; S < (1 << MaxS); ++S)
    if ((S & T) != T) add(ans, dp[N][S]);
  ans = Fast_pow(10ll, N) - ans;
  ans = (ans % Mod + Mod) % Mod;
  cout << ans << endl;
}

int main() {
  init();
  solve();
  return 0;
}

Measured memory_bytes: 84224
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 100005
using namespace std;
using LL = long long;
using P = pair<int,int>;
int n, m;
P in[M];
int main()
{
    while (~scanf("%d %d", &n, &m)) {
        REP(i,1,n) scanf("%d %d", &in[i].first, &in[i].second);
        sort(in+1, in+n+1);

        LL ans = 0;
        REP(i,1,n) {
            ans += (LL)min(m, in[i].second) * in[i].first;
            m -= min(m, in[i].second);
        }
        printf("%lld\n", ans);
    }
    
    return 0;
}



Measured memory_bytes: 1024
/*
	AARUSH JUNEJA
	@vivace
	IIT(ISM),Dhanbad
*/

#include<bits/stdc++.h>
using namespace std;

typedef double lf;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef map<string,ll> msl;
typedef pair<int,int> pii;
typedef pair<ll,ll> ii;
typedef vector<ii > vpll;
typedef map<ll,ll> mll;
typedef vector<vll > vvll;
typedef list<ll> lll;
typedef vector<lll > vlll;
typedef pair<ll,ii> iii;

#define rtn return 
#define gc getchar
#define pb push_back
#define ff first
#define ss second
#define mp(x,y) make_pair(x,y)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define lp(i,b) for(ll i = ll(0); i<ll(b) ; i++) 
#define lpit(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define mid(s,e) (s+(e-s)/2)
#define min3(a,b,c)	min(a,min(b,c))
#define max3(a,b,c)	max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))

ll ip(){
	ll x = 0; bool isNeg = false; char c;
	c = gc();
	if(c == '-')	isNeg = true , c = gc();
	for( ; c >= '0'  && c <= '9' ; c = gc()); x = (x << 1) + (x << 3) + c - '0';
	if(isNeg)	x *= -1;	return x;
}
//////////////////////////////////////////// CONTAINERS FOR FUNCTIONS MENTIONED IN TEMPLATE ///////////////////////////////////
#define MAX 100005
//bool isPrime[MAX];
//int spf[MAX];
//////////////////////////////////////////// FUNCTIONS THAT NEED COMMENTED OUT CONTAINERS ////////////////////////////////////


//void prime_sieve(){ for(ll i=2 ; i*i<=MAX ; i++){	if(!isPrime[i]){ for(ll j=i*i ; j<=MAX ; j+=i)	isPrime[j] = 1;} } 	}
//void spf_sieve(){	for(ll i=2 ; i<MAX ; i+=2)	spf[i] = 2;
//	for(ll i=3 ; i<MAX ; i+=2){	if(!isPrime[i]){ spf[i] = i; for(ll j=i ; (j*i)<MAX ; j+=2){ if(!isPrime[i*j])	isPrime[i*j] = true , spf[i*j] = i; } } }
//}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inline ll ncr(ll n,ll r){ ll ans = 1 ; if(r > n-r) r = n-r; lp(i,r+1){ans*=(n-i) ; ans/=(i+1); } rtn ans; }
inline ll gcd(ll a,ll b){if(!a) rtn b; rtn gcd(b%a,a); }
inline ll fme(ll x,ll n,ll mod){ll ans=1;x%=mod;while(n>0){if(n&1){ ans*=x;ans%=mod;} x*=x;x%=mod;n>>=1;}rtn ans%mod;}
inline bool isPalin(string &s){	int len = s.size()-1;lp(i,(len/2)+2){if(!(s[i]==s[len-i]))	rtn false;} rtn true;}
inline ll lcm(ll a,ll b){rtn (a*b)/gcd(a,b); }
inline ll fmm(ll a,ll b,ll m) {ll r=0;a%=m;b%=m;while(b>0){if(b&1){r+=a;r%=m;}a+=a;a%=m;b>>=1;}rtn r%m;}
inline ll sfme(ll a,ll b,ll m) {ll r=1;a%=m;while(b>0){if(b&1)r=fmm(r,a,m);a=fmm(a,a,m);b>>=1;}rtn r%m;}
inline int in(){ int NR=0; register char c=gc(); while( c < 48 || c > 57 ){c=gc();} 
	while(c>47 && c< 58){	NR = (NR << 3) + (NR << 1) + (c - 48); c=gc();} return NR;
}

ll dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};
//--------------------------------TEMPLATE ENDS HERE--------------------------------------------------//


int main(){
	string s;
	cin >> s;
	if(s[s.length() - 1] == 's')	s += "es";
	else s += "s";
	cout << s << "\n";

	return 0;
}














Measured memory_bytes: 3632
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
      double a,t;
      int b;
      cin >> a;
      cin >> b;
      cin >> t;
      cout << b*(int)((t+0.5)/a) << endl;
      //cin >> a >> b;
      //cout << max(max(a+b,a+a-1),b+b-1) << endl;
      return 0;
    }

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

int main() {
  int N;
  int d[110];
  cin >> N;
  for (int i=0; i<N;++i) cin >> d[i];
  
  int num[110]={0};
  for (int i=0;i<N;++i) {
    num[d[i]]++;
  }
  
  int res=0;
  for (int i=1;i<=100;++i) {
    if (num[i]) {
      ++res;
    }
  }
  cout << res <<endl;
}

Measured memory_bytes: 256
N = input()
N = int(N)
S = input()


def caesar(s, n):
    ns = []
    for ch in s:
        # A - Z
        if ('A' <= ch and ch <= 'Z'):
            ns.append(chr((ord(ch) - ord('A') - n) % 26 + ord('A')))
    return "".join(ns)


print(caesar(S, -N))


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        const long MOD = 1000000007;
        var sc = new Scanner();
        int n = sc.nextInt();
        var a = new int[n];
        var b = new int[n];
        var c = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }

        var dp = new long[n, 3];
        dp[0, 0] = a[0];
        dp[0, 1] = b[0];
        dp[0, 2] = c[0];
        for (int i = 1; i < n; i++)
        {
            dp[i, 0] = Math.Max(dp[i - 1, 1] + a[i], dp[i - 1, 2] + a[i]);
            dp[i, 1] = Math.Max(dp[i - 1, 0] + b[i], dp[i - 1, 2] + b[i]);
            dp[i, 2] = Math.Max(dp[i - 1, 0] + c[i], dp[i - 1, 1] + c[i]);
        }

        Console.SetOut(new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        Console.WriteLine(Math.Max(dp[n - 1, 0], Math.Max(dp[n - 1, 1], dp[n - 1, 2])));
        Console.Out.Flush();
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

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

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

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

    public int nextInt()
    {
        return int.Parse(next());
    }

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

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

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

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

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

Measured memory_bytes: 18500
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
#define ll long long
#define int ll
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int mul(int a, int b, int c) {
	long long res = (long long)a * b;
	return (res >= c ? res % c : res);
}

int power(long long a, long long n, int m) {
	int x = 1, p = a % m;
	while(n) {
		if(n & 1) x = mul(x, p, m);
		p = mul(p, p, m);
		n >>= 1;
	}
	return x;
}

int n,dp[105][4][4][4][4];

signed main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	cin >> n;
	int ans = 0;
	REP(i,n+1){
		REP(j,4){
			REP(k,4){
				REP(l,4){
					REP(m,4){
						if(i == 0 and j == 0 and k == 0 and l == 0 and m == 0) dp[i][j][k][l][m] = 1;
						else if(i == 0) dp[i][j][k][l][m] = 0;
						else if(i >= 4 and j == 0 and k == 2 and m == 1){
							dp[i][j][k][l][m] = 0; // AG_C
						}
						else if(i >= 4 and j == 0 and l == 2 and m == 1){
							dp[i][j][k][l][m] = 0; // A_GC
						}
						else if(i >= 3 and k == 0 and l == 2 and m == 1){
							dp[i][j][k][l][m] = 0; // _AGC
						}
						else if(i >= 3 and k == 0 and l == 1 and m == 2){
							dp[i][j][k][l][m] = 0; // _ACG
						}
						else if(i >= 3 and k == 2 and l == 0 and m == 1){
							dp[i][j][k][l][m] = 0; // _GAC
						}
						else{
							dp[i][j][k][l][m] = 0;
							REP(o,4){
								dp[i][j][k][l][m] += dp[i-1][o][j][k][l];
							}
							dp[i][j][k][l][m] %= MOD;
						}
						// if(dp[i][j][k][l][m]){
						// 	trace(i,j,k,l,m,dp[i][j][k][l][m]);
						// }
						if(i == n) ans = (ans+dp[i][j][k][l][m])%MOD;
					}
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int K = in.i();
        int[] p = in.ii(N);
        int[] sum = new int[N + 1];
        for (int i = 0; i < N; i++) {
            sum[i + 1] = sum[i] + p[i];
        }

        int ans = 0;
        for (int i = 0, M = N - K + 1; i < M; i++) {
            ans = Math.max(sum[i + K] - sum[i] + K, ans);
        }
        out.println(ans / 2.0);
    }

    static class MyReader extends BufferedReader {
        char[] cbuf = new char[512];
        int head = 0;
        int tail = 0;

        MyReader(){
            super(new InputStreamReader(System.in));
        }

        char next() {
            if (head == tail) {
                try {
                    tail = super.read(cbuf, 0, cbuf.length);
                } catch (IOException e) {}
                head = 0;
            }
            return cbuf[head++];
        }

        void back() {
            head--;
        }

        int i() {
            boolean minus;
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    if (!(minus = c == '-')) back();
                    break;
                }
            }
            int n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }

        int[] ii(final int N) {
            int[] a = new int[N];
            for (int j = 0; j < a.length; j++) a[j] = i();
            return a;
        }
    }
}


Measured memory_bytes: 37968
#include <iostream>
#include <string>
#include <map>
#define rep(i, a, b) for(int i = a; i < b; i++)

using namespace std;
typedef long long ll;
string s;

ll fact(ll x){
	if(x == 0) return 1;
	return x*fact(x-1);
}

int main(){
	cin >> s;
	map<char, int> mp;
	rep(i, 0, s.size()) mp[s[i]]++;
	
	int cnt = 0;
	int sum = 0;
	ll ans;
	map<char, int>::iterator itr = mp.begin();
	while(itr != mp.end()){
		//cout << itr->first << " "<< itr->second << endl;
		if(itr->second % 2 == 1) {
			(itr->second)--;
			cnt++;
		}
		sum += itr->second/2;
		itr++;
	}
	if(s.size() == 1){ cout << 1 << endl;
	}else if(cnt > 0 && s.size()%2 == 0) cout << 0 << endl;
	else if(cnt > 1) cout << 0 << endl;
	else{
		ans = fact(sum);
		itr = mp.begin();
		while(itr != mp.end()){
		//cout << itr->first << " A "<< itr->second << endl;
			ans /= fact(itr->second/2);
			itr++;
		}		
		cout << ans << endl;
	}
}

Measured memory_bytes: 1188
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN             PIC X(10).
01 K              PIC 9(10).
01 X              PIC 9(10).

PROCEDURE DIVISION.
  ACCEPT LN.
  UNSTRING LN DELIMITED BY SPACE INTO K X.
  IF X <= 500 * K
      DISPLAY "Yes"
  ELSE
      DISPLAY "No"
  END-IF.
  STOP RUN.


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  if(k>(n-1)*(n-2)/2)cout<<-1<<endl;
  else{
    vector<pair<ll,ll>>ans;
    for(int i=1;i<n;i++){
      ans.pb(mp(i,n));
    }
    ll now=1,now2=2;
    for(int i=(n-1)*(n-2)/2;i>k;i--){
      ans.pb(mp(now,now2));
      if(now2+1==n){
	now++;
	now2=now+1;
      }else now2++;
    }
    cout<<ans.size()<<endl;
    for(auto a:ans)cout<<a.F<<" "<<a.S<<endl;
  }
  return 0;
}


Measured memory_bytes: 512
n = int(input())
first=(0,0)
second=0
for i in range(n):
    num = int(input())
    if num>= first[0]:
        second = first[0]
        first=(num,i)
    elif num>=second:
        second = num
# print(n)
for i in range(n):
    if i==first[1]:
        print(second)
    else:
        print(first[0])


Measured memory_bytes: 55512
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Collections;
import java.util.Arrays;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		int N = reader.nextInt();
		int M = reader.nextInt();
		int[] A = new int[N];
		for(int i=0; i<M*2; i++) {
		    A[reader.nextInt()-1]++;
		}
		for(int i=0; i<N; i++) {
		    System.out.println(A[i]);
		}
	}
	
	public static void solver(long K, long[] A) {
		// write logic
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;

    rep(i, 3){
        if(n % 10 == 7){
            cout << "Yes" << endl;
            return 0;
        }
        n /= 10;
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3648
r, g, b, n = gets.split(" ").map(&:to_i)

count = 0

sum = 0

3001.times do |index|
  3001.times do |index2|
    sum = r * index + g * index2
    if (n - sum) % b == 0 && n >= sum
      count += 1
    end
  end
end

puts count

Measured memory_bytes: 1788
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int big = 1e+18+3;
int mod = 1e+9+7;

signed main()
{
    IOS;
        
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    int takawin = (c/b) + (c%b!=0);
    int nontakawin = (a/d) + (a%d!=0);

    if (takawin<=nontakawin)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;   
}

Measured memory_bytes: 3584
//package atcoderdp;
import java.util.*;
 class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int a[]=new int[n];
        for (int i = 0; i <n ; i++) {
            a[i] = s.nextInt();
        }
        System.out.println(find(a,n));
    }
    public static int find(int a[],int n){
        if(n<2)
            return 0;
        int dp[]=new int[n];
        Arrays.fill(dp,Integer.MAX_VALUE);
        dp[0]=0;
        dp[1]=Math.abs(a[1]-a[0]);
        //System.out.println(Arrays.toString(dp));
        for (int i = 2; i <n ; i++) {
            dp[i]=Math.min(dp[i-1]+Math.abs(a[i-1]-a[i]),dp[i-2]+Math.abs(a[i-2]-a[i]));
        }
        //System.out.println(Arrays.toString(dp));
        return dp[n-1];
    }
}


Measured memory_bytes: 59644
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    for (int i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        if(a[i]>b[i]){
            swap(a[i],b[i]);
        }
    }
    vector<int> c(n,0);
    for(int i=0;i<m;i++){
        c[a[i]]++;
        c[b[i]]--;
    }
    for(int i=1;i<n;i++){
        c[i]+=c[i-1];
    }
    for(int i=0;i<n-1;i++){
        if(c[i]%2){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,r;
    cin >> n >> r;
    if(n<10) cout << r+(10-n)*100 << "\n";
    else cout << r << "\n";

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair <long long,long long> ii;


ll mod = 1e9+7;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll count = 0;
    ll way = 1;
    for (int z=0;z<s.size();z++){
        ll c;
        if (s[z] == 'B') c = 1;
        else c = 0;
        if ((count + c)%2 != 0) count++;
        else {
            way *= count;
            if (way <= 0){
                cout << 0 << endl;
                return 0;
            }
            way %= mod;
            count--;
        }
        count %= mod;
    }
    if (count != 0){
        cout << 0 << endl;
        return 0;
    }
    for (int z=1;z<=n;z++){
        way *= z;
        way %= mod;
    }
    cout << max(ll(0),way%mod) << endl;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  for(int i = 0; i <= a; ++i){
    for(int j = 0; j <= b; ++j){
      for(int k = 0; k <= c; ++k){
        int tmp = 500*i+100*j+50*k;
        if(x == tmp)++ans;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <iterator>
#include <sstream>

int main(){

  std::string line;
  std::getline(std::cin, line);

  std::istringstream iss (line);
  std::vector<std::string> token ((std::istream_iterator<std::string>(iss)),
				  std::istream_iterator<std::string>());  
  std::vector<int> operand;
  for(auto t : token){
    if(t[0] == '+'){
      int x = operand[operand.size()-1];
      int y = operand[operand.size()-2];
      operand.pop_back();
      operand.pop_back();
      operand.push_back( y+x );
    }
    else if(t[0] == '-'){
      int x = operand[operand.size()-1];
      int y = operand[operand.size()-2];
      operand.pop_back();
      operand.pop_back();
      operand.push_back( y-x );
    }
    else if(t[0] == '*'){
      int x = operand[operand.size()-1];
      int y = operand[operand.size()-2];
      operand.pop_back();
      operand.pop_back();
      operand.push_back( x*y );
    }
    else {
      int n = std::stoi(t);
      operand.push_back(n);
    }
  }
  std::cout << operand[0] << std::endl;
  return 0;
}



Measured memory_bytes: 3232
// C++ program to find the longest 
// path in the DAG 

#include <bits/stdc++.h> 
using namespace std; 

// Function to traverse the DAG 
// and apply Dynamic Programming 
// to find the longest path 
void dfs(int node, vector<int> adj[], int dp[], bool vis[]) 
{ 
	// Mark as visited 
	vis[node] = true; 

	// Traverse for all its children 
	for (int i = 0; i < adj[node].size(); i++) { 

		// If not visited 
		if (!vis[adj[node][i]]) 
			dfs(adj[node][i], adj, dp, vis); 

		// Store the max of the paths 
		dp[node] = max(dp[node], 1 + dp[adj[node][i]]); 
	} 
} 

// Function to add an edge 
void addEdge(vector<int> adj[], int u, int v) 
{ 
	adj[u].push_back(v); 
} 

// Function that returns the longest path 
int findLongestPath(vector<int> adj[], int n) 
{ 
	// Dp array 
	int dp[n + 1]; 
	memset(dp, 0, sizeof dp); 

	// Visited array to know if the node 
	// has been visited previously or not 
	bool vis[n + 1]; 
	memset(vis, false, sizeof vis); 

	// Call DFS for every unvisited vertex 
	for (int i = 1; i <= n; i++) { 
		if (!vis[i]) 
			dfs(i, adj, dp, vis); 
	} 

	int ans = 0; 

	// Traverse and find the maximum of all dp[i] 
	for (int i = 1; i <= n; i++) { 
		ans = max(ans, dp[i]); 
	} 
	return ans; 
} 

// Driver Code 
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
	int n,m,a,b;
    cin>>n>>m;
    vector<int> adj[n + 1];
    for(int i=0;i<m;i++)
    {
        cin>>a>>b;
        addEdge(adj,a,b);
    } 
	cout << findLongestPath(adj, n); 
	return 0; 
} 


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vv;
#define pb push_back
#define MOD 1000000007
#define INF 1000000000
#define endl '\n'
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }

int main(){
    
    fast();
    //#ifndef ONLINE_JUDGE
    //freopen("F:\\Codes\\input.txt", "r", stdin);
   // freopen("F:\\Codes\\output.txt", "w", stdout);
   // #endif
    
    ll n,i,j,w;
    ll ans=-1*INT_MAX;
    cin>>n>>w;

    vl wgt(n+1),val(n+1);
    vv dp(n+1,vl(n*1000+1));
    for(i=1;i<=n;i++){cin>>wgt[i]>>val[i];}

    for(i=1;i<=n;i++){
        for(j=1;j<=n*1000;j++){

            if(j==val[i]){
                if(dp[i-1][j]!=0){dp[i][j]=min(dp[i-1][j],wgt[i]);}
                else{dp[i][j]=wgt[i];}
            }
            else if(j>val[i]){
                if(dp[i-1][j-val[i]]!=0){
                    if(dp[i-1][j]!=0){
                    dp[i][j]=min(dp[i-1][j],dp[i-1][j-val[i]]+wgt[i]);
                    }
                    else{
                        dp[i][j]=dp[i-1][j-val[i]]+wgt[i];
                    }
                }
                else{dp[i][j]=dp[i-1][j];}
            }
            else{dp[i][j]=dp[i-1][j];}

            if(dp[i][j]<=w && dp[i][j]!=0){ans=max(ans,j);}
            
        }
    }

    // for(i=0;i<=n;i++){
    //     for(j=0;j<=20;j++){
    //         cout<<dp[i][j]<<" ";
    //     }cout<<endl;
    // }
    cout<<ans<<endl;

    
    return 0;
}

Measured memory_bytes: 83168
function Main(input) {
    var week = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
    inputLine = input.split("\n");
    for(var i=0;;i++){
        var dateObj = new Date();
        dateObj.setFullYear(2004);
        var date = inputLine[i].split(" ");
        var month = int(date[0]);
        var day = int(date[1]);
        if(month === 0)break;
        dateObj.setMonth(month-1);
        dateObj.setDate(day);
        output(week[dateObj.getDay()]);
        dateObj=null;
    }
}

//??°??????????????¢??°??¨(??????)
function ascendingOrder(val1,val2){
    return val1 - val2;
}
//??°??????????????¢??°??¨(??????)
function descendingOrder(val1,val2){
    return val2 - val1;
}
//??°??????
function int(str){
    return parseInt(str, 10);
}
//????????????
function str(num){
    return num.toString(10);
}
function output(str){
	if(_Isdebug){
		document.getElementById("Console").value+=(str+"\n");
	}
	console.log(str);
}

//???????????°??¨
var _Isdebug = false;

function debug(){
	_Isdebug = true;
	var input = document.getElementById("Console").value;
	document.getElementById("Console").value+="\n";
	Main(input);
}

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

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

using namespace std;

int main(){
    int n,sub;
    float ans;
    cin >> n;
       if(n%2==0){
          sub = (n/2);
          ans = (1.0)*sub/n;
       }
       else{
          sub = (n+1)/2;
          ans = (1.0)*sub/n;
    
       }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 3780
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;cin>>n;
  int Map[2][n];
  for(int i=0;i<n;i++){
    cin>>Map[0][i];
  }
  for(int i=0;i<n;i++)
    cin>>Map[1][i];
  int ma=0;
  int sum=0;
  for(int i=0;i<n;i++){
    sum+=Map[0][i];
    int s=sum;
    for(int j=i;j<n;j++){
      s+=Map[1][j];
    }
    ma=max(ma,s);
  }
  cout<<ma<<endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    x: usize,
    y: usize,
    z: usize,
    k: usize,
    mut a: [usize; x],
    mut b: [usize; y],
    mut c: [usize; z],
    }
    a.sort_by(|i, j| j.partial_cmp(i).unwrap());
    b.sort_by(|i, j| j.partial_cmp(i).unwrap());
    c.sort_by(|i, j| j.partial_cmp(i).unwrap());
    let mut s = 0;
    let mut t = std::usize::MAX;
    while s + 1 < t{
        let mid = (s + t) / 2;
        if find_p(k, mid, &a, &b, &c) {
            s = mid;
        } else {
            t = mid;
        }
    }
    let mut ans = Vec::new();
    for i in 0..x {
        for j in 0..y {
            for k in 0..z {
                let g = a[i] + b[j] + c[k];
                if g < s {break}
                ans.push(g);
            }
        }
    }
    ans.sort_by(|i, j| j.partial_cmp(i).unwrap());
    let an = ans.len();
    for i in 0..k {
        if i >= an {break;}
        println!("{}", ans[i])
    }
}

fn find_p (k: usize, p: usize, a: &Vec<usize>, b: &Vec<usize>, c: &Vec<usize>) -> bool {
    let mut cnt = 0;
    let x = a.len();
    let y = b.len();
    let z = c.len();
    for i in 0..x {
        for j in 0..y {
            for kk in 0..z {
                if a[i] + b[j] + c[kk] < p {break}
                cnt += 1;
                if cnt >= k {return true}
            }
        }
    }
    false
}


Measured memory_bytes: 81480
box_num, key_num = map(int, input().split())
dp_length = 2**box_num
dp = [float('inf')] * dp_length
dp[0] = 0
for _ in range(key_num):
    current_key_price, _ = map(int, input().split())
    c = 0
    effects = list(map(int, input().split()))
    for i in effects:
        e = 1 << (i - 1)
        c += e
    for x in range(dp_length):
        new_price = dp[x] + current_key_price
        dp_index = c | x
        if dp[dp_index] > new_price:
            dp[dp_index] = new_price
    # print(dp)
if dp[-1] == float('inf'):
    print(-1)
else:
    print(dp[-1])


Measured memory_bytes: 47964
import sys
N = int(input())
X = int(input(), 2)
x_popcount = sum(map(int, bin(X)[2:]))
is_zeroflg = [x_popcount-1 <= 0, False]
x_popcounts = [max(1, x_popcount - 1), x_popcount + 1]
X_per_popcounts = [X % x_popcounts[0], X % x_popcounts[1]]
mods = [0, 0]
ans = [0]*N


def f(n):
    cnt = 0
    while n != 0:
        popcount = sum(map(int, bin(n)[2:]))
        n = n % popcount
        cnt += 1
    return cnt


flg = X & 1 ^ 1
mods[0] = (-1) % x_popcounts[0]
mods[1] = 1 % x_popcounts[1]
tmp = (X_per_popcounts[flg] + mods[flg]) % x_popcounts[flg]
ans[0] = f(tmp) + 1
if is_zeroflg[flg]:
    ans[0] = 0

for i in range(1, N):
    flg = (X >> i) & 1 ^ 1
    mods[0] = (mods[0] * 2) % (x_popcounts[0])
    mods[1] = (mods[1] * 2) % (x_popcounts[1])
    tmp = (X_per_popcounts[flg] + mods[flg]) % x_popcounts[flg]
    ans[i] = f(tmp) + 1
    if is_zeroflg[flg]:
        ans[i] = 0

print('\n'.join(map(str, ans[::-1])))


Measured memory_bytes: 96416