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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	string a[3];
  	rep(i,3) cin >> a[i];
  	string ans;
  	rep(i,3) ans += a[i].front() + 'A' - 'a';
  	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

int main()
{
	int n, q; std::cin >> n >> q;
	
	std::queue<int>* que = new std::queue<int>[n];
	
	;
	for (int i=0; i<q; i++) {
		int op, x, t;
		std::cin >> op;
		switch (op) {
		case 0:
			std::cin >> t >> x;
			que[t].push(x);
			break;
		case 1:
			std::cin >> t;
			if (!que[t].empty()) std::cout << que[t].front() << std::endl;
			break;
		case 2:
			std::cin >> t;
			if (!que[t].empty()) que[t].pop();
			break;
		}
	}
	
	delete[] que;
	
	return 0;
}
		



Measured memory_bytes: 4272
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    H = int(input())
    W = int(input())
    N = int(input())

    ans = N // max(H, W)
    if N % max(H, W) != 0:
        ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61776
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
struct UnionFind {
	vector<int> d;
	UnionFind(int n=0): d(n,-1) {}
	int root(int x) {
	  if (d[x] < 0) return x;
	  return d[x] = root(d[x]);
	}
	bool unite(int x, int y) {
	  x = root(x); y = root(y);
	  if (x == y) return false;
	  if (d[x] > d[y]) swap(x,y);
	  d[x] += d[y];
	  d[y] = x;
	  return true;
	}
	bool same(int x, int y) { return root(x) == root(y);}
	int size(int x) { return -d[root(x)];}
  };
signed main(){
	int n,m;cin >>n >> m;
	UnionFind uf(n);
	rep(i,m){
		int a,b;cin >> a >> b;
		a--;b--;
		uf.unite(a,b);
	}
	int ret = 0;
	vector<int> vis(n);
	rep(i,n){
		int x = uf.root(i);
		if(vis[x])continue;
		vis[x] = 1;
		ret = max(ret,uf.size(x));
	}
	cout << ret << endl;

	return 0;
}

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

int main(){
   string S;
   cin>>S;
   int count=0;
   int t=S.size()/2;
  
   for(int i=0;i<t;i++){
      if(S.at(i)!=S.at(S.size()-(i+1))){
         count++;
      }
   }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;
typedef long double LD;
typedef pair<LD, LD> PLD;
const int MOD=1000000007;
int INF=100100100100100;
LD pi=4*atan(1);
signed main(){
  int n;cin>>n;
  vector<LD> a(n),b(n);
  rep(i,n)cin>>a[i]>>b[i];
  
  rep(i,n){
    vector<PLD> xy;
    rep(j,n){
      if(j==i)continue;
      xy.pb(PLD(a[j]-a[i],b[j]-b[i]));
    }
    sort(xy.begin(), xy.end(), [](const auto &p1, const auto &p2) {
        return atan2l(p1.second, p1.first) < atan2l(p2.second, p2.first);
    });
    
    for (int j = 0; j < n-1; j++) {
        //cout << "(" << xy[j].first << ", " << xy[j].second << ") : " << atan2l(xy[j].second, xy[j].first) << endl;
    }
    LD ans=pi;
    rep(j,n-1){
      LD kaku;
      if(j==0)kaku=2*pi-atan2l(xy[n-2].S,xy[n-2].F)+atan2l(xy[0].S,xy[0].F);
      else kaku=-atan2l(xy[j-1].S,xy[j-1].F)+atan2l(xy[j].S,xy[j].F);
      //cout<<kaku<<endl;
      ans=max(ans,kaku);
    }
    cout<<setprecision(15)<<(ans-pi)/(2.0*pi)<<endl; 
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    Cin(int, k);

    ll a = n/k;
    ll b = (k % 2 == 0) ? (n+k/2)/k : 0;
    Cout(a*a*a + b*b*b);
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N;
vector<int> D;
int main(void) {
    cin>>N;

    for(int i = 0;i < N;i++) {
        int d;
        cin>>d;
        D.push_back(d);
    }

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

    cout<<D[N/2]-D[N/2-1]<<endl;

    return 0;
}



Measured memory_bytes: 892
//10.0.3.47 perfec
#include<set>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<climits>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define LL long long
#define ULL unsigned long long
using namespace std;
int read(){
	int f=0,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f?-x:x;
}
#define MAXN 100
#define INF 0x3f3f3f3f
int main(){
	int n=read(),cnt=0;
	for(int i=1;i<=n;i++){
		int lg=int(log10(i));
		if(lg==0||lg==2||lg==4)
			cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int x, y;
	cin >> x >> y;
	
	int ans = 0;
	if( x != 0 && y != 0 && x != y && abs(x) == abs(y) ) ans++;
	
	else if( x > y ) {
		if( (x < 0 && y < 0) || (x > 0 && y > 0) ) {
			ans += abs(x - y);
			ans += 2;
		} else if( x >= 0 && y <= 0 ) {
			ans++;
			ans += abs(x - abs(y));
		}
	} else if( x < y ) {
		if( (x <= 0 && y <= 0) || (x >= 0 && y >= 0) ) {
			ans += abs(y - x);
		} else if( x < 0 && y > 0 ) {
			ans += abs(abs(x) - y);
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int n;
vector<string> w;

void input(){
    cin >> n;
    w.resize(n);
    for(int i=0;i<n;i++) cin >> w[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    for(int i=0;i<n-1;i++){
        if(w[i][w[i].size() - 1] != w[i+1][0]){
            cout << "No" << endl;
            return 0;
        }
    }
    map<string, int> cnt;
    for(int i=0;i<n;i++) cnt[w[i]]++;
    for(auto p:cnt){
        if(p.second > 1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>

int main()
{
  int N, M, C;
  std::cin >> N >> M >> C;
  std::vector<int> bs(M);
  for (auto& val: bs)
    std::cin >> val;
  std::vector<std::vector<int>> as(N, std::vector<int>(M));
  for (auto& vec: as)
    for (auto& val: vec)
      std::cin >> val;

  int ans = 0;
  
  for (auto& a: as)
  {
    int sum = C;
    for (int i = 0; i < M; ++i)
    {
      sum += a[i] * bs[i];
    }
    if (0 < sum)
      ++ans;
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll sc(0), gs(0);
    rep(i, 0, s.size())
    {
        if (s[i] == 'g')
        {
            if (gs==0)
            {
                gs++; // g
            }
            else
            {
                sc++, gs--; // p    
            }
        }
        else
        {
            if (gs==0) 
            {
                sc--, gs++; // g
            }
            else
            {
                gs--; // p
            }
        }
    }

    cout << sc << endl;

    return 0;
}


Measured memory_bytes: 512
#e
H,W,M = map(int,input().split())
h = [None]*M
w = [None]*M
for i in range(M):
    a,b = map(int,input().split())
    h[i],w[i] = a-1,b-1


from collections import Counter
ch = Counter(h)
cw = Counter(w)

x_max=max(ch.values())
n_x_max = sum(ch[x]==x_max for x in range(H))
y_max=max(cw.values())
n_y_max = sum(cw[y]==y_max for y in range(W))
    
cnt =  sum(ch[h[i]]==x_max and cw[w[i]]==y_max for i in range(M))
if cnt < n_x_max*n_y_max:
    print(x_max+y_max)
else:
    print(x_max+y_max-1)


        

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

int main() {
  int a;
  cin >> a;
  vector <int> l(a);
  for (int i = 0; i < a; i++) cin >> l.at(i);
  sort (l.begin(),l.end());
  int l1 = 0;
  for (int i = 0; i < a-1; i++) l1 += l.at(i);
  if (l1 > l.at(a-1)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e9;
const long long LINF = 1LL << 50;
#define int long long

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	string s; cin >> s;
	char now = s[0];
	int ans = 1;
	rep(i, n) {
		if (s[i] == now) {
		
		}
		else {
			ans++;
			now = s[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define  all(x) (x).begin(),(x).end()
typedef long long ll;

vector<int> g[105];
int d[105], f[105], visited[105];
int t = 1;

void dfs(int x){
    d[x] = t++;
    visited[x] = 1;
    for(int y: g[x]){
        if(visited[y] == 1) continue;
        dfs(y);
    }
    f[x] = t++;
}

int main(){
    int n;
    cin >> n;
    rep(i,n+1){
        d[i] = 0;
        f[i] = 0;
        visited[i] = 0;
    }
    rep(i,n){
        int u, k;
        cin >> u >> k;
        rep(j, k){
            int v;
            cin >> v;
            g[u].push_back(v);
        }
    }
    for(int i = 1; i <= n; i++){
        if (visited[i] == 0){
            dfs(i);
        }
    }
    for(int i = 1; i <= n; i++){
        printf("%d %d %d\n", i, d[i], f[i]);
    }
    return 0;
}


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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1000000007LL
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(i=a;i<=b;i++)

#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

ll mypow(ll a, ll b) { if(b == 0) return 1; ll temp=mypow(a,b/2); temp=(temp*temp)%INF; if(b%2 == 1) temp=(a*temp)%INF; return temp; }
int mygcd(int a, int b) { if(b==0) return a; return mygcd(b,a%b); }
int cntBits(ll a) { int ret=0; while(a>0) { ret++; a/=2; } return ret; }

int main()
{
	ios::sync_with_stdio(0);
	int tt=1,tcase; 
	//cin >> tt;
	rep(tcase,1,tt)
	{
		int n, k; cin >> n >> k;
		string s; cin >> s;
		s[k-1] = 'a' + (s[k-1]-'A');
		cout << s << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
import heapq
N = int(input())
V = list(map(int, input().split()))
 
heapq.heapify(V)
for i in range(N-2):
  heapq.heappush(V, (heapq.heappop(V)+heapq.heappop(V))/2)
print(sum(V)/2)

Measured memory_bytes: 3060
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define maxn 505
#define ll long long 
using namespace std;

const int fx[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
int n,i,j,k,t,w;
int d[maxn*maxn][2],dis[maxn][maxn],bz[maxn][maxn];
int a[maxn][maxn],x,y;
ll ans;

int main(){
	scanf("%d",&n);
	for(i=1;i<=n;i++) for(j=1;j<=n;j++)
		dis[i][j]=min(min(i-1,j-1),min(n-i,n-j)),a[i][j]=1;
	for(i=1;i<=n*n;i++) {
		scanf("%d",&k),x=(k-1)%n+1,y=(k-1)/n+1;
		a[x][y]=0,t=0,w=1,d[w][0]=x,d[w][1]=y,bz[x][y]=1;
		ans+=dis[x][y];
		while (t<w){
			t++,x=d[t][0],y=d[t][1];
			for(k=0;k<4;k++){
				int xx=x+fx[k][0],yy=y+fx[k][1];
				if (xx>=1&&xx<=n&&yy>=1&&yy<=n){
					if (dis[x][y]+a[x][y]<dis[xx][yy]){
						dis[xx][yy]=dis[x][y]+a[x][y];
						if (!bz[xx][yy])
							w++,d[w][0]=xx,d[w][1]=yy,bz[xx][yy]=1;
					}
				}
			}
			bz[x][y]=0;
		} 
	}
	printf("%lld",ans);
}


Measured memory_bytes: 6600
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int INF = 1e9 +5;

int main(){
  	int len;
	cin >> len;
	int k;
	cin >> k;
	vector<int> n(len);
	vector<int> dp(len,INF);
	for(auto &x:n){ 
		int w;
		cin >> w;
		x = w;
	}
	dp[0] = 0;
	for(int i=0;i<len;i++){
		for(int j = i+1;j<i+k+1;j++){
			if (j<len){
			  dp[j] = min(dp[j],dp[i] + abs(n[i]-n[j]));
		  }
		}
	}
	cout << dp[len-1];
 
}

















Measured memory_bytes: 1024
#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 int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;
#define FIX(a) ((a)%MOD+MOD)%MOD

int gcd(int a, int b){if (b == 0) return a; return gcd(b, a % b);}
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int a,b,k;
    cin>>a>>b>>k;
    
    int ans = min(a,b)+1;
    int cnt = 0;
    while(cnt!=k){
        ans--;
        if(a%ans==0 && b%ans==0){
            //DEBUG(ans);
            cnt++;
        }
    }

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

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

int main(){
    int N; cin >> N;
    vector<int> d(N);
    for(int i=0;i<N;i++)cin >> d[i];
    sort(d.begin(),d.end());
    int ans = d[N/2] - d[N/2-1];
    cout << ans << endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, ns, ne) for (int i = ns; i < ne; ++i)
using namespace std;

int main() {
  unsigned long long N, a, b, ans = 0;
  cin >> N >> a;
  rep(i, 1, N) {
    cin >> b;
    if (a > b) {
      ans += a - b;
    } else {
      a = b;
    }
  }
  cout << ans << endl;
  getchar();
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<vector<int>> adj;
vector<int> num;
vector<vector<int>> color;

bool ok = true;

void dfs(int n=0, int p=-1) {
  int s = adj[n].size();
  bool dp[s+1][5001] = {}; dp[0][0] = true;
  int pos = 0, sum = 0;
  for (auto x: adj[n]) {
    if (x==p) continue;
    dfs(x,n); if (!ok) break;
    rep(i,5001) {
      if (i>=color[x][0]) dp[pos+1][i] |= dp[pos][i-color[x][0]];
      if (i>=color[x][1]) dp[pos+1][i] |= dp[pos][i-color[x][1]];
    }
    pos++;
    sum += color[x][0] + color[x][1];
  }
  // cout << n << ":"; debug(dp[2],dp[2]+10);
  int lp = p==-1 ? s : s-1;
  per(i,num[n]+1) {
    if (dp[lp][i]) {
      color[n][0] = num[n];
      color[n][1] = sum - i;
      return;
    }
  }
  ok = false;
  return;
}

int main() {
  int N; cin >> N;
  adj.resize(N); num.resize(N);
  color.resize(N,vector<int>(2,-1));
  repr(i,1,N) {
    int P; cin >> P; P--;
    adj[P].push_back(i);
    adj[i].push_back(P);
  }
  rep(i,N) cin >> num[i];
  dfs(0);
  // rep(i,N) debug(all(color[i]));
  string result = ok ? "POSSIBLE" : "IMPOSSIBLE";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 7552
from collections import defaultdict
from itertools import combinations

STR = "MARCH"

N = int(input())
s = [input() for _ in range(N)]
dd = defaultdict(int)
for i in range(N):
  dd[s[i][0]] += 1
t = tuple(dd[S]  for S in STR)
p = combinations(t,3)
ans = sum(x[0]*x[1]*x[2] for x in p)
print(ans)

Measured memory_bytes: 16492
import java.util.Scanner;

public class Main {

	static long mod = 1000000007;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String[] t = sc.nextLine().split(" ");
		long a = Long.parseLong(t[0]);
		long b = Long.parseLong(t[1]);

		long ans = 0;

		for(int i = (int)b; i <= a + 1; i++) {
			ans += i * (a - i + 1) + 1;
			ans %= mod;
		}


		System.out.println(ans);
	}
}

Measured memory_bytes: 35636
#include<stdio.h>

int main(){
    long int a,b,min,max;
    scanf("%ld %ld", &a,&b);
    min = b-a+1;
    max = b+a-1;
    for(long int i=min;i<max;i++){
        if(i<=1000000 && i>=-1000000)printf("%ld ", i);
    }
    if(max<=1000000 && max>=-1000000)printf("%ld", max);
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

n = int(input())
sum_s = []
cnt = 0
ans = 0
for i in range(n):
    sum_s.append(int(input()))
sum_s.sort()
if sum(sum_s)%10 != 0:
    ans = sum(sum_s)
else:
    for i in range(n):
        if sum_s[i]%10 != 0:
            ans = sum(sum_s)-sum_s[i]
            break
print(ans)

Measured memory_bytes: 3064
n=int(input())
w=input()
ans=[0 for i in range(n)]
for i in range(1,n):
  if w[i]=="E":
    ans[0]+=1
for i in range(1,n):
  ans[i]=ans[i-1]
  if w[i]=="E":
    ans[i]-=1
  if w[i-1]=="W":
    ans[i]+=1
print(min(ans))



Measured memory_bytes: 15500
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdlib>

using namespace std;

int main()
{
  long long A, B;
  cin >> A >> B;

  long long a=A+B;
  long long b=A-B;
  long long c=A*B;

  if(a<=b)
    {
      if(b<c)
	cout << c << endl;
      else 
	cout << b << endl;
    }
  else if(b<a)
    {
      if(a<c)
	cout << c << endl;
      else
	cout << a << endl;
    }


  return 0;
}



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

int main() {
  int n,s=0,a[101];
  cin>>n;
  rep(i,n) cin >> a[i];
  for(int i=0;i<n;i++){
    if(i%2==0&a[i]%2==1){
      s++;
    }
  }
  cout<<s<<endl;
}


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

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


  long long int x;
  x=(long long int)pow(X,0.2);

  if(X==pow(x,5)){
    A = x;
    B = 0;
  }
  else if(X==-pow(x,5)){
    A = 0;
    B = x;
  }else{
    long long int j =0;
    for(long long int i=1; i<1000000000; i++){
      long long int tmp1=0,tmp2=0;
      if(i%2 == 0){
        j=i/2;
        tmp1=(long long int)pow(j,5)+X;
        tmp2=(long long int)pow(tmp1,0.2);
        if(tmp1==pow(tmp2,5)){
          A = tmp2;
          B = j;
          break;
        }
      }else{
        j=-i/2;
        tmp1=(long long int)pow(j,5)+X;
        tmp2=(long long int)pow(tmp1,0.2);
        if(tmp1==pow(tmp2,5)){
          A = tmp2;
          B = j;
          break;
        }
      }
    }
  }
  cout << A << " " << B << endl;
}


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

using namespace std;

int main(){
	string A,B,C;
	cin>>A>>B>>C;
	int a,b,c;
	if(A[A.size()-1]==B[0]&&B[B.size()-1]==C[0]){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

long long int K;

long long int N;

set<long long int> S;
vector<long long int> id;

map<pair<int, long long int>, long long int > dp, s;
long long int DP[105][100000];

long long int MOD = 1000000007;

map<long long int, long long int > C;
long long int CC[100005];

int g[100005];

int main(void) {

	cin >> N >> K;

	for (long long int i = 1; i*i <= N; i++) {
		S.insert(i);
		S.insert(N / i);
	}
	S.insert(0);

	int q = 0;
	for (auto y : S) {
		id.push_back(y);
	}
	

	int I = S.size();

	for (int q = 1; q < I; q++) {
		int p = lower_bound(id.begin(), id.end(), N / id[q]) - id.begin();
		//cout << "q= " << q << "  p= " << p << endl;
		g[q] = p;
	}

	

	/*for (int q = 1; q < I; q++) {
		dp[make_pair(1, id[q])] = id[q] - id[q - 1];
		C[id[q]] = id[q] - id[q - 1];
	}*/

	for (int q = 1; q < I; q++) {
		CC[q] = id[q] - id[q - 1];
	}

	for (int q = 1; q < I; q++) {
		DP[1][q] = CC[q];
	}



	long long int sum;

	/*for (int k = 1; k <= K - 1; k++) {
		sum = 0;
		for (int q = 1; q < I; q++) {
			long long int num = dp[make_pair(k, id[q])];
			sum += num; sum %= MOD;
			dp[make_pair(k + 1, N / id[q])] = (sum*(C[N / id[q]]))%MOD;
		}
	}*/

	for (int k = 1; k <= K - 1; k++) {
		sum = 0;
		for (int q = 1; q < I; q++) {
			long long int num = DP[k][q];
			sum += num; sum%= MOD;
			DP[k + 1][g[q]] = (sum*CC[g[q]]) % MOD;
		}
	}


	long long int ans = 0;

	/*for (int q = 1; q < I; q++) {
		ans += dp[make_pair(K, id[q])];
		ans %= MOD;
	}*/


	for (int q = 1; q < I; q++) {
		ans += DP[K][q];
		ans %= MOD;
	}


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

Measured memory_bytes: 82556
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}

int main(){
    int n;cin>>n;
    rep(i,1,10){
        rep(j,1,10){
            if(i*j==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}


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

#define int long long
#define INF 9223372036854775807
#define M_PI 3.14159265358979323846
#define double long double

int mod = INF;

int fastPow(int b, int e){int r = 1;while(e){if(e%2 == 1){r*=b;r%=mod;}b*=b;b%=mod;e/=2;}return r;}
int pgcd(int a, int b){ if(a%b == 0) return b; else return pgcd(b, a%b);}
int sign(int a){if(a < 0){ return -1;}if(a == 0) {return 0;}if(a > 0) {return 1;}}
bool isPrime(int a){if(a == 1) {return false;}int f = sqrt(a);for(int i = 2; i<=f; i++){if(a%i == 0){return false;}}return true;}
int toInt(string s){int tot = 0;for(int i = s.size()-1; i >= 0; i--){tot+=((s[i]-'0')%mod)*fastPow(10,i);tot%=mod;}return tot;}
string toString(int a){string s = "";while(a){s = (char)('0'+a%10) + s;a/=10;}return s;}

vector<int> Graph[100009];
vector<int> memo(100009,-1);

int dfs(int n, int last){
    if(memo[n] != -1) return memo[n];
    int tot = 0;
    for(int a : Graph[n]){
        if(a != last) tot = max(tot, dfs(a, n)+1);
    }
    return memo[n] = tot;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        Graph[a].push_back(b);
    }
    for(int i = 1; i<=n; i++){
        dfs(i,-1);
    }
    int maxi = -INF;
    for(int a : memo){
        maxi = max(maxi, a);
    }
    cout << maxi << endl;
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mp(a,b) make_pair(a,b)
#define vi vector<int>
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define vp vector<pair<int,int> >
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define F first
#define S second
#define endl "\n"
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define dom 998244353
#define pi 3.14159265
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define pii pair<int,int> 
#define mini 2000000000000000000
#define time_taken 1.0 * clock() / CLOCKS_PER_SEC
//mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
void shikhar7s(int cas)
{
    int h1,h2,m1,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int a;
    if(h1==h2)
        a=m2-m1;
    else
    {
        a=60-m1;
        h1++;
        a+=(h2-h1)*60;
        a+=m2;
    }
    cout<<a-k;
}
signed main()
{
    fast;
    int t=1;
    //cin>>t;
    int cas=1;
    while(cas<=t)
    {
    shikhar7s(cas);
    cas++;
    }
    return 0;
}

Measured memory_bytes: 3648
module IntSet = Set.Make (struct
  type t = int
  let compare = compare
end)

let array_of_string s = Array.init (String.length s) (fun i -> s.[i])

let solve xs ns =
  snd (List.fold_left (fun (m, s) n ->
    (m - n, IntSet.fold (fun x s ->
      [(x + n); (x - n)]
      |> List.filter (fun x -> abs x <= m - n)
      |> List.fold_left (fun s x -> IntSet.add x s) s) s IntSet.empty))
    (List.fold_left ( + ) 0 ns, xs) ns)

let () =
  let s = Scanf.scanf "%s\n" (fun s -> s) in
  let x, y = Scanf.scanf "%d %d\n" (fun x y -> x, y) in
  array_of_string s
  |> Array.fold_left (fun (acc, curr) c ->
      match c with
      | 'F' -> (acc, curr + 1)
      | 'T' -> (curr :: acc, 0)) ([], 0)
  |> (fun (acc, curr) -> List.rev (curr :: acc))
  |> (function (n :: ns) ->
      let (_, (xs, ys)) =
        List.fold_left (fun (b, (xs, ys)) x ->
          (not b, if b then (x :: xs, ys) else (xs, x :: ys))) (false, ([], [])) ns in
      IntSet.mem 0 (solve (IntSet.singleton (n - x)) (List.rev xs))
        && IntSet.mem 0 (solve (IntSet.singleton (-y)) (List.rev ys)))
  |> (function true -> "Yes" | false -> "No")
  |> print_endline

Measured memory_bytes: 5376
N, K = map(int, input().split())
A=list(map(int, input().split()))
A.sort()
MOD=10**9+7
s_max = 0
s_min = 0
MAX = 10**5 + 100
def COMinit():
    """
    逆元テーブルをつくる前処理
    計算量はO(n)
    1 <= k <= n <= 1e7程度
    p: 素数
    """
    fac = [0]*MAX
    finv = [0]*MAX
    inv = [0]*MAX

    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[0], inv[1] = 1, 1
    for i in range(2, MAX):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD
    return fac, finv, inv



def comb(n, k):
    """
    nCk mod MODを求める.
    この部分はO(1)
    """
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return int(fac[n] * (finv[k] * finv[n-k] % MOD) % MOD)

fac, finv, inv = COMinit()

for i in range(N):
    s_min += comb(N-i-1, K-1) * A[i]
    s_min %= MOD
for i in range(N-1, -1, -1):
    s_max += comb(i, K-1) * A[i]
    s_max %= MOD
print((s_max - s_min)%MOD)

Measured memory_bytes: 89372
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  map<int, char> p;
  int tmp {s};
  ull cnt {1};
  while (true) {
    if (p[tmp] == 0) {
      p[tmp] = 1;
    } else {
      cout << cnt << '\n';
      return 0;
    }
    if (tmp %2==0) {
      tmp = tmp>>1;
    } else {
      tmp = tmp*3+1;
    }
    ++cnt;
  }
}


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

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

  map<char, int> m;

  for(int i=0; i<w.size(); i++)
    m[w[i] ]++;

  for(auto mapp : m)
    if(mapp.second%2 != 0){
      cout << "No" << endl;
      return 0;
    }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

const inf = 10000000000

func absInt(a int) int {
	switch {
	case a >= 0:
		return a
	default:
		return -a
	}
}

func minInt(a, b int) int {
	switch {
	case a <= b:
		return a
	default:
		return b
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	arrH := make([]int, n)
	for i := range arrH {
		fmt.Scan(&arrH[i])
	}

	arrCost := make([]int, n)
	for i := range arrCost {
		arrCost[i] = inf
	}
	arrCost[0] = 0

	for i := 1; i < n; i++ {
		arrCost[i] = minInt(arrCost[i], arrCost[i-1]+absInt(arrH[i]-arrH[i-1]))
		if i >= 2 {
			arrCost[i] = minInt(arrCost[i], arrCost[i-2]+absInt(arrH[i]-arrH[i-2]))
		}
	}

	fmt.Println(arrCost[n-1])
}


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

const int INF = 1e+9 * 2;

int main() {
	int n;
	while(cin >> n && n){
		int a[5010] = {0};
		for(int i = 0; i < n; ++i)
			scanf("%d", &a[i]);
		int ans = -INF;
		for(int i = 0; i < n; ++i){
			int sum = 0;
			for(int j = i; j < n; ++j){
				sum += a[j];
				if(ans < sum)
					ans = sum;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}

	inline int ts(char *s)
	{
		int a=0,c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		while(c>32 && c!=EOF)s[a++]=c,c=fetch();
		s[a]=0;
		return a;
	}
}
using ae86::ty;
using ae86::ts;

const int _ = 1000007;

int n,que[_],he,ta;char s[_]={0},t[_]={0};

int main()
{
	n=ty(),ts(s+1),ts(t+1);

	int got=0;
	for(int i=1;i<=n;i++)if(s[i]!=t[i]){got=1;break;}
	if(!got){puts("0");return 0;}
	
	he=1,ta=0;
	int ans=0;
	for(int i=n,j=n;i>=1;i--)
	{
		if(t[i]==t[i-1])continue;
		j=min(j,i);
		while(j>0 && s[j]!=t[i])j--;
		if(j<=0){puts("-1");return 0;}
		while(he<=ta && que[he]-(ta-he+1)+1>i)he++;
		que[++ta]=j;
		if(i!=j)ans=max(ans,ta-he+1);
	}
	printf("%d\n",ans+1);

	return 0;
}


Measured memory_bytes: 6144
import java.util.*

val sc = Scanner(System.`in`)
val N = sc.nextInt()

fun main(args: Array<String>) {
    (if (N % s(N) == 0) "Yes" else "No").let(::println)
}

fun s(n: Int): Int {
    return n.toString().map { it - '0' }.sum()
}


Measured memory_bytes: 31392
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll mod(ll x)
{
    if(x<0)
    return -x;
    else
    return x;
}
int main() 
{
ll n;
cin>>n;
ll h[n];
for(ll i=0;i<n;i++)
{
    cin>>h[i];
}
ll ans[n]={0};
ans[1]=mod(h[1]-h[0]);
for(ll i=2;i<n;i++)
{
    ans[i]+=min(ans[i-1]+mod(h[i]-h[i-1]),ans[i-2]+mod(h[i]-h[i-2]));
}
cout<<ans[n-1];
}


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

const string abc="abcdefghijklmnopqrstuvwxyz";

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

  string ans = "";

  while ( N > 0 ) {
    N--;
    ans = abc[N%26] + ans;
    N /= 26;
  }

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

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define pii pair<int,int>
#define fi first
#define se second
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define M 998244353
 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
 
    while(t--)
    {
        int N;
        cin>>N;
        if(N%10==7 || (N/10)%10 == 7 || ((N/10)/10)%10==7)
        {
            cout<<"Yes";
        }
        else cout<<"No";
    }
 
   return 0;
 
//    cout<<"Sum of x+y = " << z;
}

Measured memory_bytes: 3652
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))}
const main=()=>{
  let n=tn()
  if(n<100){
    to(0)
    return
  }
  let ar=String(n).split('')
  let r=Number(ar[ar.length-2]+ar[ar.length-1])
  ar.pop()
  ar.pop()
  let l=Number(ar.join(''))
  to(l*5>=r?1:0)
}
main()

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	ll ans = 1000;
	rep(i, n - 1) {
		if (a[i] < a[i + 1]) {
			ans += (a[i + 1] - a[i]) * (ans / a[i]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3560
from collections import deque
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
edge = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)
query = [list(map(int, input().split())) for _ in range(Q)]

score = [0] * (N + 1)
for n, p in query:
    score[n] += p

seen = [0] * (N + 1)
seen[1] = 1
node = deque([1])
while node:
    s = node.popleft()
    for t in edge[s]:
        if not seen[t]:
            seen[t] = 1
            score[t] += score[s]
            node.append(t)

print(*score[1:])


Measured memory_bytes: 104472
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long 
  #define float double
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
 
  int32_t main()
  { 
      IOS
      int n;
      cin>>n;
      int a[n];
      int sum=0,supp=0;
      int m[n];
      for(int i=0;i<n;i++)
       { cin>>a[i];
        sum+=a[i];
        if(i&1) supp+=a[i];
       }
       m[0]=sum-2*supp;
       cout<<m[0]<<" ";
       for(int i=1;i<n;i++)
       {
         m[i]=2*a[i-1]-m[i-1];
         cout<<m[i]<<" ";
       }      return 0;
  }

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)
using II = pair<int,int>;
using VII = vector<II>;

void vprn(VII &v){for(auto p:v){cout<<p.first<<" "<<p.second<<"\n";}}/////

ll solve(int N, int M, VII &V){
	sort(all(V));
	// vprn(V);//
	ll ans = 0;
	int L=0, R=0;
	rp(i,0,M){
		int l,r; tie(l,r) = V[i];
		// printf("(%d %d) (%d %d)\n",L,R,l,r);//
		if(R<=l){
			ans++;
			L=l;
			R=r;
		}
		else{
			if(L<l) L=l;
			if(R>r) R=r;
		}
		// printf("(%d %d) (%d %d)\n",L,R,l,r);//
		// puts("--");//
	}
	return ans;
}

int main(){
	int N; cin>>N;
	int M; cin>>M;
	VII V;
	rp(i,0,M){
		int a,b; cin>>a>>b;
		V.emplace_back(a,b);
	}
	ote(solve(N,M,V));
}


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

using namespace std;
 
int main(){
  int N;
  char S[100];
  cin >> N >> S;
  int ju = 1;
  
  if(N % 2 == 1){
    cout << "No";
  }else{
    for(int i = 0;i < N/2;i++){
      if(S[i] != S[N/2 + i]){
        ju = 0;
      }
    }
    
    if(ju == 1)
      cout << "Yes";
    else
      cout << "No";
  }
}

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

int findSumOfDigits(int n)
{
  int sum = 0;
  while (n > 0)
  {
    sum += n % 10;
    n /= 10;
  }
  return(sum);
}

int main()
{
  int N, A, B;
  cin >> N >> A >>B;
  int total = 0;
  for (int i = 1; i <= N; i++)
  {
    int sum = findSumOfDigits(i);
    if (sum >= A && sum <= B)
      total += i;
  }
  cout << total << endl;
}
  

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define rn return
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;


int main(){
    int N,i; cin >> N >> i;
    cout << N - i + 1;
    rn 0 ;
}


Measured memory_bytes: 256
from collections import deque

def bfs(s):
  q = deque()
  q.append(s)
  while len(q) > 0:
    u = q.popleft()
    searched[u] = True
    res.append(u)
    for v in adj[u]:
      indeg[v] -= 1
      if indeg[v] == 0 and not searched[v]:
        q.append(v)

V, E = map(int, input().split())
adj = [[] for i in range(V)]
indeg = [0 for i in range(V)]

for i in range(E):
  u, v = map(int, input().split())
  adj[u].append(v)
  indeg[v] += 1

searched = [False for i in range(V)]
res = []

for u in range(V):
  if indeg[u] == 0 and not searched[u]:
    bfs(u)

for u in res:
  print(u)



Measured memory_bytes: 9292
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N;
}

int solve(){
    ll ans=0;
    ll bi3 = N/3;
    ll bi5 = N/5;
    ll bi15 = N/15;
    ans += N*(N+1)/2;
    ans -= 3*bi3*(bi3+1)/2;
    ans -= 5*bi5*(bi5+1)/2;
    ans += 15*bi15*(bi15+1)/2;
    cout << ans << endl;
    return 0;
}   

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


Measured memory_bytes: 3652
N = int(input())
A = list(map(int,input().split()))
from collections import Counter
ctr = Counter(A)
x = None
for k,v in reversed(sorted(ctr.items())):
    if v >= 4:
        if x:
            print(x*k)
        else:
            print(k**2)
        exit()
    if v >= 2:
        if x:
            print(x*k)
            exit()
        x = k
print(0)

Measured memory_bytes: 21384
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  Int ans=0;
  for(Int i=0;i<n;i++){
    if(a[i]==0) continue;
    Int j=i;
    while(j<n&&a[j]) j++;
    ans=max(ans,j-i);
  }
  cout<<ans+1<<endl;
  return 0;
}



Measured memory_bytes: 3096
#include<stdio.h>
int main(){
  int i,k,H,W;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0&&W==0)break;
    for(i=0;i<H;i++){
      for(k=0;k<W;k++){
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 2616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main(){
    int n, a, b;
    cin >> n >> a >> b;

    int tmp, digit, ans = 0;
    for(int i = 1; i <= n; i++){
        
        digit = 0;
        
        tmp = i / 10000;
        digit += tmp;
        tmp = i % 10000;

        tmp /= 1000;
        digit += tmp;
        tmp = i % 1000;

        tmp /= 100;
        digit += tmp;
        tmp = i % 100;


        tmp /= 10;
        digit += tmp;
        
        tmp = i % 10;
        digit += tmp;

        if(digit >= a && digit <= b){
            ans += i;
        }
    }
    std::cout << ans;

    return 0;
}

Measured memory_bytes: 256