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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

const int N = 1e5+100;
ll dp[N];
int arr[N];

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n, k; cin>>n>>k;
    for(i = 0; i < n; i++){
        cin>>arr[i];
        dp[i] = (1LL<<40);
    }
    dp[0] = 0;
    for(i = 1; i < n; i++){
        for(j = 1; j <= k && i - j >= 0; j++){
            dp[i] = min(dp[i] , dp[i-j] + abs(arr[i-j] - arr[i]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1408
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(ReadLine());
            long e = n - 1;
            long ans = (1 + e) * e / 2;
            WriteLine(ans);
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

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

using namespace std;

int main(){
    long long N,ans=0,A,B,C;
    string S;

    vector<long long> v(3);

    for (auto &x : v)
    {
        cin>>x;
    }

    sort(v.begin(),v.end());
    
    cout<<v[0]+v[1]<<endl;
}

Measured memory_bytes: 256
def printQueen(queen)
#  p queen
  8.times{|i|
    str = ""
    8.times{|j|
      if queen[i] == j then
        str << "Q"
      else
        str << "."
      end
    }
    puts str
  }
end

def setQueen(queen)
  idx = queen.index(nil)
  ref = [0,1,2,3,4,5,6,7] - queen
  if idx == nil then
    if check(queen) == 1 then
      printQueen(queen)
      exit
    end
    return
  end
  tmp = queen.clone
  ref.each{|j|
    tmp[idx] = j
    setQueen(tmp)
  }
end

def check(queen)
  8.times{|i|
    (i+1).upto(7){|j|
      return 0 if queen[i] == queen[j] || (queen[i] - queen[j]).abs == j - i
    }
  }
  return 1
end


n = gets.to_i
queen = Array.new(8){nil}

n.times{
  x, y = gets.split.map(&:to_i)
  queen[x] = y
}

setQueen(queen)

Measured memory_bytes: 8960
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int h = int.Parse(input[0]);
		long n = long.Parse(input[1]);
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long sum = 0;

    for(int i = 0; i < n; i++)
    {
      sum += nums[i];
    }

    if(sum >= h) Console.WriteLine("Yes");
    else Console.WriteLine("No");
	}
}

Measured memory_bytes: 17248
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int main() {
  string A, B, C;
  cin >> A >> B >> C;

  if (A[A.length() - 1] == B[0] && B[B.length() - 1] == C[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N,D;cin>>N>>D;
  ll ans = (N+2*D)/(2*D+1);
  cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
using namespace std;
int main() {
    int N, K;
    cin >> N >> K;
    bitset<100> b(0);
    for (int i = 0, d; i < K; i++) {
        cin >> d;
        for (int j = 0, A; j < d; j++) {
            cin >> A;
            b.set(A - 1);
        }
    }
    cout << N - b.count() << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL; 
typedef long double LD;

const int MAX	= 1e5 + 5;
const int LIM	= 3e5 + 5;
const int MOD	= 1e9 + 7;
const LD  EPS	= 1e-10;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define Assert(x)		{if(!(x)){cerr<<"Assertion failed at line "<<__LINE__<<": "<<#x<<" = "<<(x)<<"\n";exit(1);}}
#define inchar			getchar//_unlocked
#define outchar(x)		putchar(x)//_unlocked(x)

double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
template<typename T> void inpos(T &x){x=0;register T c=inchar();while(((c<48)||(c>57))&&(c!='-'))c=inchar();bool neg=0;\
if(c=='-')neg=1;for(;c<48||c>57;c=inchar());for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x=-x;}
template<typename T> void outpos(T n){if(n<0){outchar('-');n*=-1;}char snum[65];int i=0;do{snum[i++]=n%10+'0';n/=10;}\
while(n);i=i-1;while(i>=0)outchar(snum[i--]);outchar('\n');}
inline void instr(char *str){register char c=0;register int i=0;while(c<33)c=inchar();while(c!='\n'&&c!=' '&&c!=EOF){\
str[i]=c;c=inchar();++i;}str[i]='\0';}
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
int add(int a, int b, int c){int res=a+b;return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mul(int a, int b, int c){LL res=(LL)a*b;return(res>=c?res%c:res);}
LL mulmod(LL a,LL b, LL m){LL q = (LL)(((LD)a*(LD)b)/(LD)m);LL r=a*b-q*m;if(r>m)r%=m;if(r<0)r+=m;return r;}
template<typename T>T expo(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}

long long getSum(int n)
{
    long long sum;
 
    for (sum = 0; n > 0; sum += n % 10, n /= 10);
 
    return sum;
}

int main() {
	/*#ifndef ONLINE_JUDGE
		freopen("inp.txt", "r", stdin);
		freopen("output.txt","w", stdout);
	#endif*/
		int n;cin>>n;
	long long s=getSum(n);
	if(n%s==0) cout<<"Yes"<<"\n";
	else cout<<"No\n";
	 //cout<<"Execution time : "<<tick()<<"\n";
	return 0;
}


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

using namespace std;

int n, k;
vector<int> a,b;

int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if (x >= 0) a.push_back(x);
        else b.push_back(-x);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    int p = 1e9;
    for (int i = 0; i <= k && i <= a.size(); i++) {
        if (k-i > b.size()) continue;
        int s1 = i == 0 ? 0 : a[i-1];
        int s2 = k-i == 0 ? 0 : b[k-i-1];
        p = min(p,s1+s2+min(s1,s2));
    }
    cout << p << "\n";
}




Measured memory_bytes: 1020
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<char>> G(H, vector<char>(W));

    int cnt = 0;
    rep(i, H) {
        rep(j, W) { cin >> G[i][j]; }
    }

    for (int bit = 0; bit < (1 << H); ++bit) {
        vector<int> HH;
        for (int i = 0; i < H; ++i) {
            if (bit & (1 << i)) { // 列挙に i が含まれるか
                HH.push_back(i);
            }
        }

        for (int bbit = 0; bbit < (1 << W); ++bbit) {
            vector<int> WW;
            for (int j = 0; j < W; ++j) {
                if (bbit & (1 << j)) { // 列挙に i が含まれるか
                    WW.push_back(j);
                }
            }

            vector<vector<char>> GG = G;
            rep(a, HH.size()) {
                int col = HH[a];
                rep(b, W) { GG[col][b] = 'x'; }
            }

            rep(c, WW.size()) {
                int row = WW[c];
                rep(d, H) { GG[d][row] = 'x'; }
            }

            int tmp = 0;
            rep(e, H) {
                rep(f, W) {
                    if (GG[e][f] == '#')
                        tmp++;
                }
            }

            if (tmp == K)
                cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD1 1000000007
#define MOD2 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ll t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<ll,ll> pii;
ll powe(ll n,ll m){if(m==0)return 1;if(m<0) return 0;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m,ll MOD){if(m==0)return 1;ll t=mpowe(n,m/2,MOD);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;if(n==0) return -1;return logtwo(n/2)+1;}
int main()
{

    string s,t;
    cin>>s>>t;
    int n = t.size();
    s = s + t[n-1];
    if(s==t)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cctype>
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;

const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define sort_all(v) sort(v.begin(), v.end())
#define fill(a) memset(a, 0, sizeof(a))

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


void test() {
    int N;
    cin >> N;
    vll a(N);
    ll sum = 0;
    REP(i, N) {
        cin >> a[i];
        sum += a[i];
    }
    ll ans = 0;
    REP(i, N) {
        sum = sum - a[i];
        ans = ((ans % MOD) + (((a[i] % MOD) * (sum % MOD)) % MOD)) % MOD;
    }
    ans %= MOD;
    cout << ans;
}   
 
int main ()     
{
    // int t;
    // cin >> t;
    // while(t--) 
        test();
}


Measured memory_bytes: 4840
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int H,W; cin >> H >> W;
    int h,w; cin >> h >> w;
    int ans;
    ans = H * W - h * W - w * H + h * w;
    cout << ans << endl;

}


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

#define fr(i,a,b) for(ll i=a;i<b;i++)
#define ffr(i,a,b) for(ll i=a;i>=b;i--)
#include<bits/stdc++.h>
#include<vector>
#define vl vector<ll>
//const ll N=1e5+5;



int main(){
    ll a[5],p;
  fr(i,0,5){
    cin>>a[i];
    if(a[i]==0)
      p=i;
  }
  cout<<p+1;
	return 0;
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-


while n = gets
  n = n.chomp.to_i
  ans = 0

  i = 0
  for i in (0..9)
    for j in (0..9)
      for k in (0..9)
        for l in (0..9)
          ans+=1 if i+j+k+l == n
        end
      end
    end
  end

  puts ans
end

Measured memory_bytes: 6096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
 
int main() {
	ll n;
	vector<int>a;
	cin>>n;
	if(n==0){
		cout << 0;
		return 0;
	}
	while(n){
		a.push_back(abs(n)%2);
		if(n<0){
			n=(abs(n)+1)/2;
		}
		else{
			n/=2;
			n*=-1;
		}
	}
	for(int i=a.size()-1;i>=0;i--){
		cout << a[i];
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define INF (1LL << 40)
using namespace std;
typedef long long ll;

int main() {
    ll N, min_number = 0LL, near_num = INF;
    ll A, T, H;
    cin >> N >> T >> A;
    T *= 1000LL;
    A *= 1000LL;
    for (int i = 0; i < N; i++) {
        cin >> H;
        ll avg_num = T - H * 6LL;
        ll stride;
        if (avg_num > A) stride = avg_num - A;
        else stride = A - avg_num;
        if (stride < 0) stride *= -1LL;
        if (stride < near_num) {
            min_number = i + 1;
            near_num = stride;
        }
    }
    cout << min_number << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
#define MOD (1000000007ll)
#define l_ength size

int main(void){
	ll n,k,i,ans=0ll;
	cin >> n >> k;
	if(k){
		for(i=(k+1); i<=n; ++i){
			ans += (n/i)*(i-k);
			ans += max(0ll,((n%i)-k+1));
		}
	}else{
		ans = n * n;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin >> n;
  bool ok = false;
  ok |= (n % 10 == 7);
  n /= 10;  
  ok |= (n % 10 == 7);
  n /= 10;  
  ok |= (n % 10 == 7);
  n /= 10;  
  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3612
s = input().rstrip()
k = int(input())
for i in range(len(s)):
    if s[i] == "a":
        continue
    cost = ord("z") - ord(s[i]) + 1
    if cost <= k:
        k -= cost
        s = s[:i] + "a" + s[i+1:]
s = s[:-1] + chr((ord(s[-1]) - ord("a") + k) % 26 + ord("a"))
print(s)

Measured memory_bytes: 3424
def popcount(x):
    return bin(x).count('1')

def f(x):
    if x == 0:
        return 1
    return f(x%popcount(x))+1

n=int(input())
x=input()
xx=int(x,2)
p=x.count('1')
s=xx%(p+1)
if p!=1:
    t=xx%(p-1)
for i in range(n):
    if x[i]=='1':
        if p!=1:
            k=t
            k-=pow(2,n-i-1,p-1) 
            k%=p-1
        else:
            print(0)
            continue
    else:
        k=s
        k+=pow(2,n-i-1,p+1)
        k%=p+1
    print(f(k))

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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    string S;
    cin >> S;
    bool flag = true;
    if (S[0] != 'A') flag = false;
    int count = 0;
    REP(i, S.size()){
        if (S[i] == 'C'){
            ++count;
            if (i <= 1 || S.size() - 1 <= i) flag = false;
        }
    }
    if (count != 1) flag = false;
    REP(i, S.size()){
        if (S[i] != 'A' && S[i] != 'C' && !islower(S[i])) flag = false;
    }
    if (flag){
        puts("AC");
    }else{
        puts("WA");
    }
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }


    val connectedLump = mutableListOf<MutableList<Int>>()
    for (i in 0 until n) {
        connectedLump.add(mutableListOf())
    }



    for (i in 0 until m){
        val inputs = readLine()!!.split(" ").map { it.toInt() }
        for (j in 1 until inputs.size) {
            connectedLump[inputs[j]-1].add(i)
        }
    }

    val condition = readLine()!!.split(" ").map { it.toInt() }

    var countAns = 0
    val lumpStatus = IntArray(m){0}.toMutableList()

    fun updateStatus(count: Int, mem: MutableList<Int>) {

        if (count == n){
            for(i in 0 until mem.size) {
                if (mem[i]%2 != condition[i]) {
                    return
                }
            }
            countAns += 1
            return
        }

        // スイッチを入れる場合
        val memTemp = mem.toMutableList()
        for (l in connectedLump[count]){
            memTemp[l] += 1
        }
        updateStatus(count+1, memTemp)

        // スイッチを入れない場合
        val memTempOff = mem.toMutableList()
        updateStatus(count+1, memTempOff)
    }

    updateStatus(0, lumpStatus)

    println(countAns)
}

Measured memory_bytes: 37956
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int a[m];
	string s[m];
	for(int i=0;i<m;i++)
	{
		cin>>a[i];
		cin>>s[i];
	}
	int co=0;
	int p=0;
	int b[n],c[n];
	for(int i=0;i<n;i++)
	{
		b[i]=0;
		c[i]=0;
	}
	for(int i=0;i<m;i++)
	{
		if(s[i]=="WA"&&b[a[i]-1]!=-1)
		{
			b[a[i]-1]++;
		}
		if(s[i]=="AC"&&c[a[i]-1]!=1)
		{
			co++;
			p+=b[a[i]-1];
			c[a[i]-1]=1;
			b[a[i]-1]=-1;
		}
	}
	cout<<co<<" "<<p<<endl;
	return 0;
}

Measured memory_bytes: 6912
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cassert>
#include <queue>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define fst first
#define snd second
#define SZ(x) ((int)x.size())
typedef long long ll;
#define dforn(i, n) for(int i = n - 1; i >= 0; i--)

const int MAXN = 300300;

int n, add[MAXN];
char s[MAXN];

int query(int p){
  return (p - add[p]) + add[n]-add[p+1];
}

int main() {
  //~ freopen("input.in", "r", stdin);
  while( scanf("%d %s", &n, s) >= 1 ){
    memset(add, 0, sizeof add);
    forn(i, n){
      add[i+1] = add[i] + (s[i] == 'E');
    }
    int ans = MAXN;
    forn(i, n){
      ans = min(ans, query(i));
    }
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <vector>
#include <climits>
#include <cmath>
#include <stdlib.h>

using namespace std;

int main()
{
    int x, n;
    cin >> x >> n;
    vector<int> v(101, 0);
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        v[a] = 1;
    }
    int diff = INT_MAX, ans;
    for (int i = 101; i >= 0; i--)
    {
        if (!v[i])
        {
            if (diff >= abs(i - x))
            {
                diff = abs(i - x);
                ans = i;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main(){
    int A,B,C,D;
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);
    scanf("%d",&D);
    while(1){
        C-=B;
        if(C<=0){
            printf("Yes");
            break;
        }
        A-=D;
        if(A<=0){
            printf("No");
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1728
n,m=gets.split.map &:to_i
plans=Array.new(m){Array.new(2)}
m.times do |i|
    plans[i]=gets.split.map &:to_i
end
cnt=0
plans.sort_by!{|ary| ary[1]}
until plans.empty?
    tmp=plans[0][1]
    loop do
        if plans.length!=0 && plans[0][0] < tmp 
            plans.delete_at(0)
        else
            cnt += 1
            break
        end
    end
end

puts cnt

Measured memory_bytes: 20216
#include<iostream>
int main()
{
    char poem[20],input;
    for(int i=0;i<17;){
        input=getchar();
        if(input==',') continue;
        poem[i]=input;i++;
    }
    for(int i=0;i<5;i++)
        std::cout<<poem[i];
    std::cout<<" ";
    for(int j=5;j<12;j++)
        std::cout<<poem[j];
    std::cout<<" ";
    for(int j=12;j<17;j++)
        std::cout<<poem[j];
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.reverse()
p = 1
c = 0
d = 0
for i in range(n):
    if a[i] == b[i]:
        v = a[i]
        h = i
        p = 0
        break
if p == 1:
    print('Yes')
    for i in range(n):
        print(b[i],end = ' ')
else:
    for i in range(n):
        if a[i] != v and b[i] != v:
            c += 1
        if b[i] == a[i] :
            d += 1
    if c < d:
        print('No')
    else:
        print('Yes')
        o = 0
        for i in range(n):
            if a[i] != v and b[i] != v:
                b[i],b[h+o] = b[o+h],b[i]
                o += 1
                if o == d:
                    break
        for i in range(n):
            print(b[i],end = ' ')

Measured memory_bytes: 105104
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return abs(a * b) // gcd(a, b)


def main():
    n = int(input())
    ts = [int(input()) for _ in range(n)]
    res = ts[0]
    for t in ts[1:]:
        res = lcm(res, t)
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;
ll M = 1e18;



int main(){
    
    int n;
    cin>>n;
    vector<ll> A(n);
    ll ans=1;
    bool zero=false;
    
    rep(i,n) {
        cin>>A[i];
        if(A[i]==0) zero=true;
    }
    //ゼロ含むとき
    if(zero){
        cout<<0<<endl;
        return 0;
    }
    rep(i,n){
        // オーバーフロー
        if(M/A[i] < ans){
            cout<<-1<<endl;
            return 0;
        }
        ans*=A[i];
    }
    //オーバーフロー起こさずe18より大きい
    if(ans>M){
        cout<<-1<<endl;
        return 0;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////


int main(){fastio
    ll n,m;cin>>n>>m;
    vector<ll>s[n];
    rep(i,0,m-1){
        ll k;cin>>k;
        while(k--){
            ll a;cin>>a;a--;
            s[a].pb(i);
        }
    }
    /*rep(j,0,n-1){
        cout<<j<<":";for(auto x:s[j])cout<<x<<" ";cout<<endl;
    }*/
    ll p[m];
    rep(i,0,m-1)cin>>p[i];
    ll ans=0;
    rep(i,0,(1<<n)-1){
        ll c[m];memset(c,0,sizeof(c));
        rep(j,0,n-1){
            if((i>>j)&1){
                for(auto x:s[j])c[x]++;
            }
        }
        bool flag=true;
        rep(j,0,m-1){
            if(c[j]%2!=p[j]%2)flag=false;
        }
        //cout<<flag<<" ";
        if(flag)ans++;
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stdio.h>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <assert.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))

using namespace std;

const double eps = 1e-8;

#define PB push_back
#define MP make_pair

typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int,int> PII;
typedef long long int64;
typedef long long LL;
typedef unsigned int UI;
typedef long double LD;
typedef unsigned long long ULL;

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

    if (n == 1) {
        cout << 0 << endl;
        return 0;
    }

    set<LL> res;
    for (int i = 1; i <= 2000000 && i < n; ++i) {
        if ((n - i) % i == 0) {
            res.insert((n - i) / i);
        }
    }

    for (int i = 1; i <= 2000000; ++i) {
        if (n % (i + 1) == 0) {
            LL val = n / (i + 1);
            if (val < n) {
                res.insert(i);
            }
        }
    }

    LL ans = 0;
    TR(it, res) if (n / *it == n % *it) ans += *it;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
num = input().split()
r = input()

for i in r:
    temp = num[0]
    if (i == 'W'): 
        num[0] = num[2]
        num[2] = num[5]
        num[5] = num[3]
        num[3] = temp
    elif (i == 'E'):
        num[0] = num[3]
        num[3] = num[5]
        num[5] = num[2]
        num[2] = temp
    elif (i == 'S'):
        num[0] = num[4]
        num[4] = num[5]
        num[5] = num[1]
        num[1] = temp
    else :
        num[0] = num[1]
        num[1] = num[5]
        num[5] = num[4]
        num[4] = temp

print(num[0])


Measured memory_bytes: 5560
#include <bits/stdc++.h>
using namespace std;
int main(){
long long int N, A, B; 
cin >> N >> A >> B; 
if(N == 1 && A == B){
cout << 1 << endl; 
}
else if(N == 1 && A != B){
cout << 0 << endl; 
}
else if(A > B){
cout << 0 << endl; 
}
else{
cout << (N-2) * (B - A) + 1 << endl; 
}
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  for(;;){
	int N; cin >> N;
	if(!N) break;
	VI a(N);
	REP(i,N) cin >> a[i];
	SORT(a);
	cout << accumulate(a.begin()+1, a.end()-1, 0) / (N - 2) << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.concurrent.CountDownLatch;

public class Main {

	public static void main(String args[]) {

		Scanner scanner = new Scanner(System.in);

		String aString =  scanner.next();
		
		
		if(aString.charAt(0) >= 97 ) {
			System.out.println("a");
		} else {
			System.out.println("A");
		}
		
		
	}}

Measured memory_bytes: 35704
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const char t[]={"0CODEFESTIVAL2016"};
char s[25];int res;
int main(){
	scanf("%s",s+1);
	fp(i,1,16)res+=s[i]!=t[i];
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,x,n) for(Int i=x; i<n; ++i)
#define INF LLONG_MAX
using Int = long long;
using uInt = unsigned long long;
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) { a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) { a=b; return true;} return false;}
Int N, W;
Int w[101], v[101], dp[110][100100];

Int rec(int i, int j) {
  if(dp[i][j] >= 0) {
    return dp[i][j];
  }

  Int ret;
  if(i == N) {
    ret = 0;
  } else if (j < w[i]) {
    ret = rec(i+1, j);
  } else {
    ret = max(rec(i+1, j), rec(i+1, j-w[i])+v[i]);
  }
  return dp[i][j] = ret;
}

int main() {
  cin >> N >> W;
  rep(i, 0, N) cin >> w[i] >> v[i];
  memset(dp, -1, sizeof(dp));
  printf("%lld\n", rec(0, W));
}


Measured memory_bytes: 86272
/*
	LINES :
		* multiple of 9
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;


#define pb push_back
#define F first
#define S second
#define WLL(t) while(t--)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define STF(i, a, b) for(size_t i = a; i < b; i++)
#define RFOR(i, a, b) for(int i = a; i >= b; i--)
#define SRF(i, a, b) for(size_t i = a;i >= b;i--)
#define ALL(v) v.begin(),v.end()
#define PRECISION(x) cout<<fixed<<setprecision(x)
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define READ freopen("input.txt", "r", stdin)
#define WRITE freopen("output.txt", "w", stdout)
#define MOD 1000000007

#define TO(v, type) static_cast<type>(v)

int main() {
#ifdef OJ
	READ;
	WRITE;
#endif
	string num;
	cin >> num;
	int sum{};
	FOR(i, 0, num.size()) {
		sum += num[i] - '0';
	}
	if (sum % 9 == 0)
	{
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}

}

Measured memory_bytes: 3640
from collections import Counter
n = int(input())
V = list(map(int,input().split()))
A = Counter(V[0::2]).most_common(2)
B = Counter(V[1::2]).most_common(2)
A.append((0,0))
B.append((0,0))
if A[0][0]!=B[0][0]:
    print(n-(A[0][1]+B[0][1]))
else:
    print(min(n-(A[1][1]+B[0][1]),n-(A[0][1]+B[1][1])))


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;



int main() {
	string ym,ym1,ym2;

	cin >> ym;

	ym1 = ym.substr(0, 2);
	ym2 = ym.substr(2, 2);

	if ("01" <= ym1 && ym1 <= "12") {
		if ("01" <= ym2 && ym2 <= "12") {
			cout << "AMBIGUOUS";
		}
		else {
			cout << "MMYY";
		}
	}
	else{
		if ("01" <= ym2 && ym2 <= "12") {
			cout << "YYMM";
		}
		else {
			cout << "NA";
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct Node{
  int key;
  Node *parent,*left,*right;
};

Node *root,*NIL;

void Preorder(Node *pp){
  if(pp==NIL)return;
  cout<<" "<<pp->key;
  Preorder(pp->left);
  Preorder(pp->right);
}
void Inorder(Node *in){
  if(in==NIL)return;
  Inorder(in->left);
  cout<<" "<<in->key;
  Inorder(in->right);
}

void insert(int k){
  Node *z;
  Node *y=NIL; //x's parent
  Node *x=root; //T's root
  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(1){
    if(x==NIL)break;
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else {
    if(z->key<y->key){
      y->left=z;
    }
    else {
      y->right=z;
    }
  }
}
int main(){
  int n=0,in=0,j=0;
  int i=0;
  char cel[10];
  cin>>n;
  for(i=0;i<n;i++){
    cin>>cel;
    if(!strcmp(cel, "insert")){
      cin>>in;
      insert(in);
    }
    else if(!strcmp(cel, "print")){
      Inorder(root);
      cout<<endl;
      Preorder(root);
      cout<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 26480
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
const ll mo=1000000007;
const ll INF=1<<30;
ll ans=0;
vector<ll> G[200010];
int d[200010];

void dist(int v){
    rep(i,G[v].size()){
        if(d[G[v][i]]==INF){
            d[G[v][i]]=d[v]+1;
            dist(G[v][i]);
        }
    }
}

int main()
{ 
ll n;
cin >> n; 
for (int i = 0; i < n-1; i++) {
    int L, R;
    cin >> L >> R ;
    L--; R--;
    G[L].push_back(R);
    G[R].push_back(L);
}

rep(i,n){
    d[i]=INF;
}
d[0]=0;
dist(0);
ll max=0,x;
rep(i,n){
    if(max<d[i]){
        max=d[i];
        x=i;
    }
}

rep(i,n){
    d[i]=INF;
}
d[x]=0;
dist(x);
max=0;
rep(i,n){
    if(max<d[i]){
        max=d[i];
        x=i;
    }
}
max++;
//cout << max << endl;
if(max%3==2)cout << "Second" << endl;
else cout << "First" << endl;

/* for (int i = 0; i < n; ++i) {
    cout << d[i] << " ";
}cout  << endl; */


return 0;
} 

Measured memory_bytes: 21376
H,W=map(int,input().split())
if H==1 or W==1:
    print(1)
elif H==W and (H%2)==1:

    print(int(-(-(H*W)//2)))
elif H==2:

    print(W)
elif W==2:
    print(H)
elif H%2==0 and W%2==0:

    print(int(W*H/2))
elif H%2==1 and W%2==1:
    mas=-(-W//2)
    nextmas=mas-1
    Sset=int(H/2)
    amari=H%2


    num=(mas+nextmas)*Sset

    num+=mas*amari

    print(int(num))


else:
    
    print(int(H*W/2))


Measured memory_bytes: 3064
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        sb.Append((str[0] == str[1] ? 'H' : 'D') +"\n");
    }
}

Measured memory_bytes: 11092
#include<stdio.h>

int main(void){
  int N=0,A=0;
  int n=0;
  
  scanf("%d",&N);
  scanf("%d",&A);
  
  n = N % 500;
  
  if(n<=A)
    printf("Yes");
  else if(n>A)
    printf("No");

  return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
int N, Y;

int main() {
    cin >> N >> Y;
    for(int a = 0; a <= N; a++){
        for(int b = 0; b <= N - a; b++){
            int c = N - a - b;
            int sum = a * 10000 + b * 5000 + c * 1000;
            if(sum == Y){
                cout << a << ' ' << b << ' ' << c << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def main():
    N = int(input())
    A = []
    for i in range(N):
        A.append(int(input()))
    now = 1
    check = [0]*N
    ans = 0
    # while(1):
    for k in range(N):
        if now == 2:
            print(ans)
            return
        # if check[now-1] == 1:
        #     print(-1)
        #     return
        else:
            check[now-1] = 1
        now = A[now-1]
        ans += 1
        # print(now)
    print(-1)
    return
        
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 13756
// AOJ ITP2_1_D: Vector II
// 2018.6.24 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct { char id; int t; char x[13]; } BUF;
BUF buf[500005];
int qend[1002];
int *Q[1002];
char a[30];

int main()
{
	int n, q, i, j, t;
	char *p, *r;
	
	fgets(a, 30, stdin);
	n = atoi(a);
	p = a; while (*p >= '0') p++; q = atoi(p+1);
	for (i = 0; i < q; i++) {
		fgets(a, 30, stdin);
		buf[i].id = a[0];
		t = 0, p = a+2;
		while (*p >= '0') t = 10*t + (*p++ & 0xf);
		buf[i].t = t;
		if (a[0] == '0') {
			qend[t]++;
			p++, r = p+1;
			while (*r >= '0') r++; *r = 0;
			strcpy(buf[i].x, p);
		}
	}
	for (i = 0; i < n; i++) if (qend[i] > 0) {
		Q[i] = malloc(qend[i]*sizeof(int)), qend[i] = 0;
	}
	for (i = 0; i < q; i++) {
		t = buf[i].t;
		if (buf[i].id == '0') Q[t][qend[t]++] = i; // pushBack
		else if (buf[i].id == '1') {
			if (qend[t] > 0) {    // dump
				printf(buf[Q[t][0]].x);
				for (j = 1; j < qend[t]; j++)
					putchar(' '), printf(buf[Q[t][j]].x);
			}
			putchar('\n');
		}
		else qend[t] = 0;         // clear
	}
	return 0;
}


Measured memory_bytes: 15432
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	while (true) {
		int n; cin >> n;
		if (n == 0)break;

		bool left = true, right = true, flag = true;
		int cnt = 0;
		rep(loop, n) {
			string s; cin >> s;
			if (s == "lu")left = false;
			if (s == "ru")right = false;
			if (s == "ld")left = true;
			if (s == "rd")right = true;

			if (left&&right && !flag) { flag = true; cnt++; }
			else if (!left && !right&&flag) { flag = false; cnt++; }
		}
		cout << cnt << endl;
	}
}


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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	if (n%2==0)
	{
		printf("0.500000\n");
	}
	else
	{
		int m=n/2+1;
		printf("%.6f\n", (double)(int)m/n);
	}
	return 0;
}


Measured memory_bytes: 256
void main(){
	int a, b, x;
	scanf("%d %d %d", &a, &b, &x);
	writeln(a+b>=x&&a<=x?"YES":"NO");
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


Measured memory_bytes: 2540
<?php
$n = (int)trim(fgets(STDIN));
$A = array_map('intval', explode(" ", trim(fgets(STDIN))));
$q = (int)trim(fgets(STDIN));
$Ms = array_map('intval', explode(" ", trim(fgets(STDIN))));

// dp table
for ($i = 0; $i < $n; $i++) {
    $dp[] = array_fill(0, 2001, null);
}

function solve($p, $t) {
    if ($t === 0) {
        return true;
    }
    
    global $n;
    if ($t < 0 || $p >= $n) {
        return false;
    }
    
    global $dp;
    $memo = $dp[$p][$t];
    if ($memo !== null) {
        return $memo;
    }
    
    global $A;
    $ans = solve($p + 1, $t - $A[$p]) || solve($p + 1, $t);
    $dp[$p][$t] = $ans;
    return $ans;
}

$ans = "";
foreach ($Ms as $M_i) {
    if (solve(0, $M_i)) {
        $ans .= "yes\n";
    } else {
        $ans .= "no\n";
    }
}

print $ans;


Measured memory_bytes: 14416
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define endl "\n"
#define inf 1e18

void solve(int tt){
	int n; cin>>n;
	ll a[n], b[n];
	map<ll,int> m;
    for(int i=0;i<n;i++){
    	cin>>a[i];
    	b[i] = i-a[i];
    	m[i+a[i]]++;
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		ans += m[b[i]];
	}
	cout<<ans<<endl;
}

int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve(i);
	return 0;
}

Measured memory_bytes: 29488
#include<stdio.h>

int main(){
  int c, r, i, j;
  int table[101][101] = { 0 };
  scanf("%d %d",&c,&r);
  
  for(i = 0; i < c; i++){
    for(j = 0; j < r; j++){
      scanf("%d",&table[i][j]);
	  table[i][r] += table[i][j];
	  table[c][j] += table[i][j];
	  table[c][r] += table[i][j];
    }
  }

  for(i = 0; i <= c; i++){
	for(j = 0; j <= r; j++){
	  printf("%d",table[i][j]);
	  
	  if(r > j) printf(" ");
	}
	printf("\n");
  }
  return 0;
}

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

ll n, ans;
ll const DIV = 1000000007;

int main() {
  cin >> n;
  vector<vector<vector<ll>>> dp(n, vector<vector<ll>>(2, vector<ll>(2, 0)));
  dp[0][0][0] = 8;
  dp[0][1][0] = 1;
  dp[0][0][1] = 1;
  rep (i, n-1) {
    dp[i+1][0][0] = dp[i][0][0] * 8;
    dp[i+1][0][0] %= DIV;
    dp[i+1][0][1] = dp[i][0][1] * 9 + dp[i][0][0];
    dp[i+1][0][1] %= DIV;
    dp[i+1][1][0] = dp[i][1][0] * 9 + dp[i][0][0];
    dp[i+1][1][0] %= DIV;
    dp[i+1][1][1] = dp[i][1][0] + dp[i][0][1] + dp[i][1][1] * 10;
    dp[i+1][1][1] %= DIV;
  }
  cout << dp[n-1][1][1] << endl;
  return 0;
}


Measured memory_bytes: 151560
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll a,b,c,d;
    string s,t;

    cin >> a;// >> b>> c >> d;
    //cin >> s >> t;
    if (a % 10 == 9) {cout << "Yes" << endl;}
    else if (89<a&&a<100) {cout << "Yes" << endl;}
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256