akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using state= pair<int64_t, int>;
const int logD= 40;

int64_t dp(state stat, int64_t N, const vector<int64_t>& data, map<state, int64_t>& memo){
  if(memo.count(stat)){ return memo.at(stat); }
  else{
    int64_t Xmax; int digit;
    tie(Xmax, digit)= stat;

    if(digit==logD){
      return memo[stat]= 0LL;
    }
    else{
      int64_t offset1= (1LL << digit)* (N- data.at(digit));
      int64_t offset0= (1LL << digit)* data.at(digit);
      state next  = make_pair( Xmax>>1   , digit+1);
      state next_d= make_pair((Xmax>>1)-1, digit+1);

      if(Xmax & 1) return memo[stat]= dp(next, N, data, memo)+ max(offset1, offset0);
      else if (Xmax > 0) return memo[stat]= max(dp(next_d, N, data, memo)+ offset1, dp(next, N, data, memo)+ offset0);
      else               return memo[stat]= dp(next, N, data, memo)+ offset0;
    }
  }
}

int main(){
  int64_t N,Xmax,buf;
  cin >> N >> Xmax;

  vector<int64_t> data(logD);
  for(int64_t i=0; i<N; i++){
    cin >> buf;
    int cnt= 0;
    while(buf > 0){
      if(buf & 1){ data.at(cnt)++; }

      cnt++;
      buf>>= 1;
    }
  }

  map<state, int64_t> memo;
  cout << dp(make_pair(Xmax, 0), N, data, memo) << endl;
}

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

int main() {
   int N,K;
   cin >> N >> K;
   vector<int> S(N);
   for (int i=0; i<N; i++) {
       S.at(i)=-1;
   }
   for (int i=0; i<K; i++) {
       int d;
       cin >> d;
       for (int j=0; j<d; j++) {
           int A;
           cin >> A;
           S.at(A-1)=1;
       }
   }
   int count=0;
   for (int i=0; i<N; i++) {
       if(S.at(i)==-1) count++;
   }
   cout << count << endl;
}

Measured memory_bytes: 3632
#!/usr/bin/ruby
M=5000000
MOD=1000000007
inv=[1]*M
fact=[1]*M
factr=[1]*M
2.upto(M-1){|i|
	inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD
	fact[i]=i*fact[i-1]%MOD
	factr[i]=inv[i]*factr[i-1]%MOD
}
comb=->n,k{
	return 0 if k<0||n<k
	fact[n]*factr[k]*factr[n-k]%MOD
}
h=->n,k{comb[n+k-1,k]}

loop{
	a,b,c,sx,sy=gets.split.map(&:to_i)
	break if a+b+c==0
	if sx<sy || (sx==sy&&a<b)
		a,b=b,a
		sx,sy=sy,sx
	end
	d=sx-sy
	r=0
	if a==0 # x??????????????????????????????????????????????????§???x??????????????????0????????°y??????????????????0??§???????????°?????????
		if b>0 || sx!=sy
			r=0
		else
			r=h[c,sx]
		end
	elsif b==0
		r=z=h[a,d-a]*h[a+b+c,sx-d]
	else
		([a,d+b].max..sx).each{|w|
			r=(r+h[a,w-a]*h[b,w-d-b]*h[a+b+c,sx-w])%MOD
		}
	end
	p r*comb[a+b+c,a]*comb[b+c,b]%MOD
}

Measured memory_bytes: 126044
#ifdef LOCAL_EXEC
#include "include.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define trace(...)
#endif

using LL = long long;

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

	int n; cin >> n;
	string s; cin >> s;

	bool yes = n % 2 == 0 && s.substr(0, n / 2) == s.substr(n / 2, n / 2);
	cout << (yes ? "Yes" : "No") << endl;
	
	return 0;
}


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

int main() {
    int n, ans = 0;
    cin >> n;
    int c[n], v[n];
    for(int i = 0; i < n; i++) cin >> v[i];
    for(int i = 0; i < n; i++) cin >> c[i];

    for(int i = 0; i < n; i++) {
        if(v[i] > c[i]) ans += v[i] - c[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
double na;
double nx,ny;

int main(){
	int d;
	int a;
	na=90;
	nx=0;
	ny=0;
	while(1){
		scanf("%d,%d",&d,&a);
		if(d==0&&a==0)break;
		nx+=(double)d*cos(M_PI*na/180);
		ny+=(double)d*sin(M_PI*na/180);
		na-=a;
	}
	printf("%d\n%d\n",(int)nx,(int)ny);
}
		

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

int main() {
  string a,b;cin>>a>>b;
  if (a.size() > b.size()) cout << "GREATER";
  else if (a.size() < b.size()) cout << "LESS";
  else {
    rep(i,a.size()) {
      if (a[i] > b[i]) cout << "GREATER";
      else if (a[i] < b[i]) cout << "LESS";
      else continue;
      return 0;
    }
    cout << "EQUAL";
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//const int N=1e6;

int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    ll N,A,B;
    cin>>N>>A>>B;
    ll sum=N/(A+B)*A;
    sum+=min(N%(A+B),A);
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n,k = m()


a = l()


aaa = [(1 + a[i])/2 for i in range(n)]

co = sum(aaa[:k])

ma = co
for i in range(0,n-k):
    co = co - aaa[i] + aaa[i+k]
    
    ma = max(ma,co)
print(ma)

Measured memory_bytes: 73480
#include <cstdio>
#include <algorithm>
using namespace std;
const int N=15;
const int M=105; 
const int t=100;
int m,n,d[N][N],f[M][M],p;
int read()
{	char x=getchar();
	while(x<48||x>57) x=getchar();
	int ans=0;
	while(x>=48&&x<=57)
	{	ans=(ans<<1)+(ans<<3)+(x^48);
		x=getchar();
	}
	return ans;
}
int main()
{	m=read();n=read();
	for(int i=1;i<=m;i++)
	for(int j=1;j<=n;j++)
	d[i][j]=read();
	for(int i=0;i<=t;i++)
	for(int j=0;j<=t;j++)
	for(int x=1;x<=m;x++)
	for(int y=1;y<=n;y++)
	f[i][j]=max(f[i][j],d[x][y]-i*x-j*y);
	for(int x=1;x<=m;x++)
	for(int y=1;y<=n;y++)
	{	p=0x7ffffff;
		for(int i=0;i<=t;i++)
		for(int j=0;j<=t;j++)
		p=min(p,i*x+j*y+f[i][j]);
		if(p!=d[x][y]) {printf("Impossible\n");return 0;}
	}
	printf("Possible\n");
	printf("202 10401\n");
	for(int i=1;i<=t;i++)
	{	printf("%d %d X\n",i,i+1);
		printf("%d %d Y\n",i+101,i+102);
	}
	for(int i=0;i<=t;i++)
	for(int j=0;j<=t;j++)
	printf("%d %d %d\n",i+1,202-j,f[i][j]);
	printf("1 202\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
typedef long long int ll;
#define TLE 1000000000LL
ll n, T, M;
string s;

ll solve(string s){
	ll ret = 0;
	for(int p=0;s[p];p+=4){
		int x = s[p+2]-'0';
		if(M <= x) return -1;
		ret += pow(n, x)*T;
	}
	return ret;
}
main(){
	int i,j;
	while(cin >> n >> T >> s){
		for(M=0;M<10;M++) if(TLE < pow(n, M)*T) break;
		ll ret = solve(s);
		if(ret == -1 || TLE < ret) cout << "TLE" << endl;
		else cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 1244
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cout<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1;

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int ans;
string s;

main(){
    cin>>s;
    rep(i,s.size()-1){
        if(s[i]=='A'&&s[i+1]=='C'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int i,j,a[1000],b[1000],c,d,N,M,o=0;
	scanf("%d %d",&N,&M);
	for(i=0;i<N;i++){
	scanf("%d",&a[i]);
	b[i]=0;
}
for(i=0;i<M;i++){
	scanf("%d",&c);
	for(j=0;j<N;j++){
	if(a[j]<=c){
	b[j]++;
	break;
}
}
}
for(i=0;i<N;i++){
   if(o<b[i]){
o=b[i];
d=i+1;
}
}
printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 604
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 * 
 * https://atcoder.jp/contests/abc111/submissions/3312161 にも参考
 */
public class Main {

	/** モード一覧 */
	private static final char[] MODES = { 'L', 'D', 'U', 'R' };

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] u = new int[n], v = new int[n];
			IntStream.range(0, n).forEach(i -> {
				int x = scanner.nextInt(), y = scanner.nextInt();
				u[i] = x + y;
				v[i] = x - y;
			});
			int r = u[0] & 1;
			for (int i = 1; i < n; i++) {
				if (r != (u[i] & 1)) {
					System.out.println("-1");
					return;
				}
			}
			r = 1 - r;
			int m = 31;
			System.out.println(m + r);
			StringBuilder answer = new StringBuilder();
			if (r > 0) {
				answer.append("1").append(" ");
			}
			IntStream.range(0, m).forEach(i -> answer.append(1 << i).append(" "));
			// 最後のスペースを削除
			answer.deleteCharAt(answer.length() - 1);
			System.out.println(answer.toString());

			long base = (1L << m) - 1 - r;
			for (int i = 0; i < n; i++) {
				StringBuilder sb = new StringBuilder();
				if (r > 0) {
					sb.append('R');
				}
				long uBase = (u[i] + base) >> 1, vBase = (v[i] + base) >> 1;
				for (int j = 0; j < m; j++) {
					int u1 = (int) (uBase & 1L) << 1;
					int v1 = (int) (vBase & 1L);
					sb.append(MODES[u1 + v1]);
					uBase >>= 1;
					vBase >>= 1;
				}
				System.out.println(sb.toString());
			}
		}
	}
}


Measured memory_bytes: 41020
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  string t;
  cin>>s>>t;
  int tr = 0;
  for(int i = 0; i < 3; i++)
  {
   	if(s[i]==t[i])
       tr++;
  }
       cout<<tr;
  return 0;
}

Measured memory_bytes: 256
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int N = (int)1e5 + 228;

using namespace std;

int n, res = -1, s, t;
vector < int > g[N], path;

void dfs(int v, int pr, int depth)
{
	if (depth > res)
		s =	v, res = depth;
	for (auto to : g[v])
		if (to != pr)
			dfs(to, v, depth + 1);
}

bool getPath(int v, int pr)
{
	path.pb(v);
	if (v == t)
		return true;
	for (auto to : g[v])	
	{
		if (to == pr)
			continue;
		if (getPath(to, v))
			return true;	
	}
	path.pop_back();
	return false;
}

vector < int > getRes(vector < int > t)
{
	vector < int > res;	
	int cur = 1;
	for (int i = 0; i < (int)t.size(); i++)
	{
		forn(j, t[i])
		{
			res.pb(cur + j);
		}
		res.pb(cur);
		cur += t[i] + 1;
	}
	return res;
} 

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~read
	scanf("%d", &n); 
	forn(i, n - 1)
	{	
		int v, u;
		scanf("%d%d", &v, &u);
		g[v].pb(u);
		g[u].pb(v);
	}
	//~solve
	dfs(1, -1, 0);
	t = s;
	res = -1;
	s = -1;
	dfs(t, -1, 0);
	getPath(s, -1);
	vector < int > ans, res;
	for (int i = 0; i < (int)path.size(); i++)
	{
		int cnt = 0;
		int v = path[i];
		for (auto to : g[v])
		{	
			if (i > 0 && to == path[i - 1])
				continue;
			if (i < (int)path.size() - 1 && to == path[i + 1])
				continue;
			if ((int)g[to].size() != 1)
			{
				cout << -1;
				return 0;
			}
			cnt++;
		}	
		res.pb(cnt);
	}
	ans = getRes(res);
	reverse(all(res));
	ans = min(ans, getRes(res));
	for (int i = 0; i < n; i++)
		printf("%d ", ans[i]);

	return 0;
}



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

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ar array
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod = 1e9 + 7;
const ll inf = 2e9 + 5;
double PI = 3.14159265358979323846;

void solve() {

    int n;
    cin >> n;
    double p[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    vector<vector<double>> dp(n + 1, vector<double> (n + 1,0));

    // dp[i][j] = probability of getting j heads from i coins

    dp[0][0] = 1.0;
    for(int i = 1;i <= n;i++){
        for(int j = 0;j <= i;j++){
            // dp[i][j] = (probab. of getting head on ith coin and getting j-1 heads in i-1 coins)
            //  + (probab. of getting tail on ith coin and getting j heads in i-1 coins)
            dp[i][j] = dp[i-1][j]*(1-p[i-1]) + (j == 0 ? 0 : dp[i-1][j-1]*p[i-1]);
        }
    }



    double ans = 0;
    for(int heads = 0;heads <= n;heads++){
        int tails = n-heads;
        if(heads > tails){
            ans+=dp[n][heads];
        }
    }
    cout << fixed << setprecision(10) << ans << endl;


}

int32_t main()
{
    IOS
    // int T; cin >> T; while (T--)
    solve();
    return 0;
}


Measured memory_bytes: 73764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template<typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(int i=0;i<((int)(v.size()));++i) {
    if (i) os << " ";
    os << v[i];
  }
  return os;
}
struct Dice {
  vi face;
  void init() {
    face.resize(6);
  }
  void rolll() {
    vi newface = {face[4], face[1], face[0], face[3], face[5], face[2]};
    swap(face, newface);
  }
  void rollr() {
    vi newface = {face[2], face[1], face[5], face[3], face[0], face[4]};
    swap(face, newface);
  }
  void rollu() {
    vi newface = {face[1], face[5], face[2], face[0], face[4], face[3]};
    swap(face, newface);
  }
  void rolld() {
    vi newface = {face[3], face[0], face[2], face[5], face[4], face[1]};
    swap(face, newface);
  }
  void rotl() {
    vi newface = {face[0], face[2], face[3], face[4], face[1], face[5]};
    swap(face, newface);
  }
  void rotr() {
    vi newface = {face[0], face[4], face[1], face[2], face[3], face[5]};
    swap(face, newface);
  }
};
bool operator==(Dice d1, Dice d2) {
  return d1.face == d2.face;
}
bool operator<(Dice d1, Dice d2) {
  return d1.face < d2.face;
}
struct Elm {
  Dice dice;
  int r, c;
  int pos;
  int d;
};
bool operator<(Elm e1, Elm e2) {
  return make_tuple(e1.d, e1.r, e1.c, e1.dice, e1.pos) < make_tuple(e2.d, e2.r, e2.c, e2.dice, e2.pos);
}
vi dr = {0, 0, -1, 1};
vi dc = {-1, 1, 0, 0};
bool solve() {
  vi a(6);
  for(int i=0;i<(6);++i) {
    cin >> a[i];
  }
  Dice dice;
  dice.face = {a[0], a[1], a[3], a[4], a[2], a[5]};
  int q; cin >> q;
  for(int _=0;_<(q);++_) {
    int a, b; cin >> a >> b;
    int ans = 0;
    for(int k=0;k<(2);++k) {
      for(int i=0;i<(4);++i) {
        for(int j=0;j<(4);++j) {
          if(dice.face[0] == a && dice.face[1] == b) {
            ans = dice.face[4];
          }
          dice.rolll();
        }
        dice.rolld();
      }
      dice.rotl();
    }
    cout << ans << endl;
  }
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
}



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

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            if(i*4+j*7 == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main{
  public static void main(String[] args) {
    try {
      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
      String str;
      int a, b, i, count = 0;

      str = reader.readLine();
      a = Integer.parseInt(str.substring(0, 5));
      b = Integer.parseInt(str.substring(6));

      for (i = a; i <=b ; i++ ) {
        if(i/10000 == i%10){
          if(((i - i/10000*10000) - i%1000) /1000 == (i%100 - i%10) /10 ){
            count = ++count;
          }
        }
      }

      System.out.println(count);
    }
    catch (Exception e) {
      System.out.println("error");
    }
  }
}


Measured memory_bytes: 21332
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		HashMap<Character,String> map = new HashMap<Character,String>();
		for(int i=0;i<W.length();i++){
			if(map.containsKey(W.charAt(i))){

			}else{
				map.put(W.charAt(i), "");
			}
		}
		if(map.keySet().size() == 2){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}


}


Measured memory_bytes: 22996
import java.util.*;
import java.lang.*;
import java.io.*;
 
/* Name of the class has to be "Main" only if the class is public. */
class Main
{

	
	public static void main (String[] args) 
	{
		Scanner s = new Scanner(System.in);
		int r = s.nextInt();
		int c = s.nextInt();
		int m1 = s.nextInt();
		int m2 = s.nextInt();
		
		System.out.println((r*c)-(c*m1+r*m2)+(m1*m2));
		
	}
}

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

int main(){
	ll n, m;
	cin >> n >> m;
	vector<ll> h(n);
	rep(i, n) cin >> h[i];
	
	vector<bool> good(n, true);
	vector<ll> a(m), b(m);
	rep(i, m) {
		cin >> a[i] >> b[i];
		//good[min(a[i]-1, b[i]-1)] = false;
		if (h[a[i]-1] >= h[b[i]-1]) {
			good[b[i]-1] = false;
		}
        if (h[a[i]-1] <= h[b[i]-1]){
			good[a[i]-1] = false;
		}
      //rep(j, n) cout << good[j];
      //cout << endl;
	}
	ll ans = 0;
	rep(i, n) {
		if (good[i]) ans++;
	}
	cout << ans << endl;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    string S;
    cin >> S;

    map<ll, ll> M;
    REP(i, S.length()){
        M[S[i]]++;
    }

    for(auto iter=M.begin(); iter!=M.end(); iter++){
        if(iter->second >= 2){
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>

#if defined(__GNUC__) && !defined(__clang__)
#  pragma GCC optimize("Ofast")
#  pragma GCC target("sse4.2", "tune=native")
#endif


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

  int h, w, hs, ws;
  std::cin >> h >> w >> hs >> ws;
  std::cout << ((h - hs) * (w - ws)) << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int h,count=0;
    cin>>h;
    long long int i=1;
    if(h==1)
    {
        cout<<1;
        return 0;
    }
    count=1;
    h=h/2;
    while(h>=1)
    {   i=i*2;
    count=count+i;
  
    
        h=h/2;
    }
    cout<<count;
    
}

Measured memory_bytes: 256
local n=io.read("n","l")

local cable={}
for i=1,26 do
    cable[i]=51
end

local sable={}
for i=1,n do
    for j=1,26 do
        sable[j]=0
    end
    for _,c in utf8.codes(io.read()) do
        sable[c-96]=sable[c-96]+1
    end
    for j=1,26 do
        cable[j]=math.min(cable[j],sable[j])
    end
end

local kaibunsho=""
for i=1,26 do
    kaibunsho=kaibunsho..string.char(i+96):rep(cable[i])
end
print(kaibunsho)

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

int main() {
  int n;

  cin >> n;

  vector<long> a(n);

  for (int i = 0; i < n; i++) cin >> a[i];

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

  long cnt = 1, ans = 0;

  if (n == 1 && a[0] != 1) {
    ans = 1;
  }

  for (int i = 1; i < n; i++) {
    if (a[i - 1] == a[i]) {
      cnt++;
    } else {
      if (a[i - 1] != cnt) ans += cnt;
      cnt = 1;
    }
    if (cnt > a[i - 1]) {
      ans++;
      cnt--;
    } else if (i == n - 1 && a[i] != cnt) {
      ans += cnt;
    }
  }

  cout << ans;

  return 0;
}

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

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

int main()
{
  REP( i, 5 ) {
    int x; cin >> x;
    if( x == 0 ) cout << i+1 << endl;
  }
}

Measured memory_bytes: 3632
function main(input) {
  const s = input.split("\n");

  const N = parseInt(s[0]);
  const VS = s[1].split(" ").map(function(n) { return parseInt(n, 10); });
  const CS = s[2].split(" ").map(function(n) { return parseInt(n, 10); });

  var X = 0;
  var Y = 0;

  for(var i=0; i<N; i++) {
    if(VS[i] > CS[i]) {
      X += VS[i];
      Y += CS[i];
    }
  }

  console.log(X - Y);
}

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


Measured memory_bytes: 21064
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int ans = 0;
    
    for (int i = 0; i < N; i++) {
            int x = sc.nextInt();
 
            if (x <= (int) Math.abs(x - K)) {
                ans += x * 2;
            } else {
                ans += (int) Math.abs(x - K) * 2;
            }
        }
    System.out.println(ans);
  }
}

Measured memory_bytes: 36024
n,m = map(int, input().split())
aa = [0] * n
bb = [0] * n
cc = [0] * m
dd = [0] * m

for i in range(n):
    aa[i], bb[i] = map(int, input().split())
for i in range(m):
    cc[i], dd[i] = map(int, input().split())

for i in range(n):
    d = [abs(aa[i] - cc[j]) + abs(bb[i] - dd[j]) for j in range(m)]
    print(d.index(min(d))+1)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	int a,b;
	cin>>a>>b;
	cout<<max(0,a-2*b)<<endl;
	return 0;
}

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

using ll = long long;
using ld = long double;

const int nax = 2e5+10;
const  ll mod =  1e9+7;

const ll INFL = 1e18L + 5;
void min_self(ll& a, ll b){
    a = min(a,b);
}


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


    int n,W;  cin>>n>>W;
    int w[n+5], v[n+5];

    int sum = 0;
    for(int i = 0; i < n; i++)cin>>w[i]>>v[i], sum += v[i];

    ll dp[sum+5];

    for(int i = 0; i <= sum; i++)
        dp[i] = INFL;


    dp[0] = 0;

    for(int j = 0; j < n; j++) {
        for(int i = sum-v[j]; i >= 0; --i){
            min_self(dp[i+v[j]],w[j] + dp[i]);
        }
    }



  int ans = -1;
    for(int i = sum; i>=0; --i){
        if(dp[i] <= W){
            ans = i;
            break;
        }
    }
 cout<<ans;


}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#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, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int N, W;
	cin >> N >> W;
	vector<int> v(N), w(N);
	REP(i, N) {
		cin >> v[i] >> w[i];
	}
	static int dp[10001];
	auto update = [](int &a, int b) { return a = max(a, b); };
	FOR(j, 1, W + 1) {
		dp[j] = dp[j - 1];
		REP(i, N) {
			if (w[i] <= j) {
				update(dp[j], dp[j - w[i]] + v[i]);
			}
		}
	}
	cout << dp[W] << endl;

	return 0;
}


Measured memory_bytes: 3204
A = int(input())
B = int(input())
C = int(input())
X = int(input())
counts = 0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if (500*a + 100*b + 50*c) == X:
                counts += 1

print(counts)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    while(a >= b){
        if (k == 0) break;
        b *= 2;
        k--;
    }

    while(b >= c){
        if (k == 0) break;
        c *= 2;
        k--;
    }
    if (a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3616
tmp = list(map(int, input().split()))
n = tmp[0]
m = tmp[1]

k = [[0] for i in range(n+1)]
s = [[]  for i in range(n+1)]
for i in range(m):
  tmp = list(map(int, input().split()))
  k[i] = tmp[0]
  for j in range(1,k[i]+1):
    s[i].append(tmp[j])

p = tmp = list(map(int, input().split()))

ans = 0
for cnt in range(0, 2**n):
  for i in range(m):
    on = 0
    light = True
    for sw in s[i]:
      if (cnt // (2**(sw-1))) % 2 == 1:
        on += 1
#    print('CNT=' + str(cnt) + ' ON=' + str(on))
    if on%2 != p[i]:
      light = False
      break
  if light:
    ans += 1

print (ans)

Measured memory_bytes: 40304
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
const int MOD = ((int)1e9)+7;
const int INF = (int)(1e9)+(int)(1e7);
const ll INFL = (ll)(1e18)+INF;
const double EPS = 1e-8;
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int>dp;
    rep(i,N){
        int a;
        cin >> a;
        a=(int)1e9-a;
        if(dp.size()==0){
            dp.push_back(a);
            continue;
        }
        int l=-1;
        int r=dp.size();
        while(r-l>1){
            int mid=(l+r)/2;
            if(dp[mid]<=a){
                l=mid;
            }
            else{
                r=mid;
            }
        }
        if(r==dp.size()){
            dp.push_back(a);
        }
        else{
            dp[r]=min(dp[r],a);
        }
    }
    cout << dp.size() << endl;
    
    return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max(a + b - n, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e15;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;

void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const ll MAXN = 1e6 + 10;
const ll N = 4000 + 10;
const ll MN = 200 + 10;
const ll mod = 1e6;

ll dp[N][N], b[N], a[N];

int main()
{
	faster();
	ll n , x;
	cin >> n >> x;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		dp[i][i] = a[i];
		for (int j = i + 1; j < n; j++)
		{
			dp[i][j] = min(dp[i][j - 1], a[j]);
		}
	}
	ll ans = inf;
	for (int k = 0; k <= n; k++)
	{
		ll t = 0;
		for (int i = 0; i < n; i++)
		{
			if(i >= k)
				t += dp[i - k][i];
			else
			{
				t += min(dp[0][i], dp[n - k + i][n - 1]);
			}
		}
		t += k * x;
		ans = min(t, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 62976
N = int(input())
s = [input().strip() for _ in range(N)]



def main(s):
    SB = []
    SBA = []
    SR = []
    for si in s:
        if si[0] == 'B':
            if si[-1] == 'A':
                SBA.append(si)
            else:
                SB.append(si)
        else:
            SR.append(si)
    if SR:
        R = [SR.pop()]
    elif SB:
        R = [SB.pop()]
    else:
        R = [SBA.pop()]
    SB.extend(SBA)
    while SR or SB:
        if SR and SB:
            if R[-1][-1] == 'A':
                R.append(SB.pop())
            else:
                R.append(SR.pop())
        elif SR:
            R.append(SR.pop())
        elif SB:
            R.append(SB.pop())
    return "".join(R)


print(main(s).count("AB"))

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

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

  if (N  %  500  <= A) {
    cout  <<  "Yes"  <<  endl;
  }
  else {
    cout  <<  "No"  <<  endl;
  }
}


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

int n,ma,mb;
int A[41],B[41],C[41];
int dp[41][401][401];

int main(){
	cin>>n>>ma>>mb;
	for(int i=1;i<=n;i++){
		cin>>A[i]>>B[i]>>C[i];
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=400; j++){
			for(int k=0;k<=400;k++){
				dp[i][j][k]=100000000;
			}
		}
	}
	dp[0][0][0]=0;
	for(int i=1; i<=n;i++){
		for(int a=0;a<=400;a++){
			for(int b=0;b<=400;b++){
				if(dp[i-1][a][b]!=100000000){
					dp[i][a][b]=min(dp[i-1][a][b],dp[i][a][b]);
					dp[i][a+A[i]][b+B[i]]=min(dp[i-1][a][b]+C[i],dp[i][a+A[i]][b+B[i]]);
				}
			}
		}
	}
	int ans=100000000;
	for(int i=1;i<=400;i++){
		for(int j=1;j<=400;j++){
			if(i*mb==j*ma){
				ans=min(ans,dp[n][i][j]);
			}
		}
	}
	if(ans==100000000){
		cout<<-1<<endl;
	}else{
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 25984
#include<cstdio>
#include<algorithm>
using namespace std;
const int O=100000;
const int MAXN=200001;
const long long ONE=1;
int n,fa[MAXN+5],siz1[MAXN+5],siz2[MAXN];
long long ans;
int find(int x){
	if(fa[x]==x)return x;
	return fa[x]=find(fa[x]);
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<=MAXN;i++)fa[i]=i;
	for(int i=1,x,y;i<=n;i++){
		scanf("%d%d",&x,&y);
		fa[find(x)]=fa[find(y+O)];
	}
	for(int i=1;i<=O;i++)siz1[find(i)]++;
	for(int i=O+1;i<MAXN;i++)siz2[find(i)]++;
	for(int i=1;i<MAXN;i++)ans+=ONE*siz1[i]*siz2[i];
	printf("%lld\n",ans-n);
}

Measured memory_bytes: 2048
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
///////////////////////////////////////
int N;
vector<vector<pii>>G;
vector<int>res;
//vをcに塗るpはvの親
void dfs(int v, int p, int c) {
	res[v] = c;
	for (auto e: G[v]) {
		if (e.first == p) {
			continue;
		}
		if (e.second & 1) {
			dfs(e.first, v, 1 - c);
		}
		else {
			dfs(e.first, v, c);
		}
	}
}
int main() {
	cin >> N;
	G.assign(N, vector<pii>());
	for (int i = 0; i < N - 1; ++i) {
		int u, v, w; cin >> u >> v >> w;
		--u, --v;
		G[u].push_back({ v,w });
		G[v].push_back({ u,w });
	}
	res.assign(N,0);
	dfs(0, -1, 1);
	for (auto v : res) {
		cout << v << endl;
	}
	return 0;
}

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

using mint= atcoder::modint998244353;
constexpr int Nmax= 200'000; // '
constexpr int logNmax= 31- __builtin_clz(Nmax);

struct S{
  mint mS_rep;
  int  mS_digit;
};

struct F{
  mint mF_assign;
  bool mF_id;
};

vector<mint> g_aux(logNmax+ 1);
void init(){
  g_aux.at(0)= 1;
  for(int i= 1; i<= logNmax; i++){
    g_aux.at(i)= g_aux.at(i-1)*mint(10).pow(1<<(i-1)) + g_aux.at(i-1);
  }
}

S op(S left, S right){ return S{left.mS_rep*mint(10).pow(right.mS_digit) + right.mS_rep, left.mS_digit+ right.mS_digit}; };

S e(){ return S{0, 0}; };

S mapping(F f, S s){
  if(f.mF_id){ return s; }
  else{
    int logdig= 31- __builtin_clz(s.mS_digit);
    return S{f.mF_assign* g_aux.at(logdig), s.mS_digit};
  }
};

F composition(F f2, F f1){
  if(f2.mF_id){ return f1; }
  else        { return f2; }
};

F id(){ return F{0, true}; };

int main(){
  init();

  int N,Q;
  cin >> N >> Q;

  atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(vector<S>(N, S{1,1}));

  int bufL,bufR,bufD;
  for(int q=0; q<Q; q++){
    cin >> bufL >> bufR >> bufD;
    bufL--; // [bufL,bufR] 1-indexed -> [bufL,bufR) 0-indexed
    seg.apply(bufL, bufR, F{bufD, false});

    cout << seg.all_prod().mS_rep.val() << endl;
  }
}

Measured memory_bytes: 10936
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#include <unordered_set>

#define _USE_MATH_DEFINES
#include <math.h>


#include <vector>
#include <list>

#include <set>
#include <map>

#include <unordered_map>

#include <queue>
#include <stack>

#include <string>

#include <vector>

#define sqr(x) (x) * (x)

#include <algorithm>
#include <functional>

#include <bitset>

#include <functional>

#include <chrono>

typedef unsigned int u32;
typedef int i32;

typedef unsigned long long int u64;
typedef long long int i64;

typedef uint16_t u16;
typedef int16_t i16;

typedef uint8_t u8;
typedef int8_t i8;


using namespace std;
using namespace std::chrono;

struct less_key
{
    bool operator() (pair<i64, i64> p1, pair<i64, i64> p2)
    {
        return p1.first > p2.first || (p1.first == p2.first && p1.second < p2.second);
    }
};

struct pair_hash {
public:
    std::size_t operator()(const std::pair<u64, u64> &x) const
    {
        return std::hash<u64>()(x.first) ^ std::hash<u64>()(x.second);
    }
};
#include <random>

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

// del

const i64 MAXN = 100005;

i64 n, k;
i64 a[MAXN];

i64 check(i64 l, i64 r, list<i64> q) {
    vector<i64> e;

    for (i64 i = 0; i < l; i++) {
        if (!q.empty()) {
            e.push_back(q.front());
            q.pop_front();
        }
    }

    for (i64 i = 0; i < r; i++) {
        if (!q.empty()) {
            e.push_back(q.back());
            q.pop_back();
        }
    }

    sort(e.begin(), e.end());
    i64 R = 0;
    for (auto t : e) {
        R += t;
    }

    for (i64 i = 0; i < min((i64)e.size(), max(0ll, k - (l + r))); i++) {
        if (e[i] >= 0) {
            break;
        }
        R -= e[i];
    }

    return R;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n >> k;

    list<i64> q;
    for (i64 i = 0; i < n; i++) {
        i64 t;
        cin >> t;
        q.push_back(t);
    }




    i64 R = 0;
    for (i64 i = 0; i <= k; i++) {
        for (i64 j = 0; j <= (k - i); j++) {
            R = max(R, check(i, j, q));
        }
    }


    cout << R;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <conio.h>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int x = 1;
	while (x <= n)
	{
		x *= 2;
	}
	x /= 2;
	cout << x;
	//_getch();
	return 0;
}

Measured memory_bytes: 256
# 2019/09/15
# AtCoder Beginner Contest 141 - A

# Input
s = input()

# Calc
if s == "Sunny":
    ans = "Cloudy"
elif s == "Cloudy":
    ans = "Rainy"
elif s == "Rainy":
    ans = "Sunny"

# Output
print(ans)

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

using namespace std;

typedef long long ll;

const int INF = (1<<29);
const int INFF = 0x7fffffff;
const ll LINF = (1ll<<60);
const ll LINFF = 0x7fffffffffffffff;
const long double PI = 3.14159265359;

#define _fi(n) for(int i = 0;i < n;i++)
#define _fj(n) for(int j = 0;j < n;j++)
#define _fk(n) for(int k = 0;k < n;k++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define prec(x) cout << fixed << setprecision(x)
#define sz(x) (int)x.size()
#define _log2(x) 31-__builtin_clz(x)

#define hash sodnf9843bsd
#define right iadjfof23n3okd
#define pqueue priority_queue
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define len length
#define endl '\n'

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll a, ll b){return uniform_int_distribution<ll>(a, b)(rng);}


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

    string s;cin>>s;
    ll sum = 0;
    for(int i = 0;i < sz(s);i++){
        sum += s[i]-'0';
    }

    if (sum%9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 3784
#include<iostream>
#include<vector>
#include<climits>

using namespace std;

int main(void){
    long N;
    long A, B, C;
    cin >> N >> A >> B >> C;
    vector<long> l(N);
    for(long i = 0; i < N; i++) cin >> l[i];

    long M = 1 << (2 * N);
    long ans = LONG_MAX;
    for(long m = 0; m < M; m++){
        long mm = m;
        long a = 0;
        long b = 0;
        long c = 0;
        long ans_now = -30;
        for(long i = 0; i < N; i++){
            switch(mm % 4){
                case 0:
                    break;
                case 1:
                    a += l[i];
                    ans_now += 10;
                    break;
                case 2:
                    b += l[i];
                    ans_now += 10;
                    break;
                case 3:
                    c += l[i];
                    ans_now += 10;
                    break;
            }
            mm >>= 2;
        }
        if(a == 0 || b == 0 || c == 0) continue;
        ans_now += abs(A - a) + abs(B - b) + abs(C - c);
        ans = min(ans_now, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int primes[200];
int prime[1000000];
int pr[100000];
string s[214514];
int el[314514],wl[314514];
int er[314514],wr[314514];
int roku[7]={46656,7776,1296,216,36,6,1};
int kyu[6]={59049,6561,729,81,9,1};
signed main(){
	ic(n)
	int ans=114514;
	int sum=0;
	int a=0;
	rep(0,i,n+1){
		a=i;
		rep(0,j,7){
			sum+=a/roku[j];
			a=a-roku[j]*(a/roku[j]);
		}
		a=n-i;
		rep(0,j,6){
			sum+=a/kyu[j];
			a=a-kyu[j]*(a/kyu[j]);
		}
		if(sum<ans)ans=sum;
		sum=0;
	}
	c(ans)
}	
			


Measured memory_bytes: 4352
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int a, b;
    cin >> a >> b;
    vector<string> s(100);

    rep(i, 100){
        s[i].resize(100);
        rep(j, 100){
            if(i < 50){
                s[i][j] = '#';
            } else {
                s[i][j] = '.';
            }
        }
    }
    bool f = false;
    a--;
    if(a != 0){
        for(int i = 0; i < 50; i += 2){
            for(int j = 0; j < 50; j += 2){
                s[i][j] = '.';
                a--;
                if(a == 0){
                    f = true;
                    break;
                }
            }
            if(f) break;
        }
    }


    f = false;
    b--;
    if(b != 0){
        for(int i = 99; i >= 50; i -= 2){
            for(int j = 99; j >= 50; j -= 2){
                s[i][j] = '#';
                b--;
                if(b == 0){
                    f = true;
                    break;
                }
            }
            if(f) break;
        }
    }

    cout << 100 << " " << 100 << endl;
    rep(i, 100){
        cout << s[i] << endl;
    }
}

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



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



int main(){
  int k,sum=0;
  cin >> k;
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      int x=gcd(i,j);
      for(int l=1;l<=k;l++){
        sum+=gcd(x,l);
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3640
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 10;
	x %= mod;
	return x;
}

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	string ans;
	if ((b - a) % 2 == 0)ans = "Alice";
	else ans = "Borys";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256