akhauriyash/Code-Regression huggingface dataset:
//#include<bits/stdc++.h>
#include<cstdio>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 21;
char dn[dm], * di = dn, dt;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

void pakuri_sort(int N, int A[], int B[], int C[]) {
	const int b = 8;
	int tmp[200001], tmp2[200001], tmp3[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) {
			tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
			tmp2[kazu[A[i] >> k * b & ((1 << b) - 1)]] = B[i];
			tmp3[kazu[A[i] >> k * b & ((1 << b) - 1)]] = C[i];
		}
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) {
			A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
			B[kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp2[i];
			C[kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp3[i];
		}
	}
}

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


	int N = getint(), Q = getint();
	int S[200000], T[200000], X[200000];
	rep(i, N) {
		S[i] = getint();
		T[i] = getint();
		X[i] = getint();
	}
	pakuri_sort(N, X, S, T);
	set<ll> D;
	D.insert(-2e18);
	rep(i, Q) D.insert(D.end(), ((ll)getint() << 30) + i);
	D.insert(D.end(), 4e18);
	int kotae[200000] = {};
	rep(i, N) {
		auto L = D.lower_bound((ll)(S[i] - X[i]) << 30);
		while (*L < (ll)(T[i] - X[i]) << 30) {
			kotae[*L & ((1 << 20) - 1)] = X[i];
			auto mae = L;
			L++;
			D.erase(mae);
		}
	}

	rep(i, Q) {
		if (kotae[i] == 0) {
			*di++ = '-';
			*di++ = '1';
			*di++ = '\n';
		}
		else putint(kotae[i]);
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

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

// 0_0, even_even, odd_odd, even_even, 0_0
int main() {
    int l; cin >> l;
    vector<long long> a(l);
    long long all = 0;
    for (int i = 0; i < l; i++) {
        cin >> a[i];
    }
    long long dp[l+1][6];
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < l; i++) {
        dp[i+1][0] = dp[i][0] + a[i];
        dp[i+1][1] = min({dp[i][0], dp[i][1]}) + ((a[i] == 0) ? 2 : (a[i] % 2));
        dp[i+1][2] = min({dp[i][0], dp[i][1], dp[i][2]}) + (a[i] % 2 == 0);
        dp[i+1][3] = min({dp[i][0], dp[i][1], dp[i][2], dp[i][3]}) + ((a[i] == 0) ? 2 : (a[i] % 2));
        dp[i+1][4] = min({dp[i][0], dp[i][1], dp[i][2], dp[i][3], dp[i][4]}) + a[i];
    }
    long long ans = 1e18;
    for (int i = 0; i < 5; i++) {
        ans = min(ans, dp[l][i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
#define double long double
const int INF = 1e18, MOD = 1e9 + 7;

struct UnionFind {
    vector<int> t;
    UnionFind(int size): t(size, -1) {}
    int root(int x) {return t[x] < 0 ? x : t[x] = root(t[x]);}
    int size(int x) {return -t[root(x)];}
    bool isSame(int x, int y) {return root(x) == root(y);}
    bool unite(int x, int y) {
        x = root(x), y = root(y);
        if(x != y) {
            if(t[y] < t[x]) swap(x, y);
            t[x] += t[y], t[y] = x;
        }
        return x != y;
    }
};

signed main() {
    int n;
    cin>>n;
    int x, y;
    vector<pair<int, int>> v;
    for (int i = 0; i < n; i++) {
        cin>>x>>y;
        v.push_back(make_pair(x, y));
    }
    int ans = INF;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int p, q;
            p = v[i].first - v[j].first;
            q = v[i].second - v[j].second;
            UnionFind uf(n);
            for (int k = 0; k < n; k++) {
                for (int l = 0; l < n; l++) {
                    if (
                        v[k].first + p == v[l].first &&
                        v[k].second + q == v[l].second
                    ) {
                        uf.unite(k, l);
                    }
                }
            }
            int cnt = 0;
            for (int k = 0; k < n; k++) {
                if (uf.root(k) == k) cnt++;
            }
            ans = min(ans, cnt);
        }
    }
    cout<<ans<<endl;
}

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

int main(){
  int n, q, m, date, ans, max;
  while(true){
    cin >> n >> q;
    int N[100] = {0};
    if (n == 0 && q ==0){
      break;
    }
    for (int i = 0; i < n; ++i)
    {
      cin >> m;
      for (int j = 0; j < m; ++j)
      {
        cin >> date;
        N[date-1] += 1;
      }
    }
    max = 0;
    ans = 0;
    for (int i = 99; i >= 0 ; --i)
    {
      if (N[i] >= max && N[i] >= q){
        max = N[i];
        ans = i+1;
      }
    }
    cout << ans << endl;
  }
}

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

int dp1[1010];
int dp2[1010];

int main(){
	int N;
	while( cin >> N && N ){
		vector< pair<int,int> > b(N);
		int rsum = 0, wsum = 0;
		for(int i = 0 ; i < N ; i++){
			int r,w;
			cin >> r >> w;
			rsum += r;
			wsum += w;
			b[i] = make_pair(r,w);
		}
		sort(b.begin(),b.end());
		int maxRVal = b.back().first;
		int margin = max(0,2*maxRVal-rsum);
		int required = rsum + margin;
		
		vector<int> normal,special;
		int specialWSum = 0;
		for(int i = 0 ; i < N ; i++){
			if( b[i].first < maxRVal ){
				normal.push_back(b[i].second);
			}else{
				special.push_back(b[i].second);
				specialWSum += b[i].second;
			}
		}
		sort(normal.begin(),normal.end());
		sort(special.begin(),special.end());
		for(int i = 0 ; i < 1010 ; i++)
			dp1[i] = dp2[i] = 0;
		dp1[0] = dp2[0] = 1;
		for(int i = 0 ; i < normal.size() ; i++)
			for(int j = 1000 ; j >= normal[i] ; j--)
				dp1[j] |= dp1[j-normal[i]];
		for(int i = 0 ; i < special.size() ; i++)
			for(int j = 1000 ; j >= special[i] ; j--)
				dp2[j] |= dp2[j-special[i]];
		for(int i = 0 ; i <= 1000 ; i++){
			if( dp1[i] > 0 ) dp1[i] = i;
			if( dp2[i] > 0 ) dp2[i] = i;
		}
		for(int i = 1 ; i <= 1000 ; i++){
			dp1[i] = max(dp1[i-1],dp1[i]);
			dp2[i] = max(dp2[i-1],dp2[i]);
		}
		
		int answer = 0;
		for(int i = 0 ; i <= margin ; i++){
			int x = dp1[i];
			int y = dp2[margin-i];
			if( y == specialWSum ){
				y -= special[0];
			}
			answer = max(answer,x+y);
		}
		
		cout << required + wsum - answer << endl; // 
			
	}
}

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

int main(){
  long long int n, m;
  cin >> n >> m;
  vector<long long int> a(m+2);
  vector<long long int> num(n+2);
  a[0] = -1;
  a[m+1] = n+1;
  rep(i,m+1,1) cin >> a[i];
  
  num[0] = 0;
  num[1] = 1;
  rep(i, n+2, 2){
    num[i] = num[i-1] + num[i-2];
    num[i] %= 1000000007;
  }
  
  long long int ans = 1;
  rep(i,m+1,0){
    long long int k = a[i+1] - a[i] - 1;
    ans *= num[k];
    ans %= 1000000007;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long ncr(long n,long r){
  r = min(r,n-r);
  long ans = 1;
  long i,j;
  i=n-r+1;
  j=2;
  while(i<=n){
    ans *= i;
    i++;
    while(ans%j==0&&j<=r){
      ans/=j;
      j++;
    }
  }
  return ans;
}

int main(){
  int n;
  cin >> n;
  vector<long>a(n);
  int i;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  long aa = a[0];
  for(i=1;i<n-1;i++){
    if(min(aa,a[n-1]-aa)<min(a[i],a[n-1]-a[i]))aa = a[i];
  }
  cout << a[n-1] << " " << aa << endl;

}


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

int main(void){
  char step[1000010];

  while(1) {
    cin >> step;
    if(step[0] == '#') break;
    int counter = 0;
    int state;

    if(step[0] == '1' || step[0] == '4' || step[0] == '7') state = 6;
    else if(step[0] == '2' || step[0] == '8') state = 7;
    else state = 8;
    
    int i;
    
    for(i = 1; step[i] != '\0'; i++){

      if(state == 6){
        if(step[i] == '1' || step[i] == '4' || step[i] == '7'){
          continue;
        }else if(step[i] == '8' || step[i] == '2'){
          state = 3;
          continue;
        }else{
          state = 5;
          continue;
        }
      }

      if(state == 7){
        if(step[i] == '2' || step[i] == '8'){
          continue;
        }else if(step[i] == '1' || step[i] == '4' || step[i] == '7'){
          state = 0;
          continue;
        }else{
          state = 5;
          continue;
        }
      }

      if(state == 8){
        if(step[i] == '9' || step[i] == '6' || step[i] == '3'){
          continue;
        }else if(step[i] == '8' || step[i] == '2'){
          state = 2;
          continue;
        }else{
          state = 0;
          continue;
        }
      }
      

      if(state == 0){
        if(step[i] == '3' || step[i] == '6' || step[i] == '9'){
          state = 5;
          continue;
        }else if(step[i] == '8' || step[i] == '2'){
          state = 3;
          continue;
        }else{
          state = 1;
          continue;
        }
      }

      if(state == 1){
        if(step[i] == '4' || step[i] == '7'|| step[i] == '1'){
          state = 0;
          continue;
        }else if(step[i] == '8' || step[i] == '2'){
          counter++;
          state = 3;
          continue;
        }else{
          counter++;
          state = 5;
          continue;
        }
      }

      if(state == 2){
        if(step[i] == '3' || step[i] == '6' || step[i] == '9'){
          state = 5;
          continue;
        }else if(step[i] == '2' || step[i] == '8'){
          state = 3;
          continue;
        }else{
          counter++;
          state = 0;
          continue;
        }
      }

      if(state == 3){
        if(step[i] == '1' || step[i] == '4' || step[i] == '7'){
          state = 0;
          continue;
        }else if(step[i] == '2' || step[i] == '8'){
          state = 2;
          continue;
        }else{
          counter++;
          state = 5;
          continue;
        }
      }

      if(state == 4){
        if(step[i] == '3' || step[i] == '6' || step[i] == '9'){
          state = 5;
          continue;
        }else if(step[i] == '8' || step[i] == '2'){
          counter++;
          state = 2;
          continue;
        }else{
          counter++;
          state = 0;
          continue;
        }
      }

      if(state == 5){
        if(step[i] == '6' || step[i] == '3' || step[i] == '9'){
          state = 4;
          continue;
        }else if(step[i] == '8' || step[i] == '2'){
          state = 2;
          continue;
        }else{
          state = 0;
          continue;
        }
      }
    }

    cout << counter << endl;
  }
  return 0;
}

Measured memory_bytes: 3184
<?php 

 $array_num = str_split(trim(fgets(STDIN)), 1);

$cnt = count($array_num);

$B_cnt = 0;

for ($i = 0 ; $i < $cnt; $i++) {

  if ($array_num[$i] == 1) {

$B_cnt++;

}

}

echo $B_cnt;

?>

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

int main(){
  int n; cin>>n;
  vector<string>A(n);
  vector<string>B(n);
  vector<int>C(n);
  for(int i=0;i<n;i++){
    string s; cin>>s;
    A[i]=s;
    B[i]=s;
    C[i]=s.size();
  }
  int yes=0;
  sort(A.begin(),A.end());
  for(int i=0;i<n-1;i++){
    if(A[i]==A[i+1] || B[i].at(C[i]-1)!=B[i+1].at(0)){
      yes=1;
      break;
    }
     
  }
  if(yes==1) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

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

int main(){
  int N; cin >> N;
  string wr; cin >> wr;
  int nbrouge = 0;
  int rouge[N];
  for (int i=0; i<(N); i++){
    if (wr[i]=='R'){nbrouge+=1;}
    rouge[i]=nbrouge;
  }
  int a;
  if (nbrouge==0){a=0;}
  else{
    a = min(N-nbrouge,nbrouge-rouge[nbrouge-1]);
  }
  cout << a ;
}

Measured memory_bytes: 4072
fun main(arr:Array<String>) {
    val n = readLine()!!.toLong()
    var ans = 0L

    for(i in (1..n)) {
        if(i*i > n) {
            break
        }
        if(n%i ==0L) {
            ans = (i-1) + (n/i) - 1
        }
    }
    println(ans)
}


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

using namespace std;


int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	
	int odd = (m + 1) / 2;
	int even = m / 2;
	int cur = 1;
	
	for (int i = odd; i >= 1; i--) {
		printf("%d %d\n", cur, cur + i * 2 - 1);
		cur++;
	}
	
	cur = n;
	for (int i = even; i >= 1; i--) {
		printf("%d %d\n", cur - i * 2, cur);
		cur--;
	}
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a,b) printf(a,b);
#define c(s) cout<< (s) << endl;
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define cyn(c) cout<<(c?"Yes":"No")<<endl;
#define cYN(c) cout<<(c?"YES":"NO")<<endl;
#define pyn(c) printf("%s\n",c?"Yes":"No");
#define pYN(c) printf("%s\n",c?"YES":"NO");
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int N,M,A,B[25]={},C,sum=0,ans=0; cin>>N>>M>>C;
    rep(j,M){
        cin>>B[j];
    }
    rep(i,N){
        rep(j,M){
            cin>>A;
            sum+=A*B[j];
        }
        // c(sum);
        if(sum+C>0)ans++;
        sum=0;
    }
    c(ans);
}


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(a>0&&c>0){
        c = c-b;
        a = a-d;
    }
    if(c>0) cout << "No" << endl;
    else cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>

int main() {
	int n, a, b;

	std::cin >> n >> a >> b;

	std::cout << std::min(n * a, b) << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
bool graph[8][8];
int dfs(int v,int n,bool visited[8]){
  bool all=true;
  int r=0;
  for(int i=0;i<n;i++){
    if(visited[i]==false){
      all=false;
      break;
    }
  }
  if(all==true) return 1;
  for(int i=0;i<n;i++){
    if(graph[v][i]==false || visited[i]==true) continue;
    visited[i]=true;
    r+=dfs(i,n,visited);
    visited[i]=false;
  }
  return r;
}
int main(){
  int n,m,temp_m,temp_n;
  bool visited[8];
  cin >> n >>m;
  for(int i=0;i<m;i++){
    cin >> temp_n>>temp_m;
    graph[temp_n-1][temp_m-1]=graph[temp_m-1][temp_n-1]=true;
    visited[i]=false;
  }
  visited[0]=true;
  cout << dfs(0,n,visited)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int l[m],r[m];
  for(int i=0;i<m;i++)cin >> l[i] >> r[i];
  sort(l,l+m,greater<int>());
  sort(r,r+m);
  if(r[0]-l[0]>=0)cout << r[0]-l[0]+1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 4360
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    string s;cin>>s;
    sort(s.begin(),s.end());
    if(s=="abc") cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

using namespace std;

int main()
{
    int n,m,c;
    cin>>n>>m>>c;
    int b[m];
    for(int i=0; i<m; i++)
    {
        cin>>b[i];
    }
    int niza[m];
    int cnt=0;
    while(n--)
    {
        int curr=c;
        for(int i=0; i<m; i++)
        {
            cin>>niza[i];
        }
        for(int i=0; i<m; i++)
        {
            curr+=niza[i]*b[i];
        }
        if(curr>0)
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		System.out.println((H-h)*(W-w));
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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

Measured memory_bytes: 21332
import Control.Applicative

main :: IO ()
main = do
    [a, b] <- map read . words <$> getLine
    putStrLn $ show (solve a b)

solve :: Int -> Int -> Int
solve a b = if even (a + b) then (a + b) `div` 2 else (a + b) `div` 2 + 1

Measured memory_bytes: 508
/*------------------------Original Copyright belongs to-------------------------/
!      																			!
!      ##  ##                                                		##  ##	    !
!      #   #             											#   #		!		                
!      				 ###  ####  ###   ###     ##         #                      !
!					#     #  #  #  #  #  #   #  #       ##                      !
!					#	  #  #  ###   ###    ####        #                      !
!					#     #  #  #  #  #  #   #  #        #                      !
!					 ###  ####  ###   #   #  #  #  ###  ### 			        !
!                                                                               !
/------------------------------------------------------------------------------*/
#include<bits/stdc++.h>
using namespace std;
//------------Template begins--------------------//
#define ss string
#define last(s) s.length()-1
#define lli long long int
#define v(type) vector<type>
#define pr(type1,type2) pair<type1,type2>
#define ma(type1,type2) map<type1,type2>
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define L(i,start,end) for(lli i=start;i<=end;i++)
#define R(i,start,end) for(lli i=start;i>=end;i--)
#define inp(var,start,end,array) for(var=start;var<=end;var++) cin>>array[var];
#define whatIs(x) cout<<#x<<" is "<<x<<endl
#define dbg1D(i,start,end,arr) for(lli i=start;i<=end;i++) cout<<i<<"th : "<<arr[i]<<endl;
#define dbg2D(i,j,s1,e1,s2,e2,arr) for (lli i=s1;i<=e1;i++) {cout<<i<<"th :"; for(lli j=s2;j<e2;j++)cout<<arr[i][j]<<" ";cout<<endl;}

lli dx[4]={-1, 0, 0, +1};
lli dy[4]={0, -1, +1, 0};
const lli LINF = 1e18;
const lli INF = 1e9;
const lli mod = 1e9+7;
lli power(lli a,lli b,lli m){ if(b==0) return 1; if(b==1) return a%m;
 		lli t=power(a,b/2,m); t=(t*t)%m; if(b&1) t=(t*a)%m; return t;}
lli modInverse(lli a, lli m) { return power(a, m-2, m); }
//---------------Template ends------------------//
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	#ifndef ONLINE_JUDGE
	//freopen("ip.txt","r",stdin);
	//freopen("op.txt","w",stdout);
	#endif
//#################### CATCH HERE ##########################
   	/* Uncomment if t test cases
	lli t;
	cin>>t;
	while(t--)
	{
		lli n,ans,i,j;

		cout<<ans<<endl;
	}
	*/
	lli i,r,d,x;
	cin>>r>>d>>x;
	L(i,1,10)
	{
		x=r*x-d;
		cout<<x<<endl;
	}
	//cout<<ans<<endl;
//##########################################################
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  reverse(h);
  rep(i,n-1){
    if(h[i] >= h[i+1]) continue;
    if(h[i] == h[i+1]-1) h[i+1] --;
    if(h[i] < h[i+1]-1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

int main() {
    int n;
    const int mod = 1e9 + 7;
    cin >> n;
    ll ans = 1;
    for(int i = 1; i <= n; i++) {
        ans = (ans * i) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def yakusuu(n):
    kosuu = 0
    for i in range(1, n+1 , 2):
        cnt = 0
        for j in range(1, n+1):
            if i % j == 0:
                cnt = cnt + 1
        if cnt == 8:
            kosuu = kosuu + 1
    return kosuu
    

def main():
    n = int(input())
    print(yakusuu(n))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int H,W;
char maze[30][310];
int d[30][30];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int bfs(int sx,int sy){
    queue<pair<int,int>> que;
    rep(i,H){
        rep(j,W){
            d[i][j]=INF;
        }
    }
 
    int res=0;
    que.push(make_pair(sx,sy)); // (0,0)スタート
    d[sx][sy]=0;
    while(!que.empty()){
        pair<int,int> p=que.front();
        que.pop();
        for(int i=0;i<4;i++){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(0<=nx && nx<H && 0<=ny && ny<W && maze[nx][ny]!='#' && d[nx][ny]==INF){
                que.push(make_pair(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
                res=max(res,d[nx][ny]);
            }
        }
    }
 
    return res;
}



int main(){    
    cin>>H>>W;
    rep(i,H) rep(j,W) cin>>maze[i][j];

    int ans=0;
    rep(i,H){
        rep(j,W){
            if(maze[i][j]=='.'){
                ans=max(ans,bfs(i,j));
            }
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3636
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	hellGate := 100.000

	fmt.Scanf("%d", &n)

	for i := 1; i <= n; i++ {
		hellGate *= 1.05
		hellGate = math.Ceil(hellGate)
	}

	fmt.Println(int(hellGate * 1000))
}



Measured memory_bytes: 1088
#include<bits/stdc++.h>
using namespace std;
long long mod=1e9+7;
long long qpow(long long a,long long b){
	long long res=1;
	while(b){
		if(b&1) res=res*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return res%mod;
}
int main(){
	long long r,c;
	cin>>r>>c;
	if((r+c)%3!=0||max(r,c)>min(r,c)*2) cout<<0<<endl;
	else{
		long long a=(r+c)/3,x=r-a,y=c-a,ans=1,num=1;
		for(long long i=x;i>=1;i--){
			ans=(ans*(a-i+1))%mod;
		}
		for(long long i=x;i>=1;i--){
			num=(num*i)%mod;
		}
		cout<<ans%mod*qpow(num,mod-2)%mod<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
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;
long long wv[110][2];
long long dp[110][100010];

int main() {
    int N, W;
    cin >> N >> W;
    rep(i, 0, N) {
        rep(r, 0, 2) { cin >> wv[i][r]; }
    }

    rep(i, 0, N) {
        rep(sum, 0, W + 1) {
            if(sum - wv[i][0]>=0) {
                chmax(dp[i + 1][sum], dp[i][sum - wv[i][0]] + wv[i][1]);
            }
            chmax(dp[i + 1][sum], dp[i][sum]);
        }
    }

    cout << dp[N][W] << endl;
}


Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int x;
	cin>>x;
	int n=x/200;
	cout<<10-n<<endl;
	return 0;
}




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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ll mod = 1000000007;

int main(void)
{
	ll a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22) {
		cout << "bust" << endl;
		return 0;
	}
	cout << "win" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int arr[100009];
int main()
{
    //freopen("input.txt","r",stdin);
    int n,crr[100009],res1,res2;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>crr[i];
    }
    arr[1] = 0;
    arr[2] = abs(crr[1]-crr[2]);
    if(n==2){cout<<abs(crr[1]-crr[2])<<endl;return 0;}
    for(int i=3; i<=n; i++)
    {
        res1 = abs(crr[i] - crr[i-1]) + arr[i-1];
        res2 = abs(crr[i] - crr[i-2]) + arr[i-2];
        if(res1<res2)
        {
            if(i-1!=1)
            {
                arr[i] = abs(crr[i] - crr[i-1]) + arr[i-1];
            }
            else
            {
                arr[i] = abs(crr[i] - crr[i-1]);
            }
        }
        else
        {
            if(i-2!=1)
            {
                arr[i] = abs(crr[i] - crr[i-2]) + arr[i-2];
            }
            else
            {
                arr[i] = abs(crr[i] - crr[i-2]);
            }
        }
    }
//    for(int i=1; i<=n; i++)
//    {
//        cout<<arr[i]<<" ";
//    }
    cout<<arr[n]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main() {
   string a;
   int n, co=0;
   cin >> n >> a;
\
   FOR(i,0,n-2){
       if(a.at(i) == 'A' && a.at(i+1) == 'B' && a.at(i+2) == 'C' ){
           co++;
           
       }

   }
    cout << co << endl;


  

    return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  for(i=0;i<n;i++)cin>>a[i];
  for(i=-100;i<=100;i++){
    buf=0;
    for(j=0;j<n;j++){
      buf+=(a[j]-i)*(a[j]-i);
    }
    chmin(res1,buf);
  }
  cout<<res1<<endl;

  return 0;
}

Measured memory_bytes: 256
/***
author: srijan
***/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<malloc.h>
#include<stdbool.h>
#include<limits.h>
int main()
{
	char s[3];
	char t[3];
	scanf("%s",s);
	scanf("%s",t);
	int ans = 0;
	for(int i=0;i<strlen(t);i++)
	{
		if(s[i]==t[i])
		{
			ans++;
		}
	}
	printf("%d",ans);
	return 0;
}

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

#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define ALL( a )        (a).begin(), (a).end()             

int main(void){
    int h, r; cin >> h >> r;
    
    if( r + h == 0 ) cout << 0 << endl;
    else if( h + r >= 0) cout << 1 << endl;
    else if( h + r <= 0 ) cout << -1 << endl;
}



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

typedef long long int ll;

ll n,w;
ll arr[100][2];

ll dp[100005][105];

ll solve(ll i,ll w){
	
	if(i==n || w==0)return 0;
	
	if(dp[w][i]==-1){
		
		if(w>=arr[i][0]){
			
			dp[w][i] = max(arr[i][1]+solve(i+1,w-arr[i][0]),solve(i+1,w));
			
		}else{
			dp[w][i] = solve(i+1,w);
		}
		
	}
	return dp[w][i];
	
}

int main(){
	memset(dp,-1,sizeof(dp));
	cin>>n>>w;
	
	for(ll i=0;i<n;i++)cin>>arr[i][0]>>arr[i][1];
	
	cout<<solve(0,w)<<endl;
	
}

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

int main(){
  string s;
  cin >> s;
  s=="ABC"?cout << "ARC" << endl:cout << "ABC" << endl;
}


Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
n,m = list(map(int,input().split()))
price = [0] * m
can_opens = [0] * m
for i in range(m):
    a,b = list(map(int,input().split()))
    price[i]=a
    c = ["0"] * n
    ci = list(map(int,input().split()))
    for j in ci:
        c[n- j]="1"
    can_opens[i]=int("".join(c),2)
inf=float("inf")
dp = [inf] * 2**n
dp[0]=0
#dp[i]は、iを取るために必要な最小費用
for i,(pi,coi) in enumerate(zip(price,can_opens)):
    for j in range(2**n):
        dp[j|coi]=min(dp[j|coi],dp[j]+pi)
from math import isinf
if isinf(dp[-1]):
    print(-1)
else:
    print(dp[-1])

Measured memory_bytes: 48600
#include<stdio.h>
int main(void)
{
	int a,s[7],i,j,d,f,g,h;
	scanf("%d",&a);
	for(i=1;i<=6;i++)	s[i]=0;
	for(i=1;i<=a;i++){
		scanf("%d.%d",&d,&f);
		if(d>=185)
			s[6]++;
		else if(d>=180)
			s[5]++;
		else if(d>=175)
			s[4]++;
		else if(d>=170)
			s[3]++;
		else if(d>=165)
			s[2]++;
		else if(d<165)
			s[1]++;
	}
	for(i=1;i<=6;i++){
		printf("%d:",i);
		for(j=1;j<=s[i];j++){
			printf("*");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1032
#include<bits/stdc++.h>
#define FOR(i, n) for(int i = 0; i < n; i++)
using namespace std;
int dp[3001][3001];
int s_size, t_size;
string s, t;

string solve() {
	FOR(i, s_size + 1) {
		FOR(j, t_size + 1) {
			if(i == 0 || j == 0) dp[i][j] = 0;
			else if(s[i - 1] == t[j - 1]) dp[i][j] = 1 + dp[i - 1][j - 1];
			else dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
		}
	}
	
	string result = "";
	int i = s_size;
	int j = t_size;
	while(i > 0 && j > 0) {
		if(s[i - 1] == t[j - 1]) {
			result += s[i - 1];
			--i; --j;
		} else {
			if(dp[i - 1][j] > dp[i][j - 1]) --i;
			else --j;
		}
	}
	reverse(result.begin(), result.end());
	return result;
}

int main() {
	cin>>s>>t;
	s_size = s.size();
	t_size = t.size();
	memset(dp, -1, sizeof(dp));
	string result = solve();
	cout<<result<<"\n";
	return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int a, b, c; cin >> a >> b >> c;
	cout << min({a+b, b+c, c+a}) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
long long ma=2,k,a[100005],in=2;
int main()
{
	scanf("%lld",&k);
	for(int i=1;i<=k;i++) scanf("%lld",&a[i]);
	for(long long i=k;i>=1&&ma>=in;i--)
	{
		if(in%a[i]!=0)
		in=1ll*in/a[i]*a[i]+a[i];
		ma=1ll*(ma/a[i]+1)*a[i]-1;
	}
	if(in>ma){printf("-1");return 0;}
	printf("%lld %lld\n",in,ma);
}

Measured memory_bytes: 896
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll f[110][6][3],n,p[110][20];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=0;i<n;++i)
    {
        for(int j=0;j<5;++j)
        {
            cin>>f[i][j][0]>>f[i][j][1];
        }
    }
    for(int i=0;i<n;++i)
    {
        for(int j=0;j<=10;++j)
        {
            cin>>p[i][j];
        }
    }
    ll mask=(1LL<<10)-1;
    ll ans=-1e15;
    for(ll m=mask;m;m=(m-1))
    {
        ll cost=0;
        for(int i=0;i<n;++i)
        {
            ll c=0;
            for(int j=0;j<5;++j)
            {
                for(int k=0;k<2;++k)
                {
                    ll in=2*j+k;
                    if(f[i][j][k]==1&&(   (1LL<<in)&m)>0)
                    {
                        c++;
                    }
                }
            }
            cost+=p[i][c];
        }
        ans=max(cost,ans);
    }
    cout<<ans<<'\n';

}








Measured memory_bytes: 256
def pow_mod(a, b, m):
    if b == 0:
        return 1
    elif b % 2 == 0:
        d = pow_mod(a, b//2, m)
        return (d * d) % m
    else:
        return (a * pow_mod(a,b-1,m))%m

def comb(n, c, m):
    upe = 1
    dow = 1
    for i in range(1,c+1):
        upe = upe * n % m
        dow = dow * i % m
        n -= 1
    return upe * pow_mod(dow, m-2,m)%m

def modinv(a, m):
    b = m
    u = 1
    v = 0
    while b:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u %= m
    if u < 0:
        u += m
    return u

MOD = 998244353
def solve(N, M, K):
    MOD = 998244353
    U = N-1-K
    color = M * pow_mod(M-1, U, MOD) % MOD
    c = comb(N-1, U, MOD) % MOD
    #print("c0=%d"%c)
    answer = (c * color) % MOD
    #print("a0", answer)
    #print("U=%d"%U)
    for j in range(N-K, N):
        c = ((c * (N-j)%MOD) * modinv(j, MOD)) % MOD
        #assert c == comb(N-1, j, MOD)
        color = (color * (M-1)) % MOD
        a = (c * color) % MOD
        answer += a
    return answer % MOD
N, M, K = map(int, input().split())
print(solve(N, M, K))


Measured memory_bytes: 9260
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define mod 1000000007
#define INF 1000000000000000000
/****************************/
ll n,k;
ll ans=0;
int main()
{
	cin>>n>>k;
	ans=0;
	rep3(i,k,n+2)
	{
		ans+=n*(n+1)/2-(n-i)*(n-i+1)/2-(i-1)*i/2+1;
		ans%=mod;
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc170/tasks/abc170_b>
 問題文============================================================
 B - Crane and Turtle
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int X,Y; cin >> X >> Y;
    for(int a = 0; a <= X; a++){
        int b = X - a;
        if(a*2 + b*4 == Y) return "Yes";
    }
    return "No";
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>

int main(){
  char s[3];
  int a=0,b=0,c=0,i;
  scanf("%s",s);
  for(i=0;i<3;i++){
    if(s[i]=='a') a=1;
    else if(s[i]=='b') b=1;
    else if(s[i]=='c') c=1;
  }
  if(a&&b&&c) printf("Yes\n");
  else printf("No\n");
}

Measured memory_bytes: 128
#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 aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,t,m,n,a)vector<vector<t> > name(m,vector<t> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int n, W;
int weight[4000], value[4000];

// DPテーブル
int dp[4000][4000];

int prev_w[4000][4000];

int main() {
    // 入力受け取り
    cin >> n >> W;
    W--;
    for (int i = 0; i < n; ++i) cin >> weight[i] >> value[i];

    // DPループ
    for (int i = 0; i < n; ++i) {
        for (int w = 0; w <= W; ++w) {

            // i 番目の品物を選ぶ場合を考える
            if (w >= weight[i]) {
                if (dp[i+1][w] < dp[i][w-weight[i]] + value[i]) {
                    dp[i+1][w] = dp[i][w-weight[i]] + value[i];
                    prev_w[i+1][w] = w - weight[i];
                }
            }

            // i 番目の品物を選ばない場合を考える
            if (dp[i+1][w] < dp[i][w]) {
                dp[i+1][w] = dp[i][w];
                prev_w[i+1][w] = w;
            }
        }
    }

    // 最適値の出力
    //cout << dp[n][W] << endl;


    // 復元
    //cout << "Selected items are..." << endl;
    int cur_w = W;
    for (int i = n-1; i >= 0; --i) {
        // 選んでいた場合
        if (prev_w[i+1][cur_w] == cur_w - weight[i]) {
            value[i]=0;
        }

        // 復元テーブルをたどる
        cur_w = prev_w[i+1][cur_w];
    }
    sort(value,value+4000,greater<int>());
    std::cout << value[0]+dp[n][W] << std::endl;
}

Measured memory_bytes: 96512
N, M = map(int,input().split())
A = [[1,int(a)] for a in input().split()]
BC = A + [list(map(int,input().split())) for _ in range(M)]

BC.sort(key=lambda x:x[1], reverse=True)

i = 0
ans = 0
for B,C in BC:
    if i + B <= N:
        ans += B*C
        i += B
    else:
        ans += (N - i) * C
        break

print(ans)

Measured memory_bytes: 45432
n, q = gets.chomp.split.map(&:to_i)
g = Array.new(n)
cnt = Array.new(n, 0)

(n - 1).times do
  a, b = gets.chomp.split.map(&:to_i)
  g[a - 1] ||= []
  g[a - 1] << b - 1
  g[b - 1] ||= []
  g[b - 1] << a - 1
end

q.times do
  p, x = gets.chomp.split.map(&:to_i)
  cnt[p - 1] += x
end

done = Array.new(n, false)
que = [[0, 0]]
while !que.empty?
  cur, c = que.pop
  if done[cur]
    next
  end

  done[cur] = true
  cnt[cur] += c
  g[cur].each do |v|
    que << [v, cnt[cur]]
  end
end

puts cnt.join(" ")

Measured memory_bytes: 43336
N,X = map(int, input().split())
m = [int(input()) for i in range(N)]
cnt = 0

m = sorted(m)
for j in range(len(m)):
    X = X - m[j]
    cnt += 1

while X >= m[0]:
    X = X - m[0]
    cnt += 1

print(cnt)


Measured memory_bytes: 3188
#include <cstdio>

// [lx, rx), [dy, uy)
int solve(int lx, int rx, int dy, int uy, int d, int color, int tx, int ty)  {
    if(lx <= tx and tx < rx and dy <= ty and ty < uy) return color;
    // fprintf(stderr, "[%d, %d), [%d, %d), color = %d\n", lx, rx, dy, uy, color);
    
    if(d == 0) rx += (uy - dy);
    if(d == 1) uy += (rx - lx);
    if(d == 2) lx -= (uy - dy);
    if(d == 3) dy -= (rx - lx);
    return solve(lx, rx, dy, uy, (d+1)%4, (color+1)%3, tx, ty);
}

int main() {
    int x, y; scanf("%d%d", &x, &y);
    printf("%d\n", solve(0, 1, 0, 1, 0, 0, x, y) + 1);
}



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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N; cin >> N;
    vector<int> a(N - 1), b(N - 1);
    Graph G(N);
    map<pair<int, int>, int> edge;
    for(int i = 0; i < N - 1; i++) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    int M = 0, ne = -1;
    for(int i = 0; i < N; i++) {
        if(M < G[i].size()) {
            M = G[i].size();
            ne = i;
        }
    }
    queue<int> q;
    vector<int> visit(N);
    visit[ne] = 1;
    q.push(ne);
    int i;
    vector<set<int>> color(N);
    while(!q.empty()) {
        int u = q.front(); q.pop();
        i = 1;
        for(auto v: G[u]) {
            if(visit[v] != 0) continue;
            visit[v] = 1;
            pair<int, int> w(u, v), x(v, u);
            if(color[u].count(i) || color[v].count(i)) i++;
            edge[w] = i; edge[x] = i;
            color[u].insert(i); color[v].insert(i); 
            q.push(v);
            i++;
        }
    }
    cout << M << endl;
    for(int i = 0; i < N - 1; i++) {
        pair<int, int> p(a[i], b[i]);
        cout << edge[p] << endl;
    }
    return 0;
}

Measured memory_bytes: 36376