akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let  s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
	let n: usize;
	let a: Vec<usize>;
	
	input! {
		n:usize,
		a:[usize ; n],
	}
	
	let m: Vec<bool> = a.iter()
		.filter(|&&x| x % 2 == 0)
		.map(|&x| x % 3 == 0 || x % 5 == 0)
		.filter(|&x| !x)
		.collect();
	
	println!("{}", if m.len() == 0 { "APPROVED" } else { "DENIED" })
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI 3.14159265358979323846

double angleClock(int hour, int minutes) {
        double hourAngle = ((hour % 12) + minutes * 1.0/60) * 30;
        double minutesAngle = minutes * 6;
        double a = abs(hourAngle - minutesAngle);
        double b = 360 - a;
        return a < b ? a : b;
    }
int main(){
    IO;
    double a,b,h,m;

    cin>>a>>b>>h>>m;

    double k = angleClock(h,m);
    // float tmp = m/2;
    // double angle = abs((30*h)-(11*tmp));
    // angle = min(angle,360-angle);

    // cout<<setprecision(2)<<angle<<endl;
    double aa = k*PI;
    double bb = aa/180.0;

    long double ans = sqrt(a*a+b*b-2*a*b*cos(bb));
    cout<<setprecision(20)<<ans<<endl;

    return 0;
}





Measured memory_bytes: 4240
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n);
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end());
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define reverse(a)      reverse((a).begin(), (a).end());
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d);
#define outl(d)         std::cout<<(d)<<"\n";
#define Yes()           printf("Yes\n");
#define No()            printf("No\n");
#define YES()           printf("YES\n");
#define NO()            printf("NO\n");
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int a, b; cin >> a >> b;
  cout << (a + b) % 24 << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12)

  solve();
}


Measured memory_bytes: 256
H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]
ans = ""
for i in range(H+2):
  for j in range(W+2):
    if 1 <= i <= H and 1 <= j <= W:
      ans += a[i-1][j-1]
    else:
      ans += '#'
  ans += "\n"
print(ans)

Measured memory_bytes: 67712
h, w = map(int, input().split())

a = [[0] * h for j in range(w)]
for y in range(h):
    for x, b in enumerate(map(int, input().split())):
        a[x][y] = b


ret = []
cnt = 0
for y in range(h):
    for x in range(w - 1):
        if a[x][y] % 2 == 1:
            a[x+1][y] += 1
            cnt += 1
            ret.append("{} {} {} {}".format(y+1, x+1, y+1, x+2))

for y in range(h - 1):
    if a[-1][y] % 2 == 1:
        a[-1][y+1] += 1
        cnt += 1
        ret.append("{} {} {} {}".format(y+1, w, y+2, w))

print(cnt)
for i in ret:
    print(i)

Measured memory_bytes: 16048
#include<stdio.h>
#define N 100000
#define NIL -1

typedef struct{

  int pid;//親のID
  int leftc;//自分の子供の一番左の子
  int rights;//自分のすぐ右隣の兄弟
  
}Rooted;

int type(int,int);
int depth(int,int);

Rooted data[N];
int D[N];

int main(){

  int i,j,t,n,id,c,k,oldc,root;

  scanf("%d",&n);//接点の数

  for(i=0;i<n;i++){
    data[i].pid=NIL;
    data[i].leftc=NIL;
    data[i].rights=NIL;
  }

  for(i=0;i<n;i++){

    scanf("%d%d",&id,&k);

    for(j=0;j<k;j++){

      scanf("%d",&c);

      data[c].pid=id;

      if(j==0){
	data[id].leftc=c;
      }

      if(j>=1){
	data[oldc].rights=c;
      }

      oldc=c; 

    }//for

  }//for

  c=-1;

  for(i=0;i<n;i++){

    if(data[i].pid==NIL){
      root=i;
    }
    
  }

  depth(root,0);

  for(i=0;i<n;i++){

    printf("node %d: ",i);

    printf("parent = %d, ",data[i].pid);

    printf("depth = %d, ",D[i]);

    t=type(data[i].pid,data[i].leftc);
    if(t==-1) printf("root, ");
    else if(t==0) printf("leaf, ");
    else printf("internal node, ");

    printf("[");

    if(data[i].leftc!=NIL){

      printf("%d",data[i].leftc);

      c=data[data[i].leftc].rights;

	while(c!=NIL){
	  printf(", %d",c);
	  c=data[c].rights;
	 
	}

   
     

    }//if

    printf("]\n");

  }//for

  return 0;
  
}

int type(int pid,int leftc){
  if(pid==-1) return -1;
  else if(leftc==-1) return 0; 
  else return 2;
}

int depth(int i,int dep){

  D[i]=dep;

  if(data[i].rights!=NIL){
    depth(data[i].rights,dep);
  }

  if(data[i].leftc!=NIL){
    depth(data[i].leftc,dep+1);
  }
  
  
}



Measured memory_bytes: 6412
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string t="hello";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define srch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    string a;
    while(cin>>a)
    {
        x=a.at(0)-'0';
        x=x*10+(a.at(1)-'0');
        y=a.at(2)-'0';
        y=y*10+(a.at(3)-'0');
        if(x>=1&&x<=12&&y>=1&&y<=12)
            cout<<"AMBIGUOUS"<<en;
        else if(x>=1&&x<=12)
            cout<<"MMYY"<<en;
        else if(y>=1&&y<=12)
            cout<<"YYMM"<<en;
        else cout<<"NA"<<en;
    }
}



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

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using ull = unsigned long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vs = vector<string>;
using vvs = vector<vs>;
using vc = vector<char>;
using vvc = vector<vc>;
using ii = pair<int,int>;
using vii = vector<ii>;
using vvii = vector<vii>;
using dd = pair<double, double>;
using vdd = vector<dd>;
using vvdd = vector<vdd>;
using Mii = map<int,int>;
using vMii = vector<Mii>;
using Si = set<int>;
using vSi = vector<Si>;
using vvSi = vector<vSi>;

#define fi first
#define se second
#define INF 1e9 + 5
#define mod(a,m) (a%m+m)%m
#define PB push_back
#define MP make_pair

int main(){
//	cout.setf(ios::fixed);
//	cout.precision(4);
	int n;
	while(cin >> n) {
		string s;
		cin >> s;
		int ans = 0;
		for (int i = 0; i < n; ++i) {
			if(i == 0 or s[i] != s[i-1]) ans++;
		}
		cout << ans << endl;
	}
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define long long long
#define ull unsigned long long
#define up(i,a,b) for (int i=a; i<=b; i++)
#define down(i,a,b) for (int i=a; i>=b; i--)
#define endl '\n'
#define pb push_back
#define X first
#define Y second
#define II pair<int, int>
#define III pair<int, pair<int, int> >
#define V vector
#define debug(X) cerr<< #X << " = " <<X << endl
#define debug2(X,Y) cerr<< #X << " = " <<X << ","<<#Y<<" = "<<Y<<endl
#define show(X,a,b) {cerr << #X << " = "; up(__,a,b) cerr << X[__] << ' '; cerr << endl;}
#define gc getchar
#define pc putchar

using namespace std;

inline void read(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for (;((c<48 || c>57) && c != '-') ;c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}
inline void writeln(int x){

         char buffor[21];
         register int i=0;
         int neg=0; if (x<0) {neg=1; x= -x;}
         do{
               buffor[i++]=(x%10)+'0';
               x/=10;
            } while(x);
           i--;
           if (neg) pc('-');
           while(i>=0) pc(buffor[i--]);
           pc('\n');
       }
const int N= (int) 1e5+10;
int sum[2][N];

void input()
{
	string s;
	up(i,0,1)
	{
		cin>>s; s= " "+ s;
		up(j,1,(int)s.size()-1) sum[i][j]= sum[i][j-1]+ (int)(s[j]- 'A')+ 1;
	}
}

void solve()
{
	int q;
    cin>>q;
    up(i,1,q)
    {
    	int a,b,c,d;
    	cin>>a>>b>>c>>d;
    	if ( ((sum[0][b]- sum[0][a-1])%3+3) % 3 == ((sum[1][d]- sum[1][c-1])%3+3) % 3) cout<<"YES"<<endl;
    	else cout<<"NO"<<endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);// don't use when interactive
    #define TASK "tmp"
   // freopen(TASK".inp","r",stdin);
    //freopen(TASK".out","w",stdout);

    input();
    solve();

    return 0;
}


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

using namespace std;

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

  std::vector<int> v(3);
  v.at(0) = A + B;
  v.at(1) = A - B;
  v.at(2) = A * B;

  std::sort(v.begin(), v.end());

  cout << v[2] << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)998244353) 
#define INF ((int)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int main(){
	int n;
	cin >> n;
	double ans = 0;
	REP(i, n){
		int d;
		cin >> d;
		ans += 1.0 / d;
	}
	printf("%.8lf\n", 1.0/ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define in insert
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n,W;
    cin>>n>>W;
    vector<int> value(n),weight(n);
    int big_value=0;
    for(int i=0;i<n;i++){
        cin>>weight[i]>>value[i];
        big_value+=value[i];
    }
    vector<int> dp(big_value+1,INF);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=big_value;j>=value[i];--j){
            dp[j]=min(dp[j],dp[j-value[i]]+weight[i]);
        }
    }
    int answer=0;
    for(int i=0;i<=big_value;i++){
        if(dp[i]<=W) answer=max(answer,i);
    }
    cout<<answer;
}

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

int main(){
  int R,G,B,N;
  cin >> R >> G >> B >> N;
  int ans=0;
  for (int x=0;x<=N;++x){
    for (int y=0;y<=N;++y){
      int tmp=N-R*x-G*y;
      if (tmp>=0&&tmp%B==0) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
#define EPS 1e-13
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

int mp[1024][1024];
int sm[1024][1024];

int main(){
  while(true){
    int n;
    cin>>n;
    if(!n)break;
    REP(i,n){
      string s;
      cin>>s;
      REP(j,n)sm[i][j] = mp[i][j] = (int)(s[j]=='*');
    }
    REPR(i,n)REP(j,n)sm[i][j]+=sm[i-1][j];
    REP(i,n)REPR(j,n)sm[i][j]+=sm[i][j-1];
    int res = 0;
    REP(i,n)REP(j,n){
      // pos
      if(mp[i][j]==1)continue;
      int low = 1, high = (n-max<int>(i,j))+1;
      while(low+1<high){
        int mid = (low+high)/2;
        // check
        if(sm[i+mid-1][j+mid-1]
          -(j>0?sm[i+mid-1][j-1]:0)
          -(i>0?sm[i-1][j+mid-1]:0)
          +(i>0&&j>0?sm[i-1][j-1]:0) == 0){
          low = mid;
        }else{
          high = mid;
        }
      }
      res = max(res,low);
    }
    cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 9388
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const long long MAX = 1e7;
const long long MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(long long n, long long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    ll X, Y;
    cin >> X >> Y;
    if((X+Y)%3 != 0){pr(0); return 0;}
    COMinit();
    
    if(X==0 && Y == 0) pr(1);
    else pr((COM((X+Y)/3,X-((X+Y)/3)))%MOD);
}

Measured memory_bytes: 234624
A,B,M=map(int,input().split(" "))
As=list(map(int,input().split(" ")))
Bs=list(map(int,input().split(" ")))
ans=min(As)+min(Bs)
for i in range(M):
  x,y,c=map(int,input().split(" "))
  ans=min(ans,As[x-1]+Bs[y-1]-c)
print(ans)

Measured memory_bytes: 18736
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
vector<P> vs[200010];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, x, d;
    cin >> n >> x >> d;
    ll y = x - d;
    if (d == 0) {
        if (y == 0) {
            cout << 1 << endl;
        } else {
            cout << n + 1 << endl;
        }
        return 0;
    }
    if (d < 0) {
        y *= -1LL;
        d *= -1LL;
    }
    ll res = 0;
    vector<ll> v;
    for (ll k = 0; k <= n; k++) {
        v.push_back((k * y) % d);
    }
    sort(all(v));
    v.erase(unique(all(v)), v.end());
    for (ll k = 0; k <= n; k++) {
        int id = lower_bound(all(v), (k * y) % d) - v.begin();
        ll l = k * y / d + k * (k + 1LL) / 2LL,
           r = k * y / d + k * (n - k + 1LL + n) / 2LL;
        vs[id].push_back(P(l, r));
        //  cout << id << " " << l << " " << r << endl;
    }
    for (int i = 0; i < v.size(); i++) {
        vector<ll> vv;
        for (auto &p : vs[i]) {
            vv.push_back(p.first);
            vv.push_back(p.second + 1);
        }
        sort(all(vv));
        vv.erase(unique(all(vv)), vv.end());
        vector<ll> sum(vv.size() + 1);
        for (auto &p : vs[i]) {
            int l = lower_bound(all(vv), p.first) - vv.begin();
            int r = lower_bound(all(vv), p.second + 1) - vv.begin();
            sum[l]++;
            sum[r]--;
        }
        for (int i = 1; i < vv.size(); i++) {
            sum[i] += sum[i - 1];
        }
        for (int i = 0; i + 1 < vv.size(); i++) {
            if (sum[i] > 0) {
                res += vv[i + 1] - vv[i];
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 17772
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi					3.14159265359
ll INF=1e18+10;
ll MOD=998244353;

int main()
{
    ll a,b,k;cin>>a>>b>>k;
    ll kk=k;
    if(a>=k)a-=k;
    else
        k-=a,a=0,b-=k;
    if(a>=0 && b>=0 )cout<<a<<" "<<b;
    else cout<<0<<" "<<0;

}


Measured memory_bytes: 256
lines = readlines(chomp: true).map{|line| line.split(' ')}

a = lines[0][0].to_i
b = lines[0][1].to_i
c = lines[0][2].to_i
k = lines[1][0].to_i

k.times do
	if c <= b then
		c = c * 2
	elsif b <= a
		b = b * 2
	end
end

if c > b && b > a
	print "Yes"
else
	print "No"
end


Measured memory_bytes: 14392
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;

template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int main(){

ll L,R;
cin>>L>>R;
if(R-L>2020)cout<<0<<endl;
else{
    ll ans=(ll)1e19;
    for(ll i=L;i<R;i++){
        for(ll j=i+1;j<=R;j++){
            chmin(ans,(i*j)%2019);
        }
    }
    cout<<ans<<endl;
}
return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n);
    vpii a2(n);
    rep(i, n) cin >> a[i];
    rep(i, n) {
        a2[i].first = a[i];
        a2[i].second = i;
    }
    RSORT(a2);
    vi ans(n);
    rep(i, n) {
        if (i == a2[0].second) ans[i] = a2[1].first;
        else ans[i] = a2[0].first;
    }
    rep(i, n) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 6380
#include <iostream>
#include <vector>

using namespace std;

const int N=1e5+5;
int n,m;
vector<vector<int> > g;

vector<int> path_front, path_end;
bool used[N];

int main() {
        cin >> n >> m;
        g = vector<vector<int> >(n+1, vector<int>());
        for (int i=0; i<m; i++) {
                int a,b;
                cin >> a >> b;
                g[a].push_back(b);
                g[b].push_back(a);
                if (i == 0) {
                        path_front.push_back(a);
                        used[a] = true;
                        path_end.push_back(b);
                        used[b] = true;
                }
        }

        while (true) {
                int cur = path_front.back();
                for (auto v : g[cur]) {
                        if (!used[v]) {
                                path_front.push_back(v);
                                used[v] = true;
                                goto a1;
                        }
                }

                break;
                a1:;
        }

        while (true) {
                int cur = path_end.back();
                for (auto v : g[cur]) {
                        if (!used[v]) {
                                path_end.push_back(v);
                                used[v] = true;
                                goto a2;
                        }
                }

                break;
                a2:;
        }

        cout << path_front.size() + path_end.size() << "\n";
        for (int i=path_front.size()-1; i >= 0; i--)
                cout << path_front[i] << " ";
        for (int i=0; i<path_end.size(); i++)
                cout << path_end[i] << " ";
        cout << "\n";
}

Measured memory_bytes: 6904
import Control.Applicative
import Control.Monad
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.Bool (bool)

main :: IO ()
main = do
  n <- readLn
  map solve <$> replicateM n f >>= mapM_ putStrLn
  where
    f = head <$> B.words <$> B.getLine

solve :: ByteString -> String
solve bs = bool "No" "Yes" $ f 0 bs || f 1 bs
  where
    f lr bs = case g bs of
      Just (stp, bs') | isNatural lr stp -> f (1 - lr) bs'
      Just _ -> False
      Nothing -> True
    g bs = do
      (c1, bs') <- B.uncons bs
      (c2, _) <- B.uncons bs'
      return ((c1, c2), bs')

isNatural :: Int -> (Char, Char) -> Bool
isNatural lr stp
  | lr == 0   = stp `elem` [('U','R'),('U','D'),('L','U'),('L','R'),('L','D'),('D','U'),('D','R')]
  | otherwise = stp `elem` [('U','L'),('U','D'),('R','U'),('R','L'),('R','D'),('D','U'),('D','L')]



Measured memory_bytes: 4828
#include<iostream>
using namespace std;
int main(){
    int h,r;
    cin>>h>>r;

    if(h+r>0){
        cout<<1<<"\n";
    }

    if(h+r==0){
        cout<<0<<"\n";
    }

    if(h+r<0){
        cout<<-1<<"\n";
    }
    
    return 0;
}


Measured memory_bytes: 3108
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
//import static java.lang.System.*; はしばらく使わなそう(使うとしてもexit(0)のためだけ)←return;でよさそう
最後にout.flush()またはout.close()をするのを忘れずに！
Point2D p2d=new Point2D.Double(d1,d2);
*/
//入力終了→Ctrl+D
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        int x=sc.nextInt();
        int a=sc.nextInt();
        out.println(x<a?0:10);
        out.close();
    }

    static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    //Union Find木(0-indexed)
    static class UF {
        static int[] d;

        static void Init(int size) {
            d = new int[size];
            for (int i = 0; i < size; i++) {
                d[i] = -1;
            }
        }

        static boolean unite(int x, int y) {
            x = find(x);
            y = find(y);
            if (x == y) return false;
            if (d[x] > d[y]) {
                int t = d[y];
                d[y] = d[x];
                d[x] = t;
            }
            d[x] += d[y];
            d[y] = x;
            return true;
        }

        static boolean same(int x, int y) {
            return find(x) == find(y);
        }

        static int find(int k) {
            return d[k] < 0 ? k : (d[k] = find(d[k]));
        }

        static int size(int k) {
            return -d[find(k)];
        }
    }

    static PrintWriter out = new PrintWriter(System.out);

    static class sc {
        static Scanner s = new Scanner(System.in);

        static String next() {
            return s.next();
        }

        static String nextLine() {
            return s.nextLine();
        }

        static int nextInt() {
            return Integer.parseInt(s.next());
        }

        static long nextLong() {
            return Long.parseLong(s.next());
        }

        static double nextDouble() {
            return Double.parseDouble(s.next());
        }

        static boolean hasNext() {
            return s.hasNext();
        }

        static boolean hasNextInt() {
            return s.hasNextInt();
        }

    }

}

Measured memory_bytes: 25172
n = int(input())

import numpy as np
h = list(map(int, input().split()))

lim = 10 ** 9
dp_a = [lim] * n
dp_a[0] = 0
dp_a[1] = abs(h[1] - h[0])
dp = np.array(dp_a)

for i in range(2, n):

    bef1 = abs(h[i] - h[i - 1])
    bef2 = abs(h[i] - h[i - 2])

    dp[i] = min(dp[i - 1] + bef1, dp[i - 2] + bef2)

print(dp[n-1])
#print(dp)


Measured memory_bytes: 23048
s = list(map(int, list(input())))

def paint(start):
    a = s[::]
    ret = 0
    if a[0] != start:
        ret += 1
        a[0] ^= 1
    for i in range(1, len(a)):
        if a[i] == a[i - 1]:
            ret += 1
            a[i] ^= 1
    return ret

print(min(paint(0), paint(1)))

Measured memory_bytes: 4652
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
print(n*(n-1)//2)

Measured memory_bytes: 38384
#include <stdio.h>

int main() {
    char s[3];
    scanf("%s", s);
    if(s[0] == 'A' && s[1] == 'B' || s[1] == 'B' && s[2] == 'A' || s[0] == 'B' && s[2] == 'A' || s[1] == 'A' && s[2] == 'B'|| s[0] == 'A' && s[2] == 'B') {
        
        printf("Yes\n");
    } else {
        printf("No\n");
    }
      

    return 0;
}


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

#define max(a,b) (((a) < (b)) ? (b) : (a))
#define abs(a) (((a) < 0) ? (-(a)) : (a))
int main(void) {
    int64_t N,Z,W;

    cin >> N >> Z >> W;

    vector<int64_t> a(N);
    for(int i=0;i<N;i++) {
        cin >> a[i];
    }
    
    if(N == 1) {
        cout << abs(W-a[0]) << "\n";
    } else {
        cout << max(abs(a[a.size()-1]-W),abs(a[a.size()-1]-a[a.size()-2])) << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      while(true){
          int sum=0;
            String s = sc.next();
            if( s.equals("0"))
                break;
            for(int i = 0; i < s.length(); i++){
              Character.getNumericValue(s.charAt(i));
            sum+=Character.getNumericValue(s.charAt(i));
            }
            System.out.println(sum);
        }
        sc.close();
    }
}



Measured memory_bytes: 26720
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <cmath>
#include <utility>
#include <tuple>
#define FOR(i,m,n) for(int i = (m); i < (n); i++)
#define REP(i,n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vint;

int main() {
	int a[5], k;
	for(int i = 0; i < 5; i++) {
		scanf("%d", &a[i]);
	}
	scanf("%d", &k);
	int flag{};
	for(int i = 0; i < 5; i++) {
		for(int j = 1; j < 5; j++) {
			if(abs(a[i] - a[j]) > k) {
				flag = 1;
			}
		}
	}
	cout << ((flag) ? ":(": "Yay!") << '\n';
	return 0;
}


Measured memory_bytes: 256
#coding:utf-8

r , c = [int(i) for i in input().rstrip().split()]
hyou =[]
r1=[]

#r????????§
for i in range(r):
    a = [int(i) for i in input().rstrip().split()]
    gou = sum(a)
    a.append(gou)
    print(" ".join(list(map(str ,a))))
    hyou.append(a)
    gou =0

#r+1
for i in range(c+1):
    for j in range(r):
       gou += hyou[j][i]


    r1.append(gou)
    gou = 0

#print(hyou)

print(" ".join(list(map(str ,r1))))

Measured memory_bytes: 7728
#include<stdio.h>
#define MAX 2147483647
#define NMAX 100001


int getsum(int A[],int x,int y){
int i;
int sum=0;

for(i=x;i<=y;i++){
 sum+=A[i];
}

return sum;
}



int main(){
int n,q,i;
int com,x,y;
int A[NMAX]={0};
int C[NMAX];
scanf("%d %d",&n,&q);

for(i=0;i<q;i++)C[i]=-1;

for(i=0;i<q;i++){
 scanf("%d %d %d",&com,&x,&y);
 switch(com){
  case 0:A[x]+=y;
         break;
  case 1:C[i]=getsum(A,x,y);
         break;
 }
}


for(i=0;i<q;i++){if(C[i]!=-1){printf("%d\n",C[i]);}}

return 0;
}


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



int main() {
    int count , times = 0;
    cin >> count ;
    set<string> ss ;
    while(times != count){
        times++ ;
        string value ;
        cin >> value ;
        ss.insert(value);
    }
    cout << ss.size();
    
    
    
}

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


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

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int dates[12] ={31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int days[12][31] = {0};
	int month, date;
	int i, j, day;
	
	day = 0;
	
	for (i = 0; i < 12; i++){
		for (j = 0; j < dates[i]; j++){
			days[i][j] = day % 7;
			day++;
			
		}
	}
	
	while (1){
		scanf("%d %d", &month, &date);
		
		if (month == 0){
			break;
		}
		
		month--;
		date--;
		switch (days[month][date]){
		 case 4:
		 	printf("Monday");
			break;
		  case 5:
			printf("Tuesday");
		  	break;
		  case 6:
		  	printf("Wednesday");
			break;
		  case 0:
		  	printf("Thursday");
			break;
		  case 1:
		  	printf("Friday");
			break;
		  case 2:
		  	printf("Saturday");
			break;
		  case 3:
		  	printf("Sunday");
			break;
		}
		printf("\n");
	}
	
	
	return (0);
}

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

using namespace std;

typedef unsigned long long ull;

ull N,K,A[200000];

int main()
{
    cin>>N>>K;
    for(int i =0 ; i<N; i++){
        cin>>A[i];
    }
    for(ull i = K; i<N; i++){
        if(A[i-K]<A[i]){
            cout<<"Yes"<<endl;
        } else {
            cout<<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5164
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
int A =0;//500
int B =0;//100
int C =0;//50
int X =0;

int main(void){
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&X);
	int cnt = 0;
	for(int i=0;i<=A;i++){
		for(int j=0;j<=B;j++){
			for(int k =0;k<=C;k++){
				if((X-500*i-100*j-50*k)==0)	{
					cnt++;
					//printf("i:%d j:%d k:%d\n",i,j,k);
				}
			}
		}
	}
	printf("%d\n",cnt);
	return 0;

}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    s = S()

    m = {}
    m[0] = 0
    def f(i):
        if i in m:
            return m[i]

        c = 0
        ii = i
        while ii > 0:
            c += ii % 2
            ii //= 2

        t = i % c
        m[i] = f(t) + 1
        return m[i]

    c = len([_ for _ in s if _ == '1'])
    t = int(s, 2)
    cm = (c+1) * c * (c-1)
    if c > 1:
        t %= cm

    r = []
    k = 1
    for i in range(n-1,-1,-1):
        if t == k:
            r.append(0)
        elif s[i] == '1':
            r.append(f((t - k) % (c-1)) + 1)
        else:
            r.append(f((t + k) % (c+1)) + 1)
        k *= 2
        if c > 1:
            k %= cm

    return JA(r[::-1], "\n")


print(main())




Measured memory_bytes: 122944
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	n,m = MI()
	a = np.array(LI())
	total = np.sum(a)
	if m <= np.sum(a>=(total/(4*m))):
		print("Yes")
	else:
		print("No")

if __name__ == '__main__':
	main()

Measured memory_bytes: 12276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main(){
  string s;
  cin >> s;
  int x,y;
  cin >> x >> y;
  int tx,ty;
  tx=ty=0;
  int si=0;
  rep(i,s.size()){
    si++;
    if(s[i]=='F'){
      x--;
    }
    else if(s[i]=='T'){
	break;
      }
  }
  int xy=1;//x:0 y:1
  vector<int> vx,vy;
  for(int i=si;i<s.size();i++){
    if(s[i]=='F' && xy==0) tx++;
    if(s[i]=='F' && xy==1) ty++;
    if(s[i]=='T' && xy==0){
      xy=1;
      if(tx!=0) vx.pb(tx);
      tx=0;
    }
    else if(s[i]=='T' && xy==1){
      xy=0;
      if(ty!=0) vy.pb(ty);
      ty=0;
    }
    else if(i==s.size()-1){
      if(s[i]=='F' && xy==0) vx.pb(tx);
      else if(s[i]=='F' && xy==1) vy.pb(ty);
    }
  }
  //  rep(i,vx.size()) cout << vx[i] << " ";
  //  cout << "" <<endl;
  //  rep(i,vy.size()) cout << vy[i] << " ";
  //  cout << "" << endl;
  
  int xmax=0;
  int ymax=0;
  rep(i,vx.size()) xmax+=vx[i];
  rep(i,vy.size()) ymax+=vy[i];
  //  cout << abs(x) << " " << endl;
  if(xmax<abs(x) || ymax<abs(y)){
    cout << "No" << endl;
    return 0;
  }
  vector<bool> xdp(xmax*2+1);
  vector<bool> nxdp(xmax*2+1);
  vector<bool> ydp(ymax*2+1);
  vector<bool> nydp(ymax*2+1);
  rep(i,xmax*2+1){
    xdp[i]=false;
  }
  rep(i,ymax*2+1){
    ydp[i]=false;
  }
  xdp[xmax]=true;
  ydp[ymax]=true;
  rep(i,vx.size()){
    rep(j,xmax*2+1) nxdp[j]=false;
    rep(j,xmax*2+1){
      if(xdp[j]){
	nxdp[j+vx[i]]=true;
	nxdp[j-vx[i]]=true;
      }
    }
    swap(nxdp,xdp);
  }
  rep(i,vy.size()){
    rep(j,ymax*2+1) nydp[j]=false;
    rep(j,ymax*2+1){
      if(ydp[j]){
	nydp[j+vy[i]]=true;
	nydp[j-vy[i]]=true;
      }
    }
    swap(nydp, ydp);
  }
  if(xdp[xmax+x] && ydp[ymax+y]) cout << "Yes" << endl;
  else cout << "No" << endl;    
  return 0;

}


Measured memory_bytes: 384
# Aizu Problem 0277: Ticket Sale

import sys, math, os, datetime

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


price = {1: 6000, 2: 4000, 3: 3000, 4: 2000}
for k in range(4):
    t, n = [int(_) for _ in input().split()]
    print(n * price[t])

Measured memory_bytes: 8232
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

var mod int64 = 1000000007

func modPow2(num int64) int64 {
	if num == 0 {
		return 1
	}

	var rtn int64
	rtn = 1
	var i int64
	for i = 0; i < num; i++ {
		rtn = (rtn << 1) % mod
	}
	return rtn
}

func main() {
	N := getStdinInt64()
	hash1 := make(map[string]int64)
	hash2 := make(map[string]string)
	var zero int64 = 0
	var i int64 = 0
	for i = 0; i < N; i++ {
		list := getStdinIntArr64()
		A := list[0]
		B := list[1]
		if A == 0 && B == 0 {
			zero++
		} else if B == 0 {
			hash1["1/0"]++
			hash2["1/0"] = "0/1"
		} else if A == 0 {
			hash1["0/1"]++
			hash2["0/1"] = "1/0"
		} else {
			rat1 := big.NewRat(A, B)
			rat2 := big.NewRat(-B, A)
			hash1[fmt.Sprint(rat1)]++
			hash2[fmt.Sprint(rat1)] = fmt.Sprint(rat2)
		}
	}

	var ans int64 = 1
	for idx, val1 := range hash1 {
		if val1 == -1 {
			continue
		}
		var val2 int64 = hash1[hash2[idx]] // 仲の悪い相方
		var tmp1 int64 = (modPow2(val1) - 1) % mod
		var tmp2 int64 = (modPow2(val2) - 1) % mod
		var tmp3 int64 = 1
		hash1[idx] = -1 // 重複を避ける
		hash1[hash2[idx]] = -1
		ans = (ans * (tmp1 + tmp2 + tmp3)) % mod
	}
	ans = (ans + zero + mod - 1) % mod
	fmt.Printf("%d", ans)
	fmt.Printf("\n")
}

func getStdin() string {
	sc.Scan()
	return sc.Text()
}
func getStdinInt() int {
	sc.Scan()
	rtn, _ := strconv.Atoi(sc.Text())
	return rtn
}
func getStdinInt64() int64 {
	sc.Scan()
	rtn, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return rtn
}
func getStdinIntArr() []int {
	sc.Scan()
	str := sc.Text()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	sc.Scan()
	str := sc.Text()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}


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

int main(){

  map<string, vector<int> > mp;
  string s;
  int n;

  while(cin>>s>>n){
    mp[s].push_back(n);
  }

  for(auto p:mp){
    string name=p.first;
    vector<int> v=p.second;

    cout<<name<<endl;

    sort(v.begin(), v.end());
    for(int i=0;i<(int)v.size();i++){
      if(i>0) cout<<" ";
      cout<<v[i];
    }

    cout<<endl;
  }
  
  return 0;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

int c[10][10];
int memo[11];

int dfs(int ini, int now, int sum){
  if(now == 1){
    memo[ini] = min(memo[ini], sum);
    return 0;
  }

  if(memo[ini] <= sum) return 0;

  for(int nex = 0; nex < 10; nex++){
    if(nex==now) continue;
    dfs(ini, nex, sum + c[now][nex]);
    // dfs(ini, nex, sum);
  }

  return 0;
}

int main(){
  int h, w;
  cin >> h >> w;
  const int max_h = 200;
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      cin >> c[i][j];
    }
  }
  int a[max_h + 1][max_h + 1];
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> a[i][j];
    }
  }

  for(int i = 0; i < 10; i++) memo[i] = INF;
  for(int i = 0; i < 10; i++){
    dfs(i, i, 0);
  }

  int ans = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(a[i][j] == -1) continue;
      ans += memo[a[i][j]];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3788
//https://atcoder.jp/contests/dp/tasks/dp_g

#include <bits/stdc++.h>
#include <limits.h>
#include <algorithm>  


#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

typedef long long int ll;

const int precision = 16;
const int modulo =  1000000007; // 10^9 + 7
using ll = long long;
const double EPS = 1e-9;
//const ll INF = 1e18L + 5;
const int nax = 1e5 + 5;


enum class  Color {
	NOT_VISITED, PROCESING, VISITED
};

int dfs( int v, vector<Color> & seen, map<int, vector<int>> & G, unordered_map<int, int> & memo) {
	if(seen[v] == Color::VISITED) return memo[v];

	assert(seen[v] != Color::PROCESING);

	seen[v] = Color::PROCESING;

	int maxLenSeen = 0;
	for(auto u : G[v]) {
		maxLenSeen = max(maxLenSeen, dfs(u, seen, G, memo) + 1);
	}

	seen[v] = Color::VISITED;
	memo[v] = maxLenSeen;
	return maxLenSeen;
}

int solveLongestPath() {
	int v, m; cin >> v >> m;

	map<int, vector<int>> G;
	for(auto i = 0; i < m; ++i) {
		int u, v; cin >> u >> v;
		G[u].push_back(v);
	}


	unordered_map<int, int> memo;
	vector<Color> seen(v + 1, Color::NOT_VISITED);
	int maxLen = 0;
	for(auto i = 1; i <= v; ++i) {
		if(seen[i] == Color::NOT_VISITED) {
			maxLen = max(maxLen, dfs(i, seen, G, memo));
		}
	}


	// for(auto i = 1; i <= v; ++i) {
	// 	cout << " i: " << i << " - > ";
	// 	switch(seen[v]) {
	// 		case Color::NOT_VISITED : cout << " NOT_VISITED"; break;
	// 		case Color::PROCESING : cout << " PROCESING"; break;
	// 		case Color::VISITED : cout << " VISITED"; break;
	// 	}
	// 	cout << " memo : " << memo[i] ;
	// 	cout <<endl;
	// }

	return maxLen;
}

void eDfs(int u, vector<vector<int>> & G, vector<bool> & visited, vector<int> & inDegree, vector<int> & dist) {
	assert(!visited[u]);
	visited[u] = true;
	
	for(auto v : G[u]) {
		dist[v] = max(dist[v], dist[u] + 1);
		inDegree[v]--;
		if(inDegree[v] == 0) {
			eDfs(v, G, visited, inDegree, dist);
		}
	}
}

int solveLongestPath_byE() {
	int vert, m; cin >> vert >> m;

	vector<vector<int>> G(nax);
	vector<int> inDegree(nax);
	vector<bool> visited(nax, false);
	vector<int> dist(nax, 0);

	while(m--) {
		int u, v; cin >> u >> v;

		G[u].push_back(v);
		inDegree[v]++;
	}

	for(auto i = 1; i <= vert; ++i) {
		if(!visited[i] and inDegree[i] == 0) {
			eDfs(i, G, visited, inDegree, dist);
		}
	}

	int maxDist = 0;
	for(auto i = 1; i <= vert; ++i) {
		maxDist = max(maxDist, dist[i]);
	}

	return maxDist;
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(precision);
	cout.setf(ios_base::fixed);

	auto ret = solveLongestPath_byE();
	cout << ret << endl;
	return 0;
}




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

int main(){
    ll n;
    cin>>n;
    ll ans=0;
    ll eat[n],bonus[n-1];
    for (int i = 0; i < n; ++i) {
        cin>>eat[i];
    }
    for (int j = 0; j < n; ++j) {
        ll t;
        cin>>t;
        ans+=t;
    }
    for (int k = 0; k < n-1; ++k) {
        cin>>bonus[k];
    }
    for (int l = 0; l < n-1; ++l) {
        if(eat[l+1]-eat[l]==1)ans+=bonus[eat[l]-1];
    }
    cout<<ans<<endl;
    return 0;
}


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

const int N = 1e5 + 100;

int n;
int dist1[N], dist2[N];
vector < int > gr[N];

void dfs1( int v, int u ){
    dist1[v] = dist1[u] + 1;
    for( auto to: gr[v] ){
        if( to == u )
            continue;
        dfs1( to, v );
    }
}
void dfs2( int v, int u ){
    dist2[v] = dist2[u] + 1;
    for( auto to: gr[v] ){
        if( to == u )
            continue;
        dfs2( to, v );
    }
}

int main(){

    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif
    ios_base::sync_with_stdio( false );
    cin >> n;
    int v, u;
    cin >> v >> u;
    for( int i = 1; i <= n-1; i ++ ){
        int a, b;
        cin >> a >> b;
        gr[a].push_back( b );
        gr[b].push_back( a );
    }
    dist1[0] = -1;
    dist2[0] = -1;
    dfs1( v, 0 );
    dfs2( u, 0 );
    int ans = 0;
    for( int i = 1; i <= n; i ++ ){
        if( dist1[i] < dist2[i] ){
            ans = max( ans, dist2[i]-1 );
        }
    }
    cout << ans;
}

Measured memory_bytes: 10368