akhauriyash/Code-Regression huggingface dataset:
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
int h,w,k;
string s[7];
int vis[7][7];
bitset<7>bt;
int chk(int msk1,int msk2)
{
     clr(vis);
     f(i,0,h-1)
     {
         f(j,0,w-1)
         {
             if(s[i][j]=='#')vis[i][j]=2;
             else vis[i][j]=1;
         }
     }
     bt=msk1;
     for(int j=0;j<h;j++)
     {
         if(bt[j]==1)
         {
             f(i,0,w-1)
             {
                 vis[j][i]=3;
             }
         }
     }
     bt=msk2;
     for(int j=0;j<w;j++)
     {
         if(bt[j]==1)
         {
             f(i,0,h-1)
             {
                 vis[i][j]=3;
             }
         }
     }
     int ret=0;
     f(i,0,h-1)
     {
         f(j,0,w-1)
         {
             if(vis[i][j]==2)ret++;
         }
     }
    return ret;
}
 main()

{
    fast
    cin>>h>>w>>k;
    f(i,0,h-1)
    {
        cin>>s[i];
    }
    int xx=(1LL<<h);
    int yy=(1LL<<w);
    set<pi>ses;
    f(i,0,xx-1)
    {
        f(j,0,yy-1)
        {
            if(chk(i,j)==k)
            {
                ses.insert(mp(i,j));
            }
        }
    }
    cout<<ses.size()<<endl;
    return 0;

}





































Measured memory_bytes: 3732
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let a: usize = sc.read();
    let b: usize = sc.read();

    if a <= 9 && b <= 9 {
        format!("{}\n", a*b)
    } else {
        "-1\n".to_string()
    }
}
#[test]
fn test_solve() {
   assert_eq!(solve("2 5\n"), "10\n");
   assert_eq!(solve("5 10\n"), "-1\n");
   assert_eq!(solve("9 9\n"), "81\n");
}
fn main() {
    let mut buf = String::new();
    use std::io::Read;
    std::io::stdin().read_to_string(&mut buf).unwrap();
    use std::io::Write;
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<I> {
    src: I,
}
impl<'a> Scanner<std::str::SplitWhitespace<'a>> {
    fn from_str(src: &'a str) -> Self {
        Scanner {
            src: src.split_whitespace(),
        }
    }
}
#[allow(dead_code)]
impl<'a, I> Scanner<I>
where
    I: std::iter::Iterator<Item = &'a str>,
{
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.src.next().unwrap().parse().ok().expect("Parse error")
    }
    fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    fn chars(&mut self) -> Vec<char> {
        self.src.next().unwrap().chars().collect()
    }
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,k;
inline void read(ll &x)
{
	ll f;char c;
	for (f=1,c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for (x=0;c<='9'&&c>='0';c=getchar()) x=x*10+(c&15);x*=f;
}
inline ll mn(ll _x,ll _y)
{
	return _x<_y?_x:_y;
}
inline ll ab(ll _x)
{
	if(_x<0) return -_x;
	else return _x;
}
int main()
{
	read(n);read(k);
	n%=k;
	printf("%lld\n",mn(n,ab(n-k)));
	return 0;
}




Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

	    int n=gi();
	    int a=gi();
	    int b=gi();
	    int c=0;
	    for (int i=1; i<=n;i++) {
	    	int e=d(i);
	    	if(a<=e && e<=b) {
	    		c+=i;
	    	}
	    }


	    System.out.println(c);
//	    if (s.compareTo(t) >0) {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }



	}

	public static int d(int n) {
		int m=0;
		while(true) {
			if(n<1) {
				break;
			}
			int l= n%10;
			m+=l;
			n= (n-l)/10;
		}
		return m;
	}
	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35684
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

vector<int> G[100000];

int dist[100000];
int ans[100000];

int  dfs(int cur, int prev){
    int ret = 0;
    for(auto to:G[cur]){
        if(to==prev)continue;
        ret = max(ret,1+dfs(to,cur));
    }
    return dist[cur] = ret;
}


void dfs2(int cur, int prev, int d_par){
    vector<pii> v{pii(0,-1)};
    for(auto to:G[cur]){
        if(to==prev)v.pb(pii(1+d_par,to));
        else v.pb(pii(1+dist[to],to));
    }
    
    sort(all(v),greater<pii>());
    
    for(auto to:G[cur]){
        if(to==prev)continue;
        if(v[0].second==to) dfs2(to,cur,v[1].first);
        else                dfs2(to,cur,v[0].first);
    }
    ans[cur] = v[0].first;
}

int main(){
    int v;
    cin>>v;
    rep(i,v-1){
        int s,t;
        cin>>s>>t;
        s--,t--;
        G[s].pb(t);
        G[t].pb(s);
    }
    
    dfs(0,-1);
    
    dfs2(0,-1,0);
    
    rep(i,v)cout<<2*(v-1)-ans[i]<<endl;
}

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

using namespace std;

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

    string w;
    cin>>w;

    int freq[26]={};

    if(w.length()%2==0){
        for(int i=0;i<w.length();i++){
            int num = int(w[i])-97;
            freq[num]++;
        }

        for(int i=0;i<26;i++){
            if(freq[i]%2!=0){
                cout<<"No\n";return 0;
            }
        }

        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }

    //cout<<int('z')-97;


    return 0;
}


Measured memory_bytes: 256
// "include" {{{
#include <deque>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
// }}}
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x;
	cin >> x;
	cout << x / 11 * 2 + ((x % 11 + 6 - 1) / 6)<< '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

double l[20],a[20],b[20];
                   
int main() {
  int n, m;
  cin >> n >> m;
  REP(i,n)
    cin >> l[i]>>a[i]>>b[i];
  string s = string(n-m, '0') + string(m, '1');
  double res = 0;
  do {
    double tmp = 0;
    REP(i,n) {
      REP(j,i) {
        if (s[i] == '1' && s[j] == '1') {
          tmp += (a[i]-a[j])*(a[i]-a[j]) + (b[i]-b[j])*(b[i]-b[j]) + (l[i]-l[j])*(l[i]-l[j]);
        }
      }
    }
    res = max(res, tmp);
  } while(next_permutation(ALL(s)));
  printf("%.12f\n", res);
}

Measured memory_bytes: 940
//
// Created by watemus on 10.05.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

using namespace std;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second

using ll = long long;
using ld = long double;
#define int ll

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;

vector<pair<int, int>> DD = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

#ifdef LOCAL
#else
#endif

constexpr int MOD = 998244353;

int pw(int a, int b) {
    int ans = 1;
    while (b > 0) {
        if (b & 1) {
            ans *= a;
            ans %= MOD;
        }
        a *= a;
        a %= MOD;
        b >>= 1;
    }
    return ans;
}

const int MAXN = 3e5;

int fact[MAXN];

int C(int n, int k) {
    return fact[n] * pw(fact[k], MOD - 2) % MOD * pw(fact[n - k], MOD - 2) % MOD;
}

void run() {
    int n, m, k;
    cin >> n >> m >> k;
    k++;
    fact[0] = fact[1] = 1;
    for (int i = 2; i < MAXN; i++) {
        fact[i] = fact[i - 1] * i % MOD;
    }
    int adj = 1;
    int cnt = n - 1;
    int ans = 0;
    while (adj <= k) {
        int cur = m * pw(m - 1, cnt) % MOD;
        cur *= C(n - 1, cnt);
        cur %= MOD;
        ans += cur;
        ans %= MOD;
        adj++;
        cnt--;
    }
    cout << ans << "\n";
}

signed main() {
#ifdef LOCAL
    std::freopen("input.txt", "r", stdin);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    int t = 1;
//    cin >> t;
    while (t--) {
        run();
    }
    return 0;
}

Measured memory_bytes: 6004
#include <iostream>
#include <vector>

using namespace std;

int parent[100000];

void init(int n) {
	while (n--)
		parent[n] = n;
}

int find(int x) {
	return parent[x] != x ? parent[x] = find(parent[x]) : x;
}

inline void unite(int x, int y) {
	parent[find(y)] = find(x);
}

vector<int> l[100000];

int main() {
	int n, m;

	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int li;
			cin >> li;
			l[li - 1].emplace_back(i);
		}
	}

	init(n);
	for (int i = 0; i < m; i++)
		for (int j = 1; j < l[i].size(); j++)
			unite(l[i][0], l[i][j]);

	const int hoge = find(0);
	for (int i = 1; i < n; i++)
		if (find(i) != hoge) {
			cout << "NO" << endl;
			return 0;
		}

	cout << "YES" << endl;

	return 0;
}


Measured memory_bytes: 4608
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int C = scan.nextInt();
        int[] s = new int[N];
        int[] t = new int[N];
        int[] c = new int[N];
        int[] dp = new int[200002];
        int[] sum = new int[200002];
        for (int i = 0; i < N; i++) {
            s[i] = scan.nextInt();
            t[i] = scan.nextInt();
            c[i] = scan.nextInt()-1;
        }
        for (int i = 0; i < C; i++) {
            Arrays.fill(dp, 0);
            for (int j = 0; j < N; j++) {
                if (c[j] != i) {
                    continue;
                }
                dp[2*s[j]-1] += 1;
                dp[2*t[j]] -= 1;
            }
            for (int j = 1; j <= 200001; j++) {
                dp[j] += dp[j-1];
            }
            for (int j = 0; j <= 200001; j++) {
                if (0 < dp[j]) {
                    sum[j] += 1;
                }
            }
        }
        int ans = 0;
        for (int i = 0; i <= 200001; i++) {
            ans = Math.max(ans, sum[i]);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 98368
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<iomanip>

int main() {
	int l;
	cin >> l;
	long double a,b;
	a = double(l) / double(3);
	b = a * a * a;
	cout << fixed<<setprecision(12)<<b << endl;
}

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

#include <math.h>
#include <stdlib.h>


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

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; }



int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int a, b; cin >> a >> b;

    if(a < 10 && b < 10) cout << a * b << endl;
    else cout << "-1" << endl;
    return 0;
}


Measured memory_bytes: 256
S = input()
ans = 0
for i in range(2**(len(S)-1)):
    l = 0
    for j in range(len(S)-1):
        if (i >> j) & 1:
            ans += int(S[l:j+1])
            l = j+1
    ans += int(S[l:])
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define FF first
#define SS second
using namespace std ;
 
const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

#define N 1000001

void solve()
{
	lli pr[6] = {0};

	loopl(i,0,5)
	{
		lli x;
		cin>>x;
		pr[x]=1;
	}

	loopl(i,1,6)
	{
		if(pr[i] == 0)
		{
			cout<<i;
			return ;
		}
	}

}

int main()
{
/////////////////////////////////////
    fastio;
/////////////////////////////////////  

    lli t;
    t=1;
    while(t--)
    	solve();
}

Measured memory_bytes: 3648
import copy

class BinaryIndexedTree():
    def __init__(self, max_n):
        self.size = max_n + 1
        self.tree = [0] * self.size
        self.depth = self.size.bit_length()
 
    def initialize(self, seq):
        for i, x in enumerate(seq[1:], 1):
            self.tree[i] += x
            j = i + (i & (-i))
            if j < self.size:
                self.tree[j] += self.tree[i]
 
    def __repr__(self):
        return self.tree.__repr__()
 
    def get_sum(self, i):
        s = 0
        while i:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i < self.size:
            self.tree[i] += x
            i += i & -i
 
    def find_kth_element(self, k):
        x, sx = 0, 0
        dx = (1 << self.depth)
        for i in range(self.depth - 1, -1, -1):
            dx = (1 << i)
            if x + dx >= self.size:
                continue
            y = x + dx
            sy = sx + self.tree[y]
            if sy < k:
                x, sx = y, sy
        return x + 1

n,k = map(int,input().split())
a = [int(input()) for _ in range(n)]
ssum = [0]*(n+1)
for i in range(1,n+1):
    ssum[i] = ssum[i-1] + a[i-1]

r = [0]*(n+1)
for i in range(n+1):
    r[i] = ssum[i]-i*k

r2 = copy.copy(r)
r2.sort()

d = dict()
cnt = 1
d[r2[0]] = 1
for i in range(1,n+1):
    if r2[i] != r2[i-1]:
        cnt += 1
    d[r2[i]] = cnt
#print(d)

bit = BinaryIndexedTree(2*10**5+5)
ans = 0

for i in range(n,-1,-1):
    t = d[r[i]]
    ans += bit.get_sum(2*10**5+2)-bit.get_sum(t-1)
    bit.add(t, 1)

print(ans)

Measured memory_bytes: 90200
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,sum;
	cin>>n>>m>>sum;
	for(int i=1;i<=m;i++)
	cout<<sum<<" ";
	for(int i=1;i<=n-m;i++){
		if(sum<1e9)
	cout<<sum+1<<" ";
	    else
	   cout<<1<<" "; 
}
	cout<<endl; 
}

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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COL(x) cout << x << endl
#define CO(x) cout << x
#define int long long

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const int INF = INT64_MAX;
//const int INF = INT_MAX;

template<typename T> inline constexpr auto sqr(T x) { return (x) * (x); }
inline void printd(double x) { printf("%.10lf\n", x); }
inline void upsort(VI& x) { sort((x).begin(), (x).end()); }
inline void downsort(VI& x) { sort((x).begin(), (x).end(), greater<int>()); }

inline int abssa(int a, int b) {
	if (a > b) return (a - b);
	else return (b - a);
}

signed main()
{
	int N, K;
	cin >> N >> K;
	int x = N;

	if (N == K) {
		COL(0);
		return 0;
	}
	else if (N > K) {
		N = N % K;
	}

	if (static_cast<double>(N) < (K / 2.0)) {
		COL(N);
		return 0;
	}
	else {
		COL(K-N);
		return 0;
	}
	return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    double x = acos(-1) * c / 180;
    double s = a*b / 2 * sqrt(1-cos(x)*cos(x));
    double l = a + b + sqrt(a*a + b*b - 2*a*b*cos(x));
    double h = 2*s / a;
    printf("%f\n", s);
    printf("%f\n", l);
    printf("%f\n", h);
    return 0;
}


Measured memory_bytes: 3324
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

typedef struct node *link;

struct node
{
	int key;
	link parent,left,right;
};

link root;
link in;

void insert(link z)
{
	link p=NULL;
	link x=root;
	while(x!=NULL)
	{
		p=x;
		if(z->key<x->key)
		{
			x=x->left;
		}
		else
		{
			x=x->right;
		}
		z->parent=p;
	}
	if(p==NULL)
	{
		root=z;
	}
	else if(z->key<p->key)
	{
		p->left=z;
	}
	else
	{
		p->right=z;
	}
}

void traverse1(link a)
{
	if(a==NULL) return;
	printf(" %d",a->key);
	traverse1(a->left);
	traverse1(a->right);
}

void traverse2(link a)
{
	if(a==NULL) return;
	traverse2(a->left);
	printf(" %d",a->key);
	traverse2(a->right);
}

int main(void)
{
	root=NULL;

	int i,num,N;
	char get[10];

	scanf("%d",&N);

	for(i=0;i<N;i++)
	{
		scanf("%s",get);

		if(strcmp(get,"insert")==0)
		{
			scanf("%d",&num);
			in=malloc(sizeof(*in));
			in->key=num;
			in->left=NULL;
			in->right=NULL;
			in->parent=NULL;
			insert(in);
		}
		else if(strcmp(get,"print")==0)
		{
			traverse2(root);
			printf("\n");
			traverse1(root);
			printf("\n");
		}
	}

	return 0;
}



Measured memory_bytes: 25172
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

bool isPrime(ll n){
	for(ll i = 2; i*i <= n; i++){
		if(n%i == 0) return false;
	}
	return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q, l, r;
    cin >> q;
    vector<int> sum(100005, 0);
    for(int i = 3; i <= 100000; i++){
        sum[i] = sum[i-1];
        if(i%2 == 1){
            if(isPrime(i) && isPrime((i+1)/2)) sum[i]++;
        }
    }
    rep(i,q){
        cin >> l >> r;
        cout << sum[r] - sum[l-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,K=MAP()
V=LIST()

def calc(l, r):
    # Kより多く操作するケースは不可
    if l+(N-r)>K:
        return -INF
    ngtv=[]
    res=0
    # 左から取る分
    for i in range(l):
        res+=V[i]
        if V[i]<0:
            ngtv.append(V[i])
    # 右から取る分
    for i in range(N-1, r-1, -1):
        res+=V[i]
        if V[i]<0:
            ngtv.append(V[i])
    # マイナス分をソートしておく
    ngtv.sort()
    # 取った分の操作回数
    k=l+(N-r)
    i=0
    # まだ操作できるかつマイナスが残ってる限り、捨てる
    while k<K and i<len(ngtv):
        res-=ngtv[i]
        i+=1
        k+=1
    return res

ans=-INF
# 左右どこまで取るかを全通り試す
for l in range(N+1):
    for r in range(l, N+1):
        ans=max(ans, calc(l, r))
print(ans)


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

using uli = unsigned long int;
using lli = long long int;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define repa(a,i,x) for(int i=a;i<=x;i++)

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


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=105;
//i_am_noob
int n,m,dp[maxn][maxn];
char a[maxn][maxn];
 
signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n >> m;
	rep(n) rep1(j,m) cin >> a[i][j];
	rep(n) rep1(j,m){
		if(i==0&&j==0) dp[i][j]=(a[i][j]=='#');
		else if(i==0) dp[i][j]=dp[i][j-1]+(a[i][j]=='#'&&a[i][j-1]=='.');
		else if(j==0) dp[i][j]=dp[i-1][j]+(a[i][j]=='#'&&a[i-1][j]=='.');
		else dp[i][j]=min(dp[i-1][j]+(a[i][j]=='#'&&a[i-1][j]=='.'),dp[i][j-1]+(a[i][j]=='#'&&a[i][j-1]=='.'));
	}
	print1(dp[n-1][m-1]);
	return 0;
}

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

const int MAX_N=2e6;
vector<int> primes,is_prime(MAX_N,1);

void sieve(){
    is_prime[0]=is_prime[1]=0;
    for (int i=2;i<MAX_N;++i){
        if (is_prime[i]){
            primes.emplace_back(i);
            for (int j=2*i;j<MAX_N;j+=i) is_prime[j]=0;
        }
    }
}

int k,ans;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    sieve();
    while(cin >> k,k){
        if (is_prime[k]){
            cout << 0 << '\n';
            continue;
        }
        auto itr=upper_bound(primes.begin(),primes.end(),k);
        ans=*itr-*(itr-1);
        cout << ans << '\n';
    }
}


Measured memory_bytes: 11520
#include <iostream>

using namespace std;

int GCD(int x, int y)
{
	if (x == 0)
	{
		return(y);
	}
	else
	{
		GCD(y % x, x);
	}
}

void solve()
{
	int x, y;
	cin >> x >> y;
	cout << GCD(x, y) << endl;
}

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

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long i,n,l;
    cin>>n;
    long long a[n],s=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    cout<<s-n<<endl;
}


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

using namespace std;

const int mod = 998244353;

map< string, int > dp;

int rec(const string &S)
{
  if(S.empty()) return (1);
  if(dp.count(S)) return (dp[S]);
  int ret = (1 + S[0] - '0') * rec(S.substr(1)) % mod;
  string mask1;
  for(int i = 1; i <= S.size() / 2; i++) {
    mask1.push_back('1');
    string mask2 = mask1;
    for(int j = i; j <= S.size(); j += i) {
      for(int k = j - i; k < j; k++) {
        if(S[k] == '0') mask2[k - (j - i)] = '0';
      }
      if(j == i) continue;
      (ret += 1LL * rec(mask2) * rec(S.substr(j)) % mod) %= mod;
    }
  }
  return (dp[S] = ret);
}


int main()
{
  string S;
  cin >> S;
  cout << rec(S) << endl;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   long long n=0;
   int k;
   cin>>k;
   rep(i,k){
    rep(j,k){
     rep(l,k){
       n+=gcd(gcd(i+1,j+1),l+1);
     }
    }
   }
  cout<<n<<endl;
}

Measured memory_bytes: 3604
import sys
s = int(input())
a_list = [0, s]
check_set = set([s])
counter = 2
while len(check_set) <= 10**9:
    if a_list[-1]%2 == 0:
        a_i = a_list[-1]/2
    else:
        a_i = a_list[-1]*3 + 1
    a = set([a_i])
    if a.issubset(check_set):
        print(counter)
        sys.exit()
    else:
        a_list.append(a_i)
        check_set.add(a_i)
    counter += 1

Measured memory_bytes: 3064
H, W = gets.split(" ").map( & :to_i)
a = []
w_indexes = (W - 1).downto(0).to_a
H.times do
  row = gets.chomp.split("")
  next if row.uniq == ["."]

  w_indexes = w_indexes.select { | i | row[i] == "." }
  a << row
end
transposed_a = a.transpose
w_indexes.each { | i | transposed_a.delete_at(i)}

transposed_a.transpose.each { |row| puts row.join }

Measured memory_bytes: 4348
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#define endl '\n'
//#define ll long long
#define mod 1000000007
#define NCONS 100001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
#define int long long
//#define double long double
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
typedef long long ll;

int gcd(int a, int b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }

#define YYYY cout << "YES" << endl
#define NNNN cout << "NO" << endl
#define yyyy cout << "Yes" << endl
#define nnnn cout << "No" << endl

int cnt[200001];
vector<int> adj[200001];
int N, Q;

void dfs_setting(int cur, int e, int value)
{
    cnt[cur] += value;
    for(int i = 0; i < adj[cur].size(); i++)
    {
        auto nxt = adj[cur][i];
        if(nxt == e) continue;
        dfs_setting(nxt, cur, cnt[cur]);
    }
    
}

int32_t main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    cin >> N >> Q;
    
    for(int i = 0; i < N - 1; i++)
    {
        int a, b; cin >> a >> b; adj[a].push_back(b); adj[b].push_back(a);
    }
    
    while(Q--)
    {
        int p, x; cin >> p >> x; cnt[p] += x;
    }
    
    dfs_setting(1, -1, 0);
    
    for(int i = 1; i <= N; i++)
        cout << cnt[i] << " ";
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 24320
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9;

int main(){
  int N;
  double x[10];
  string u[10];
  cin>>N;
  for (int i(0);i<N;i++) cin>>x[i]>>u[i];
  double sum(0);
  for (int i(0);i<N;i++){
    if (u[i] == "JPY"){
      sum+= x[i];
    }else{
      sum+=x[i]*380000.0;
    }
  }
  cout << setprecision(10) << sum << endl;
  return 0;
}


Measured memory_bytes: 256
n,a,b = list(map(int,input().split()))

t1 = n // (a+b)
t2 = n % (a+b)

if t2 <= a:
  ans = t1 * a + t2
else:
  ans = t1 * a + a

if n < a + b:
  if n < a:
    ans = n
  else:
    ans = a

if a == 0:
  ans = 0
elif b == 0:
  ans = n
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>

int a[31] = {1, 1, 2};

int main(void)
{
	int n, i;
	
	for (i = 3; i <= 30; i++) a[i] = a[i - 1] + a[i - 2] + a[i - 3];
	
	while (1){
		scanf("%d", &n);
		if (n == 0) break;
		printf("%d\n", a[n] / 10 / 365 + 1);
	}
	
	return (0);
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

int main() {
	int n; cin >> n;
	int a[103];
	for (int i = 0; i < n; ++i) cin >> a[i];
	ll ans = 2e18;
	for (ll i = -100; i <= 100; ++i) {
		ll sum = 0;
		for (int j = 0; j < n; ++j) {
			sum += (i - a[j])*(i - a[j]);
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import re
while 1:
	n,m = map(int,raw_input().split())
	if n == m == 0: break
	R = [0]*n
	for i in range(n):
		p,s,d = raw_input().replace("?","[0-9]").split()
		R[i] = [re.compile(s+d), p[0] == "p"]
	ans = []
	for i in range(m):
		s,d,name = raw_input().split()
		for r,p in R[::-1]:
			if r.search(s+d):
				if p: ans.append([s,d,name])
				break
	print len(ans)
	for s,d,name in ans:
		print s,d,name

Measured memory_bytes: 5264
#include <iostream>
#include <utility>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;

int main(){
    string S;
    cin >> S;

    if(S[1]=='B') cout << "ARC" << endl;
    else cout << "ABC" << endl;

    return 0;
}


Measured memory_bytes: 3624
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n;
string a,b,c;
int main()
{
    scanf("%d",&n);
    cin>>a;cin>>b;cin>>c;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]==b[i]&&b[i]==c[i]) continue;
        else if(a[i]==b[i]||a[i]==c[i]||b[i]==c[i]) ans++;
        else ans+=2;
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Solver_agc007d solver = new Solver_agc007d();
		solver.input();
		solver.solve();
	}
}

class FastScanner {
	BufferedReader br;
	StringTokenizer st;
	public FastScanner(Reader in) {
		br = new BufferedReader(in);
	}

	String next() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
				throw new RuntimeException("Can't read more inputs.");
			}
		}
		return st.nextToken();
	}
	int nextInt() {
		return Integer.parseInt(next());
	}
	long nextLong() {
		return Long.parseLong(next());
	}
	double nextDouble() {
		return Double.parseDouble(next());
	}
	String readNextLine() {
		String str = "";
		try {
			str = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return str;
	}
}
class Solver_agc007d {
	static FastScanner in = new FastScanner(new InputStreamReader(System.in));
	static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	int n, e, T, a[];
	long f[];
	void input() {
		n = in.nextInt(); e = in.nextInt(); T = in.nextInt();
		a = new int[n + 1];
		f = new long[n + 1];
		for(int i = 1; i <= n; i++) a[i] = in.nextInt();
	}
	class DequeItem {
		DequeItem(int index_, long val_) {
			index = index_;
			val = val_;
		}
		int index;
		long val;
	}
	void solve() {
		int j_ = 1;
		long min_j_ = Long.MAX_VALUE >> 1;
		Deque<DequeItem> deque = new LinkedList<>();
		deque.offer(new DequeItem(1, f[0]));
		for(int i = 1; i <= n; i++) {
			while(2 * (a[i] - a[j_]) > T) {
				j_++;
				min_j_ = Math.min(min_j_, f[j_ - 2] - 2 * a[j_ - 1]);
			}
			f[i] = min_j_ + 2 * a[i];
			while(deque.getLast().val > f[i - 1]) deque.removeLast();
			deque.offer(new DequeItem(i, f[i - 1]));
			while(deque.getFirst().index < j_) deque.removeFirst();
			f[i] = Math.min(f[i], deque.getFirst().val + T);
		}
		out.println(f[n] + e);
		out.close();
	}
}


Measured memory_bytes: 45660
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main(){

	int n, a, b, c, d, flag=0;
	string s;
	vector<int> v, g, f;

	cin>> n >> a >> b >> c >> d;
	cin>> s;

	v.resize(n+1);
	//h.resize(n+1);
	g.resize(n+1);
	f.resize(n+1);
	v[0]=0;
	for(int i=0;i<=n;i++){
		//h[i]=0;
		g[i]=0;
		f[i]=0;
	}

	for(int i=1;i<=n;i++){
		if(s[i-1]=='#'){
			v[i]=1;
			if(v[i-1]==1) f[i-1]=1;
			/*if(2<=i){
				if(v[i-2]==1) h[i-1]=1;
			}*/
		}else{
			v[i]=0;
			if(2<=i){
				if(v[i-1]==0 && v[i-2]==0) g[i-2]=1;
			}
		}
	}

	//for(int i=0;i<v.size();i++) cout<< v[i] <<endl;

	for(int i=a-1;i<max(c, d);i++){
		if(f[i]==1){
			cout<< "No" <<endl;
			return 0;
		}
	}

	if(d<c){
		if(v[d-1]==0 && v[d+1]==0){
			flag=1;
			//cout<< "0d0" << endl;
		}

		for(int i=b-1;i<=d-2;i++){
			if(g[i]==1){
				flag=1;
				//cout<< "g" << endl;
			}
		}

		if(flag==0){
			cout<< "No" <<endl;
			return 0;
		}

	}

	cout<< "Yes" <<endl;


}

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

using namespace std;

int memo[200005];

int main(void)
{
	int n;
	cin >> n;
	int nums = 0;
	for (int i = 1; i <= n; ++i)
	{
		cin >> memo[i];
	}
	for (int i = n / 2; i >= 1; --i)
	{
		//cout << "hoge" << endl;
		int sum = 0;
		for (int j = i * 2; j <= n; j += i)
		{
			//cout << j << endl;
			sum += memo[j];
		}
		//cout << sum << endl;
		if (sum % 2 == 1 && memo[i] == 0)
		{
			memo[i] = 1;
		}
		else if (sum % 2 == 1 && memo[i] == 1)
		{
			memo[i] = 0;
		}
	}
	for (int i = 1; i <= n; ++i)
	{
		if (memo[i] == 1)
		{
			nums++;
		}
	}
	cout << nums << endl;
	for (int i = 1; i <= n; ++i)
	{
		if (memo[i] == 1)
		{
			cout << i << " ";
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


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

  vector<long long> A(N);
  long long a = 0;
  for(int i = 0;i < N;i++) {
    cin >> A[i];
    a = a^A[i];
  }

  for(int i = 0;i < N;i++) {
    long long c = a^A[i];
    cout << c << " ";
  }

  cout << endl;
  

}


Measured memory_bytes: 4844
N,Y = map(int,input().split())
for i in range(N+1):
    for j in range(N+1-i):
        x = i
        y = j
        z = N - i - j
        s = 10000*x + 5000*y + 1000*z
        if s == Y:
            break
    if s == Y:
        break
    else:
        x = -1
        y = -1
        z = -1
print(x,y,z)


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

int main () {
  int N;
  cin >> N;
  
  bool diff = true;
  
  vector<int> A(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  sort(A.begin(), A.end());
  
  for (int i = 0; i < N-1; i++) {
    if (A.at(i) == A.at(i+1)) {
      diff = false;
      break;
    }
  }
  
  if (diff) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}

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

using namespace std;

int main(){
  
  int a, b;

  cin >> a >> b;

  if(a >= b){
    while(a--){
      cout << b;
    }
  }
  else{
    while(b--){
      cout << a;
    }
  }

  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long;
const ll mod=1000000007;
ll add(ll x, ll y){
    return (x+y)%mod;
}
ll mul(ll x, ll y){
    return (x*y)%mod;
}
ll at(vector<ll>& C, ll i){
    if(C.size()<=i){return 0;}
    else return C[i];
}
int main(){
    long long N;
    cin>>N;
    vector<ll> C(N);
    for(auto& c: C)cin>>c;
    vector<ll> color(200001);
    ll current=1;
    for(ll i=0;i<N;i++){
        //update color
        if(at(C,i+1)!=C[i])
            color[C[i]]=current;
        else
            color[C[i]]=0;
        //calc next
        if(i!=N-1){
            current = add(current,color[C[i+1]]);
        }
    }
    cout<<current<<endl;
}

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

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int a = Integer.parseInt(chr[0]);
			int b = Integer.parseInt(chr[1]);
			 System.out.println(Math.max(a+b, Math.max(a-b, a*b)));
		}
	}
}

Measured memory_bytes: 25372
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long mod = 1000000007ll;
  int N, M; cin >> N >> M;
  vector<long long> stairs(100010, -1ll);
  
  if(N == 1){
    cout << 1 << endl;
    return 0;
  }
  
  stairs.at(0) = 1ll;
  stairs.at(1) = 2ll;
  
  for(int i = 0; i < M; ++i){
    int x; cin >> x;
    stairs.at(x-1) = 0ll;
  }
  
  if(stairs.at(0) == 0ll && stairs.at(1) != 0ll) stairs.at(1) = 1ll;
  
  if(N == 2){
    cout << stairs.at(1) << endl;
    return 0;
  }
  
  for(int i = 1; i < N-1; ++i){
    if(stairs.at(i+1) != 0ll){
      stairs.at(i+1) = (stairs.at(i-1) + stairs.at(i)) % mod;
    }
  }
  
  cout << stairs.at(N-1) << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;
#define N 100005
int vis[N],n;
vector<int>g[N];
int main()
{
	int i, x, y, index, cnt=0, now;
	pair<int,int> cur;
	scanf("%d",&n);
	for(i=0;i<n-1;++i)
	{
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	queue<pair<int,int> >qu1;
	queue<pair<int,int> >qun;
	qu1.push(make_pair(1,0)); vis[1]=1;
	qun.push(make_pair(n,0)); vis[n]=2;

	while(!qu1.empty()||!qun.empty())
	{
		if(!qu1.empty()){
			cur=qu1.front();
			index=cur.second;
			while(cur.second==index){
				for(i=0;i<g[cur.first].size();++i)
				{
					now=g[cur.first][i];
					if(vis[now]) continue;
					vis[now]=1;
					qu1.push(make_pair(now,index+1));
				}
				qu1.pop();
				if(qu1.empty()) break;
				cur=qu1.front();
			}
		}
		
		if(!qun.empty()){
			cur=qun.front();
			index=cur.second;
			while(cur.second==index){
				for(i=0;i<g[cur.first].size();++i)
				{
					now=g[cur.first][i];
					if(vis[now]) continue;
					vis[now]=2;
					qun.push(make_pair(now,index+1));
				}
				qun.pop();
				if(qun.empty()) break;
				cur=qun.front();
			}
		}
	}
	
	for(i=2;i<n;++i)
	{
		if(vis[i]==1) 
			cnt++;
		else 
			cnt--;
	}

	if(cnt>0)
	cout<<"Fennec";
	else
	cout<<"Snuke";
	
	return 0;
}

Measured memory_bytes: 6400
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
string f(vector<pair<string,int> >A)
{
	if(A.size()==1)
	{
		string ret="";
		for(int i=0;i<A[0].second;i++)ret+=A[0].first;
		return ret;
	}
	sort(A.begin(),A.end());
	int sum=0;
	for(pair<string,int>p:A)
	{
		sum+=p.second;
	}
	vector<string>ret;
	if(A[0].second*2<=sum)
	{
		for(int i=0;i<A[0].second;i++)ret.push_back(A[0].first);
		int cnt=A[0].second;
		A[0].second=0;
		int id=A.size()-1;
		while(0<id)
		{
			for(int i=0;i<cnt;i++)
			{
				while(0<id&&A[id].second==0)id--;
				if(id==0)break;
				else
				{
					A[id].second--;
					ret[i]+=A[id].first;
				}
			}
			sort(ret.begin(),ret.end());
			int ncnt=0;
			for(int i=0;i<cnt;i++)if(ret[0]==ret[i])ncnt++;
			cnt=ncnt;
		}
	}
	else
	{
		int cnt=sum-A[0].second;
		for(int i=0;i<cnt;i++)
		{
			ret.push_back("");
			for(int j=0;j<A[0].second/cnt+(i<A[0].second%cnt);j++)
			{
				ret.back()+=A[0].first;
			}
		}
		int id=A.size()-1;
		for(string&s:ret)
		{
			while(A[id].second==0)id--;
			A[id].second--;
			s+=A[id].first;
		}
	}
	sort(ret.begin(),ret.end());
	vector<pair<string,int> >nxt;
	nxt.push_back(make_pair(ret[0],1));
	for(int i=1;i<ret.size();i++)
	{
		if(nxt.back().first==ret[i])nxt.back().second+=1;
		else nxt.push_back(make_pair(ret[i],1));
	}
	return f(nxt);
}
main()
{
	int X,Y,Z;
	cin>>X>>Y>>Z;
	vector<pair<string,int> >A;
	if(X>0)A.push_back(make_pair("a",X));
	if(Y>0)A.push_back(make_pair("b",Y));
	if(Z>0)A.push_back(make_pair("c",Z));
	cout<<f(A)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int A, B, X;
long double EPS = 1e-8;

long double SIN(long double ang) {
	return sin(ang * 3.14159265358979338327L / 180.0L);
}

long double COS(long double ang) {
	return cos(ang * 3.14159265358979338327L / 180.0L);
}

long double TAN(long double ang) {
	return tan(ang * 3.14159265358979338327L / 180.0L);
}

long double solve(long double ang) {
	long double V1 = 1.0L * B * TAN(max(EPS, min(90.0L - EPS, ang)));
	if (V1 <= 1.0L * A) {
		return 0.5L * V1 * A * B;
	}

	long double V2 = 1.0L * A * TAN(max(EPS, min(90.0L - EPS, 90.0L - ang)));
	return 0.5L * (2.0L * B - V2) * A * A;
}

int main() {
	cin >> A >> B >> X;

	long double cl = 0.0, cr = 90.0, cm;
	for (int i = 0; i < 60; i++) {
		cm = (cl + cr) / 2.0;
		long double I = solve(cm);
		if (I < 1.0L * X) cl = cm;
		else cr = cm;
	}
	printf("%.12Lf\n", 90.0L - cm);
	return 0;
}

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

int main(void) {
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int cnt = 0;
    while (a >= b) {
        b *= 2;
        cnt++;
    }
    while (b >= c) {
        c *= 2;
        cnt++;
    }
    cout << ((cnt <= k) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	string s;
	cin>>s;
	int n = s.size();
	int ans = 0;
	int g = 0;
	int p = 0;
	rep(i,s.size()){
		if(s[i]=='g') g++;
		else p++;
	}
	while(g-p>1){
		g--;
		p++;
		ans++;
	}
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  Int r,s,p;
  cin>>r>>s>>p;
  string t;
  cin>>t;

  Int ans=0;
  for(Int i=0;i<k;i++){
    Int dp[3]={};
    for(Int j=i;j<n;j+=k){
      Int cs[3]={};
      if(t[j]=='s') cs[0]=r;
      if(t[j]=='p') cs[1]=s;
      if(t[j]=='r') cs[2]=p;

      Int nx[3]={};
      for(Int a=0;a<3;a++)
        for(Int b=0;b<3;b++)
          if(a!=b) chmax(nx[a],dp[b]+cs[a]);

      for(Int a=0;a<3;a++) dp[a]=nx[a];
    }
    ans+=*max_element(dp,dp+3);
  }

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


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  char c;
  cin >> c;
  if (strchr("aeiou", c)) {
    cout << "vowel\n";
  } else {
    cout << "consonant\n";
  }
  return 0;
}


Measured memory_bytes: 256