akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int modpow(int a,int b,int m) {
    if(b==0) return 1;
    if(b%2==0) {
        llint t = modpow(a,b/2,m);
        return t*t% m;
    }   
    return a*modpow(a,b-1,m)%m;
}

int popcount(int n) {
    int ans = 0;
    while(n!=0) {
        if(n%2==1) ans++;
        n /= 2;
    }
    return ans;
}

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

    string x;
    cin >> x;

    int pcx = 0;
    for(int in=0;in<n;in++) {
        if(x[in]=='1') pcx++;
    }

    if(pcx==1) {
        if(x[n-1]!='1') {
            for(int in=0;in<n;in++) {
                if(in==n-1) cout << 2 << endl;
                else if(x[in]!='1') cout << 1 << endl;
                else cout << 0 << endl;
            }
        }
        else {
            for(int in=0;in<n;in++) {
                if(in==n-1) cout << 0 << endl;
                else cout << 2 << endl;
            }
        }
        return 0;
    }

    int ansp1 = 0, tmpp1;
    for(int in=0;in<n;in++) {
        tmpp1 = 0;
        if(x[in]=='1') {
            tmpp1 = modpow(2,x.size()-in-1,pcx+1) - 1;
        }
        ansp1 += tmpp1;
        if(ansp1<0) ansp1 += pcx + 1;
        ansp1 %= pcx+1;
    }

    int ansm1 = 0, tmpm1;
    for(int in=0;in<n;in++) {
        tmpm1 = 0;
        if(x[in]=='1') {
            tmpm1 = modpow(2,x.size()-in-1,pcx-1) - 1;
        }
        ansm1 += tmpm1;
        if(ansm1<0) ansm1 += pcx - 1;
        ansm1 %= pcx-1;
    }

    int nowx, ans;
    for(int in=0;in<n;in++) {
        ans = 1;
        if(x[in]=='0') {
            nowx = ansp1;
            nowx += modpow(2,x.size()-in-1,pcx+1) - 1;
            if(nowx<0) nowx += pcx + 1;
            nowx %= pcx+1;
        }
        else {
            nowx = ansm1;
            nowx -= modpow(2,x.size()-in-1,pcx-1) - 1;
            if(nowx<0) nowx += pcx - 1;
            nowx %= pcx-1;
        }
        // cout << nowx << endl;
        int div;
        while(nowx!=0) {
            div = popcount(nowx);
            nowx %= div;
            ans++;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3764
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
//#define ll long long
#define ull  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 340000;
int mod = 1e9 + 7;
int a[N], f[N], invf[N], b[N], d[N];
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
int c(int n, int k){
    return f[n] * invf[k] % mod * invf[n - k] % mod;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    f[0] = 1;
    invf[0] = 1;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % mod;
    for (int i = 1; i <= n; i++) invf[i] = binpow(f[i], mod - 2);
    d[1] = 1;
    for (int i = 2; i <= n; i++) d[i] = (d[i - 1] * i + f[i - 1]) % mod;
    int ans = 0;
    for (int i = 1; i < n; i++){
        b[i] = a[i + 1] - a[i];
    }
    for (int i = 1; i < n; i++){
        ans = (ans + c(n - 1, i) * d[i] % mod * b[i] % mod * f[n - i - 1] % mod) % mod;
    }
    cout << ans;
}


Measured memory_bytes: 11264
a, b = map(int, input().split())
if a == b:
  print(a)
else:
  if a % 2 == 0:
    fa = a//2%2
  else:
    fa = (a-1)^(a//2%2)
  if (b+1) % 2 == 0:
    fb = (b+1)//2%2
  else:
    fb = b^((b+1)//2%2)
  print(fa^fb)

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine()); // 整数の個数
		int minNum = Integer.parseInt(br.readLine()); // 最小値
		int maxNum = -1000000000; // 差額の最大値
		for (int i = 1; i < n; i++) {
			int r = Integer.parseInt(br.readLine());
			maxNum = Math.max(maxNum, r - minNum);
			minNum = Math.min(minNum, r);
		}
		System.out.println(maxNum);

	}

}


Measured memory_bytes: 42700
#include <algorithm>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define int long long
#define double long double
#define INF INT_MAX
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int q, d, a, b, cnt, s1, s2;
multiset<int> st1, st2;
signed main() {
	cin >> q;
	rep(i, q) {
		cin >> d;
		if (d == 1) {
			cin >> a >> b;
			cnt += b;
			if (st1.empty()) {
				st1.insert(a);
				s1 += a;
				st2.insert(a);
				s2 += a;
			}
			else if (*st1.rbegin() <= a && a <= *st2.begin()) {
				st1.insert(a);
				s1 += a;
				st2.insert(a);
				s2 += a;
			}
			else if (a < *st1.rbegin()) {
				st1.insert(a);
				s1 += a;
				st1.insert(a);
				s1 += a;
				st2.insert(*st1.rbegin());
				s2 += *st1.rbegin();
				s1 -= *st1.rbegin();
				auto ite = st1.end();
				ite--;
				st1.erase(ite);
			}
			else {
				st2.insert(a);
				s2 += a;
				st2.insert(a);
				s2 += a;
				st1.insert(*st2.begin());
				s1 += *st2.begin();
				s2 -= *st2.begin();
				st2.erase(st2.begin());
			}
		}
		else cout << *st1.rbegin() << " " << cnt + (s2 - s1) / 2 << endl;
	}
}

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

struct ans{
    string name;
    double eff;

    bool operator<(const ans &another) const{
        if(eff!=another.eff){
            return eff>another.eff;
        }else{
            return name<another.name;
        }
    };
};

int main(){

    while(1){
        int n;
        cin >> n;
        if(n==0)break;
        vector<ans> a(n);
        for(int i=0;i<n;i++){
            cin >> a[i].name;
            double p;
            vector<double> ae(5); 
            int f,m,s;
            cin >> p;
            double tt=0;
            for(int i=0;i<5;i++){
                cin >> ae[i];
                tt+=ae[i];
            }
            cin >> f >> s >> m;
            int cnt=m*f;
            double st=cnt*s-p;
            tt+=(ae[3]+ae[4])*(m-1);
            a[i].eff=(double)st/tt;
        }
        sort(a.begin(),a.end());
        for(int i=0;i<n;i++){
            cout << a[i].name <<  endl;
        }
        cout << "#" << endl;
    }

    return 0;
}


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

int main(){
  int D,N;
  cin >> D >> N;
  if(N != 100){
    cout << pow(100, D) * N << endl;
  }else if(D == 0){
    cout << pow(100, D) * N + 1 << endl;
  }else if(D==1){
    cout << pow(100, D) * N + 100 << endl;
  }else if(D==2){
    cout << int(pow(100, D) * N + 10000) << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
const int maxn = int(1e5) + 7;
using namespace std;
ll inf=1e9+7;
ll a[900009];
ll sum[20];
int main()
{
    ll h,w,n;
    scanf("%lld%lld%lld",&h,&w,&n);
    ll x,y;
    int k=0;
    ll zo=(h-2)*(w-2);
    for(ll i=1;i<=n;i++)
    {
        //cin>>x>>y;
        scanf("%lld%lld",&x,&y);
        for(ll i=0;i<=2;i++)
        for(ll j=0;j<=2;j++)
        {
            if(x-i>=1&&x-i<=h-2&&y-j>=1&&y-j<=w-2)
            {

                a[k++]=inf*(x-i)+(y-j);
            }
        }
    }
    sort(a,a+k);
    ll t=1;
    for(int i=0;i<k;i++)
    {
        if(a[i]==a[i+1])t++;
        else
        {
            sum[t]++;t=1;zo--;
        }
    }
    cout<<zo<<endl;
    for(int i=1;i<=9;i++)
    {
        cout<<sum[i]<<endl;
    }
}


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

int main() {   
  ll x, a, b;
  cin >> x >> a >> b;
  
  if(b <= a) {
  	cout << "delicious" << endl;
  }
  else if(b - a <= x) {
  	cout << "safe" << endl;
  }
  else {
  	cout << "dangerous" << endl;
  }
  
}

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

b=len(a)
Z=a[-1]
X=0
for i in range(1,n-1):
  if abs((Z/2)-a[X])>abs((Z/2)-a[i]):
    X=i



print(a[-1],a[X])


Measured memory_bytes: 14428
/*
  I_🧡🧡🧡_QMsh
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using namespace __gnu_pbds; // gp_hash_table<int, int> table;

template <typename T> void smin(T &a, const T &b) { a = (a < b ? a : b); }
template <typename T> void smax(T &a, const T &b) { a = (a > b ? a : b); }

typedef long long ll;
typedef long double ld;

const int MAXN = 1e6 + 30;
const ll MOD = 998244353;

signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

  vector <vector <int>> divs(MAXN);
  for (int i = 1; i < MAXN; i++)
    for (int j = i; j < MAXN; j += i)
      divs[j].push_back(i);

  int n;
  cin >> n;
  vector <int> a(n);
  vector <__int128> sum(MAXN);
  vector <__int128> sqr(MAXN);

  for (int &i : a)
  {
    cin >> i;
    for (int d : divs[i])
    {
      sum[d] += i;
      sqr[d] += (ll)i * i;
    }
  }

  for (__int128 &i : sum)
    i *= i;

  ll ans = 0;
  for (int i = MAXN - 1; i >= 1; i--)
  {
    __int128 val = (sum[i] - sqr[i]) / (2 * i);
    ans = (ans + val) % MOD;
    for (int d : divs[i])
    {
      sum[d] -= sum[i];
      sqr[d] -= sqr[i];
    }
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 148352
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

int main(){
	int n = ci(), ans = 0;
	rep(i,1,n) if( (ci()&1) && (i&1) ) ans++;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1564
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define forn(i,n) for(int i=0;i<n;i++)
#define free(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%lld", &n)
#define sff(a,b) scanf("%lld %lld", &a, &b)
#define sfff(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define pfn(n) printf("%lld\n", n)
#define pfs(n) printf("%lld ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define f find
#define ub upper_bound
#define lb lower_bound
#define ld long double
#define in insert
#define bs binary_search
#define le length()
const ll max_i=1e9+7;
#define np(s) next_permutation(s.begin(),s.end())
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
//it gives the lexicographically smallest string//


void solve()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  string s;
  cin>>s;
  if(s[0]=='R' &&s[1]=='R' &&s[2]=='R') cout<<3;
  else if(s[0]=='R' &&s[1]=='R' || s[1]=='R' &&s[2]=='R') cout<<2;
  else if(s[0]=='R' || s[1]=='R' || s[2]=='R' ) cout<<1;
  else cout<<0;
}
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input1.txt", "r",stdin);
  freopen("output1.txt","w",stdout);
  #endif
  solve();
  return 0;
}

Measured memory_bytes: 3632
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<LL,LL> P;
int read()
{
    int x=0,flag=1; char c=getchar();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

const int maxn=2e5+5;
char s[maxn];
int l,r;

int main()
{
    int n=read();
    scanf("%s",s+1);
    l=1,r=n;
    int ans=0;
    while(l<=r)
    {
        while(l<=n && s[l]=='R') l++;
        while(r>=1 && s[r]=='W') r--;
        if(l<r) swap(s[l],s[r]),ans++;
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std ;
int main() {
  string x;
  cin >> x;
  
  int a = 0;
  int b = 0;
  
  for(int i=0; i<x.size(); i++) {
    if(x.at(i) == 'A') {
    break;
    }
    a++;
  }
  string str;
  for(int i=1; i < x.size(); i++) {
    str += x.at(x.size() - i);
  }
  
   for(int i=0; i<x.size(); i++) {     
    if(str.at(i) == 'Z') {
    break;
    }
    b++;
  }
  cout << x.size() - a - b << endl; 
}

Measured memory_bytes: 776
#include <stdio.h>

int main()
{
    long long int x, h_1000, h_5, rem;
    scanf("%lld", &x);
    h_1000=x/500;
    h_1000*=1000;
    rem=x%500;
    h_5=rem/5;
    h_5*=5;
    printf("%lld\n", h_1000+h_5);
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
#define INFTY 1000000000000000LL

using namespace std;
using ll = long long;

typedef struct Edge{
    int from;
    int to;
    ll cost;
} Edge;

//負経路を含むコストの最大化 <-> 各辺のコストを反転させて得られるコストの最小化
//ベルマンフォード法による最短経路計算

void solve();

int main(void){
    int N, M;
    cin >> N >> M;
    ll nodes[N];
    rep(i, N) nodes[i] = INFTY;
    Edge edges[M];
    rep(i, M){
        int a, b; ll c;
        cin >> a >> b >> c;
        edges[i].from = a-1;
        edges[i].to = b-1;
        edges[i].cost = -c; 
    }
    nodes[0] = 0LL;

    rep(i, N-1){
        rep(j, M){
            ll aim = nodes[edges[j].to];
            if(nodes[edges[j].from] + edges[j].cost < aim){
                nodes[edges[j].to] = nodes[edges[j].from] + edges[j].cost;
            }
        }
    }

    //ここまでで最短は求まっているはず さらに回したときに更新されたら負閉路がある
    bool negative[N] = {false};
    rep(i, N){
        rep(j, M){
            ll aim = nodes[edges[j].to];
            if(nodes[edges[j].from] + edges[j].cost < aim){
                negative[edges[j].to] = true;
                nodes[edges[j].to] = nodes[edges[j].from] + edges[j].cost;
            }
        }
    }

    if(negative[N-1] == true) cout << "inf" << endl;
    else cout << -nodes[N-1] << endl;

    return 0;
}

void solve(){}

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

int N,M;
int mp[2010][2010],ar[5][2010][2010];
string S[2010];

void dfs(int x,int y,int c){
	if(x<1||y<1||x>N||y>M)return;
	if(mp[x][y])return;
	if(S[x][y]!='1')return;
	
	mp[x][y]=c;
	
	dfs(x+1,y,3);
	dfs(x-1,y,4);
	dfs(x,y+1,1);
	dfs(x,y-1,2);
}

int main(){
	int Q,a=1;
	cin>>N>>M>>Q;
	string K;
	for(int i=1;i<=N;i++){
		cin>>K;
		S[i]="0"+K;
	}
	for(int i=1;i<=N;i++){
		for(int j=1;j<=M;j++){
			dfs(i,j,5);
		}
	}
	for(int i=0;i<=N;i++){
		for(int j=0;j<=M;j++){
			if(mp[i][j]<1)continue;
			ar[mp[i][j]-1][i][j]++;
		}
	}
	for(int k=0;k<2;k++)
		for(int i=1;i<=N;i++)
			for(int j=1;j<=M;j++)
				ar[k][i+1][j]+=ar[k][i][j];
	
	for(int k=2;k<4;k++)
		for(int i=1;i<=N;i++)
			for(int j=1;j<=M;j++)
				ar[k][i][j+1]+=ar[k][i][j];
	
	for(int i=1;i<=N;i++)
		for(int j=1;j<=M;j++)
			ar[4][i][j+1]+=ar[4][i][j];
	for(int i=1;i<=N;i++)
		for(int j=1;j<=M;j++)
			ar[4][i+1][j]+=ar[4][i][j];
	
	int x1,y1,x2,y2,ans=0;
	queue<int> ANS;
	for(int i=0;i<Q;i++){
		cin>>x1>>y1>>x2>>y2;
		ans=0;
		ans+=ar[4][x2][y2]-ar[4][x1-1][y2]-ar[4][x2][y1-1]+ar[4][x1-1][y1-1];
		//cout<<ans<<endl;
		ans+=ar[2][x1][y2]-ar[2][x1][y1-1];
		ans+=ar[3][x2][y2]-ar[3][x2][y1-1];
		ans+=ar[0][x2][y1]-ar[0][x1-1][y1];
		ans+=ar[1][x2][y2]-ar[1][x1-1][y2];
		//cout<<ans<<endl;
		ANS.push(ans);
	}
	
	
	while(!ANS.empty()){
		cout<<ANS.front()<<endl;
		ANS.pop();
	}
}


Measured memory_bytes: 102272
/**
 * Title: C - Unification
 * URL: https://atcoder.jp/contests/abc120/tasks/abc120_c
 * 
 * ＜解法＞
 * 計算量: {O(10^10)}
 * ポイント
 **/
#include<iostream>
#include<string.h>

using namespace std;

int main() {
    string S;
    cin >> S;
    int c0=0, c1=0;
    for(auto s:S) {
        if(s=='0') {
            c0++;
        } else {
            c1++;
        }
    }
    cout << 2*min(c0, c1) << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
string s;
cin>>s;
bool flag1=true,flag2=true;
for(int i=0;i<=a+b;i++){
if(i==a){
if(s[i]!='-'){
	flag2=false;
}else continue;	
}
else{
if(s[i]<48 or s[i]>57){
		flag1=false;
	}
}
}
if(!flag1 or !flag2){
	cout<<"No"<<endl;
}else{
	cout<<"Yes"<<endl;
}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long x = scan.nextLong();
		long[] a = new long[n];
		long b = 0;
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextLong();
		}
		for (int i = 1; i < n; i++) {
			if (a[i-1]+a[i] > x) {
				long c = ((a[i-1]+a[i])-x);
				b += c;
				if (((a[i-1]+a[i])-x) < a[i]) {
					a[i] -= c;
				} else {
					a[i] = 0;
				}
			}
		}
		System.out.println(b);
	}
}


Measured memory_bytes: 57504
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N,K; cin >> N >> K;
	cout << N-K+1 << endl;
}


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

int main()
{
    i64 n;
    cin >> n;
    vector<i64> a(n);
    for (i64 i = 0; i < n; i++)
        cin >> a[i];
    vector<i64> suml(n), sumr(n);
    suml[0] = a[0];
    for (i64 i = 1; i < n; i++)
        suml[i] = __gcd(suml[i - 1], a[i]);
    sumr[n - 1] = a[n - 1];
    for (i64 i = n - 2; 0 <= i; i--)
        sumr[i] = __gcd(sumr[i + 1], a[i]);
    i64 ans = max(suml[n - 2], sumr[1]);
    for (i64 i = 1; i < n - 1; i++)
        ans = max(ans, __gcd(suml[i-1], sumr[i + 1]));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
w,h,n = map(int,input().split())
x_min,x_max,y_min,y_max = 0,w,0,h
for i in range(n):
    x,y,a = map(int,input().split())
    if a==1:
        x_min = min(max(x_min,x),w)
    elif a==2:
        x_max = max(min(x_max,x),0)
    elif a==3:
        y_min = min(max(y_min,y),h)
    else:
        y_max = max(min(y_max,y),0)
print(max(0,x_max-x_min)*max(0,y_max-y_min))

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

using namespace std;

bool exists(int x, int n, string s) {
    if (x * 2 > n) return false;

    unordered_map <string, vector <int> > ssm;
    string ss;

    for (int i = 0; i < n - x + 1; i++) {
        ss = s.substr(i, x);
        if (ssm.find(ss) == ssm.end()) {
            ssm[ss] = vector <int> {};
        }
        ssm[ss].push_back(i);
    }
    vector <int> si;
    for (auto itr = ssm.begin(); itr != ssm.end(); itr++) {
        si = itr->second;
        if (si.back() - si.front() >= x) return true;
    }

    return false;
}

int main(void) {
    int n, mi, md, ma;
    string s;
    cin >> n;
    cin >> s;

    mi = 0;  // Exist
    ma = 2501;  // Not exist
    for (int i = 0; i < 100; i++) {
        md = mi + (ma - mi) / 2;
        if (exists(md, n, s)) {
            mi = md;
        } else {
            ma = md;
        }
        if (ma - mi <= 1) break;
    }
    cout << mi << endl;

    return 0;
}


Measured memory_bytes: 6756
from fractions import gcd  # python<=3.4

MOD=1000000007

def ADD(x, y):
  return (x + y) % MOD

def SUB(x, y):
  return (x - y + MOD) % MOD

def MUL(x, y):
  return x * y % MOD

def POW(x, e):
  v = 1
  while e:
    if e & 1:
      v = MUL(v, x)
    x = MUL(x, x)
    e >>= 1
  return v

def INV(x):
  return POW(x, MOD-2)

def DIV(x, y):
  return MUL(x, INV(y))


n = int(input().rstrip())
a = [int(x) for x in input().rstrip().split()]

el = 1
for ai in a:
  g = gcd(el,ai)
  el = el // g * ai

el %= MOD

sum = 0
for ai in a:
  sum += DIV(el, ai)

sum %= MOD
print(sum)


Measured memory_bytes: 69080
n=int(input())

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])

    return arr

def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

k=make_divisors(n)
c=0
for i in range(len(k)):
    if i==0:pass
    else:
        l1=factorization(k[i])
        seigo=is_prime(l1[0][0])
        if len(l1)==1 and seigo==True and n%k[i]==0:
            n//=k[i]
            c+=1
        
print(c)

Measured memory_bytes: 9588
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        System.out.println(solve(A, B, C, D) ? YES : NO);
    }

    private static boolean solve(int A, int B, int C, int D) {
        while (true) {
            C -= B;
            if (C <= 0) return true;

            A -= D;
            if (A <= 0) return false;
        }
    }
}

Measured memory_bytes: 35896
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>

using namespace std;

int main()
{
    int n;
    long long a[200000];
    long long b[200000] = {0};//1からnに入る。0からではない//
    
    cin >> n;
    for (int i = 0;i < n;i++){
        cin >> a[i];
        b[a[i]]++;
    }
    long long sum = 0;
    for (int i = 1;i <= n;i++){
        sum += (b[i]*(b[i]-1))/2;
    }
    
    for (int i = 0;i < n;i++){
        cout << sum-(b[a[i]]*(b[a[i]]-1))/2+((b[a[i]]-1)*(b[a[i]]-2))/2 << endl;;
    }
}


Measured memory_bytes: 5760
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

struct SegTree<T, F> {
    n: usize,
    node: Vec<T>,
    acc: F,
    init: T,
}

impl<T: Clone, F> SegTree<T, F> where F: Fn(&T, &T) -> T {
    pub fn new(n: usize, init: T, acc: F) -> SegTree<T, F> {
        let mut m = 1;
        while m < n {
            m *= 2;
        }
        SegTree {
            n: m,
            node: vec![init.clone(); m * 2],
            acc: acc,
            init: init,
        }
    }

    pub fn add(&mut self, pos: usize, val: T) {
        let mut x = pos + self.n - 1;
        self.node[x] = (self.acc)(&self.node[x], &val);
        while x > 0 {
            x = (x-1)/2;
            self.node[x] = (self.acc)(&self.node[x], &val);
        }
    }

    fn sum_inner(&self, pos: usize, x: usize, y: usize, p: usize, q: usize) -> T {
        if x<= p && q <= y {
            return self.node[pos].clone();
        }
        if y <= p || q <= x {
            return self.init.clone();
        }

        let left = pos * 2 + 1;
        let mid = (p + q) / 2;
        let right = pos * 2 + 2;
        (self.acc)(&self.sum_inner(left, x, y, p, mid), &self.sum_inner(right, x, y, mid, q))
    }

    pub fn sum(&self, x: usize, y: usize) -> T {
        self.sum_inner(0, x, y, 0, self.n)
    }
}

fn main() {
    let line: Vec<i64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = line[0] as usize;
    let c = line[1];
    let mut memo = SegTree::new(n, 0i64, |a,b| cmp::max(*a,*b));
    let mut memo2 = SegTree::new(n, 0i64, |a,b| cmp::max(*a,*b));
    let mut xs = Vec::with_capacity(n+2);
    let mut vs = Vec::with_capacity(n+2);
    for i in 0..n {
        let line: Vec<i64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
        let x = line[0];
        let v = line[1];
        xs.push(x);
        vs.push(v);
    }

    let mut sum = 0;
    for i in 0..n {
        sum += vs[i];
        memo.add(i, sum - xs[i]);
    }
    sum = 0;
    for i in (0..n).rev() {
        sum += vs[i];
        memo2.add(i, sum - (c- xs[i]));
    }

    let mut ans = cmp::max(memo.sum(0, n), memo2.sum(0, n));

    let mut sum = 0;
    for i in 0..n {
        sum += vs[i];
        let tmp = sum - xs[i] * 2 + memo2.sum(i + 1, n);
        ans = cmp::max(ans, tmp);
    }
    sum = 0;
    for i in (0..n).rev() {
        sum += vs[i];
        let tmp = sum - (c - xs[i]) * 2 + memo.sum(0, i);
        ans = cmp::max(ans, tmp);
    }
    println!("{}", ans);

}


Measured memory_bytes: 10492
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

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

int p2(int n) {
	int a = 1;
	while (n) {
		a *= 2;n--;
	}
	return a;
}

int main() {
	int N, K;
	cin >> N >> K;
	int mx = p2(N);
	int i = -1;
	if (N == 1) {
		if (K == 0)
			cout << "0 0 1 1" << endl;
		else
			cout << i << endl;
	}
	else if (K < p2(N)) {
		cout << K << " ";
		while(i < mx - 1) {
			i++;
			if (i == K) continue;
			cout << i << " ";
		}
		cout << K << " ";
		i++;
		while (i > 0) {
			i--;
			if (i == K) continue;
			cout << i << " ";
		}
	}
	else
		cout << i;
	cout << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>
#include <complex>

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
// BEGIN CUT HERE
#define foreach(itr,c) for(typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
// END CUT HERE
typedef complex<double> P;

double crossP(P a, P b){return a.real()*b.imag() - a.imag()*b.real();}

int main(){
  int i,j,k,n;
  double xa,ya,xb,yb,xc,yc,xd,yd;
  P ab,bc,cd,da;

  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd) != EOF){
    bool f = false;
    ab = P((xb-xa),(yb-ya));
    bc = P((xc-xb),(yc-yb));
    cd = P((xd-xc),(yd-yc));
    da = P((xa-xd),(ya-yd));

    if(crossP(ab,bc) > 0 && crossP(bc,cd) > 0 && crossP(cd,da) > 0 && crossP(da,ab) > 0) f = true;
    if(crossP(ab,bc) < 0 && crossP(bc,cd) < 0 && crossP(cd,da) < 0 && crossP(da,ab) < 0) f = true;

    if(f) printf("YES\n");
    else printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 0
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n = f.read_int()
    b = f.read_int_list()

    ans = b[0] + b[-1]

    for i in xrange(n-2):
        ans += min(b[i], b[i+1])

    return ans


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 5520
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

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

int main(){
  int h,a;
  cin >> h >> a;
  cout<< (h+a-1)/a <<endl;
}


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

typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


//===

const ll mod = static_cast<ll>(1e9 + 7);


int main() {
	int A, P;
	cin >> A >> P;
	cout << (A * 3 + P) / 2 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    cout << (n - 1) / 2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pii pair<int,int>
#define ll long long int
#define ull unsigned long long int
#define inf LONG_MAX
#define mod 100000007
using namespace std;
int dp[3001][3001];
string s,t;
string ans="";
void find_lcs(int i,int j)
{
    if(dp[i][j]==0)
        return;
    if(dp[i-1][j]==dp[i][j-1] && dp[i][j-1]==dp[i-1][j-1])
    {
        if(dp[i][j]>dp[i-1][j-1])
            ans+=t[j-1];
        find_lcs(i-1,j-1);
    }
    else if(dp[i-1][j]>dp[i][j-1])
        find_lcs(i-1,j);
    else
        find_lcs(i,j-1);
}
int main()
{
    fast_io
    cin>>s>>t;
    for(int i=1;i<=s.length();i++)
    {
        for(int j=1;j<=t.length();j++)
        {
            if(s[i-1]==t[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    find_lcs(s.length(),t.length());
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}


Measured memory_bytes: 38792
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  m:integer;
begin
  try
    { TODO -oUser -cConsole Main : abc84a}
    readln(m);
    Writeln(48-m);
    readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 128
#include <stdio.h>
int k,n,s,j,a,m=998244353,d[3001];int main(){scanf("%d%d",&n,&s);while(n--){scanf("%d",&a);for(j=s+1;j-->a;)d[j]=(d[j]+d[j-a])%m;d[a]++;d[0]++;k=(k+d[s])%m;}printf("%d",k);}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  ll N, K;
  cin >> N >> K;
  auto A = vector<ll>(2001);
  REP(i, N) cin >> A[i];
  // REP(i, 2000) { A[i] = 2000 - i; }

  auto left = vector<ll>(2001, 0);
  auto right = vector<ll>(2001, 0);
  REP(i, N) {
    REP(j, N) {
      if(A[j] > A[i] && j > i) {
        left[A[j]]++;
      } else if(A[j] > A[i] && i > j) {
        right[A[j]]++;
      }
    }
  }
  ll sum = 0;
  REP(i, 2001) {
    ll rs = 0;
    rs += (K + 1) * K / 2;
    rs %= MOD;
    rs *= right[i];
    rs %= MOD;

    ll ls = 0;
    ls += (K - 1) * K / 2;
    ls %= MOD;
    ls *= left[i];
    ls %= MOD;

    sum += rs;
    sum %= MOD;
    sum += ls;
    sum %= MOD;
  }

  std::cout << sum << endl;
}


Measured memory_bytes: 256
s = input()
index_a=-1
for i in range(len(s)):
    if s[i]=="A":
        index_a = i
        break
j=len(s)-1
index_z=-1
while j>0:
    if s[j]=="Z":
        index_z = j
        break
    j-=1
print(index_z-index_a+1)


Measured memory_bytes: 3516
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, M, Q, *abcd = map(int, read().split())
cand = [[0, 1]]

for _ in range(N - 1):
    new_cand = []
    for j in cand:
        for k in range(j[-1], M + 1):
            new_cand.append(j[:] + [k])
    cand = new_cand[:]

answer = 0
abcd = tuple(zip(*[iter(abcd)] * 4))
for seq in cand:
    t = 0
    for a, b, c, d in abcd:
        if seq[b] - seq[a] == c:
            t += d
    answer = max(answer, t)

print(answer)


Measured memory_bytes: 21164
'use strict';
function main(input) {
  let sum = 0;
  const arr = input.trim().split('\n');
  const a = arr[1].split(' ').map(x => Number(x)).map(x => sum += 1 / x);
  
  console.log(1/ sum);
}

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

Measured memory_bytes: 7372
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long[] A = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            int cnt = 0;
            while (true)
            {
                for (int j = 0; j < N; j++)
                {
                    if (A[j] % 2 == 0)
                    {
                        A[j] = A[j] / 2;
                    }
                    else
                    {
                        Console.WriteLine(cnt);
                        return;
                    }
                }
                cnt++;
            }
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


//Console.WriteLine(ans);


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

#define max_n 100002

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

vector<int> v[max_n];

// calc depth of each node from "original" p
void f(int p, int d, int z[]){
	if(z[p] != 0) return;
	z[p] = d;
	for(int q : v[p]) f(q, d+1, z);
}

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

	int n;
	cin >> n;

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

	int x[n+1] = {};
	f(1,1,x);

    int y[n+1] = {};
    f(n,1,y);

    int cnt = 0;
    FOR(i,1,n+1) x[i] <= y[i] ? cnt++ : cnt--;
    cout << (cnt > 0 ? "Fennec" : "Snuke") << endl;
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100005;
int n,m,ed,a[N],fir[N],vis[N],b[N],id[N],c[N],f[N];
ll sum[N],g[N];
struct E{int v,nxt;}e[N*2];  
void adde(int x,int y){
	e[++ed].v=y;e[ed].nxt=fir[x];fir[x]=ed;
}
bool cmp(int x,int y){
	return c[x]<c[y]; 
} 
int F(int x){return x==f[x]?x:f[x]=F(f[x]);}
int main(){
	//freopen("aa.in","r",stdin);
	int i,j;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i){
		scanf("%d%d",a+i,b+i);
		c[i]=max(a[i]-b[i],0);	
	}
	for(i=1;i<=m;++i){
		int x,y;scanf("%d%d",&x,&y);
		adde(x,y);adde(y,x);
	}
	for(i=1;i<=n;++i)f[i]=id[i]=i,g[i]=c[i],sum[i]=b[i];
	sort(id+1,id+1+n,cmp);
	for(i=1;i<=n;++i){
		int x=id[i];vis[x]=1;
		for(j=fir[x];j;j=e[j].nxt)if(vis[e[j].v]){
			int y=e[j].v;
			if(x==F(y))continue;
			//printf("%d %d\n",x,y);
			//printf("con %d %d ,f %d %d : %d %d\n",x,y,f[x],f[y],sum[f[x]],sum[f[y]]);
			g[x]=min(g[x],g[f[y]]+max(c[x]-g[f[y]]-sum[f[y]],0LL));
			//printf("g %lld\n",g[f[x]]);		
			sum[x]+=sum[f[y]];
			f[f[y]]=x;
		}
	} 
	//printf("fin sum %lld\n",sum[F(1)]); 
	ll ans=g[F(1)]+sum[F(1)];
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 6144
r, c = map(int, input().split())
a = [list(map(int, input().split())) for i in range(r)]
newr = []

for i in range(r):
    a[i].append(sum(a[i]))

for j in range(c + 1):
    sumc = 0
    for i in range(r):
        sumc += a[i][j]
    newr.append(sumc)
a.append(newr)

for i in range(r+1):
    print(" ".join(str(t) for t in a[i]))

Measured memory_bytes: 7712
#include<stdio.h>
int ta[200010],nt[400010],to[400010],cc[400010];
long long u[200010],ANS[200020],ans[200020];
int mbk(long long a,int n,int m){return n?(mbk((a*a)%m,n/2,m)*(n%2?a:1))%m:1;}
int inv(int a,int m){return mbk((long long)a,m-2,m);}
long long pp[200010],M=1e9+7;
void fc(int s,int t){ans[s]=ans[s]*ans[t]       %M;}
void ic(int s,int t){ans[s]=ans[s]*inv(ans[t],M)%M;}
void fp(int s){ans[s]=ans[s]*inv(cc[s],M)%M;}
void ip(int s){ans[s]=ans[s]*cc[s]       %M;}
void f(int s){//printf("!%d\n",s);
  long long i;
  u[s]=1;
  for(i=ta[s];i+1;i=nt[i]){
    if(u[to[i]])continue;
    f(to[i]);
    fc(s,to[i]);
    cc[s]+=cc[to[i]];
  }
  fp(s);
}

void h(int s,int t){
  ip(s);
  ic(s,t);
  ip(t);
  cc[s]-=cc[t];
  cc[t]+=cc[s];
  fp(s);
  fc(t,s);
  fp(t);
}
void g(int s){//printf("!!%d %d\n",s,cc[s]);
  int i;
  u[s]=2;
  ANS[s]=ans[s];
  for(i=ta[s];i+1;i=nt[i]){
    if(u[to[i]]==2)continue;
    //printf("%d %d %d %d %lld %lld\n",s,to[i],cc[s],cc[to[i]],ans[s],ans[to[i]]);
    h(s,to[i]);
    //printf("%d %d %d %d %lld %lld\n",s,to[i],cc[s],cc[to[i]],ans[s],ans[to[i]]);
    g(to[i]);
    h(to[i],s);
  }
}
int main(){
  int n,a,b,i;
  scanf("%d",&n);
  for(i=0;i<=n;i++)ta[i]=-1;
  pp[0]=1;
  for(i=1;i<=n;i++)pp[i]=(pp[i-1]*i)%M;
  //for(i=0;i<=n;i++)ip[i]=inv(i,M);
  for(i=1;i<=n;i++)ans[i]=cc[i]=1;
  for(i=0;i<n-1;i++){
    scanf("%d %d",&a,&b);
    nt[i    ]=ta[to[i+n-1]=a];
    nt[i+n-1]=ta[to[i    ]=b];
    ta[b]=i+n-1;
    ta[a]=i;
  }
  f(1);
  //for(i=0;i<=10;i++)printf("%lld\n",pp[i]);printf("\n");
  //for(i=0;i<=n;i++)printf("%d\n",cc[i]);
  //printf("%d\n",f(1));
  //for(i=0;i<=n;i++)printf("%d\n",cc[i]);
  //for(i=1;i<=n;i++)printf("%3d ",i);printf("\n");
  //for(i=1;i<=n;i++)printf("%3lld ",ans[i]);printf("\n");
  //for(i=1;i<=n;i++)printf("%3d ",cc[i]);printf("\n");
  g(1);
  for(i=1;i<=n;i++)printf("%lld\n",ANS[i]*pp[n]%M);
  return 0;
}


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

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

  int pattern = 0;

  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      if((((x - (i*500) - (j*100)) % 50) == 0)
         and (((x - (i*500) - (j*100)) / 50) >=0)
         and (((x - (i*500) - (j*100)) / 50) <=c)){
        pattern++;
      }
    }
  }
  cout << pattern << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
const int N=1e6+5,MAX=3e7,MOD=1e9+7;

using namespace std;

int n;
int a[N][5];

ll memo[N][5];
ll solve(int indx,int last){

	 if(indx == n)return 0;

	 ll &ret = memo[indx][last+1];

	 if(ret != -1LL)return ret;

	 for(int i=0;i<3;i++){

	 	  if(last == i )continue;
          
          ll c = a[indx][i] + solve(indx+1,i);
	 	  ret = max(ret ,  c );
	 }

	 return ret;
}
int main(){
   // #ifndef ONLINE_JUDGE
     //   freopen("test.txt","r",stdin);
    //#endif
    
    scanf("%d",&n);

     
    for(int i=0;i<n;i++)for(int j=0;j<3;j++)scanf("%d",&a[i][j]);
    
    memset(memo,-1,sizeof(memo));

    printf("%lld\n",solve(0,-1) );
     
}

Measured memory_bytes: 51072
X, Y = list(map(int, input().split(' ')))

money = 0
if X == 1:
    money += 300000
elif X == 2:
    money += 200000
elif X == 3:
    money += 100000
else:
    pass
if Y == 1:
    money += 300000
elif Y == 2:
    money += 200000
elif Y == 3:
    money += 100000
else:
    pass
if X == 1 and Y == 1:
    money += 400000
print(money)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e5+6;
const int mod = 1e9+107;
const ll inf = 1e16;
ll c[N];
ll a[22][22];
void solve(){
    int n,m,x;
    cin>>n>>m>>x;
    for(int i=0;i<n;i++){
        cin>>c[i];
        for(int j=0;j<m;j++)cin>>a[i][j];
    }
    ll ans = inf;
    for(int i=0;i<(1<<n);i++){
        ll trt = 0;
        ll cnt[22] = {};
        for(int j=0;j<n;j++){
            if(i&(1<<j)){
                trt+=c[j];
                for(int k=0;k<m;k++){
                    cnt[k]+=a[j][k];
                }
            }
        }
        int can = 1;
        for(int j=0;j<m;j++){
            if(cnt[j]<x)can = 0;
        }
        if(can)ans = min(ans,trt);
    }
    if(ans==inf)ans = -1;
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3652
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc =new Scanner(System.in);
        
        int N = sc.nextInt();
        String S = sc.next();
        int K = sc.nextInt();
        String str = S.substring(K-1,K);

        S = S.replaceAll(str, "_");
        S = S.replaceAll("[a-z]","*");
        S = S.replaceAll("_",str);
        
        System.out.println(S);
    }
}


Measured memory_bytes: 21844
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	ans := float64(0)
	var x, y int
	for i := 1; i <= n; i++ {
		x = i
		for j := 0; j <= 20; j++ {
			if x*(1<<uint(j)) >= k {
				y = j
				break
			}
		}
		ans += math.Pow(0.5, float64(y))
	}
	ans /= float64(n)
	fmt.Println(ans)
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES //M_PI, M_E
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int c[n-1],s[n-1],f[n-1];
	for(int i = 1; i<n; i++)
		cin>>c[i-1]>>s[i-1]>>f[i-1];
	int ans = 0,time = 0;
	vector<int> v;
	for(int j = 0; j<n-1; j++)
	{
		time = 0;
		for(int i = j; i<n-1; i++)
		if(time<=s[i])
		{
			time += ((s[i]-time)+c[i]);
		}
		else
		{
			int h = s[i];
			while(h<time)
				h += f[i];
			time += (h-time)+c[i];
		}
		v.pb(time);
	}
	for(auto it: v) cout<<it<<endl;
		cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, M, X int
	fmt.Scan(&N, &M, &X)
	A := make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Scan(&A[i])
	}
	var c1, c2 int
	for i := 0; i < M; i++ {
		if A[i] < X {
			c1++
		}
		if X < A[i] {
			c2++
		}
	}
	if c1 < c2 {
		fmt.Println(c1)
	} else {
		fmt.Println(c2)
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using LL = long long;
using P = pair<int,int>;


int main(){
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int ans = 0;
	rep(i,A+1){
		rep(j,B+1){
			rep(k,C+1){
				if(500*i+100*j+50*k == X) ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
		
}












Measured memory_bytes: 3612