akhauriyash/Code-Regression huggingface dataset:
/*
{By GWj
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
int h,w,a[200000+1],b[200000+1];
multiset<int> s;
set<mp> se;
int main(){
	R2(h,w);
	rb(i,1,h)
		R2(a[i],b[i]);
	rb(i,1,w)
		s.insert(0),se.insert(II(i,i));
	set<mp> :: IT l,r,nex;
	rb(i,1,h){
		l=se.lower_bound(II(a[i],-INF));
		r=se.upper_bound(II(b[i],INF));
		if(r!=se.begin()&&l!=se.end()&&l!=r){
			r--;
			int save=(*r).SEC;
			while(1){
//				cout<<"E:"<<(*l).FIR<<","<<(*l).SEC<<endl;
				if(l==r){
					s.erase(s.lower_bound((*l).FIR-(*l).SEC));
					se.erase(l);
					if(b[i]!=w){
						se.insert(II(b[i]+1,save));
//						cout<<"I:"<<b[i]+1<<","<<save<<endl;
						s.insert(b[i]+1-save);
					}
					break;
				}
				l++;
				nex=l;
				l--;
				s.erase(s.lower_bound((*l).FIR-(*l).SEC));
				se.erase(l);
				l=nex;
			}
			
		}
		if(s.empty()) cout<<"-1\n";
		else cout<<(*s.begin())+i<<endl;
	}
	return 0;
}


Measured memory_bytes: 23940
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
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;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
    int A, B, K;
    cin >> A >> B >> K;
    int k = 0;
    for (int i = min(A, B); i >= 1; --i)
    {
        if ((A % i == 0) && (B % i == 0))
        {
            ++k;
            if (k == K)
            {
                cout << i << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
import math

K = int(input())

ans = 0

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            if i>j or j>k or i>k:
                continue
            else:
                if i == j == k:
                    ans = ans + math.gcd(math.gcd(i,j),k)
                elif i == j or j == k or k == i:
                    ans = ans + 3*math.gcd(math.gcd(i,j),k)
                else:
                    ans = ans + 6*math.gcd(math.gcd(i,j),k)
print(ans)

Measured memory_bytes: 9212
//bismillahir rahmanir rahim
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a;
    cin>>n;
    a=n%10;
    if(a==3) cout<<"bon"<<endl;
    else if(a==0||a==1||a==8||a==6) cout<<"pon"<<endl;
    else cout<<"hon"<<endl;
}

Measured memory_bytes: 3644
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

const int N=5e3+5;
const int mod=1e9+7;

int n,siz[N],res[N],tmp[N],dp[N][N];
vector <int> son[N];

inline int mul(int x,int y) {return 1ll*x*y%mod;}
inline void inc(int&x,int y) {x+=y;if(x>=mod) x-=mod;}
inline int add(int x,int y) {x+=y;if(x>=mod) x-=mod;return x;}
template <typename _Tp> inline void IN(_Tp&x) {
	char ch;bool flag=0;x=0;
	while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	if(flag) x=-x;
}
inline void addedge(int u=0,int v=0) {
	IN(u),IN(v),son[u].push_back(v),son[v].push_back(u);
}

void dfs(int u,int fa) {
	dp[u][1]=1,siz[u]=1;
	for(auto v:son[u]) if(v!=fa) {
		dfs(v,u);
		for(int i=1;i<=siz[u]+siz[v];++i) tmp[i]=0;
		for(int i=1;i<=siz[u];++i)
			for(int j=0;j<=siz[v];++j)
				inc(tmp[i+j],mul(dp[u][i],dp[v][j]));
		for(int i=1;i<=siz[u]+siz[v];++i) dp[u][i]=tmp[i],tmp[i]=0;
		siz[u]+=siz[v];
	}
	for(int i=2;i<=siz[u];i+=2) inc(dp[u][0],mod-mul(dp[u][i],res[i]));
}

int main() {
	IN(n),res[0]=1;
	for(int i=2;i<=n;++i) addedge();
	for(int i=2;i<=n;i+=2) res[i]=mul(res[i-2],i-1);
	dfs(1,0);
	printf("%d\n",mod-dp[1][0]);
	return 0;
}

Measured memory_bytes: 97408
#include<cstdio>
using namespace std;
int men[200000],prev[200000],next[200000];
int main(void)
{
	int n,m,q,i,j,flg,qq;

	int a,x,deg;
	scanf("%d %d %d",&n,&m,&q);
	for(i=0;i<n;i++)	{
		men[i]=1;
		prev[i]=i-1;
		next[i]=i+1;
	}
	prev[0]=n-1;
	next[n-1]=0;
	x=0;
	for(i=0;i<m;i++)	{
		scanf("%d",&a);
		deg=a%2;
		for(j=0;j<a;j++)	{
			if(deg==0)	{
				x=next[x];
			}
			else {
				x=prev[x];
			}
		}
		men[x]=0;
		prev[next[x]]=prev[x];
		next[prev[x]]=next[x];
		x=next[x];
	}
	for(i=0;i<q;i++)	{
		scanf("%d",&qq);
		printf("%d\n",men[qq]);
	}
	return 0;
}


Measured memory_bytes: 3372
#include<bits/stdc++.h>
using namespace std;
const int N=800005,M=998244353;
int n,m,u,v,i,head[N],Next[N*2],adj[N*2],d[N],q[N],l,r,k;
char c[200005];
void Push(int u,int v)
{
	Next[++k]=head[u];
	head[u]=k;
	adj[k]=v;
	++d[v];
}
int main()
{
	scanf("%d %d",&n,&m);
	scanf("%s",c+1);
	for(i=1;i<=m;++i)
	{
		scanf("%d %d",&u,&v);
		if(c[u]=='A'&&c[v]=='A')
			Push(u,v+n);
		if(c[u]=='A'&&c[v]=='B')
			Push(u+n,v+2*n);
		if(c[u]=='B'&&c[v]=='B')
			Push(u+2*n,v+3*n);
		if(c[u]=='B'&&c[v]=='A')
			Push(u+3*n,v);
		swap(u,v);
		if(c[u]=='A'&&c[v]=='A')
			Push(u,v+n);
		if(c[u]=='A'&&c[v]=='B')
			Push(u+n,v+2*n);
		if(c[u]=='B'&&c[v]=='B')
			Push(u+2*n,v+3*n);
		if(c[u]=='B'&&c[v]=='A')
			Push(u+3*n,v);
	}
	for(i=1;i<=n*4;++i)
		if(!d[i])
			q[++r]=i;
	l=1;
	while(l<=r)
	{
		for(i=head[q[l]];i!=0;i=Next[i])
		{
			--d[adj[i]];
			if(d[adj[i]]==0)
				q[++r]=adj[i];
		}
		++l;
	}
	puts(r==4*n?"No":"Yes");
}


Measured memory_bytes: 13952
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
     ll n;
     cin>>n;
     ll g=n/2;
     ll ans=0;
     if(n%2==1)
     {cout<<0;
     return 0;}
     for(ll x=5;x<=1e18;x*=5)
     {
         ll f=g/x;
         if(f==0)
            break;
         ans+=f;
     }
     cout<<ans;
}


Measured memory_bytes: 256
#C問題
A,B,C,D = map(int,input().split())
#gcd(二つの数)
def gcd(GCD1,GCD2):
    x = min(GCD1,GCD2)
    y = max(GCD1,GCD2)
    if y%x == 0:
        return x
    else:
        return gcd(x,y%x)
GCD = gcd(C,D)
per = C*D//GCD
def f(n,a,b):
    gab = gcd(a,b)
    perab = a*b//gab
    ret = n-(n//a)-(n//b)+(n//perab)
    return int(ret)
print(f(B,C,D)-f(A-1,C,D))

Measured memory_bytes: 3064
#include <stdio.h>

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

Measured memory_bytes: 600
#include <iostream>


using namespace std;


using ull = unsigned long long;


ull gcd(ull x, ull y)
{
    ull r;
    if (x < y) {
        ull t = y;
        y = x;
        x = t;
    }

    while ((r = x % y) != 0) {
        x = y;
        y = r;
    }
    return y;
}


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


int main()
{
    ull x, y, N;
    cin >> N >> x;
    for (ull i = 0; i < N - 1; i++) {
        cin >> y;
        x = lcm(x, y);
    }
    cout << x << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

#define dbg(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
template <typename T>
ostream& operator<<(ostream& os, vector<T>& a) {
  for (int i = 0; i < (int)a.size(); ++i)
    os << a[i] << " \n"[i == (int)a.size() - 1];
  return os;
}

constexpr ll MOD = 1000000007;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<double> a(n);
  rep(i, 0, n) cin >> a[i];

  auto c = [&](double x) { // 最大値をx以下にできるか。
    ll res = 0;
    rep(i, 0, n) {
      if (x >= a[i]) continue;
      // double j = 1.0;
      // while (x < a[i] / (j + 1.0)) j += 1.0;
      ll j = ceil(a[i] / x);
      res += j - 1;
    }
    return res <= k;
  };
  double l = 0.0, r = 1e9 + 5;
  for (int i = 0; i < 100; ++i) {
    double mid = (r + l) / 2.0;
    if (c(mid))
      r = mid;
    else
      l = mid;
  }
  ll ans = ceil(r);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4700
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define ld long double
#define u128 __int128
#define ff first
#define ss second
#define pb push_back

#define MOD 1000000007
#define INTMAX 1000000009
#define N 100050

void solve()
{
	ll n;
	cin >> n;
	ll a[n];
	ll mean = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		mean += a[i];
	}
	ll sum = mean;
	
	for (int i = 0; i < n; ++i)
	{
		if((sum - a[i]) * n == mean * (n-1))
		{
			cout << i + 1 << "\n";
			return;
		}
	}
	cout << "Impossible\n";
}

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

	ll a, b, q;
	cin >> a >> b >> q;

	ll s[a + 1], t[b + 1];
	for (int i = 0; i < a; ++i)
	{
		cin >> s[i];
	}
	s[a] = 1000000000000;
	for (int i = 0; i < b; ++i)
	{
		cin >> t[i];
	}
	t[b] = 1000000000000;

	sort(s, s + a);
	sort(t, t + b);
	ll x;
	for (int i = 0; i < q; ++i)
	{
		cin >> x;
		int l = 0, r = a - 1;
		while(l < r)
		{
			int mid = l + r + 1 >> 1;
			if(s[mid] >= x)
				r = mid - 1;
			else
				l = mid;
		}
		int l1 = l;
		
		l = 0, r = b - 1;
		while(l < r)
		{
			int mid = l + r + 1 >> 1;
			if(t[mid] >= x)
				r = mid - 1;
			else
				l = mid;
		}
		int l2 = l;

		// cout << l1 << " " << l << "\n";
		ll ans = 0;

		if(s[l1] <= x && t[l2] <= x)
		{
			ans = min({max(abs(s[l1] - x), abs(t[l2] - x)),
				max(abs(s[l1 + 1] - x), abs(t[l2 + 1] - x)),
				abs(s[l1] - t[l2 + 1]) + min(abs(s[l1] - x), abs(t[l2 + 1] - x)),
				 abs(s[l1 + 1] - t[l2]) + min(abs(s[l1 + 1] - x), abs(t[l2] - x))});
		}
		else if(s[l1] >= x && t[l2] <= x)
		{
			ans = min({ abs(s[l1] - t[l2]) + min(abs(s[l1] - x), abs(t[l2] - x)), 
				max(s[l1] - x, t[l2 + 1] - x)});
		}
		else if(s[l1] <= x && t[l2] >= x)
		{
			ans = min({abs(t[l2] - s[l1]) + min(abs(s[l1] - x), abs(t[l2] - x)),
				max(abs(s[l1 + 1] - x), abs(t[l2] - x))});
		}
		else
		{
			ans = max(abs(s[l1] - x), abs(t[l2] - x));
		}
		cout << ans << "\n";
	}
	return 0;	
}

Measured memory_bytes: 2944
#include<stdio.h>
#include<string.h>

int main(){
  int i,j,n,s,d,len,k,si;
  char str[2][1000000];
  do{
    scanf("%d",&n);
    if(n==0) break;
    scanf("%s",str[0]);
    for(s=0,d=1,i=0;i<n;i++,d=(d+1)%2,s=(s+1)%2){
      len=strlen(str[s]);
      j=0;
      si=0;
      while(j<len){
	for(k=j+1;str[s][k]==str[s][j];k++)
	  ;
	sprintf(str[d]+si,"%d%c",k-j,str[s][j]);
	while(str[d][si]) si++;
	j=k;
      }	      
    }
    printf("%s\n",str[s]);
  }while(1);

  return 0;
}

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

int n,D,d[99],x[99],c1[99],c2[99];
LL Ans,Pi;

int main()
{
#ifdef h10
	freopen("mirrored.in","r",stdin);
	freopen("mirrored.out","w",stdout);
#endif
	int i,j,S,tmp;
	bool flag;
	for (i=0;i<10;i++)
	for (j=0;j<10;j++) c1[i-j+10]++;
	for (i=0;i<10;i++)
	for (j=1;j<10;j++) c2[i-j+10]++;

	scanf("%d",&D);
	for (tmp=D;tmp;tmp/=10) d[n++]=tmp%10;

	for (S=0;S<1<<n<<n;S++)
		if (S>>(n+n-1))
		{
			memset(x,0,sizeof(x));
			for (i=0;i<n+n;i++)
				if ((S>>i)&1) x[i]+=d[i];
				else x[i]-=10-d[i],x[i+1]++;

			flag=1;
			for (i=0;i<n+n;i++)
				flag&=x[i]!=10&&x[i]!=-10;
			for (i=n+n-1;i>=0;i--)
			{
				flag=1;
				for (j=0;j<=i;j++)
					flag&=x[j]+x[i-j]==0;
				if (flag||x[i]) break;
			}
			if (!flag) continue;

			Pi=1; j=i;
			for (i=(j+1)/2;i<j;i++)
				Pi*=c1[x[i]+10];
			Pi*=c2[x[j]+10];
			Ans+=Pi;
		}
	printf("%lld\n",Ans);
}


Measured memory_bytes: 256
#ifdef _WIN32
#define NOMINMAX
#define _CRT_SECURE_NO_WARNINGS
#include <Windows.h>
#define DEBUGBREAK() ::DebugBreak()
#else
#define DEBUGBREAK() static_cast<void>(0)
#endif

#include <iostream>
#include <sstream>
#include <iomanip>
#include <valarray>
#include <vector>
#include <string>
#include <fstream>
#include <cstdlib>
#include <queue>
#include <array>
#include <functional>
#include <stack>
#include <bitset>
#include <random>
#include <algorithm>
#include <unordered_map>

using namespace std;

const int dx4[4] = { 0, -1, 1, 0 };
const int dy4[4] = { -1, 0, 0, 1 };
const int dx5[5] = { 0, -1, 0, 1, 0 };
const int dy5[5] = { -1, 0, 0, 0, 1 };
const int dx8[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int dy8[8] = { -1, -1, -1, 0, 0, 1, 1, 1 };
const int dx9[9] = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };
const int dy9[9] = { -1, -1, -1, 0, 0, 0, 1, 1, 1 };

#define REP(i, K) for (int i = 0; i < K; ++i)
#define REPYX() for (int y = 0; y < H; ++y) for (int x = 0; x < W; ++x)
#define REPX() REP(x, W)
#define REPY() REP(y, H)
#define INSIDE(x_, y_) (0 <= (x_) && 0 <= (y_) && (x_) < W && (y_) < H)
#define INSIDE_MARGIN(x_, y_, m_) ((m_) <= (x_) && (m_) <= (y_) && (x_) < W - (m_) && (y_) < H - (m_))

int get_assert_level() {
    const char* s = getenv("ASSERT_LEVEL");
    if (s) { return atoi(s); }
    return 0;
}
static int g_assert_level = get_assert_level();

#define LV_1() if (g_assert_level >= 1)
#define LV_2() if (g_assert_level >= 2)
#define LV_3() if (g_assert_level >= 3)
#define ASSERT_1(expr) do { const bool b = bool(expr); if (g_assert_level >= 1 && !b) { std::cerr << "[ASSERT 1] (" << #expr << ") failed." << std::endl; exit(-1); } } while (false)
#define ASSERT_2(expr) do { const bool b = bool(expr); if (g_assert_level >= 2 && !b) { std::cerr << "[ASSERT 2] (" << #expr << ") failed." << std::endl; exit(-1); } } while (false)
#define ASSERT_3(expr) do { const bool b = bool(expr); if (g_assert_level >= 3 && !b) { std::cerr << "[ASSERT 3] (" << #expr << ") failed." << std::endl; exit(-1); } } while (false)

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

    uint64_t A;
    int Bint, Bfrac;
    char dot;
    cin >> A >> Bint >> dot >> Bfrac;

    uint64_t B100 = Bint * 100 + Bfrac;
    cout << (A * B100 / 100ull) << endl;

    return 0;
}



Measured memory_bytes: 3616
#include "bits/stdc++.h"

using namespace std;

#define print(s) cout << (s) << endl;
#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n) 
#define all(a) a.begin(), (a).end()
#define inf = 9876543210
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, i; cin>>n>>i;
    print(n-i+1);
return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		int[] s = new int[100];
		while (n != 0 || k != 0) {
			Arrays.fill(s, 0);
			for (int i = 0; i < k; i++) {
				s[i] = in.nextInt();
			}
			boolean isYes = true;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < k; j++) {
					if (isYes) {
						s[j] -= in.nextInt();
						isYes = s[j] >= 0;
					} else {
						in.next();
					}
				}
			}
			System.out.println(isYes ? "Yes" : "No");
			n = in.nextInt();
			k = in.nextInt();
		}
	}
}

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

int main()
{
    int A, B, C, D, Left, Right, Balanced;
    scanf("%d %d %d %d", &A, &B, &C, &D);
    if (A+B>C+D)
    {
        printf("Left");
    }
    else if (A+B<C+D)
    {
        printf("Right");
    }
    else
    {
        printf("Balanced");
    }
    return 0;
}

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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
template <typename T> 
T Min(T a,T b){ return a<b?a:b; }
template <typename T>
T Max(T a,T b){ return a>b?a:b; }

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	int n;cin>>n;
	string s;int a=0,b=0,c=0,d=0;
	repi(i,n){
		cin>>s;
		if(s=="AC") a++; else if(s=="WA") b++; else if(s=="TLE") c++; else d++;
	}
	cout<<"AC x "<<a<<endl<<"WA x "<<b<<endl<<"TLE x "<<c<<endl<<"RE x "<<d<<endl;
	
	/*
	int test1;cin>>test1;while(test1--){ 
			
	 }
	 //*/
return 0;
}



Measured memory_bytes: 3660
#include<iostream>
#include<string.h>

using namespace std;

int main()
{
	char s[1000];
    int i = 0;
	cin>>s;
  	int len = strlen(s);
	if (s[len-1] == 's')
    {
      cout<<s;
      cout<<"es";
    }
  	else
    {
      cout<<s;
      cout<<"s";
    }
	
}


Measured memory_bytes: 3040
n = int(input())
mod = 10**9 + 7
l = list(map(int,input().split()))
l.sort()
if n % 2 == 1:
  ans = [2*i for i in range(n//2+1)] + [2*i for i in range(1,n//2+1)]
  ans.sort()
else:
  ans = [2*i+1 for i in range(n//2)] * 2
  ans.sort()
if l == ans:
  print( 2 ** (n//2) % mod )
else:
  print(0)

Measured memory_bytes: 14008
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define ini 0
using namespace std;

int rlay[100001];

int main (){

while (1){

memset(rlay ,0 ,sizeof(rlay));
int n,k,input,ansmax=0;
cin>>n>>k;
if (n==0 && k==0)break;

rlay[0]=ini;
for (int i=1;i<=n;i++){
        cin>>input;
        rlay[i]=input+rlay[i-1];
}

for (int i=n;i-k>0;i--){
        ansmax = max ( rlay[i]-rlay[i-k] ,ansmax );
}

cout<<ansmax<<endl;
}

return 0;
}



Measured memory_bytes: 3476
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
a,b,c=MAP()
if c-a-b>=0 and 4*a*b<(c-a-b)**2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String head = s.substring(0,1);
    String last = s.substring(2,s.length()-1);
    int ch = 0;
    if(head.equals("A"))ch++;
    if(last.length() - last.replace("C","").length() == 1)ch++;
    if(ch != 2){
      System.out.println("WA");
      return;
    }
    last = s.substring(2,s.length());
    last = last.replace("C","");
    String ALP[] = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
    for(String al:ALP){
      if(last.contains(al) || s.substring(1,2).equals(al)){
        System.out.println("WA");
        return;
      }
    }
    System.out.println("AC");
  }
}


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

#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)

int main() {
	ios::sync_with_stdio(false);
	
	int a[5], c[3];
	
	while(1) {
		cin >> a[0];
		if(!a[0])break;
		repi(i, 1, 5) cin >> a[i];
		
		rep(i, 3) c[i] = 0;
		rep(i, 5) c[a[i]-1]++;
		if( (c[0]>0&&c[1]>0&&c[2]>0) || (c[0]==5) || (c[1]==5) || (c[2]==5) ) {
			rep(i, 5)cout << 3 << endl;
		}else if(c[0]==0) {
			rep(i, 5)cout << (a[i]==2?1:2) << endl;
		}else if(c[1]==0) {
			rep(i, 5)cout << (a[i]==3?1:2) << endl;
		}else if(c[2]==0) {
			rep(i, 5)cout << (a[i]==1?1:2) << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1192
#include<cstdio>

int num = 0,t;
int  count(long long x,int flag){
	//递归边界 

	//x小于t，且含有3,5,7 
	if(x<=t ){
		if(flag==7)
			num++;
		//在其后分别添加3,5,7
		count(x*10+3,flag|1);
		count(x*10+5,flag|2);
		count(x*10+7,flag|4);
	}  
} 
int main(){
	scanf("%d",&t);
	//printf("hello");
	count(0,0);
	printf("%d",num);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>

template<typename T> struct segment_tree {
	int N;
	std::vector<T> V;
	std::function<T(T, T)> F;
	T E;

	segment_tree(std::vector<T>& a, std::function<T(T, T)> f, T e) : F(f), E(e) {
		int m = 1;
		while (m < a.size()) m *= 2;
		V.resize(N = m * 2, E);
		for (int i = 0; i < a.size(); i++) V[m + i] = a[i];
		for (int i = m - 1; i > 0; i--) V[i] = F(V[i * 2], V[i * 2 + 1]);
	}

	segment_tree(int n, std::function<T(T, T)> f, T e) : F(f), E(e) {
		int m = 1;
		while (m < n) m *= 2;
		V.resize(N = m * 2, E);
	}

	void point_update(int i, T x, std::function<T(T, T)> update) {
		int idx = N / 2 + i;
		V[idx] = update(V[idx], x);
		while (idx /= 2) V[idx] = F(V[idx * 2], V[idx * 2 + 1]);
	}

	T range_fold(int L, int R, int idx = 1, int l = 0, int r = -1) {
		if (r == -1) r = N / 2;
		if (L <= l && r <= R) return V[idx];
		if (r <= L || R <= l) return E;
		return F(range_fold(L, R, idx * 2, l, (l + r) / 2), range_fold(L, R, idx * 2 + 1, (l + r) / 2, r));
	}
};

int main() {
	int n, q;
	std::cin >> n >> q;
	std::vector<long long> a(n);
	for (int i = 0; i < n; i++) std::cin >> a[i];

	segment_tree<long long> sg(a, [](long long a, long long b){return a + b;}, 0);
	while (q--) {
		int op;
		std::cin >> op;
		if (op == 0) {
			int p; long long x;
			std::cin >> p >> x;
			sg.point_update(p, x, [](long long a, long long b){return a + b;});
		} else {
			int l, r;
			std::cin >> l >> r;
			std::cout << sg.range_fold(l, r) << '\n';
		}
	}

	return 0;
}

Measured memory_bytes: 16432
// OBïÄh2011 Day4 A : åKåNÌ

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

const double EPS = 1e-8;

int main(){
	int H, W;
	string f[600];
	while(cin >> H >> W){
		for(int i=H-1;i>=0;i--) cin >> f[i];

		vector< pair<double, int> > vd;
		// ÌæªÏíé¸_ð²×é.
		// X«(j/i)ðå«­µ½Æ«ÌÌæÌ¸àÁÄ¨­
		for(int i=1;i<=H;i++){
			for(int j=0;j<=W;j++){
				int cnt = 0;
				for(int k=0;k<4;k++){
					int ni = i-k%2, nj = j-k/2;
					if(0<=ni&&ni<H&&0<=nj&&nj<W&&f[ni][nj]=='#') cnt++;
				}
				if(cnt%2 == 1){
					if(0<=i-1&&i-1<H&&0<=j&&j<W&&f[i-1][j]==(cnt==1?'#':'.'))
						vd.push_back(make_pair((double)j/i,  1));
					if(0<=i&&i<H&&0<=j-1&&j-1<W&&f[i][j-1]==(cnt==1?'#':'.'))
						vd.push_back(make_pair((double)j/i, -1));
				}
			}
		}
		sort(vd.begin(), vd.end());

		int res = 1, cur = 1;
		// X«ðå«­µÄ¢«AÌæÌ¸ð²×é
		for(int i=0;i<vd.size(); ){
			int idx = i;
			while(idx < vd.size() && abs(vd[i].first-vd[idx].first) < EPS)
				cur += vd[idx++].second;
			i = idx;
			res = max(cur, res);
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 2528
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    int n, m;
    cin >> n >> m;
    cout << (n*(n-1) + m*(m-1)) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    ans = ""
    if n == 0:
        print(0)
        exit()
    while n != 0:
        if n&1:
            ans += "1"
            n = -(n-1)//2
        else:
            ans += "0"
            n = -(n//2)
    print(ans[::-1])
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 74868
k = []
w = []
K = 0
W = 0
for i in range(1,21):
    if i <= 10:
        a = int(input())
        w.append(a)
    else:
        b = int(input())
        k.append(b)
for j in range(1,4):
    m = max(w)
    W += m
    w.remove(m)
    M = max(k)
    K += M
    k.remove(M)
print(W,K)


Measured memory_bytes: 5596
from collections import deque

n,m = list(map(int, input().split()))
puted = [True]*(n+1)

ab = [[] for i in range(n+1)]
for i in range(m):
	a,b = map(int, input().split())
	ab[a].append(b)
	ab[b].append(a)

q = deque([1])
flg = [-1]*n
flg[0] = 0

while q:
	item = q.popleft()
	for i in ab[item]:
		if puted[i]:
			flg[i-1]=item
			q.append(i)
			puted[i]=False

if -1 in flg:
	print("No")
	exit()

print("Yes")
for i in range(1,len(flg)):
	print(flg[i])


Measured memory_bytes: 34924
// Problem : D - Score Attack
// Contest : AtCoder - AtCoder Beginner Contest 061
// URL : https://atcoder.jp/contests/abc061/tasks/abc061_d
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
const int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}
vp v[1001];
int ind[1001];
vi dp;
int n;
vi topo;
int topo_sort()
{
	queue<int> q;
	for(int i=1;i<=n;i++)
	if(!ind[i])
	q.push(i);
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		topo.pb(x);
		for(pii p:v[x])
		{
			ind[p.f]--;
			if(!ind[p.f])
			q.push(p.f);
		}
	}
	return size(topo)==n;
}
int vis[1001];
bool b=0;
void solve()
{
int m;cin>>n>>m;
vector<pair<pii,int>> edges;
while(m--)
{
	int x,y,z;cin>>x>>y>>z;
	edges.pb({{x,y},-z});
}
int dis[n+1];
inima(dis);
dis[1]=0;
for(int i=0;i<n-1;i++)
{
	for(auto p:edges)
	dis[p.f.se]=min2(dis[p.f.se],dis[p.f.f]+p.se);
}
int x=dis[n];
for(auto p:edges)
	dis[p.f.se]=min2(dis[p.f.se],dis[p.f.f]+p.se);
if(x!=dis[n])
cout<<"inf";
else
cout<<-x;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 384
N = int(input())
P = list(map(float, input().split()))


def solve():
    dp = [[0]*(N+1) for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(1,N+1):
        dp[i][0] = dp[i-1][0]*(1-P[i-1])
    for i in range(1,N+1):
        for j in range(1,i+1):
            dp[i][j] = dp[i-1][j-1]*P[i-1]+dp[i-1][j]*(1-P[i-1])
    ans = sum(dp[-1][(N+2)//2:])
    return ans
print(solve())

Measured memory_bytes: 335476
use std::io;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main () {
	let N = read_line().trim().parse::<i32>().unwrap();

	let r = (N * 800) - ((N/15)*200);
	println!("{}",r);
}


Measured memory_bytes: 4352
// Created By Jefferson Samuel on 23/08/20 at 2:47 PM

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

class Main {


    static void solve() throws Exception {

        int fc = 0 ,sc = 0;
        for(int i = 0 ; i < 3;i++)
        {
            int f = scanInt();
            if(f == 5) fc++;
            else if(f == 7) sc ++;
        }
        out.println(fc == 2 && sc == 1 ? "YES":"NO");

    }




    // dont touch this side
    static int scanInt() throws IOException {
        return parseInt(scanString());
    }

    static long scanLong() throws IOException {
        return parseLong(scanString());
    }

    static String scanString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        } catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}

Measured memory_bytes: 32544
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int K;
const int N = 50;
int A[50];
const int e16 = 10000000000000000;

signed main() {
    cin >> K;
    K = 50 * e16 - K;
    rep(i, 50) {
        A[i] = e16 + 49 - (K / 50);
    }
    rep(i, K % 50) {
        A[i] -= 51;
    }
    rep(i, 50) {
        A[i] += K % 50;
    }
    cout << 50 << endl;
    rep(i, 50) {
        cout << (i ? " " : "") << A[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  long long x, k, d; cin >> x >> k >> d;
  x = abs(x);
  k -= x / d;
  x -= (x / d) * d;
  if (k < 0) {
    x += d * abs(k);
  } else {
    if (k % 2 == 1) {
      x -= d;
    }
  }
  cout << abs(x) << endl;

  return 0;
}

// EOF

Measured memory_bytes: 3636
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
const int MAXN=220000;
const ll INF=1E18;
int n, m, a[MAXN];
struct Edge
{
	int to, val;
	Edge(int v, int w): to(v), val(w) {}
};
vector<Edge> g[MAXN];
struct DSU
{
	int f[MAXN];
	void init()
	{
		for (int i=1; i<=n; i++) f[i]=i;
	}
	int getf(int x)
	{
		if (x==f[x]) return x;
		return f[x]=getf(f[x]);
	}
	bool merge(int u, int v)
	{
		int x=getf(u), y=getf(v);
		if (x==y) return 0;
		f[x]=y; return 1;
	}
} dsu;
typedef pair<ll, int> pli;
pli dp1[MAXN], dp2[MAXN], p[MAXN];
void dfs1(int u, int f)
{
	for (Edge e:g[u])
	{
		int v=e.to;
		if (v!=f)
		{
			dfs1(v, u);
			dp1[u]=min(dp1[u], make_pair(dp1[v].first+e.val, dp1[v].second));
		}
	}
	for (Edge e:g[u])
	{
		int v=e.to;
		if (v!=f)
		{
			dp2[u]=min(dp2[u], dsu.f[dp1[v].second]!=dsu.f[dp1[u].second]?
			make_pair(dp1[v].first+e.val, dp1[v].second):
			make_pair(dp2[v].first+e.val, dp2[v].second));
		}
	}
}
void dfs2(int u, int f)
{
	for (Edge e:g[u])
	{
		int v=e.to;
		if (v!=f)
		{
			dp1[v]=min(dp1[v], make_pair(dp1[u].first+e.val, dp1[u].second));
			dp2[v]=min(dp2[v], dsu.f[dp1[u].second]!=dsu.f[dp1[v].second]?
			make_pair(dp1[u].first+e.val, dp1[u].second):
			make_pair(dp2[u].first+e.val, dp2[u].second));
			dfs2(v, u);
		}
	}
}
int main()
{
//	freopen("AT3611.in", "r", stdin);
//	freopen("AT3611.out", "w", stdout);
	scanf("%d", &n);
	for (int i=1; i<=n; i++) scanf("%d", &a[i]);
	for (int i=1; i<n; i++)
	{
		int u, v, w;
		scanf("%d%d%d", &u, &v, &w);
		g[u].push_back(Edge(v, w));
		g[v].push_back(Edge(u, w));
	}
	dsu.init();
	int cnt=0; ll ans=0;
	while (cnt<n-1)
	{
		for (int i=1; i<=n; i++)
		{
			dp1[i]=make_pair(a[i], i);
			dp2[i]=make_pair(INF, 0);
		}
		dfs1(1, 0); dfs2(1, 0);
		for (int i=1; i<=n; i++)
		{
			p[i]=dsu.f[dp1[i].second]!=dsu.f[i]?dp1[i]:dp2[i];
			p[i].first+=a[i];
		}
		for (int i=1; i<=n; i++) p[dsu.f[i]]=min(p[dsu.f[i]], p[i]);
		for (int i=1; i<=n; i++)
		{
			pli t=p[dsu.getf(i)];
			if (t.first<INF&&dsu.merge(i, t.second)) cnt++, ans+=t.first;
		}
		for (int i=1; i<=n; i++) dsu.getf(i);
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
  int N,x,ans = 0;
  cin >> N >> x;
  vector<int> v(N);
  for(int i = 0; i < N; i++) cin >> v.at(i);
  sort(v.begin(),v.end()); 
  for(int i = 0; i < N; i++){
    if( x >= v.at(i)) {
      x -= v.at(i);
      ans++;
    }else {
      break;
    }
  }
  if(x > 0 && ans == N) cout << ans -1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
   int a , b;
   cin >> a >> b;
   
   if(a == b)
   {
	cout << "a == b\n";
   }
   else if(a < b)
   {
	cout << "a < b\n";
   }
   else if(a > b)
   {
	cout << "a > b\n";
   }
   
   return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <math.h>
using namespace std;

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

    bool a =S[0] =='R';
    bool b =S[1] =='R';
    bool c =S[2] =='R';
    if(a && b && c){
        cout<<"3";
    }
    else if((a && b) || (b && c)){
        cout<<"2";
    }
    else if(a || b||c){
        cout<<"1";
    }
    else{
        cout<<"0";
    }

    return 0;
}

Measured memory_bytes: 3580
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,x = readline() |> split |> parseMap
	if x==1||x==2n-1
		println("No")
	else
		println("Yes")
		f = 0
		for i in 2:n-1
			if i == x
				f = 1
			end
			println(i+f)
		end
		println(1)
		println(x)
		println(2n-1)
		for i in n:2n-3
			if i==x
				f = 1
			end
			println(i+f)
		end
	end
end

main()

Measured memory_bytes: 136880
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int solve(int x, int y) {
  if (x % y == 0)
    return -1;
  return x;
}

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


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

ll price[102];
ll weight[102];
// ll dp[104][104];

// ll knap(ll n, ll c) {
// 	if (n == 0 or c == 0)
// 		return 0;
// 	if (dp[n - 1][c - 1] != -1)
// 		return dp[n - 1][c - 1];
// 	ll &a = dp[n - 1][c - 1];
// 	ll inc , exc;
// 	inc = exc = 0;
// 	if (weight[n - 1] <= c)
// 		inc = price[n - 1] + knap(n - 1, c - weight[n - 1]);
// 	exc = knap(n - 1, c);
// 	return a = max(inc, exc);
// }

void knap2(ll n, ll c) {
	ll dp[n + 1][c + 1];
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i <= n; i++)
		dp[i][0] = 0;
	for (int i = 0; i <= c; i++)
		dp[0][c] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= c; j++) {
			dp[i][j] = dp[i - 1][j];
			if (weight[i - 1] <= j)
				dp[i][j] = max(dp[i][j] , price[i - 1] + dp[i - 1][j - weight[i - 1]]);
		}
	}
	cout << dp[n][c];
	return;
}

int main() {

	ll items, capacity;
	cin >> items >> capacity;
	// memset(dp, -1, sizeof(dp));
	for (ll i = 0; i < items; i++)
		cin >> weight[i] >> price[i];
	knap2(items, capacity);
	return 0;
}

Measured memory_bytes: 82460
#include <cstdio>
#include <vector>
using namespace std;

int N,M,H[100100];
vector<int> G[100100];

int main()
{
  scanf ("%d %d",&N,&M);
  for (int i=1;i<=N;i++) scanf ("%d",&H[i]);
  for (int i=1;i<=M;i++){
int x,y; scanf ("%d %d",&x,&y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  int a = 0;
  for (int i=1;i<=N;i++){
bool g = 1;
    for (int j : G[i]) if (H[i] <= H[j]) g = 0;
    if (g)a++;
  }
printf ("%d\n",a);
return 0;
}


Measured memory_bytes: 8768
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) {
		
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int n=Integer.parseInt(in.next());
		List<Integer> A=new ArrayList<>();
		
		for(int i=0;i<n;i++)A.add(Integer.parseInt(in.next()));
		int q=Integer.parseInt(in.next());
		
		Comparator<Integer> lower = (x, y) -> x.compareTo(y) >= 0 ? 1 : -1;
		Comparator<Integer> upper = (x, y) -> x.compareTo(y) > 0 ? 1 : -1;
		
		for(int i=0;i<q;i++) {
			int key=Integer.parseInt(in.next());
			out.println(~Collections.binarySearch(A, key, lower)+" "
					+~Collections.binarySearch(A, key, upper));
		}
		out.flush();
	}
}


Measured memory_bytes: 109724
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    res = 0
    s = read_str()
    if s[0] == '+':
        res += 1
    else:
        res -= 1
    if s[1] == '+':
        res += 1
    else:
        res -= 1
    if s[2] == '+':
        res += 1
    else:
        res -= 1
    if s[3] == '+':
        res += 1
    else:
        res -= 1
    print(res)


main()


Measured memory_bytes: 3828
#include <iostream>
using namespace std;
int main(){
  int Q;
  cin>>Q;
  for(int i=0;i<Q;i++){
    int c,a,n;
    int can=0,cca=0,ccc=0;
    cin>>c>>a>>n;
      if(1<=n&&1<=a&&1<=c){
        can=min(min(c,a),n);
        a=a-can; c=c-can;
      }
      if(1<=a&&1<=c/2){
        cca=min(c/2,a);
        c=c-cca*2;
      }


      if(1<=c/3){
        ccc=c/3;
      }

    cout<<can+cca+ccc<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include <vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
#define PI 3.141592653589793
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	vi a(n), b(n);
	rep(i, n) cin >> a[i];

	for (int i = n - 1; i >= 0; i--) {
		int sum = 0;
		for (int j = i; j < n; j += i + 1) {
			sum += b[j];
		}
		if (sum % 2 != a[i]) b[i] = 1;
	}
	int ans = 0;
	rep(i, n) ans += b[i];
	cout << ans << endl;
	rep(i, n) {
		if (b[i] == 1) cout << i + 1 << " ";
	}
}

Measured memory_bytes: 2432
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL << 60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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やllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  ll sum = 0;
  for(int i=0; i<N; i++){
    int x;
    cin >> x;
    sum += x-1;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
\
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;


int main() {
    int n;
    bool ans = true;
    string prev,cur;
    map<string,bool> mp;
    cin >> n;

    REP(i,n){
        cin >>cur;
        if(i == 0) {
            prev = cur;
            mp[cur] = true;
        } else{
            if((prev[prev.length()-1] != cur[0])||(mp.count(cur) != 0)){
                ans = false;
                break;
            }else{
                prev = cur;
                mp[cur] = true;
            }
        }
    }
    cout << ((ans)?"Yes":"No");
}







Measured memory_bytes: 3556
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [0]*N
    for i in range(N, 0, -1):
        sumMul = 0
        for j in range(i, N+1, i):
            sumMul += B[j-1]
        if sumMul % 2 != A[i-1] % 2:
            B[i-1] += 1
    print(sum(B))
    if sum(B) != 0:
        ans = []
        for i, b in enumerate(B):
            if b != 0:
                ans.append(i+1)
        print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 69724
while true
  n,x = gets.split.map {|s| s.to_i}
  break if n == 0 && x == 0
  cnt = 0
  for i in 1..n
    for j in i+1..n
      for k in j+1..n
        cnt += 1 if i+j+k == x
      end
    end
  end
  puts cnt
end

Measured memory_bytes: 6108
/**
 *      ABC 98 C 累積和
 *      author  : kyomukyomupurin
 *      created : 2018/08/26
**/

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

int main(){
    int N; cin >> N;
    string S; cin >> S;
    vector<int> E(N);    //S[0]までにあるEの数
    S[0] == 'E' ? E[0] = 1 : E[0] = 0;

    for (int i = 1; i < N; ++i) 
        S[i] == 'E' ? E[i] = E[i - 1] + 1 : E[i] = E[i - 1];

    vector<int> W(N);    //S[0]までにあるWの数
    S[0] == 'W' ? W[0] = 1 : W[0] = 0;

    for (int i = 1; i < N; ++i) 
        S[i] == 'W' ? W[i] = W[i - 1] + 1 : W[i] = W[i - 1];

    int min = E[N - 1] - E[0];
    for (int i = 1; i < N; ++i){
        int x = W[i - 1] + E[N - 1] - E[i];
        if (x < min){
            min = x;
        }
    }
    
    cout << min << endl;
        
    return 0;
}

Measured memory_bytes: 3076
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val words = (0 until n).map { readLine()!! }

    if (words.toSet().size != words.size) {
        println("No")
        return
    }

    var end = words[0].first()
    for (word in words) {
        if (end != word.first()) {
            println("No")
            return
        }
        end = word.last()
    }

    println("Yes")
}

Measured memory_bytes: 33856
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextDouble()){
            double v = sc.nextDouble();
            int ans=0;
            for(int N=0;;N++){
                if(v*v<2.0*9.8*(5*N-5)){
                    ans=N;
                    break;
                }
            }
            System.out.println(ans);
        }
        
    }
}

Measured memory_bytes: 18612
from collections import deque 
def main():
    n,x,y=map(int,input().split())
    root=[[]for i in range(n)]
    for i in range(1,n):
        root[i-1].append(i)
        root[i].append(i-1)
    root[x-1].append(y-1)
    root[y-1].append(x-1)
    short=[0 for i in range(n)]
    dictlen={}
    for i in range(1,n):
        dictlen[i]=0
    for start in range(n):
        distance=[0]*n
        toVis=deque()
        checkVis=[-1 for i in range(n)]
        toVis.append(start)
        while len(toVis)>0:
            now=toVis.popleft()
            checkVis[now]=1
            for nex in root[now]:
                if checkVis[nex]==1:
                    continue
                toVis.append(nex)
                checkVis[nex]=1
                tonex=distance[now]+1
                distance[nex]=tonex
                dictlen[tonex]+=1
    #print(dictlen)
    for key in dictlen.keys():
        print(dictlen[key]//2)
if __name__=="__main__":
    main()

Measured memory_bytes: 52956
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

A,B,C,K=gets.chomp.split(' ').map{|n| n.to_i}
if(A-B > 10**18)
	puts "Unfair"
	exit(0)
end
if(K % 2 == 1)
	puts B-A
else
	puts A-B
end


Measured memory_bytes: 2172
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()

int main() {
  //
  int n, m;
  cin >> n >> m;
  vl x(n), y(n), z(n);
  rep(i, n) { cin >> x[i] >> y[i] >> z[i]; }

  vector<vector<ll> > data(8, vector<ll>(n));
  rep(i, n) {
    for (int p = 0; p < 8; p++) {
      ll tmp = 0;
      if (p & 1) {
        tmp += x[i];
      } else {
        tmp -= x[i];
      }
      if ((p >> 1) & 1) {
        tmp += y[i];
      } else {
        tmp -= y[i];
      }
      if ((p >> 2) & 1) {
        tmp += z[i];
      } else {
        tmp -= z[i];
      }
      data[p][i] = tmp;
    }
  }
  ll ans = 0;
  for (int p = 0; p < 8; p++) {
    sort(ALL(data[p]));
    reverse(ALL(data[p]));
    ll tmp = 0;
    for (int i = 0; i < m; i++) {
      tmp += data[p][i];
    }
    ans = max(ans, tmp);
  }

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


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

int main() {
  char a;
  cin >> a;
  string ans = "consonant";
  if (a == 'a') {
    ans = "vowel";
  } else if (a == 'i') {
    ans = "vowel";
  } else if (a == 'u') {
    ans = "vowel";
  } else if (a == 'e') {
    ans = "vowel";
  } else if (a == 'o') {
    ans = "vowel";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256