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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N, K; cin >> N >> K;
  vector<int> A(N);
  ll asum = 0;
  for (int i = 0; i < N; i++)  {
    cin >> A.at(i);
    asum += A.at(i);
  }
  sort(A.begin(), A.end());
  vector<bool> tbl(K);
  tbl.at(0) = true;
  int high = 0;
  int i = N-1;
  for ( ; i >= 0; i--) {
    if (high + asum < K) break;
    int a = A.at(i);
    asum -= a;
    for (int j = min(high + a, K-1); j-a >= 0; j--) {
      if (! tbl.at(j-a)) continue;
      tbl.at(j) = true;
      high = max(high, j);
    }
  }
  cout << (i+1) << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long int LL;
#define fr(i,p,n) for(LL i=p;i<n;i++)
#define fr1(i,p,n) for(LL i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;

using namespace std;
 
int main()
{
        LL n;
        cin>>n;
        LL a[n];
        long long int ans=1;
        bool flag=true;
        fr(i,0,n){
            cin>>a[i];
            if(a[i]==0){
              ans=0;
            }
            }
            LL prev;
         fr(i,0,n){ 
             prev=ans;
            if(ans==0){
              break;
            }
            ans=ans*a[i];
            if(ans<prev){
                cout<<-1<<endl;
                flag=false;
                break;
            }
           if(ans>(long long int)pow(10,18)){
                cout<<-1<<endl;
                flag=false;
                break;
            }
        }
        
        if(flag==true) cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 4416
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int x,y;
  cin >> x >> y;
  cout << x + y / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long
#define ULL unsigned long long

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

LL mod(LL x, LL md) {
	return ((x % md) + md) % md;
}

class Mint {
public:
	static LL md;
	LL x;
	Mint(LL _x) {
		x = mod(_x, md);
	}
	Mint(const Mint &y) {
		x = mod(y.x, md);
	}
};

void MintMyExgcd(LL a, LL b, LL &x, LL &y) {
	// solve equation ax + by = 1 (mod m)
	LL md = Mint::md;
	if (b == 0) {
		y = 0;
		x = 1;
		return ;
	}
	MintMyExgcd(b, a % b, x, y);
	LL t = y;
	y = mod(x - (a / b) * y, md);
	x = t;
}

LL MintNY(LL x) {
	if (x == 0) {
		return 1;
	}
	LL md = Mint::md;
	LL a, b;
	MintMyExgcd(x, md, a, b);
	while (a < 0) {
		a += md;
	}
	return a;
}

/* LL gcd(LL a, LL b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
} */

Mint operator+(Mint a, Mint b) {
	return Mint(mod(a.x + b.x, Mint::md));
}
Mint operator-(Mint a, Mint b) {
	return Mint(mod(a.x - b.x, Mint::md));
}
Mint operator*(Mint a, Mint b) {
	return Mint(mod(a.x * b.x, Mint::md));
}
Mint operator/(Mint a, Mint b) {
	Mint c = Mint(MintNY(b.x));
	return Mint(mod(a.x * c.x, Mint::md));
}

Mint operator-(Mint a) {
	return Mint(-a.x);
}
bool operator==(Mint a, Mint b) {
	return a.x == b.x;
}
bool operator!=(Mint a, Mint b) {
	return a.x != b.x;
}
bool operator>(Mint a, Mint b) {
	return a.x > b.x;
}
bool operator<(Mint a, Mint b) {
	return a.x < b.x;
}
bool operator>=(Mint a, Mint b) {
	return a.x >= b.x;
}
bool operator<=(Mint a, Mint b) {
	return a.x <= b.x;
}

void operator+=(Mint &a, Mint b) {
	a = a + b;
}
void operator-=(Mint &a, Mint b) {
	a = a - b;
}
void operator*=(Mint &a, Mint b) {
	a = a * b;
}
void operator/=(Mint &a, Mint b) {
	a = a / b;
}

ostream& operator<<(ostream &out, Mint a) {
	out << a.x;
	return out;
}

istream& operator>>(istream &in, Mint &a) {
	in >> a.x;
	return in;
}

Mint factorial(LL n) {
	if (n == 0) {
		return Mint(1);
	}
	Mint res = 1;
	for (LL i = 1; i <= n; ++i) {
		res *= i;
	}
	return res;
}
Mint multiRange(LL s, LL t) {
	Mint res = 1;
	for (LL i = s; i <= t; ++i) {
		res *= i;
	}
	return res;
}

Mint getC(LL n, LL k) {
	if (n - k < k) {
		return getC(n, n - k);
	}
	return multiRange(n - k + 1, n) / factorial(k);
}

Mint getA(LL n, LL k) {
	return multiRange(n - k + 1, n);
}

Mint countNonNegativeDivision(LL n, LL k) {
	return getC(n + k - 1, k - 1);
}
Mint countPositiveDivision(LL n, LL k) {
	if (n < k) {
		return 0;
	}
	if (k <= 0) {
		return 0;
	}
	return getC(n - 1, k - 1);
}
Mint quickMod(Mint a, LL b) {
	Mint res = 1;
	while (b > 0) {
		if (b % 2) {
			res *= a;
		}
		a *= a;
		b /= 2;
	}
	return res;
}

LL Mint::md = 1000000007;
LL a, b, c;

int main() {
	cin >> a >> b >> c;
	LL rgt = c - a - b;
	if (rgt < 0) {
		cout << "No" << endl;
		return 0;
	}
	rgt = rgt * rgt;
	ULL urgt = rgt;
	ULL lft = (ULL)(4) * (ULL)(a) * (ULL)(b);
	if (lft < urgt) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
while True:
    h,w = map(int,input().split())
    if w == 0 and h == 0:
        break
    else:
        print("#"*w)
        for i in range(h-2):
            print("#",end="")
            print("."*(w-2),end="")
            print("#")
        print("#"*w)
    print()


Measured memory_bytes: 5628
#include <iostream>
using namespace std;
typedef long long ll;
int main(void) {
  ll n, k;
  ll ans = 0;
  cin >> n >> k;
  if (k == 0) {
    ans = n * n;
  } else {
    for (ll i = k + 1; i <= n; i++) {
      ll quo1 = (n - k) / i;
      ll rem1 = (n - k) % i;
      ll quo2 = (n - i) / i;
      ll rem2 = (n - i) % i;
      ll num1 = (quo1 + 1) * (rem1 + 1) + (quo1 + 1) * quo1 * i / 2;
      ll num2 = (quo2 + 1) * (rem2 + 1) + (quo2 + 1) * quo2 * i / 2;
      ans += (num1 - num2);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
using namespace std;
const int p = 1000000007;
int pw(int x,int y)
{
	int lst=1;
	while(y)
	{
		if(y&1)lst=1LL*lst*x%p;
		y>>=1;
		x=1LL*x*x%p;
	}
	return lst;
}
int n;
int vis[N];
int jie[N],ni[N];
int c(int n,int m)
{
	if(n<m)return 0;
	return 1LL*jie[n]*ni[m]%p*ni[n-m]%p;
}
int main()
{
	scanf("%d",&n);
	jie[0]=ni[0]=ni[1]=1;
	for(int i=1;i<=n+1;i++)jie[i]=1LL*jie[i-1]*i%p;
	for(int i=2;i<=n+1;i++)ni[i]=1LL*(p-p/i)*ni[p%i]%p;
	for(int i=2;i<=n+1;i++)ni[i]=1LL*ni[i]*ni[i-1]%p;
	int len=0;
	for(int i=1;i<=n+1;i++)
	{
		int tmp;scanf("%d",&tmp);
		if(vis[tmp])
		{
			len=i-vis[tmp];
		}
		vis[tmp]=i;
	}
	for(int i=1;i<=n+1;i++)
	{
		int ans=c(n+1,i);
		ans-=c(n-len,i-1);
		ans=(ans+p)%p;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2432
#include<iostream>
#include<cmath>
#define DIFF (1000000000 + 7)

using namespace std;


int main(){
   int h,w,k;
   cin >> h >> w >> k;

   long* fib =new long[w];
   fib[0]=1;
   fib[1]=1;
   for(int i=2;i<w;i++){
      fib[i] = fib[i-1]+fib[i-2];
      fib[i] %= DIFF;
   }
   long* map = new long[w+2];
   long* map2 = new long[w+2];
   for(int i=0;i<w+2;i++){
      map[i] = i == 1;
   }

   for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
         map2[j+1] = map[j+1] *(fib[j] * fib[w-j-1]);
         map2[j+1] %= DIFF;
         map2[j+1] += map[j+2] * (fib[j] * fib[max(0, w-j-2)]);
         map2[j+1] %= DIFF;
         map2[j+1] += map[j] * (fib[max(j-1,0)] * fib[w-j-1]);
         map2[j+1] %= DIFF;
      }
      long* tmp = map2;
      map2 = map;
      map = tmp;
   }

   /*
   for(int i=0;i<w;i++){
      cout << map[i+1] << " ";
   }
      cout << endl;
      */
   cout << map[k] << endl;
}

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

int main(){
  int a, b;
  std::cin >> a >> b;
  if(a + b == 15){
    std::cout << "+" << std::endl;
  }else if(a * b == 15) {
    std::cout << "*" << std::endl;
  }else{
    std::cout << "x" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
p = [int(x) for x in input().split()]

cnt = 0

for i in range(K):
    cnt += p[i]
ans = cnt
for i in range(1,N-K+1):
    cnt -= p[i-1]
    cnt += p[K+i-1]
    ans = max(cnt,ans)


print((ans+K)/2)

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

using namespace std;
using ll = long long;

int main(){
  string S, T;
  cin >> S >> T;
  
  int cnt = 0;
  for(int i=0; i<3; i++){
    if(S[i]==T[i]) cnt += 1;
  }
  
  cout << cnt << endl;
  

  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <vector>
#include <string>
#include <vector>
#include <cassert>
#include <cmath>
#include <cctype>
#include <queue>
#include <algorithm>
#include <memory>
#include <memory.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P,P> P2;
const int INF = 1 << 30;
const double EPS = 1E-9;

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

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

int main(){
	int w, h;
	while(cin >> w >> h && (w || h)){
		string ord;
		int y = 1;
		int x = 1;
		int d = 0;
		int m = 0;
		bool f = false;
		while(cin >> ord && ord != "STOP"){
			if(ord == "RIGHT"){
				d = (d+1) % 4;
			}else if(ord == "LEFT"){
				d = (d+3)%4;
			}else if(ord == "BACKWARD"){
				cin >> m;
				y -= m * dy[d];
				if(y > h){
					f = true;
					y = h;
				}
				if(y < 1){
					y = 1;
					f = true;
				}
				x -= m * dx[d];
				if(x > w){
					f = true;
					x = w;
				}
				if(x < 1){
					f = true;
					x = 1;
				}
			}else{
				cin >> m;
				y += m * dy[d];
				if(y > h){
					f = true;
					y = h;
				}
				if(y < 1){
					f = true;
					y = 1;
				}
				x += m * dx[d];
				if(x > w){
					f = true;
					x = w;
				}
				if(x < 1){
					f = true;
					x = 1;
				}
			}
		}
		cout << x << " " << y << endl;
	}
	return 0;
}
		

Measured memory_bytes: 0
s = input()
s = list(s[i] for i in range(len(s)))
count=0
if len(s)==0 and s[0]=="0":
  print(0)
else:
  for i in range(len(s)):
    if i==len(s)-1:pass
    else:
      if s[i]==s[i+1]=="0":
        s[i+1]="1"
        count+=1
      elif s[i]==s[i+1]=="1":
        s[i+1]="0"
        count+=1
print(count)
        

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

const long long MOD = 1000000007;
const long long MAX = 200000;

long long inv[MAX+10], power[MAX + 10];

void prepare(){
    inv[1] = 1;
    power[0] = 1;
    power[1] = 2;
    for(int i =2; i < MAX+ 5 ; i++){
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        power[i] = power[i-1]*2%MOD;
    }
}

int COM(long long n, long long k){
    if(k == 0) return 1;
    else return (n-k+1)*inv[k]%MOD*COM(n,k-1)%MOD;
}

int main(){
    prepare();
    long long n;
    cin >> n;
    long long a, b;
    cin >> a >> b;
    long long twon = 1;
    long long q = n/MAX;
    long long r = n%MAX;
    for(int i =0; i < q; i++){
        twon = twon*power[MAX]%MOD;
    }
    for(int i =0; i < r; i++){
        twon =twon*2%MOD;
    }
    cout << (2*MOD + twon - 1 - COM(n,a) - COM(n,b))%MOD << endl;
}

Measured memory_bytes: 9600
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl


int main(){
	
	li a;
	while(cin>>a){
		bool omori[10]={false};
		bool ff=true;
		li fo=9;
		li div=512;
		li now=9;
		while(a>0){
			//p2(a,div);
			if(a>=div){
				if(ff){ff=false; fo=now;}
				a-=div;
				omori[now]++;
			}
			div/=2;
			now--;
		}
		li w=1;
		rep(i,10){
			if(omori[i]){
				cout<<w;
				if(i!=fo)cout<<" ";
			}
			w*=2;
		}
		puts("");
	}
	
	
	return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;

#define dbg(x1) cout<<#x1<<" = "<<(x1)<<endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<(x1)<<" "<<#x2<<" = "<<(x2)<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<(x1)<<" "<<#x2<<" = "<<(x2)<<" "<<#x3<<" = "<<(x3)<<endl
map<int,int> mp;
map<int,ll> mp2;
int lowbit(int x) {return x&(-x);}
void add(int x,int val)
{
    while(x<=1000000000)
    {
        mp[x]++;
        mp2[x]+=val;
        x+=lowbit(x);
    }
}
int sum(int x)
{
    int ans=0;
    while(x>0)
    {
        ans+=mp[x];
        x-=lowbit(x);
    }
    return ans;
}
ll sum2(int x)
{
    ll ans=0;
    while(x>0)
    {
        ans+=mp2[x];
        x-=lowbit(x);
    }
    return ans;
}
int ct[maxn],pre[maxn],a[maxn];
ll ans[maxn],nx[maxn],ct2[maxn];
set<int> s;
map<int,int> pos;
int main() {
    //freopen(".in", "r", stdin);
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=n;i>=1;i--) nx[i]=nx[i+1]+a[i];
    for(int i=n;i>=1;i--)
    {
        ct[i]=(n-i+1) - sum(a[i]-1);
        ct2[i]= nx[i] - sum2(a[i]-1) - 1LL*a[i]*ct[i];
        //dbg2(i,ct2[i]);
        add(a[i],a[i]);
    }
    for(int i=1;i<=n;i++)
    {
        set<int>::iterator it = s.upper_bound(-a[i]);
        if(it!=s.end()) pre[i]=pos[-(*it)];
        if(pos.find(a[i])==pos.end()) pos[a[i]]=i;
        s.insert(-a[i]);
    }
    int mx=0,ps=-1;
    for(int i=1;i<=n;i++)
    {
        if(a[i]>mx) mx=a[i],ps=i;
    }
    ct2[0] = nx[1];
    while(ps!=0)
    {
        int nx=pre[ps];
        ans[ps] += (ct2[nx] - ct2[ps]);
        ps = nx;
    }
    for(int i=1;i<=n;i++) printf("%lld\n",ans[i]);
    return 0;
}




Measured memory_bytes: 128640
#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<ll, ll>;

int main(){
    ll n;
    cin >> n;
    ll ans = n*(n-1)/2;
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int f=0;
    if(n%2)
        f=1;

    for(int i=0; i<n/2; i++)
    {
        if(s[i]!=s[n/2+i])
        {

            f=1;
        }
    }

    if(!f)
        cout<<"Yes";
    else
        cout<<"No";

}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  long long ans=0;
  for(int i=0;i<s.size();i++){
    int n=s[i]-'0';
    ans+=n;
  }
  if(ans%9==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
  
using namespace std;
  
struct Edge {
  int to, cost;
  Edge(int t, int c)
    : to(t), cost(c) {}
};

struct State {
  int cost, m, pos;
  State(int c, int m, int p) : cost(c), m(m), pos(p) {}
  bool operator<(const State& s) const { return cost>s.cost; }
};
  
typedef pair<int, int> PII;
typedef pair<int, PII> PIII;
  
#define MP make_pair
  
#define FST first
#define SND second
  
#define INF ((int)1e9)
  
int N, LIM, EST, ROAD, src, dst;
bool estb[100];
vector<Edge> G[100];
int cost[100][110]; // cost[N][LIM]
 
int dijkstra(int src, int dst) {
   
  fill(cost[0], cost[0]+11000, INF);
   
  priority_queue<State> pq;
  pq.push(State(0, LIM, src)); // cost, m, now
   
  while(!pq.empty()) {
    State st = pq.top(); pq.pop();
     
    if(st.pos == dst) { return st.cost; }
     
    if(cost[st.pos][st.m] < st.cost) { continue; }
     
    if(estb[st.pos] == 1 && st.m + 1 <= LIM) {
      // 冷凍中
      if( cost[st.pos][st.m+1] > st.cost+1 ) {
	cost[st.pos][st.m+1]   = st.cost+1;
	pq.push( State(st.cost+1, st.m+1, st.pos ) );
      }
    }
       
    for(int i=0; i<G[st.pos].size(); i++) {
       
      const int next = G[st.pos][i].to;
      const int add_cost = G[st.pos][i].cost;
      const int moved_m = st.m - add_cost;
       
      if(moved_m < 0) { continue; } // 到達不可
       
      if( cost[next][moved_m] > st.cost + add_cost ) {
	cost[next][moved_m] = st.cost + add_cost;
	pq.push( State( st.cost + add_cost, moved_m, next ) );
      }
    }
  }
  
  return -1;
}
 
int main() {
   
  while(cin >> N >> LIM >> EST >> ROAD >> src >> dst && N) {
     
    for(int i=0; i<100; i++) {
      G[i].clear();
      estb[i] = 0;
    }
    for(int i=0; i<EST; i++) {
      int a; cin >> a; estb[a] = 1;
    }
     
    for(int i=0; i<ROAD; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      G[a].push_back(Edge(b, c));
      G[b].push_back(Edge(a, c));
    }
     
    int ret = dijkstra(src, dst);
    if(ret == -1) {
      cout << "Help!" << endl;
    }
    else {
      cout << ret << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1476
#include <stdio.h>
int main(void){
	char op;
	int a,b;
	while(1){
	scanf("%d %c %d", &a, &op, &b);
	int res;
		if(op=='+'){
			res = a+b;
		}else if(op=='-'){
			res = a-b;
		}else if(op=='*'){
			res = a*b;
		}else if(op=='/'){
			res = a/b;
		}else{
			break;
		}
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;


void solve(long long N, long long M, std::vector<long long> A){

    long long sum = 0;

    for(long long i = 0; i < M; i++){
        sum += A[i];
    }

    if( N >= sum ){
        cout << (N-sum) << endl;
    }else{
        cout << -1 << endl;
    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 3756
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int64_t ans = 0;
  for (int i = 1; i <= N; ++i)
    if (i % 3 != 0 && i % 5 != 0)ans += i;
  cout << ans << endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <utility>

using namespace std;

typedef pair<int, int> pii;

int main() {
    int n;
    cin >> n;
    pii ba[n];
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        ba[i] = {b, a};
    }
    sort(ba, ba+n);

    int cur = 0;
    bool ans = true;
    for (int i = 0; i < n; i++) {
        cur += ba[i].second;
        if (cur > ba[i].first) {
            ans = false;
        }
    }

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 1792
import java.math.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d[] = new int[n];
        for (int i = 0; i < n; i++)
            d[i] = sc.nextInt();
        Arrays.sort(d);
        int cnt = 0;
        int tmp = 0;
        for (int i = 0; i < n; i++) {
            if (tmp == d[i]) {
                tmp = d[i];
                continue;
            } else
                cnt++;
            tmp = d[i];
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int32_t main()
{
	string s;
    cin>>s;
    int k=count(all(s),'7');
    cout<<(k>=1?"Yes":"No")<<endl;



}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int N, K;
int C[2002], G[2002];

vector<int> books[10];
int dp1[11][2002];
int dp2[11][2002];

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> K;
  rep(i, N) {
    cin >> C[i] >> G[i];
    books[--G[i]].push_back(C[i]);
  }

  rep(i, 10) sort(all(books[i])), reverse(all(books[i]));

  fill(dp1[0], dp1[11], 0);
  rep(i, 10) {
    int sum = 0;
    rep(j, books[i].size()) { // テ」ツ?セテ」ツ?ィテ」ツつ?」ツ?ヲテ・ツ」ツイテ」ツつ凝」ツ?ェテ」ツつ嘉ゥツォツ佚」ツ??ゥツ??」ツ?ォテ・ツ」ツイテ」ツ?」テ」ツ?淌ヲツ鳴ケテ」ツ?古ィツ可ッテ」ツ?陛」ツ?敕」ツ??
      sum += books[i][j];
      dp1[i][j+1] = sum + j*(j+1);
      //cout << i << " " << j+1 << " " << dp1[i][j+1] << endl;
    }
  }

  fill(dp2[0], dp2[10], 0);
  rep(i, 10) {
    rep(j, N) dp2[i+1][j] = dp2[i][j];
    reps(j, 1, books[i].size()+1) {
      for(int k = K; k >= j; k--) {
	dp2[i+1][k] = max(dp2[i+1][k], dp2[i][k-j] + dp1[i][j]);
      }
    }
  }

  //int ans = 0;
  //rep(i, 10) ans = max(ans, dp2[i][K]);
  //cout << ans << endl;
  cout << dp2[10][K] << endl;

  return 0;
}

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

n, m = map(int, input().split())
a = [0]*n
b = [0]*n
for i in range(n):
    a[i], b[i] = map(int, input().split())
c = [0]*m
d = [0]*m
for i in range(m):
    c[i], d[i] = map(int, input().split())
ans = [0]*m
for i in range(n):
    for j in range(m):
        ans[j] = abs(a[i]-c[j]) + abs(b[i]-d[j])
    print(ans.index(min(ans))+1)
    ans = [0]*m

Measured memory_bytes: 3064
S = list(map(int, list(input())))[::-1]
N = len(S)
CNT = [0]*2019
CNT[0] = 1
num = 0
d = 0
for i in range(N):
    num += S[i]*pow(10, d, 2019)
    num %= 2019
    CNT[num] += 1
    d += 1
ans = 0 
for cnt in CNT:
    ans += (cnt*(cnt - 1)) // 2
print(ans)

Measured memory_bytes: 96588
//https://atcoder.jp/contests/abc167/tasks/abc167_c
#include<stdio.h>
#define N 15
#define INF ((1<<30)-1)*2
short choose[N];
int a[N][N],cost[N],tot[N];
int main()
{
	register i;
	int n,m,x,j,ans=INF,cnt;
	scanf("%d%d%d",&n,&m,&x);
	for(i=1;i<=n;++i)
	{
		scanf("%d",cost+i);
		for(j=1;j<=m;++j)
			scanf("%d",a[i]+j);
	}
	do
	{
		cnt=0;
		for(i=1;i<=n;++i)
			tot[i]=0;
		
		for(i=1;i<=n;++i)
		{
			if(choose[i])
			{
				cnt+=cost[i];
				for(j=1;j<=m;++j)
					tot[j]+=a[i][j];
			}
		}
		for(i=1;i<=m;++i)
		{
			if(tot[i]<x)
			{
				cnt=INF;
				break;
			}
		}
		ans=ans<cnt?ans:cnt; 
		
		choose[n]=!choose[n];
		for(i=n-1;!choose[i+1];--i)
			choose[i]=!choose[i];
	}while(!choose[0]);
	
	printf("%d",ans==INF?-1:ans);
	return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int d, s, t;
    cin >> d >> s >> t;
    if(d <= s * t) cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 3648
// https://atcoder.jp/contests/abc118/tasks/abc118_a

#include <iostream>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int a, b;

  cin >> a >> b;

  cout << (b % a == 0 ? b + a : b - a) << '\n';

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("03")
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
//	ifstream cin("tst.in");
//	ofstream out("tst.out");
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int x, y, xx, yy;
	cin >> x >> y >> xx >> yy;
	int lenx = xx - x;
	int leny = yy - y;
//	if(xx > x && yy == y)
//		return cout << xx << ' ' << yy + len << ' ' << x << ' ' << yy + len, 0;
//	if(x == xx && yy > y)
//		return cout << x - len << ' ' << yy << ' ' << x - len << ' ' << y, 0;
//	if(y == yy && xx < x)
//		return cout << xx << ' ' << y - len << ' ' << x << ' ' << yy - len, 0;
//	cout << x + len << ' ' << yy << ' ' << x + len << ' ' << y;
	cout << x - leny + lenx << ' ' << y + lenx + leny << ' ' << x - leny << ' ' << y + lenx;
//	int dx[2] = {-leny, leny};
//	int dy[2] = {-lenx, lenx};
//	for(int i = 0; i < 2; i++)
//		for(int j = 0; j < 2; j++)
//			for(int k = 0; k < 2; k++)
//				for(int p = 0; p < 2; p++){
//					int X = x + dx[i]; 
//					int Y = y + dy[j];
//					int XX = xx + dx[k];
//					int YY = yy + dy[p];
//					if(abs(XX - x) * abs(XX - x) + abs(YY - y) * abs(YY - y) == abs(X - xx) * abs(X - xx) + abs(Y - yy) * abs(Y - yy) && (abs(XX - x) * abs(XX - x) + abs(YY - y) * abs(YY - y) == abs(x - xx) * abs(x - xx) + abs(y - yy) * abs(x - yy)))
//						return cout << X << ' ' << Y << ' ' << XX << ' ' << YY, 0;
//				}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

const ll MOD = 1000000007;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> S(N), T(M);
    for(int i=0;i<N;i++){
        cin >> S[i];
    }
    for(int i=0;i<M;i++){
        cin >> T[i];
    }
    vector<vector<ll>> sum(N+1, vector<ll>(M+1, 0));
    for(int i=1;i<=N;i++){
        for(int j=1;j<=M;j++){
            if(S[i-1]==T[j-1]){
                sum[i][j] = sum[i-1][j] + sum[i][j-1] + 1;
            }else{
                sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
            }
            sum[i][j] = (sum[i][j] + MOD) % MOD;
        }
    }
    cout<<(sum[N][M]+1)%MOD<<endl;

    return 0;
}

Measured memory_bytes: 31616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    int[] inputArray;

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        char[] line = sc.next().toCharArray();
        Set<String> set = new HashSet<>();

        String[] ansList = {
                "a",
                "b",
                "c",
                "d",
                "e",
                "f",
                "g",
                "h",
                "i",
                "j",
                "k",
                "l",
                "m",
                "n",
                "o",
                "p",
                "q",
                "r",
                "s",
                "t",
                "u",
                "v",
                "w",
                "x",
                "y",
                "z",
        };

        for(char s: line){
            set.add(String.valueOf(s));
        }

        List<String> list = new ArrayList<>(set);
        Collections.sort(list);

        String ret = "None";

        for(int i=0; i<list.size(); i++){
            String expected = ansList[i];
            String actual = list.get(i);

            if(!actual.equals(expected)){
                ret = expected;
                break;
            }
        }

        if(ret.equals("None") && list.size() < 26){
            System.out.println(ansList[list.size()]);
        } else {
            System.out.println(ret);
        }

    }

}

Measured memory_bytes: 28176
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let S: String = sc.get();
    if S == "Sunny" {
        println!("Cloudy");
    } else if S == "Cloudy" {
        println!("Rainy");
    } else {
        println!("Sunny");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int x,a,b;
	cin>>x>>a>>b;
	if(abs(x-a)>abs(x-b)){
		ce('B')
	}else{
		ce('A')
	}
}

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

main(){
  int N;
  int count2=0;
  cin >> N;
  
  
  for(int i=0; i*2+1 <= N ; i++){
    int odd = i*2+1;
    int count1 = 0;
    
   for(int j=1; j<=odd ;j++){
     if(odd%j==0) count1++;
   }
     if(count1==8) count2++;
  }
   
  cout << count2 <<endl;
}
       

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

using namespace std;

int n;
const int inf = int(1e9);
int s[100005];

int dp[100005];


int main() {
    cin >> n;
    for(int i=0;i<n;i++){
        cin>> s[i];
    }

    for(int i=1;i<n;i++){
        dp[i]=inf;
    }
    for(int i=0;i<n;i++){
        dp[i+1]=min(dp[i+1],dp[i]+abs(s[i]-s[i+1]));
        dp[i+2]=min(dp[i+2],dp[i]+abs(s[i]-s[i+2]));
    }

    cout << dp[n-1]<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 1123456789012345
using namespace std;

bool end(string str){
	rep(i, str.length()) if (str[i] != str[0]) return false;
	return true;
}

int main(){
	//firstが距離
	string s; cin >> s;
	ll ans = INF;
	rep(i, s.size()){
		char target = s[i];
		string temp_s = s;
		ll temp;
		ll count = 0;
		ll del;
		ll maxi;
		while (1){
			if (end(temp_s)) break;
			mrep(j, temp_s.length() - 2) if (temp_s[j] == target) temp_s[j + 1] = temp_s[j];
			if (temp_s[0] != target) maxi = 0;
			else{
				temp = 0;
				del = 0;
				maxi = 0;
				rep(i, temp_s.size()){
					if (temp_s[i] == target){
						if (del < temp){
							maxi = i;
							del = temp;
						}
						temp = 0;
					}
					else temp++;
				}if (i == temp_s.size() - 1){
					if (del < temp){
						maxi = i;
					}
				}
			}
			temp_s.erase(temp_s.begin()+ maxi);
			count++;
		}ans = min(count, ans);
	}cout << ans << endl;
	return 0;
}

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

int main(int argc, char *argv[])
{
    string input;
    int count;
    int index;
    while (cin >> input && input != "-")
    {
        cin >> count;
        for (int i = 0; i < count; i++)
        {
            cin >> index;
            input = input.substr(index) + input.substr(0, index);
        }
        cout << input << endl;
        input = "";
        count = 0;
        index = 0;
    }

    return 0;
}


Measured memory_bytes: 3124
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

INF = 10 ** 18

N = input()

ls = []
for i in range(N):
    H, P = map(int, raw_input().split())
    ls.append((H + P, H, P))

ls.sort()

DP = [INF] * (N + 1)
DP[0] = 0

for i in range(N):
    _, H, P = ls[i]
    for j in range(i, -1, -1):
        if DP[j] <= H and DP[j + 1] > DP[j] + P:
            DP[j + 1] = DP[j] + P

ans = 0
for i in range(N + 1):
    if DP[i] < INF:
        ans = i

print ans

Measured memory_bytes: 33256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<vi> g(h + 2, vi(w + 2, -1));
  rep2(i, 1, h + 1) rep2(j, 1, w + 1) {
    char c;
    cin >> c;
    if(c == '#') g[i][j] = 0;
  }
  bool ans = true;
  rep2(a, 1, h + 1) rep2(b, 1, w + 1) {
    if(g[a][b] != 0) continue;
    queue<pair<int, int>> q;
    q.push(P(a, b));
    g[a][b] = 1;
    bool ok = false;
    while(!q.empty()) {
      int i = q.front().first;
      int j = q.front().second;
      q.pop();
      rep(k, 4) {
        int ni = i + dir[k];
        int nj = j + dir[k + 1];
        if(g[ni][nj] != 0) continue;
        ok = true;
        g[ni][nj] = 1;
        q.push(P(ni, nj));
      }
    }
    if(!ok) ans = false;
  }
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	char s[3];
  	scanf("%s", s);
  	int price = 700;
  
  	for (int i = 0; i < 3; i++){
    	if (s[i] == 'o') {
        	price += 100;
        }
    }
  	printf("%d", price);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <iomanip>
#include <time.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;


int tile[1004][1004];

int main()
{
    int H,W;
    cin >> H >> W;
    int ch,cw,dh,dw;
    cin >> ch >> cw >> dh >> dw;
    ch++;cw++;dh++;dw++;

    
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            char c;
            cin >> c;
            if(c=='.') tile[i+2][j+2]=-1;
            else tile[i+2][j+2]=-2;
        }
    }

    int cnt=1,ans;
    queue<P> que,warp;
    que.push(P(ch,cw));
    while(true){
        bool flag=false;
        while(!que.empty()){
            P now=que.front();que.pop();
            warp.push(now);
            int h=now.first,w=now.second;
            tile[h][w]=cnt;
            if(tile[h+1][w]==-1){
                tile[h+1][w]=cnt;
                warp.push(P(h+1,w));
                que.push(P(h+1,w));
            }
            if(tile[h-1][w]==-1){
                tile[h-1][w]=cnt;
                warp.push(P(h-1,w));
                que.push(P(h-1,w));
            }
            if(tile[h][w+1]==-1){
                tile[h][w+1]=cnt;
                warp.push(P(h,w+1));
                que.push(P(h,w+1));
            }
            if(tile[h][w-1]==-1){
                tile[h][w-1]=cnt;
                warp.push(P(h,w-1));
                que.push(P(h,w-1));
            }
        }
        if(warp.empty()){
            ans=-1;
            break;
        }
        cnt++;
        while(!warp.empty()){
            P now=warp.front();warp.pop();
            int h=now.first,w=now.second;
            if(h==dh && w==dw){
                flag=true;
                break;
            }
            for(int i=-2; i<3; i++){
                for(int j=-2; j<3; j++){
                    if(tile[h+i][w+j]==-1 || tile[h+i][w+j]>cnt){
                        que.push(P(h+i,w+j));
                    }
                }
            }
        }
        if(flag){
            ans=cnt-2;
            break;
        }
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 10756
#include <iostream>

using namespace std;

int arraylength, array[10];

int main() {

    cin >> arraylength;
    for (int i=0; i<arraylength; i++){
        cin >> array[i];
    }

    int highest_item = array[0];
    int result = 0;


    for (int i = 0; i < arraylength; i++){
        result += array[i];
        if(array[i] > highest_item){
            highest_item = array[i];
        }
    }
    result -= highest_item/2;
    cout << result;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin>>x;
  int res=0;
  for(int i=0;i<100;i++){
    for(int k=0;k<100;k++){
      int total=i*7+k*4;
      if (total==x)res++;
    }
  }
  if(res>0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
    }


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#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 << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);


	string x;
	cin >> x;
	cout << x.substr(0, 3) << endl;;
}

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

using namespace std;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<ll, ll> pii;

const int mn = 2e5 + 5;
const int mod = 1e9 + 7;

void bye() {
    puts("No");
    exit(0);
}

int n, q;
ll m;

vector<pii> e0, e1;
vector<int> v;
int f[mn];

int sf(int x) { return f[x] == x ? x : f[x] = sf(f[x]); }

ll usedm = 0;

int main() {
#ifdef trote
    freopen("../1.txt", "r", stdin);
#endif
    scanf("%d%lld%d", &n, &m, &q);
    for (int i = 1; i <= q; i++) {
        int u, v, w;
        scanf("%d%d%d", &u, &v, &w);
        u++;
        v++;
        if (!w)
            e0.emplace_back(u, v);
        else e1.emplace_back(u, v);
    }
    for (int i = 1; i <= n; i++) f[i] = i;
    for (auto &i:e0) {
        if (sf(i.first) != sf(i.second)) f[sf(i.first)] = sf(i.second), usedm++;
    }
    // judge: if connected
    for (auto &i:e1) {
        if (sf(i.first) == sf(i.second)) bye();
    }
    for (int i = 1; i <= n; i++) if (sf(i) == i) v.pb(i);
    if (e1.empty()) {
        usedm += sz(v) - e1.empty();
    } else {
        if (sz(v) <= 2) bye();
        usedm += v.size();
    }
    ll maxim = usedm - sz(v) + e1.empty() + (ll) sz(v) * (sz(v) - 1) / 2;
    //printf("%lld %lld\n", usedm, maxim);
    if (m >= usedm && m <= maxim) puts("Yes");
    else bye();
    return 0;
}

Measured memory_bytes: 3188
with open(0) as f:
    N, *a = map(int, f.read().split())

from itertools import count
p = 0
seen = {0}
for i in count(1,1):
    p = a[p]-1
    if p == 1:
        ans = i
        break
    if p in seen:
        ans = -1
        break
    seen.add(p)
print(ans)

Measured memory_bytes: 22200
# Breadth First Search
from collections import deque
import sys
input = sys.stdin.readline
n = int(input())
E = (tuple(map(int, input().split())) for _ in range(n))
E = [[v-1 for v in V] for i, k, *V in E]

q = deque()
visited = [False]*n
D = [-1]*n

# 初期条件
s = 0
q.append(s)
visited[s] = True
D[s] = 0

# BFS
while q:
    v = q.popleft()
    for u in E[v]:
        if not visited[u]:
            q.append(u)
            visited[u] = True
            D[u] = D[v]+1


for i in range(n):
    print(i+1, D[i])



Measured memory_bytes: 6040
#include<stdio.h>

int main(void)
{
	int m,f,r;
	char grade;


	while(1){
		scanf("%d %d %d",&m,&f,&r);

		if(m==-1 && f ==-1 && r==-1)break;
		
		if( m == -1 || f == -1){
  			grade='F';
		}
		else{
			if(m + f >= 80)grade='A';
			if(m + f >= 65 && m + f < 80)grade='B';
			if(m + f >= 50 && m + f < 65)grade='C';
			if(m + f >= 30 && m + f < 50){
				if(r >=50){
					grade='C';
				}
				else{			
					grade='D';
				}
			}
			if(m + f < 30)grade='F';

			
		}
	printf("%c\n",grade);
	}
	return 0;
}
	
	

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int d, t, s; cin >> d >> t >> s;
    if (d <= t*s) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3584